akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    int a,b,k;
    cin >> a >> b >> k;
    if(a + k - 1 >= b - k + 1)
    {
        for(int i = a;i <= b;i++)
        {
            cout << i << "\n";
        }
    }
    else
    {
        for(int i = a;i <= a + k - 1;i++)
        {
            cout << i << "\n";
        }
        for(int i = b - k + 1;i <= b;i++)
        {
            cout << i << "\n";
        }
    }

    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
a.sort()

a_sum = [0 for i in range(n)]
a_sum[0] = a[0]
for i in range(1, n):
    a_sum[i] = a_sum[i - 1] + a[i]

cnt = 1
for i in range((n - 1) - 1, -1, -1):
    if a[i + 1] <= a_sum[i] * 2:
        cnt += 1
    else:
        break

print(cnt)


Measured memory_bytes: 14308
#include <stdio.h>
#include <string.h>
int main(void)
{
  int n,m,c,i;
  char p[2000002],s[2000002];
  while(1){
    c=0;
    scanf("%d",&n);
    if(!n) break;
    for(i=0;i<n;i++){
      p[2*i]='I';
      p[2*i+1]='O';
    }
    p[2*i]='I';
    scanf("%d",&m);
    scanf("%s",s);
    for(i=0;i<m-2*n;i++){
      if(strncmp(p,&s[i],2*n+1)==0)
	c++;
    }
    printf("%d\n",c);
  }
  return 0;
}

Measured memory_bytes: 2680
#include<cstdio>
#include<cmath>
#include<vector>
#define mod 1000000007
using namespace std;

long calc(long x){
    long t[31],a[31],ans=1;
    t[0]=1;
    a[0]=x;
    ans=x;
    for(int i=1;i<31;i++){
        t[i]=2*t[i-1];
        a[i]=a[i-1]*a[i-1];
        a[i]%=mod;
        if((mod-2)&t[i]){
            ans*=a[i];
            ans%=mod;
        }
    }
    return ans;
}

int main(){
    long n,m,t[100100],inv[100100],s,ans=1;
    vector<long> v;
    scanf("%ld %ld",&n,&m);
    s=sqrt(m);
    t[0]=1;
    for(long i=1;i<=n+30;i++){
        t[i]=t[i-1]*i;
        t[i]%=mod;
    }
    inv[n+30]=calc(t[n+30]);
    for(long i=n+29;i>=0;i--){
        inv[i]=inv[i+1]*(i+1);
        inv[i]%=mod;
    }
    for(long i=2;i<=s;i++){
        if(m%i==0){
            v.push_back(1);
            m/=i;
            while(m%i==0){
                v.back()++;
                m/=i;
            }
        }
    }
    if(m>1){
        v.push_back(1);
    }
    for(long i=0;i<v.size();i++){
        ans*=t[v[i]+n-1];
        ans%=mod;
        ans*=inv[v[i]];
        ans%=mod;
        ans*=inv[n-1];
        ans%=mod;
    }
    printf("%ld\n",ans);
}

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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

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

    vector<int> a1(n);
    vector<int> a2(n);
    int s1=0, s2=0;

    for(int in=0;in<n;in++) {
        cin >> a1.at(in);
        s1 += a1.at(in);
    }
    for(int in=0;in<n;in++) {
        cin >> a2.at(in);
    }
    s2 = a2.at(n-1);

    int ans = s1+s2;
    for(int in=n-1;in>=1;in--) {
        s1 -= a1.at(in);
        s2 += a2.at(in-1);
        ans = max(ans, s1+s2);
    }

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


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll INF=1e18;

int main()
{
    ll n,m;
    cin >> n >> m;
    vector<ll> x(m),y(m-1);
    rep(i,m){
        cin >> x[i];
    }
    ll sum=0;
    sort(x.begin(),x.end());
    rep(i,m-1){
        y[i]=x[i+1]-x[i];
        sum+=y[i];
    }
    sort(y.rbegin(),y.rend());
    ll times=min(n-1,m-1);
    rep(i,times){
        sum-=y[i];
    }
    cout << sum << endl;
    return 0;
} 

Measured memory_bytes: 1792
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author ZYCSwing
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int sum = 0;
            int m = n;
            while (m > 0) {
                sum += m % 10;
                m /= 10;
            }
            out.println(n % sum == 0 ? "Yes" : "No");
        }

    }
}



Measured memory_bytes: 21844
R, G, B, N = map(int, input().split())
ans = 0
for r in range(N // R + 1):
    for g in range(N // G + 1):
        n = R * r + G * g
        if N - n >= 0 and (N - n) % B == 0:
            ans += 1
print(ans)


Measured memory_bytes: 40812
//file_name:ABC112_B.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts()
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;

    // 整数スキャン（複数）
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&y);

    // n個の整数のスキャン
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // 文字列スキャン
    /*
    string s;
    cin >> s;
    */


int main() {
    int n;
    scanf("%d",&n);
    int T;
    scanf("%d",&T);
    ll c[n] = {};
    ll t[n] = {};
    int min = 9999;
    rep(i,n){
        scanf("%lld",&c[i]);
        scanf("%lld",&t[i]);
        if(t[i]<=T){
            if(min>c[i]){
                min=c[i];
            }
        }
    }


    int ans = min;
    if(ans>1000){
        puts("TLE");
    }else{
        cout << ans << endl;
    }

    

    return 0;
}



Measured memory_bytes: 256
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
# 約数列挙
def find_divisor(n):
    divisors=[]
    for i in range(1, int(sqrt(n)) + 1):
        if n % i == 0:
            divisors.append(i)
            if i*i!=n:
                divisors.append(n // i)
    return divisors


def main():
    X=I()
    S=set()
    for i in range(10**5):
        S.add(i**5)
        S.add(-i**5)
    for s in S:
        if(X-s in S):
            B=int(pow(abs(X-s),1/5))
            if(X-s<0):
                B*=-1
            A=int(pow(abs(s),1/5))
            if(s<0):
                A*=-1
            print(A,-B)
            break

if __name__ == '__main__':
    main()

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

using namespace std;

#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n);i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(a);i>=(int)(b);--i)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;

const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

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

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

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

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  REP(i, SZ(v)) {
    if(i) os << " ";
    os << v[i];
  }
  return os;
}

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

  ll n; cin >> n;
  ll tmp = 1;
  REP(i, n) {
    tmp *= 9;
    tmp %= MOD;
  }
  tmp *= 2;
  tmp %= MOD;

  ll tmp2 = 1;
  REP(i, n) {
    tmp2 *= 8;
    tmp2 %= MOD;
  }
  tmp = (tmp - tmp2 + MOD) % MOD;

  ll tmp3 = 1;
  REP(i, n) {
    tmp3 *= 10;
    tmp3 %= MOD;
  }

  cout << (tmp3 - tmp + MOD) % MOD << endl;

  return 0;
}








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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
const ll MOD = 13;
const ll mod_ans = 1e9 + 7;
long long modPow(int x, int n){
  if(n == 0) return 1;
  if(n % 2 == 0) {
    long long sqrtX = modPow(x,n/2);
    return sqrtX * sqrtX % MOD ;
  }else{
    return x * modPow(x,n-1) % MOD;
  }
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  ll dp[s.size() + 1][13];
  memset(dp,0,sizeof(dp));
  dp[0][0] = 1;
  rep(i,s.size()){
    rep(j,13){
      if(s[i] != '?'){
        int num = int(s[i] - '0');
        ll tmp = ((j+(num* modPow(10,s.size()-i-1)))) % 13;
        dp[i+1][ tmp ] += dp[i][j] ;
        dp[i+1][tmp] %= mod_ans;
      }else{
        rep(k,10){
          dp[i+1][( (k* modPow(10,s.size()-i-1)) + j) % 13] += dp[i][j] ;
          dp[i+1][( (k* modPow(10,s.size()-i-1)) + j) % 13] %= mod_ans;
        }
      }
    }
  }
  cout << dp[s.size()][5] << endl;
  return 0;
}


Measured memory_bytes: 10704
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<set>
#include<cstdio>

using namespace std;

#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define P pair<int, int>

typedef vector<int> vec;
typedef vector<vec> mat;

ll n;
ll a[10000001];


void fuct(){
    for (ll i = 2; i <= n; i++){
        if(a[i] == 1){
            for (ll j = i; j <= n; j += i){
                ll m = j;
                ll num = 0;
                while (m % i == 0){
                    m /= i;
                    num++;
                }
                a[j] *= (num + 1);
            }
        }
    }
}

int main(){
    cin >> n;
    fill(a, a + n + 1, 1);
    fuct();
    // rep(i, n+1){
    //     cout << i << ": " << a[i] << endl;
    // }
    ll ans = 0;
    for (ll i = 1; i <= n; i++){
        ans += a[i] * i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 81760
#include<cstdio>
#include<iostream>
#define MN 100005
using namespace std;
int n,k;
long long a[MN],ans,s1[MN],s2[MN];
int main()
{
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++){
        scanf("%lld",&a[i]);
        s1[i]=s1[i-1]+a[i];
        s2[i]=s2[i-1];
        if(a[i]>0) s2[i]+=a[i];
    }
    for(int i=k;i<=n;i++){
        long long t1=s1[i]-s1[i-k],t2=s2[i-k]+s2[n]-s2[i];
        if(t1>0) t2+=t1;
        ans=max(ans,t2);
    }
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <numeric>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
 
int main() {
    int r;
    cin >> r;
 
    cout << 2*r*3.14159265358979323846 << endl;
}

Measured memory_bytes: 3788
n=int(input())
a,b=map(int,input().split())
P=list(map(int,input().split()))
q,w,e=0,0,0
for i in P:
    if i<=a:
        q+=1
    elif i<=b:
        w+=1
    else:
        e+=1
print(min(q,w,e))

Measured memory_bytes: 61900
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
using namespace std;

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

  deque<int> r, w;
  rep(i,0,N-1)
  {
    char ch;
    cin >> ch;
    if (ch == 'R') r.push_back(i);
    else w.push_back(i);
  }

  if (w.size() == 0 || r.size() == 0)
  {
    cout << 0 << endl;
    return 0;
  }

  int ans = 0;
  while (w.front() < r.back())
  {
    ans++;
    int w_front = w.front(); w.pop_front();
    int r_back = r.back(); r.pop_back();
    r.push_front(w_front);
    w.push_back(r_back);
  }

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


Measured memory_bytes: 4432
#include<iostream>
#include<string.h>
#include<ctype.h>
#include<string>
#include<math.h>
#define pi 3.141592653589
#include<iomanip>
#include<vector>
using namespace std;
#include<algorithm>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 1e9
#define LINF 1e17
#define ll long long
#define MOD (int)(1e9+7)

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



int main() {

	int n, cnt = 0;

	cin >> n;
	while (1) {
		if (pow(2, cnt) > n)break;
		cnt++;
	}
	cout << pow(2,cnt - 1) << endl;

	return 0;
}

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

int main(){

     long long int a,b,c,s=0;
     cin>>a;

     b=a/500;
     c=a%500;

     s=b*1000;
     c=c/5;

     s=s+(c*5);

     cout<<s<<endl;
     
     return 0;





}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>


using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define CL(arr, val) memset(arr, val, sizeof(arr))

#define rep(i, n) for (int i = 0; i < n; ++i)

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

typedef long long ll;
typedef pair<int, int> pint;

const double EPS = 1e-8;
const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };
bool valid_pos(int x, int y, int w, int h) { return 0 <= x && x < w && 0 <= y && y < h; }



int main()
{
	ios::sync_with_stdio(false);

	int w, h, n;
	static int x[114514], y[114514], _x[114514], _y[114514];
	cin >> w >> h >> n;
	for (int i = 0; i < n; ++i)
		cin >> x[i] >> y[i], _x[i] = x[i], _y[i] = y[i];
	sort(_x, _x + n);
	sort(_y, _y + n);

	ll res = 1LL << 60, res_x, res_y;
	for (int a = max(0, n / 2 - 1); a <= n / 2; ++a)
	{
		for (int b = max(0, n / 2 - 1); b <= n / 2; ++b)
		{
			int gx = _x[a], gy = _y[b];

			static ll d[114514];
			for (int i = 0; i < n; ++i)
				d[i] = abs(x[i] - gx) + abs(y[i] - gy);
			ll total = 2 * accumulate(d, d + n, 0LL) - *max_element(d, d + n);
			if (total < res)
			{
				res = total;
				res_x = gx;
				res_y = gy;
			}
		}
	}
	cout << res << endl;
	cout << res_x << " " << res_y << endl;
}

Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define to_s to_string
#define len(v) (int)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
ll MOD = 1e9 + 7;
ll devc(ll x, ll y) { return 1 + (x - 1) / y; }

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

    ll n,m;
    cin >> n >> m;
    print((n - 1) * (m - 1));

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
  int a,b;
  std::cin>>a>>b;
  if(a>=1&&a<=9&&b<=9&&b>=1)
  {
    std::cout<<(a*b);
    return 0;
  }
  else
    std::cout<<"-1";
  return 0;
}

Measured memory_bytes: 256
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
//vector<ll> cue: キューの宣言
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// x,yの最大公約数
ll gcd(ll x, ll y) {
	ll r;
	while (x%y) {
		r = x % y;
		x = y;
		y = r;
	}
	return y;
}

//nC2の計算
ll C(ll N) {
	return N * (N - 1) / 2;
}

ll a(ll n, ll x) {
	ll r = pow(10, x);
	n = (n % r);
	n /= pow(10, x - 1);
	return n;
}

int main() {
	int R,G,B, N; cin >> R>> G >> B >> N;

	ll ans = 0;
	for (int r = 0; r <= N; r++) {
		for (int g = 0; g <= N; g++) {
			ll sum = r * R + g * G;
			if (N - sum >= 0 && (N - sum) % B == 0) {
				ans++;
			}
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast","inline","-ffast-math")
#pragma GCC target("avx,sse2,sse3,sse4,mmx")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/hash_policy.hpp>
#define MOD 1000000007 
using namespace __gnu_pbds;
using namespace std;

int n,m,dp[3010][3010][2];

inline void add(int &x,int y)
{
	x+=y;
	if(x>=MOD) x-=MOD;
}

signed main()
{
	ios::sync_with_stdio(false);
	cin>>n>>m;
	for(int i=0;i<=n;i++){
		if(i==0) dp[0][i][1]=1;
		else dp[0][i][0]=1;	
	}
	for(int i=1;i<=m;i++){
		for(int j=0;j<=n;j++){
			if(j>1) add(dp[i][j][0],dp[i-1][j][0]);
			if(j<n) add(dp[i][j][0],dp[i-1][j][0]);
			if(j) add(dp[i][j][0],dp[i-1][j-1][0]);
			if(j<n) add(dp[i][j][0],dp[i-1][j+1][0]);
			if(j) add(dp[i][j][1],dp[i-1][j][1]);
			if(j<n) add(dp[i][j][1],dp[i-1][j][1]);
			if(j) add(dp[i][j][1],dp[i-1][j-1][1]);
			if(j<n) add(dp[i][j][1],dp[i-1][j+1][1]);
			if(j==0){
				add(dp[i][j][1],dp[i][j][0]);
				dp[i][j][0]=0;
			}
			if(j==1) add(dp[i][j][1],dp[i-1][j][0]);
		}
	}
	int ans=0;
	for(int i=0;i<=n;i++) add(ans,dp[m][i][1]);
	cout<<ans<<endl;
	return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,K;
ll mo=1000000007;

ll comb(ll N_, ll C_) {
	const int NUM_=400001;
	static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];
	if (fact[0]==0) {
		inv[1]=fact[0]=factr[0]=1;
		for (int i=2;i<=NUM_;++i) inv[i] = inv[mo % i] * (mo - mo / i) % mo;
		for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%mo, factr[i]=factr[i-1]*inv[i]%mo;
	}
	if(C_<0 || C_>N_) return 0;
	return factr[C_]*fact[N_]%mo*factr[N_-C_]%mo;
}
ll hcomb(int P_,int Q_) { return (P_==0&&Q_==0)?1:comb(P_+Q_-1,Q_);}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>K;
	
	ll ret=0;
	for(i=1;i<=K;i++) {
		ll a=hcomb(i,K-i);
		ll b=hcomb(i+1,N-K-(i-1));
		cout<<a*b%mo<<endl;
	}
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> vec(N + 1);
  vec.at(N) = 0;
  for(int i = 0; i < N; i++)
    cin >> vec.at(i);
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  int alice= 0, bob = 0;
  int n;
  if(N % 2 == 0)
    n = N/2;
  else
    n = N/2 + 1;
  for(int i = 0; i < n; i++){
    alice = alice + vec.at(2 * i);
    bob = bob + vec.at(2 * i + 1);
  }
  cout << alice - bob << endl;
  
    
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;

int n;
string w[111];

int main(){
  ios_base::sync_with_stdio(false);
  
  int f = 0;

  cin >> n;
  for(int i=0;i<n;i++){
    cin >> w[i];
    if(i > 0 && f == 0){
      //cout << w[i-1][w[i-1].size()-1] << " " <<  w[i][0] << endl;
      if(w[i-1][w[i-1].size()-1] != w[i][0]){
        f = 1;
      }
    }
  }
  
  sort(w, w+n);

  for(int i=1;i<n;i++){
    if(w[i-1] == w[i]){
      f = 1;
      break;
    }
  } 

  if(f){
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }

  return 0;
}



Measured memory_bytes: 256
def insertionSort(A,N):
    for i in range(1,N):
        v=A[i]
        j=i-1
        while j>=0 and A[j]>v:
            A[j+1]=A[j]
            j-=1
        A[j+1]=v
        print(str(A).replace(",",'').replace("[",'').replace("]",''))


N=int(input())
sl=input()
print(sl)
lis=list(map(int,sl.split()))
insertionSort(lis,N)

Measured memory_bytes: 7724
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

n,m = map(int,readline().split())
lst1 = []
for i in range(n):
    lst1.append(list(map(int,readline().split())))

ans = 0
for i in range(1<<4):
    res = [0]*n
    for j in range(3):
        if i>>j&1:
            for k in range(n):
                res[k] += lst1[k][j]
        else:
            for k in range(n):
                res[k] -= lst1[k][j]
    res.sort(reverse=True)
    ans = max(ans,sum(res[:m]))

print(ans)


Measured memory_bytes: 40048
// inputに入力データ全体が入る
function Main(input) {
	input = input.split(" ");
	const map1 = input.map(n => parseInt(n, 10));
  	map1.sort((a, b) => a - b)
  	console.log( map1[0] + map1[1] === map1[2] ? "Yes" : "No")
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define MOD 1000000007

class Comb{
private:
  ll *fac,*finv,*inv;
public:
  Comb(){
    fac = new ll[1000000];
    finv = new ll[1000000];
    inv = new ll[1000000];
    fac[0] = 1;
    for(int i=1;i<1000000;i++){
      fac[i] = i*fac[i-1];
      fac[i] %= MOD;
    }
    inv[1] = 1;
    for(int i=2;i<1000000;i++){
      inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
    }
    finv[0] = 1;
    for(int i=1;i<1000000;i++){
      finv[i] = inv[i]*finv[i-1];
      finv[i] %= MOD;
    }
  }
  ll calc(ll n,ll k){
    ll c = fac[n];
    c *= finv[k];c %= MOD;
    c *= finv[n-k];c %= MOD;
    return c;
  }
};

int main(){
  ll k,n;
  cin >> k >> n;
  ll a[n],b[n];
  for(int i=0;i<n;i++) cin >> a[i];
  for(int i=0;i<n-1;i++){
    b[i] = a[i+1]-a[i];
  }
  b[n-1] = a[0]+(k-a[n-1]);
  sort(b,b+n);
  cout << k-b[n-1] << endl;
  return 0;
}


Measured memory_bytes: 3328
#include <cstring>
#include <cstdlib>
#include <map>
#include <unordered_map>
#include <string>
#include <list>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <iostream>
#include <set>
#include <unordered_set>
using namespace std;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)<0?(-(a)):(a))
#define CS while(cases())
#define I(n) int n = gi()
#define II(n) n = gi()
#define L(n) ll n = gli()
#define LL(n) n = gli()
#define F0(i, n) for (int i = 0; i < n; i++)
#define F1(i, n) for (int i = 1; i < n; i++)
#define Fi(n, a) for (int i = 0; i < n; i++) a[i] = gi()
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int, int> pii;

template<class T>
T gcd(T a, T b) {
    return (b == 0 ? a : gcd(b, a%b));
}

int gi() {
    int a;
    scanf("%d", &a);
    return a;
}

ll gli() {
    ll a;
    scanf("%lld", &a);
    return a;
}

int cases() {
    static int t = gi();
    return t--;
}

#define MD 1000000007
int v[1000004];
int a[200000];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    memset(v, 0, sizeof(v));
    int n = gi(), r = 0;
    F0(i, n) a[i] = gi();
    sort(a, a+n);
    for (int i = 0; i < n; i++) {
        if (i < n-1 && a[i+1] == a[i]) {
            v[a[i]] = 1;
            continue;
        }
        int g = 1;
        for (int f = 1; f*f <= a[i]; f++)
            if (a[i]%f == 0 && (v[f] || v[a[i]/f])) {
                g = 0;
                break;
            }
        r += g;
        v[a[i]] = 1;
    }

    printf("%d\n", r);

    return 0;
}


Measured memory_bytes: 8496
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
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 ll INF = 2e15;
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; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int main(){
  ll n;
  cin >> n;
  vl l(n);
  rep(i,n){
    cin >> l[i];
  }
  ll count = 0;
  sort(all(l));
  rep(i, n){
    for (ll j = i + 1; j < n;j++){
      for (ll k = j + 1; k < n;k++){
        if(l[i]!=l[j]&&l[i]!=l[k]&&l[j]!=l[k]&&l[i]+l[j]>l[k]){
          count++;
        }
      }
    }
  }
  print(count);
}

Measured memory_bytes: 3624
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var l = Console.ReadLine().Split();
            var S = l[0];
            var T = l[1];

            var ans = "";
            for (var i = 0; i < N; i++)
            {
                ans += S[i];
                ans += T[i];
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define int long long
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; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define ll long long
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define PB(x) push_back(x)
#define MP make_pair
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) max_element(x.begin(),x.end())
#define MIN(x) min_element(x.begin(),x.end())
#define couty cout<<'Y'<<'e'<<'s'<<endl
#define coutn cout<<'N'<<'o'<<endl
#define coutY cout<<'Y'<<'E'<<'S'<<endl
#define coutN cout<<'N'<<'O'<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;
//fixed<<setprecision(15);

struct unionFind
{
  // par[i]：データiが属する木の親の番号。i == par[i]のとき、データiは木の根ノードである
  vector<int> par;
  // sizes[i]：根ノードiの木に含まれるデータの数。iが根ノードでない場合は無意味な値となる
  vector<int> sizes;

  unionFind(int n) : par(n), sizes(n, 1) {
    // 最初は全てのデータiがグループiに存在するものとして初期化
    rep(i,n) par[i] = i;
  }

  // データxが属する木の根を得る
  int find(int x) {
    if (x == par[x]) return x;
    return par[x] = find(par[x]);  // 根を張り替えながら再帰的に根ノードを探す
  }

  // 2つのデータx, yが属する木をマージする
  void unite(int x, int y) {
    // データの根ノードを得る
    x = find(x);
    y = find(y);

    // 既に同じ木に属しているならマージしない
    if (x == y) return;

    // xの木がyの木より大きくなるようにする
    if (sizes[x] < sizes[y]) swap(x, y);

    // xがyの親になるように連結する
    par[y] = x;
    sizes[x] += sizes[y];
    // sizes[y] = 0;  // sizes[y]は無意味な値となるので0を入れておいてもよい
  }

  // 2つのデータx, yが属する木が同じならtrueを返す
  bool same(int x, int y) {
    return find(x) == find(y);
  }

  // データxが含まれる木の大きさを返す
  int size(int x) {
    return sizes[find(x)];
  }
};

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

    //a受け取り(0-indexed)
    vint p(n);
    rep(i,n){
        cin >> p[i];
        p[i]--;
    }
    
    //各ペアをグループ分け
    //同じグループ内の数なら順番を変えられる
    unionFind uf(n);
    rep(i,m){
        int a,b;
        cin >> a >> b;
        a--; b--;
        uf.unite(p[a],p[b]);
    }
    
    int res=0;
    rep(i,n){
        if(uf.same(i,p[i])) res++;
    }
    COUT(res);
}


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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair 
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;

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;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}

int main(){
	ll H,W; cin>>H>>W;
	ll ans=INF;
	FOR(i,H/3,H/3+2){
		if(i!=0) chmin(ans,maxx(i*W,(H-i)*(W/2),(H-i)*(W-(W/2)))-minn(i*W,(H-i)*(W/2),(H-i)*(W-(W/2))));
	}
	FOR(i,H/3,H/3+2){
		ll x=H-i;
		if(i!=0 && x>=2) chmin(ans,maxx(i*W,(x/2)*W,(x-(x/2))*W)-minn(i*W,(x/2)*W,(x-(x/2))*W));
	}

	swap(H,W);
	FOR(i,H/3,H/3+2){
		if(i!=0) chmin(ans,maxx(i*W,(H-i)*(W/2),(H-i)*(W-(W/2)))-minn(i*W,(H-i)*(W/2),(H-i)*(W-(W/2))));
	}
	FOR(i,H/3,H/3+2){
		ll x=H-i;
		if(i!=0 && x>=2) chmin(ans,maxx(i*W,(x/2)*W,(x-(x/2))*W)-minn(i*W,(x/2)*W,(x-(x/2))*W));
	}

	cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
//-std=c++11
#define print(x) printf("%.12f",x);
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i, n) for(int i =0 ; i < n; ++i)
#define repr(i, n) for(int i=n-1;i>=0;i--)
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define Repr(i,a,b) for(int i=a;i>=b;i--)
#define pii pair < int, int >
#define iter ::iterator
#define forit(a) for(it=a.begin();it!=a.end();it++)
typedef vector<int> vi;
typedef  long long ll;
const int inf = int(1e9);
const int mod = inf + 7;
const int N = (int)2e5 + 5;

void solve(){
	int a[5];
	int ans=0,x=0;
	vector<pii >v;
	rep(i,5){
		cin>>a[i];
		v.pb(mp(a[i]%10,a[i]));
	}
	sort(all(v));
	bool ok=1;
	rep(i,sz(v)){
		if(v[i].F==0)ans+=v[i].S;
		else if(ok){
			x=v[i].S;
			ok=0;
		}
		else if(!ok){
			ans+=(v[i].S+10)/10*10;
		}
		//acout<<ans<<" "<<x<<endl;
	}
	cout<<ans+x;
}


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

Measured memory_bytes: 256
#include<stdio.h>
#define N 100000

typedef struct{
  int p,l,r;
} Node;

Node A[N];
int depth[N];

void getDepth(int id){
  int up;
  up = A[id].p;
  while(1){
    if(up == -1){
      break;
    }
    else {
      up = A[up].p;
      depth[id]++; 
    }
  }
}

void printCild(i){
  int cild;
  if(A[i].p == -1) printf("root, [");
  
  else if(A[i].l != -1) printf("internal node, [");
   
  else printf("leaf, [");

  if(A[i].l != -1){
    cild = A[i].l;
    while(1){
      printf("%d",cild);
      cild = A[cild].r;
      if(cild == -1)break;
      printf(", ");
    }
  }
  printf("]\n");
}   

int main(){
  int i,j;
  int id,k,c;
  int n,fm;

  scanf("%d",&n);

  for(i = 0; i < n; i ++){
    A[i].p = -1;
    A[i].l = -1;
    A[i].r = -1;
  }

  for(i = 0; i < n; i ++){
    scanf("%d%d",&id,&k);
    for(j = 0; j < k; j ++){
      scanf("%d",&c);
      if(j == 0){
	A[id].l = c;
	fm = c;
	A[c].p = id;
      }
      else{
	A[fm].r = c;
	A[c].p = id;
	fm = c;
      }
    }
  }
 
  for(i = 0; i < n; i ++){  
    getDepth(i);
    printf("node %d: parent = %d, depth = %d, ",i,A[i].p,depth[i]);
    printCild(i);
  }
  return 0;
}

Measured memory_bytes: 2172
//
// Created by miyoshi on 2019/05/23.
//

#include <iostream>

using namespace std;

int N[45];


int f(int n) {
    if (N[n] != 0) {
        return N[n];
    }
    else if (n==0 || n==1) {
        return 1;
    } else {
        return f(n-1) + f(n-2);
    }
}

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

    for (int i=0; i <= n; i++) {
        N[i] = 0;
    }

    for (int i=0; i <= n; i++) {
        N[i] = f(i);
    }

    cout << N[n] << endl;
    return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n; cin >> n;
  V<> r(n), a(n), w(n), t(n); for (int i = 0; i < n; ++i) cin >> r[i] >> a[i] >> w[i] >> t[i];
  int res = 0;
  for (int cr = -1; cr <= 1; ++cr) for (int ct = -1; ct <= 1; ++ct) {
    V<> idx(n);
    iota(begin(idx), end(idx), 0);
    sort(begin(idx), end(idx), [&](int i, int j) { return cr * r[i] + ct * t[i] < cr * r[j] + ct * t[j]; });
    constexpr int T = 4000;
    V<> dp(T);
    for (int i : idx) {
      V<> ndp(T, -1e9);
      for (int x = 0; x < t[i]; ++x) {
        ndp[r[i] + x] = a[i] + dp[x];
      }
      for (int x = r[i]; x < t[i]; ++x) {
        ndp[x + r[i]] = max(ndp[x + r[i]], w[i] + ndp[x]);
      }
      for (int x = 0; x < T; ++x) {
        dp[x] = max(dp[x], ndp[x]);
      }
    }
    res = max(res, *max_element(begin(dp), end(dp)));
  }
  cout << res << '\n';
}


Measured memory_bytes: 3292
#include<string>
#include<iostream>
#include<cctype>
#include<cmath>
#include<cstdio>

using namespace std;

int main(void){
	int a;
	cin >> a;
	int b[10000];
	long long min=pow(10,6);
	long long  max=-pow(10,6);
	int i;

	for(i=0;i<a;i++){
		cin >> b[i];	
		}
	for(i=0;i<a;i++){
		if(min>b[i]) min=b[i];
		if(max<b[i]) max=b[i];
		}

	long long sum=0;
	for(i=0;i<a;i++){
		sum+=b[i];
		}

	cout << min << " "<< max << " "<< sum <<endl;
	return 0;
}

Measured memory_bytes: 1196
#[allow(unused_imports)]
use std::cmp;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    #[allow(unused_mut)]
    let mut s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

  ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
    let $var = read_value!($iter, $t);
    input_inner!{$iter $($r)*}
  };
}

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

  ($iter:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  };

  ($iter:expr, chars) => {
    read_value!($iter, String).chars().collect::<Vec<char>>()
  };

  ($iter:expr, usize1) => {
    read_value!($iter, usize) - 1
  };

  ($iter:expr, $t:ty) => {
    $iter.next().unwrap().parse::<$t>().expect("Parse error")
  };
}

const MOD: i64 = 1e9 as i64 + 7;

fn main() {
  input! {
    n: usize,
    s: chars
  }
  let mut dp = vec![vec![0i64; n]; n];
  dp[0][0] = 1;
  for (pos, &c) in s.iter().enumerate() {
    let len = pos + 1;
    match c {
      '<' => {
        for tail in 1 .. len + 1 {
          dp[len][tail] = (dp[len][tail - 1] + dp[len - 1][tail - 1]) % MOD;
        }
      },
      '>' => {
        for tail in (0 .. len).rev() {
          dp[len][tail] = (dp[len][tail + 1] + dp[len - 1][tail]) % MOD;
        }
      },
      _ => unreachable!()
    }
  }
  let ans = dp[n-1].iter().sum::<i64>() % MOD;
  println!("{}", ans);
}


Measured memory_bytes: 90364
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MAX 510000
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < n; ++i)

ll fac[MAX], finv[MAX], inv[MAX];

//二項係数の計算
void comint()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; ++i)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
ll com(ll n, ll k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(void)
{
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n, k;
    cin >> n >> k;
    comint();
    rep(i, 1, k + 1) cout << (com(k - 1, i - 1) * com(n - k + 1, i)) % MOD << endl;
}


Measured memory_bytes: 15516
#include<stdio.h>
int main()
{
  int A,B,C,N;
  scanf("%d",&N);
  A=N/100;
  B=(N/10)%10;
  C=(N%100)%10;
  if(A==7||B==7||C==7){
    printf("Yes");
  }
  else{
    printf("No");
  }
}


Measured memory_bytes: 1736
//https://atcoder.jp/contests/abc146/tasks/abc146_b
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
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 main() {
#if LOCAL&01
    std::ifstream in("./test/sample-1.in"); //input.txt
    std::cin.rdbuf(in.rdbuf());
#else
    cin.tie(0);
    ios::sync_with_stdio(false);
#endif
    ll N; cin>>N;
    string S; cin>>S;    
    string ans;

    auto replace=[&](char c){
        char r=c+N;
        if(r>'Z')r-=26;
        return r;
    };

    dump(replace('A'));
    dump(replace('Y'));

    for(auto&& c:S){
        ans.push_back(replace(c));
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <cctype>
using namespace std;
int main(){
    string s;bool b1,b2;
    cin>>s;
    int a=stoi(s.substr(0,2)),b=stoi(s.substr(2));
    b1 = (a>=1&&a<=12) ;
    b2 = (b>=1&&b<=12) ;
    if(b1&&b2) cout<<"AMBIGUOUS";
    else if(b1) cout<<"MMYY";
    else if(b2) cout<<"YYMM";
    else cout<<"NA";
}

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

int main() 
{
	string s;
	cin >> s;
	if (s == "Sunny")
		cout << "Cloudy";
	if (s == "Cloudy")
		cout << "Rainy";
	if (s == "Rainy")
		cout << "Sunny";
	return 0;
}

Measured memory_bytes: 256
/*  Author : Alpha_The_Coder
    Created on 13/09/2020      */
#include <bits/stdc++.h>
using namespace std;
#define iamalpha ios_base::sync_with_stdio(false);cin.tie(NULL);
#define loop(a,n) for(int i=a;i<n;i++)
#define nloop(a,n) for(int j=a;j<n;j++)
#define lli long long int
lli mod=1000000007;
void solve();


int main()
{
    iamalpha;
    int t=1;
    while(t--)
    {
        solve();
    }
}

void solve()
{

 bool ans=false;
 int n;
 cin>>n;
 int a[n][2];
 loop(0,n)
 {
     for(int j=0;j<2;j++)
     {
         cin>>a[i][j];
     }
 }

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

    if(a[i][0]==a[i][1] && a[i+1][0]==a[i+1][1] && a[i+2][0]==a[i+2][1])
    {
        ans=true;
        break;
    }
 }
 if(ans) cout<<"Yes";
 else cout<<"No";


}


// Solely contributed by Subhojeet Sahoo aka Alpha


Measured memory_bytes: 3644
#include <bits/stdc++.h> 
using namespace std;
int main() {
int N;cin>>N;
// input
vector<int> A(N); for(int i=0;i<N;++i){
cin >> A[i];
--A[i]; }
vector<int> B(N); for(int i=0;i<N;++i){
cin >> B[i]; }
vector<int> C(N-1); for(int  i=0;i<N;++i){
cin >> C[i]; }
// calc
int ans=0; for(int i=0;i<N;++i){
ans += B[A[i]];
if (i > 0 && A[i] == A[i-1]+1) {
ans += C[A[i-1]]; }
}
// output
cout << ans << endl; }


Measured memory_bytes: 256
n, m = map(int, input().split())

pre = [[] for _ in range(n)]
for i in range(m):
    p, y = map(int, input().split())
    pre[p-1].append((i, y))

c = []
for x, p in enumerate(pre):
    p.sort(key = lambda x : x[1])

    for j, (i, y) in enumerate(p):
        c.append((i, x+1, j+1))

c.sort(key = lambda x :x[0])
for _, x, y in c:
    print(str(x).zfill(6)+str(y).zfill(6))


Measured memory_bytes: 40128
#include <bits/stdc++.h>
    using namespace std;
     
    #define MP make_pair
    #define PB push_back
    #define ALL(x)      (x).begin(),(x).end()
    #define REP(i,n)    for(int i=0;i<(n);i++)
    #define REP1(i,n)   for(int i=1;i<(n);i++)
    #define REP2(i,d,n) for(int i=(d);i<(n);i++)
    #define RREP(i,n)   for(int i=(n);i>=0;i--)
    #define CLR(a)      memset((a),0,sizeof(a))
    #define MCLR(a)     memset((a),-1,sizeof(a))
    #define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
     
    typedef long long LL;
    typedef unsigned long long ULL;
    typedef vector<int> VI;
    typedef vector<VI > VVI;
    typedef vector<string> VS;
    typedef vector<LL> VLL;
    typedef pair<int,int> PII;
     
    const int INF = 0x3f3f3f3f;
    const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
    const double EPS = 1e-9;
     
    const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};
     
    int main() {
      int N;
      cin >> N;
      LL ans = 1;
      LL memo = 1;
      int tmp;
      REP(i, N) {
        ans *= 3;
      	cin >> tmp;
        if(tmp % 2 == 0) {
          memo *= 2;
        }
      }
      
      cout << (ans-memo) << endl;
    }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct edge{ int to,costa,costb; };

int N,P;
vector<edge> G[1000];
vector<int> rG[1000];
map<int,bool> visited;
vector<int> vd;

int d[1000][1000];

void dfs(int pos){
  if(visited[pos])return;
  visited[pos]=true;
  
  for(int i=0;i<(int)rG[pos].size();i++){
    dfs(rG[pos][i]);
  }
  vd.push_back(pos);
}

int main(){
  cin>>N>>P;
  for(int i=0;i<P;i++){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    a--,b--;
    G[a].push_back( (edge){b,c,d} );
    rG[b].push_back(a);
  }
  
  dfs(N-1);

  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      d[i][j]=1e9;
    }
  }

  map<int,int> mp;
  for(int i=0;i<N;i++){
    mp[ vd[i] ]=i;
  }
  
  d[0][0]=0;

  for(int i=0;i<N;i++){
    for(int j=i;j<N;j++){
      int posa=vd[i];
      int posb=vd[j];
      if(i==j){
        for(int k=0;k<(int)G[posa].size();k++){
          for(int l=0;l<=k;l++){
            edge ea=G[posa][k];
            edge eb=G[posb][l];
            
            int toa=mp[ea.to];
            int tob=mp[eb.to];
            int ncost=d[i][j];
            if(toa==tob)ncost+=ea.costa+eb.costb;
            else ncost+=ea.costa+eb.costa;

            if(toa>tob)swap(toa,tob);
            if(d[toa][tob]>ncost){
              d[toa][tob]=ncost;            
            }
          }
        }
        continue;
      }
      for(int k=0;k<(int)G[posa].size();k++){
        edge e=G[posa][k];
        int ncost=d[i][j]+e.costa;
        int to=mp[ e.to ];
        int nb=mp[posb];
        
        if(to>nb)swap(to,nb);
        if(d[to][nb]>ncost){
          d[to][nb]=ncost;
        }
        
      }
    }
  }
  cout<<d[N-1][N-1]<<endl;
  return 0;
}

Measured memory_bytes: 7236