akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,n) for (ll i = 0, i##_len = (n); i < i##_len; i++)

int main() {

    ll n; cin >> n;
    vector<ll> a(n);
    REP(i, n) cin >> a[i];

    vector<ll> dp(n-1, -1);
    for (ll ai : a) {
        if (dp[ai % (n-1)] == -1) {
            dp[ai % (n-1)] = ai;
        } else {
            cout << ai << " ";
            cout << dp[ai % (n-1)] << endl;
            return 0;
        }
    }

}


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

int main() {
  int N, A;
  cin >> N >> A;
  
  if (A >= 500) {
    cout << "Yes" << endl;
  }
  
  else {
   if (A >= N % 500) {
     cout << "Yes" << endl; 
   }
   else {
     cout << "No" << endl;  
   }
  }
  
}

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
module Main where

import Control.Arrow
import Data.Bool
import Data.Functor
import Data.List

main :: IO ()
main = do
  { [n] <- getInts
  ; xs  <- getInts
  ; case selectionSort xs of
      (c,ys) -> do
        { putInts ys
        ; putInts [c]
        }
  }

getInts :: IO [Int]
getInts = map read . words <$> getLine

putInts :: [Int] -> IO ()
putInts = putStrLn . unwords . map show

selectionSort :: Ord a => [a] -> (Int,[a])
selectionSort []  = (0,[])
selectionSort xs  = first sum $ unzip $ unfoldr phi xs
  where
    phi []         = Nothing
    phi xxs@(x:xs) = case break (minx ==) xxs of
      ([],_)      -> Just ((0,x),xs)
      (y:ys,z:zs) -> Just ((1,z),ys++y:zs)
      where
        minx = minimum xxs

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/03/22  Problem: ABC 052 A / Link: http://abc052.contest.atcoder.jp/tasks/abc052_a  ----- */


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

	LL a, b, c, d; cin >> a >> b >> c >> d;
	LL ans = max(a*b,c*d);
	
	
	cout << (ans) << "\n";

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int main(){
	string s; cin >> s;
	int n = s.length();
	if (s[n - 1] == '1'||s[n-2]=='0') {
		cout << -1 << endl; return 0;
	}
	rep(i, n - 1) {
		if (s[i] != s[n - i - 2]) {
			cout << -1 << endl; return 0;
		}
	}
	int num = 2;
	queue<P> out;
	int d = n / 2;
	int now = 1;
	rep(i, d) {
		if (s[i] == '1') {
			out.push({ num,now });
			now = num; num++;
		}
		else {
			out.push({ num,now });
			num++;
		}
	}
	while (num<=n) {
		out.push({ num,now });
		num++;
	}
	while (!out.empty()) {
		P x = out.front(); out.pop();
		cout << x.first << " " << x.second << endl;
	}
	return 0;
}

Measured memory_bytes: 2304
n, k = map(int, input().split())
a = sorted(list(map(int, input().split())))[::-1]

l = 0
r = a[0] + 1
ref = 0
ans = a[0]

while r - l > 1:
    now = (l + r)//2
    for i in a:
        ref += 0 - -i//now - 1
        if ref > k:
            ref = 0
            l = now
            break
    else:
        ans = min(ans, now)
        ref = 0
        r = now
print(ans)

Measured memory_bytes: 30700
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <algorithm>

using namespace std;

struct Pazzle {
    string field;
    int space;
};

map<string, bool> mp;
queue<Pazzle> que;

int main() {
    Pazzle p;
    int num, depth = 0;
    for (int i = 0; i < 9; i++) {
        cin >> num;
        p.field += num + '0';

        if (num == 0) {
            p.space = i;
        }
    }

    que.push(p);
    while (!que.empty()) {
        int size = que.size();
        for (int i = 0; i < size; i++) {
            p = que.front();
            que.pop();

            if (p.field == "123456780") {
                cout << depth << endl;
                return 0;
            }
            if (mp[p.field] == true) {
                continue;
            }
            else {
                mp[p.field] = true;
            }

            if ((p.space + 1) % 3 != 0) {
                swap(p.field[p.space], p.field[p.space + 1]);
                p.space++;
                que.push(p);
                p.space--;
                swap(p.field[p.space], p.field[p.space + 1]);
            }
            if (p.space % 3 != 0) {
                swap(p.field[p.space], p.field[p.space - 1]);
                p.space--;
                que.push(p);
                p.space++;
                swap(p.field[p.space], p.field[p.space - 1]);
            }
            if (2 < p.space) {
                swap(p.field[p.space], p.field[p.space - 3]);
                p.space -= 3;
                que.push(p);
                p.space += 3;
                swap(p.field[p.space], p.field[p.space - 3]);
            }
            if (p.space < 6) {
                swap(p.field[p.space], p.field[p.space + 3]);
                p.space += 3;
                que.push(p);
                p.space -= 3;
                swap(p.field[p.space], p.field[p.space + 3]);
            }
        }
        depth++;
    }
    
    return 0;
}

Measured memory_bytes: 22532
(function (input) {
  'use strict';
  const lines = input.split('\n')
  for(let i=0; i<lines.length;) {
    if (lines[i] == '1') {
      console.log('Hello World')
      i++
      continue
    }
    if (lines[i] == '2') {
      console.log(Number(lines[i+1]) + Number(lines[i+2]))
      i = i + 3
      continue
    }
    i++
  }
})(require("fs").readFileSync("/dev/stdin", 'utf8'));


Measured memory_bytes: 21064
#dp[i][j]=(頂点iをjで塗った時,iを親とする部分木の塗り方の場合の数) j=0:黒 j=1:白
#dp[i][0]=(dp[k][0])の総乗(kはiの子)
#dp[i][1]=(dp[k][0]+dp[k][1])の総乗(kはiの子)
import sys
sys.setrecursionlimit(1000000000)
input = sys.stdin.readline
mod=10**9+7
n=int(input())
es=[[] for i in range(n)]
for i in range(n-1):
   a,b=map(int,input().split())
   es[a-1].append(b-1)
   es[b-1].append(a-1)
dp=[[0,0] for i in range(n)]
def dfs(v,p):
    if dp[v][0]:
        return
    dp[v][0]=dp[v][1]=1
    for i in es[v]:
        if i-p:
            dfs(i,v)
            dp[v][0]*=dp[i][1]
            dp[v][0]%=mod
            dp[v][1]*=dp[i][0]+dp[i][1]
            dp[v][1]%=mod
dfs(0,-1)
print((dp[0][0]+dp[0][1])%mod)

Measured memory_bytes: 110128
#include<cstdio>
#include<algorithm>
using namespace std;
char a[200010];
char b[200010];
int main() {
	int n, m, k;
	scanf("%d %d %d", &n, &m, &k);
	int st, en;
	scanf("%d %d", &st, &en);
	for (int i = 0; i < k; i++)
		scanf(" %1c", &a[i]);
	for (int i = 0; i < k; i++)
		scanf(" %1c", &b[i]);
	int ch = en;
	for (int i = 0; i < k; i++) {
		if (a[i] == 'R')ch++;
		if (ch > m) {
			puts("NO");
			return 0;
		}
		if (b[i] == 'L') {
			if(ch>1)
				ch--;
		}
	}
	ch = en;
	for (int i = 0; i < k; i++) {
		if (a[i] == 'L')ch--;
		if (ch==0) {
			puts("NO");
			return 0;
		}
		if (b[i] == 'R') {
			if (ch<m)
				ch++;
		}
	}
	ch = st;
	for (int i = 0; i < k; i++) {
		if (a[i] == 'U')ch--;
		if (ch == 0) {
			puts("NO");
			return 0;
		}
		if (b[i] == 'D') {
			if (ch < n)
				ch++;
		}
	}
	ch = st;
	for (int i = 0; i < k; i++) {
		if (a[i] == 'D')ch++;
		if (ch > n) {
			puts("NO");
			return 0;
		}
		if (b[i] == 'U') {
			if (ch > 1)ch--;
		}
	}
	puts("YES");
}

Measured memory_bytes: 640
c = input()
alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']

for i in range(len(alphabet)):
    x = str(alphabet[i])
    if c == x:
        print(alphabet[i+1])

Measured memory_bytes: 3060
#include<iostream>

using namespace std;

int main(){

    while(1){
        int ans = 0;
        int n, x;
        cin >> n >> x;
        if(n == 0 && x == 0) break;

        for (int i = 1; i <= n; ++i) {
            for (int j = i+1; j <= n; ++j) {
                for (int k = j+1; k <= n; ++k) {
                    if(i + j + k == x){
                        ans++;
                    }
                }
            }
        }

        cout << ans << endl;
    }


    return 0;
}


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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    int k, q;
    cin >> k >> q;
    vector<ll> d(k);
    for(auto& i : d) cin >> i;

    vector<vector<ll>> query(q, vector<ll>(3));
    REP(i, q){
        REP(j, 3){
            cin >> query[i][j];
        }
    }

    REP(i, q){
        ll n = query[i][0], x = query[i][1], m = query[i][2];
        ll last = x;
        vector<ll> cnt(k);
        REP(j, k){
            cnt[j] = (n-1) / k + ((n-1) % k > j ? 1 : 0);
            last += d[j] % m * cnt[j];
        }
        ll ans = n - 1 - ((last / m) - (x / m));
        REP(j, k){
            if(d[j] % m == 0){
                ans -= cnt[j];
            }
        }

        cout << ans << '\n';
    }

    return 0;
}


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

int main(){
  ll N, K;
  cin >> N >> K;
  vector<ll> h(N);
  for(int i=0; i<N; i++) cin >> h[i];
  sort(h.begin(),h.end());
  
  auto itr = lower_bound(h.begin(), h.end(), K);
  int index = distance(h.begin(), itr);
  
  cout << N-index << endl;
  
  
  return 0;
}


Measured memory_bytes: 3880
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int nax=3002;
const int mod=998244353;
ll dp[nax][nax];
ll pow1(ll a,ll b)
{
    ll ans=1;
    while(b>0)
    {
        if(b%2) ans=(1LL*ans*a)%mod;
        a=(a*1LL*a)%mod;
        b/=2;

    }
    return ans;
   
}
void add_self(ll &a ,ll b)
{
    a=(a+b)%mod;
}
int main()
{
    ll n,s;
    cin>>n>>s;
    int a[n];

for(int i=0;i<n;i++) cin>>a[i];
dp[0][0]=pow1((ll)2,n);
//cout<<dp[0][0]<<endl;
for(int i=1;i<=n;i++)
{
    for(int j=s;j>=0;j--)
    {
        if(j>=a[i-1])
        {
            ll add=pow1(2,mod-2)%mod;
           // cout<<add<<endl;
           add=(add*dp[i-1][j-a[i-1]])%mod;
        add_self(dp[i][j],add);
        }
        add_self(dp[i][j],dp[i-1][j]);
    }
}
cout<<dp[n][s]<<endl;


}


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

int main() {
  long long A, B, C, K;
  cin >> A >> B >> C >> K;
  
  long long count = 0;
  
  count = min(A+count, K);
  long long answer = count;
  count = min(B+count, K);
  
  answer -= K - count;
  
  cout << answer << endl;  
  return 0;
}

Measured memory_bytes: 3624
data=[]

for i in input():
  data.append(int(i))

  
A=data.count(0)+data.count(1)

a=0
b=0
c=0
d=0
if A%2==0:
  for j in range(0,A//2):
    s=2*j
    if data[s]==1:
      a=a+1
    else:
      b=b+1
    if data[s+1]==1:
      c=c+1
    else:
      d=d+1
      
if A%2==1:
  for j in range(0,A//2+1):
    s=2*j
    if data[s]==1:
      a=a+1
    else:
      b=b+1
  for j in range(0,A//2):
    s=2*j
    if data[s+1]==1:
      c=c+1
    else:
      d=d+1
      
      
e=max(a+d,b+c)

print(A-e)
  
    
     

Measured memory_bytes: 4092
//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define trav(x,A) for(auto &x:A)
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<int> veci;
typedef vector<long long> vecl;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

//Required Functions

ll power(ll x,ll y) 
{ 
	if (y == 0) 
		return 1; 
	ll p = power(x, y/2) % MOD; 
	p = (p * p) % MOD; 
  
	return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work
set<string> Z;
void curse_(string S,ll sxr,ll N,ll distc)
{
	if(sxr==N)
	{
		Z.insert(S);
	}
	else
	{
		char d=(char)((ll)'a'+distc);
		FORI(i,0,sxr)
		{
			curse_(S+S[i],sxr+1,N,distc);
		}	
		curse_(S+d,sxr+1,N,distc+1);
	}
}
int main()
{
	#ifndef ONLINE_JUDGE
	if (fopen("INPUT.txt", "r"))
	{
		freopen ("INPUT.txt" , "r" , stdin);
		//freopen ("OUTPUT.txt" , "w" , stdout);
	}
	#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	clock_t clk;
	clk = clock();
//-----------------------------------------------------------------------------------------------------------//

	READV(N);
	curse_("",0,N,0);
	for(auto s:Z)
	{
		cout<<s<<endl;
	}

//-----------------------------------------------------------------------------------------------------------//


	clk = clock() - clk;
	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << endl;

	return 0;
}

Measured memory_bytes: 14208
#include <cstdio>
#include <cctype>
#include <cstring>
#include <algorithm>
#define repu(i,x,y) for (int i=x; i<=y; ++i)
#define lc x<<1
#define rc x<<1|1
#define mid ((l+r)>>1)
using namespace std;

int w,h,n,ans,stk1[300100],top1,stk2[300100],top2,maxw[1100000],tag[1100000],ql,qr;
struct data
{
    int x,y;
    bool operator<(const data &t) const
    {
        return x<t.x;
    }
} a[300100];

int getint()
{
    char ch;
    while (!isdigit(ch=getchar()));
    int x=ch-'0';
    for (; isdigit(ch=getchar()); x=x*10+ch-'0');
    return x;
}

void update(int x)
{
    maxw[x]=max(maxw[lc],maxw[rc])+tag[x];
}

void build(int x,int l,int r)
{
    if (l==r)
    {
        maxw[x]=-a[l].x;
        return;
    }
    build(lc,l,mid),build(rc,mid+1,r);
    update(x);
}

void modify(int x,int l,int r,int w)
{
    if (ql<=l && qr>=r)
    {
        tag[x]+=w,maxw[x]+=w;
        return;
    }
    if (ql<=mid)
        modify(lc,l,mid,w);
    if (qr>mid)
        modify(rc,mid+1,r,w);
    update(x);
}

void modify(int l,int r,int w)
{
    if (l<=r)
        ql=l,qr=r,modify(1,1,n,w);
}

void solve()
{
    sort(a+1,a+1+n);
    memset(tag,0,sizeof(tag));
    build(1,1,n);
    top1=top2=0,stk1[0]=stk2[0]=1;
    repu(i,1,n)
    {
        ans=max(ans,a[i].x+maxw[1]);
        if (a[i].y<=h/2)
        {
            modify(stk1[top1],i-1,-h/2);
            for (; top1 && a[stk1[top1]].y<a[i].y; --top1)
                modify(stk1[top1-1],stk1[top1]-1,a[stk1[top1]].y-h/2);
            stk1[++top1]=i,modify(stk1[top1-1],i-1,h/2-a[i].y);
        }
        else
        {
            modify(stk2[top2],i-1,h/2-h);
            for (; top2 && a[stk2[top2]].y>a[i].y; --top2)
                modify(stk2[top2-1],stk2[top2]-1,h/2-a[stk2[top2]].y);
            stk2[++top2]=i,modify(stk2[top2-1],i-1,a[i].y-h/2);
        }
        modify(i,i,h);
    }
}

int main()
{
    scanf("%d%d%d",&w,&h,&n);
    repu(i,1,n)
        a[i].x=getint(),a[i].y=getint();
    a[++n]=(data){0,0};
    a[++n]=(data){w,0};
    a[++n]=(data){0,h};
    a[++n]=(data){w,h};
    solve();
    repu(i,1,n)
        swap(a[i].x,a[i].y);
    swap(w,h);
    solve();
    printf("%d\n",ans*2);
    return 0;
}

Measured memory_bytes: 12544
import java.io.*;

class Main{
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String str;
while((str=br.readLine())!=null){
String[] s=str.split(" ");
String[] t=br.readLine().split(" ");
int[] a=new int[4];
int[] b=new int[4];
a[0]=Integer.parseInt(s[0]);
a[1]=Integer.parseInt(s[1]);
a[2]=Integer.parseInt(s[2]);
a[3]=Integer.parseInt(s[3]);
b[0]=Integer.parseInt(t[0]);
b[1]=Integer.parseInt(t[1]);
b[2]=Integer.parseInt(t[2]);
b[3]=Integer.parseInt(t[3]);
int hit=0;
int blow=0;
for(int i=0;i<4;i++){
for(int j=0;j<4;j++){
if(a[i]==b[j]){
if(i==j){
hit++;
}
else{
blow++;
}
}
}
}
System.out.println(hit+" "+blow);
}
}
}

Measured memory_bytes: 16916
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 998244353;

long long int N, M, K, H, W, L, R;
//int N, M, K, H, W, L, R

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

	cin >> N;
	map<long long int, int>m;
	m[N]++;
	for (int i = 2; i <= 10000000; i++) {
		if (N % 2)N = N * 3 + 1;
		else N /= 2;
		if (m[N]) {
			cout << i << endl;
			return 0;
		}
		m[N]++;
	}
	return 0;
}

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

int n;
int points[100005][3];
ll memo[100005][4];

ll dp(int idx, int last_activity){
    ll &res = memo[idx][last_activity];
    if(res != -1){
        return res;
    }
    if(idx == n){
        return res = 0;
    }
    res = 0;
    for(int i = 0; i < 3; i++){
        if(i != last_activity){
            res = max(res, dp(idx + 1, i) + points[idx][i]);
        }
    }
    return res;
}

int main(){
    memset(memo, -1, sizeof memo);
    scanf("%d", &n);
    for(int i = 0; i < n; i++){
        scanf("%d%d%d", &points[i][0], &points[i][1], &points[i][2]);
    }
    printf("%lld", dp(0, 3));
}


Measured memory_bytes: 15728
#include <bits/stdc++.h>
using namespace std;
#define _overload3(_1,_2,_3,_4,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,n) (int i=a;i<n;i++)
#define per(i,a,n,s) (int i=n-1;i>=a;i--)
#define range(...) _overload3(__VA_ARGS__,per,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define vecin(x) for(auto&youso_: (x) ) cin >>  youso_
#define vecout(x) for(auto&youso_: (x) ) cout << youso_ << " " ; cout << 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; }
const int inf = 1e9+10;
const int mod = 1e9+7;
const long long llinf = 1e18;
#define _GLIBCXX_DEBUG
// head

int main(){
    int n,m,a,b;
    cin >> n >> m;
    vector<bool> data1(n+1,false);
    vector<bool> datan(n+1,false);
    for range(i,m){
        cin >> a >> b;
        if (a>b) { swap(a,b); }
        if (a==1) { data1[b]=true; }
        if (b==n) { datan[a]=true; }
    }
    for range(i,2,n) {
        if (data1[i] && datan[i]) {
            cout << "POSSIBLE"  << endl;
            return  0;
        }
    }
    // for range(i,1,n) { cout << data1[i] << " "  << datan[i] << endl;}
    cout << "IMPOSSIBLE" << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

//#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long int
#define pb push_back


int main() {
  int N, K, zero = -1, sum = 0;
  cin >> N >> K; 
  vector<ll> a(N);
  vector<ll> b; 
  double index = -1;

  rep(i, N){
    cin >> a[i];
    if (a[i] >= 0 && zero==-1) zero = i;
  }

  // 累積和作成
  b.push_back(0);
  rep(i, N - 1){
    sum += abs(a[i]-a[i+1]);
    b.push_back(sum); 
  }


  // 間Kこの表現 b[K+i-1] - b[i]
  ll min_length = pow(10, 13), tmp;
  for(int i = 0; i < N-K+1; i++) {
    if(a[K+i-1]*a[i] >= 0){ // 偶奇が一致している場合
      tmp = b[K+i-1] - b[i];
      if(a[i] >= 0) tmp+=a[i];
      else tmp += abs(a[K+i-1]);
    } else { // 0を挟んでいる場合
      tmp = b[K+i-1] - b[i] + min(abs(a[K+i-1]), abs(a[i]));
    }
    // cout << tmp << endl;
    min_length = min(tmp, min_length);

  }
  
  cout << min_length << endl;

}


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

int main() {
  int P,Q,R;
  cin >> P >> Q >> R;
if(P >= R && P >= Q){
 cout << R + Q <<endl;
}
else if(R >= P && R >= Q){
   cout << P + Q <<endl;
}
   else {
     cout << P + R <<endl;
   }
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
import numpy as np


def solve(N: int, d: "List[int]"):
    sum = 0
    for i in range(N-1):
        for j in range(i,N):
            if i!=j:
                sum+=d[i]*d[j]

    print(sum)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    d = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, d)

if __name__ == '__main__':
    main()


Measured memory_bytes: 12396
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,m,flag=0,i;
    cin>>n;
    for(i=9;i>0;i--)
    {
        if(n%i==0)
        {
            m=n/i;
            if(m>=1&&m<=9)
            {
                flag=1;
                break;
            }
        }
    }
    if(flag==1) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}



Measured memory_bytes: 3604
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const int INF=1000000001;
const double PI=3.141592653589;


int main(){
  int a,b,c; cin>>a>>b>>c;
  if(a==b)
  cout<<c<<endl;
  else if(b==c)
  cout<<a<<endl;
  else
  cout<<b<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

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

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


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 20)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する


int main() {
    int n;
    cin >> n;
    string s = to_string(n);
    int a = 0;
    rep(i,0,s.size()){
        a += s[i] - '0';
    }
    if(n%a){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int m,n,i;
	cin>>m>>n;
	if(m>=n)
	{
		for(i=1;i<=m;i++)
		cout<<n;
	}
	else {
		for(i=1;i<=n;i++)
		cout<<m;
	}
 } 

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
typedef long long ll;
const ll MOD=1e+9+7;
struct mint{
  ll x;
  mint(ll x=0):x(x%MOD){}
  mint& operator+=(const mint a){
    if((x+=a.x)>=MOD) x-=MOD;
    return *this;
  }
  mint& operator-=(const mint a){
    if((x += MOD-a.x)>=MOD) x-=MOD;
    return *this;
  }
  mint& operator*=(const mint a){
    (x*=a.x)%=MOD;
    return *this;
  }
  mint operator+(const mint a) const{
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const{
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const{
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const{
    if(!t) return 1;
    mint a = pow(t>>1);
    a*=a;
    if(t&1) a*=*this;
    return a;
  }
  
  //for prime mod
  mint inv() const{
    return pow(MOD-2);
  }
  mint& operator/=(const mint a){
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const{
    mint res(*this);
    return res/=a;
  }
};

int main()
{
  int n,m;
  cin >> n >> m;
  vector<int> s(n),t(m);
  rep(i,n) cin >> s[i];
  rep(i,m) cin >> t[i];

  vector<vector<mint>> dp(n,vector<mint>(m));
  vector<vector<mint>> sum(n+1,vector<mint>(m+1));
  rep(i,n){
    rep(j,m){
      if(s[i]==t[j]){
	dp[i][j] = sum[i][j]+(mint)1;
      }
      sum[i+1][j+1] = dp[i][j]+sum[i][j+1]+sum[i+1][j]-sum[i][j];
    }
  }

  // rep(i,n){
  //   rep(j,m) cout << dp[i][j].x << " ";
  //   cout  << "\n";
  // }

  // rep(i,n+1){
  //   rep(j,m+1) cout << sum[i][j].x << " ";
  //   cout  << "\n";
  // }

  mint res(1);
  rep(i,n) rep(j,m) res += dp[i][j];
  cout << res.x << "\n";

  return 0;
}


Measured memory_bytes: 62976
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int N, Q; cin >> N >> Q;
    string S; cin >> S;
    int cnt = 0;
    vector<int> A(N);
    rep(i, N-1){
        if(S.at(i)=='A'&&S.at(i+1)=='C'){
            cnt++;
        }
        A.at(i) = cnt;
    }
    A.at(N-1) = cnt;

    rep(i, Q){
        int l, r; cin >> l >> r;
        int ans = A.at(r-1)-A.at(l-1);
        if(S.at(l-1)=='A'&&S.at(l)=='C') ans++;
        if(S.at(r-1)=='A'&&A.at(r-1)-A.at(r-2)==1) ans--;
        cout << ans << endl;
    }
}

Measured memory_bytes: 1408
s = list(input())

i = int(s[0] + s[1])
k = int(s[2] + s[3])

if 0 < i <= 12:
  if 0 < k <= 12:
    print('AMBIGUOUS')
  else:
    print('MMYY')
else:
  if 0 < k <= 12:
    print('YYMM')
  else:
    print('NA')

Measured memory_bytes: 3060
# 自分の回答
stdin = list(map(int, input().split()))
n = stdin[0]
a = stdin[1]
b = stdin[2]

ans = 0
for j in range(n+1):
    wa = 0
    array = list(map(int, str(j)))
    for k in range(len(str(j))):
        # print(array[k])
        wa += array[k]
    if wa >= a and wa <= b:
        # print(j)
        ans += j

print(ans)


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

int main(void) {
    
    long long N, K;
    scanf("%lld", &N); scanf("%lld", &K);

    int towns[N];
    for (int i=0; i<N; i++) {
        scanf("%d", &towns[i]);
    }

    vector<bool> visited(N+1, false);
    vector<int> visited_locations;
    int location=1;
    int i=0;

    while (1) {
        if (visited[location]) {
            break;
        }

        visited_locations.push_back(location);
        visited[location] = 1;
        location = towns[location - 1];
    }

    vector<int>::iterator it = find(visited_locations.begin(), 
                                    visited_locations.end(), 
                                    location);

    int index = distance(visited_locations.begin(), it);
    //cout << index << endl;

    int distance = visited_locations.size() - index;
    //cout << distance << endl;

    //for (int i=0; i<visited_locations.size(); i++) printf("%d ", visited_locations[i]);
    //printf("\n");
    //for (int i=0; i<visited.size(); i++) printf("%s ", visited[i] ? "true":"false");
    //printf("\n");

    if (K <= index) {
        printf("%d\n", visited_locations[K]);
    } else {
        printf("%d\n", visited_locations[(int) (index + (K - index) % distance)]);
    }

}

Measured memory_bytes: 4688
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
#define mem(a,v) memset((a), (v), sizeof (a))
#define enl printf("\n")
#define case(t) printf("Case #%d: ", (t))
#define ni(n) scanf("%d", &(n))
#define nl(n) scanf("%lld", &(n))
#define nai(a, n) for (int i = 0; i < (n); i++) ni(a[i])
#define nal(a, n) for (int i = 0; i < (n); i++) nl(a[i])
#define pri(n) printf("%d\n", (n))
#define prl(n) printf("%lld\n", (n))
#define pii pair<int, int>
#define pil pair<int, long long>
#define pll pair<long long, long long>
#define vii vector<pii>
#define vil vector<pil>
#define vll vector<pll>
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef cc_hash_table<int,int,hash<int>> ht;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
const double pi = acos(-1);
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const int MAXN = 1e6 + 5;
const double eps = 1e-9;
vi adj[MAXN];
int U[MAXN], V[MAXN], deg[MAXN], vis[MAXN];

void dfs(int u, int p) {
	if (vis[u]) return;
	vis[u] = 1;
	for (int v: adj[u])
		dfs(U[v]^V[v]^u, v);
	if (p!=-1 && deg[u]) {
		swap(U[p],V[p]);
		deg[u] ^= 1;
		deg[U[p]^V[p]^u] ^= 1;
	}
}

int main() {
	int n, m;
	scanf("%d %d", &n, &m);
	for (int i = 0; i < m; i++) {
		scanf("%d %d", &U[i], &V[i]);
		adj[U[i]].pb(i);
		adj[V[i]].pb(i);
		deg[U[i]] ^= 1;
	}
	if (m & 1) return !printf("-1\n");
	dfs(1, -1);
	for (int i = 0; i < m; i++)
		printf("%d %d\n", U[i], V[i]);
    return 0;
}


Measured memory_bytes: 44544
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <tuple>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repd(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define repdm(i, a, b) for (ll i = (ll)(a); i > (ll)(b); i--)
const ll INF = 1LL << 60;

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

int N, K;
ll h[100010];
ll dp[100010];

ll rec(int i)
{
  if (dp[i] < INF)
    return dp[i];
  if (i == 0)
    return 0;

  ll res = INF;
  repd(k, 1, K + 1)
  {
    if (i - k < 0)
      continue;
    chmin(res, rec(i - k) + abs(h[i - k] - h[i]));
  }

  return dp[i] = res;
}

int main()
{
  cin >> N >> K;
  rep(i, N) cin >> h[i];
  rep(i, N) dp[i] = INF;

  cout << rec(N - 1) << endl;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const int INF = 2e9;
template<class T> void print(const T& t){ cout << t << endl; }
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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
ll dpa[107];
ll dpb[107];
ll dp[107];
int main(){
  ll n;
  cin >> n;
  vi a(n);
  vi b(n);
  cin >> a[0];
  dpa[0] = a[0];
  for(ll i=1;i<n;i++){
    cin >> a[i];
    dpa[i] = dpa[i - 1] + a[i];
  }
  cin >> b[0];
  dpb[0] = b[0];
  for(ll i=1;i<n;i++){
    cin >> b[i];
    dpb[i] = dpb[i - 1] + b[i];
  }
  dp[0] = dpa[0] + dpb[n-1];
  for (ll i = 1; i < n; i++){
    dp[i] = dpa[i] + dpb[n-1] - dpb[i - 1];
  }
  ll ans = 0;
  rep(i, n) chmax(ans, dp[i]);
  print(ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    char x, y;
    cin >> x >> y;
    if(x == y) cout << "=" << endl;
    else if(x > y) cout << ">" << endl;
    else cout << "<" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main() {
	int tc;
	scanf("%d\n",&tc);
	char ans[5];
	
	int AC_ctr = 0;
	int WA_ctr = 0;
	int TLE_ctr = 0;
	int RE_ctr = 0;
	
	for (int i = 0; i < tc; i++)
	{
		scanf("%s\n",&ans);
		if (ans[0] == 'A')
		{
			AC_ctr++;
		} 
		else if (ans[0] == 'W')
		{
			WA_ctr++;
		} 
		else if (ans[0] == 'T')
		{
			TLE_ctr++;
		} 
		else if (ans[0] == 'R')
		{
			RE_ctr++;
		}
	}

	printf("AC x %d\n",AC_ctr);
	printf("WA x %d\n",WA_ctr);
	printf("TLE x %d\n",TLE_ctr);
	printf("RE x %d\n",RE_ctr);
	return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main() {
    string S; cin >> S;
    int s = S.size();
    int cnt0 = 0;
    int cnt1 = 0;
    rep(i, s){
        if(S[i] == '0'){
            cnt0++;
        } else {
            cnt1++;
        }
    }
    int ans = min(cnt0, cnt1);
    ans *= 2;

    cout << ans << endl;


    return 0;
}

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

using namespace std;

typedef long long ll;

vector<int> friends[100005];
vector<int> groups[100005];

class UnionFind {
public:
  vector <long long> par;
  vector <long long> siz;
  // Constructor
  UnionFind(long long sz_): par(sz_), siz(sz_, 1LL) {
    for (long long i = 0; i < sz_; ++i) par[i] = i;
  }
  void init(long long sz_) {
    par.resize(sz_);
    siz.assign(sz_, 1LL);
    for (long long i = 0; i < sz_; ++i) par[i] = i;
  }
  long long root(long long x) {
    while (par[x] != x) {
      x = par[x] = par[par[x]];
    }
    return x;
  }
  bool unite(long long x, long long y) {
    x = root(x);
    y = root(y);
    if (x == y) return false;
    if (siz[x] < siz[y]) swap(x, y);
    siz[x] += siz[y];
    par[y] = x;
    return true;
  }
  bool is_same_g(long long x, long long y) {
    return root(x) == root(y);
  }
  long long size(ll x) {
    return siz[root(x)];
  }
};

int main() {
  int n, m, k;
  cin >> n >> m >> k;
  UnionFind tree(n);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    friends[a].push_back(b);
    friends[b].push_back(a);
    tree.unite(a, b);
  }
  for (int i = 0; i < k; i++) {
    int c, d;
    cin >> c >> d;
    c--; d--;
    groups[c].push_back(d);
    groups[d].push_back(c);
  }
  for (int i = 0; i < n; i++) {
    long long cnt = tree.size(i)-1;
    vector<int> t;
    for (int j = 0; j < friends[i].size(); j++) {
      t.push_back(friends[i][j]);
    }
    for (int j = 0; j < groups[i].size(); j++) {
      if (tree.is_same_g(i, groups[i][j])) {
        t.push_back(groups[i][j]);
      }
    }
    sort(t.begin(), t.end());
    unique(t.begin(), t.end());
    int dif = t.size();
    cout << cnt-(dif);
    cout << ( (i == n-1) ? "\n" : " ");
  }

  return 0;
}

Measured memory_bytes: 13816
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

const long long INF = 1e18;
//const ll mod = 1000000007;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll X;
    cin >> X;
    X = __gcd(X, 360LL);
    cout << 360 / X << endl;
    return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int k=nxt(),s=nxt();
    ll test=0;
    for(int i=0;i<=k;i++)
        for(int j=0;j<=k;j++)
            if(i+j<=s&&(s-i-j)<=k&&(s-i-j)>=0)
                test++;
        cout<<test<<endl;
    
    
    return 0;   
}




 
 


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <cstdio>

using namespace std;

struct Point2D {
        double x, y;
        Point2D(double _x = 0.0, double _y = 0.0) : x(_x), y(_y) { }
        bool operator==(const Point2D &p) const { return x == p.x && y == p.y; }
        bool operator!=(const Point2D &p) const { return x != p.x || y != p.y; }
        bool operator<(const Point2D &p) const {
                if(x < p.x){ return true; }
                if(x > p.x){ return false; }
                return y < p.y;
        }
};

Point2D operator+(const Point2D &a, const Point2D &b){
        return Point2D(a.x + b.x, a.y + b.y);
}
Point2D operator-(const Point2D &a, const Point2D &b){
        return Point2D(a.x - b.x, a.y - b.y);}

double cross2d(const Point2D &a, const Point2D &b){
        return a.x * b.y - a.y * b.x;
}

double convexArea(const vector<Point2D> &polygon){
        double sum = 0.0;
        for(int i = 1; i < polygon.size(); ++i){
                sum += cross2d(polygon[i - 1], polygon[i]);
        }
        sum += cross2d(polygon.back(), polygon[0]);
        return sum / 2;
}

int main(){
        int caseNum = 0;
        while(true){
                int n;
                cin >> n;
                if(n == 0){ break; }
                vector<Point2D> polygon(n);
                for(int i = 0; i < n; ++i){
                        cin >> polygon[i].x >> polygon[i].y;
                }
                printf("%d %.1lf\n", ++caseNum, abs(convexArea(polygon)));
        }
        return 0;
}

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

const int M=3005;
const int MM=2e5+5;
const int MO=1e9+7;

inline int add(int x,int y)
{
	x+=y;
	if(x>=MO) x-=MO;
	return x;
}
inline int sub(int x,int y)
{
	x-=y;
	if(x<0) x+=MO;
	return x;
}
inline int mul(int x,int y)
{
	return 1LL*x*y%MO;
}
inline void addv(int &x,int y)
{
	x+=y;
	if(x>=MO) x-=MO;
}
inline void subv(int &x,int y)
{
	x-=y;
	if(x<0) x+=MO;
}
inline void mulv(int &x,int y)
{
	x=1LL*x*y%MO;
}

int inv[MM],fa[MM],ifa[MM];
void init()
{
	fa[0]=ifa[0]=1;
	inv[1]=fa[1]=ifa[1]=1;
    for(int i=2;i<MM;i++)
    {
    	fa[i]=mul(fa[i-1],i);
    	inv[i]=mul(MO-MO/i,inv[MO%i]);
    	ifa[i]=mul(inv[i],ifa[i-1]);
    }
}

int C(int n,int m)
{
	return mul(mul(fa[n],ifa[m]),ifa[n-m]);
}

struct Point
{
	int x,y;
	void read()
	{
		scanf("%d%d",&x,&y);
	}
	bool operator<(const Point &B) const
	{
		return x+y<B.x+B.y;
	}
	bool operator==(const Point &B) const
	{
		return x+y==B.x+B.y;
	}
}p[M];

int dp[M]; // from (0,0) i is the first to block the path

int main()
{
	init();
	int h,w,n;
	scanf("%d%d%d",&h,&w,&n);
	for(int i=0;i<n;i++)
		p[i].read();
	p[n].x=h; p[n].y=w;
	n++;
	sort(p,p+n);
	for(int i=0;i<n;i++)
	{
		int r=p[i].x-1,c=p[i].y-1;
		dp[i]=C(r+c,c);
		for(int j=0;j<i;j++)
		{
			if(p[i].x<p[j].x||p[i].y<p[j].y) continue;
			int r=p[i].x-p[j].x,c=p[i].y-p[j].y;
			//cout<<p[i].x<<" "<<p[j].x<<" "<<p[i].y<<" "<<p[j].y<<endl;
			//assert(r>=0&&c>=0);
			subv(dp[i],mul(dp[j],C(r+c,c)));
		}
	}
	printf("%d\n",dp[n-1]);
	return 0;
}

Measured memory_bytes: 2560
//#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <bitset>
#include <string>
#include <set>
#include <stack>
#include <sstream>
#include <list>
#include <array>
#include <vector>
#include <queue>
#include <map>
#include <memory>
#include <iterator>
#include <climits>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
#define FAST_IO ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef unsigned int UINT;
typedef unsigned long long ull;
typedef pair<int, int> pdi;
typedef pair<ll, int> pli;

int const maxn = 1e5 + 10;
inline int lc(int x)  {return x << 1;}
inline int rc(int x)  {return x << 1 | 1;}

ll v[maxn];
int cnt = 0;

int main(void) {
    FAST_IO;
    
    ll a, b;
    cin >> a >> b;
    ll g = __gcd(a, b);
    // vector<ll> v;
    for (ll i = 1; i * i <= g; i++) {
        if (g % i == 0) {
            // v.push_back(i);
            v[cnt++] = i;
            if (i * i == g) continue;
            // v.push_back(g / i);
            v[cnt++] = g / i;
        }
    }
    // cout << cnt << endl;
    sort(v,v + cnt);
    for (int i = cnt - 1; i > 0; i--) {
        for (int j = i - 1; j > 0; j--) {
            if (v[i] % v[j] == 0) {
                cnt--;
                break;  
            }
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,p,q,t;
    int j=999999;
    cin>>n>>t;
    for(i=0;i<n;i++){
        cin>>p>>q;
        if(q<=t) {
           if(p<j) {
            j=p;
           }
        }
    }
    if(j==999999) cout<<"TLE"<<endl;
    else cout<<j<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string a, b, c ;
  cin >> a >> b >> c;
  char dif = 'A' - 'a';
  
  a.at(0) = a.at(0)+dif;
  b.at(0) = b.at(0)+dif;
  c.at(0) = c.at(0)+dif;
  
  cout << a.at(0) << b.at(0) << c.at(0) << endl; 
  
}

Measured memory_bytes: 256
#pragma comment(linker, "/STACK:102400000,102400000")
//#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <climits>
#include <stdlib.h>
#include <deque>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <string>
#include <vector>
#include <bitset>
#include <complex>
#include <functional>
#include <fstream>
#include <ctime>
#include <stdexcept>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
const int INF = 0x3f3f3f3f;
const int maxn = 1e5+5;
const int mod = 1e6;
const double eps = 1e-8;
const double pi = asin(1.0)*2;
const double e = 2.718281828459;
bool Finish_read;
template<class T>inline void read(T &x){Finish_read=0;x=0;int f=1;char ch=getchar();while(!isdigit(ch)){if(ch=='-')f=-1;if(ch==EOF)return;ch=getchar();}while(isdigit(ch))x=x*10+ch-'0',ch=getchar();x*=f;Finish_read=1;}

struct ac {
	int v;
	int dis;
	int cost;
};

int n, m;
int a, b, d, c;
int ans;
int dis[maxn];
int cost[maxn];
bool vis[maxn];
vector<ac> Adj[maxn];

void Dijkstra() {
	mem(dis, INF);
	mem(cost, INF);
	mem(vis, 0);
	dis[1] = 0;
	cost[1] = 0;
	for (int i = 1; i <= n; ++i) {
		int u = -1, dismin = INF, costmin = INF;
		for (int j = 1; j <= n; ++j) {
			if (!vis[j]) {
				if (dis[j] < dismin) {
					u = j;
					dismin = dis[j];
					costmin = cost[j];
				}
				else if (dis[j] == dismin) {
					if (cost[j] < costmin) {
						u = j;
						dismin = dis[j];
						costmin = cost[j];
					}
				}
			}
		}
		if (u == -1) {
			return;
		}
		vis[u] = 1;
		for (int j = 0; j < int(Adj[u].size()); ++j) {
			int v = Adj[u][j].v;
			if (!vis[v]) {
				if (dis[u] + Adj[u][j].dis < dis[v]) {
					dis[v] = dis[u] + Adj[u][j].dis;
					cost[v] = Adj[u][j].cost;
				}
				else if (dis[u] + Adj[u][j].dis == dis[v]) {
					if (Adj[u][j].cost < cost[v]) {
						cost[v] = Adj[u][j].cost;
					}
				}
			}
		}
	}
}

int main(int argc, char *argv[]) {
//#ifndef ONLINE_JUDGE
//	freopen("in.txt", "r", stdin);
//	freopen("out.txt", "w", stdout);
//#endif
	while (~scanf("%d%d", &n, &m), n + m) {
		for (int i = 1; i <= m; ++i) {
			read(a); read(b); read(d); read(c);
			ac add;
			add.v = b;
			add.dis = d;
			add.cost = c;
			Adj[a].pb(add);
			add.v = a;
			Adj[b].pb(add);
		}
		Dijkstra();
		ans = 0;
		for (int i = 1; i <= n; ++i) {
			Adj[i].clear();
//			printf("dis[%d]=%d cost[%d]=%d\n", i, dis[i], i, cost[i]);
			ans += cost[i];
		}
		printf("%d\n", ans);
	}
//#ifndef ONLINE_JUDGE
//	fclose(stdin);
//	fclose(stdout);
//	system("gedit out.txt");
//#endif
    return 0;
}



Measured memory_bytes: 7948
n = gets.chomp.to_i
arr = gets.chomp.split(' ').map(&:to_i).sort.reverse
if arr[-1] == 0
  puts 0
  exit
end
sum = 1
i = 0
while i < n
  sum *= arr[i]
  if sum > 10**18
    puts "-1"
    exit
  end
  i += 1
end
puts sum

Measured memory_bytes: 25012