akhauriyash/Code-Regression huggingface dataset:
/**
*    created: 03.07.2020 02:33:11
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b) {if (b < a) {a = b; return 1;} return 0;}
const long double pi = acos(-1.0);
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int n, a, b;
    cin >> n >> a >> b;
    cout << min(n*a,b) << endl;
    return 0;
}

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

int main() {
	int N, a, ans = 0, tmp[9] = {0};
	cin >> N;
	for (int i = 0; i < N; ++i) {
		cin >> a;
		if (a >= 3200) ++tmp[8];
		else ++tmp[a / 400];
	}
	for (int i = 0; i < 8; ++i) {
		if (tmp[i] > 0) ++ans;
	}
	if (ans == 0) cout << 1;
	else cout << ans;
	cout << " " << ans + tmp[8];
}

Measured memory_bytes: 256
import numpy as np
D = int(input())
s = [input() for i in range(D+1)]
for i in range(0,D+1):
    s[i] = s[i].split()
    s[i] = [int(p) for p in s[i]]
a = []
b = [0]*len(s[0])
S = 0
for i in range (1,D+1):
    ak = []
    for k in range(0,len(s[0])):
        Sk = S
        n = [0]*len(s[0])
        for j in range(0,len(s[0])):
            if j == k:
                n[j] = 0
            else:
                n[j] = b[j] + s[0][j]
        Sk = Sk + s[i][k] - sum(n)
        ak.append(Sk)
    mx = np.argmax(ak)
    an = [0]*len(s[0])
    for j in range(0,len(s[0])):
            if j == k:
                an[j] = 0
            else:
                an[j] = b[j] + s[0][j]
    S = S + s[i][mx] - sum(an)
    a.append(mx+1)
for i in (a):
    print(i)

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

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n, m;
	cin >> n >> m;
	vector<int> a(n);
	vector<int> b(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
	}
	vector<int> c(m);
	vector<int> d(m);
	for (int i = 0; i < m; i++) {
		cin >> c[i] >> d[i];
	}
	for (int j = 0; j < n; j++) {
		int mn = INT_MAX, cp;
		for (int k = 0; k < m; k++) {
			if (abs(a[j] - c[k]) + abs(b[j] - d[k]) < mn) {
				mn = abs(a[j] - c[k]) + abs(b[j] - d[k]);
				cp = k + 1;
			}
		}
		cout << cp << '\n';
	}

	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define ll long long
#define vi vector<int>
#define pi pair<int,int>
#define mp make_pair

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) "FUCK YOU"
#endif

const int mod=1e9+7;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<typename A,typename B> istream& operator>>(istream&,pair<A,B>&);
template<typename A> istream& operator>>(istream&,vector<A>&);
void add(int&,int);
int mul(int,int);
int powz(int,int);
template<typename A> ostream& operator<<(ostream&,vector<A>&);

const int N=500006;

void solve(){
	int n,x;
	cin>>n>>x;
	vi a(n);
	cin>>a;
	
	int ans=1;
	int ind=0;
	int cur=0;
	while(cur<n&&ind+a[cur]<=x&&cur<n){
		
		ind+=a[cur];
		debug(ind);
		cur++;
		ans++;
	}
	cout<<ans;
		

}
	
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int tc=1;
	//~ cin>>tc;
	for(int _=0;_<tc;_++){
		//~ cout<<"Case #"<<_+1<<": ";
		solve();
		if(_!=tc-1)
		cout<<"\n";
	}


}

int mul(int a,int b)
{
	return ((a)*1ll*(b))%mod;
}

void add(int &a,int b)
{
	a+=b;
	if(a>=mod)a-=mod;
	if(a<0)a+=mod;
}

int powz(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1)res=mul(res,a);
		b/=2;
		a=mul(a,a);
	}
	return res;
}

template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
	input>>x.F>>x.S;
	return input;
}

template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
	for(auto& i:x)
		input>>i;
	return input;
}

template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
	for(auto& i:x)
	    output<<i<<' ';
	return output;	
}


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

int main() {
  int n, m, q;
  cin >> n >> m >> q;
  int g[n+1][n+1];
  int dp[n+1][n+1];
  for ( int l = 0; l <= n; l++ ) {
    for ( int r = 0; r <= n; r++ ) {
      g[l][r] = 0;
      dp[l][r] = 0;
    }
  }

  for ( int i = 0; i < m; i++ ) {
    int l, r;
    cin >> l >> r;
    g[l][r]++;
  }

  for ( int l = 1; l <= n; l++ ) {
    for ( int r = 1; r <= n; r++ ) {
      dp[l][r] += dp[l][r-1] + g[l][r];
    }
  }

  for ( int que = 0; que < q; que++ ) {
    int l, r;
    cin >> l >> r;
    int ans = 0;
    for ( int i = l; i <= r; i++ ) {
      ans += dp[i][r] - dp[i][l-1];
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 2944
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;
int N;
int Ans;
char S[99];
int main()
{
  scanf("%s", S);
  for(int I=0;I<strlen(S);I++)
  {
  	N=0;
    for(int J=I;J<strlen(S);J++)
    {
 	  	if(S[J]!='R')
 	  	{
 	  		break;
		}
		N++;
    }
    if(N>Ans)
    {
    	Ans=N;
	}
  }
  printf("%d", Ans);
  return 0;
}

Measured memory_bytes: 3784
#include<bits/stdc++.h>
using namespace std;
#define N 1010
#define ll long long
const ll mod =1e9+7;
double pow(double a,int k)
{
    double res=1;
    while(k)
    {
        if(k&1)
            res=res*a;
        a=a*a;
        k>>=1;
    }
    return res;
}
int main()
{

    double n,k,ans=0;
    cin>>n>>k;
    for(int i=1;i<=n;i++)
    {
        int b=(ceil)(log(k/i)/log(2));
        b=max(b,0);
        ans+=pow(0.5,b);
    }
    printf("%.12f\n",ans/n);
    return 0;
}


Measured memory_bytes: 512
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
B = [a+i for i, a in enumerate(A)]
C = [j-a for j, a in enumerate(A)]
B, C = Counter(B), Counter(C)
ans = 0
for k in B.keys():
    ans += B[k]*C[k]
print(ans)

Measured memory_bytes: 63548
//This Code was made by Chinese_zjc_.
#include <iostream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <bitset>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <map>
#include <set>
#include <ctime>
// #include<windows.h>
#define int long long
#define double long double
using namespace std;
const double PI = acos(-1);
const double eps = 0.0000000001;
const int INF = 0x3fffffffffffffff;
int n, a[2][3];
vector<int> dp;
signed main()
{
    ios::sync_with_stdio(false);
    cin >> n;
    for (int i = 0; i < 2; ++i)
    {
        for (int j = 0; j < 3; ++j)
        {
            cin >> a[i][j];
        }
    }
    dp.assign(n + 1, 0);
    for (int i = 0; i <= n; ++i)
    {
        dp[i] = i;
        for (int j = 0; j < 3; ++j)
        {
            if (i >= a[0][j])
            {
                dp[i] = max(dp[i], dp[i - a[0][j]] + a[1][j]);
            }
        }
    }
    n = dp[n];
    dp.assign(n + 1, 0);
    for (int i = 0; i <= n; ++i)
    {
        dp[i] = i;
        for (int j = 0; j < 3; ++j)
        {
            if (i >= a[1][j])
            {
                dp[i] = max(dp[i], dp[i - a[1][j]] + a[0][j]);
            }
        }
    }
    cout << dp[n] << endl;
    return 0;
}

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl "\n"
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}


void dfs(int now, int plus, vi &ans, const vii &tree, const vi &que, vector<bool> &seen) {
  seen[now] = true;
  plus += que[now];
  ans[now] = plus;
  for(int x: tree[now]) {
    if(seen[x]) continue;
    dfs(x, plus, ans, tree, que, seen);
  }
  return;
}


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

  int n, q;
  cin >> n >> q;
  vii tree(n);
  rep(i,n-1) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    tree[a].push_back(b);
    tree[b].push_back(a);
  }
  vi que(n);
  rep(i,q) {
    int p, x;
    cin >> p >> x;
    p--;
    que[p] += x;
  }
  vi ans(n);
  vector<bool> seen(n);
  dfs(0, 0, ans, tree, que, seen);
  rep(i,n) {
    cout << ans[i] << endl;
  }
}

Measured memory_bytes: 30592
//
// Created by Myabu on 2020/01/27.
//

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <math.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <numeric>
#include <iomanip>

using namespace std;


int main(void){
    int A,B,C;
    cin>>A>>B>>C;
    
    if(C<=A+B){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
typedef vector<int> vi;
typedef long long lint;
typedef unsigned int uint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
typedef unsigned long long ulint;
#define endl '\n'
#define fst first
#define sed second
#define pb push_back
#define mp make_pair
#define rint register int
#define SZ(x) (int((x).size()))
#define all(x) (x).begin(), (x).end()
#define reveal(x) cerr << #x << " = " << (x) << endl
#define rep(it, f, e) for (rint it = (f); it <= (e); ++it)
#define per(it, f, e) for (rint it = (f); it >= (e); --it)
#define repe(it, x) for (auto it = (x).begin(); it != (x).end(); ++it)
const int MAXN = 2e5 + 20;
int a[MAXN], b[MAXN], s[MAXN], t[MAXN], fail[MAXN], res[MAXN];
int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);
	int n;
	cin >> n;
	rep (i, 1, n) {
		cin >> a[i - 1];
	}
	rep (i, 1, n) {
		cin >> b[i - 1];
	}
	a[n] = a[0];
	b[n] = b[0];
	rep (i, 0, n - 1) {
		s[i] = a[i + 1] ^ a[i];
	}
	rep (i, 0, n - 1) {
		t[i] = b[i + 1] ^ b[i];
	}
	int j = fail[0] = -1;
	rep (i, 1, n) {
		while (~j && s[j] != s[i - 1]) j = fail[j];
		fail[i] = ++j;
	}
	j = 0, s[n] = -1;
	rep (i, 0, n * 2 - 2) {
		while (~j && s[j] != t[i % n]) j = fail[j];
		if (++j >= n) {
			res[(n - (i - n + 1)) % n] = 1;
		}
	}
	rep (i, 0, n - 1) if (res[i]) {
		cout << i << ' ' << (b[0] ^ a[i]) << endl;
	}
	return 0;
}

Measured memory_bytes: 8192
using System;
using System.Collections.Generic;
class Program
    {
    	static void Main(string[] args)
    	{
            string[] s1 = Console.ReadLine().Split(' ');
            int r = int.Parse(s1[0]), d = int.Parse(s1[1]), x = int.Parse(s1[2]);
            
            for (int i=0; i<10; i++)
            {
                x = x * r - d;
                Console.WriteLine(x);
            }
            
        }
    }
    //mcs Main.cs
    //mono Main.exe

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define UM unordered_map
#define ALL(a) (a).begin(), (a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
typedef pair<ll, ll> pii;
const ll INF = 1LL << 58;
const ll MOD = 1000000007;
struct Edge
{
    ll s, t, d;
};
typedef vector<vector<Edge>> Graph;
typedef vector<pii> vpii;
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;
}

signed main()
{
    int A, B;
    cin >> A >> B;
    int ans = 0;
    if (A >= B)
    {
        ans += A;
        A--;
    }
    else
    {
        ans += B;
        B--;
    }
    if (A >= B)
    {
        ans += A;
        A--;
    }
    else
    {
        ans += B;
        B--;
    }
    cout << ans << endl;

    // system("pause");
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void)
{
  char str[21], reversed_str[21];
  scanf("%s", str);
  int len = strlen(str);

  int i;
  for(i=0; i<len; ++i){
    reversed_str[i] = str[len-1-i];
  }
  reversed_str[len] = '\0';

  printf("%s\n", reversed_str);

  return 0;
}

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

struct node{
    struct node *right;
    struct node *left;
    struct node *p;
    int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

/* Node treeMinimum(Node x){
   while(x->left != NIL) {
   x = x->left;
   }
   return x;
   } */

/* Node treeSearch(Node x, int k){
   while(x != NIL && k != x->key) {
   if(k < x->key){
   x = x->left;
   }
   else {
   c = x->right;
   }
   return x;
   }

   Node treeSuccessor(Node x){
   Node y;

   if(x->right != NIL){
   return treeMinimum(x->right);
   }
   y = x->p;
   while(y != NIL && x == y->right) {
   x = y;
   y = y->p;
   }
   return y;
   }
   */
/*    void treeDelete(Node z){
      Node y; // node to be deleted
      Node x; // child of y
      if(z->left == NIL || z->right == NIL) {
      y = z;
      }
      else {
      y = treeSuccessor(z);
      }
      if(y->left != NIL) {
      x = y->right;
      }
      else {
      x = y->right;
      }
      if(x != NIL) {
      x->p = y->p;
      }
      if(y->p == NIL) {
      T->root = x;
      }
      else if(y == y->p->left) {
      y->p->left = x;
      }
      else {
      y->p->right = x;
      }
      } */

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

    z = malloc(sizeof(struct 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->p = y;
    if(y == NIL) {
        root = z;  
    }
    else if(z->key < y->key){
        y->left = z;
    }
    else y->right = z;
}

void inorder(Node x){
    if(x->left != NIL){
        inorder(x->left);
    }

    printf(" %d",x->key);
    if(x->right != NIL){
        inorder(x->right);
    }

}

void preorder(Node x){
    printf(" %d",x->key);
    if(x->left!= NIL){
        preorder(x->left);
    }

    if(x->right!= NIL){
        preorder(x->right);
    }
}

int main(){
    int n, i, x;
    char com[20];
    scanf("%d", &n);

    for ( i = 0; i < n; i++ ){
        scanf("%s", com);
        /*  if ( com[0] == 'f' ){
            scanf("%d", &x);
            Node t = treeSearch(root, x);
            if ( t != NIL ) printf("yes\n");
            else printf("no\n");
            } else */ 
        if ( com[0] == 'i' ){
            scanf("%d", &x);
            insert(x);
        } else if ( com[0] == 'p' ){
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        } /*else if ( com[0] == 'd' ){
            scanf("%d", &x);
            treeDelete(treeSearch(root, x));
            } */
    }
    return 0;
}

Measured memory_bytes: 24040
#include <bits/stdc++.h>
 
#define ll long long
#define pb push_back
#define mp make_pair
#define all(X) (X).begin(), (X).end()
 
#define cmp_all(X) (X).begin(), (X).end(), cmp
 
#define B begin()
#define E end()
#define sz size()
#define skip continue
 
#define ppi pair<pair<int, int>, int>
#define pii pair<int, int> 
#define pli pair<ll, int>
 
#define F first
#define S second
 
using namespace std;
 
const int maxn = 1e7 + 17;
const int MAXN = maxn * 4;
const int darr = 1e3 + 17;
const ll INF = 1e17 + 5;
const int mod = 1e9 + 7;
 
void Need_For_Speed () {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

int n, m;

int main () {
	Need_For_Speed();
	cin >> n >> m;
	if (n == 0 || m == 0 || (n < 0 && m > 0)) {
		cout << "Zero";
		return 0;
	}
	if (n > 0 && m > 0) {
		cout << "Positive";
		return 0;
	}
	if ((abs(n) - abs(m) + 1) % 2 == 0) {
		cout << "Positive";
		return 0;
	}
	cout << "Negative";
	return 0;
}

Measured memory_bytes: 256
import collections

n=int(input())
b=[[0,0,0]]
a=[int(i) for i in input().split()]

def my_index(l, x):
    if x in l:
        return l.index(x)
    else:
        return -1

for i in range(n):
    k=my_index(b[-1],a[i])
    if k==-1:
        print(0)
        break
    c=[]
    for j in range(3):
        if j==k:
            c.append(b[-1][j]+1)
        else:
            c.append(b[-1][j])
    b.append(c)
else:
    x=1
    for i in range(n):
        x=x*b[i].count(a[i])%1000000007
    print(x)


Measured memory_bytes: 22628
package main

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

func main() {
	N := nextInt()
	array := nextInts(N)
	max := 0
	c := 0
	for _, v := range array {
		if v >= max {
			c += 1
			max = v
		}
	}
	fmt.Printf("%v", c)
}

func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}

func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}

func nextString() string {
	return nextReader()
}

func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}

func nextInt64s(n int) []int64 {
	r := make([]int64, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt64()
	}
	return r
}

var nextReader func() string

func init() {
	nextReader = NewScanner()
}

func NewScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}

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

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

func MinIn2Values(a int, b int) int {
	if a < b {
		return a
	}
	return b
}

func Abs(a int) int {
	if a < 0 {
		return a * -1
	}
	return a
}


Measured memory_bytes: 640
/*-------enazuma11----------------*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(v) v.begin(),v.end()
#define inc(a,n) sort(a,a+n)
#define dec(a,n) sort(a,a+n,greater<int>() )
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define F first
#define S second
#define M 1000000007
 
/* int x[]={-1,-1,0,1,1,1,0,-1};
int y[]={0,1,1,1,0,-1,-1,-1};
*/
/* int x[]={-1,0,1,0};
int y[]={0,1,0,-1};
*/


int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	int t=1;
//	cin>>t;
	while(t--){
		ll n,m,i,j;
		cin>>n>>m;
		vector<string> v(n);
		rep(i,0,n){
			cin>>v[i];
		}
		ll dp[n][m];
		rep(i,0,n)
		{
			rep(j,0,m)
			dp[i][j]=0;
		}
		dp[0][0]=1;
		rep(i,1,n){
			if(v[i][0]=='.')
			dp[i][0]=dp[i-1][0];
			else
			dp[i][0]=0;
		}
		rep(i,1,m)
		{
			if(v[0][i]=='.')
			dp[0][i]=dp[0][i-1];
			else
			dp[0][i]=0;
		}
		rep(i,1,n)
		{
			rep(j,1,m){
				if(v[i][j]=='#')
				dp[i][j]=0;
				else{
					if(dp[i][j-1]==0)
					dp[i][j]=dp[i-1][j];
					else if(dp[i-1][j]==0)
					dp[i][j]=dp[i][j-1];
					else
					dp[i][j]=(dp[i-1][j]+dp[i][j-1])%M;
				}
			}
		}
		cout<<dp[n-1][m-1]<<'\n';
	}
	return 0;
}


Measured memory_bytes: 9088
#include<cstdio>
typedef long long lger;
inline lger read(){
    lger x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9') {if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') {x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
lger n,num[100050],sum;
int main(){
	n=read();
	for(int i=1;i<=n;i++){num[i]=read();sum+=num[i];}
	if(sum%(n*(n+1)/2)!=0){puts("NO"); return 0;}
	lger round=sum/(n*(n+1)/2);
	lger flag=0;
	if((round-num[1]+num[n])%n!=0||round-num[1]+num[n]<0){puts("NO"); return 0;}
	else flag+=(round-num[1]+num[n])/n;
	for(int i=2;i<=n;i++)
		if((round-num[i]+num[i-1])%n!=0||round-num[i]+num[i-1]<0){
			puts("NO"); return 0;
		}
		else flag+=(round-num[i]+num[i-1])/n;
	puts(flag==round?"YES":"NO");
	return 0;
}

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

int N, M, Q;
int a[50], b[50], c[50], d[50];

int A[10];

int score() {
  int sum = 0;

  for (int i = 0; i < Q; i++) {
    if (A[b[i] - 1] - A[a[i] - 1] == c[i]) {
      sum += d[i];
    }
  }

  return sum;
}

int dfs(int idx, int prev) {
  if (idx == N) {
    return score();
  }

  int max = 0;
  for (int i = prev; i <= M; i++) {
    A[idx] = i;
    max = std::max(max, dfs(idx + 1, i));
  }

  return max;
}

int main(void) {
  std::cin >> N >> M >> Q;
  for (int i = 0; i < Q; i++) {
    std::cin >> a[i] >> b[i] >> c[i] >> d[i];
  }

  std::cout << dfs(0, 1) << std::endl;
}


Measured memory_bytes: 3628
#include <iostream>

using namespace std;

int main(){

	int n = 0;
	bool card[4][13] = { 0 };

	cin >> n;
	
	for (int i = 0; i < n; i++) {

		char kind = 0;
		int num = 0;

		cin >> kind >> num;

		switch (kind) {

		case 'S':
			card[0][num - 1] = true;
			break;
		case 'H':
			card[1][num - 1] = true;
			break;
		case 'C':
			card[2][num - 1] = true;
			break;
		case 'D':
			card[3][num - 1] = true;
			break;

		}

	}

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

		for (int u = 0; u < 13; u++) {

			if (!card[i][u]) {

				switch (i) {

				case 0:
					cout << "S " << u + 1 << endl;
					break;
				case 1:
					cout << "H " << u + 1 << endl;
					break;
				case 2:
					cout << "C " << u + 1 << endl;
					break;
				case 3:
					cout << "D " << u + 1 << endl;
					break;

				}

			}

		}

	}

	return 0;

}



Measured memory_bytes: 3088
#include <algorithm>
#include <utility>
#include <cstring>
#include <cstdio>
#define idx second
typedef std::pair<int, int> data; 
data app[100005]; 
int lst[100005], to[1000005], pre[1000005], tot; 
int low[100005], dfn[100005], st[100005], comp[100005], tp, clk, comp_cnt; 
int pos[100005], x[100005], y[100005], cnt, n; 
int lson[100005], rson[100005], rt, t_cnt; 
bool in_st[100005]; 
inline void add_edge(int u, int v)
{
	to[tot] = v; 
	pre[tot] = lst[u]; 
	lst[u] = tot++;
}
void build(int &u, int l, int r)
{
	if (l == r)
	{
		u = app[l].idx < n ? app[l].idx + n : app[l].idx - n; 
		pos[app[l].idx] = l; 
		return; 
	}
	u = t_cnt++; 
	int m = l + r >> 1; 
	build(lson[u], l, m); 
	build(rson[u], m + 1, r); 
	add_edge(u, lson[u]); 
	add_edge(u, rson[u]); 
}
void modify(int u, int l, int r, int v, int L, int R)
{
	if (L > R)
		return; 
	if (L <= l && r <= R)
	{
		add_edge(v, u); 
		return; 
	}
	int m = l + r >> 1; 
	if (L <= m)
		modify(lson[u], l, m, v, L, R); 
	if (m < R)
		modify(rson[u], m + 1, r, v, L, R); 
}
void tarjan(int u)
{
	dfn[u] = low[u] = clk++; 
	st[tp++] = u; 
	in_st[u] = true; 
	for (int i = lst[u]; ~i; i = pre[i])
	{
		if (-1 == dfn[to[i]])
		{
			tarjan(to[i]); 
			low[u] = std::min(low[u], low[to[i]]); 
		}
		else if (in_st[to[i]])
			low[u] = std::min(low[u], dfn[to[i]]); 
	}
	if (low[u] == dfn[u])
	{
		comp_cnt++; 
		do
		{
			in_st[st[--tp]] = false; 
			comp[st[tp]] = comp_cnt; 
		}
		while (st[tp] != u); 
	}
}
inline bool chk(int d)
{
	for (int i = 0; i < n << 1; i++)
		lst[i] = -1;
	for (int i = 0; i < n; i++)
	{
		int l = std::lower_bound(app, app + cnt, (data){x[i] - d + 1, -1}) - app; 
		int r = std::upper_bound(app, app + cnt, (data){x[i] + d - 1, 1e9}) - app - 1; 
		if (l <= r)
		{
			modify(rt, 0, cnt - 1, i, l, pos[i] - 1); 
			modify(rt, 0, cnt - 1, i, pos[i] + 1, r); 
		}
		l = std::lower_bound(app, app + cnt, (data){y[i] - d + 1, -1}) - app; 
		r = std::upper_bound(app, app + cnt, (data){y[i] + d - 1, 1e9}) - app - 1; 
		if (l <= r)
		{
			modify(rt, 0, cnt - 1, i + n, l, pos[i + n] - 1); 
			modify(rt, 0, cnt - 1, i + n, pos[i + n] + 1, r); 
		}
	}
	memset(dfn, -1, sizeof(dfn)); 
	memset(in_st, 0, sizeof(in_st)); 
	tp = clk = comp_cnt = 0; 
	for (int i = 0; i < t_cnt; i++)
	{
		if (-1 == dfn[i])
			tarjan(i); 
	}
	for (int i = 0; i < n; i++)
	{
		if (comp[i] == comp[i + n])
			return false; 
	}
	return true;
}
int main()
{
	// freopen("ARC069-F.in", "r", stdin); 
	memset(lst, -1, sizeof(lst)); 
	scanf("%d", &n); 
	for (int i = 0; i < n; i++)
	{
		scanf("%d%d", x + i, y + i); 
		app[cnt++] = {x[i], i};
		app[cnt++] = {y[i], i + n}; 
	}
	std::sort(app, app + cnt); 
	t_cnt = cnt; 
	build(rt, 0, cnt - 1); 
	int l = 0, r = 1e9, ans = 0, orig = tot; 
	while (l <= r)
	{
		int m = l + r >> 1; 
		if (chk(m))
		{
			ans = m; 
			l = m + 1; 
		}
		else
			r = m - 1; 
		tot = orig; 
	}
	printf("%d\n", ans);
	return 0; 
}


Measured memory_bytes: 11776
#include <stdio.h>

int main(){
  int i,n;
  int tree[250];

  scanf("%d",&n);

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

  for(i = 1; i <= n; i++){
    if(i == 1) {
    printf("node %d: key = %d, ",i,tree[i]);
    }
    else printf("node %d: key = %d, parent key = %d, ",i,tree[i],tree[i/2]);
    
    if(2*i <= n) printf("left key = %d, ",tree[2*i]);
    if(2*i+1 <= n) printf("right key = %d, ",tree[2*i+1]);
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 600
using System;

class F
{
	static void Main()
	{
		var h = Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
		long l = h[0], a = h[1], b = h[2];
		M = h[3];

		long r = 0, n_min = 0;
		var d_max = (a + (l - 1) * b).ToString().Length;
		for (int d = a.ToString().Length; d <= d_max; d++)
		{
			var d10 = 1L;
			for (int i = 0; i < d; i++) d10 *= 10;
			var n_max = Math.Min(l - 1, (d10 - 1 - a) / b);

			long c = a + n_min * b, n = n_max - n_min + 1;
			n_min = ++n_max;

			var q = new[,] { { d10 % M, 1, 0 }, { 0, 1, 1 }, { 0, 0, 1 } };
			var qn = MPow(q, n);
			r = MMul(qn, new[] { r, c % M, b % M })[0];
		}
		Console.WriteLine(r);
	}

	static long M;

	static long[,] UnitMatrix(int n)
	{
		var r = new long[n, n];
		for (int i = 0; i < n; i++) r[i, i] = 1;
		return r;
	}

	static long[,] MPow(long[,] b, long i)
	{
		for (var r = UnitMatrix(b.GetLength(0)); ; b = MMul(b, b))
		{
			if (i % 2 > 0) r = MMul(r, b);
			if ((i /= 2) < 1) return r;
		}
	}

	static long[,] MMul(long[,] a, long[,] b)
	{
		var n = a.GetLength(0);
		var r = new long[n, n];
		for (var i = 0; i < n; i++)
			for (int j = 0; j < n; j++)
				for (var k = 0; k < n; k++)
					r[i, j] = (r[i, j] + a[i, k] * b[k, j]) % M;
		return r;
	}

	static long[] MMul(long[,] a, long[] v)
	{
		var n = v.Length;
		var r = new long[n];
		for (var i = 0; i < n; i++)
			for (var k = 0; k < n; k++)
				r[i] = (r[i] + a[i, k] * v[k]) % M;
		return r;
	}
}


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

int main(){
	int n;
	cin >> n;
	int num[n];
	for(int i = 0;i < n;i++){
		cin >> num[i];
	}
	/*for(int i = 0;i < n;i++){
		for(int j = i+1;j < n;j++){
			if(num[i] > num[j]){
				int t = num[i];
				num[i] = num[j];
				num[j] = t;
			}
		}
	}*/
	sort(num,num+n);
	int ans = num[n/2] - num[n/2 - 1];
	cout << ans;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
//#include <tr1/unordered_map>
//#include"Bignum/bignum.h"
//#define big bignum
#define lowbit(x) (x & -x)
#define debug(x) (cout << "#x = " << (x) << endl)
#define Set(x, i) memset (x, i, sizeof(x))
#define R register
#define For(i, j, k) for(R int i = (j); i <= (int) (k); ++i)
#define Rep(i, j, k) for(R int i = (j); i >= (int) (k); --i)
#define Cross(i, j, k) for(R int i = (j); i; i = (k))
using namespace std;
typedef long long ll;
const ll N = 311;
const ll INF = 5e16;

namespace IO {

	inline char gc() {
		static char buf[100000], *p1 = buf, *p2 = buf;
		return (p1 == p2) && (p2 = (p1 = buf) +
			fread(buf, 1, 100000, stdin), p1 == p2)? EOF: *p1++;
	}

	#define dd ch = getchar()
	inline ll read() {
		R ll x = 0; R int f = 0; R char dd;
		for (; !isdigit(ch); dd) f ^= (ch == '-');
		for (; isdigit(ch); dd)  x = x * 10 + (ch ^ 48);
		return f? -x: x;
	}
	#undef dd

	inline void write ( ll x ) {
		if (x < 0) x = -x, putchar('-');
		if (x > 9) write(x / 10); putchar(x % 10 | 48);
	}

	inline void wrn ( ll x ) { write(x), putchar(' '); }

	inline void wln ( ll x ) { write(x), putchar('\n'); }

	inline void wlnn ( ll x, ll y ) { wrn(x), wln(y); }

}

using IO::wln;
using IO::read;

namespace Cesare {
	
	/*
		一个 a[i] 被删到 0 需要选他 a[i] 次 
		f[i][j][k] 表示从 (a1, a2, a3) 删到 (i, j, k)
		的期望操作次数。 
	*/
	
	ll a1, a2, a3;
	ll n, S = 0, a[N];
	double Ans, f[N][N][N];
	
	inline double dfs ( ll x, ll y, ll z ) {
		if (f[x][y][z]) return f[x][y][z];
		if (x == 0 && y == 0 && z == 0) return 0;
		
		double res = 1.0 * n / (x + y + z);
		if (x) res += dfs(x - 1, y, z) * x / (x + y + z);
		if (y) res += dfs(x + 1, y - 1, z) * y / (x + y + z);
		if (z) res += dfs(x, y + 1, z - 1) * z / (x + y + z);
//		if (n > 1) res += 1.0 * (x + y + z - 1) * (x + y + z - 1) / (n - 1);
//		cout << "!" << x << " " << y << " " << z << " " << res << endl;
		return f[x][y][z] = res;
	}
	
	int main() {
		n = read();
		For ( i, 1, n ) a[i] = read();
		For ( i, 1, n ) 
			a1 += a[i] == 1, 
			a2 += a[i] == 2, a3 += a[i] == 3;
		dfs(a1, a2, a3);
//		if (n > 1) f[a1][a2][a3] += 1.0 * n / (n - 1);
		return printf("%.8lf\n", f[a1][a2][a3]), 0;
	}
	
}

int main()
{
//	freopen(".in", "r", stdin);
//	freopen(".out", "w", stdout);

	return Cesare :: main();
}

/*

*/






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


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


#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a-1;i>=b;i--)

int main() {
	vector<int> a(9);
	vector<vector<int*>> bingo;
	vector<int*> inner;
	bingo.resize(8);
	inner.resize(3);

	rep(i, 0, 9) {
		cin >> a.at(i);
	}
	rep(i, 0, 8) {
		bingo[i] = inner;
	}

	rep(i, 0, 3) {
		bingo[0][i] = &a[i];
		bingo[1][i] = &a[i+3];
		bingo[2][i] = &a[i+6];

		bingo[3][i] = &a[i * 3];
		bingo[4][i] = &a[1 + i * 3];
		bingo[5][i] = &a[2 + i * 3];

		bingo[6][i] = &a[i * 4];
		bingo[7][i] = &a[(i+1) * 2];
	}

	int n;
	cin >> n;
	rep(i, 0, n) {
		int temp;

		cin >> temp;

		rep(j, 0, 9) {
			if (temp == a[j]) {
				a[j] = -1;
			}
		}

	}
	string ans = "No";

	rep(i, 0, 8) {
		if(*bingo[i][0] == -1 &&
			*bingo[i][1] == -1 &&
			*bingo[i][2] == -1){ 
			ans = "Yes";
		}
	}

	cout << ans << endl;
	

	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<cstring>
#include<cctype>
#include<complex>
#include<algorithm>
#include<iomanip>
#define rep(X,Y) for(int X=0;(X)<(Y);++X)
#define X first
#define Y second
#define pb push_back

using namespace std;

typedef pair<int,int> pii;
typedef pair<int,pii> piii;

const double EPS=1e-8;
typedef complex<double> P;
namespace std{
  bool operator< (const P &a, const P &b){
    return real(a)!=real(b)?real(a)<real(b):imag(a)<imag(b);
  }
}

double cross(const P &a,const P &b){
  return imag(conj(a)*b);
}
double dot(const P &a,const P &b){
  return real(conj(a)*b);
}

struct L : public vector<P>{
  L(const P &a,const P &b){
    pb(a); pb(b);
  }
};

P proj(const L &l,const P &p){
  double t=dot(p-l[0],l[0]-l[1])/norm(l[0]-l[1]);
  return l[0]+t*(l[0]-l[1]);
}

int ccw(P a,P b,P c){
  b-=a; c-=a;
  if(cross(b,c)>EPS) return 1;
  if(cross(b,c)<-EPS) return -1;
  if(dot(b,c)<-EPS) return 2;
  if(norm(b)<norm(c)+EPS) return -2;
  return 0;
}

double intersectSS(const L &s,const L &t){
  return ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1])<=0 &&
    ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1])<=0;
}

double intersectSP(const L &s,const P &p){
  return abs(s[0]-p)+abs(s[1]-p)-abs(s[1]-s[0])<EPS;
}

double distSP(const L &s, const P &p){
  const P r=proj(s,p);
  if(intersectSP(s,r))return abs(r-p);
  return min(abs(s[0]-p), abs(s[1]-p));
}

double distSS(const L &s,const L &t){
  if(intersectSS(s,t)) return 0;
  return min({distSP(s,t[0]),distSP(s,t[1]),distSP(t,s[0]),distSP(t,s[1])});	 
}


int main(){
  int n,m,l;
  while(cin>>n>>m>>l,n){
    vector<vector<L>> st(n);
    cout<<fixed<<setprecision(10);
    int x,y,a,r;
    rep(i,n){
      cin>>x>>y>>a>>r;
      double th=M_PI/2+1.*a*M_PI/180;
      vector<P> ps(5);
      rep(j,5){
	ps[j]=P(x+r*cos(th),y+r*sin(th));
	th+=72.*M_PI/180;
      }
      rep(j,5){
	st[i].pb(L(ps[j],ps[(j+2)%5]));
      }
    }
    
    double d[n][n];
    fill(d[0],d[0]+n*n,1e20);
    rep(i,n)rep(j,n)rep(a,5)rep(b,5)
      d[i][j]=min(d[i][j],distSS(st[i][a],st[j][b]));
    //rep(i,n){rep(j,n)cout<<d[i][j]<<" ";cout<<endl;}
    rep(k,n)rep(i,n)rep(j,n)
      d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
    cout<<d[m-1][l-1]<<endl;
  }
}

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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

int main()
{
    int k,t;
    scanf(" %d %d", &k, &t);

    int max_cake=0;
    rep(i,t)
    {
        int a;
        scanf(" %d", &a);
        max_cake = max(max_cake,a);
    }

    int ans=0;
    if(max_cake>=(k+1)/2+1) ans = 2*max_cake-k-1;
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(x) (x).begin(),(x).end()
#define dup(x,y) (((x)+(y)-1)/(y))
#define sz(x) (int)(x).size()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(){
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> v(n);
    rep(i,q){
        int a;
        cin >> a;
        v[a-1]++; 
    }
    rep(i,n){
        //cout << v[i] << endl;
        if(k > q-v[i]) puts("Yes");
        else puts("No");
    }
    return 0;
}

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

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

    int max = A + B;

    if(max < A - B){
        max = A - B;
    }
    if(max < A * B){
        max = A * B;
    }
    cout << max << endl;  
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;

int N, ans=1234567890;

int digitsum(int k){
    if (k <= 0) return 0;
    return digitsum(k/10) + k%10;
}

int main(){
    scanf("%d", &N);
    for (int i=1; i<=N/2; i++) ans = min(ans, digitsum(i) + digitsum(N-i));
    printf("%d\n", ans);
    return 0;
}


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

int main(){
  if(df) printf("*debug mode*\n");
  string s; cin >>s;
  int n=s.size(); 
  for(int i=0;i<n;i++){
    char a=s.at(i);
    if(i%2==0 && a=='L'){
      cout << "No";
      return 0;
    }
    if(i%2==1 && a=='R'){
      cout << "No";
      return 0;
    }
  }
      cout << "Yes";
      return 0;
}

/// confirm df==0 ///

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};


LL n;
LL dp[100][2][2];

//k:桁,f:いつもの,t:桁上げがあるかどうか
LL rec(int k,bool f,bool t){
    if(k==-1) return !t;
    if(~dp[k][f][t]) return dp[k][f][t];
    LL ret = 0;
    int x = f?((n>>k)&1):1;
    for (int i = 0; i <= x; i++) {
        if(i==0){
            ret = (ret + rec(k-1,f&(x==i),false))%mod; //(v,u)=(0,0)
            if(t){
                ret = (ret + rec(k-1,f&(x==i),true))%mod; //(v,u)=(0,1)
            }
        }
        else{
            if(!t){
                ret = (ret + rec(k-1,f&(x==i),false))%mod; //(v,u)=(1,1)
            }
            ret = (ret + rec(k-1,f&(x==i),true))%mod; //(v,u)=(1,0)
        }
    }
    return dp[k][f][t] = ret;
}


int main(){
    cin >> n;
    LL t = n;
    int k = 0;
    while(t){
        t >>= 1;
        k++;
    }
    memset(dp,-1,sizeof(dp));
    cout << rec(k-1,true,false) << endl;
    return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let mut pairs = vec![];
    for i in 0..n {
        let v = read_vec::<i64>();
        pairs.push((v[0] - 1, v[1]));
    }
    let r_min = pairs.iter().map(|&x| x.1).min().unwrap();
    let l_max = pairs.iter().map(|&x| x.0).max().unwrap();

    let length_max = pairs.iter().map(|&x| x.1 - x.0).max().unwrap();
    let mut ans = length_max + max(0, r_min - l_max);

    pairs.sort_by_key(|x| (x.0, -x.1));

    let mut fl = vec![0; n + 1];
    for i in 0..n {
        fl[i + 1] = max(fl[i], pairs[i].0);
    }
    let mut br = vec![1000_000_000; n + 1];
    for j in (0..n).rev() {
        br[j] = min(br[j + 1], pairs[j].1);
    }
    for i in 1..n {
        let temp = max(0, br[i] - l_max) + max(0, r_min - fl[i]);
        ans = max(ans, temp);
    }
    println!("{}", ans);
}
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 8444
#include<bits/stdc++.h>
#define N 200005
#define inf 1000000000
using namespace std;
struct node {
	int x,y;
}a[N];
int i,j,k,l,n,m,ans,d[N*4][4],f[N*4],s[2][N],x;
inline bool cmp(const node x,const node y) {
	return x.y<y.y;
}
inline void down(int o,int l,int r) {
	for (int i=1;i<=2;i++) {
		f[o*2]=min(f[o*2],d[o][i]+s[i-1][l]);
		d[o*2][i]=min(d[o*2][i],d[o][i]);
		f[o*2+1]=min(f[o*2+1],d[o][i]+s[i-1][r]);
		d[o*2+1][i]=min(d[o*2+1][i],d[o][i]);
		d[o][i]=inf;
	}
}
inline void build(int o,int l,int r) {
	d[o][1]=d[o][2]=inf;
	if (l==r) {
		f[o]=s[1][l];
		return ;
	}
	int mid=(l+r)>>1;
	build(o*2,l,mid),build(o*2+1,mid+1,r);
}
inline void change(int o,int l,int r,int ll,int rr,int w,int p) {
	if (ll>rr) return ;
	if (l==ll&&r==rr) {
		f[o]=min(f[o],s[w-1][l]+p);
		d[o][w]=min(d[o][w],p);
		return ;
	}
	down(o,l,r);
	int mid=(l+r)>>1;
	if (rr<=mid) change(o*2,l,mid,ll,rr,w,p);
	else if (ll>mid) change(o*2+1,mid+1,r,ll,rr,w,p);
	else change(o*2,l,mid,ll,mid,w,p),change(o*2+1,mid+1,r,mid+1,rr,w,p);
}
inline int ask(int o,int l,int r,int ll) {
	if (ll<=0) return 0;
	if (l==ll&&r==ll) return f[o];
	down(o,l,r);
	int mid=(l+r)>>1;
	if (ll<=mid) return ask(o*2,l,mid,ll);
	else return ask(o*2+1,mid+1,r,ll);
}
int main() {
	scanf("%d",&n);
	for (i=1;i<=n;i++) scanf("%d",&x),s[x][i]=s[x][i-1]+1,s[x^1][i]=s[x^1][i-1];
	scanf("%d",&m);
	for (i=1;i<=m;i++) scanf("%d%d",&a[i].x,&a[i].y);
	sort(a+1,a+1+m,cmp);
	j=1;
	build(1,1,n);
	for (i=1;i<=n;i++) {
		while (a[j].y==i) {
			x=ask(1,1,n,a[j].x-1)-s[0][a[j].x-1];
			change(1,1,n,a[j].x,a[j].y,1,x);
			x=ask(1,1,n,a[j].y)-s[1][a[j].y];
			change(1,1,n,a[j].y+1,n,2,x);
			j++;
		}
	}
	printf("%d\n",ask(1,1,n,n));
}

Measured memory_bytes: 16896
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#define rep(i, a) for (int i = 0; i < (a); i++)
using namespace std;


int main(){
    long long int n, h, w, a, b;
    cin >> n >> h >> w;
    long long int count = 0;
    for(long long int i = 0; i < n; i++){
        cin >> a >> b;
        if(a >= h && b >= w){
            count++;
        }
    }
    cout << count << endl;
}


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

const ll MOD = 1e9 + 7;

int mpow(int base, int exp);
typedef  vector<int> vi;
typedef  vector<ll> vll;
typedef  vector<pair<ll,ll>> vpll;
typedef  vector<pair<int, int>> vpii;
typedef  pair<int, int> pii;
typedef  pair<ll, ll> pll;
typedef  unordered_map<ll, ll> umpll;
typedef  unordered_map<int, int> umpii;
typedef  unordered_map<ll, int> umpli;
typedef  unordered_set<int> usi;
typedef  unordered_set<ll> usll;
typedef  set<int> si;
typedef  set<ll> sll;
typedef  set<pair<int, int>> spii;
typedef  set<pair<ll, ll>> spll;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define fo(i,n) for(i = 0;i < n; i++)
#define Fo(i,k,n) for(i = k;k < n ? i < n : i > n; k < n ? i += 1 : i -= 1)
#define deb(x) cout << #x << " = " << x << endl
#define deb2(x, y) cout << #x << " = " << x << ", " << #y << " = " << y << endl
#define deb3(x, y, z) cout << #x << " = " << x << ", " << #y << " = " << y << ", "<< #z << " = " << z << endl

ll randGen(ll lower, ll upper) { return (rand() % (upper - lower + 1)) + lower; }
ll dir[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
// cout << fixed;
// cout.precision(10);
//******************          Function here          *********************//

   void solve(){
      int n, x, t;
      cin >> n >> x >> t;
      if(n % x == 0) cout << (n / x) * t << endl;
     else cout << (n / x + 1) * t << endl;
   }

//*********************************************************************//

int main()
{
    #ifndef ONLINE_JUDGE
      string inputFile, outputFile;
      inputFile = "input.txt";
      outputFile = "output.txt";
      freopen(inputFile.c_str(), "r", stdin);
      freopen(outputFile.c_str(), "w", stdout);
    #endif

    int t = 1;
    // cin>>t;
    while(t-- >0){
      solve();
    }
    return 0;
}



/**********************   Utility Functions  *****************************/
   int mpow(int base, int exp) {
     base %= MOD;
     int result = 1;
     while (exp > 0) {
       if (exp & 1) result = ((ll)result * base) % MOD;
       base = ((ll)base * base) % MOD;
       exp >>= 1;
     }
     return result;
   }
/***********************************************************************/


Measured memory_bytes: 3644
c1= list(map(int, input().split()))
c2 = list(map(int, input().split()))
c3 = list(map(int, input().split()))

a1 = 0
a2 = c2[0] - c1[0]
a3 = c3[0] - c1[0]
b1 = c1[0]
b2 = c1[1]
b3 = c1[2]

if c1[0] == a1 + b1 and c1[1] == a1 + b2 and c1[2] == a1 + b3 and c2[0] == a2 + b1 and c2[1] == a2 + b2 and c2[2] == a2 + b3 and c3[0] == a3 + b1 and c3[1] == a3 + b2 and c3[2] == a3 + b3:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9176
#include <iostream>

using namespace std;

#define MAXN 105
#define MAXK 100005

int arr[MAXN];

bool dp[MAXK];

int main(){

    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cerr.tie(NULL);

    int n,k;cin>>n>>k;

    for(int i=0;i<n;i++)cin>>arr[i];

    for(int i=0;i<=k;i++){
        for(int j=0;j<n;j++){
            if(i>=arr[j] && !dp[i-arr[j]]){
                
                dp[i]=true;

            }
        
        }
    }
    cout<<(dp[k]?"First":"Second")<<endl;

}



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

int main()
{
    string s;
    cin >> s;
    int ans=0;
    for(int i=0;i<s.length();i++)
    {
        int t = 0;
        for(int j=i;j<s.length();j++)
        if( s[j] == 'S' )
            break;
        else
            t++;
        ans = max(t, ans);
    }
    cout << ans ;
}

Measured memory_bytes: 3568
#include<cstdio>
#include<cstring>

int main(void){
	int t=0,ans;
	int f1[30][30],f2[30];
	char s[5],sl;

	memset(f1, 0, sizeof(f1));
	memset(f2, 0, sizeof(f2));
	while(1){
		if(t==0){
			printf("?aaa\n");
			f1[0][0]=1;
		}else{
			for(int i=0;i<26;i++){
				if(f1[sl-'a'][i]==0){
					printf("?%c%ca\n", sl, i+'a');
					f1[sl-'a'][i]=1;
					break;
				}
			}
		}

		t++;
		fflush(stdout);
		scanf("%s",s);
		ans=0;
		sl=s[strlen(s)-1];
		if(s[0]!='a')ans=1;
		else{
			if(strlen(s)==1){//s=*
				if(f2[26]==1)ans=1;
				else f2[26]=1;
			}
			else{//s=**
				if(f2[sl-'a']==1)ans=1;
				else f2[sl-'a']=1;
			}
		}

		if(ans==1){
			printf("!OUT\n");
			break;
		}
	}
	return 0;
}

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

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<char> SLis(n);
    for (int i=0;i<n;i++){
        char s;
        cin >> s;
        SLis[i] = s;
    }
    int ans = 0;
    int p_count = count(SLis.begin(),SLis.end(),'P');
    int w_count = count(SLis.begin(),SLis.end(),'W');
    int g_count = count(SLis.begin(),SLis.end(),'G');
    int y_count = count(SLis.begin(),SLis.end(),'Y');
    if (p_count > 0) ans += 1;
    if (w_count > 0) ans += 1;
    if (g_count > 0) ans += 1;
    if (y_count > 0) ans += 1;
    if (ans==3) cout << "Three" << endl;
    else if(ans==4) cout << "Four" << endl;
}

Measured memory_bytes: 256
#include  <iostream>
    #include  <stdio.h>
    #include <algorithm>
    #include <vector>
    //#include <stack>
    //#include <queue>

    #include <math.h>
    /*
    int standerd = int(pow(10.0,9.0)) + 7;
    */
    using namespace std;
    string ans_Yes = "Yes"; 
    string ans_No = "No"; 
    string ans_yes = "yes"; 
    string ans_no = "no"; 
    

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

        double count=0.0;
        long long abc_count=0;
        long long abc_count2=0;



        //abc_count = N / K ;
        for(int i=K; i<=N; i+=K) abc_count++;
        count += pow(abc_count,3);
        //count += abc_count * max(0,(abc_count - 1)) * 3;
        //count += abc_count * max(0,(abc_count - 1))  * max(0,(abc_count - 2));

        if(K % 2 == 0){

            for(int i=K/2; i<=N; i+=K) abc_count2++;
            //abc_count = N/(K/2) - abc_count;
            //count += abc_count;
            //count += abc_count * max(0,(abc_count - 1)) * 3;
            //count += abc_count * max(0,(abc_count - 1))  * max(0,(abc_count - 2));
            count += pow(abc_count2,3);

        }
        cout << abc_count2 * abc_count2 * abc_count2 + abc_count * abc_count * abc_count;    

    }

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	static class Vertex implements Comparable <Vertex> {
		int id, d0;
		Vertex(int vertex, int d0){
			this.id = vertex;
			this.d0 = d0;
		}
//		public boolean equals(Object v) {
//			return this.id == ((Vertex)v).id;
//		}
		public int compareTo(Vertex v) {
			return this.d0 - v.d0;
		}
	}
	
	static int inf = 100000000;
	public static void main(String args[]){
		try(Scanner sc=new Scanner(System.in)){
			int n = sc.nextInt();  //頂点数
			int[] d = new int[n];  //始点からの距離
			Arrays.fill(d, inf);
			d[0] = 0;
			int[][] length=new int[n][n];//各頂点ごとの距離
			for(int i=0; i<n; i++) {
				int u=sc.nextInt();
				int k=sc.nextInt();
				for(int j=0; j<k; j++){
					int v=sc.nextInt();
					int c=sc.nextInt();
					length[u][v]=c;
				}
			}
			PriorityQueue<Vertex> pq = new PriorityQueue<Vertex>();
			Vertex[] vs = new Vertex[n];
			for(int i=0; i<n; i++) {
				vs[i] = new Vertex(i, d[i]);
				pq.add(vs[i]);
			}
			Map<Integer, Integer> prev=new HashMap<>();
			prev.put(0, 0);
			while(!pq.isEmpty()) { 
				Vertex u = pq.remove();
				if(prev.containsKey(u.id)) {
					int keymin=Math.min(prev.get(u.id), u.d0);
					prev.remove(u.id);
					prev.put(u.id, keymin);
				}
				else {
					prev.put(u.id, u.d0);
				}//mapに小さい値のみいれる
				for(Vertex v: vs) {//vs要素をやっていく
					int alt =  d[u.id]+length[u.id][v.id]; 
					if(length[u.id][v.id] > 0 && d[v.id] > alt) {
						//pq.remove(v);//ここで要素を削除
						d[v.id] = alt;
						pq.add(new Vertex(v.id, alt));
					}
				}
			}
			for(int i=0; i<n; i++) {
				System.out.println(i + " " + prev.get(i));
			}
		}
	}
} 


Measured memory_bytes: 40264
#include <cstdio>

using namespace std;

typedef long long ll;

ll solve(ll a) {
    return (a & 1 ? a >> 1 & 1 ^ 1 : a >> 1 & 1 | a);
}

int main() {
    ll a, b;
    scanf("%lld%lld", &a, &b);
    printf("%lld\n", solve(--a) ^ solve(b));
    return 0;
}


Measured memory_bytes: 128