akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct node{
    int key;
    struct node *nxt, *pre;
}Node;

Node *nil;

void insert(int key){
    Node *x = (Node *)malloc(sizeof(Node));
    x->key = key;
    x->nxt = nil->nxt;
    nil->nxt->pre = x;
    nil->nxt = x;
    x->pre = nil;
}

void deleteNode(Node *t){
    if(t == nil) return;
    t->pre->nxt = t->nxt;
    t->nxt->pre = t->pre;
    free(t);
}

void delete(int key){
    Node *cur = nil->nxt;
    while(cur != nil && cur->key != key){
      cur = cur->nxt;
    }
    deleteNode(cur);
}

void deleteFirst(){
    deleteNode(nil->nxt);
}

void deleteLast(){
    deleteNode(nil->pre);
}

void init(){
    nil = (Node *)malloc(sizeof(Node));
    nil->nxt = nil;
    nil->pre = nil;
}

void print(){
    Node *cur = nil->nxt;
    int m = 0;
    while(1){
        if(cur == nil) break;
        if(m++ > 0) printf(" ");
        printf("%d", cur->key);
        cur = cur->nxt;
    }
    printf("\n");
}

int main(void){
    int n, i, key;
    char cmd[20];

    scanf("%d", &n);
    init();
    for(i=0; i<n; i++){
        scanf("%s%d", cmd, &key);
        if(cmd[0] == 'i') insert(key);
        else if(cmd[0] == 'd'){
            if(strlen(cmd) > 6){
            if(cmd[6] == 'F') deleteFirst();
            else if(cmd[6] == 'L') deleteLast();
            } else {
            delete(key);
            }
        }
    }
    print();
    return 0;
}

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

int main(){
	int n,m;
	cin>>n>>m;
	int sum=0;
	for(int i=0;i<m;++i){
		int a;
		cin>>a;
		sum+=a;
	}
	if(n-sum>=0)
		printf("%d", n-sum);
	else puts("-1");
}


Measured memory_bytes: 3696
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define deb(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;

typedef long long int ll;
typedef string str;

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

void fast(){
	ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

int main ()
{
	ll t,n,m,k,i,a,b,j;
	cin >> n;
	if(n>=30)
		cout << "Yes\n";
	else
		cout << "No\n";
	return 0;
}

Measured memory_bytes: 3616
using namespace std;

#define visual

#ifdef visual
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <assert.h>
#include <functional>
#include <math.h>
#include <string>
#include <ctime>
#endif
#ifndef visual
#include <bits/stdc++.h>
#endif

typedef long long ll;


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

    int n;
    cin >> n;
    ll tot = 0;
    for (int a = 1; a < n; a++) {
        tot += (n-1) / a;
    }
    cout << tot << endl;
}


Measured memory_bytes: 3648
n = int(input())

scr = [[0,0,0] for _ in range(n+1)]

for i in range(n):
    a,b,c = map(int,input().split())
    scr[i+1][0] = max(scr[i][1],scr[i][2])+a
    scr[i+1][1] = max(scr[i][0],scr[i][2])+b
    scr[i+1][2] = max(scr[i][0],scr[i][1])+c

print(max(scr[n]))

Measured memory_bytes: 22764
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
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;}

int main(){
    int h[3], m[2];
    rep(i, 2){
        cin >> h[i] >> m[i];
    }
    int k;
    cin >> k;
    int ans = 0;
    
    if(h[0] == h[1]){
        ans += m[1]-m[0];
        ans += (h[1]-h[0])*60;
    }
    else if(h[0] < h[1]){
        ans += (60-m[0])+m[1];
        ans += (h[1]-h[0]-1)*60;
    }
    /*else {
        ans += (60-m[0])+m[1];
        ans += (24+h[0]+h[1]-1)*60;
    }*/
    cout << ans-k << endl;
    return 0;
}

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

char a[4][4] = {{'a', 'b', 'c', 'c'}, {'a', 'b', 'd', 'd'}, {'e','e', 'f', 'g'}, {'h', 'h', 'f', 'g'} };
char b[5][5] = {{'a', 'a', 'b', 'b', 'c'}, {'e','.', 'd', 'd', 'c'}, {'e', 'f', '.', '.', 'j'}, {'g', 'f', '.', '.', 'j'}, {'g', 'h', 'h', 'i', 'i'}};
char c[7][7] = {{'a', 'b', 'n', 'n', '.', '.', '.'}, {'a','b', '.', 'm', 'm', '.', '.'}, {'c', 'd', '.', '.', 'l', 'l', '.'}, {'c', 'd', '.', '.', '.', 'k', 'k'}, {'e', '.', 'f', '.', '.', '.', 'j'}, {'e', '.', 'f', '.', '.', '.', 'j'}, {'.', 'g', 'g', 'h', 'h', 'i', 'i'}};
char d[3][3] = {{'.', 'a', 'a'}, {'b', '.', '.'}, {'b', '.', '.'}};


int main(){

    int n;
    cin >> n;
    if(n <= 2){
        cout << -1;
        return 0;
    }

    else{
        vector<vector<char> > out;
        vector<int> ans;
        if(n == 3) ans = {3};
        else if(n == 6) ans = {3, 3};
        else if(n == 7) ans = {7};
        else if(n == 11) ans = {7, 4};
        else{
            while(n % 4){
                ans.push_back(5);
                n -= 5;
            }

            while(n){
                ans.push_back(4);
                n-=4;
            }
        }

        for(auto x: ans){
            out.resize(out.size() + x);
            for(int i = 0; i<out.size(); i++){
                out[i].resize(out.size());
                for(int j = out.size() - x; j<out.size(); j++) out[i][j] = '.';
            }

            for(int i = out.size() - x; i<out.size(); i++){
                for(int j = 0; j<out.size(); j++) out[i][j] = '.';
                for(int j = out.size() - x; j<out.size(); j++){
                    if(x == 3) out[i][j] = d[i - out.size() + x][j - out.size() + x];
                    if(x == 4) out[i][j] = a[i - out.size() + x][j - out.size() + x];
                    if(x == 5) out[i][j] = b[i - out.size() + x][j - out.size() + x];
                    if(x == 7) out[i][j] = c[i - out.size() + x][j - out.size() + x];
                }
            }
        }
        for(int i = 0; i<out.size(); i++){
            for(int j = 0; j<out.size(); j++){
                cout << out[i][j];
            }
            cout << endl;
        }
    }


}




Measured memory_bytes: 2688
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
// 標準入力からデータを読み込む準備
        try (Scanner sc = new Scanner(System.in)) {
            while (true) {
                int n = sc.nextInt();
                if (n == 0) { break; }
                int[] scores = new int[n];
                for (int i = 0; i < scores.length; i++) {
                    scores[i] = sc.nextInt();
                }
                double average = 0, variance = 0;
// ... 平均値averageと，分散varianceを計算しよう ...
                double b=0;
                double s=0;
                for(int i=0; i<scores.length;i++) {
                    s=s+scores[i];
                }
                double a;
                average=s/n;
                for(int i=0; i<scores.length;i++) {
                    a = Math.pow((scores[i] - average), 2);
                    b = a + b;
                }
                variance=b/n;
                System.out.println(Math.sqrt(variance));

            }
        }
     }
}


Measured memory_bytes: 31556
N, K, Q = map(int, input().split())
A = [int(input()) for i in range(Q)]
N_array = [K - Q] * N
for x in A:
    N_array[x - 1] += 1
for z in N_array:
    if z > 0:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 10472
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<V>;
using VVV = vector<VV>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;
template<class T> using VE = vector<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
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; }
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; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
string dfs(ll n, string s) {
	if (n == 0) return s;
	ll Base = 1;
	while (Base * 26 < n) {
		Base *= 26;
	}
	rep(i, 26) {
		ll num = (i + 1) * Base;
		char c = 'a' + i;
		char b = 'a' + i - 1;
		if (num == n) return s + c;
		else if (num > n) return dfs(n - (num - Base), s + b);
		else if (i == 25) return dfs(n - (num - Base), s + b);
	}
}
const int N = 101010;
int main() {
	/*
	ll n;
	cin >> n;
	cout << dfs(n, "") << endl;
	*/
	int n;
	cin >> n;
	int Xor = 0;
	V a(n);
	rep(i, n) {
		cin >> a[i];
		Xor ^= a[i];
	}
	rep(i, n) {
		Xor ^= a[i];
		cout << Xor << " ";
		Xor ^= a[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 4044
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
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; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
    詰まった時に、別の分野の問題として考え直す（これdpでは？、グラフとしてみればいいのでは？）
    多くの問題はパターンマッチだが、パターンに落とし込むまでが難しく、そのための訓練としてわからない問題をあれこれ色々な角度から考察してみるのではないか
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */

class UnionFind{
public:
    //親の番号を格納する。親だった場合はー（その集合のサイズ）
    vector<int> parents;
    int count;

    //作る時はparentsを-1で初期化する
    //こうすることで全部ばらばらになる
    UnionFind(int n){
        parents = vector<int>(n, -1);
        count = n;
    }

    //Aがどのグループにいるか調べる
    int root(int A){
        if(parents[A]<0) return A;
        return parents[A] = root(parents[A]);
    }

    //自分のいるグループの大きさを調べる
    int size(int A){
        return -parents[root(A)];
    }

    //AとBをくっつける
    bool connect(int A, int B){
        //AとBを直接ではなく親同士をくっつける
        A=root(A);
        B=root(B);
        if(A==B){
            return false;
        }

        //大きい方（A)に小さい方（B)をくっつけたい
        if(size(A)<size(B)) swap(A, B);

        parents[A] += parents[B];
        parents[B] = A;
        --count;

        return true;
    }
};

const int inf = 1<<29;
int N;
vector<int> edges[200];
vector<vector<int>> dist(220, vector<int>(220, inf));

bool bipart(){
    UnionFind uf(2*N);
    rep(i, N) for(int j : edges[i]){
        uf.connect(i+N, j);
        uf.connect(j+N, i);
    }
    rep(i, N) if(uf.root(i) == uf.root(i+N)) return false;
    return true;
}

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

    cin >> N; 
    rep(i, N){
        string s; cin >> s;
        rep(j, N){
            if(s[j]=='1'){
                edges[i].push_back(j);
                edges[j].push_back(i);
                dist[i][j] = dist[j][i] = 1;
            }
        }
    }
    rep(i, N) dist[i][i] = 0;

    if(bipart()==false) { cout << -1 << endl; return 0; }
    
    rep(k, N) rep(i, N){
        if(dist[i][k] == inf) continue;
        rep(j, N) {
            if(dist[k][j] == inf) continue;
            chmin(dist[i][j], dist[i][k]+dist[k][j]);
        }
    }

    int ans=0;
    rep(i, N) rep(j, N) chmax(ans, dist[i][j]);
    cout << ans+1 << endl; 
    
    return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <cstdio>
#include <cstdlib>
using namespace std;

struct Node {
	int key;
	Node *right, *left, *parent;
};

Node *root, *NIL;

void insert(int k) {
	Node *x = root;
	Node *y = NIL;
	Node *z;

	z = (Node*)malloc(sizeof(Node));
	z->key = k;
	z->left = NIL;
	z->right = NIL;

	while (x != NIL) {
		y = x;
		if (z->key < x->key) {
			x = x->left;
		}
		else {
			x = x->right;
		}
	}
	z->parent = y;
	if (y == NIL) {
		root = z;
	}
	else {
		if (z->key < y->key) {
			y->left = z;
		}
		else {
			y->right = z;
		}
	}
}

void inorder(Node *u) {
	if (u == NIL) return;
	inorder(u->left);
	cout << " " << u->key;
	inorder(u->right);
}

void preorder(Node *u) {
	if (u == NIL) return;
	cout << " " << u->key;
	preorder(u->left);
	preorder(u->right);
}

int main() {
	int n, x;
	string com;

	scanf("%d", &n);

	for (int i = 0; i < n; ++i) {
		cin >> com;
		if (com == "insert") {
			scanf("%d", &x);
			insert(x);
		}
		else if (com == "print") {
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
	}


	return 0;
}




Measured memory_bytes: 26748
###################
# AC:1102 ms(PyPy)
###################

MOD = 10**9+7
fac = [1, 1]
f_inv = [1, 1]
inv = [0, 1]

def prepare(n, mod):
    for i in range(2, n+1):
        fac.append((fac[-1] * i) % mod)
        inv.append((-inv[mod % i] * (mod//i)) % mod)
        f_inv.append((f_inv[-1] * inv[-1]) % mod)


def modcmb(n, r, mod):
    if n < 0 or r < 0 or r > n:
        return 0

    return fac[n] * f_inv[r] * f_inv[n-r] % mod


def f(r, c):
    return modcmb(r+c, r, MOD)


def main():
    prepare(2*10**6+10, MOD)
    r1,c1,r2,c2 = map(int, input().split())

    ans = 0
    for c in range(c1,c2+1):
        ans += ((r2+1) * modcmb(c+r2+1, r2+1, MOD) - r1 * modcmb(c+r1, r1, MOD)) * pow(c+1, MOD-2, MOD)
        ans %= MOD

    print(ans)


if __name__ == "__main__":
    main()


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

using namespace std;

int main() {
  int N; cin>>N;
  vector<int> a(N+1);
  a[0] = 0;
  for (int i = 1; i <= N; i++) {
    cin >> a[i];
  }
  vector<int> box(N+1, 0);
  int M = 0;

  for (int i = N/2+1; i <= N; i++) {
    box[i] = a[i];
    if (box[i] != 0) M++;
  }

  for (int i = N/2; i >= 1; i--) {
    int sum = 0;
    int index = i;
    for (int j = 2; true; j++) {
      index = i*j;
      if (index > N) break;
      sum += box[index];
    }
    sum %= 2;
    if (sum == a[i]) box[i] = 0;
    else {
      box[i] = 1;
      M++;
    }
  }

  cout << M << endl;
  bool flag = true;
  for (int i = 1; i <= N; i++) {
    if (box[i] == 1) {
      if (flag) {
        cout << i;
        flag = false;
      } else {
        cout << " " << i;
      }
    }
  }
  if (!flag) {
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

// #define int ll
#define REP(i,n) for (int i = 0; i < (n); ++i)
#define FORE(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define debug(x) cerr << #x << ": " << x << '\n'
#define hyphen() cerr << "--\n"

#define ALL(vec) (vec).begin(), (vec).end()
#define REVALL(vec) (vec).rbegin(), (vec).rend()

#define fst first
#define pb push_back

const int MOD = (int)1e9 + 7;
const int INF = numeric_limits<int>::max();

signed main() {
    int N, K;
    cin >> N >> K;

    vector<int> As(N);
    REP(i, N) {
        cin >> As.at(i);
    }

    int ans = INF;

    REP(l, N) {
        int r = l + K - 1;
        if (r >= N) {
            continue;
        }

        // debug(r);
        // debug(l);
        int l2r = abs(As.at(l)) + abs(As.at(r) - As.at(l));
        int r2l = abs(As.at(r)) + abs(As.at(l) - As.at(r));

        ans = min({ans, l2r, r2l});
    }

    cout << ans << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;

const int MAX = 7 * 100 * 1000 + 47;
const double EPS = 1e-8;
const int MOD = 1000 * 1000 * 1000 + 7;

int A[MAX];

int main()
{
    int n;
    scanf("%d", &n);
    FOR(i, 0, n)
        scanf("%d", A + i);

    int st = 0;
    int prev = A[0];
    int ans = 1;
    FOR(i, 1, n)
    {
        if (A[i] > A[i-1] && st == -1)
        {
            st = 0;
            ans++;
        }
        else if (A[i] < A[i-1] && st == 1)
        {
            st = 0;
            ans++;
        }
        else if (A[i] > A[i-1])
        {
            st = 1;
        }
        else if (A[i] < A[i-1])
        {
            st = -1;
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <stdio.h>
using namespace std;

int main() {
	int K, S;
	cin >> K >> S;

	int ans = 0;
	for (int i = 0; i <= K; i++) {						//iはX
		for (int j = 0; j <= K; j++) {					//三つ目の変数ZはS - i - j
			int z = S - (i + j);
			if (i + j + z == S && i <= K && j <= K && 0 <= z && z <= K) {
				ans++;
			}
			
		}

	}
	cout << ans << endl;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
p = list(map(int, input().split()))

s = []
for i in range(K):
    s.append(p[i])

m = sum(s)
t = m
for i in range(K, N):
    t += p[i] - p[i - K]
    if m < t:
        m = t

m += K

print(m / 2)

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

int main(){

    int n;
    cin >> n;
    vector<int> p(n);
    for (int i=0; i<n; i++){
        cin >> p.at(i);
    }

    int cnt = 0;
    for (int i=0; i<n-2; i++){
        if ((p.at(i) < p.at(i+1)) && (p.at(i+1) < p.at(i+2))){
            cnt++;
        }
        if ((p.at(i) > p.at(i+1)) && (p.at(i+1) > p.at(i+2))){
            cnt++;
        }
    }

    cout << cnt << endl;
    return 0;
}

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

typedef long long ll;
int N;
vector<ll> arr;

int main() {
    scanf("%d", &N);
    arr.resize(N);
    for(int i = 0; i < N; i++) {
        scanf("%lld", &arr[i]);
    }

    ll ans = 1e18;
    for(int i = 0; i <= N; i++) {
        ll r = i;
        ll x = 0;
        for(int j = 0; j < N; j++) {
            if(arr[j] + r - N < 0) continue;
            x += (arr[j] + r - N) / (N + 1) + 1;
        }
        ll q = x - r;
        if(q < 0) continue;
        ans = min(ans, q*(N + 1) + r);
    }
    printf("%lld", ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl
#define int ll

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7, M = 998244353;

int dp[3003][3003], a[3003];

signed main()
{
	IO_OP;
	
	int n, s, ans = 0;
	cin >> n >> s;
	for(int i=1;i<=n;i++) cin >> a[i];
	dp[0][0] = 0;
	for(int i=1;i<=n;i++) {
		dp[i][a[i]] += i ;
		for(int j=0;j<=s;j++) {
			dp[i][j] += dp[i-1][j];
			if(j >= a[i]) {
				dp[i][j] = (dp[i][j] + dp[i-1][j-a[i]]) % M;
			}
		}
		ans += dp[i][s];
	}
	cout << ans % M << endl;
}





Measured memory_bytes: 70656
#include<iostream>
#include<cstring>
#include<string>
#include <bitset>
#include <type_traits>
#include <string>
#include <climits>
#include <cmath>



using namespace std;

// long long func(long long a, long long b, long long c){ 
//     long long ret = 0;
//     a %= c; 
//     while (b) { 
//         if (b & 1){
//         	ret = (ret + a) % c; 
//         }  
//         a = (2 * a)%c; 
//         b >>= 1;
//     } 
//     return ret; 
// } 

int main(){
	#ifndef ONLINE_JUDGE
	    // for getting input from input.txt
	    freopen("input.txt", "r", stdin);
	    // for writing output to output.txt
	    freopen("output.txt", "w", stdout);
	#endif

	int n;

	cin >> n;
	cout << !n << endl;

	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long LL;
inline LL in()
{
    LL x = 0, flag = 1; char ch = getchar();
    while (ch < '0' || ch > '9') {if (ch == '-') flag = -1; ch = getchar();}
    while (ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + ch - '0', ch = getchar();
    return x * flag;
}
vector <int> vec[600];
int n, m, q;
int main()
{
    n = in(), m = in(), q = in();
    for (int i = 1; i <= m; i ++)
    {
        int l = in(), r = in();
        vec[l].push_back(r);
    }
    for (int i = 1; i <= 500; i ++) sort(vec[i].begin(), vec[i].end());
    for (int i = 1; i <= q; i ++)
    {
        int l = in(), r = in(), ans = 0;
        for (int j = l; j <= r; j ++)
        {
            int pos = upper_bound(vec[j].begin(), vec[j].end(), r) - vec[j].begin();
            ans += pos;
            // cout << pos << endl;
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <map>
#include <vector>
#include <utility>
#include <cmath>
using namespace std;


map<uint64_t, uint64_t> primeFactorize(const uint64_t n)
{
    map <uint64_t, uint64_t> factors;
    uint64_t nTmp = n;
    uint64_t nSq = (uint64_t) sqrt(n);
    uint64_t i;
    for (i = 2; i <= nSq; ++i)
    {
        while (nTmp > 1)
        {
            if (nTmp % i) break;
            nTmp /= i;
            ++factors[i];
        }
    }
    if (nTmp > 1) factors[nTmp] = 1;
    // if (factors.empty()) factors[n] = 1;
    return factors;
}


uint64_t getSumM(const vector<pair<uint64_t, uint64_t>>* primeFactorP, const uint64_t n, const size_t index, const uint64_t currentProduct)
{
    if (primeFactorP->size() <= index)
    {
        // cout << currentProduct << endl;
        uint64_t m = currentProduct - 1;
        if (m == 0) return 0;
        uint64_t q = n / m;
        uint64_t r = n % m;
        if (q == r)
        {
            // cout << m << endl;
            return m;
        }
        else
        {
            return 0;
        }
    }
    else
    {
        uint64_t sumM = 0;
        uint64_t prime = primeFactorP->at(index).first;
        uint64_t nPrime = primeFactorP->at(index).second;
        uint64_t primeExp;
        for (uint64_t i = 0; i <= nPrime; ++i)
        {
            primeExp = 1;
            for (uint64_t j = 1; j <= i; ++j)
            {
                primeExp *= prime;
            }
            sumM += getSumM(primeFactorP, n, (index + 1), (currentProduct * primeExp));
        }
        return sumM;
    }
}


int main()
{
    uint64_t n;
    cin >> n;

    // 素因数とその個数
    map<uint64_t, uint64_t> primeFactors = primeFactorize(n);
    vector<pair<uint64_t, uint64_t>>* primeFactorsP = new vector<pair<uint64_t, uint64_t>>(primeFactors.size());
    int i = 0;
    for (auto && item: primeFactors)
    {
        primeFactorsP->at(i) = make_pair(item.first, item.second);
        ++i;
        // cout << item.first << "\t" << item.second << endl;
    }

    uint64_t sumM = getSumM(primeFactorsP, n, 0, 1);

    cout << sumM << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <string>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <iterator>
#include <limits>
#include <numeric>
#include <utility>
#include <cmath>
#include <cassert>
#include <cstdio>

using namespace std;
using namespace placeholders;

using LL = long long;
using ULL = unsigned long long;
using VI = vector< int >;
using VVI = vector< vector< int > >;
using VS = vector< string >;
using SS = stringstream;
using PII = pair< int, int >;
using VPII = vector< pair< int, int > >;
template < typename T = int > using VT = vector< T >;
template < typename T = int > using VVT = vector< vector< T > >;
template < typename T = int > using LIM = numeric_limits< T >;

template < typename T > inline istream& operator>>( istream &s, vector< T > &v ){ for ( T &t : v ) { s >> t; } return s; }
template < typename T > inline ostream& operator<<( ostream &s, const vector< T > &v ){ for ( int i = 0; i < int( v.size() ); ++i ){ s << ( " " + !i ) << v[i]; } return s; }
template < typename T > inline T fromString( const string &s ) { T res; istringstream iss( s ); iss >> res; return res; }
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); }

#define REP2( i, n ) REP3( i, 0, n )
#define REP3( i, m, n ) for ( int i = ( int )( m ); i < ( int )( n ); ++i )
#define GET_REP( a, b, c, F, ... ) F
#define REP( ... ) GET_REP( __VA_ARGS__, REP3, REP2 )( __VA_ARGS__ )
#define FOR( e, c ) for ( auto &&e : c )
#define ALL( c ) begin( c ), end( c )
#define AALL( a, t ) ( t* )a, ( t* )a + sizeof( a ) / sizeof( t )
#define DRANGE( c, p ) ( c ).begin(), ( c ).begin() + ( p ), ( c ).end()

#define SZ( v ) ( (int)( v ).size() )
#define EXIST( c, e ) ( ( c ).find( e ) != ( c ).end() )

template < typename T > inline bool chmin( T &a, const T &b ){ if ( b < a ) { a = b; return true; } return false; }
template < typename T > inline bool chmax( T &a, const T &b ){ if ( a < b ) { a = b; return true; } return false; }

#define PB push_back
#define EM emplace
#define EB emplace_back
#define BI back_inserter

#define MP make_pair
#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

bool solve( const int N )
{
	VPII ps( N );
	FOR( p, ps )
	{
		cin >> p.snd >> p.fst;
	}
	sort( ALL( ps ) );

	int w = 0;
	FOR( p, ps )
	{
		w += p.snd;
		if ( p.fst < w )
		{
			return false;
		}
	}
	return true;
}

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

	for ( int N; cin >> N, N; cout << ( solve( N ) ? "Yes" : "No" ) << endl );

	return 0;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

typedef pair<int, int> pp;

pp add(pp a, pp b) // a + b
{
    pp ans;
    ans.first = a.first * b.second + a.second * b.first;
    ans.second = a.second * b.second;
    return ans;
}

bool eq(pp a, pp b) 
{
    return a.first * b.second == b.first * a.second;
}

pp target; // p/q 
int limit, n, cnt;

void search(int num, int now, pp sum, int l) // 
{
    if(num == n) return ;
    for(int i = now; i < limit; i++)
    {
        if(l * i >= limit) break;
        pp tmp = pp(1, i);
        pp next = add(sum, tmp);
        if(eq(next, target)) cnt++;
        else if(next.first / next.second > target.first / target.second) continue;
        else search(num + 1, i, next, l * i);
    }
    return;
}

int main()
{
    int p, q, a;
    while(cin >> p >> q >> limit >> n && n)
    {
        limit++;
        target.first = p; target.second = q;
        cnt = 0;
        for(int i = 1; i < limit; i++)
        {
            pp tmp = pp(1, i);
            if(eq(target, tmp)) cnt++; 
            search(1, i, tmp, i);
        }
        cout << cnt << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll x_1,y_1,x_2,y_2;
  cin>>x_1>>y_1>>x_2>>y_2;
  ll b=x_1-x_2;
  ll a=y_2-y_1;
  cout<<x_2-a<<' '<<y_2-b<<' '<<x_1-a<<' '<<y_1-b<<endl;
  return 0;
}

Measured memory_bytes: 3572
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

struct BoolName : numpunct<char> {
  string t, f;
  BoolName (string t = "Yes", string f = "No") : t(t), f(f) {}
  string do_truename() const {return t;}
  string do_falsename() const {return f;}
};

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15) << boolalpha;
    cout.imbue(locale(cout.getloc(), new BoolName));
  }
} initializer;

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

template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
  for (const T &t : v) s << t << endl;
  return s;
}

void set_bool_name(string t, string f) {
  cout.imbue(locale(cout.getloc(), new BoolName(t, f)));
}

int main() {
  int n;
  cin >> n;
  vector<int> t(n + 1), x(n + 1), y(n + 1);
  for (int i = 0; i < n; ++i) cin >> t[i + 1] >> x[i + 1] >> y[i + 1];
  for (int i = 0; i < n; ++i) {
    int d = abs(x[i] - x[i + 1]) + abs(y[i] - y[i + 1]);
    if (d > t[i + 1] - t[i] || d % 2 != (t[i + 1] - t[i]) % 2) {
      cout << false << endl;
      return 0;
    }
  }
  cout << true << endl;
}



Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using lli = long long int;
using ulli = unsigned long long int;
#define debug(x) cerr << #x << " : " << x << endl

namespace atcoder {
	void judge_outer(bool judge_exp, string ok = "Yes", string ng = "No") {
		if (judge_exp) {
			cout << ok << endl;
		}
		else {
			cout << ng << endl;
		}
	}

	template<typename T>
	T ncr(T left, T right) {
		right = min(left - right, right);
		T ans = 1;
		for (T i = 1; i <= right; i++) {
			ans = ans * (left - right + i) / i;
		}
		return ans;
	}

	const int LIMIT = 1000000007;
	const int tenfive = 100000;
}

using namespace atcoder;

int main() {
	int N;
	cin >> N;
	int stk;
	bool win = false;
	for (int i = 0; i < N; i++) {
		cin >> stk;
		if (stk % 2 == 1) {
			win = true;
		}
	}
	cout << (win ? "first":"second") << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<random>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
//const int inf = 1e9 + 7;
//int dy[] = {0, 0, -1, 1};
//int dx[] = {1, -1, 0, 0};

int main() {
    ll n, m; cin >> n >> m;
    vector<pair<ll, ll> > v(n);
    rep(i, n) {
        cin >> v[i].first >> v[i].second;
    }
    sort(v.begin(), v.end());
    ll sum = 0;
    ll cnt = 0;
    rep(i, v.size()) {
        if (cnt + v[i].second <= m) {
            cnt += v[i].second;
            sum += v[i].first * v[i].second;
        } else {
            
            sum += v[i].first * (m - cnt);
            cnt += m - cnt;
        }
        //cout << cnt << " " << sum << endl;
        if (cnt > m) break;
    }
    cout << sum << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin>>n;
  bool flag=false;
  for(int i=0;i<26;i++){
    for(int j=0;j<16;j++){
      if(4*i+7*j==n) flag=true;
    }
  }
  if(flag==true) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(8)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bitcount __builtin_popcount
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;
typedef vector<pair<int,int> > vii;
typedef vector<int> vi;
typedef pair<int,int> ii;
const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
bool isprime(ll a){
  if(a==2)return 1;
  if(!(a&1))return 0;
  for(ll i=3;i*i<=a;i+=2)
    if(a%i==0)return 0;
  return 1;
}
ll mpow(ll base,ll exponent,ll modulus){
  if(modulus==1)return 0;
  long long result = 1;
  base=base%modulus;
  while(exponent){
    if(exponent%2 == 1)
    result=(result*base)%modulus;
    exponent=exponent>>1;
    base=(base*base)%modulus;
  }
  return result;
}
ll minv(ll a,ll mod){
  ll _gcd=gcd(a,mod);
  assert(_gcd==1);
  return mpow(a,mod-2,mod);
}


/*
ll ncr(ll N,ll K){
  if(N<K)return 0;
  if(K==0)return 1;
  if(N==0)return 0;

  ll den=1;
  for(ll i=1;i<=K;i++)den*=i;
  ll num=1;
  while(K--){
    num*=N;
    if(num%den==0){
      num/=den;
      den=1;
    }
    N--;
  }

  return num;
}
*/
ll n;
ll a[2*MAX];
int main(){FAST;
cin>>n;
for(int i=1;i<=n;++i)cin>>a[i];
ll mi = a[1];
ll ans = 1;
for(int i=2;i<=n;++i){
  if(mi>=a[i])ans++;
  mi = min(mi,a[i]);
}
cout<<ans;
return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <string.h>
#include <vector>
#include <stdlib.h>
#include <cstdint>
#include <cmath>
#include <algorithm>
#include <float.h>
using namespace std;

int n;
int m;

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

	long long mi = min(n, m);
	long long ma = max(n, m);
	if( mi == 1 ) {
		if( ma == 1 ) {
			ans = 1;
		}
		else {
			ans = ma - 2;
		}
	}
	else if( mi == 2 ) {
		ans = 0;
	}
	else {
		ans = (mi - 2) * (ma - 2);
	}

	cout << ans << endl;
 
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
 
#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
 
using namespace std;
//using namespace __gnu_pbds;
 
//typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
 
const int N = 1000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 31;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const int MAX_INT = (1 << 31) - 1;
const double eps = 1e-6;
const double pi = atan2(0, -1);
 
int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("battleship.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(20);
    //int TL = 0.95 * CLOCKS_PER_SEC;
    //clock_t time = clock();
    int n;
    cin >> n;
    map<int, int> m;
    rep(i, 1, n + 1)
    {
        int x = i;
        for (int j = 2; j * j <= x; j++)
            while (x % j == 0)
            {
                m[j]++;
                x /= j;
            }
        if (x > 1)
            m[x]++;
    }
    ll ans = 1;
    for (auto it : m)
        ans = (ans * (it.se + 1)) % MOD;
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
template<class S, class T> inline S chmin(S &a, T b){
  if(a>b){
    a=b;
  }
  return a;
}
int N;
int M;
int A[1000];
int B[1000];
int C[1000];
int d[100][100];
int main(){
  int k;
  int i;
  int j;
  int res = 0;
  rd(N);
  rd(M);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=(0);Lj4PdHRW<(M);Lj4PdHRW++){
      rd(A[Lj4PdHRW]);A[Lj4PdHRW] += (-1);
      rd(B[Lj4PdHRW]);B[Lj4PdHRW] += (-1);
      rd(C[Lj4PdHRW]);
    }
  }
  for(i=(0);i<(N);i++){
    for(j=(0);j<(N);j++){
      d[i][j] = 1073709056;
    }
  }
  for(i=(0);i<(N);i++){
    d[i][i] = 0;
  }
  for(i=(0);i<(M);i++){
    chmin(d[A[i]][B[i]], C[i]);
    chmin(d[B[i]][A[i]], C[i]);
  }
  for(k=(0);k<(N);k++){
    for(i=(0);i<(N);i++){
      for(j=(0);j<(N);j++){
        chmin(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
  for(i=(0);i<(M);i++){
    if(C[i] != d[A[i]][B[i]]){
      res++;
    }
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190921-1

// --- original code ---
// int N, M, A[1000], B[1000], C[1000];
// int d[100][100];
// {
//   int i, j, res = 0;
//   rd(N,M,(A--,B--,C)(M));
//   rep(i,N) rep(j,N) d[i][j] = int_inf;
//   rep(i,N) d[i][i] = 0;
//   rep(i,M){
//     d[A[i]][B[i]] <?= C[i];
//     d[B[i]][A[i]] <?= C[i];
//   }
//   rep(k,N) rep(i,N) rep(j,N) d[i][j] <?= d[i][k] + d[k][j];
//   rep(i,M) if(C[i] != d[A[i]][B[i]]) res++;
//   wt(res);
// }


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

int main(void){
	int r,D,x2000;
	cin >> r >> D >> x2000;
	int cur=r*x2000-D;
	cout << cur << endl;
	for(int i=0;i<9;i++){
		cur=r*cur-D;
		cout << cur << endl;
	}
	return 0;
}

Measured memory_bytes: 888
#include<stdio.h>

int main(void){
    int n,k,q,a[100000]={};
    int win;
    scanf("%d %d %d",&n,&k,&q);
    // for (int i = 0; i < n; i++){
    //     a[i]=k;
    // }
    for (int i = 0; i < q; i++){
        scanf("%d",&win);
        a[win-1]++;
        
        // for (int j = 0; j < n; j++){
        //     if (j!=win-1){
        //         --a[j];
        //     }
        // }
    }
    for (int i = 0; i < n; i++){
        if ((a[i]+k)<=q){
            printf("No\n");
        }else{
            printf("Yes\n");
        }
        
    }
    return 0;
}

Measured memory_bytes: 896
N, M = gets.chop.split.map(&:to_i)
L = Array.new

M.times do
  L << gets.chop.split.map(&:to_i)
end

ans = 0

M.times do |i|
  # i番目を取り除いた配列を作る
  l = L[0,i] + L[i+1,M-1]

  # i番目を取り除いたときのグラフを作る
  h = Hash.new{ |h, k| h[k] = [] }

  l.each do |from, to|
    h[from] << to
    h[to] << from
  end


  visited = {}
  queue = [1]
  until queue.empty?
    vertex = queue.shift

    next unless visited[vertex].nil?
    visited[vertex] = true

    h[vertex].each do |j|
      queue.push(j)
    end
  end

  # すべての頂点に訪れていなかったら橋なので+1
  unless visited.size == N
    ans += 1
  end
end

p ans





Measured memory_bytes: 2172
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <cstdio>
#include <cstdint>
using namespace std;

int_fast8_t d;
uint_fast32_t M = 0;
uint_fast64_t c, sd = -1, sc = -1;
constexpr int buff_size = 1 << 19;
char buff[buff_size], *ci = buff + buff_size, *ce = ci, ct;

inline char read_input() {
    if (ci == ce) { fread_unlocked(buff, 1, buff_size, stdin); ci = buff; }
	return *ci++;
}

int main() {
    while((ct=read_input()) > 47) M = (M<<1) + (M<<3) + ct - 48;
    while(M--) {
        if(ci + 18 > ce) {
            d = read_input() - 48;
            read_input();
            for(c=0; (ct=read_input()) > 47;) c = (c<<1) + (c<<3) + ct - 48;
        } else {
            d = *ci - 48;
            ci += 2;
            for(c=0; *ci > 47;) c = (c<<1) + (c<<3) + *ci++ - 48;
            ci++;
        }
        sc += c;
        sd += c * d;
    }
    printf("%lld", sc + sd / 9);
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
signed main() {
	bitset<64>b(0);
	int q;
	cin >> q;
	while (q--) {
		int k, x, ans;
		cin >> k;
		if (k < 4)cin >> x;
		switch (k) {
		case 0:
			cout << b.test(x) << endl;
			break;
		case 1:
			b.set(x);
			break;
		case 2:
			b.reset(x);
			break;
		case 3:
			b.flip(x);
			break;
		case 4:
			cout << b.all() << endl;
			break;
		case 5:
			cout << b.any() << endl;
			break;
		case 6:
			cout << b.none() << endl;
			break;
		case 7:
			cout << b.count() << endl;
			break;
		case 8:
			cout << b.to_ullong() << endl;
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
const ll inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

template <typename T>
struct edge
{
    int src, to;
    T cost;

    edge(int to, T cost) : src(-1), to(to), cost(cost) {}

    edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

    edge &operator=(const int &x)
    {
        to = x;
        return *this;
    }

    operator int() const { return to; }
};

//Weighted edge set
template <typename T>
using Edges = vector<edge<T>>;

//Weighted graph
template <typename T>
using WeightedGraph = vector<Edges<T>>;

//Unweighted graph (adjacency matrix)
//Initialize : vector<vector<int>>(N, vector<int>(N, 0))
template <typename T>
using UnweightedGraph = vector<vector<T>>;

//distance matrix
template <typename T>
using Matrix = vector<vector<T>>;

#include <vector>
#include <limits>

template <typename T>
vector<T> BellmanFrod(Edges<T> &edges, int N, int source)
{
    const auto INF = numeric_limits<T>::max();
    vector<T> dist(N, INF); //distance from source
    dist[source] = 0;
    for (int i = 0; i < N - 1; i++)
    {
        for (auto &e : edges)
        {
            if (dist[e.src] == INF)
                continue;
            dist[e.to] = min(dist[e.to], dist[e.src] + e.cost);
        }
    }
    vector<bool> neg(N);
    for (auto &e : edges)
    {
        if (dist[e.src] == INF)
            continue;
        if (dist[e.src] + e.cost < dist[e.to])
            neg[e.to] = true;
        if (neg[e.src] == true)
            neg[e.to] = true;
    }
    if (neg[N - 1] == true)
        return vector<T>();
    return dist;
}

int N, M;

int main()
{
    cin >> N >> M;
    Edges<ll> edges;
    for (int i = 0; i < M; i++)
    {
        int a, b;
        ll c;
        cin >> a >> b >> c;
        a--, b--;
        edges.emplace_back(a, b, -c);
    }
    auto v = BellmanFrod(edges, N, 0);
    if (v.size() == 0)
    {
        cout << "inf" << endl;
    }
    else
    {
        cout << -v[N - 1] << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define debug(var) std::cout << #var << " : " << var;
using ll = long long;
using ull = unsigned long long;
ll mod = 1e9 + 7;

int main(){


	int N; std::cin >> N;
	std::vector<int> x(N + 1, 0);
	for(int i = 2; i <= N; i++){
		int tmp = i;
		for(int j = 2; j <= N; j++){
			while(tmp % j == 0){
				x[j]++;
				tmp /= j;
			}
		}
	}

	ull ans = 1;
	rep(i, N + 1){
		ans *= x[i] + 1;
		ans %= mod;
	}

	std::cout << ans;


	return 0;
}

Measured memory_bytes: 256
p[1<<17],h[1<<17],i,I,n;main(k){for(scanf("%*d%d",&k);~scanf("%d",h+n);)p[n]=n++*1e4;for(;I<k+i?:(I=++i)<n;)p[++I]=fmin(p[I],p[i]+abs(h[I]-h[i]));printf("%d",p[n-1]);}

Measured memory_bytes: 896
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int max = 0;
			int cnt = 0;

			for (int i = 0; i < n; i++) {
				if (sc.nextInt() == sc.nextInt()) {
					cnt++;
				} else {
					cnt = 0;
				}
				if (max < cnt) {
					max = cnt;
				}
			}
			if (max >= 3) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		}
	}
}


Measured memory_bytes: 35992
class Table
  def initialize
    @t = []
    8.times do |i|
      @t << Array.new(8, 0)
    end
  end
  def get(x, y)
    @t[y][x]
  end
  def set(x, y)
    @t[y][x] = 1
    8.times do |i|
      8.times do |j|
        if @t[i][j] == 0 && takable?(x, y, j, i)
          @t[i][j] = 2
        end
      end
    end
  end
  def takable?(x1, y1, x2, y2)
    r = (Math.atan2(y2 - y1, x2 - x1) * 180.0 / Math::PI).to_i
    return true if r % 45 == 0
    return false
  end
  def to_s
    @t.map{|row| row.map{|col| if col == 1 then 'Q' else '.' end }.join('') }.join("\n")
  end
end

n = STDIN.gets.chomp.to_i
$default_queens = []
n.times do |i|
  y, x = STDIN.gets.chomp.split(' ').map(&:to_i)
  $default_queens << [x, y]
end

def default_table
  table = Table.new
  $default_queens.each do |q|
    table.set(q[0], q[1])
  end
  table
end

queue = []
queue << []

while true do
  table = default_table
  queens = queue.shift
  last = nil
  queens.each do |q|
    table.set(q[0], q[1])
    last = q
  end
  if queens.size + $default_queens.size == 8
    puts table.to_s
    exit
  end
  8.times do |y|
    next if last && last[1] > y
    8.times do |x|
      next if last && last[1] == y && last[0] >= x
      next if table.get(x, y) != 0
      new_queens = Marshal.load(Marshal.dump(queens))
      new_queens << [x, y]
      queue << new_queens
    end
  end
end

Measured memory_bytes: 9824
# ABC102C - Linear Approximation (ARC100C)
def main():
    N, *A = map(int, open(0).read().split())
    B = [j - i for i, j in enumerate(A, 1)]
    B.sort()
    b = B[N // 2]
    ans = sum(abs(i - b) for i in B)
    print(ans)


if __name__ == "__main__":
    main()

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

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

typedef long long ll;

int main(void) {

	int H, W;
	cin >> H >> W;
	
	char **pixel = new char*[H];
	REP(i,H) pixel[i] = new char[W];

	REP(i, H) {
		REP(j, W) {
			cin >> pixel[i][j];
		}
	}

	char **result = new char*[H+2];
	REP(i, H+2) result[i] = new char[W+2];

	REP(i, H+2) {
		REP(j, W+2) {
			if (i == 0 || j == 0 || i == (H+1) || j == (W+1)) {
				result[i][j] = '#';
			}
			else {
				result[i][j] = pixel[i-1][j-1];
			}
		}
	}

	REP(i, H+2) {
		REP(j, W+2) {
			cout << result[i][j];
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int a, b, c, k, i;

    scanf("%d%d%d", &a, &b, &c);
    scanf("%d", &k);

    for (i = 0; i < k; i++) {
        if (a >= b)
            b *= 2;
        else if (b >= c)
            c *= 2;
        
        if (a < b && b < c)
            break;
    } 

    if (i < k)
        printf("Yes\n");
    else 
        printf("No\n");

    return 0;   
}

Measured memory_bytes: 1624