akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main{
	public static void main(String[] args){		//メソッド宣言
		try(Scanner sc = new Scanner(System.in)){
			int n = sc.nextInt();
			long SUM = 0;
			int MAX = -9999999;
			int MIN = 9999999;

			for(int i = 0; i < n ; i++) {
				int num = sc.nextInt();
				MAX = num>MAX ? num:MAX;

				MIN = num<MIN ? num:MIN;

				SUM += num;
			}
				System.out.println(String.format("%d %d %d",MIN,MAX,SUM));
		}
	}
}





Measured memory_bytes: 41996
n = int(input())
x = [0]*n
y = [0]*n

if n == 1:
  print(1)
else:
  for i in range(n):
    x[i],y[i] = map(int, input().split())
  ans = []
  for i in range(n):
    for j in range(n):
      if i == j:
        continue
      p = x[i]-x[j]
      q = y[i]-y[j]
      count = 0
      for k in range(n):
        for l in range(n):
          if p == x[k]-x[l] and q == y[k]-y[l]:
            count += 1
            ans.append(count)
  print(n-max(ans))


Measured memory_bytes: 45148
#include<bits/stdc++.h>
#define ll long long
using namespace std;
struct aaa{
	int x,y,w,id;
}a[2000001],b[1000001];
int n,m,tot,cnt,v[2000001],e[2000001],nt[2000001],hd[2000001],val[2000001],dis[2000001];
priority_queue<pair<int,int> >q;
vector<int>zh[2000001];
bool cmp(aaa a,aaa b){
	return a.w<b.w;
}
void build(int x,int y,int w){
	tot++;
	e[tot]=y;val[tot]=w;
	nt[tot]=hd[x];hd[x]=tot;
}
void dj(){
	int i,u,now;
	q.push(make_pair(-0,1));
	memset(dis,44,sizeof(dis));
	dis[1]=0;
	while(!q.empty()){
		u=q.top().second;now=-q.top().first;
		//printf("%d %d\n",u,now);
		q.pop();
		if(v[u])continue;
		v[u]=1;
		for(i=hd[u];i;i=nt[i]){
		 if(dis[u]+val[i]<dis[e[i]]){
			dis[e[i]]=dis[u]+val[i];
			if(!v[e[i]]){
				q.push(make_pair(-dis[e[i]],e[i]));
			}
		}
	  }
	}
	//for(i=1;i<=n+m;i++)printf("%d %d\n",i,dis[i]);
}
int main(){
	int i,x,y,j,ii;
	scanf("%d%d",&n,&m);
	for(i=1;i<=m;i++){
		scanf("%d%d%d",&a[i].x,&a[i].y,&a[i].w);
		zh[a[i].x].push_back(i);
		zh[a[i].y].push_back(i);
		a[i].id=i;
	}
	for(ii=1;ii<=n;ii++){
		//printf("-1 %d %d\n",ii,zh[ii].size());
		cnt=0;
		for(j=0;j<zh[ii].size();j++){
			build(ii,n+zh[ii][j],1);
			build(n+zh[ii][j],ii,0);
			b[++cnt]=a[zh[ii][j]];
			//printf("%d %d\n",ii,n+zh[ii][j]);
		}
		sort(b+1,b+cnt+1,cmp);
		for(i=1;i<=cnt;i++)if(b[i].w!=b[i-1].w){
			for(j=i+1;j<=cnt&&b[i].w==b[j].w;j++)build(n+b[j-1].id,n+b[j].id,0),build(n+b[j].id,n+b[j-1].id,0);
			if(j>i+1)build(n+b[i].id,n+b[j-1].id,0),build(n+b[j-1].id,n+b[i].id,0);
			//printf("%d %d %d\n",ii,i,j-1);
		}
	}
	dj();
	if(dis[n]>=100000000)puts("-1");
	 else 
	printf("%d",dis[n]);
}

Measured memory_bytes: 98196
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
#include <complex>
#include <cstdint>
#define _USE_CMATH_DEFINES

const long INF = (1l << 30);
const long LINF = (1l << 60); //1.15*10^18

long x, n;
long p[105];

bool found(long a){
    for(int i = 0; i < n; i++){
        if(p[i] == a){
            return true;
        }
    }
    return false;
}

int main(){
    scanf("%ld%ld", &x, &n);
    for(int i = 0; i < n; i++){
        scanf("%ld", p+i);
    }
    for(long i = 0; i <= 101; i++){
        if(!found(x-i)){
            printf("%ld\n", x-i);
            return 0;
        }
        if(!found(x+i)){
            printf("%ld\n", x+i);
            return 0;
        }
    }
}


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

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

#define vi vector<ll>
#define vvi vector<vi>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define vvii vector<vii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define mc(a,b,c) mp(mp(a,b),c)

struct mint {
    typedef decay<decltype(MOD)>::type T; 
    T v; explicit operator T() const { return v; }
    mint() { v = 0; }
    mint(ll _v) { 
        v = (-MOD < _v && _v < MOD) ? _v : _v % MOD;
        if (v < 0) v += MOD;
    }
    friend bool operator==(const mint& a, const mint& b) { 
        return a.v == b.v; }
    friend bool operator!=(const mint& a, const mint& b) { 
        return !(a == b); }
    friend bool operator<(const mint& a, const mint& b) { 
        return a.v < b.v; }   
    mint& operator+=(const mint& m) { 
        if ((v += m.v) >= MOD) v -= MOD; 
        return *this; }
    mint& operator-=(const mint& m) { 
        if ((v -= m.v) < 0) v += MOD; 
        return *this; }
    mint& operator*=(const mint& m) { 
        v = (ll)v*m.v%MOD; return *this; }
    mint& operator/=(const mint& m) { return (*this) *= inv(m); }
    friend mint pow(mint a, ll p) {
        mint ans = 1; assert(p >= 0);
        for (; p; p /= 2, a *= a) if (p&1) ans *= a;
        return ans;
    }
    friend mint inv(const mint& a) { assert(a.v != 0); 
        return pow(a,MOD-2); }
        
    mint operator-() const { return mint(-v); }
    mint& operator++() { return *this += 1; }
    mint& operator--() { return *this -= 1; }
    friend mint operator+(mint a, const mint& b) { return a += b; }
    friend mint operator-(mint a, const mint& b) { return a -= b; }
    friend mint operator*(mint a, const mint& b) { return a *= b; }
    friend mint operator/(mint a, const mint& b) { return a /= b; }
};

vector<mint> a;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k;
    mint ans=0,m;
    cin>>n>>m.v>>k;
    a.resize(k+1);
    a[0] = 1;
    for(ll i=0;i<=k;i++){
        if(i)
            a[i] = (a[i-1]*(n-i))/i;
        ans+=m*a[i]*pow(m-1,n-i-1);
    }
    cout<<ans.v;
    

    return 0;
}

Measured memory_bytes: 3860
#include<bits/stdc++.h>
using namespace std;
int main() {
  int N, count = 0; cin >> N;
  map<string, int> goods;
  for(int i = 0; i < N; i++) {
    string s; cin >> s;
    if(goods.count(s)) continue;
    goods[s] = 1;
    count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 19232
import sys
import math

N, M=map(int,input().split())
if(abs(N%1000000007-M%1000000007)>1):
    i=0
else:
    i=math.factorial(M%1000000007)*math.factorial(N%1000000007)
if(N==M):
    i=i*2
ans=i%1000000007
print(ans)

Measured memory_bytes: 5184
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

n,k,*aaa = get_all_int()
# log(aaa)
ruiseki = [0] * (n+1)
for i,a in enumerate(aaa):
    ruiseki[i+1] = (ruiseki[i] + a - 1) % k

count = {}
ans = 0
for right in range(len(ruiseki)):
    x = ruiseki[right]
    # log(x, count.get(x, 0), count)
    count[x] = count.get(x, 0) + 1

    if right >= k:
        y = ruiseki[right-k]
        count[y] -= 1

    ans += count.get(x, 0) - 1

print(ans)


Measured memory_bytes: 103096
a,b=map(int,input().split())
if a*b<=0:
    print("Zero")
elif a>0 :
    print("Positive")
elif b<0 and (a-b+1)%2==0:
    print("Positive")
elif b<0 and (a-b+1)%2==1:
    print("Negative")

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<ll> a(n);
    for(int i=0; i<n; i++) cin>>a[i];
    sort(a.begin(),a.end());
    ll ans=0,ans2=0;
    
    for(int i=(n/2)+2; i<n; i++) ans+=2*a[i];
    ans+=a[n/2];
    ans+=a[(n/2)+1];
    for(int i=0; i<n/2; i++) ans-=2*a[i];

    for(int i=0; i<n/2; i++) ans2+=2*a[n-i-1];
    for(int i=0; i<(n/2)-1; i++) ans2-=2*a[i];
    ans2-=a[n/2];
    ans2-=a[(n/2)-1];

    cout<<max(ans,ans2)<<endl;

}

Measured memory_bytes: 1024
#coding: utf-8
import sys
c = [0 for i in range(26)]
in_list = []

for line in sys.stdin:
    in_list.append(line)

for s in in_list:
    for i in range(len(s)):
        if   ord(s[i]) >= ord('a') and ord(s[i]) <= ord('z'):
            c[ord(s[i])-97] += 1
        elif ord(s[i]) >= ord('A') and ord(s[i]) <= ord('Z'):
            c[ord(s[i])-65] += 1

for i in range(26):
    print(chr(ord('a')+i) + " : " + str(c[i]))


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>0;(i)--)
#define rrep(i,n,m) for(int (i)=(n);(i)<(m);(i)++)
#define rrepr(i,n,m) for(int (i)=(n);(i)>(m);(i)--)
#define esort(s) sort((s).begin(),(s).end())

typedef long long ll;
typedef pair<int,int> ipair;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;

const int INF = 1000000000;
const ll LINF = 1000000000000000000;
const double PI = acos(-1.0);
const double EPS = 1e-10;

const ll MOD = 1000000007ll;
const int MAX=510000;

int A,B;
void solve(){
    cin>>A>>B;
    cout<<max(0,A-2*B)<<endl;
    return;
}

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

    solve();
    return 0;
}

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

int main(){
  int N, K;
  cin >> N >> K;
  
  int x = 1;
  
  for (int i=0; i<N; i++){
    int A = x * 2;
    int B = x + K;
    x = A < B ? A : B;
  }
  cout << x << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
typedef long long int64;
 
int main()
{
  string S;
  cin >> S;
  if(set< char >(S.begin(), S.end()).size() == S.size()) {
    cout << "yes" << endl;
  } else {
    cout << "no" << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a,b,i,j;
	while(1){
		scanf("%d%d",&a,&b);
		if(a==0&&b==0)
		break;
		for(i=1;i<=a;i++){
			for(j=1;j<=b;j++){
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 572
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define ll long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

signed main() {
	int A1, A2, A3;
	cin >> A1 >> A2 >> A3;
	int a = abs(A1 - A2);
	int b = abs(A1 - A3);
	int c = abs(A2 - A3);
	int ans = a + b + c - max({ a,b,c });
	cout << ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,l,r) for (int i=l;i<=r;i++)
using namespace std;
typedef long long ll;
const int N=2010;
const ll p=1e9+7;
const ll inv2=(1e9+8)/2;
ll f[N*2+5][N*2+5],fac[N*4+5],inv[N*4+5],a[200500],b[200500];
int n;
ll Pow(ll x,ll y){
    ll ans=1;
    while (y){
        if (y&1) ans=ans*x%p;
        x=x*x%p;
        y/=2;
    }
    return ans;
}
ll C(int n,int m){
    return fac[n]*inv[m]%p*inv[n-m]%p;
}
int main(){
    scanf("%d",&n);
    rep(i,1,n){
        scanf("%d%d",&a[i],&b[i]);
        f[N-a[i]][N-b[i]]++;
    }
    rep(i,1,2*N) rep(j,1,2*N) f[i][j]=(f[i][j]+f[i-1][j]+f[i][j-1])%p;
    fac[0]=1; rep(i,1,4*N) fac[i]=fac[i-1]*i%p;
    inv[4*N]=Pow(fac[4*N],p-2);
    for (int i=4*N;i>=1;i--) inv[i-1]=inv[i]*i%p;
    ll ans=0;
    rep(i,1,n) 
        ans=(ans+f[a[i]+N][b[i]+N]+p-C(2*(a[i]+b[i]),2*a[i]))%p;
    printf("%lld\n",ans*inv[2]%p);
    return 0;
}

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

public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999999;
	
	public static void Main(string[] args)
	{
		var p = Console.ReadLine().ToInt();
      if(p <1200)
		Console.WriteLine("ABC");
      else
		Console.WriteLine("ARC");
	}
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str, int offset = 0)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt() + offset;
		return r;
	}
}

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

int main()
{
  int64_t N, a, b, c, d;
  cin >> N;
  vector<pair<int64_t, int64_t>> A(N), B(N);
  for (int i = 0; i < N; i++)
  {
    cin >> a >> b;
    A.at(i) = make_pair(a, b);
  }
  for (int i = 0; i < N; i++)
  {
    cin >> c >> d;
    B.at(i) = make_pair(c, d);
  }
  vector<vector<bool>> Grid(N, vector<bool>(N, false));
  vector<int64_t> cntA(N, 0), cntB(N, 0);
  for (int i = 0; i < N; i++)
  {
    for (int j = 0; j < N; j++)
    {
      if (A.at(i).first < B.at(j).first && A.at(i).second < B.at(j).second)
      {
        Grid.at(i).at(j) = true;
        cntA.at(i)++;
        cntB.at(j)++;
      }
    }
  }
  int64_t INF = 100000007, SKIP = 100000009;
  vector<vector<int64_t>> Points(N, vector<int64_t>(N, 0));
  for (int i = 0; i < N; i++)
  {
    for (int j = 0; j < N; j++)
    {
      if (Grid.at(i).at(j))
        Points.at(i).at(j) = cntA.at(i) + cntB.at(j) - 1;
      else
        Points.at(i).at(j) = INF;
    }
  }
  int64_t cnt = 0;
  while (true)
  {
    int minp = INF, mini = INF, minj = INF;
    for (int i = 0; i < N; i++)
    {
      for (int j = 0; j < N; j++)
      {
        if (Points.at(i).at(j) == SKIP)
          break;
        if (!Grid.at(i).at(j))
          continue;
        if (Points.at(i).at(j) <= minp)
        {
          minp = Points.at(i).at(j);
          mini = i;
          minj = j;
        }
      }
    }
    if (minp == INF)
      break;
    cnt++;
    for (int i = 0; i < N; i++)
    {
      Points.at(mini).at(i) = SKIP;
      Grid.at(mini).at(i) = false;
      Grid.at(i).at(minj) = false;
    }
    minp = INF;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(ll i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
typedef tuple<ll,ll,ll> Tu;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807/2;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[8]={0,1,0,-1,1,1,-1,-1},mdy[8]={-1,0,1,0,1,-1,1,-1};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int n,m;
int a[310][310];
int ans=1000;
int used[310];
int co[310];
int main(){
	cin>>n>>m;
	REP(i,n)
		REP(j,m){
			cin>>a[i][j];
			a[i][j]--;
		}
	if(n==1){
		cout<<1<<endl;
		return 0;
	}
	for(int tt=0;tt<m-1;tt++){
		REP(i,310)co[i]=0;
		for(int i=0;i<n;i++){
			for(int j=0;j<m;j++){
				if(!used[a[i][j]]){
					co[a[i][j]]++;
					break;
				}
			}
		}
		int tans=0;
		for(int i=0;i<310;i++){
			if(co[tans]<=co[i]){
				tans=i;
			}
		}
		ans=min(ans,co[tans]);
		used[tans]=1;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "
#define  E  2.71828182845904523536
#define pb push_back
#define pp pop_back
#define valid(nx,ny) nx>=0 && nx<n && ny>=0 && ny<m
#define ee endl
#define pii pair<int,int>
#define infinity 10000000000000000
#define mod 1000000007
int fx[]={0,0,+1,-1};
int fy[]={+1,-1,0,0};

using namespace std;
///check n=1;
///check corner case;
const int maX=1e5+1;
vector<ll>Graph[maX],cost[maX];
ll visit[maX];
ll x[10];
ll y[10];
double dist(ll i, ll j)
{
    double dx=x[i]-x[j];
    double dy=y[i]-y[j];
    return pow(dx*dx+dy*dy,0.5);
}

int main()
{
   ll n,a,b;cin>>n>>a>>b;cout<<min(a*n,b);
}


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

using namespace std;

int main()
{
	int n,t;
	int max_high,min_high;
	int bump[100];
	
	cin >> t ;
	for(int i=0;i<t;i++)
	{
		cin >> n ;
		
		max_high=min_high=0;
		
		cin >> bump[0];
		for(int j=1;j<n;j++)
		{
			cin >> bump[j] ;
			if(bump[j-1]<bump[j])
			{
				max_high=max(max_high,bump[j]-bump[j-1]);
			}
			else
				min_high=max(min_high,bump[j-1]-bump[j]);
		}
		
		cout << max_high << " "  << min_high << endl;
	}
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int a,b,c,k; cin>>a>>b>>c>>k;
	for(int i=0,aa=a;i<=k;++i,a*=2){
		for(int j=0,bb=b;j<=k-i;++j,bb*=2){
			for(int K=0,cc=c;K<=k-i-j;++K,cc*=2){
				if(bb>aa&&cc>bb){
					cout<<"Yes\n"s;
					return 0;
				}
			}
		}
	}
	cout<<"No\n"s;
	return 0;
}


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

int a[3000],b[3000];
int dp1[3001][3001],dp2[3001][3001];

int main() {
	int n,t,s;scanf("%d%d%d",&n,&t,&s);
	rep(i,n)scanf("%d%d",&a[i],&b[i]);
	for(int i=0;i<n;i++){
		for(int j=0;j<=s;j++){
			if(b[i]>j)dp1[i+1][j]=dp1[i][j];
			else dp1[i+1][j]=max(dp1[i][j],dp1[i][j-b[i]]+a[i]);
		}
	}
	reverse(a,a+n);reverse(b,b+n);
	for(int i=0;i<n;i++){
		for(int j=0;j<=t-s;j++){
			if(b[i]>j)dp2[i+1][j]=dp2[i][j];
			else dp2[i+1][j]=max(dp2[i][j],dp2[i][j-b[i]]+a[i]);
		}
	}
	int Max=0;
	for(int i=0;i<n;i++)
		Max=max(Max,dp1[i][s]+dp2[n-i-1][t-s]);
	printf("%d\n",Max);
}

Measured memory_bytes: 62368
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr int N = 1e5+5;
int n, a[N];
ll dp[2];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    ll ans = 0;
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    dp[0] = a[0]/2;
    if(a[0]) dp[1]=(a[0]-1)/2;
    for(int i = 1; i < n; i++) {
        ll newdp[2];
        newdp[0]=0,newdp[1]=0;
        if(a[i]>=1) {
            newdp[1]=(a[i]-1)/2+max(dp[0],dp[1]);
        }
        if(a[i]>=2 && a[i-1]!=0) {
            newdp[1]=max(newdp[1], (a[i]-2)/2+dp[1]+1);
        }
        newdp[0]=a[i]/2+max(dp[0], dp[1]);
        if(a[i-1]!=0 && a[i]>=1) {
            newdp[0]=max(newdp[0], (a[i]-1)/2+dp[1]+1);
        }
        dp[0]=newdp[0];
        dp[1]=newdp[1];
    }
    cout << max(dp[0], dp[1]);
    return 0;
}

Measured memory_bytes: 4032
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const ld eps = 1e-9;
const ld pi = acos((ld) -1);

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

const int maxn = (int) 1e5 + 5;
int n, m;
vector<int> g[maxn];

int read() {
  if (scanf("%d%d", &n, &m) < 2) {
    return false;
  }
  for (int i = 0; i < n; i++) {
    g[i].clear();
  }
  for (int i = 0; i < m; i++) {
    int v, u;
    scanf("%d%d", &v, &u);
    v--;
    u--;
    g[v].push_back(u);
    g[u].push_back(v);
  }
  return true;
}

int used[maxn];
int col[maxn];

bool dfs(int v) {
  used[v] = true;
  bool res = true;
  for (int i = 0; i < sz(g[v]); i++) {
    int u = g[v][i];
    if (used[u]) {
      if (col[u] == col[v]) {
        res = false;
      }
      continue;
    } else {
      col[u] = !col[v];
      if (!dfs(u)) {
        res = false;
      }
    }
  }
  return res;
}

void solve() {
  for (int i = 0; i < n; i++) {
    used[i] = false;
  }
  int c[2] = {0, 0};
  int is = 0;
  for (int i = 0; i < n; i++) {
    if (used[i]) {
      continue;
    }
    if (g[i].empty()) {
      is++;
      continue;
    }
    col[i] = false;
    if (dfs(i)) {
      c[0]++;
    } else {
      c[1]++;
    }
  }
  long long res = (long long) (c[0] + c[1]) * (c[0] + c[1]) + (long long) c[0] * c[0];
  res += (long long) is * is + (long long) is * (n - is) * 2;
  printf("%lld\n", res);
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen(TASK ".in", "r", stdin));
  assert(freopen(TASK ".out", "w", stdout));
#endif
  while (read()) {
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 11264
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC144A
{
	class Program
	{
		static void Main(string[] args)
		{
			int a, b,s;
			var word = Console.ReadLine().Split(' ');
			a = int.Parse(word[0]);
			b = int.Parse(word[1]);
			if ((a < 10) && (b < 10))
			{
				s = a * b; ;
			}
			else
			{
				s = -1;
			}
			Console.WriteLine(s);
			Console.ReadLine();
		}
	}
}


Measured memory_bytes: 13140
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;

const int c_YET = -1;
//const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const ll MAX = 1e9;
const double PI = 3.14159265358979323846264338327950288;
//========================================================================



int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	//==================================


	string S, T, U;
	int A, B;
	cin >> S >> T;
	cin >> A >> B;
	cin >> U;


	if (U == S) {
		cout << A - 1 << " " <<  B;
	}
	else {
		cout << A << " " << B-1;
	}




}


Measured memory_bytes: 256
def gcd(a,b):
    if b==0:
        return a
    return gcd(b,a%b)


n = int(input())
l = list(map(int,input().split()))
d = l[0]
for i in l:
    d = gcd(d,i)

ans = []
for i in range(1,d):
    if i**2>d:
        break
    if d==i**2:
        ans.append(i)
    elif d%i==0:
        ans.append(i)
        ans.append(d//i)
ans.sort()
for i in ans:
    print(i)


Measured memory_bytes: 5600
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

static const int P = (int)1e9+7;
static const int M = (int)1e5+5;
int fact[M];
int A[M],pos[M];
int inv(int x){
	int cnt=P-2;
	int res=1;
	while(cnt){
		if(cnt&1)res=1ll*res*x%P;
		cnt>>=1;
		x=1ll*x*x%P;
	}
	return res;
}
void init(){
	fact[0]=1;
	for(int i=1;i<M;++i)fact[i]=1ll*fact[i-1]*i%P;
}
int C(int n,int k){
	if(n<k)return 0;
	return 1ll*fact[n]*inv(fact[k])%P*inv(fact[n-k])%P;
}
int main(){
	int n;
	scanf("%d",&n);
	int L,R;
	init();
	for(int i=1;i<=n+1;++i){
		scanf("%d",&A[i]);
		if(pos[A[i]])L=pos[A[i]],R=i;
		else pos[A[i]]=i;
	}
	for(int k=1;k<=n+1;++k){
		int ans=0;
		ans+=C(n-1,k);
		if(ans>=P)ans-=P;
		ans+=2ll*C(n-1,k-1)%P;
		if(ans>=P)ans-=P;
		ans+=(P-C(n-(R-L),k-1))%P;
		if(ans>=P)ans-=P;
		ans+=C(n-1,k-2);
		if(ans>=P)ans-=P;
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O0")
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
const ll mod = 1e9+7;
const ll INF = 1e18;
#define All(a) (a).begin(),(a).end()
#define Pi acos(-1)

bool isPrime(int x) {
  int i;
  if(x < 2)return 0;
  else if(x == 2) return 1;
  if(x%2 == 0) return 0;
  for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
  return 1;
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  chrono::system_clock::time_point start,end;
  start = chrono::system_clock::now();

  vector<ll> a(100010);
  for (ll i = 1; i < 100001; ++i) {
    if (i%2 == 1) {
      if (isPrime(i) && isPrime((i+1)/2)) {
        a[i] = a[i-1]+1;
      }
      else {
        a[i] = a[i-1];
      }
    }
    else {
      a[i] = a[i-1];
    }
  }
  ll q;
  cin >> q;
  rep(i,q) {
    ll l, r;
    cin >> l >> r;
    cout << a[r]-a[l-1] << '\n';
  }

  end = chrono::system_clock::now();
  auto elapsed = chrono::duration_cast< chrono::milliseconds >(end - start).count();
  cerr << elapsed << "ms" << '\n';
}

Measured memory_bytes: 3976
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef double db;
typedef vector <ll> vll;
typedef pair <ll, ll> pll;
#define pb push_back
#define mp make_pair
#define MAX 1000000
#define mod 1000000007
#define all(_) _.begin(), _.end()
#define F first
#define S second
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    ll a, b;
    cin >> a >> b;
    for(ll i = 1; i <= 1000; i++)
    {
        if((ll)floor(i * 8 / 100.0000) == a && i / 10 == b)
        {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
using namespace std;
int main(){
	int n;
	scanf("%d", &n);
	n %= 10;
	if(n == 3){
		printf("bon");
	}
	else if(n == 0 || n==1 || n==6 || n==8){
		printf("pon");
	}
	else printf("hon");
	return 0;
}

Measured memory_bytes: 1736
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


class Combination:
    def __init__(self, n: int, mod: int):
        self.mod = mod
        self.fact = [0] * (n + 1)
        self.factinv = [0] * (n + 1)
        self.inv = [0] * (n + 1)
        
        self.fact[0] = self.fact[1] = 1
        self.factinv[0] = self.factinv[1] = 1
        self.inv[1] = 1
        for i in range(2, n + 1):
            self.fact[i] = (self.fact[i - 1] * i) % mod
            self.inv[i] = (-self.inv[mod % i] * (mod // i)) % mod
            self.factinv[i] = (self.factinv[i - 1] * self.inv[i]) % mod
    
    def ncr(self, n: int, r: int):
        if r < 0 or n < r:
            return 0
        r = min(r, n - r)
        return self.fact[n] * self.factinv[r] % self.mod * self.factinv[n - r] % self.mod
    
    def nhr(self, n: int, r: int):
        return self.ncr(n + r - 1, r)
    
    def npr(self, n: int, r: int):
        if r < 0 or n < r:
            return 0
        return self.fact[n] * self.factinv[n - r] % self.mod


def solve():
    N, K = map(int, rl().split())
    A = list(map(int, rl().split()))
    MOD = 10 ** 9 + 7
    
    A.sort()
    com = Combination(N, MOD)
    
    ans = 0
    for i in range(N):
        ans += com.ncr(i, K - 1) * A[i] % MOD
        ans -= com.ncr(N - i - 1, K - 1) * A[i] % MOD
        ans %= MOD
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 59376
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <list>
#include <array>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__)
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
template<typename T>
T gcd(T a, T b){
    while(b){
        a %= b;
        swap(a, b);
    }
    return a;
}
struct TwoStacks{
    using T = long long;
    struct Node{
        T val, sum;
        Node(const T &val, const T &sum):val(val), sum(sum){}
    };
    T merge(T l, T r){
        return gcd(l, r);
    }
    stack<Node> front, back;
    int size(){
        return front.size() + back.size();
    }
    T eval(){
        //        assert(front.size() + back.size() > 0);
        if(!back.empty()){
            if(!front.empty()){
                return merge(front.top().sum, back.top().sum);
            }else{
                return back.top().sum;
            }
        }else{
            return front.top().sum;
        }
    }
    void pop_front(){
        //        assert(front.size() + back.size() > 0);
        if(front.empty()){
            front.emplace(back.top().val, back.top().val);
            back.pop();
            while(!back.empty()){
                front.emplace(back.top().val, merge(back.top().val, front.top().sum));
                back.pop();
            }
        }
        front.pop();
    }
    void push_back(const T &val){
        if(!back.empty()){
            back.emplace(val, merge(back.top().sum, val));
        }else{
            back.emplace(val, val);
        }
    }
};

int main(){
    string s, t;
    cin >> s >> t;
    cout << t + s << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int isPrime(int x){
  int i;
  if(x<2) return 0;
  else if(x==2) return 1;
  if (x%2==0) return 0;
  for(i=3; i*i<=x; i+=2){
    if(x%i==0) return 0;
  }
  return 1;
}

int main(){
  int n,x,i;
  int ct=0;
  scanf("%d",&n);
  for(i=0; i<n; i++){
    scanf("%d",&x);
    if(isPrime(x)) ct++;
  }
  printf("%d\n",ct);

  return 0;
}


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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int N; scanf("%d", &N);
  int sum = 0;
  for (int i = N; i > 0; i /= 10) {
    sum += (i % 10);
  }
  bool ok = (N % sum) == 0;
  printf("%s\n", ok ? "Yes" : "No");
  return 0;
}


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

int main() {
	int n,s=0;
	cin>>n;
	int k=n;
	while(k)
	{
	    s+=k%10;
	    k=k/10;
	}
	if(n%s==0)
	cout<<"Yes"<<endl;
	else
	cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  vector<string> S;
  int N, L;
  cin >> N >> L;
  
  for(int i = 0; i < N; i++){
    string tmp;
    cin >> tmp;
    S.push_back(tmp);
  }
  
  sort(S.begin(), S.end());
  for(int i = 0; i < N; i++){
    cout << S.at(i);
  }
}

Measured memory_bytes: 256
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let a = read_as_string().chars().collect::<Vec<char>>();
    let b = read_as_string().chars().collect::<Vec<char>>();

    if a == b{
        println!("EQUAL");
        return;
    }

    if a.len() > b.len(){
        println!("GREATER");
        return;
    }else if a.len() < b.len(){
        println!("LESS");
        return;
    }

    for i in 0..a.len(){
        if a[i] > b[i]{
            println!("GREATER");
            return;
        }else if a[i] < b[i]{
            println!("LESS");
            return;
        }
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll/*, vl, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, n) for(ll i = 1; i <= ll(n); i++)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); i++)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); i++)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  char alpha;
  cin >> alpha;
  cout << ((ll)alpha>='a' ? 'a' : 'A') << newl;
  return 0;
}

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

void call(){

	int n;
	cin >> n;

	cout << n/3 << endl;

	return;
}

int main()
{
	int t;
	t=1;

	for (int i = 0; i < t; ++i)
	{
		call();
	}
	return 0;
}

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

double solve (double L) {
    double ans = 0;
    ans = (L / 3.0) * (L / 3.0) * (L / 3.0);
    return ans;
}

int main(){
  double L;
  cin >> L;
  cout << fixed << setprecision(8) << solve(L) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include <numeric>
using namespace std;
#define INF (1 << 30) - 1
#define LINF 1LL << 60
const int MOD = 1000000007;
using ll = long long;
using P = pair<ll, int>;

struct Edge{
  int to;
  ll weight;
  Edge(int t, ll w) : to(t), weight(w) {}
};

vector<vector<Edge>> g;
int n;

vector<ll> dist;
void dfs(int v, int p = -1, ll d = 0){
  dist[v] = d;
  for(auto nv : g[v]){
    if(nv.to == p)continue;
    dfs(nv.to, v, d + nv.weight);
  }
}


int main(){
  cin >> n;
  g.resize(n);
  for(int i = 0; i < n - 1; ++i){
    int a, b;
    ll c;
    cin >> a >> b >> c;
    --a;
    --b;
    g[a].push_back(Edge(b, c));
    g[b].push_back(Edge(a, c));
  }

  int q, k;
  cin >> q >> k;
  --k;
  dist.assign(n, LINF);
  dfs(k);

  for(int i = 0; i < q; ++i){
    int x, y;
    cin >> x >> y;
    --x;
    --y;

    cout << dist[x] + dist[y] << endl;
  }

  return 0;
}


Measured memory_bytes: 14336
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll MOD=1000000007;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
long long gcd(long long a,long long b){
    ll gcdmax=max(a,b);
    ll gcdmin=min(a,b);
    while(true){
        if(gcdmax%gcdmin==0)break;
        else gcdmax%=gcdmin;
        swap(gcdmin,gcdmax);
    }
    return gcdmin;
}
ll powerup(ll N,ll P,ll M){
    if(P==0)return 1;
    else if(P%2==0){
        ll t=powerup(N,P/2,M);
        return t*t%M;
    }
    else return N*powerup(N,P-1,M)%M;
}
vector<ll> find_divisor(ll N){
  ll k=1;
  while(k*k<=N){
    k++;
  }
  vector<ll> A(1);
  rep(i,k){
    if(i==1)A.at(0)=1;
    else if(i>=2){
      if(N%i==0)A.push_back(i);
    }
  }
  ll t=0;
  t=A.size();
  rep(i,t){
    if(A.at(t-i-1)*A.at(t-i-1)!=N)A.push_back(N/A.at(t-1-i));
  }
  return A;
}
const ll nmax=8;
bool graph[nmax][nmax];
ll dfs(ll v,ll N,bool visited[nmax]){
   bool all_visited=true;
   for(ll i=0;i<N;++i){
     if(visited[i]==false)all_visited=false;
   }
   if(all_visited){
     return 1;
    }
ll ret=0;
for(ll i=0;i<N;++i){
  if(graph[v][i]==false) continue;
  if(visited[i]) continue;
  visited[i]=true;
  ret+=dfs(i,N,visited);
  visited[i]=false;
  }
  return ret;
} 
int main()
{
  ll L;
  string S;
  cin>>S;
  L=S.size();
  vector<char> num(L);
  vector<ll> mod(2019);
  vector<ll> modt(L+1);
  rep(i,L){
    num.at(i)=S[L-i-1];
    modt.at(i+1)=(modt.at(i)+(num.at(i)-'0')*powerup(10,i,2019))%2019;
    mod.at(modt.at(i+1))+=1;
  }
  ll ans=0;
  mod.at(0)++;
  rep(i,2019){
    ans+=mod.at(i)*(mod.at(i)-1)/2;
  }
  cout<<ans<<endl;
}

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

using namespace std;

int N, A, B, C;
vector<int> l;

int solve(int a, int b, int c, int n) {
	if (n == N) {
		if (!(a && b && c)) return 1e9;
		return abs(A - a) + abs(B - b) + abs(C - c);
	}
	int r0 = solve(a, b, c, n + 1);
	int r1 = solve(a + l[n], b, c, n + 1) + (a ? 10 : 0);
	int r2 = solve(a, b + l[n], c, n + 1) + (b ? 10 : 0);
	int r3 = solve(a, b, c + l[n], n + 1) + (c ? 10 : 0);
	return min({ r0, r1, r2, r3 });
}

int main() {
	cin >> N >> A >> B >> C;
	l.resize(N);
	for (int i = 0; i < N; ++i) cin >> l[i];
	cout << solve(0, 0, 0, 0) << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>

using namespace std;

int main(void)
{
	int len;
	char str[20];
	cin >> str;
	
	string str1 = str;
	len = str1.size();
	
	for(int i = len-1; i >= 0; i--){
		cout << str[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
typedef long long int LL;
typedef unsigned long long int ULL;
using namespace std;

// 插入此處

LL a[200005];

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    LL ans = 0;
    LL t = a[0];
    for (int i = 1; i < n; i++) {
        if (a[i] < t) {
            ans += (t - a[i]);
        } else {
            t = a[i];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 5188
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <numeric>
#include <unordered_map>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <memory>
#include <iomanip>
#include <type_traits>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//constexpr long long MOD = 1e9 + 7;
//constexpr long long MAX = 1000000;

//long long MOD = 998244353;
constexpr ll INF = 1e17;
constexpr double PI = 3.141592653589793;
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; }

ll h, w;
vector<ll> dx = { -1, 0, 1, 0 };
vector<ll> dy = { 0, -1, 0, 1 };


bool isInField(ll x, ll y) {
    bool f = x >= 0 && x < w && y >= 0 && y < h;
    return f;
}

bool compare_first(pair<ll, ll> x, pair<ll, ll> y)
{
    if (x.first != y.first) {
        return x.first < y.first;
    }
    else {
        return x.second < y.second;
    }
}

bool compare_second(pair<ll, ll> x, pair<ll, ll> y)
{
    if (x.second != y.second) {
        return x.second < y.second;
    }
    else {
        return x.first < y.first;
    }
}

struct {
    bool operator()(pair<string, int> x, pair<string, int> y) const
    {
        return x.second <= y.second && x.first < y.first;
    }
} compare_map;

const ll MAX = 500000000;
const ll MOD = 1000000007;

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

    string s;
    cin >> s;
    if ((s[0] == 'A' && s[1] == 'A' && s[2] == 'A') || (s[0] == 'B' && s[1] == 'B' && s[2] == 'B')) {
        cout << "No" << "\n";
        return 0;
    }

    cout << "Yes" << "\n";
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int a,b,c,d;/*入力*/
	int ty=0,hg=0;

	while(scanf("%d,%d,%d",&a,&b,&c)!= EOF)
	{
		d=a*a+b*b;
		if(d==c*c)
		{
			if(a==b)
				hg++;
			else
				ty++;
		}
		else if(d>c*c)
		{
			if(a==b)
				hg++;
		}
	}
	printf("%d\n",ty);
	printf("%d\n",hg);
	return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
namespace QiFeng233{
	typedef long long ll;
	const int maxn=2e5+10;
	const ll mod=1e9+7;
	ll n,k,ans,s[maxn]; 
	void solve(){
		scanf("%lld%lld",&n,&k);
		for(ll i=1;i<=n;++i)s[i]=s[i-1]+i;
		for(ll i=k;i<=n;++i){
			ll first=s[i-1],end=s[n]-s[n-i];
			ans+=end-first+1;
			ans%=mod;
		}
		++ans;
		ans%=mod;
		printf("%lld",ans);
	}
}
signed main(){
	QiFeng233::solve();
	return 0;
}

Measured memory_bytes: 5268
#include<bits/stdc++.h>
using namespace std;
 
int main() {
  	int N,L;
  	cin >> N >> L;
  
  	string S;
  	vector<string> vec(N);
  
  	for (int i = 0; i < N; i++) {
    	cin >> vec.at(i);
    }
  
  	sort(vec.begin(),vec.end());
  	
 	for (int i = 0; i < N; i++) {
    	cout << vec.at(i);
    }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  int n;
  cin >> n;
  while(n > 0) {
    if (n % 10 == 7) {
      cout << "Yes" << endl;
	  return 0;
    }
    n /= 10;
  }
  cout << "No" << endl;
}


Measured memory_bytes: 3104
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <tuple>
#include <queue>
using namespace std;
typedef long long ll;

int main(void){
    int a[3], b[3];
    cin >> a[0] >> b[0];
    cin >> a[1] >> b[1];
    cin >> a[2] >> b[2];
    
    int k[4];
    k[0] = k[1] = k[2] = k[3] = 0;
    for (int i = 0; i < 3; i++) {
        k[a[i]-1]++;  k[b[i]-1]++;
    }
    
    int l[2];
    l[0] = l[1] = 0;
    for (int i = 0; i < 4; i++) {
        if (k[i] == 1) l[0]++;
        if (k[i] == 2) l[1]++;
    }
    
    if (l[0] == 2 && l[1] == 2) cout << "YES" << endl;
    else cout << "NO" << endl;
    
}


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

int main() {
    int N;
    cin >> N;
    int a[N], b[N], c[N];
    for (int i=0; i<N; ++i) cin >> a[i] >> b[i] >> c[i];

    long long int dp[3][N];
    dp[0][0] = a[0];
    dp[1][0] = b[0];
    dp[2][0] = c[0];

    for (int i=1; i<N; ++i) {
        dp[0][i] = max(dp[1][i-1]+a[i], dp[2][i-1]+a[i]);
        dp[1][i] = max(dp[2][i-1]+b[i], dp[0][i-1]+b[i]);
        dp[2][i] = max(dp[0][i-1]+c[i], dp[1][i-1]+c[i]);
    }

    cout << max(dp[0][N-1], max(dp[1][N-1], dp[2][N-1])) << endl;
    return 0;
}

Measured memory_bytes: 3712
#include <cstdio>
#include <utility>
#include <algorithm>

int n;
int P[200000];
int Q[200000];

int main(){
  scanf("%d", &n);
  for(int i = 0; i < n; i++) scanf("%d", P+i), Q[i] = std::min(i?Q[i-1]:n+1, P[i]);
  int ans = 0;
  for(int i = 0; i < n; i++) ans += Q[i] == P[i];
  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 1664
#include <iostream>
using namespace std;
int main(void){
    string a,b,c;
    cin >>a >>b >>c;
    a=a[0]-'a'+'A';
    b=b[0]-'b'+'B';
    c=c[0]-'c'+'C';
    cout <<a[0]<<b[0]<<c[0];

    return 0;
    
    
}

Measured memory_bytes: 256
from collections import deque
inf=10**9


def BFS(num):
    color=["white" for _ in range(n+1)]
    D=[inf for _ in range(n+1)]
    queue=deque([num])

    color[num]="gray"
    D[num]=0

    while len(queue)>0:
        u=queue.popleft()
        for i in M[u]:
            if color[i]=="white" and D[u]+1<D[i]:
                D[i]=D[u]+1
                color[i]="gray"
                queue.append(i)
        color[u]="black"

    return D


n,x,y=map(int,input().split())
M=[[] for _ in range(n+1)]
for i in range(1,n):
    M[i].append(i+1)
    M[i+1].append(i)
M[x].append(y)
M[y].append(x)

ans=[0 for _ in range(n-1)]
for i in range(1,n+1):
    for j in BFS(i)[i+1:]:
        ans[j-1] +=1

for i in ans:
    print(i)

Measured memory_bytes: 9676
#include<bits/stdc++.h>
#define ll long long
#define F(i,n) for(int i=0;i<n;i++)
#define pb push_back
#define i64 int64_t
#define fi first
#define se second
using namespace std;
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);
	string s;
	cin>>s;
	if(s[2]==s[3]&&s[4]==s[5])
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
double pi=3.14159265358979323846264338327950;
  double a,b,h,m;
  cin >> a >> b >> h >> m;
  long double deg;
  deg = 2*pi*((h/12+m/60/12) - (m/60));
  long double ans;
  ans = (a*a+b*b) - (2*a*b*cosl(deg));
  cout << setprecision(15) << sqrtl(ans) << endl;
}

Measured memory_bytes: 4128
#include<stdio.h>
int main(void){
    int a,b,c,d,e,x;
    scanf("%d %d %d %d %d",&a,&b,&c,&d,&e);
    if(a<40){
        a=40;
    }
    if(b<40){
        b=40;
    }
    if(c<40){
        c=40;
    }
    if(d<40){
        d=40;
    }
    if(e<40){
        e=40;
    }
    x=a+b+c+d+e;
    printf("%d\n",x/5);
    return 0;
}

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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

int main() {
    int h, a;
    cin >> h >> a;

    int d = h / a;
    int r = h % a;
    cout << (0 < r ? d + 1 : d) << endl;

    return 0;
}


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

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN];
int head, tail,n;

void initialize(){
  head = tail = 0;
}

void enqueue(P x){
  Q[tail] = x;
  tail = (tail + 1) % LEN;
  }

P dequeue(){
  int tmp;
  P x = Q[head];
  head = (head+1) % LEN;
  return x;
}

int min(int a, int b){
  return a<b ? a:b;
}

int main() {
  int elaps=0,c;
  int i,q;
  P u;
  scanf("%d %d", &n,&q);
  for(i=1;i<=n;i++){
       scanf("%s",Q[i].name);
    scanf("%d",&Q[i].t);
  }
  head = 1;
  tail = n+1;
  while(head != tail){
    u=dequeue();
    c=min(q,u.t);
    u.t -= c;
    elaps += c;
    if(u.t>0)
      enqueue(u);
    else{
      printf("%s %d\n" ,u.name,elaps);
    }
  }
  return 0;
}


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


int main()
{
    ll n,w;
    cin>>n>>w;
    vector<ll> weight(n);
    vector<ll> value(n);
    for(ll i=0;i<n;i++)
    {
        cin>>weight[i];
        cin>>value[i];
    }
    ll sum_value=0;
    for(ll i=0;i<n;i++)
    sum_value+= value[i];
    vector<ll> dp(sum_value+1,1e18);
    dp[0]=0;
    for(ll i =0;i<n;i++)
    {
        for(ll j=sum_value-value[i];j>=0;j--)
        {
            dp[j+value[i]] = min(dp[j+value[i]],dp[j]+weight[i]);
        }
    }
    ll ans = -1;
    for(ll i=1;i<=sum_value;i++)
    {
        if(dp[i] <= w)
        {
            ans = max(ans,i);
        }
    }
    cout<<ans;
    return 0;
}

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

int n;
string s;

long long k;

int main() {
	//freopen(".inp", "r", stdin); freopen(".out", "w", stdout);
	ios_base :: sync_with_stdio(false); cin.tie(NULL);
 	cin >> s >> k;
 	n = s.size(); 
 	s = " " + s;
 	int pos = -1;
 	for (int i = 1; i <= n; i++) {
 		if (s[i] != '1') {
 			pos = i;
 			break;
 		}
 	}
 	if (pos == -1) return cout << 1, 0;
 	if (k < pos) return cout << 1, 0;
 	cout << s[pos];
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <algorithm>

using namespace std;

int a[200'009];

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
    a[i] -= i + 1;
  }
  sort(a, a + n);
  long long ans = 0;
  for (int i = 0; i < n; ++i) {
    ans += abs(a[i] - a[n / 2]);
  }
  printf("%lld\n", ans);
}


Measured memory_bytes: 896