akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
 
using namespace std;
 
#define MAX_N 20
#define MAX_C 10001
#define INF 1e9
#define EPS 1e-9
#define equal(a,b) (fabs(a-b) < EPS)
#define lt(a,b) (a-b < -EPS)
#define le(a,b) (equal(a,b) || lt(a,b))
#define PI acos(-1)
 
struct Point{
  double x,y;
  Point(){}
  Point(double x,double y) : x(x),y(y) {}
   
  Point operator + (const Point &p)const{
    return Point(x+p.x,y+p.y);
  }
  Point operator - (const Point &p)const{
    return Point(x-p.x,y-p.y);
  }
  Point operator * (double k)const{
    return Point(x*k,y*k);
  }
};
 
istream &operator >> (istream &is,Point &p){
  return is >> p.x >> p.y;
}
 
struct State{
  double d;
  int v,p,c;
   
  State(double d,int v,int p,int c) : 
    d(d),v(v),p(p),c(c) {}
   
  bool operator < (const State &s)const{
    return d > s.d;
  }
};
 
double dot(const Point &a,const Point &b){
  return a.x*b.x+a.y*b.y;
}
 
double norm(const Point &p){
  return dot(p,p);
}
 
double abs(const Point &p){
  return sqrt(norm(p));
}
 
typedef Point Vector;
 
inline double getAngle(const Vector &a,const Vector &b){
  return acos(dot(a,b)/abs(a)/abs(b))*180/PI;
}
 
double dist(const Point &a,const Point &b){
  return sqrt(pow(a.x-b.x,2)+pow(a.y-b.y,2));
}
 
int N;
double r,th,d2[MAX_N][MAX_N];
bool can[MAX_N][MAX_N][MAX_N];
double d[MAX_N][MAX_N][MAX_C];
 
int solve(const vector<Point> &vec){
  for(int i = 0 ; i < N ; i++){
    for(int j = 0 ; j < N ; j++){
      for(int k = 0 ; k < MAX_C ; k++){
        d[i][j][k] = INF;
      }
    }
  }
  priority_queue<State> Q;
  for(int i = 1 ; i < N ; i++){
    Q.push(State(dist(vec[0],vec[i]),i,0,1));
    d[i][0][1] = dist(vec[0],vec[i]);
  }
  while(!Q.empty()){
    State s = Q.top(); Q.pop();
    int v = s.v,p = s.p,c = s.c;
    if(lt(d[v][p][c],s.d)){ continue; }
    if(lt(r,s.d)){ continue; }
    for(int i = 0 ; i < N ; i++){
      if(i == v || i == p){ continue; }
      if(!can[p][v][i]){ continue; }
      if(c+1 < MAX_C && lt(d[v][p][c]+d2[v][i],d[i][v][c+1])){
        d[i][v][c+1] = d[v][p][c]+d2[v][i];
        Q.push(State(d[i][v][c+1],i,v,c+1));
      }
    }
  }
  int ans = 0;
  for(int i = 0 ; i < N ; i++){
    for(int j = 0 ; j < N ; j++){
      if(i == j){ continue; }
      for(int k = MAX_C-1 ; k > 0 ; k--){
        if(le(d[i][j][k],r)){
          ans = max(ans,k);
          break;
        }
      }
    }
  }
  return ans;
}
 
int main(){
  cin >> N >> r >> th;
  vector<Point> v(N);
  for(int i = 0 ; i < N ; i++){
    cin >> v[i];
  }
  memset(can,false,sizeof(can));
  for(int i = 0 ; i < N ; i++){
    for(int j = 0 ; j < N ; j++){
      if(i == j){ continue; }
      for(int k = 0 ; k < N ; k++){
        if(i == k || j == k){ continue; }
        Vector a = v[j]-v[i];
        Vector b = v[k]-v[j];
        double angle = getAngle(a,b);
        if(le(angle,th)){
          can[i][j][k] = true;
        }
      }
    }
  }
  for(int i = 0 ; i < N ; i++){
    for(int j = 0 ; j < N ; j++){
      d2[i][j] = dist(v[i],v[j]);
    }
  }
  cout << solve(v) << endl;
  return 0;
}

Measured memory_bytes: 32700
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  int h, w; cin >> h >> w;
  V<string> s(h); for (int i = 0; i < h; i++) cin >> s[i];
  VV<> a(h - 1);
  auto f = [&](int i, int j) { return s[i][j] == '#'; };
  for (int i = 0; i < h - 1; i++) {
    for (int j = 0; j < w - 1; j++) {
      if (f(i, j) + f(i, j + 1) + f(i + 1, j) + f(i + 1, j + 1) & 1) a[i].push_back(j);
    }
    a[i].push_back(w - 1);
  }
  int res = max(h, w);
  for (int j = 0; j < w - 1; j++) {
    V<> b(h - 1), l(h - 1), r(h - 1);
    for (int i = 0; i < h - 1; i++) b[i] = *lower_bound(a[i].begin(), a[i].end(), j) - j + 1;
    stack<int> st;
    for (int i = 0; i < h - 1; i++) {
      while (!st.empty() and b[st.top()] >= b[i]) st.pop();
      l[i] = b[i] * (i - (!st.empty() ? st.top() : -1));
      st.push(i);
    }
    stack<int>().swap(st);
    for (int i = h - 2; i >= 0; i--) {
      while (!st.empty() and b[st.top()] >= b[i]) st.pop();
      r[i] = b[i] * ((!st.empty() ? st.top() : h - 1) - i);
      st.push(i);
    }
    for (int i = 0; i < h - 1; i++) res = max(res, l[i] + r[i]);
  }
  cout << res << '\n';
}

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

#define hell                         1000000007
#define lcm(a,b)                     (a*b)/__gcd(a,b)
#define ll                           long long
#define vll                          vector<ll>
#define vi                           vector<int>
#define pll                          vector< pair<ll,ll> >
#define pb                           push_back
#define mp                           make_pair
#define all(v)                       v.begin(),v.end()
#define lbnd                         lower_bound
#define ubnd                         upper_bound
#define bs                           binary_search
#define F                            first
#define S                            second
#define rep(i,a,b)                   for(i=a;i<b;i++)
#define parr(a,n)                    for(ll it=0;it<n;it++) cout<<a[it]<<" ";cout<<endl;
#define pcont(a)                     for(auto it:a) cout<<it<<" ";cout<<endl;
#define ret(x)                       return cout<<x,0;
#define endl                           '\n'

/*constants*/
#define MAXN                         100005
#define PI                           3.14159265358979323846

/*debug*/
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>void __f(const char* name, Arg1&& arg1){ std::cout << name << " : " << arg1 << '\n';}
    template <typename Arg1, typename... Args>void __f(const char* names, Arg1&& arg1, Args&&... args){const char* comma = strchr(names + 1, ','); std::cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);}
#else
#define trace(...)
#endif

using namespace std;


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	
	ll i,j,n,m,k,cnt=0,ans=0,t=1;
	cin>>n;
	string s;
	cin>>s;
	if(n<3200) ret("red")
	ret(s)	
	
	return 0;
}

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

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

	int W, a, b;
	cin >> W >> a >> b;
	int t = max(a, b) - min(a, b) - W;
	if (t > -1)cout << t;
	else cout << 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include<iostream>
using namespace std;
using ll = long long int;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define IFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define RPT(i,a,b) for(int i=(a);i<((a)+(b));++i)
#define IRPT(i,a,b) for(int i=((a)+(b)-1);i>=(a);--i)
#define ALL(x) x.begin(),x.end()
#define fs first
#define sd second

template<class T> using V = vector<T>;
template<class T> using V2 = V<V<T>>;


void solve(){
  int n; cin >> n;
  int INF = 1<<25;
  V<int> p(n+5,INF), pl(n+5), pll(n+5,0), plr(n+5,0), prl(n+5,n+1), prr(n+5,n+1); 
  FOR(i,0,n) {
    cin >> p[i+1];
    pl[p[i+1]] = i+1;
  }/*
  FOR(i,1,n){
    int u = pl[i], cnt = 0;
    IFOR(j,1,u){
      if(p[j]>i){
        if(cnt==0) plr[i] = j;
        if(cnt==1) pll[i] = j;
        cnt++;
      }
      if(cnt==2) break;
    }
    //if(plr[i]==pll[i]) pll[i] = -1;
    cnt = 0;
    FOR(j,u,n+2){
      if(p[j]>i){
        if(cnt==0) prl[i] = j;
        if(cnt==1) prr[i] = j;
        cnt++;
      }
      if(cnt==2) break;
    }
    //if(prr[i]==prl[i]) prr[i] = n+2;
  }*/
  set<int> S, T;
  S.insert(n+1); T.insert(-n-1); S.insert(n+2); T.insert(-n-2);
  S.insert(0); T.insert(0); S.insert(-1); T.insert(1);
  IFOR(i,1,n+1){
    int ip = pl[i];
    auto aa = S.upper_bound(ip);
    auto ab = S.upper_bound(*aa);
    if(aa!=S.end()  &&  (*aa)>=0 && (*aa) <= n+1) prl[i] = *aa;
    if(aa!=S.end() && ab != T.end() && (*ab)>=0 && (*ab) <= n+1) prr[i] = *ab;
    aa = T.upper_bound(-ip);
    ab = T.upper_bound(*aa);
    if(aa!=S.end()  &&  -(*aa)>=0 && -(*aa) <= n+1) plr[i] = -(*aa);
    if(aa!=S.end() && ab != T.end() &&-(*ab)>=0 && -(*ab) <= n+1) pll[i] = -(*ab);
    S.insert(ip);
    T.insert(-ip);
  }
  ll ans = 0;
  FOR(i,1,n){
    ll ip = pl[i];
    ll tmp = ((ll)(ip - plr[i])*(ll)(prr[i]-prl[i]) + (ll)(prl[i]-ip) *(ll)(plr[i]-pll[i]));
    ans += tmp*i;
    //cout << i << "~" << tmp << '\n';
  }
  /*
  FOR(i,0,n+2){
    cout << pll[i] << '~' << plr[i] << "~~" << prl[i] << '~' << prr[i] << '\n';
  }*/
  cout << ans << '\n';
}

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

Measured memory_bytes: 12032
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
using namespace std;

int gcd(int a, int b){
    int tmp;
    while (b != 0) {
        if (b < a) {
            tmp = a;
            a = b;
            b = tmp;
        }
        b = b % a;
    }
    return a;
}

int main(void){
    long long n,m;
    string s,t;
    cin >> n >> m >> s >> t;
    long long num=n/gcd(n,m)*m;
    for(int i=0; i<n; i++){
        if(num/m*i>=n || num/n*i>=m)break;
        if(s[num/m*i]!=t[num/n*i]){
            num=-1;
            break;
        }
    }
    cout << num << endl;
    return 0;
}

Measured memory_bytes: 512
N,K = map(int,input().split())
V = list(map(int,input().split()))
res = 0
for i in range(1,min(N+1,K+1)): #獲得の回数
  for j in range(i+1):#Aの回数
    have = []
    trash_value = 0
    a = j
    b = i - j
    have.extend(V[:a])
    if not b ==0:
      have.extend(V[((-1)*b):])
    have.sort()
    trash = K - i #捨てる回数
    for p in range(min(trash,len(have))):
      if have[p] < 0:
        trash_value += have[p]
      else:
        break
    if res < (sum(have)-trash_value):
      res = (sum(have)-trash_value)
print(res)



Measured memory_bytes: 3064
#include <stdio.h>

int main(void){

  int n,m;
  scanf("%d %d", &n, &m);
  int s[m];
  int c[m];
  for (int i = 0; i < m; i++) {
    scanf("%d %d", &s[i], &c[i]);
  }

  int number[n];
  for (int i = 0; i < n; i++) {
    number[i] = -1;
  }
  for (int i = 0; i < m; i++) {
    if (n != 1 && s[i] == 1 && c[i] == 0) {
      printf("-1\n");
      return 0;
    } else if (number[s[i]-1] == -1) {
      number[s[i]-1] = c[i];
    } else if (number[s[i]-1] != c[i]) {
      printf("-1\n");
      return 0;
    }
  }

  for (int i = 0; i < n; i++) {
    if (number[i] == -1) {
      number[i] = 0;
    }
  }
  if (n != 1 && number[0] == 0) {
    number[0] = 1;
  }

  for (int i = 0; i < n; i++) {
    printf("%d", number[i]);
  }
  printf("\n");

  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
#define cinf(n,x) for(int UNCH=0;UNCH<(n);UNCH++) cin >> x[UNCH];
#define fcin(n,x) for(int UNCH=1;UNCH<=(n);UNCH++) cin>> x[UNCH];
#define memmin(x) memset((x),-1,sizeof((x)))
#define memzer(x) memset((x), 0,sizeof((x)))
#define meminf(x) memset((x),0x3f,sizeof((x)))
#define int long long
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
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 qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}



signed main(){
  string str;
  cin >>str;
  str[3]++;
  cout <<str fin;
  return 0;
}



struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;



Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;

class Main {

	public static void main(String[] args) throws IOException {

		Scanner scane = new Scanner(System.in);

		int n = scane.nextInt();

		int m = scane.nextInt();

		int[][]  A = new int[n][m];

		int[] b = new int[m];

		int[] c = new int[n];

		for(int i=0; i<A.length; i++){
			for(int j = 0; j<A[0].length; j++){

				A[i][j] = scane.nextInt();
			}
		}
		for(int i= 0; i<A[0].length; i++){
			b[i] = scane.nextInt();
		}



		for(int i=0; i<A.length; i++){
			int sum =0;
			for(int j = 0; j<A[0].length; j++){
				sum += A[i][j]*b[j];
			}

			c[i] = sum;
		}

		for(int i=0; i<c.length; i++){
			System.out.println(c[i]);
		}


	}
}

Measured memory_bytes: 40992
n=int(input())
if 1<=n<=9:
      print('Yes')
elif n==10:
      print('Yes')
elif n==12:
      print('Yes')
elif n==14:
      print('Yes')
elif n==15:
      print('Yes')
elif n==16:
      print('Yes')
elif n==18:
      print('Yes')
elif n==20:
      print('Yes')
elif n==21:
      print('Yes')
elif n==24:
      print('Yes')
elif n==25:
      print('Yes')
elif n==27:
      print('Yes')
elif n==28:
      print('Yes')
elif n==30:
      print('Yes')
elif n==32:
      print('Yes')
elif n==35:
      print('Yes')
elif n==36:
      print('Yes')
elif n==40:
      print('Yes')
elif n==42:
      print('Yes')
elif n==45:
      print('Yes')
elif n==48:
      print('Yes')
elif n==49:
      print('Yes')
elif n==54:
      print('Yes')
elif n==56:
      print('Yes')
elif n==63:
      print('Yes')
elif n==64:
      print('Yes')
elif n==72:
      print('Yes')
elif n==81:
      print('Yes')
else:
      print('No')

Measured memory_bytes: 3064
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        HashMap<String, String> hashmap = new HashMap<>();
        hashmap.put("A", "T");
        hashmap.put("T", "A");
        hashmap.put("C", "G");
        hashmap.put("G", "C");
		String a = sc.next();
 
		System.out.println(hashmap.get(a));
    }
}


Measured memory_bytes: 21972
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
#include<assert.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<60)
#define MOD1 1000000007
#define MOD2 998244353
#define MAX_N (1 << 17)
#define YES printf("Yes\n")
#define NO printf("No\n")
#define PN printf("\n")
#define charsize 100005 //10^5+5

void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a= c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll min3(ll a, ll b, ll c){return (a<=b && a<=c) ? a : b<=c ? b : c;}
ll max3(ll a, ll b, ll c){return (a>=b && a>=c) ? a : b>=c ? b : c;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll mod(ll n){n+= n<0?((-n)/MOD1+1)*MOD1:0; return n%=MOD1;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{ ll a , b;}fr;
int cmp1( const void *p, const void *q ) { return ((fr*)p) ->a - ((fr*)q)->a;}
int cmp2( const void *p, const void *q ) { return ((fr*)q) ->a - ((fr*)p)->a;}
void strsortup(fr*a,int n){qsort(a,n,sizeof(fr),cmp1);}
void strsortdown(fr*a,int n){qsort(a,n,sizeof(fr),cmp2);}

int main(void){
    // char ;
    ll n;
    double ans; 
    scanf("%lld",&n);
    // // ll [n];
    // rep(i,0,n){
    //     scanf("%lld",&[i]);
    // }
    ans=2*M_PI*n;

    
    printf("%.8f\n",ans);
    return 0;
}


Measured memory_bytes: 1732
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#define rep(i,n) for (int i = 0; i < n; ++i)
const int INF = 1001001001;

using namespace std;

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

    vector<int> p(n), q(n);
    rep(i,n) cin >> p[i];
    rep(i,n) cin >> q[i];

    vector<int> per(n);
    rep(i,n) per[i] = i+1;
    auto ptoi = [n](vector<int> v) {
        int x = 0;
        int mul = 1;
        int l;
        rep(i,n) {
            l = v.size();
            x += mul * v[l-1-i];
            mul *= 10;
        }
        return x;
    };

    int pi = ptoi(p);
    int qi = ptoi(q);
    int cntp = 0, cntq = 0;
    int peri;

    do {
        peri = ptoi(per);
        if (peri <= pi) cntp++;
        if (peri <= qi) cntq++;
    } while (next_permutation(per.begin(), per.end()));

    cout << abs(cntp - cntq) << endl;
    return 0;
}

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

namespace ConsoleApplication1
{
    struct Doll : IComparable
    {
        internal int h, r, size;

        public int CompareTo(object obj)
        {
            Doll other = (Doll)obj;
            return size - other.size;
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            while (true)
            {
                int n = int.Parse(Console.ReadLine());

                if (n == 0) break;

                List<Doll> list = new List<Doll>();

                for (int i = 0; i < n; i++)
                {
                    string[] input = Console.ReadLine().Split(' ');

                    Doll temp;
                    temp.h = int.Parse(input[0]);
                    temp.r = int.Parse(input[1]);
                    temp.size = temp.h * temp.r * temp.r;
                    list.Add(temp);
                }

                int m = int.Parse(Console.ReadLine());

                for (int i = 0; i < m; i++)
                {
                    string[] input = Console.ReadLine().Split(' ');

                    Doll temp;
                    temp.h = int.Parse(input[0]);
                    temp.r = int.Parse(input[1]);
                    temp.size = temp.h * temp.r * temp.r;
                    list.Add(temp);
                }

                list.Sort();

                int[] memo = new int[list.Count];

                for (int i = 0; i < list.Count; i++)
                {
                    memo[i] = 1;

                    for (int j = 0; j < i; j++)
                    {
                        if (list[i].h > list[j].h && list[i].r > list[j].r)
                        {
                            memo[i] = Math.Max(memo[i], memo[j] + 1);
                        }
                    }
                }
                sb.AppendLine(memo.Max().ToString());
            }
            Console.Write(sb);
        }
    }
}

Measured memory_bytes: 9872
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
using namespace std;
using namespace __gnu_pbds;
typedef long long int ll;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pii pair<ll,ll>
#define F first
#define S second
#define pb push_back
template <typename T>
using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll mod1=998244353,mod2=(ll)1e9+7;
ll power(ll n,ll k,ll mod){ll ans=1; n=n%mod;while(k>0){if(k&1)ans=(ans*n)%mod;n=(n*n)%mod;k>>=1;}return (ans+mod)%mod;}//negative nos & 0^0
struct triplet{ll a,b,c;};bool operator < (const triplet &t1,const triplet &t2){if(t1.a<t2.a)return true;if(t1.a==t2.a && t1.b <t2.b)return true;if(t1.a==t2.a && t1.b ==t2.b && t1.c<t2.c)return true;return false;}

int main()
{
    fio;
    ll a,b,m;
    cin>>a>>b>>m;
    ll x[a],y[b];
    ll mini=1e9;
    ll mx=1e9,my=1e9;
    for(int i=0;i<a;i++)
        cin>>x[i],mx=min(mx,x[i]);
    for(int i=0;i<b;i++)
        cin>>y[i],my=min(my,y[i]);
    mini=mx+my;
    for(int i=0;i<m;i++)
    {
        int u,v,c;
        cin>>u>>v>>c;
        mini=min(x[u-1]+y[v-1]-c,mini);
    }
    cout<<mini;
}


Measured memory_bytes: 1792
-- https://github.com/minoki/my-atcoder-solutions
{-# LANGUAGE BangPatterns #-}
import Data.List
import Data.Char
import Control.Monad
import qualified Data.ByteString.Char8 as BS
import qualified Data.Vector.Unboxed as U

readIntPair :: BS.ByteString -> (Int, Int)
readIntPair s = let Just (a, s') = BS.readInt s
                    Just (b, _) = BS.readInt $ BS.dropWhile isSpace s'
                in (a, b)

main = do
  (n,m) <- readIntPair <$> BS.getLine
  (maxL,minR) <- fmap (U.foldl1' (\(!l,!r) (!l',!r') -> let !ll = max l l'; !rr = min r r' in (ll,rr))) $ U.replicateM m (readIntPair <$> BS.getLine)
  print $ max 0 (minR - maxL + 1)


Measured memory_bytes: 2556
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using ll = long long;

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    int d[3];
    d[0] = d[1] = d[2] = -1;
    for (int i=0, s, c; i<m; i++) {
        cin >> s >> c;
        if (d[--s] >= 0 && d[s] != c) {
            cout << -1 << '\n';
            return 0;
        }
        d[s] = c;
    }
    if (n > 1 && d[0] == 0) {
        cout << -1 << '\n';
        return 0;
    }
    if (n > 1 && d[0] == -1) d[0] = 1;
    int ans = 0;
    for (int i=0; i<n; i++) {
        ans += max(d[i], 0);
        if (i < n-1) ans *= 10;
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
# coding: utf-8

# In[32]:


n = int(input())
data = []
for i in range(n):
    x,u = map(str, input().split())
    data.append([x, u, i])


# In[34]:


result = 0
for i in range(n):
    if data[i][1] == "JPY":
        result += int(data[i][0])
    else:
        result += float(data[i][0]) *  380000


# In[35]:


print(result)



Measured memory_bytes: 3060
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
const int MaxN = 1e5;
using namespace std;
typedef long long LL;
int n, a[MaxN + 5];
LL sum[MaxN + 5];
int main() 
{
	while(~scanf("%d", &n)) {
		for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
		for (int i = 1; i <= n + 1; i++) sum[i] = sum[i - 1] + abs(a[i] - a[i - 1]);
		for (int i = 1; i <= n; i++) {
			LL sum1 = sum[i - 1], sum2 = sum[n + 1] - sum[i + 1];
			int sum3 = abs(a[i + 1] - a[i - 1]);
			printf("%lld\n", sum1 + sum2 + sum3);
		}
	}
	return 0;
}

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

#define VARNAME(x) #x
#define show(x) cerr << #x << " = " << x << endl

using namespace std;
using ll = long long;

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{
    os << "sz:" << v.size() << "\n[";
    for (const auto& p : v) {
        os << p << ",";
    }
    os << "]\n";
    return os;
}

template <typename S, typename T>
ostream& operator<<(ostream& os, const pair<S, T>& p)
{
    os << "(" << p.first << "," << p.second
       << ")";
    return os;
}


constexpr ll MOD = (ll)1e9 + 7LL;

template <typename T>
constexpr T INF = numeric_limits<T>::max() / 10;

struct Graph {
    Graph(const ll n)
    {
        edge.resize(n);
    }
    void addEdge(const ll from, const ll to)
    {
        edge[from].push_back(to);
    }
    vector<vector<ll>> edge;
};

ll dfs(const Graph& g_, Graph& g, const ll s, vector<ll>& sub)
{
    sub[s] = 1;
    for (const ll to : g_.edge[s]) {
        if (sub[to] == -1) {
            g.addEdge(s, to);
            sub[s] += dfs(g_, g, to, sub);
        }
    }
    return sub[s];
}

using P = pair<ll, ll>;
void ddfs(const Graph& g_, const ll s, const vector<ll>& w, vector<ll>& d, const map<P, ll>& ind)
{
    const ll di = d[s];
    for (const ll to : g_.edge[s]) {
        if (d[to] == -1) {
            d[to] = di + w[ind.at(make_pair(s, to))];
            ddfs(g_, to, w, d, ind);
        }
    }
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    Graph g_(N);
    vector<P> edge(N - 1);
    map<P, ll> ind;
    for (ll i = 0; i < N - 1; i++) {
        ll u, v;
        cin >> u >> v;
        u--, v--;
        g_.addEdge(u, v);
        g_.addEdge(v, u);
        edge[i] = make_pair(u, v);
        ind[make_pair(u, v)] = i;
        ind[make_pair(v, u)] = i;
    }
    vector<ll> d(N);
    for (ll i = 0; i < N; i++) {
        cin >> d[i];
    }
    Graph g(N);
    vector<ll> sub(N, -1);
    dfs(g_, g, 0, sub);
    vector<ll> w(N - 1, -1);
    for (ll i = 0; i < N - 1; i++) {
        const auto& e = edge[i];
        const ll u = e.first;
        const ll v = e.second;
        const ll sa = abs(N - 2 * min(sub[u], sub[v]));
        const ll dsa = abs(d[u] - d[v]);
        if (dsa > 0) {
            w[i] = dsa / sa;
        }
    }
    for (ll i = 0; i < N - 1; i++) {
        if (w[i] == -1) {
            w[i] = 0;
            const ll u = edge[i].first;
            const ll v = edge[i].second;
            vector<ll> dist(N, -1);
            dist[u] = 0;
            ddfs(g_, u, w, dist, ind);
            const ll sum = accumulate(dist.begin(), dist.end(), 0LL);
            w[i] = (d[u] - sum) / (N / 2);
            break;
        }
    }
    for (ll i = 0; i < N - 1; i++) {
        cout << w[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 39296
#include <iostream>
using namespace std;
int main()
{
    string a, b, c;
    cin >> a >> b >> c;
    if(a[a.size()-1] == b[0] && b[b.size()-1] == c[0]){
        cout << "YES" << endl;
    }
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define LLMAX (1ll << 60) - 1
#define INTMAX (1 << 30) - 1
#define MOD 1000000007 
#define NMAX 1000*100+1

#define numberOfSetBits(S) __builtin_popcount(S) // __builtin_popcountl(S) __builtin_popcountll(S)
#define MSET(x,y) memset(x,y,sizeof(x))
#define gcd(a,b) __gcd(a,b)
#define all(x)  x.begin(),x.end()
#define isOn(S, j) (S & (1 << j))
#define endl '\n'
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define print(x)    for(auto it:x) cout<<it<<' '; cout<<endl;
#define printii(x)  for(auto it:x) cout<<it.F<<' '<<it.S<<'\t';  cout<<endl;
#define in(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}

#define vi vector<ll>
#define vvi vector<vi>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define vvii vector<vii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define mc(a,b,c) mp(mp(a,b),c)
const int nmax = 1e5+3;
ll a[nmax],b[nmax],c[nmax];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,x,t,m,y,z;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    x = 0,y=0;
    for(int i=1;i<=n;i++){
        b[i]=a[i]+b[i-1];
        if((i%2)&&(b[i]<=0)){
            x+=(1-b[i]);
            b[i] = 1;
        }
        if((i%2==0)&&(b[i]>=0)){
            x+=(b[i]+1);
            b[i] = -1;
        }
    }
    for(int i=1;i<=n;i++){
        c[i]=a[i]+c[i-1];
        if((i%2==0)&&(c[i]<=0)){
            y+=(1-c[i]);
            c[i] = 1;
        }
        if((i%2)&&(c[i]>=0)){
            y+=(c[i]+1);
            c[i] = -1;
        }
    }
    cout<<min(x,y);
    
    

    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
const int maxn = 200 + 10;
int n, l, ord, ans, res = 0x7fffffff;
int main() {
    scanf("%d %d", &n, &l);
    ord = n * (2 * l + n - 1) / 2;
    for (int i = 1; i <= n; ++i) {
        if (abs((i + l - 1)) < res) {
            res = abs(i + l - 1), ans = i;
        }
    }
    printf("%d\n", ord - (ans + l - 1));
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)  
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define RVSORT(v) sort(v.rbegin(), v.rend());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int gcd(int a,int b){return b?gcd(b,a%b):a;}

ll modpow(ll n,ll k){
  if(k == 1){
    return n;
  }else if(k == 0){
    return 1;
  }else if(k%2==0){
    ll memo = modpow(n,k/2)%MOD;
    return memo*memo%MOD;
  }else{
    return n * modpow(n,k-1)%MOD;
  }
}

int main(){

  ll ans = 0;
  ll n,d,a;cin>>n>>d>>a;
  vector<LP> v;
  REP(i,n){
    ll x,h;
    cin>>x>>h;
    h = (h+a-1)/a;
    LP lp;
    lp.first = x;
    lp.second = h;
    v.pb(lp);
  }

  VSORT(v);

  vector<ll> w;
  REP(i,n){
    w.pb(v[i].first);
  }

  ll bomb[n+1];
  REP(i,n){
    bomb[i] = 0;
  }
  ll now = 0;

  //cout<<v.size()<<endl;
  REP(i,n){

    //初期ダメの計算
    now += bomb[i];

    v[i].second -= now;
    if(v[i].second > 0){
      now += v[i].second;
      ans += v[i].second;
      ll utan = v[i].first + 2*d;
      auto Iter = upper_bound(w.begin(),w.end(),utan);
      ll t = Iter - w.begin();
      bomb[t] -= v[i].second;
    }


  }

  cout<<ans<<endl;
 

  return 0;
}

Measured memory_bytes: 9708
//#include "SaveFuncs.cpp"

#include <iostream>
#include <array>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <iomanip>	//cout << fixed << setprecision(桁数);
#include <stdexcept>

using namespace std;
using ll = long long;

#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; i++)
#define rep1(i, n) for(int i=1, i##_len=(n); i<i##_len; i++)
#define rrep(i, n) for(int i=(n)-1; i >= 0; i--)
#define rrep1(i, n) for(int i=(n); i > 0; i--)
#define all(x) (x).begin(), (x).end()
#define pair(a, b) make_pair(a, b);
//#define int long long
constexpr int INF = 2000000100;
constexpr int DIV = 1000000007;	// 10e9+7
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> T divUp(T a, T b) { if (a % b == 0) { return a / b; } return a / b + 1; }
string strMulti(string t, int n) { string out = ""; for (int i = 0; i < n; i++) { out += t; } return out; }

/*****/

int Main()
{
	int N;
	cin >> N;

	int ret = 0;

	if (N < 10)
	{
		ret += N;
	}
	else
	{
		ret += 9;
		if (N < 100)
		{
		}
		else
		{
			if (N < 1000)
			{
				ret += N - 100 + 1;
			}
			else
			{
				ret += 900;
				if (N < 10000)
				{
				}
				else
				{
					if (N < 100000)
					{
						ret += N - 10000 + 1;
					}
					else
					{
						ret += 90000;
					}
				}
			}
		}
	}

	cout << ret << endl;


	return 0;
}

/*****/

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

	Main();

	return 0;
}


Measured memory_bytes: 256
/*
digu_J - Digvijay Janartha
NIT Hamirpur - INDIA
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")

using namespace std;
using namespace __gnu_pbds;

template < typename T > using ordered_set = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

#ifdef HOME
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
    cout << name << " : " << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    int len = comma - names;
    for (int i = 0; i < len; ++i) {
        cout << names[i];
    }
    cout <<  " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
#else
#define trace(...)
#endif

typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < ll, ll > pll;
typedef pair < int, int > pii;
typedef vector < ll > vll;
typedef vector < int > vi;
typedef complex < double > com;

#define eb emplace_back
#define pb push_back
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define unique_sort(x) (sort(x.begin(), x.end()), x.resize(distance(x.begin(), unique(x.begin(), x.end()))))
#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

const ll LINF = LLONG_MAX, base = 1e9, MOD = 1e9 + 7, N = 1e5 + 5, M = 1e3 + 5, LG = 20;
const int INF = INT_MAX;
const db PI = acos(-1), EPS = 1 / db(1e6);
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());

void test() {
    int a, b;
    cin >> a >> b;
    if (a < 10 and b < 10) {
        cout << a * b << "\n";
    } else {
        cout << "-1\n";
    }
}

int main() {
    fast_io();
    #ifdef HOME
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    cout << fixed << setprecision(15);
    test();
    #ifdef HOME
        cout << "Time: " << (int)(clock() * 1000. / CLOCKS_PER_SEC) << "ms";
    #endif
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std;

int num_of_digits(long long x) {
    int num_of_digits = 0;
    while(x > 0) {
        num_of_digits++;
        x /= 10;
    }
    return num_of_digits;
}

int F(long long A, long long B) {
    int result = fmax(num_of_digits(A), num_of_digits(B));
    return result;
}

int main() {
    long long N;
    cin >> N;
    int min_F = 10;
    for (long long A = 1; A <= sqrt(N); A++) {
        if (N % A == 0) {
            long long B = N / A;
            min_F = fmin(min_F, F(A, B));
        }
    }
    cout << min_F << endl;
    return 0;
}

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

namespace AtCoderMake.ABC172
{
    class ABC172B
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var t = Console.ReadLine();
            int ans = 0;
            
            for(int i = 0; i < s.Length; i++)
            {
                if (s[i] != t[i])
                {
                    ans++;
                }
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 27332
package main

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

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt(A ...*int) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.Atoi(L[i])
  }
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func Output() {
  _ = writer.Flush()
}

const p = 1000000007

func Solve() {
  var N int
  NextInt(&N)
  DP := make([]int, N + 2)
  S := make([]int, N + 1)
  DP[1] = N
  DP[2] = N * N % p
  X := (N - 1) * (N - 1) % p
  for k := 3; k <= N; k++ {
    DP[k] = (X + DP[k - 1] + S[k - 3] + N - k + 2) % p
    S[k - 2] = (S[k - 3] + DP[k - 2]) % p
  }
  Write(DP[N])
  return
}

func main() {
  Solve()
  Output()
}

Measured memory_bytes: 16768
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int N;
	cin >> N;

	map<Int, Int> cnt;
	Int a;
	for (Int i = 0; i < N; i++) {
		cin >> a;
		cnt[a]++;
	}

	bool flag = false;

	if (1==cnt.size()) {//1種類の時
		if (N==cnt[0]) {//全部0以外ダメ
			flag = true;
		}
	}
	else if (0==N%3) {
		if (2==cnt.size()) {//2種類の時
			if (cnt[0]==N/3) {//0がN/3個ちょうど
				flag = true;
			}
		}
		else if (3==cnt.size()) {//3種類の時
			Int temp = 0;
			Int num = 0;
			for (const auto& e : cnt) {//全部3/N個以外ダメ
				temp ^= e.first;
				num += abs(N / 3 - e.second);
			}
			if (temp==0&&num==0) {
				flag = true;
			}
		}
	}

	if (flag) cout << "Yes" << "\n";
	else cout << "No" << "\n";
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
int n, f[55][105], C[55][55];
int main() {
	scanf("%d", &n);
	for (int i = C[0][0] = 1; i <= n; i++) {
		for (int j = C[i][0] = 1; j <= i; j++) {
			C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % mod;
		}
	}
	f[1][n] = f[1][n - 1] = 1;
	for (int i = 1; i <= n; i++) {
		for (int j = -n; j <= n; j++) if (f[i][j + n]) {
			for (int k = max(1, abs(j)); k <= n - i; k++) if (!((j + k) & 1)) {
				for (int l = 0; l <= k; l++) {
					int val = (j + k - 2 * l) >> 1;
					if (val < -n || val > n) continue;
					f[i + k][val + n] = (f[i + k][val + n] + 1ll * f[i][j + n] * C[i + k][k] % mod * C[k][l]) % mod;
				}
			}
		}
	}
	printf("%d\n", f[n][n]);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;

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 (a>b) { a=b; return 1; } return 0; }
#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 all(x) (x).begin(),(x).end()

const int mod = 1e9 + 7;

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> G(n+1, vector<int>(n+1, 0));
    rep (i, m) {
        int a, b;
        cin >> a >> b;
        G[a][b] = 1;
        G[b][a] = 1;
    }
    int ans = 0;
    vector<int> p(n-1);
    iota(all(p), 2);
    while (true) {
        auto H = G;
        int now = 1;
        rep (i, p.size()) {
            if (H[now][p[i]] == 1) {
                H[now][p[i]] = H[p[i]][now] = 0;
                now = p[i];
            } else {
                break;
            }
            if (i == p.size() - 1) {
                ans++;
            }
        }
        if (!next_permutation(all(p))) {
            break;
        }
    }
    cout << ans << endl;
}




Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
	int n, count = 0;
	while(cin >> n) {
		for(int i = 0; i < 10; i++) {
			for(int j = 0; j < 10; j++) {
				for(int k = 0; k < 10; k++) {
					for(int l = 0; l < 10; l++) {
						if(i + j + k + l == n) {
							count++;
						}
					}
				}
			}
		}
		cout << count << endl;
		count = 0;
	}

	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }


int N,x;

bool input(){
  cin >>N >>x;
  if (N == 0) if (x == 0) return false;
  return true;
}

void solve(){
  int res = 0;
  for (int i=1; i<=N; i++){
    for (int j=i+1; j<=N; j++){
      int k = x - i - j;
      if (k < 0 || k > N) continue;
      if (j >= k) continue;
      res++;
    }
  }
  cout <<res <<endl;
}

int main() {
  while (input()) solve();
}



Measured memory_bytes: 3116
<?php

$a = "a";
$numOfAlphabet = 26;
for($i=0; $i<$numOfAlphabet; $i++){
    $counter[$a] = 0;
    $a++;
}

while($inStrRaw = fgets(STDIN)){
    $inStr = strtolower($inStrRaw);
    for($i=0; $i<strlen($inStr); $i++){
        $ch = $inStr[$i];
        if(isIn($counter, $ch)){
            $counter[$ch]++;
        }
    }
}

// output
foreach($counter as $key => $value){
    echo $key . " : " . $value . PHP_EOL;
}

function isIn($counter, $ch){
    foreach($counter as $key => $value){
        if($key === $ch){
            return true;
        }
    }
    return false;
}

Measured memory_bytes: 15452
//abc161_b.cpp
//Sat Apr  4 20:35:11 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007

using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	int a[n];
	int votetotal = 0;
	for (int i=0;i<n;i++){
		cin >> a[i];
		votetotal += a[i];
	}

	int threshold = 0;
	if (votetotal%(4*m)==0){
		threshold = votetotal/(4*m)-1;
	}else {
		threshold = votetotal/(4*m);
	}

	sort(a,a+n,greater<int>());

	for (int i=0;i<m;i++){
		if (a[i]<=threshold){
			cout << "No" << endl;
			return 0;
		}
	}


	cout << "Yes"<< endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)
//#define i_7 998244353
//#define i_5 998244351
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
long double EPS=1E-8;
////////////////////////////////////////


int main(){
    ll h,w,n;cin>>h>>w>>n;
    ll ob[n][2];rep(i,0,n-1)rep(j,0,1){cin>>ob[i][j];ob[i][j]--;}
    ll u[h];rep(i,0,h-1)u[i]=inf;
    rep(i,0,n-1){
        Min(u[ob[i][0]],ob[i][1]);
    }
    //rep(i,0,n-1)cout<<u[i]<<" ";cout<<endl;
    if(h==1){
        cout<<1<<endl;return 0;
    }
    if(u[1]==0){
        cout<<1;return 0;
    }
    ll maxy=0;
    rep(i,1,h-2){
        if(u[i]!=maxy+1)maxy++;
        if(u[i+1]<=maxy){
            cout<<i+1<<endl;return 0;
        }
    }
    cout<<h<<endl;
    
    return 0;
}



Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    int x, y;
    cin >> x >> y;
    
    for(int i = 0; i <= 100; i++) {
        for (int j = 0; j <= 100; j++) {
            int sum = 2*i +4*j;
            int num = i+j;

            if(sum == y && num == x) {
                cout << "Yes" << endl;
                return 0;
            }
        }
        
    }

    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3596
#define D(x) cout << #x " = " << x << endl
#define DD(x, y) cout << "(" #x ", " #y ") = (" << x << ", " << y << ")" << endl
#define DDD(x, y, z) cout << "(" #x ", " #y ", " #z ") = (" << x << ", " << y << ", " << z << ")" << endl
#define DV(v) for (auto __macro_vi : v){ cout << __macro_vi << " ";} cout << endl;
#define DA(a, n) for (int __macro_i = 0; __macro_i < n; ++__macro_i) { cout << a[__macro_i] << " "; } cout << endl;
#define REP(i, n) for (int i = 0; i < n; ++i)
#define ALL(v) (v).begin(), (v).end()
#include<iostream>
#include<vector>
#include<cassert>
#include<cmath>

using namespace std;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    vector<int> v, ind, to;
    cin >> n;
    v.resize(n); ind.resize(n); to.resize(n);

    REP(i, n) {cin >> v[i]; ind[i] = i;}
    sort(ind.begin(), ind.end(), [&v](int a, int b){return v[a] < v[b];});
    REP(i, n) to[ind[i]] = i;
    // DV(v);
    // DV(to);
    int ans = 0;
    REP(i, n) {
        if (to[i] % 2 != i % 2) {
            ans++;
        }
    }
    cout << ans / 2 << endl;
}


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

int N;
signed main(){
  cin>>N;
  int k=1,ans=0;
  for(int i=0;i<N;i++){
    int A;
    cin>>A;
    if(k==1)ans+=A-1,k++;
    else if(A==k)k++;
    else if(A%k==0)ans+=A/k-1;
    else ans+=A/k;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 384
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cctype>
#include <vector>
using namespace std;

namespace zyt
{
	template<typename T>
	inline bool read(T &x)
	{
		char c;
		bool f = false;
		x = 0;
		do
			c = getchar();
		while (c != EOF && c != '-' && !isdigit(c));
		if (c == EOF)
			return false;
		if (c == '-')
			f = true, c = getchar();
		do
			x = x * 10 + c - '0', c = getchar();
		while (isdigit(c));
		if (f)
			x = -x;
		return true;
	}
	template<typename T>
	inline void write(T x)
	{
		static char buf[20];
		char *pos = buf;
		if (x < 0)
			putchar('-'), x = -x;
		do
			*pos++ = x % 10 + '0';
		while (x /= 10);
		while (pos > buf)
			putchar(*--pos);
	}
	const int N = 110;
	int n, m, arr[N][N], b[N][N];
	vector<int> g[N];
	namespace Hungary
	{
		int match[N], vis[N], time;
		bool find(const int u)
		{
			for (auto v : g[u])
				if (vis[v] < time)
				{
					vis[v] = time;
					if (!match[v] || find(match[v]))
					{
						match[v] = u;
						return true;
					}
				}
			return false;
		}
		void solve()
		{
			time = 0;
			memset(match, 0, sizeof(int[n + 1]));
			memset(vis, 0, sizeof(int[n + 1]));
			for (int i = 1; i <= n; i++)
				++time, find(i);
		}
	}
	bool used[N][N];
	int work()
	{
		using namespace Hungary;
		read(n), read(m);
		for (int i = 1; i <= n; i++)
			for (int j = 1; j <= m; j++)
				read(arr[i][j]);
		for (int i = 1; i <= n; i++)
			for (int j = 1; j <= m; j++)
				g[i].push_back((arr[i][j] - 1) / m + 1);
		for (int i = 1; i <= m; i++)
		{
			solve();
			for (int j = 1; j <= n; j++)
			{
				for (int k = 1; k <= m; k++)
					if (!used[match[j]][k] && (arr[match[j]][k] - 1) / m + 1 == j)
					{
						used[match[j]][k] = true, b[match[j]][i] = arr[match[j]][k];
						break;
					}
				for (auto it = g[j].begin(); it != g[j].end(); it++)
					if (match[*it] == j)
					{
						g[j].erase(it);
						break;
					}
			}
		}
		for (int i = 1; i <= n; i++)
		{
			for (int j = 1; j <= m; j++)
				printf("%d ", b[i][j]);
			putchar('\n');
		}
		for (int i = 1; i <= n; i++)
		{
			for (int j = 1; j <= m; j++)
				for (int k = 1; k <= n; k++)
					if ((b[k][j] - 1) / m + 1 == i)
					{
						printf("%d ", b[k][j]);
						break;
					}
			putchar('\n');
		}
		return 0;
	}
}
int main()
{
	return zyt::work();
}

Measured memory_bytes: 512