akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>

using namespace std;

void solve()
{
	int x, y;
	while(cin >> x >> y, x || y)
	{
		int n;
		cin >> n;
		vector< vector<int> > dp(y + 1, vector<int>(x + 1, 1));
		for(int i = 0; i <= y; ++i)
		{
			dp[i][0] = 0;
		}
		for(int i = 0; i <= x; ++i)
		{
			dp[0][i] = 0;
		}
		for(int i = 0; i < n; ++i)
		{
			int x1, y1;
			cin >> x1 >> y1;
			dp[y1][x1] = 0;
		}
		dp[0][1] = 1;
		for(int i = 1; i <= y; ++i)
		{
			for(int j = 1; j <= x; ++j)
			{
				if(dp[i][j])
				{
					dp[i][j] = dp[i][j - 1] + dp[i - 1][j];
				}
			}
		}
		cout << dp[y][x] << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1216
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#define INF 1000000000
using namespace std;
int main() {

	int n; cin >> n; 
	int sm = INF,ans = 0;
	for (int i = 0; i < n; i++) {
		int p; cin >> p;
		if (sm >= p) { ans++; }
		sm = min(sm, p);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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; }

int c[26][50];
int n,mini;
string S;

int main(){
    cin>>n;
    rep(i,n){
        cin>>S;
        rep(j,S.length()){
            c[S[j]-'a'][i]++;
        }
    }
    rep(i,26){
        mini=1e9;
        rep(j,n){
            mini=min(mini,c[i][j]);
        }
        rep(j,mini){
            cout<< char('a'+i);
        }
    }
    out("");
    
}


Measured memory_bytes: 384
function Main(input) {
	input = input.split("\n");
	const n = parseInt(input[0]);
	arr = input[1].split("");

	var b = 0;
	var r = 0;

	for(i=0;i<n;i++) {
		if ( arr[i]=="B" ) {
			b++;
		} else {
			r++;
		}
	}
	//比較
	if (r>b) {
		console.log("Yes");
	} else {
		console.log("No");
	}
	
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 11468
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<vector>
#include<map>

using namespace std;

typedef long long ll;

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

   int T;
   cin >> T;
   ll A[T], B[T], C[T], D[T];

   for (int i = 0; i < T; i++) {
      cin >> A[i] >> B[i] >> C[i] >> D[i];
   }

   for (int i = 0; i < T; i++) {
      bool flg = false;
      ll Atmp = A[i];
      ll Btmp = B[i];
      ll Ctmp = C[i];
      ll Dtmp = D[i];
      if (Atmp < Btmp) {
         // cout << "1" << endl;
         flg = false;
      }
      else if (Btmp > Dtmp) {
         // cout << "2" << endl;
         flg = false;
      }
      else if (Btmp <= Ctmp) {
         // cout << "3" << endl;
         flg = true;
      }
      else {
         ll large = Btmp;
         ll small = Dtmp;
         if (large < Dtmp) {
            large = Dtmp;
            small = Btmp;
         }
         ll Amod = Atmp % gcd(large, small);
         if (Amod < 0) Amod += gcd(large, small);
         
         ll maxid = Btmp / gcd(large, small);
         // cout << "Amod " << Amod << endl;
         // cout << "maxid " << maxid << endl;
         // cout << Amod + gcd(large, small) * (maxid - 1) << endl;
         if (Amod + gcd(large, small) * (maxid - 1) > Ctmp) {
            // cout << "4" << endl;
            flg = false;
         }
         else {
            // cout << "5" << endl;
            flg = true;
         }
      }
      if (flg) cout << "Yes" << endl;
      else cout << "No" << endl;
   }
   return 0;
}


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

struct node{
  int key;
  struct node *p;
  struct node *l;
  struct node *r;
};

typedef struct node *NodePointer;

NodePointer r,NIL;

NodePointer find(NodePointer x,int k){
  while(x != NIL && k != x->key){
    if(k < x->key){
      x = x->l;
    }else{
      x = x->r;
    }
  }
  return x;
}

void insert(int k){
  NodePointer y = NIL;
  NodePointer x = r;

  NodePointer z = (NodePointer)malloc(sizeof(struct node));
  z->key = k;
  z->l = NIL;
  z->r = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key){
      x = x->l;
    }else{
      x = x->r;
    }
  }
  z->p = y;
  
  if(y == NIL){
    r = z;
  }else if(z->key < y->key){
    y->l = z;
  }else{
    y->r = z;
  }
}

void inorder(NodePointer u){
  if(u == NIL){
    return;
  }
  inorder(u->l);
  printf(" %d",u->key);
  inorder(u->r);
}

void preorder(NodePointer u){
  if(u == NIL){
    return;
  }
  printf(" %d",u->key);
  preorder(u->l);
  preorder(u->r);
}

void print(){
  inorder(r);
  puts("");
  preorder(r);
  puts("");
}

int main(){
  int n,i,j,z,x;
  char s[10];

 scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",s);
    if(s[0] == 'f'){
      scanf("%d",&x);
      NodePointer t = find(r,x);
      if(t == NIL)printf("no\n");
      else printf("yes\n");

    }else if(s[0] == 'i'){
      scanf("%d",&z);
      insert(z);
    }else{
      print();
    }
  }

  return 0;
}


Measured memory_bytes: 20456
#include<iostream>
using namespace std;
#include<string>
#include<string.h>
#include<math.h>
#include<iomanip>
#include<vector>
#include<cmath>
#include<algorithm>
#include<numeric>
#include<cctype>
#include<utility>
#include<set>
#include<map>
#include<sstream>
#define pb push_back
#define F(i,a,b) for(int i=a;i<b;++i)
#define Fl(i,a,b) for(long long i=a;i<b;++i)
#define all(v) v.begin(), v.end() 
#define fi first;
#define se second;
#define mp make_pair;
typedef long long ll;
typedef std::vector<int> vec;
typedef std::vector<long long> vecl;
typedef std::pair<int,int> pii;
typedef pair<ll,ll> pll; 



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

// 	int t{};
// 	cin>>t;
// 	while(t--){
// 	    int n{},a{},b{},c{},s{},f{};
// 	    cin>>
// 	}

    int x,a,b=360;
    cin>>x;
    if(b%x==0){
        a=b/x;
    }else{
        for(int i=b/x+1;;++i){
            if((i*x)%b==0){
                a=i;
                break;
            }
        }
    }
    cout<<a<<endl;
    
	return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <map>
#include <set>
using namespace std;

using pint = pair<int,int>;

int main() {
    int H, W, N;
    map<int, set<int> > ma;
    cin >> H >> W >> N;
    for (int i = 0; i < N; ++i) {
        int x, y;
        cin >> x >> y;
        ma[x].insert(y);
    }
    int res = H;
    int left = 1, right = 1;
    for (int x = 2; x <= H; ++x) {
        if (!ma.count(x))  right = min(right + 1, W);
        else {
            int first = *ma[x].begin();
            if (left <= first && first <= right) {
                res = min(res, x - 1);
                break;
            }
            if (first != right + 1) right = min(right + 1, W);
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 28416
N,M=map(int,input().split())
if N>=M:
    print(0)
    exit()
X=[int(i) for i in input().split()]
X.sort()
Y=[X[i+1]-X[i] for i in range(M-1)]
Y.sort()
ans=0
for i in range(M-N):
    ans+=Y[i]
print(ans)


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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

void solve() {
  int n, k; scanf("%d%d", &n, &k);
  printf("%d", (n-1+k-2)/(k-1));
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 3852
#include<bits/stdc++.h>
using namespace std;
int main(){
    string a;
    cin>>a;
    string b=a;
    reverse(a.begin(),a.end());
    for(int i=0;i<a.size();++i){
        if(a[i]=='b') a[i]='d';
        else if(a[i]=='d') a[i]='b';
        else if(a[i]=='p') a[i]='q';
        else if(a[i]=='q') a[i]='p';
    }
    if(a==b) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Range(container) container.begin(), container.end()
#define Cin(T, x) T x; cin >> x;
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i];
#define Cout(val) cout << (val) << "\n";
using namespace std;
using ll = long long;

int main(void){
    Cin(int, n);
    vector<int> x(n), y(n), h(n);
    int io = -1;
    For(i, n){
        cin >> x[i] >> y[i] >> h[i];
        if(h[i] > 0) io = i;
    }
    For(xtop, 101) For(ytop, 101){
        int htop = h[io] + abs(xtop - x[io]) + abs(ytop - y[io]);
        if(htop < 1) continue;
        bool f = true;
        For(i, n){
            if(max(htop - abs(x[i] - xtop) - abs(y[i] - ytop), 0) != h[i]){ f = false; break; }
        }
        if(f){
            cout << xtop << " " << ytop << " " << htop << "\n";
            return 0;
        }
    }
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
#pragma GCC target("sse", "sse2", "avx", "avx2")

#include<bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;
using ull = unsigned long long;

#define int long long
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

void accell() {
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
}
const int mod = 1e9 + 7;
const int K = 120;
const int N = 5000;
int p[N][3];

signed main() {
    accell();
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int>t(n + 1);
    for (int i = 0; i < n; ++i) {
        int aa = 0;
        if (s[i] == 'G')
            aa = 1;
        if (s[i] == 'B')
            aa = 2;
        for (int j = 0; j < 3; ++j) {
            p[i + 1][j] = p[i][j] + (int)(aa == j);
        }
        t[i + 1] = aa;
    }
    int ans = 0;
    for (int i = 1; i <= n; ++i) {
        for (int j = i + 1; j <= n; ++j) {
            if (t[i] == t[j])
                continue;
            int aa[3] = {};
            aa[t[i]]++;
            aa[t[j]]++;
            int cur = 0;
            for (int k = 0; k < 3; ++k) {
                if (aa[k] == 0) {
                    cur = k;
                    break;
                }
            }
            int res = p[n][cur] - p[j][cur];
            if (2 * j - i <= n && cur == t[j + j - i])
                --res;
            ans += res;
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3736
from fractions import gcd


def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))

    g = a[0]
    for i in range(1, n):
        g = gcd(g, a[i])

    mx = max(a)

    if k > mx:
        bl = False

    else:
        if (k - mx) % g == 0:
            bl = True
        else:
            bl = False

    print("POSSIBLE" if bl else "IMPOSSIBLE")


if __name__ == "__main__":
    main()


Measured memory_bytes: 16100
//# define FLAG
///delet....................................
# include <iostream>
# include <cstring>
# include <cstdlib>
# include <cstdio>
# include <cmath>
# include <ctime>
# include <map>
# include <queue>
# include <stack>
# include <vector>
# include <fstream>
# include <algorithm>
using namespace std;
# define bug puts("")
# define pi acos(-1.0)
# define mem(a,b) memset(a,b,sizeof(a))
# define IOS ios::sync_with_stdio(false)
# define FO(i,n,a) for(int i=n; i>=n; --i)
# define FOR(i,a,n) for(int i=a; i<=n; ++i)
typedef unsigned long long ULL;
typedef long long LL;
inline int Scan() {
    int 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;
}
///coding...................................

int main()
{
#ifdef FLAG
    freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
#endif /// FLAG
    LL a,b,x;
    cin>>a>>b>>x;
    if(a)cout<<b/x-(a-1)/x<<endl;
    else cout<<b/x+1<<endl;
    return 0;
}
///delete # define FLAG......................


















Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
ll gcd(ll a,ll b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
int main() {
	ll n,h,w,N,i,j,t;
	scanf("%lld",&N);	
	if(N%2==0) printf("%lld %lld %lld",N/2,N,N);
	else if(N%3==0) printf("%lld %lld %lld",N,N/3*2,N/3*2);
	else {
		for(i=1;i<=3500;i++) {
			for(j=1;j<=3500;j++) {
				t=4*i*j-N*i-N*j;
				if(t<=0) continue;
				if(gcd(t,N*i*j)==t) {printf("%lld %lld %lld",i,j,N*j*i/t);return 0;}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
n = int(input())
blue = list()
for i in range(n):
    blue.append(input())
m = int(input())
red = list()
for j in range(m):
    red.append(input())
ans = 0
for p in range(n):
    cnt = 0
    for q in range(n):
        if blue[p] == blue[q]:
            cnt += 1
    for r in range(m):
        if blue[p] == red[r]:
            cnt -= 1
    ans = max(ans, cnt)
print(ans)

Measured memory_bytes: 9204
use proconio::input;

fn main() {
    input! {
    a:i32,
    b:i32,
    t:i32
    }

    let mut ans = 0;
    for i in 1..=t {
        if i % a == 0 {
            ans += b;
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 2072
#include<bits/stdc++.h>
using namespace std;
     
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int long long int
#define pb push_back
#define endl "\n"
#define ff first
#define ss second
#define N 200009
#define M 15000007
#define mod 1000000007
#define debug cout<<"There There\n";
#define debug1(x) cout<<"\nValue is "<<x<<endl
#define debug2(x,y) cout<<"\nValue is "<<x<<" "<<y<<endl
#define debug3(x,y,z) cout<<"\nValue is "<<x<<" "<<y<<" "<<z<<endl  
#define pq priority_queue<int>
#define mpq priority_queue<int,vector<int>,greater<int>>
#define pr pair<int,int>
#define mx INT_MAX
#define lmx LLONG_MAX
#define err return 0
#define all(a) a.begin(),a.end()

int n;
int a[N];

int32_t main()
{
     IOS;
     cin>>n;
     int usm=0;
     for(int i=0;i<n;i++)
     {    
          cin>>a[i];
          usm+=a[i];
     }
     int mini = mx;
     int sum=0;
     for(int i=0;i<n;i++)
     {    
          cin>>a[i];
          sum+=a[i];
          mini = min(mini,abs(usm-sum-sum));
     }
     cout<<mini<<endl;
}

Measured memory_bytes: 256
n = int(input())
s = input()
#print(s)

tot = s.count('R') * s.count('G') * s.count('B')
#print(tot)

for i in range(n):
    for d in range(1,n):
        j = i+d
        k = j+d
        if k > n-1:
            break
        if s[i]!=s[j]!=s[k]!=s[i]:
            tot -= 1

print(tot)

Measured memory_bytes: 9080
n = int(input())
cs = input()
cnt = 0
i = 0
j = n-1
while(1):
  if i >= j:
    break
  if cs[i] == "R":
    i += 1
  if cs[j] == "W":
    j -= 1
  if cs[i] == "W" and cs[j] == "R":
    cnt += 1
    i += 1
    j -= 1
      
print(cnt)

    

    

Measured memory_bytes: 67528
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <stdio.h>
#include <math.h>
#include <cstdlib>
#include <iostream>
#include <cstdlib>
using namespace std;


int main()
{
   string s;
   int cnt=0;
   cin>>s;
   for(int i=0;i<s.size();i++)
   {
       if(s[2]==s[3]&&s[4]==s[5])
        cnt++;
       break;
   }
    if(cnt>0)
    {
        cout<<"Yes";
    }
    else
        cout<<"No";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
#define ld long douroote
#define pb push_back
#define ll long long
#define INF 0x7f7f7f7f
#define sc(a) scanf("%d",&a)
#define scll(a) scanf("%I64d",&a)
#define scc(a) scanf(" %c",&a)
#define scs(a) scanf(" %s",a)
#define me(a,b) memset(a,b,sizeof a)
#define all(a) a.begin(),a.end()
#define allr(a,n) a,a+n
#define loop(a,s,e) for(ll a=s;a<=e;a++)
#define read_arr(a,s,n) for(ll i=s;i<n+s;i++){sc(a[i]);}
#define read_arr_ll(a,s,n) for(ll i=s;i<n+s;i++){scll(a[i]);}
#define open(in,out) freopen(in,"r",stdin);freopen(out,"w",stdout);
#define err(a,s) cerr<<a<<s;
#define err_arr(a,s,n) for(ll i=s;i<n+s;i++){cerr<<a[i]<<" ";}cerr<<endl;
#define prtll(x) printf("%lld",x);
#define prt(x) printf("%d",x);
using namespace std;
const int N=3e3+55;
ll dp[N][N];
ll a[N];
int n;

ll bt(int l , int r)
{
    if(r<l){return 0;}
	if(l==r)
        return a[l];
	ll &ret=dp[l][r];
    if(ret!=-1)
    return ret;
	ret=max(min(bt(l+2,r)-a[l+1],bt(l+1,r-1)-a[r])+a[l],
            min(bt(l+1,r-1)-a[l],bt(l,r-2)-a[r-1])+a[r]);
	return ret;
}
/**
bt(l+1,r,-1)=min(bt(l+2,r)-a[l+1],bt(l+1,r-1)-a[r])+a[l];
bt(l,r-1,-1)=min(bt(l+1,r-1,1)-a[l],bt(l,r-2)-a[r])
**/
int main()
{
	memset(dp,-1,sizeof dp);
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=0;i<n;i++)
	cin>>a[i];
	cout<<bt(0,n-1)<<endl;
	return 0;
}


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

#define F 0 
#define R 1 
#define B 2 
#define L 3 

using namespace std;

typedef struct {
	int top; 
	int front;
} Dice;

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

int get_dir1(Dice d){
	int tmp;
	if(d.top == 1 || d.top == 6) tmp = 5;
	else tmp = 6;

	if(d.front == tmp) return F;
	if((7-d.front) == tmp) return B;
	if(d.top % 2){
		if(d.front <= 3) return R; 
		else return L;
	}else {
		if(d.front <= 3) return L;
		else return R;
	}
}

int get_dir2(Dice d){
	int tmp;
	if(d.top == 3 || d.top == 4) tmp = 5;
	else tmp = 4;

	if(d.front == tmp) return F;
	if((7-d.front) == tmp) return B;
	if(d.top % 2){
		if(d.front <= 3) return L;
		else return R; 
	}else {
		if(d.front <= 3) return R;
		else return L;
	}
}

Dice next_state(Dice d, int dir){
	Dice nd;
	if(dir == F){
		nd.top = 7-d.front;
		nd.front = d.top;
	}else if(dir == B){
		nd.top = d.front;
		nd.front = 7-d.top;
	}else{
		nd.front = d.front;
		nd.top = 6 - min(d.top, 7-d.top) - min(d.front, 7-d.front);
	}
	return nd;
}

int main(){
	while(1){
		int map[200][200]={0};
		int val[200][200]={0};
		int n; cin >> n;
		if(!n) break;

		for(int i=0; i<n; i++){
			Dice d;
			cin >> d.top >> d.front;
			int x=100, y=100;
			if(map[x][y] == 0){
				map[x][y]++;
				val[x][y] = d.top;
				continue;
			}

			while(1){
				int dir;
				dir = get_dir1(d);
				if(map[x][y] > map[x + dx[dir]][y + dy[dir]]){
					x = x + dx[dir];
					y = y + dy[dir];
					d = next_state(d, dir);
					continue;
				}
				dir = get_dir2(d);
				if(map[x][y] > map[x + dx[dir]][y + dy[dir]]){
					x = x + dx[dir]; 
					y = y + dy[dir];
					d = next_state(d, dir);
					continue;
				}
				map[x][y]++;
				val[x][y] = d.top;
				break;
			}
		}

		int count[7] = {0};
		for(int i=0; i<200; i++){
			for(int j=0; j < 200; j++){
				if(val[i][j] != 0) count[val[i][j]]++;
			}
		}
		for(int i=1; i<=6; i++){
			cout << count[i];
			if(i != 6) cout << " ";
			else cout << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3424
#include <stdio.h>
#define INF 20000000
int array[5001];
int n,i,sum,k=0;
void tansaku(int a)
{
    k += array[a];
    if(k > sum)
    {
        sum = k;
    }
    if(a == n-1)return;
    tansaku(a+1);
}
int main(void)
{
    while(1)
    {
        for(i=0;i<5001;i++)
        {
            array[i] = 0;
        }
        scanf("%d",&n);
        if(n==0)break;
        for(i=0;i<n;i++)
        {
            scanf("%d",&array[i]);
        }
        sum = -INF;
        for(i=0;i<n;i++)
        {
            tansaku(i);
            k = 0;
        }
        printf("%d\n",sum);
    }
    return 0;
}

Measured memory_bytes: 1048
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,n) for (int i=(n-1);i >= 0;i--)
#define all(v) v.begin(),v.end()
#define sz(v) (int)((v).size())
#define MAX(v) *max_element(all(v))
#define MIN(v) *min_element(all(v))
using namespace std; using ll = long long; using P = pair<int,int>;
using vl = vector<ll>; using vvl = vector<vl>;
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cout << H << " ";
    debug_out(T...);
}
#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
    for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
    return os;
}
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
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 ll INF = 1LL << 60;
const ll mod = 1000000007;
const int dx[8] = {1,0,-1,0,1,1,-1,-1}; const int dy[8] = {0,1,0,-1,1,1,-1,-1};

ll n,m,q;
vl a(50),b(50),c(50),d(50);
ll ans;
vl s(10);

void dfs(ll i,ll v){
    if(v>m) return;
    s[i] = v;
    if(i==n-1){
        ll tmp = 0;
        rep(j,q){
            if(s[b[j]]-s[a[j]]==c[j]) tmp+=d[j];
        }
        chmax(ans,tmp);
        return;
    }
    rep(j,m) dfs(i+1,v+j);
    return;
}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> n >> m >> q;
    rep(i,q){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--; b[i]--;
    }
    rep(i,1,m+1) dfs(0,i);
    cout << ans << endl;
}

Measured memory_bytes: 3608
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include<iomanip>

//#include<bits/stdc++.h>

using namespace std;


int main() {

	int n;
	cin >> n;
	int ans = 1, y = 1;
	while (1) {
		if (y > n)break;
		y *= 2;
		if (y > n)break;
		ans=y;
	}
	cout << ans << endl;
	return 0;
	
}


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

/*
,,,,
　　　　　　　　　　　　　　　　　　　　　　　　　　,.斗*''“i:i:{
　　　　　　　　　　　　　,.　｡. . . * : : : ''' : : : :” :”“ ''ｰ - 弋,,_
　　　　　 　 　 ,.斗*''“ : : : : : : : : : : : : : ' ' ' ' ' ' : : : : : : : : : : :”: '':* ｡ ,
　　　 ,.斗*''“ ” ＼：　　 ”・・． ' ' ' '　　　　　　　　 ' ' ' ' : : : : : : : : : : : : ”ミ*｡,,,,,,　　　　　　 　 　 　 ＿
　　く.　 ◎　 ﾞ:.ﾞ:..　ﾟ:,　:　───────────　　　--　　,,,,,,__ ' ' ' :.:.:.:.:.”≧s｡.　　＿,,,｡s*i:i:i:i:<
　　ﾏ*s｡ :,　 }　ﾟ:,　 :}　　　　　　　　　　　　　　　　　　　　　　　　　　　　”　''　-　”””：：”：：`*｡i:i:i:i:i:i:i;:’
　　　` .｡`　 ,　,ノ ／｡ ,,,_　　　　　　　　　　　　　　　　　　　　　　　　　　　　　＿＿`　　} }　　ﾉi:i:i:i:i:ﾂ
　　　　　 `　*　｡　　`*｡i:i:i::*=-　　　　　　　　　　　＿＿　　　　　　,,,....｡s*'i,:’　　　”`*｡＿,*’i:i:i:i:r’
　　　　　　　　　　　”　─ --　　　　｡｡｡｡｡　　 -　－`''''''''ヽ ─ '''”　　　｀ｰ“　　　　　　　`*｡i:i:i:i:i:i:
　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　`*｡i:i:::
　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　`*ﾟ:,
         fozubaoyou    no BUGs alive!
*/

typedef long long ll;
//{
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define dumo dump
#define sd pop_back
//}

#define debug_interval ','
#define dump_interval endl
#define debug_toggle 0

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cout<<endl;}
template<class...A> inline void debug_rest() {cout<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cout<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cout<<first,debug_rest(rest...);}
//}

int a,b,c,d;
string s,t;

int main(){
    cin>>a>>b;
    c=b-a;
    while(c){
        d+=c;
        c--;
    }
    dump(d-b);
}


Measured memory_bytes: 256
n, t = map(int, input().split())
ab = []
for _ in range(n):
    ab.append(list(map(int, input().split())))

ab.sort(key=lambda x:x[0])

dp = [-1]*(t+1)
dp[0] = 0

for a, b in ab:
    tmp = dp[:]
    for i in range(t):
        if dp[i] >= 0 and dp[i]+b > tmp[min(i+a, t)]:
            tmp[min(i+a, t)] = dp[i]+b
    dp = tmp
print(max(dp))

Measured memory_bytes: 47592
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<algorithm>
#include<utility>
#include<map>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1001001001;
const double PI = acos(-1);

ll pow_mod(ll p, ll n, ll m) {
	if (n == 0) return 1;
	else if (n == 1) return p % m;
	else if (n % 2 == 1) return p * pow_mod(p, n - 1, m) % m;
	else {
		ll tmp = pow_mod(p, n / 2, m);
		return (tmp * tmp) % m;
	}
}

ll gcd(ll x, ll y) {
	if (y == 0) {
		return x;
	}
	return gcd(y, x % y);
}

ll com_mod(ll n, ll k, ll m) {
	if (k == 0) return 1;
	else {
		ll x = 1;
		ll y = 1;
		for (ll i = 0; i < k; i++) {
			x = (x * (n - i)) % m;
			y = (y * (i + 1)) % m;
		}
		ll res = (x * pow_mod(y, m - 2, m)) % m;
		return res;
	}
}

int main() {
	string s, t; cin >> s >> t;
	if (t.substr(0, s.size()) == s) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a,b,x,y;
  cin >> n >> a >> b;
  if(a<b){
    x = a;
  }else{
    x = b;
  }
  if(a+b-n<0){
    y = 0;
  }else{
    y = a+b-n;
  }
  cout << x << " " << y << endl;
}

Measured memory_bytes: 256
// g++ -I ~/Documents/programming/cppLib -std=gnu++14 -o test ~/Documents/programming/cppLib/test.cpp && ./test && rm test
#include <bits/stdc++.h>
using namespace std;
template <typename T> using vector2 = vector <vector  <T>>;
template <typename T> using vector3 = vector <vector2 <T>>;
template <typename T> using vector4 = vector <vector3 <T>>;
using lint = long long;
#define FOR( i, a, b ) for( lint i=(a) ; i < (b) ; ++i )
#define REP( i, n )    for( lint i= 0  ; i < (n) ; ++i )
#define ALL( v )       (v).begin(), (v).end()


int main() {
    int A, P;
	cin >> A >> P;
    cout << (A*3 + P) / 2 << endl;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define each(it,n) for(__typeof((n).begin()) it=(n).begin();it!=(n).end();++it)

using namespace std;

int main() {
    long long n, m;
    cin >> n;

    vector<long long> a(n);
    rep(i, n) cin >> a[i];
    cin >> m;
    vector<pair<pair<long long, long long>, long long> > p(m);

    rep(i, m) {
        p[i].second = i;
        cin >> p[i].first.first;
    }
    rep(i, m) {
        cin >> p[i].first.second;
    }
    sort(a.begin(), a.end());
    sort(p.begin(), p.end());

    vector<bool> ans(m);
    long long sum = 0;

    int i = 0, j = 0;
    while (j < m) {
        if (i < n && a[i] <= p[j].first.first) {
            sum += a[i];
            i++;
        } else {
            ans[p[j].second] = ((long long)p[j].first.second <= sum);
            j++;
        }
    }

    rep(i, m) {
        cout << (ans[i] ? "Yes" : "No") << endl;
    }

    return 0;
}

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

using lint = unsigned long long;

constexpr int X = 20;

void solve() {
    int n;
    std::cin >> n;

    std::vector<lint> dp(X + 1, 0);
    auto ndp = dp;

    int x;
    std::cin >> x;
    dp[x] = 1;

    for (int i = 1; i < n - 1; ++i) {
        int d;
        std::cin >> d;

        std::fill(ndp.begin(), ndp.end(), 0);
        for (int x = 0; x <= X; ++x) {
            for (int sign : {-1, 1}) {
                int nx = x + sign * d;
                if (nx < 0 || X < nx) continue;
                ndp[nx] += dp[x];
            }
        }

        std::swap(dp, ndp);
    }

    std::cin >> x;
    std::cout << dp[x] << "\n";
}

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

    solve();

    return 0;
}



Measured memory_bytes: 3220
#include<stdio.h>
int main(){
    int n,i;
    scanf("%d",&n);
    int a[n+1];
    for(i=1;i<n+1;i++)scanf("%d",&a[i]);

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


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

int main() {
	string s;
	getline(cin, s);
	
	if(s[2] == s[3] && s[4] == s[5]) {
		cout << "Yes";
	} else {
		cout << "No";
	}
	return 0;
}

Measured memory_bytes: 3628
//#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

//うーん

void pakuri_sort(int N, int A[]) {
	const int b = 8;
	int tmp[1 << 18];
	rep(k, 4) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
	}
}

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

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


	int N = getint();
	int n = (1 << N);
	int S[1 << 18];
	rep(i, (1 << N)) {
		S[i] = getint();
	}
	pakuri_sort(n, S);
	int A[1 << 17];
	A[0] = S[n - 1];
	int OK = 1;
	rep(i, N - 1) {
		int p = n - (1 << i);
		for (int j = (1 << i) - 1; j >= 0; j--) {
			while (p >= 0 && S[p] >= A[j]) p--;
			if (p < 0) {
				OK = 0;
				break;
			}
			A[j + (1 << i)] = S[p];
			S[p] = 1e9;
			p--;
		}
		if (!OK) break;
		pakuri_sort(n - (1 << i) - p - 1, S + p + 1);
		pakuri_sort(1 << (i + 1), A);
	}
	int i = N - 1;
	int p = n - (1 << i);
	for (int j = (1 << i) - 1; j >= 0; j--) {
		while (p >= 0 && S[p] >= A[j]) p--;
		if (p < 0) {
			OK = 0;
			break;
		}
		S[p] = 1e9;
		p--;
	}

	if (OK) printf("Yes");
	else printf("No");

	Would you please return 0;
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;

int main(){
  int H,W,D; cin>>H>>W>>D;
  int d=D*2;
  rep(i,H){
    string ans="";
    rep(j,W){
      int r=(i+j)%d, c=((i-j)%d+d)%d;
      if(r<D){
        if(c<D) ans+="R";
        else ans+="Y";
      }else{
        if(c<D) ans+="G";
        else ans+="B";
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
int main(void){
    int a[5];
    int flg[4];
    int i;
    
    while(1){
        scanf("%d",&a[0]);
        if(a[0]==0){
            break;
        }
        for(i=1;i<4;i++){
            flg[i]=0;
        }
        
        flg[a[0]]++;
        for(i=1;i<5;i++){
            scanf("%d",&a[i]);
            flg[a[i]]++;
        }
        
        if(flg[1]==5 || flg[2]==5 || flg[3]==5 || flg[1]*flg[2]*flg[3]!=0){
            printf("3\n3\n3\n3\n3\n");
            continue;
        }
        
        if(flg[1]==0){
            for(i=0;i<5;i++){
                if(a[i]==2){
                    puts("1");
                }
                else puts("2");
            }
        }
        
        if(flg[2]==0){
            for(i=0;i<5;i++){
                if(a[i]==3){
                    puts("1");
                }
                else puts("2");
            }
        }
        
        if(flg[3]==0){
            for(i=0;i<5;i++){
                if(a[i]==1){
                    puts("1");
                }
                else puts("2");
            }
        }
        
    }
    return 0;
}

Measured memory_bytes: 580
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long
#define si(n) scanf("%d",&n);
#define PI acos(-1.0)
#define sl(n) scanf("%lld",&n);
#define sf(n) scanf("%lf",&n);
#define ss(n) scanf("%s",n);
#define for0(i,n) for(ll i=0;i<n;i++)
#define for1(i,n) for(ll i=1;i<=n;i++)
#define forc(i,j,n) for(ll i=j;i<n;i++)
#define pb push_back
#define sor(n) sort(n.begin(),n.end())
#define sorcmp(n) sort(n.begin(),n.end(),cmp)
#define rev(n) reverse(n.begin(),n.end())
#define pi(x)  printf("%d",x);
#define pl(x)  printf("%lld",x);
#define pf(x)  printf("%.10lf",x);
#define ps(x)  printf("%s",x);
#define en() printf("\n");
#define random_shuffle(r...)random_shuffle(r,[](int _){return rand()%_;})
#define SQR(a) (a)*(a)
#define sp(x) fixed<<setprecision(x)
#define mod 1000000007
#define endl '\n'
#define pii pair<int,int>
#define pll pair<ll,ll>
#define bug cout<<"Here"<<endl
void fastio(){ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}
template <typename T> T POW(T B,T P){ if(P==0) return 1; if(P&1) return B*POW(B,P-1);  else return SQR(POW(B,P/2));}
ll powmod(ll a, ll b){ll ans = 1;while(b){if(b&1) ans = ans*a%mod;a = a*a%mod;b >>= 1;}return ans;}


int main()
{

	int n;
	cin>>n;

	ll ans=0;

	for(int i=1;i<=n;i++)
    {
        int ok=n/i;

        ans+=ok;
        if(n%i==0) ans--;
    }

    cout<<ans<<endl;





	return 0;
}




Measured memory_bytes: 3596
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
typedef long long lng;
#define FOR(i,a,b) for(int i=(a); i<=(b); ++i)
#define FORD(i,b,a) for(int i=(b); i>=(a); --i)
#define REP(i,n) FOR(i,0,n-1)
#define ALL(a) (a).begin(), (a).end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end()) //NOTE: <a> must be sorted in advance

lng power(lng b, lng n) {lng sol=1; while(n>0) {if(n&1) {sol=sol*b;} n>>=1; b*= b;} return sol;} //calculate b^n

const int MOD = 1000000007; //10^9+7


/*********** variables ************/
int N;
/**********************************/

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    int ans = N*800;
    ans -= 200*(N/15);
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#define p 1000000007
using namespace std;
int main()
{
    int i,j;
    int r,c;
    char arr[1001][1001];
    cin>>r>>c;
    for(i=1;i<=r;i++)
    for(j=1;j<=c;j++)
    cin>>arr[i][j];
    int grid[r+1][c+1];
    memset(grid,0,sizeof(grid));
    for(i=1;i<=r;i++)
    {
        if(arr[i][1]=='.')
        grid[i][1] = 1;
        else
        break;
    }
    for(i=1;i<=c;i++)
    {
        if(arr[1][i]=='.')
        grid[1][i] =1;
        else
        break;
    }
    for(i=2;i<=r;i++)
    for(j=2;j<=c;j++)
    {
        if(arr[i][j]=='#')
        continue;
        
        if(grid[i-1][j])
        grid[i][j] = (grid[i-1][j]+grid[i][j])%p;
        if(grid[i][j-1])
        grid[i][j] = (grid[i][j-1]+grid[i][j])%p;
    }
    cout<<grid[r][c]<<endl;
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
//const int mod=998244353;
using P = pair<int,int>;
using Pll = pair<ll,ll>;
using ld=long double;
using V=vector<int>;
using Vl=vector<ll>;
using VV=vector<vector<int>>;
using VVl=vector<vector<ll>>;

int main(){
   int n;cin >>n;
   string s;cin >>s;
   ll r,g,b;r=g=b=0;
    for (int i = 0; i < n; ++i) {
        if(s[i]=='R')r++;
        if(s[i]=='G')g++;
        if(s[i]=='B')b++;
    }
    ll ans=r*g*b;
    for (int i = 0; i < n; ++i) {
        for (int j = i+1; j < n; ++j) {
            int k=2*j-i;
            if(k>=n)continue;
            if(k<0)continue;
            if(s[i]!=s[j]and s[j]!=s[k] and s[i]!=s[k])ans--;
        }
    }
    cout <<ans <<endl;
}


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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int N, M;
	cin >> N >> M;
	cout << ((N - M) * 100 + M * 1900)*(int)pow(2, M) << endl;

	return 0;
}

Measured memory_bytes: 256
"""
author : halo2halo
date : 9, Jan, 2020
"""

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

DISH = [int(readline()) for _ in range(5)]
Ceiled = [(i + 9) // 10 * 10 for i in DISH]
div = [y - x for x, y in zip(DISH, Ceiled)]

print(sum(Ceiled)-max(div))


Measured memory_bytes: 3060
n,k = map(int,input().split())
if  n < k:
  l = abs(k-n)
  if l > n:
      print(n)
  else:
      print(l)

else:
  p = (n+k)%k
  q = abs(p-k)
  if p > q:
    print(q)
  else:
    print(p)


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

typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector <ll> vi;
typedef vector <pi> vpi;
#define f first
#define s second
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0)
#define maxn 200001
#define int ll
int N;

int32_t main(){
	fast;
	cin>>N;


	FOR(i,1,N){
		int x = i * 2;
		int ans = 0;
		FOR(a,2,sqrt(2 * i) + 1){
			FOR(b,2,sqrt(2 * i) + 1){
				if (a * a + b * b > x) continue;
				
				int c = sqrt(x - a * a - b * b);
				
				if (a * a + b * b + c * c != x) continue;
				if ((a + b - c) % 2 == 1 || (a - b + c) % 2 == 1 || (-a + b + c) % 2 == 1) continue;
				
				int x = (a + b - c) / 2;
				int y = (a - b + c) / 2;
				int z = (- a + b + c) / 2;
				if (x < 1 || y < 1 || z < 1) continue;
				
				ans += 1;
				
			}
		}
		cout<<ans<<'\n';
	}
		
	
	
}


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

bool isGoodInteger(int n){
  int pattern1 = n / 10;
  int pattern2 = n % 100;
  array<int, 2> ar{pattern1, pattern2};
  
  for(auto itr = ar.cbegin(); itr != ar.cend(); ++itr)
  {
    if(0 == ((*itr) % 111)){
      return true;
    }
  }
  return false;
}

int main() {
  int n;
  cin >> n;
  
  if(isGoodInteger(n)){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import collections

N, K = list(map(int, input().split()))
A = list(map(int, input().split()))

count_rmv = 0
count_int = collections.Counter(A).most_common()
num_int_type = len(count_int)

while num_int_type > K:
    num_int_type -= 1
    count_rmv += count_int[num_int_type][1]

print(count_rmv)


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

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


Measured memory_bytes: 2684
from collections import deque
import copy
H,W=map(int, input().split())
Ch,Cw=map(int, input().split())
Dh,Dw=map(int, input().split())
S=[list(str(input())) for i in range(H)]

field2=copy.deepcopy(S)
move=[[1,0],[-1,0],[0,1],[0,-1]]
ans=0
temp=deque()

def dfs2(x,y):
    field2[x][y]='#'
    temp.append([x,y])
    for i in range(4):
        nx=x+move[i][0]
        ny=y+move[i][1]
        if 0<=nx and nx<H and 0<=ny and ny<W and field2[nx][ny]=='.':
            dfs2(nx,ny)
    return temp

start=dfs2(Ch-1,Cw-1)

while True:
    if field2[Dh-1][Dw-1]=='#':
        print(ans)
        exit()
    else:
        for i in range(len(start)):
            ttemp=start.popleft()
            for hh in range(-2,3):
                for ww in range(-2,3):
                    nnx=ttemp[0]+hh
                    nny=ttemp[1]+ww
                    if 0<=nnx and nnx<H and 0<=nny and nny<W and field2[nnx][nny]=='.':
                        dfs2(nnx,nny)
        ans+=1
    if len(start)==0:
        print(-1)
        exit()


Measured memory_bytes: 154632
main = do
  s <- getLine
  line <- getLine
  let
    k = read $ head $ words line :: Int
    func :: [[Char]] -> Int -> Int -> [Char]
    func xs ln i
      | ln+i > length s = func xs (ln - 1) 0
      | ln == 0         = head xs
      | otherwise       = func (cut $ ins xs $ subs s ln i) ln (i+1)
    ins xs str
      | xs == []        = str : []
      | head xs > str   = head xs : ins (tail xs) str
      | head xs == str  = xs
      | otherwise       = str : xs
    cut xs
      | length xs > k   = tail xs
      | otherwise       = xs
    subs str ln i 
      | i > 0     = subs (tail str) ln (i - 1)
      | ln > 0    = head str : subs (tail str) (ln - 1) i
      | otherwise = []
    in
      putStrLn $ func [] k 0


Measured memory_bytes: 1916
N, K = map(int, input().split())
MOD = 10 ** 9 + 7

ans = 0
for k in range(K, N+2):
    ans = (ans + k*N - k*(k-1) + 1) % MOD
#     print(k*(k-1)//2, k*N - k*(k-1)//2)
print(ans)

Measured memory_bytes: 9168
#include<stdio.h>
int main()
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(a==5)
	{
		if((b==5&&c==7)||(b==7&&c==5))
		printf("YES\n");
		else
		printf("NO\n");
	}
	else if(b==5)
	{
		if((a==5&&c==7)||(a==7&&c==5))
		printf("YES\n");
		else
		printf("NO\n");
	}
	else if(c==5)
	{
		if((a==5&&b==7)||(b==7&&a==5))
		printf("YES\n");
		else
		printf("NO\n");
	}
	 else
	 printf("NO\n");
	 return 0;
}
	

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

int main()
{
  int s,s1,s2,s3;
  cin >> s;
  s1 = s / 100;
  s2 = (s - s1 * 100) /10;
  s3 = (s - s1 * 100 - s2 * 10);
  cout << s1 + s2 + s3 << endl;
}


Measured memory_bytes: 256
using System;

class Program
{
    static void Main()
    {
		var A = int.Parse(Console.ReadLine());
        var B = int.Parse(Console.ReadLine());
        var C = int.Parse(Console.ReadLine());
        var X = int.Parse(Console.ReadLine());
        var answer = 0;
        for (int a=0; a<=A; a++)
        {
            for (int b=0; b<=B; b++)
            {
                for(int c=0; c<=C; c++)
                {
                    if ( a*500 + b*100 +c*50 == X ) answer += 1;
                }
            }
        }
        Console.WriteLine(answer);
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  set<int>s;
  for(int i=0;i<n;i++)
  {
    int t;
    cin>>t;
    s.insert(t);
  }
  if(s.size()==n)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  return 0;
}

Measured memory_bytes: 9600
# define _CRT_SECURE_NO_WARNINGS 1
# include <iostream>
# include <numeric>
# include <string>
# include <bitset>
# include <vector>
# include <algorithm>
# include <cstdlib>
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iomanip>
# include <queue>
# include <sstream>
# include <climits>
# include <cmath>
# include <list>
# include <functional>
# include <string>
# include <ctime>
# include <set>
# include <forward_list>
# include <map>
# include <stack>
using namespace std;
//# define M_PI 3.141592
# define INF ((int)(1<<30))
# define FOR(i,n) for(int i=0;i<(int)n;i++)
# define FORI(i,k,n) for(int i=k;i<(int)n;i++)
# define toRad 2.0*M_PI/360.0
# define inin(x) int x;cin>>x;
# define all(x) x.begin(),x.end()
# define debug(x) cout<<#x<<" :"<<x<<endl;
# define rep(i,n) for(int i=0;i<(int)n;i++)
# define EPS 1e-12
# define CHECK(i,a) FOR(i,a.size())cout<<#a<<"["<<i<<"] : "<<a[i]<<endl; 
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
int dx[4] = { 0,-1,1,0 }, dy[4] = { 1,0,0,-1 };
short memo[1 << 15][182][5];
int x;
int dp(int a,int n,int now)
{
	if (now<=4&&a==x)return 1;
	if (now >= 4||x-a<n*n||a>x)return 0;
	if (memo[a][n][now] != -1)return memo[a][n][now];
	int ans = 0;
	for (int i = 0; i <= 4; i++)
	{
		ans += dp(a + n*n*i, n + 1, now + i);
	}
	return memo[a][n][now] = ans;
}

signed main()
{
	
	while (cin >> x&&x)
	{
		memset(memo, -1, sizeof memo);
		cout << dp(0,1,0) << endl;
	}
}

Measured memory_bytes: 61360
N = int(input())
A = [int(input()) for _ in range(N)]
A.sort()

a = len(A)
if a%2==0:
  answer = 2 * sum(A[a//2+1:]) + A[a//2] - A[a//2-1] - 2* sum(A[:a//2-1])
  
if a%2==1:
  b = a//2
  if 2*A[b] - A[b-1] - A[b+1]<0:
    answer = 2*sum(A[b+1:]) - A[b] - A[b-1] - 2*sum(A[:b-1])
  else:
    answer = A[b] + A[b+1] + 2*sum(A[b+2:]) - 2*sum(A[:b])  
  
print(answer)    

Measured memory_bytes: 7512