akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;

int main() {
	string s;
	cin >> s;
	set<string> sum;
	rep(i, 0, s.size()) {
		string a;
		a = s[i];
		sum.insert(a);
	}
	if (s.size() == sum.size()) {
		cout << "yes\n";
	}
	else {
		cout << "no\n";
	}
	return 0;
}


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

int main()
{
    set<long long> s;
    int N;
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        long long a;
        cin >> a;
        s.insert(a);
    }
    if (N == s.size())
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 9600
#include<map>
#include<bitset>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<stack>
#define REP(i,x,y) for(ll i=x;i<y;i++)
#define SIZE(a) ll(a.size())
#define vll vector<ll>
#define MEMSET(a, n, m) for(ll i=0;i<=n;i++) a[i] = m
#define BIT(n) (ll(1)<<n)
#define UNIQUE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define UNIQUE_ARRAY(a,n) n = unique(a + 1, a + x + 1) - a - 1
#define SORT(a,n) sort(a+1,a+n+1)
#define SORT_O(a,n,order) sort(a+1,a+n+1,order)
#define PER(i,y,x) for(ll i=y;i>x;i--)
typedef long long ll;
using namespace std;
int main(){
    ll n,a,b;
    cin>>n>>a>>b;
    if (a*n>=b){
        cout<<b<<endl;
    }
    else{
        cout<<a*n<<endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<vector>
using namespace std;
int t,n,m,x[100010],y[100010],f[100010],g[100010],r[100010],u,v,w,p,q;
vector<int> a[100010];
inline void dfs(int i,int j)
{
    int k;
    for(k=0;k<a[i].size();k++)
      if(a[i][k]!=j)
        if(!x[a[i][k]])
          {
           x[a[i][k]]=-x[i];
           dfs(a[i][k],i);
          }
        else
          {
           u=i;
           v=a[i][k];
           w=(x[i]==x[a[i][k]]);
          }
}
inline void dp(int i,int j)
{
    int k;
    f[i]=x[i];
    g[i]=y[i];
    for(k=0;k<a[i].size();k++)
      if(a[i][k]!=j && (i!=u || a[i][k]!=v) && (i!=v || a[i][k]!=u))
        {
         dp(a[i][k],i);
         f[i]+=f[a[i][k]];
         g[i]+=g[a[i][k]];
        }
}
int main()
{
	//freopen("color.in","r",stdin);
	//freopen("color.out","w",stdout);
	int i,j,k;
	//scanf("%d",&t);
	t=1;
	while(t--)
	  {
       scanf("%d%d",&n,&m);
       for(i=1;i<=n;i++)
         a[i].clear();
       for(i=1;i<=m;i++)
         {
          scanf("%d%d",&j,&k);
          a[j].push_back(k);
          a[k].push_back(j);
         }
       if(n&1)
         {
          printf("-1\n");
          continue;
         }
       for(i=1;i<=n;i++)
         x[i]=y[i]=0;
       p=q=0;
       x[1]=1;
       dfs(1,0);
       if(m==n-1)
         {
          dp(1,0);
          if(f[1])
            {
             printf("-1\n");
             continue;
            }
          for(i=2;i<=n;i++)
            p+=abs(f[i]);
          printf("%d\n",p);
         }
       else if(w)
         {
          dp(1,0);
          p=abs(f[1]/2);
          x[u]-=f[1]/2;
          x[v]-=f[1]/2;
          dp(1,0);
          for(i=2;i<=n;i++)
            p+=abs(f[i]);
          printf("%d\n",p);
         }
       else
         {
          y[u]=1;
          y[v]=-1;
          dp(1,0);
          if(f[1])
            {
             printf("-1\n");
             continue;
            }
          q=1;
          r[1]=0;
          for(i=2;i<=n;i++)
            if(g[i])
              r[++q]=f[i]*g[i];
            else
              p+=abs(f[i]);
          sort(r+1,r+q+1);
          for(i=1;i<=q;i++)
            p+=abs(r[i]-r[q+1>>1]);
          printf("%d\n",p);
         }
      }
	return 0;
}


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

using namespace std;

int main () {
	int n;
	cin >> n;
	vector<int> d(n);
	for (int i = 0; i < n; i++) {
		cin >> d[i];
	}

	sort(d.begin(), d.end());

	int a = d[n / 2 - 1];
	int b = d[n / 2];

	int c = a == b ? 0 : b - a;

	cout << c << endl;
}

Measured memory_bytes: 640
n, q = map(int, input().split(' '))
L = []
i = 0
while i < n:
    name, time = map(str, input().split(' '))
    L.append([name, int(time)])
    i += 1
t = 0
fin = []
while len(L) != 0:
    if L[0][1] > q:
        t += q
        name = L[0][0]
        time = L[0][1] - q
        L.append([name, time])
        L.pop(0)
    else:
        t += L[0][1]
        name = L[0][0]
        time = t
        fin.append([name, time])
        L.pop(0)
ans = ''
for f in fin:
    ans += f[0] + ' ' + str(f[1]) + '\n'
print(ans[:-1])


Measured memory_bytes: 16264
/*
      author  : nishi5451
      created : 14.08.2020 23:36:21
*/

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


int main(){
    int n,m;
    cin >> n >> m;
    vector<int> dp(m+1);
    rep(i,n){
        int k;
        cin >> k;
        rep(j,k){
            int a;
            cin >> a;
            dp[a]++;
        }
    }
    int ans = 0;
    for(int i=1; i<=m; i++){
        if(dp[i]==n) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
  int n;
  cin >> n;
  
  string res = "No";
  
  for(size_t i = 0; i < 3; ++i)
  {
    if((n % 10) == 7)
    {
      res = "Yes";
      break;
    }
    n /= 10;
  }
  
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3620
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using static System.Globalization.CultureInfo;

class Program
{
    static void Main(string[] args)
    {
        var nab = Input.ar;
        var xs = Input.ar;
        var res = 0L;
        for (var i = 1; i < nab[0]; i++)
            res += Min((long)(xs[i] - xs[i-1]) * nab[1], nab[2]);
        WriteLine(res);
    }
}

public class Input
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public static int[][] twodim(int num)
        => Enumerable.Repeat(0, num).Select(v => ar).ToArray();
    public static long[][] twodimL(int num)
        => Enumerable.Repeat(0, num).Select(v => arL).ToArray();
    public static Tuple<int, int, long> MakeEdge(int num1, int num2, long weight=Inf)
        => new Tuple<int, int, long>(num1, num2, weight);
    public const long Inf = (long)1e18;
    public const double eps = 1e-11;
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}


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

using ll = long long;

int main() {
  size_t N, M;
  std::cin >> N >> M;

  std::vector<size_t> Mods(N+1);
  Mods[0] = 0;
  ll Sum = 0;
  for (size_t i=1; i<N+1; i++) {
    ll a;
    std::cin >> a;
    Sum += a;
    Mods[i] = Sum % M;
  }

  std::sort(Mods.begin(), Mods.end());

  ll ans = 0;
  size_t cnt = 0;

  for (size_t i=1; i<N+1; i++) {
    if (Mods[i] == Mods[i-1]) {
      cnt++;
      ans+=cnt;
    } else {
      cnt=0;
    }
  }

  std::cout << ans << std::endl;
}



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

int main(){
    int A,B,C,D; cin>>A>>B>>C>>D;
    while(A>0 && C>0){
        C-=B;
        if(C<=0){
            cout<<"Yes";
            return 0;
        }
        A-=D;
        if(A<=0){
            cout<<"No";
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
 
using namespace std;
 
#define INF 1000000007
#define LINF 1000000000000000007
 
typedef long long ll;
typedef pair<ll,ll> P;


int n, a[101010], k;

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

int main(){
	cin >> n >> k;
	for(int i = 0; i < n; i++) cin >> a[i]; 
	
	int c = a[0];
	bool b = 0;
	for(int i = 0; i < n; i++){
		c = gcd(c, a[i]);
		if(a[i] >= k) b = 1;
	}
	if(b && k%c == 0) cout << "POSSIBLE" << endl;
	else cout << "IMPOSSIBLE" << endl;
	
	return 0;
}

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

#define name ""
#define ini freopen(name".inp","r",stdin); freopen(name".out","w",stdout)
#define foe(it,c) for (__typeof(c.begin()) it = c.begin(); it != c.end(); it++)
#define long long long 
#define db double 
#define pii pair <int, int>
#define pll pair <long, long>
#define all(c) c.begin(), c.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

const int INF = 1e9+7;
const int MOD = 1e9+7;
const int dx[4] = {0,0,-1,1};
const int dy[4] = {-1,1,0,0};

int main()
{
  fastio;
  int n; cin >> n;
  vector <int> deg; deg.resize(n + 1, 0);
  for (int i = 1; i < n; i++){
    int u; cin >> u; 
    deg[u]++;
  }
  for (int i = 1; i <= n; i++) cout << deg[i] << '\n';
  return 0;
}

Measured memory_bytes: 4004
while True:
    m,f,r = map(int,input().split())
    if m == f == r == -1:
        break
    elif m == -1 or f == -1:
        print("F")
    elif m+f >= 80:
        print("A")
    elif m+f >= 65:
        print("B")
    elif m+f >= 50:
        print("C")
    elif m+f >= 30:
        if r >= 50:
            print("C")
        else:
            print("D")
    else:
        print("F")

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  int n,k;cin>>n>>k;
  vector<int>p(n);
  rep(i, n){ cin>>p[i]; p[i]--; }
  vector<ll>c(n);
  rep(i, n)cin>>c[i];

  ll result = -INF;
  rep(i, n){
    vector<ll>scores;
    int now=p[i];
    int lc = 1;
    scores.push_back(0);
    scores.push_back(c[now]);
    while(now!=i){
      now = p[now];
      scores.push_back(scores[lc] + c[now]);
      lc++;
    }

//rep1(j, lc)cout<<scores[j]<<' ';cout<<endl;cout<<lc<<endl;

    rep1(j, lc){
      if(k<j)continue;
      ll total = scores.back();
      ll loopcount = (k-j)/lc;
      if(loopcount<0 || total<0)loopcount=0;
//cout<<result<<' '<<total<<' '<<loopcount<<' '<<scores[j]<<endl;
      result = max<ll>(result, total * loopcount + scores[j]);
    }
  }

  cout<<result<<endl;

  return 0;
}


Measured memory_bytes: 3792
#include <cstdio>

int main()
{
    int deck[50] = {}, tam[50] = {}, num, times, p, c;

    while (1)
    {
        scanf("%d %d", &num, &times);
        if (num == 0 && times == 0)
        {
            break;
        }
        for (int i = 0; i < num; i++)
        {
            deck[i] = num - i;
        }

        for (int i = 0; i < times; i++)
        {
            scanf("%d %d", &p, &c);
            for (int j = 0; j < p - 1; j++)
            {
                tam[j] = deck[j];
            }
            for (int j = 0; j < c; j++)
            {
                deck[j] = deck[j + p - 1];
            }
            for (int j = 0; j < p - 1; j++)
            {
                deck[c + j] = tam[j];
            }
        }
        printf("%d\n", deck[0]);
    }
}


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

typedef vector <int> VI;

VI::iterator putting_card( VI& hands, int deck_top )
{
	for ( VI::iterator it = hands.begin(); it != hands.end(); it++ )
	{
		if ( deck_top == -1 || *it > deck_top ) return it;
	}
	return hands.end();
}

int main( void )
{
	int n;
	while ( cin >> n && n )
	{
		VI tarou(n);
		for ( int i = 0; i < n; i++ ) cin >> tarou[i];
		VI hanako(2*n);
		for ( int i = 0; i < 2*n; i++ ) hanako[i] = i+1;
		for ( VI::iterator it = tarou.begin(); it != tarou.end(); it++ )
		{
			VI::iterator remove_card;
			if ( ( remove_card = find( hanako.begin(), hanako.end(), *it ) ) != hanako.end() )
				hanako.erase( remove_card );
		}

		sort( tarou.begin(), tarou.end() );
		sort( hanako.begin(), hanako.end() );

		bool turn = true;
		int deck_top = -1;
		while ( tarou.empty() == false && hanako.empty() == false )
		{
			if ( turn )
			{
				VI::iterator card = putting_card( tarou, deck_top );
				if ( card != tarou.end() )
				{
					deck_top = *card;
					tarou.erase( card );
				}
				else deck_top = -1;
			}
			else
			{
				VI::iterator card = putting_card( hanako, deck_top );
				if ( card != hanako.end() )
				{
					deck_top = *card;
					hanako.erase( card );
				}
				else deck_top = -1;
			}
			turn = !turn;
		}

		cout << hanako.size() << endl;
		cout << tarou.size() << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <cmath>
#include <unordered_map>

#define MaxN 200010

using namespace std;

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

int n, m;

int main() {
    scanf("%d%d", &n, &m);
    ll ans = 0;
    for (int i = 0; i < m; ++i) {
        int a;
        scanf("%d", &a);
        ans += a;
    }
    if (ans <= n) {
        printf("%d\n", int(n - ans));
    }
    else {
        puts("-1");
    }

    return 0;
}

Measured memory_bytes: 3816
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tll;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<ll> baseNums;
    ll temp = 6;
    while (temp <= N)
    {
        baseNums.push_back(temp);
        temp *= 6;
    }
    temp = 9;
    while (temp <= N)
    {
        baseNums.push_back(temp);
        temp *= 9;
    }
    sort(baseNums.begin(), baseNums.end());
    ll INF = 1e12;
    vector<vector<ll>> dp(baseNums.size() + 1, vector<ll>(N + 1, INF));
    for (int i = 0; i <= N; i++)
    {
        dp.at(0).at(i) = i;
    }
    for (int i = 0; i < baseNums.size(); i++)
    {
        ll baseNum = baseNums.at(i);
        for (int j = 0; j <= N; j++)
        {
            if (j < baseNum)
            {
                dp.at(i + 1).at(j) = dp.at(i).at(j);
            }
            else
            {
                dp.at(i + 1).at(j) = min(dp.at(i).at(j), dp.at(i + 1).at(j - baseNum) + 1);
            }
        }
    }
    cout << dp.at(baseNums.size()).at(N) << endl;
    return 0;
}


Measured memory_bytes: 10496
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const long long int mod=1000000007;
const long long int MAX=100005;
#define pb push_back
#define IO() ios_base::sync_with_stdio(false); cin.tie(NULL);
#define endl "\n"
#define fr first
#define sc second
#define all(v) (v.begin(),v.end())
#define fl(i,a,b) for(ll i=a;i<b;i++)
#define fle(i,a,b) for(ll i=a;i<=b;i++)
#define gr greater<ll>()
#define input(a,n) fl(i,0,n) { cin>>a[i]; }
#define output(a,n) fl(i,0,n) { cout<<a[i]<<" "; } cout<<"\n";
ll fact(ll );
ll lcm(ll , ll );
ll gcd(ll , ll );
ll x=0;

ll fact(ll n){
    if(n==0)
        return 1;
    return n*fact(n-1);
}

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

ll lcm(ll a, ll b)  {
    return (a*b)/gcd(a, b);
}

ll modPower(ll a,ll b)
{
    ll res = 1;
    while(b)
    {
        if(b&1)
            res  = (res%mod * a%mod)%mod;
        b >>= 1;
        a = (a%mod * a%mod)%mod;
    }
    return res;
}

ll sigma(ll x)
{
    return (x*(x+1))/2;
}

class Graph 
{ 
    ll V;  
    list<ll> *adj; 
  
    void DFSUtil(ll v, bool visited[]); 
public: 
    Graph(ll V);    
    ~Graph(); 
    void addEdge(ll v, ll w); 
    void connectedComponents(); 
}; 
  
void Graph::connectedComponents() 
{ 
    bool *visited = new bool[V]; 
    for(ll v = 0; v < V; v++) 
        visited[v] = false; 
  
    for (ll v=0; v<V; v++) 
    { 
        if (visited[v] == false) 
        { 
            DFSUtil(v, visited); 
            // cout<<"\n";
            x++;
        } 
    } 
    delete[] visited; 
} 
  
void Graph::DFSUtil(ll v, bool visited[]) 
{ 
    visited[v] = true; 
    // cout<<v<<" ";
    list<ll>::iterator i; 
    for(i = adj[v].begin(); i != adj[v].end(); ++i) 
        if(!visited[*i]) 
            DFSUtil(*i, visited); 
} 
  
Graph::Graph(ll V) 
{ 
    this->V = V; 
    adj = new list<ll>[V]; 
} 
  
Graph::~Graph() 
{ 
    delete[] adj; 
} 
  
void Graph::addEdge(ll v, ll w) 
{ 
    adj[v].push_back(w); 
    adj[w].push_back(v); 
} 
  

string decimalToBinary(ll n)
{
    string s = bitset<64> (n).to_string();

    const auto loc1 = s.find('1');

    if(loc1 != string::npos)
        return s.substr(loc1);

    return "0";
}

void solve()
{
    ll n,m;
    cin>>n>>m;
    Graph g(n);
    ll u,v;
    for(ll i=0;i<m;i++)
    {
        cin>>u>>v;
        --u;--v;
        g.addEdge(u, v); 
    }
    g.connectedComponents();
    cout<<x-1;
}

int main()
{
    IO()
	// freopen("D:/C++ Programs/abc_input.txt","r",stdin);
    // freopen("D:/C++ Programs/abc_output.txt","w",stdout);
	ll T = 1;
	//cin>>T;
	fle(i,1,T)
	{
	    // cout<<"Case #"<<i<<": ";
	    solve();
	    cout<<"\n";
	}
	return 0;
}


Measured memory_bytes: 13256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repe(i, n) for(i = 0; i <= (n); i++)
#define repr(i, n) for(int (i) = (n); (i) > 0; --(i))
#define repre(i, n) for(int (i) = (n); (i) >= 0; --(i))
typedef long long ll;
typedef unsigned long long ull;

int dp[5005][5005];

int main()
{
    ull N;
    cin >> N;
    cout << pow(N, 3) << endl;
    return 0;
}


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

#define ll long long
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007

using namespace std;
ll power(ll a,ll n)
{
          ll result=1;
          while(n>0)
          {
               if(n&1)
                    result=result*a;
               a=a*a;
               n=n>>1;
          }
          return result;
}
ll lcm(ll a,ll b)
{
          return ((a*b)/__gcd(a,b));
}
bool ispow2(ll n)
{
          return (ceil(log2(n))==floor(log2(n)));
}
bool isprime(ll n)
{
          if(n==1)
               return false;
          else if(n==2)
               return true;
          else
          {
               for(ll i=2;i*i<=n;++i)
               {
                    if(n%i==0)
                         return false;
               }
               return true;
          }
}

ll ncr(ll n,ll r)
{
    if(r > n - r)
          r = n - r;
    ll ans = 1;
    ll i;

    for(i = 1; i <= r; i++)
     {
        ans *= n - r + i;
        ans /= i;
    }

    return ans;
}

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

          int t=1;
          //cin>>t;
          while(t--)
          {
                    int a,b,c;
                    cin>>a>>b>>c;
                    int temp = (int)ceil((double)a/b);
                    cout<<temp*c;
          }
          return 0;
}


Measured memory_bytes: 3692
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007

int main(){
  ll n;
  cin>>n;
  vector<string> vs;
  vector<ll> v;
  rep(i,0,n){
    ll a;
    string s;
    cin>>s>>a;
    vs.pb(s);
    v.pb(a);
  }
  string ss;
  cin>>ss;
  ll ans = 0;
  ll flag = 0;
  rep(i,0,vs.sz){
    if(flag==1){
      ans += v[i];
    }
    if(vs[i]==ss){
      flag = 1;
    }
  }
  cout << ans << endl;
  return 0;
}

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

using ll = long long;
 
int main(){
	ll n; cin >> n;
	string s; cin >> s;
	ll r = 0, g = 0, b = 0, ans = 0;
	for(ll i = 0; i < n; ++i){
		if(s[i] == 'R')r++;
		else if(s[i] == 'G')g++;
		else b++;
	}
	ans = r * g * b;
	for(ll i = 0; i < n; ++i){
		for(ll j = 1; j  <= n; ++j){
			ll kanta = i;
			ll kanta1 = i + j;
			ll kanta2 = kanta1 + j;
			if(kanta2 < n){
				if(s[kanta] != s[kanta2] && s[kanta] != s[kanta1] && s[kanta1] != s[kanta2]){
					ans--;
				}
			}
		}
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 3584
def main():
    a, b, k = map(int, input().split())
    if a == 0 and b == 0:
        print(a, b)
    elif a <= k:
        a_diff = k - a
        a = 0
        if b <= a_diff:
            b = 0
            print(a, b)
        else:
            b -= a_diff
            print(a, b)
    else:
        a = a - k
        print(a, b)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#include <limits.h>

#define lli long long int
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define	abs(a) ((a)<0?-(a):(a))

int comp(const void *a,const void *b){
	return *(int*)b - *(int*)a;
}

int main(void){
	int k;int t;
	scanf("%d%d",&k,&t);
	int *a;
	a = calloc(sizeof(int),t);
	int i;
	for(i=0;i<t;i++){
		scanf("%d",&a[i]);
	}
	qsort(a,t,sizeof(int),comp);
	for(i=1;i<t;i++){
		a[0] -= a[i];
	}
	a[0]--;
	printf("%d\n", max(0,a[0]));
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
  
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <string>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <unordered_set>
#include <list>
#include <tuple>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <cassert>
#include <numeric>
#include <math.h>
#include <bitset>
#include <random>
#include <regex>

using namespace std;
  
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,f,n) for(int i=f;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(14)
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;
constexpr int dy[] = {0,1,0,-1,1,-1,-1,1};
constexpr int dx[] = {1,0,-1,0,1,1,-1,-1};
 
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class A, class B> inline A updiv(const A a,const B b){ return (a + b - 1) / b; }
template <class A, class B> inline A gcd(const A a,const B b){ return b ? gcd(b,a % b) : a; }
template <class A, class B> inline A lcm(const A a,const B b){ return a / gcd(a,b) * b; }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A,class B> using umap = unordered_map<A,B>;

signed main(void){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int xs, ys, xt, yt, n;
    cin >> xs >> ys >> xt >> yt >> n;

    vector<tuple<int, int, int> > xyr;

    xyr.emplace_back(xs, ys, 0);
    rep(i,n){
        int x, y, r;
        cin >> x >> y >> r;
        xyr.emplace_back(x, y, r);
    }
    xyr.emplace_back(xt, yt, 0);

    n += 2;

    vector<vector<pair<int, long double> > > g(n);

    rep(i,n){
        rep(j,n){
            if(i == j) continue;
            int xa, ya, ra, xb, yb, rb;
            tie(xa, ya, ra) = xyr[i];
            tie(xb, yb, rb) = xyr[j];
            double dist = max(hypot(xa - xb, ya - yb) - ra - rb, 0.0);
            g[i].emplace_back(j, dist);
            g[j].emplace_back(i, dist);
        }
    }

    min_heap<pair<long double, int> > pq;
    vector<long double> min_cost(n, LINF);

    pq.emplace(0, 0);
    min_cost[0] = 0;

    while(!pq.empty()){
        long double now_cost;
        int now_node;
        tie(now_cost, now_node) = pq.top();
        pq.pop();
        if(now_cost > min_cost[now_node]) continue;
        for(auto e : g[now_node]){
            int next_node;
            long double next_cost;
            tie(next_node, next_cost) = e;
            if(chmin(min_cost[next_node], min_cost[now_node] + next_cost)){
                pq.emplace(min_cost[next_node], next_node);
            }
        }
    }

    cout << Fixed << min_cost[n-1] << '\n';

    return 0;
}

Measured memory_bytes: 74988
n = int(input().strip())
a = list(map(int, input().split()))
dic = {}
for i in range(len(a)):
    if dic.get(a[i]):
        dic[a[i]] += 1
    else:
        dic[a[i]] = 1
for i in range(1, n + 1):
    if dic.get(i):
        print(dic[i])
    else:
        print(0)


Measured memory_bytes: 111956
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;

int main(){
    int a,b,c;
    cin >> a >> b >> c;

    vector <int> v(3);
    v[0] = a;
    v[1] = b;
    v[2] = c; 
    sort(v.begin(),v.end());

    int count=0;
    if(v[1]==v[2] && v[1]!=v[0]){

        if((v[1]-v[0])%2==0){
            count += (v[1]-v[0])/2;
        }else{
            v[2]++;
            v[1]++;
            count++;
            count += (v[1]-v[0])/2;
        }

    }else if(v[0]==v[1] && v[1]==v[2]){

    }else if(v[1]==v[0] && v[1]!=v[2]){

        count += v[2]-v[1];

    }else{

        while(1){
            v[0]++;
            v[1]++;
            count++;
            if(v[1]==v[2]) break;
        }
        if((v[1]-v[0])%2==0){
            count += (v[1]-v[0])/2;
        }else{
            v[2]++;
            v[1]++;
            count++;
            count += (v[1]-v[0])/2;
        }

    }

    cout << count << endl;

}

Measured memory_bytes: 256
while True:
    s=input().split()
    t=[int(i) for i in s]
    H=t[0]
    W=t[1]
    if H==0:
        break
    else:
        print("#"*W)
        for i in range(H-2):
            print("#"+"."*(W-2)+"#")
        print("#"*W)
        print()


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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD 1000000007

using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int iy[]={0, 0, 1, -1};
int ix[]={1, -1, 0, 0};

long long int n, k;
long long int ans;
int main(){
	cin >> n >> k;
	if(k==0){
		ans = n*n;
	}else{
		for(long long int i = k+1;i <=n;i++){
			ans += (n+1) / i * (i-k);
			if((n+1+i)%i!=0){
				if((n+1+i)%i - k>0) ans+=(n+1+i)%i - k;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = []
for i in range(N):
    A.append(int(input()))

srtd = sorted(A)
for i in range(N):
    # print(str(i) + '番目')
    if srtd[-1] != A[i]:
        print(srtd[-1])
    else:
        print(srtd[-2])


Measured memory_bytes: 70360
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d,e,f[5009],pas=1;
vector <pair <int, int> > v[5009];
vector <pair <int, int> >::iterator it;
int main(){
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>a;
	for(b=1; b<=a; b++) cin>>f[b];
	sort(f+1,f+a+1);
	for(b=a-1; b>=1; b--){
		for(c=b+1; c<=a; c++){
			if(v[c].size()==0){
				v[b].push_back(make_pair(f[c]-f[b],2));
				if(pas<2) pas=2;
				continue;
			}
			it=lower_bound(v[c].begin(),v[c].end(),make_pair(f[c]-f[b],0));
			if(it==v[c].end()||(*it).first>f[c]-f[b]){
				v[b].push_back(make_pair(f[c]-f[b],2));
				if(pas<2) pas=2;
			}else{
				v[b].push_back(make_pair(f[c]-f[b],(*it).second+1));
				if(pas<(*it).second+1) pas=(*it).second+1;
			}
		}
	}
	cout<<pas<<endl;
	return 0;
}


Measured memory_bytes: 115868
// ABC067_A.cpp : Defines the entry point for the console application.
//

#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main()
{
	int a, b;
	cin >> a >> b;
	if (a + b <= 23) {
		cout << a + b << endl;
	}
	else if (a + b >= 24) {
		cout << a + b - 24 << endl;
	}
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define pp pair<ll,ll>
#define all(v) (v).begin(),(v).end()
#define sz(v) (ll)(v).size()
#define F first 
#define S second 
#define lc "\n"
ll power(ll x,ll y,ll p){ll res=1;x=x%p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
ll ncr(ll n,ll k){if(k==0)return 1;if(k>n-k)k=n-k;ll a=1,b=1,d;while(k){a*=n;b*=k;d=__gcd(a,b);a/=d;b/=d;n--;k--;}return a;} 
ll MAX=1e18 , MIN=-1e18 , MOD=1000000007;
void YJ()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
}
int main() 
{
    YJ(); fastio
    string s; cin>>s;
    ll i,n,ans=0; n=s.length();
    for(i=0;i<n;i++) ans+=(s[i]-'0');
    if(ans%9) cout<<"No";
    else cout<<"Yes";
    return 0;
}

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

using namespace std;
using ll = long long;
using p = pair<ll,ll>;
#define rep(i,k) for(ll i = 0; i<(ll)k;i++)

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

    return 0;
}

Measured memory_bytes: 3612
# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..)
import sys
def main(N, A):
    m = ans = 1000
    s = 0
    for i in range(N - 1):
        if A[i + 1] > A[i]:
            s += m // A[i]
            m %= A[i]
        else:
            m += s * A[i]
            s = 0
        ans = max(ans, m)
    ans = max(ans, m + s * A[-1])
    print(ans)

if __name__ == '__main__':
    input = sys.stdin.readline
    N = int(input())
    *A, = map(int, input().split())
    main(N, A)


Measured memory_bytes: 61868
#include <iostream>
#include<cmath>
#include<vector>
#include <algorithm>
#include <limits>
#include <numeric>
#include <type_traits>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

int main() {
	long int n, a, b;
	long int ans;
	long int l, r;
	cin >> n >> a >> b;
	if ((a - b) % 2 == 0) {
		ans = abs(a - b) / 2;
	}

	else {
		l = (a-1 + b-1 + 1) / 2;
		r = (n - a + n - b + 1) / 2;
		ans = min(l, r);
	}
	cout << ans;
}
		


Measured memory_bytes: 256
v[50],c,p,s;f(X){for(;c<X;c+=v[p++]);c=50*(c-X);}main(n){for(;c=n=atoi(gets(v));printf("%d\n",s)){for(p=s=0;p<n;v[++p]=strlen(gets(v+n)));for(;c;)c=0,p=++s,f(5),f(7),f(5),f(7),f(7);}
}

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

int main() {
    string S;
    cin >> S;

    long long ans = 0;
    for (int i = 0; i < (1 << (S.size() - 1)); i++) {
        long long sum = 0;
        for (int j = 0; j < S.size(); j++) {
            if (j > 0 && ((i >> (j - 1)) & 1)) {
                sum = 10 * sum + (S[j] - '0');
            } else {
                ans += sum;
                sum = S[j] - '0';
            }
        }
        ans += sum;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ld long double
#define INF 1000000000000000000
typedef pair<ll, ll> pll;

ll H = 0;

int parent(int i) { return i / 2; }

int left(int i) { return 2 * i; }

int right(int i) { return 2 * i + 1; }

void maxHeapify(vector<ll> &A, int i) {
    int l = left(i);
    int r = right(i);
    int largest;
    if (l <= H and A[l] > A[i]) {
        largest = l;
    } else {
        largest = i;
    }
    if (r <= H && A[r] > A[largest]) {
        largest = r;
    }
    if (largest != i) {
        swap(A[i], A[largest]);
        maxHeapify(A, largest);
    }
}

void heapIncrease(vector<ll> &A, int i, int key) {
    if (key < A[i]) {
        cout << "Error"
             << "あほぼけ" << endl;
        return;
    }
    A[i] = key;
    while (i > 1 && A[parent(i)] < A[i]) {
        swap(A[i], A[parent(i)]);
        i = parent(i);
    }
}

void insert(vector<ll> &A, int key) {
    H++;
    A[H] = -INF;
    heapIncrease(A, H, key);
}

int heapExtractMax(vector<ll> &A) {
    if (H < 1) {
        cout << "Error"
             << "あほぼけ" << endl;
        return 0;
    }

    ll ma = A[1];
    A[1] = A[H];
    H--;
    maxHeapify(A, 1);

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

    vector<ll> A(pow(10, 7));

    while (1) {
        string s;
        cin >> s;
        if (s == "end")
            break;
        else if (s == "insert") {
            int n;
            cin >> n;
            insert(A, n);
        } else if (s == "extract") {
            cout << heapExtractMax(A) << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 80852
// a/K b/K c/K の余りをA B Cとして A+B=K B+C=K C+A=K
// Kが奇数ならどれかが偶数になるから A=B=C=0
// Kが偶数なら A=B=C=0,K/2

using System;
using static System.Console;
using System.Linq;
public class Program{
    public static void Main(){
        string[] input = ReadLine().Split(' ');
        int n = int.Parse(input[0]);
        int k = int.Parse(input[1]);
        
        if(k%2==0){
            int a = n/(k/2);
            long b = a/2;
            long c = (a+1)/2;
            long x = b*b*b;
            long y = c*c*c;
            WriteLine(x+y);
        }else{
            long a = n/k;
            long x = a*a*a;
            WriteLine(x);
        }
    }
}

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

int main() {
  int n, a[205], ans = 0;
  cin >> n;
  n *= 2;
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a+n);
  for (int i = 0; i < n; i += 2) ans += a[i];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
// atoi : atoi(str.c_str())
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)

int main(){
  int n;
  cin >> n;
  long answer = 0;
  long tmp;
  rep(i,n){
    cin >> tmp;
    answer += tmp-1;
  }
  cout << answer << endl;
}


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

int main() {
  int k;
  cin >> k;
  int x = 7%k;
  for (int i = 1; i <= k; ++i) {
    if (x == 0) {
      cout << i << endl;
      return 0;
    }
    x = (x*10+7)%k;
  }
  cout << -1 << endl;
  return 0;
}



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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
typedef pair<int, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = 10e10;
const ll MINF = -10e10;
//const int INF = INT_MAX;
#define mins(x, y) x = min(x, y)
#define maxs(x, y) x = max(x, y)

typedef priority_queue<P, vector<P>, greater<P> > PQ_ASK;
const int mod = 1000000007;
//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
typedef tuple<int, int, int> Q;


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

    vector<ll> as(n);
    rep(i, n) {
        cin >> as[i];
        as[i] -= i;
    }

    sort(as.begin(), as.end());
    if (n % 2 == 0) {

        ll a1 = [&] {
            ll m = as[n / 2 - 1];

            ll now = 0;
            rep(i, n) {
                now += abs(as[i] - m);
            }
            return now;
        }();

        ll a2 = [&] {
            ll m = as[n / 2];

            ll now = 0;
            rep(i, n) {
                now += abs(as[i] - m);
            }
            return now;
        }();
        cout << min(a1, a2) << endl;
        return 0;
    }

    ll m = as[n / 2];

    ll now = 0;
    rep(i, n) {
        now += abs(as[i] - m);
    }
    cout << now << endl;
}




Measured memory_bytes: 1792
#include<iostream>
#include<math.h>
#include<vector>
#include<climits>
using namespace std;
int dp[100001][3]={0};
int find(int n,int arr[][3],int choosen)
{
  if(n==0) return 0;
  
  if(dp[n][choosen]!=0) return dp[n][choosen];
  int ans=INT_MIN;
  
  
  for(int i=0;i<3;++i)
  {
 	if(i!=choosen) ans=max(ans,arr[n][i]+find(n-1,arr,i));
  }
  dp[n][choosen]=ans;
  return dp[n][choosen];
}
int main()
{
  int n;
  cin>>n;
  int arr[n+1][3];
  for(int i=1;i<=n;++i)
  {
    cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
  }
  
  
  
  int ans=INT_MIN;
  for(int i=0;i<3;++i)
  {
      ans=max(ans,find(n,arr,i));
  }
  
  cout<<ans<<endl;
  return 0;
}

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

using namespace std;

const int mod = 1e9 + 7;
const int maxn = 1e5 + 10;
const int inf = 0x3f3f3f3f;
#define ll long long

int A[maxn], B[maxn], C[maxn];
long long ansb[maxn];
int numa[maxn], numb[maxn], numc[maxn];

bool cmp(int a, int b) {
    return a < b;
}

int main() {
    //freopen("input.txt", "r", stdin);
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> A[i];
    for (int i = 1; i <= n; i++)
        cin >> B[i];
    for (int i = 1; i <= n; i++)
        cin >> C[i];
    sort(A + 1, A + 1 + n, cmp);
    sort(B + 1, B + 1 + n, cmp);
    sort(C + 1, C + 1 + n, cmp);
    int cnta = 1, cntb = 1, cntc = 1;
    for (int i = 1; i <= n; i++) {
        if (A[i] != A[i - 1] || i == 1)
            A[cnta++] = A[i];
        else
            numa[cnta - 1]++;
        if (B[i] != B[i - 1] || i == 1)
            B[cntb++] = B[i];
        else
            numb[cntb - 1]++;
        if (C[i] != C[i - 1] || i == 1)
            C[cntc++] = C[i];
        else
            numc[cntc - 1]++;
    }
    for(int i=1;i<=n;i++){
        numa[i]+=numa[i-1]+1;
    }
    long long ans = 0;
    for (int i = 1; i < cntb; i++) {
        int l = 1, r = cnta - 1, mid;
        while (l <= r) {
            mid = (l + r) / 2;
            if (A[mid] < B[i]) l = mid + 1;
            else r = mid - 1;

        }

        while (A[mid] < B[i] && mid < cnta - 1) mid++;
        while (A[mid] >= B[i] && mid > 0) mid--;
        ansb[i] = 1ll * numa[mid];
    }
    for (int i = 1; i < cntb; i++) {
        ansb[i] = 0ll + ansb[i] * (numb[i] + 1) + ansb[i - 1];
    }
    for (int i = 1; i < cntc; i++) {
        int l = 1, r = cntb - 1, mid;
        while (l <= r) {
            mid = (l + r) / 2;
            if (B[mid] < C[i]) l = mid + 1;
            else r = mid - 1;
        }
        while (B[mid] < C[i] && mid < cntb - 1) mid++;
        while (B[mid] >= C[i] && mid > 0) mid--;
        ans += 1ll * ansb[mid] * (numc[i] + 1);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3328
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
using namespace std;

typedef long long ll;

int N, W;
int w[102];
int v[102];
int dp[102][100002];

int main() {
  while (cin >> N >> W) {
    for (int i = 0; i < N; i++) {
      cin >> w[i] >> v[i];
    }
    for (int i = 0; i <= N; i++) {
      for (int j = 0; j <= 100000; j++) {
        dp[i][j] = INT_MAX;
      }
    }
    dp[0][0] = 0;

    for (int i = 0; i < N; i++) {
      for (int j = 0; j <= 100000; j++) {
        if (dp[i][j] == INT_MAX) continue;
        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);

        int nw = dp[i][j] + w[i];
        int nj = j + v[i];

        if (nw > W) continue;

        dp[i + 1][nj] = min(dp[i + 1][nj], nw);
      }
    }

    int ans = 0;
    for (int j = 0; j <= 100000; j++) {
      if (dp[N][j] != INT_MAX) {
        ans = max(ans, j);
      }
    }
    cout << ans << endl;
  }
}


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

// typedef
// -----------------------------------------------------------------------------
typedef long long ll;
typedef long double ld;

// container util
// -----------------------------------------------------------------------------
#define ALL(c)  (c).begin(),(c).end()
#define SZ(c) ((ll)(c).size())
#define MAX(c) *max_element(ALL(c))
#define MIN(c) *min_element(ALL(c))
#define SORT(c) sort((c).begin(),(c).end())

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

// constant
// -----------------------------------------------------------------------------
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);

// debug
// -----------------------------------------------------------------------------
#define DUMP(x)  cerr << #x << " = " << (x) << endl


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    ll L, R; cin >> L >> R;
    ll ans = INF;
    FOR(i, L, min(R, L + 2019)) {
        FOR(j, i + 1, min(R + 1, i + 2019)) {
            ans = min(ans, ((i % 2019) * (j % 2019)) % 2019);
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int main()
{
	int n, m;
	double l[20], a[20], b[20];

	cin >> n >> m;

	rep(i, n) {
		cin >> l[i] >> a[i] >> b[i];
	}

	if (m == 1) {
		cout << 0 << endl;
	}
	else {
		double ans = 0;

		rep(i, (1 << n)) {
			int count = 0;

			rep(j, n) {
				if ((i >> j) % 2 == 1) {
					count++;
				}
			}

			if (count != m) {
				continue;
			}

			double distance = 0;

			rep(j, n) {
				if ((i >> j) % 2 == 1) {
					for (int k = j + 1; k < n; k++) {
						if ((i >> k) % 2 == 1) {
							distance += (l[j] - l[k])*(l[j] - l[k]) + (a[j] - a[k])*(a[j] - a[k]) + (b[j] - b[k])*(b[j] - b[k]);
						}
					}
				}
			}

			ans = max(ans, distance);
		}

		cout << fixed << ans << endl;
	}

	return 0;
}

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

void	call(int n) {
	for (int i = 1; i <= n; ++i) {
		int x = i;
		if (x % 3 == 0) {
			cout << " " << i;
			continue;
		}
		while (true) {
			if (x % 10 == 3) {
				cout << " " << i;
				break;
			}
			if (x == 0) break;
			x /= 10;
		}
	}
	cout << endl;
}

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



Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
#define PI 3.14159265358979

//const int64_t INF = 1LL << 60;
const int INF = 1 << 29;
//const int64_t MOD = 1000000007;
//const int64_t INF = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
//#define P pair<int, int>
typedef pair<int, int> P;

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    vector<vector<int>> x(N, vector<int>(N - 1, -1));
    vector<vector<int>> y(N, vector<int>(N - 1, -1));
    rep(i, 0, N){
        cin >> A.at(i);
        rep(j, 0, A.at(i)){
            cin >> x.at(i).at(j) >> y.at(i).at(j);
        }
    }
    int ans = 0;
    rep(tmp, 0, 1 << N){
        bitset<15> s(tmp);
        vector<int> TF(N + 1, -1);
        bool can = false;
        int count = 0;
        rep(i, 0, N){
            if(s.test(i))TF.at(i + 1) = 1;
            else TF.at(i + 1) = 0;
        }
        rep(i, 0, N){
            if(s.test(i)){
                rep(j, 0, A.at(i)){
                    if (y.at(i).at(j) == 1){
                        if (TF.at(x.at(i).at(j)) == 0){
                            can = true;
                            break;
                        }
                        else{
                            TF.at(x.at(i).at(j)) = 1;
                        }
                    }
                    if (y.at(i).at(j) == 0){
                        if (TF.at(x.at(i).at(j)) == 1){
                            can = true;
                            break;
                        }
                        else{
                            TF.at(x.at(i).at(j)) = 0;
                        }
                    }
                }
            }
        }
        rep(i, 1, N + 1){
            //cout << TF.at(i) << endl;
            if(TF.at(i) == 1){
                count++;
            }
        }
        if(can){
            count = 0;
        }
        //cout << s << " " << count << endl;
        ans = max(ans, count);
        //cout << endl;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
main() {
  int N,M; cin>>N>>M;                             // 入力を得る
  if(N>=M) { cout<<0<<endl; exit(0); }            // 全ての地点にコマを置ける
  vector<int> X(M); for(auto& x:X) cin>>x;        // 入力を得る
  sort(X.begin(), X.end());                       // 地点らを整列する
  vector<int> d;                                  // disdance; 地点同士の距離
  for(int i=1;i<M;++i) d.push_back(X[i]-X[i-1]);  // 条件より地点は重ならない
  sort(d.begin(), d.end());                       // 距離で整列する
  vector<int> s=d;                                // sum; 累積和
  for(int i=1;i<s.size();++i) s[i]+=s[i-1];       // 累積和を得る
  cout<< s[s.size()-N] <<endl;                    // コマの数だけ移動せずにすむ距離がある
}

Measured memory_bytes: 1528
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

int main(){
    ll X;
    cin>>X;
    ll ans=360/(__gcd(X,360LL));
    cout<<ans<<endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, M = 0;
  cin >> N;
  
  for (int i = 100000000; i > 0; i /= 10){
    M += N / i - N / (i * 10) * 10;
  }
  
  if (N % M == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

bool ignore;
int right;
int acute;
int obtuse;

int main() {
    while (1) {
        int es[3];
        int p, q;

        if (scanf("%d %d %d", &es[0], &es[1], &es[2]) == EOF) return 0;
        if (ignore) continue;

        sort(es, es+3);
        if (es[0]+es[1] <= es[2]) {
            ignore = true;
            printf("%d %d %d %d\n", right+acute+obtuse, right, acute, obtuse);
            continue;
        }

        p = es[0]*es[0] + es[1]*es[1];
        q = es[2]*es[2];
        if (p == q) right++;
        else if (p > q) acute++;
        else obtuse++;
    }
}

Measured memory_bytes: 1040