akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

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 ll = long long;

ll K;
ll dp[1010][10], sumdp[1010][10];
std::string ans;

void func( ll di, ll d, ll k )
{
  ll sum = 0;

  if( !di )
    return;

  repi( d2, d-1, d+2 )
  {
    if( d2 < 0 || d2 > 9 )
      continue;

    if( sum+dp[di][d2] >= k )
    {
      ans += d2+'0';
      func( di-1, d2, k-sum );

      return;
    }

    sum += dp[di][d2];

    //printf( "dp[%d][%d] = %lld\n", di-1, d2, dp[di][d2] );

    //std::cout << sum << std::endl;
  }
}

int main()
{
  rep( i, 1000 )
  {
    if( i ) rep( j, 2 )
      dp[i][0] += dp[i-1][j];

    rep( j, 10 )
    {
      if( !i )
      {
        dp[i+1][j] = 1;
      }
      else if( j )
      {
        if( j+1 <= 9 )
          dp[i+1][j] += dp[i][j+1];
        if( j-1 >= 0 )
          dp[i+1][j] += dp[i][j-1];

        dp[i+1][j] += dp[i][j];
      }
    }
  }

  rep( i, 11 )
  {
    sumdp[i][0] = sumdp[i-1][0]+sumdp[i-1][9];

    repi( j, 1, 10 )
      sumdp[i][j] = (j-1 ? sumdp[i][j-1] : 0)+dp[i][j];
  }

  //rep( i, 11 ) rep( j, 10 )
    //printf( "dp[%d][%d] = %lld\n", i, j, sumdp[i][j]+sumdp[i][0] );

  std::cin >> K;

  ll si, sj;

  for( int i = 10; i >= 0; --i )
  {
    ll sum = sumdp[i][0];

    if( K < sum )
      continue;

    repi( j, 1, 10 )
    {
      sum += sumdp[i][j];

      if( sum >= K && sumdp[i][0]+(j-1?sumdp[i][j-1]:0) < K )
      {
        si = i;
        ans += j+'0';
        sj = j;
        K -= sumdp[i][0]+(j-1?sumdp[i][j-1]:0);

        //std::cout << K << std::endl;
        //printf( "(%d,%d)\n", si, sj );

        goto end;
      }

      sum -= sumdp[i][j];
    }
  }

  end:;

  //std::cout << si << std::endl;

  func( si-1, sj, K );

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

  return 0;
}

Measured memory_bytes: 1016
#include <iostream>
using namespace std;
double f(int x);

int main(){
  int n;
  int sum;
  while(cin >> n){
    sum = 0;
    for (int i=0; i<600/n; i++){
      sum += f(i*n)*n;
    }
    cout << sum <<endl;
  } 
}

double f(int x){
  return x*x;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_set>
#include <string>
#include <random>
#include <queue>


using namespace std;

// ans = a ? b : c; // to simplify: if (a) ans = b; else ans = c;
// ans += val; // to simplify: ans = ans + val; and its variants
// index = (index + 1) % n; // index++; if (index >= n) index = 0;
// index = (index + n - 1) % n; // index--; if (index < 0) index = n - 1;
// int ans = (int)((double)d + 0.5); // for rounding to nearest integer
// ans = min(ans, new_computation); // min/max shortcut
// alternative form but not used in this book: ans <?= new_computation;
// some code use short circuit && (AND) and || (OR)

typedef long long ll; // comments that are mixed in with code
typedef pair<int, int> ii; // are aligned to the right like this
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
#define INF 1000000000
#define M_PI 3.14159265358979323846

void printVector2d(vector<vector<int>> a){
    for(int i=0;i<a.size();i++){
        for(int j=0;j<a[i].size();j++){
            cout<<a[i][j]<<" ";
        }
        cout<<endl;
    }
    cout<<"end"<<endl;
}

void printVector(vector<int> a){
    for(int i=0;i<a.size();i++){
        int curr_num = a[i]+1;
        cout<<curr_num<<" ";
    }
    cout<<endl;
}

void printVectorTwo(vector<int> a){
    for(int i=0;i<a.size();i++){
        int curr_num = a[i];
        cout<<curr_num<<" ";
    }
    cout<<endl;
}

void printVectorPair(vector<pair<int,int>> a){
    for(int i=0;i<a.size();i++){
        cout<<"Total "<<i<<": "<<a[i].first<<" "<<a[i].second<<endl;
    }
}

void printMap(map<char, int> mp){
    for(auto x:mp){
        cout<<x.first<<": "<<x.second<<endl;
    }
}

void printMapVec(map<int, vector<int>> mpV){
    for(auto x:mpV){
        cout<<x.first<<": ";
        for(auto y:x.second){
            cout<<y<<" ";
        }
        cout<<endl;
    }
}

void printQueue(queue<char> q){
    while(!q.empty()){
        cout<<q.front()<<" ";
        q.pop();
    }
    cout<<" ##### ";
}

void solve(){
    int X;
    cin>>X;
    if(X>=30)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}

int main() {
    //solve();
    int T;
//    cin >> T;
    T=1;
    for (int case_num = 1; case_num <= T; case_num++) {
//        cout<<"Case #"<<case_num<<": ";
        solve();
    }
    return 0;
}

Measured memory_bytes: 3092
def calcPattern(N, Y):
    for i in range(0, N+1):
        for j in range(0, N+1):
            if i == ((Y - 1000*N - 4000*j) / 9000):
                if (N-i-j) >= 0: return (str(i) + " " + str(j) + " " +str(N-i-j))
    return ("-1 -1 -1")
    
n,y = map(int, input().split())
print(calcPattern(n,y))

Measured memory_bytes: 9092
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>
#include <bits/stdc++.h>
using namespace std;

int main()
{
    string s,t,u="";
    cin>>s>>t;
    int n=s.length(),m=t.length(),i,j,k,l;
    int h[n+1][m+1];
    memset(h,0,sizeof(h));
    for(i=1;i<n+1;i++) {
        for(j=1;j<m+1;j++) {
            if(s[i-1]==t[j-1]) h[i][j]=h[i-1][j-1]+1;
            else h[i][j]=max(h[i-1][j],h[i][j-1]);
        }
    }
    
    for(i=n,j=m;i>0 && j>0;) {
        if(s[i-1]==t[j-1]) {
            u+=s[i-1];
            i--;
            j--;
        }
        else {
            if(h[i][j-1]>h[i-1][j]) j--;
            else i--;
        }
    }
    reverse(u.begin(),u.end());
    cout<<u<<endl;

    return 0;
}


Measured memory_bytes: 38760
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

struct UnionFind {
	vector<int> par;
	vector<int> rank;
	
	UnionFind() {}
	UnionFind(int n) {
		init(n);
	}
	
	int operator[] (int x) {
		return find(x);
	}

	void init(int n) {
		par.resize(n);
		rank.resize(n);
		REP(i, n) {
			par[i] = i;
			rank[i] = 0;
		}
	}

	int find(int x) {
		if (par[x] == x) return x;
		return par[x] = find(par[x]);
	}

	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y) return;

		if (rank[x] < rank[y]) {
			par[x] = y;
		} else {
			par[y] = x;
			if (rank[x] == rank[y]) rank[x]++;
		}
	}

	bool same(int x, int y) {
		return find(x) == find(y);
	}
};

int main() {
	int n, q;
	cin >> n >> q;
	
	UnionFind uf(n);
	
	// UnionFind??¨????????????
	for (int i = 0; i < q; i++) {
		int com, x, y;
		scanf("%d %d %d", &com, &x, &y);
		
		if (com == 0) { // unite
			uf.unite(x, y);
		}
		else { // same
			printf("%d\n", uf.same(x, y));
		}
	}
	return 0;
}

Measured memory_bytes: 3276
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N,ans = 300000;
  cin >> N;
  int E[N],W[N];
  char S[N];
  E[0] = 0;
  W[N - 1] = 0;
  for(int i = 0;i < N;i++)cin >> S[i];
  for(int i = 1;i < N;i++){
    if(S[i - 1] == 'W')E[i] = E[i - 1] + 1;
    else E[i] = E[i - 1];
  }
  for(int i = N - 2;i >= 0;i--){
    if(S[i + 1] == 'E')W[i] = W[i + 1] + 1;
    else W[i] = W[i + 1];
  }
  for(int i = 0; i < N;i++)ans = min(ans,(E[i] + W[i]));
  cout << ans;
}

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

namespace ConsoleApp23
{
    class Program
    {

        static void Main(string[] args)
        {
            // var line = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var s = Console.ReadLine().ToCharArray();
            var t = Console.ReadLine().ToCharArray();

            Array.Sort(s);
            Array.Sort(t);
            // Array.Reverse(s);
            Array.Reverse(t);

            var s2 = new string(s);
            var t2 = new string(t);

            if(s2.CompareTo(t2) < 0)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }

        }


    }

}


Measured memory_bytes: 13524
def jmp(h,k):
    n=len(h)
    dp=[1000000000 for i in range(n+1)]
    dp[0]=0
    dp[1]=abs(h[1]-h[0])
    for i in range(n+1):
        for j in range(i+1,i+k+1):
            if(j<n):
                dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]))
    # print(dp)
    return dp[n-1]
 
 
n,k=map(int,input().split())
l=list(map(int,input().split()))
print(jmp(l,k))

Measured memory_bytes: 90308
import sys

input = sys.stdin.readline
sys.setrecursionlimit(100000)
mod = 10 ** 9 + 7


def read_values():
    return map(int, input().split())


def read_index():
    return map(lambda x: int(x) - 1, input().split())


def read_list():
    return list(read_values())


def read_lists(N):
    return [read_list() for n in range(N)]


class V:
    def __init__(self, f, v=None):
        self.f = f
        self.v = v

    def __str__(self):
        return str(self.v)

    def ud(self, n):
        if n is None:
            return

        if self.v is None:
            self.v = n
            return
        self.v = self.f(self.v, n)


def main():
    N, K = read_values()
    dp = [
        [[0 for i in range(N ** 2 + 1)] for ii in range(N + 1)] for iii in range(N + 1)
    ]
    dp[0][0][0] = 1

    for i in range(1, N + 1):
        for j in range(N + 1):
            for k in range(K + 1):
                if k - 2 * j < 0:
                    continue

                dp[i][j][k] = (
                    (2 * j + 1) * dp[i - 1][j][k - 2 * j]
                    + (
                        (j + 1) * (j + 1) * dp[i - 1][j + 1][k - 2 * j]
                        if j + 1 <= N
                        else 0
                    )
                    + dp[i - 1][j - 1][k - 2 * j]
                ) % mod

    print(dp[N][0][K])


if __name__ == "__main__":
    main()


Measured memory_bytes: 95452
#include<iostream>

using namespace std;

int main(){
  string S;
  int ans= 0;
  
  cin >> S;
  
  if(S.length() % 2 ==1){
    cout << "No" << endl;
    return 0;
  }
  
  for(int i = 0; i < S.length()-1; i+=2){
    if(S[i] == 'h' && S[i+1] == 'i'){
      ans = 1;
    }else{
      ans = 2;
    }
    
    if(ans != 1){
      break;
    }
  }
  
  if(ans == 1){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<iostream>
#include<set>
#include<map>
using namespace std;
#define mp make_pair
#define ll long long
#define re register
typedef pair<int,int> pii;
#define file(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
inline int gi()
{
	int f=1,sum=0;char ch=getchar();
	while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return f*sum;
}
const int N=2010;
int n,K,tot,dep[N];
vector<int>G[N];
void dfs(int u,int ff)
{
	dep[u]=dep[ff]+1;
	if(dep[u]>K/2)tot++;
	for(int v:G[u])
	{
		if(v==ff)continue;
		dfs(v,u);
	}
}
int main()
{
	n=gi();K=gi();
	for(int i=1;i<n;i++)
	{
		int u=gi(),v=gi();
		G[u].push_back(v);G[v].push_back(u);
	}
	int ans=n;
	if(K&1)
		for(int u=1;u<=n;u++)
			for(int v:G[u])
			{
				tot=0;
				dep[u]=-1;dfs(v,u);
				dep[v]=-1;dfs(u,v);
				ans=min(ans,tot);
			}
	else
		for(int i=1;i<=n;i++)tot=0,dep[i]=-1,dfs(i,i),ans=min(ans,tot);
	printf("%d\n",ans);
	return 0;
}


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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    ll n, h; cin >> n >> h;

    vector<ll> a(n);
    vector<ll> b(n);
    for (ll i = 0; i < n; ++i) {
        cin >> a[i] >> b[i];
    }

    sort(a.rbegin(), a.rend());
    sort(b.rbegin(), b.rend());

    ll a_max = a[0];

    ll ans = 0;

    for (ll i = 0; i < n; ++i) {
        if (a_max < b[i]) {
            h -= b[i];
            ++ans;

            if (h <= 0) {
                break;
            }
        } else {
            break;
        }
    }

    if (h > 0) {
        if (h % a_max == 0) {
            ans += h / a_max;
        } else {
            ans += h / a_max + 1;
        }
    }

    cout << ans << endl;
}

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

#define NREP() for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define IPT(t, x) t ipt; cin >> ipt; x.push_back(ipt);
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
//ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;
string s;

int main() {
    ll n;
    cin >> n;
    vl a, b, c;
    ll ans = 0;

    NREP() {
        ll tmp;
        cin >> tmp;
        a.push_back(tmp);
    }

    NREP() {
        ll tmp;
        cin >> tmp;
        b.push_back(tmp);
    }

    REP(i, n - 1) {
        ll tmp;
        cin >> tmp;
        c.push_back(tmp);
    }

    ll prev = a.at(0);
    NREP() {
        ans += b.at(a.at(i) - 1);

        if (i != 0 && a.at(i) == prev + 1) {
            ans += c.at(prev - 1);
        }

        prev = a.at(i);
    }

    MSG(ans)
}


Measured memory_bytes: 256
n = int(input())
graph = [[] for _ in range(n)]
for i in range(n):
    in_list = list(map(int, input().split()))
    u = in_list[0]
    graph[u - 1] = in_list[2:]

d = [0 for _ in range(n)]
f = [0 for _ in range(n)]
time = 0

def dfs(now, prev, graph, d, f, time):
    if d[now] != 0:
        return d, f, time
    time += 1
    d[now] = time
    if not graph[now]:
        f[now] = time + 1
        time += 1
        return d, f, time
    for k in graph[now]:
        if k - 1 == prev or d[k-1] !=0:
            continue
        _, _, time = dfs(k - 1, now, graph, d, f, time)
    else:
        time += 1
        f[now] = time
    return d, f, time



for i in range(n):
    d, f, time = dfs(i, 0, graph, d, f, time)
    print(i+1, d[i], f[i])



Measured memory_bytes: 5728
#include <iostream>
#include <cstring>
#define MAX_N 10
#define MAX_S 10000
using namespace std;

int ans[MAX_N+1][MAX_S];
int used[10];

void calc(int n, int depth, int sum){
	if (n+1 == depth) {
		ans[n][sum]++;
	}else {
		for (int i = 0; i < 10; i++) {
			if (used[i] == 0) {
				used[i] = 1;
				calc(n,depth+1,i*depth+sum);
				used[i] = 0;
			}
		}
	}
}


int main(){
	int n, s;
	memset(ans, 0, sizeof(ans));
	// calc any answers for n, s in advance.
	for (int i = 0; i < 10; i++) {
		memset(used, 0, sizeof(used));
		calc(i+1, 1, 0);
	}
	while (cin >> n >> s) {
		cout << ans[n][s] << endl;
	}
	return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> two_power(3, 0);
    for(int i = 0; i < N; i++) {
        int a;
        cin >> a;
        if (a % 2 != 0) two_power[0]++;
        else if (a % 4 != 0) two_power[1]++;
        else two_power[2]++;
    }
    bool check = false;
    if (two_power[1] > 0 && two_power[0] <= two_power[2]) check = true;
    if (two_power[1] == 0 && two_power[0] <= two_power[2]+1) check = true;
    
    if (check) cout << "Yes\n";
    else cout << "No\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define mod 1000000007
using namespace std;
ll binpow(ll x,ll y)/* (x^y)%p in O(log y) */{ll res=1;while (y > 0){if(y&1)res=(res*x);y = y>>1;x=(x*x);}return res;}
ll binpowmod(ll x,ll y,ll p)/* (x^y)%p in O(log y) */{ull 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 mod_inverse(ll n,ll p)/* Returns n^(-1) mod p */{return binpowmod(n,p-2,p);}
int gcd(int x,int y)
{
    if(y==0)
        return x;
    return gcd(y,x%y);
}
bool comp(pair<int,int> x,pair<int,int> y)
{
    return x.first<y.first;
}
bool comp_pairs_by_s(pair<ll,ll> &x ,pair<ll,ll> &y)
{
    return x.second<y.second;
}
bool isPowerOfTwo (ll x)  
{  
    /* First x in the below expression is for the case when x is 0 */
    return x && (!(x&(x-1)));  
}

class cmp      //comparator for priority_queue 
{               //declaration: priority_queue<int,vector<int>,cmp>
public:         
    bool operator()(pair<int,int> A,pair<int,int> B)
    {
        if(abs(A.first-A.second)==abs(B.first-B.second))
            return A.first>B.first;
        return abs(A.first-A.second)<abs(B.first-B.second);
    }
};
int prime[1768457]={0};
void sieve(void)
{
 int i,j;
 for(i=0;i<1768457;i++)
        prime[i]=1;
 prime[0]=0,prime[1]=0;
 for(i=2;i<=sqrt(1768457);i++){
     if(prime[i]){
         for(j=i*i;j<1768457;j+=i){
             prime[j]=0;
         }
     }
 }
    
}
void swap(ll &x,ll &y){
    int temp=x;
    x=y;
    y=temp;
}
  
unsigned int onesComplement(unsigned int n) 
{ 
   // Find number of bits in the given integer 
   int number_of_bits = floor(log2(n))+1; 
  
   // XOR the given integer with poe(2,  
   // number_of_bits-1 and print the result  
   return ((1 << number_of_bits) - 1) ^ n; 
}


void solve()
{   
    ll n;
    cin>>n;
    map<ll,ll> m;
    ll sum=0;
    for(ll i=0;i<n;++i){
        ll x;
        cin>>x;
        m[x]++;
        sum+=x;
    }
    ll q;
    cin>>q;
    while(q--){
        ll b,c;
        cin>>b>>c;
        if(m.find(b)!=m.end() || m[b]!=0){
            int cnt=m[b];
            m[b]=0;
            m[c]+=cnt;
            sum=sum-cnt*b+cnt*c;
        }

        cout<<sum<<'\n';
    }

}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
}   


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


int main(){
    int N,M;
    //int p[100000];
    //string S[100];
    bool AC[100000];
    int wa[100000];
    cin >> N >> M;
    //for(int i=0; i<M; i++){
        //cin >> p[i] >> S[i];
    //}

    int ac = 0, wasum = 0;

    for(int k=0; k<N; k++){
        AC[k] = false;
        wa[k] = 0;
    }

    for(int j=0; j<M; j++){
        int p;
        string S;
        cin >> p >> S;
        if(!AC[p]){
            if(S == "AC"){
                ac++;
                AC[p] = true;
                wasum += wa[p];
            }
            else{
                wa[p]++;
            }
        }
    }

    cout << ac << " " << wasum;

    return 0;
}

Measured memory_bytes: 768
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
lint dp[3010][3010];
lint mo=998244353;
int a[3010];
int main()
{
	int n,s;cin>>n>>s;lint out=0;
	rep(i,n) cin>>a[i];
	memset(dp,0,sizeof(dp));
	rep(i,n) dp[i][0]=i+1;
	rep(i,n){
		//dp[i+1][0]=dp[i][0]+1;
		rep(j,s+1){
			//cout<<i<<' '<<j<<' '<<dp[i][j]<<endl;
			if(j>0) dp[i+1][j]+=dp[i][j];dp[i+1][j]%=mo;
			if(j+a[i]>s) continue;
			if(j+a[i]==s){
				out+=dp[i][j]*(n-i);out%=mo;
			}
			else{
				dp[i+1][j+a[i]]+=dp[i][j];
				dp[i+1][j+a[i]]%=mo;
			}
		}
	}
	cout<<out<<endl;
}


Measured memory_bytes: 71040
#include<bits/stdc++.h>
using namespace std;
int main(){
	vector<int> A(5);
	int count=0;
	for(int i=0;i<5;i++){
		cin>>A[i];
		count+=((A[i]+9)/10)*10;
		A[i]=(150-A[i])%10;
	}int k=*max_element(A.begin(),A.end());
	cout<<count-k<<endl;
}

Measured memory_bytes: 384
a,b = map(int,input().split())
if a*b<=0:
    print("Zero")
elif a>0:
    print("Positive")
else:
    mab = (abs(a)%2 - abs(b)%2)%2 
    if mab == 0:
        print("Negative")
    else:
        print("Positive")


Measured memory_bytes: 2940
using System;
using System.Collections.Generic;
using System.Linq;
class abc166_b{
  public static void Main(){
    String[] str = Console.ReadLine().Split(' ');
    int n = int.Parse(str[0]);
    int k = int.Parse(str[1]);
    int[] sunuke = new int[n];
    for(int i=0; i<k; i++){
      int d = int.Parse(Console.ReadLine());
      int[] man = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
      for(int j=0; j<man.Length; j++){
        sunuke[man[j]-1] += d;
      }
    }
    int count = 0;
    for(int i=0; i<n; i++){
      if(sunuke[i] == 0){
        count++;
      }
    }
    Console.WriteLine(count);
  }
}


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

int n, a, b, c;
const int mod = 1e9 + 7;
typedef long long ll;
ll expmod(ll a, ll b, ll mod) {
	ll rlt = 1;
	for (a %= mod; b; a = a * a % mod, b >>= 1) if (b & 1) rlt = rlt * a % mod;
	return rlt;
}

#define N 200020
int fac[N], rfac[N], ri[N];
void init() {
	fac[0] = 1;
	for (int i = 1; i < N; i ++) fac[i] = 1ll * fac[i-1] * i % mod;
	rfac[0] = rfac[1] = 1, ri[1] = 1;
   	for(int i = 2; i < N; i ++){
      		int t = mod / i;
      		ri[i] = (1ll * t * (mod - ri[mod % i])) % mod;
      		rfac[i] = (1ll * rfac[i-1] * ri[i]) % mod;
   	}
}

int func(int a, int b, int c) {
	int r = expmod(a + b, mod - 2, mod);
	int now = expmod(r, n + 1, mod);
	int sum = 0;
	for (int i = 0; i < n; i ++) {
		sum = (sum + 1ll * fac[n+i] * rfac[i] % mod * now) % mod;
		now = 1ll * now * b % mod * r % mod;
	}
	return 1ll * sum * expmod(a, n, mod) % mod * rfac[n-1] % mod;
}

int main() {
	init();
	scanf("%d%d%d%d", &n, &a, &b, &c);
	int q = expmod(100, mod - 2, mod);
	a = 1ll * a * q % mod;
	b = 1ll * b * q % mod;
	c = 1ll * c * q % mod;
	printf("%d\n", (func(a, b, c) + func(b, a, c)) % mod);
	return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <utility>
#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()
#define inf 100000007
using namespace std;

int main(){
	string s[2];
	cin >> s[0]; cin >> s[1];
	
	int dp[s[0].length()+1][s[1].length()+1] = {};
	rep(i,0,s[1].length()+1) dp[0][i] = i;
	rep(i,0,s[0].length()+1) dp[i][0] = i;
	rep(i,1,s[0].length()+1){
		rep(j,1,s[1].length()+1){
			dp[i][j] = inf;
		}
	}
	
	rep(i,1,s[0].length()+1){
		rep(j,1,s[1].length()+1){
			dp[i][j] = min({dp[i][j],dp[i-1][j]+1,dp[i][j-1]+1,dp[i-1][j-1]+(s[0][i-1]!=s[1][j-1])});
		}
	}
	cout << dp[s[0].length()][s[1].length()] << endl;

}



Measured memory_bytes: 7136
import math

D = int(input())
c = list(map(int, input().split()))
S = []
for i in range(D):
    S.append(list(map(int, input().split())))

nocontest = [1 for i in range(26)]

for i in range(D):
    s = S[i]
    contest = [0 for j in range(26)]
    for j in range(26):
        contest[j] = c[j] * nocontest[j] * s[j]
    #print(contest)
    max_contest = max(contest)
    ans = contest.index(max_contest)
    print(ans + 1)
    
    for j in range(26):
        if j == ans:
            nocontest[j] = 1
        else:
            nocontest[j] += 100
    #print(nocontest)

Measured memory_bytes: 9516
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll N;
std::string S;
ll dp[5010][5010];
ll ans;

int main()
{
  std::cin >> N >> S;

  repd( i, N ) for( ll j = N; j > i; --j ) {
    if( S[i] == S[j] )
      dp[i][j] = dp[i+1][j+1]+1;
    
    chmax( ans, std::min( dp[i][j], j-i ) );
  }
  
  std::cout << ans << std::endl;

  return 0;
}

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

using namespace std;
using llong = long long;
using P = pair<llong, llong>;

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	int w,h,n;
	cin >> w >> h >> n;
	vector<vector<int> > area(102,vector<int>(102,1));

	int x,y,a;
	for(int i = 0; i < n; i++){
		cin >> x >> y >> a;
		if(a == 1){
			for(int i = 0; i <= h; i++)
				for(int j = 0; j < x; j++)
					area[i][j] = 0;
		}else if(a == 2){
			for(int i = 0; i <= h; i++)
				for(int j = x+1; j <= w; j++)
					area[i][j] = 0;
		}else if(a == 3){
			for(int i = 0; i < y; i++)
				for(int j = 0; j <= w; j++)
					area[i][j] = 0;
		}else{
			for(int i = y+1; i <= h; i++)
				for(int j = 0; j <= w; j++)
					area[i][j] = 0;
		}
	}

	int ans = 0;
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			cerr << area[i][j];
			if(area[i][j] == 1 && area[i+1][j+1] == 1)
				ans++;
		}
		cerr << endl;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());
#define PAU system("pause")

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector <int> > vvi;
const int EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 30);
const double PI = acos(-1);

typedef pair<int, int> P;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int D, G;
	cin >> D >> G;
	vi P(D), C(D);
	REP(i, D)cin >> P[i] >> C[i];
	int ans = INT_MAX;
	REP(i, (1 << D)) {//ビットマスク
		int score = 0;
		int cnt = 0;
		REP(j, D) {
			if ((i & (1 << j)) != 0) {
				score += (j + 1) * 100 * P[j] + C[j];
				cnt += P[j];
			}
		}
		if (score >= G) {
			ans = min(ans, cnt);
			continue;
		}
		REPR(j, D) {
			int ii = i & (1 << j);
			if ((i & (1 << j)) == 0) {
				int ind = 0;
				while (score < G && ind < P[j]) {
					score += (j + 1) * 100;
					cnt++; ind++;
				}
			}
		}
		if (score >= G) {
			ans = min(ans, cnt);
		}
	}
	cout << ans << endl;
	PAU;
	return 0;
}


Measured memory_bytes: 504
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cstdio>
#include<queue>
#include<cmath>
using namespace std;
const int INF=1e9;
#define ll long long
const int MAX=1e5;

vector<vector<int> > G(MAX);
vector<int> d(MAX,-1); 
int main(){
    int n,m;cin>>n>>m;
    int a,b;
    for(int i=0;i<m;i++){
        cin>>a>>b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    d[0]=0;
    queue<int> que;
    que.push(0);
    while(!que.empty()){
        int s=que.front();que.pop();
        for(int j=0;j<(int)G[s].size();j++){
            int t=G[s][j];
            if(d[t]!=-1) continue;
            d[t]=s;
            que.push(t);
        }
    }
    bool flag=true;
    for(int i=1;i<n;i++){
        if(d[i]==-1){
            flag=false;
            break;
        }
    }
    if(!flag){
        cout<<"No"<<endl;
        return 0;
    }
    cout<<"Yes"<<endl;
    for(int i=1;i<n;i++){
        cout<<d[i]+1<<endl;
    }
    return 0;
} 

Measured memory_bytes: 10332
import java.io.PrintWriter
val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val s = next()
    val k = nextLong()

    // aaaaaaaa... => a_a_a_a_ or a_a_a_a
    if (s.length == 1 || s.toList().distinct().size == 1) {
        println((s.length * k) / 2L)
        return
    }

    var changed = false
    var count = 0L

    for (i in 1 until s.length) {
        if (changed) {
            changed = false
            continue
        }
        if (s[i] == s[i-1]) {
            count++
            changed = true
        }
    }

    if (k == 1L) {
        println(count)
        return
    }

    // not continuous
    // 1) first and last letters are not the same
    // abbbc => ab_bc|ab_bc|... == count * k
    if (s.first() != s.last()) {
        println(count * k)
        return
    }

    val firstLetter = s.first()
    val lastLetter = s.last()
    val startCount = s.takeWhile { it == firstLetter }.length
    val endCount = s.takeLastWhile { it == lastLetter }.length

    // 2) even numbers of the same letter at the end
    // abbbaa => ab_ba_|ab_ba_|...
    // == count * k
    if (endCount % 2 == 0) {
        println(count * k)
        return
    }

    // continuous
    // 3) even numbers of the same letter at the beginning && odd numbers of the same letter at the end
    // aabbbaaa => a_b_ba_a|_ab_ba_a|_ab_ba_a|...
    // == count * k
    if (startCount % 2 == 0 && endCount % 2 == 1) {
        println(count * k)
        return
    }

    // 4) odd numbers of the same letter at the beginning && odd numbers of the same letter at the end
    // abbbaaa => ab_ba_a|_b_ba_a|_b_ba_a|...
    // (count + 1) * k - 1
    if (startCount % 2 == 1 && endCount % 2 == 1) {
        println((count + 1) * k - 1)
        return
    }
}

fun next() = readLine()!!
fun nextLong() = next().toLong()

fun println(value : Any) {
    pw.println(value)
}


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

typedef long long ll; // -9,223,372,036,854,775,808 から 9,223,372,036,854,775,807

template <class T> using vec = std::vector<T>;
template <class T> using vec2 = vec<vec<T>>;
template <class T> using vec3 = vec<vec<vec<T>>>;

#define DEBUG

vec2<ll> solve(int n, ll k){
    // 2n = k(k-1)
    if(n == 1){
        vec2<ll> res(2, vec<ll>{1});
        return res;
    }

    vec2<ll> minRes = solve((k-1)*(k-2)/2, k-1);
    vec2<ll> res(k, vec<ll>(k-1, 0));

    // 最初の行は1-kまで
    for(int i=1; i <= k-1; i++){
        res.at(0).at(i-1) = i;
    }

    // あとの行はiと、minResをkシフトしたもの
    for(int i=1; i < k; i++){
        // 1-kの値
        res.at(i).at(0) = i;
        // kシフト
        for(int j=0; j < k-2; j++){
            res.at(i).at(1+j) = minRes.at(i-1).at(j) + k - 1;
        }
    }

    return res;

}

ll isKK1(int n){
    ll k = 1;
    while(k*(k-1) <= 2*n){
        if(k*(k-1) == 2*n){
            return k;
        }
        k++;
    }
    return -1;
}

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

    auto resKK = isKK1(N);
    if(resKK == -1){
        cout << "No" << endl;
        return 0;
    }

    vec2<ll> res = solve(N, resKK);
    cout << "Yes" << endl;
    auto k = resKK;
    printf("%d\n", k);
    for(int i=0; i < k; i++){
        printf("%d ", k-1);
        for(int j=0; j < k-1; j++){
            printf("%d", res.at(i).at(j));
            if(j == k - 2){
                printf("\n");
            }else{
                printf(" ");
            }
        }
    }
    // cout << res.size() << endl;
    // for(auto iter: res){
    //     cout << iter.size() << " ";
    //     for(int i=0; i < iter.size(); i++){
    //         cout << iter[i];
    //         if(i == iter.size() - 1){
    //             cout << endl;
    //         }else{
    //             cout << " ";
    //         }
    //     }
    // }
    // cout << "hoge" << endl;
    
    return 0;
}

Measured memory_bytes: 4736
#include<bits/stdc++.h>
//One implementation to rule them all?
#define db              double
#define ll              long long int
#define ld              long long double
//#define int           long long int
#define ull             unsigned long long
#define fi              first
#define se              second
#define rep(i,a,n)      for(int i=a;i<n;i++)
#define repr(i,n,b)     for(int i=n;i>=b;i--)
#define endl            '\n'
#define mem(a,b)        memset(a, b, sizeof a)
#define mkp             make_pair
#define pb              push_back
#define max3(a,b,c)     max(a,max(b,c))
#define min3(a,b,c)     min(a,min(b,c))
#define w(t)            int t; cin>>t; while(t--)
#define all(a)          a.begin(), a.end()
#define sz(a)           int((a).size())
#define dbg(x)          cerr << #x << " = " << x << endl;
//Bitwise 
#define isOn(S, j)      (S & (1<<j))
#define setBit(S, j)    (S |= (1<<j))
#define clearBit(S, j)  (S &= ~(1<<j))
#define toggleBit(S, j) (S ^= (1<<j))
#define lowBit(S)       (S & (-S))
#define setAll(S, n)    (S = (1<<n)-1)
#define turnOffLastBit(S) ((S) & (S-1))
#define turnOnLastZero(S) ((S) | (S+1))
//Can use tuples in C++17
using namespace std;
typedef map < int, int > mii;
typedef vector < int > vii;
typedef vector < ll > vll;
typedef vector < vii > vvi;
typedef pair < int,int > pii;
template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
const db PI = 2*acos(0.0);
const int INF = 0x3f3f3f3f;
const ll LINF = (ll)2e18;
db eps       =          0.000001;
ll mod       =          998244353;   //(1e9+7)
void print(vector <int> &arr){
    for(int i=0;i<arr.size();i++)
        cout<<arr[i]<<" ";
    
    cout<<endl;
}
void printll(vector <ll> &arr){
    for(int i=0;i<arr.size();i++)
        cout<<arr[i]<<" ";
    
    cout<<endl;
}

ll ncr(ll n, ll r)
{
    r=min(r,n-r);
    ll A[r],i,j,B[r];
    iota(A,A+r,n-r+1);  
    iota(B,B+r,1);     

    ll g;
    for(i=0;i<r;i++)
    for(j=0;j<r;j++)
    {
        if(B[i]==1)
            break;
        g=__gcd(B[i], A[j] );
        A[j]/=g;
        B[i]/=g;
    }
    ll ans=1;
    for(i=0;i<r;i++)
        ans=(ans*A[i]%mod);
    return ans;
}
const int SIZE=2000008;
bool judge(int a[], int n){
    static int used[SIZE+1];
    for(int i = 1; i <= n; i++) used[i] = 0;
    for(int i = 0; i < n; i++) used[a[i]] = 1;
    for(int i = 1; i <= n; i++) {
        if(!used[i]) return 0;
    }
    return 1;
}

int main(){ 
//CONDITION && cout << "YES" || cout << "NO"; cout << '\n';
//////////////////////////////////////////////////////////////////////
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cerr.tie(NULL);
//For fast IO
///////////////////////////////////////////////////////////////////// 
//  std::cout.unsetf ( std::ios::floatfield );  // floatfield not set
//  std::cout.precision(10);
//  freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
		ll n;
		cin>>n;
		n--;
		string ans;
		while(n>=0)
		{
			ans+=((ll)'a'+(n%26));
			n/=26;
			n--;
		}
		reverse(all(ans));
		cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define lcm hddalkwjeidjjhasda
#define random_shuffle asdasdd

const int MAXN = 105000;

int n, m;
int cnt[MAXN];

int main() { 

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

  for (int i = 1; i <= n; i++) {
    if (cnt[i] & 1) {
      puts("NO");
      return 0;
    }
  }

  puts("YES");

  return 0;
}


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

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

    int a[n];
    vector<int> v(1000001, 0);
    int ones = 0;

    for(int i=0; i<n; i++)
    {
        cin >> a[i];
        v[a[i]]++;
        if(a[i] == 1)
        {
            ones++;
        }
    }
    if(ones > 1)
    {
        cout << 0 << endl;
        return ;
    }
    if(ones == 1)
    {
        cout << 1 << endl;
        return ;
    }
    sort(a, a+n);
    int ans = 0;
    for(int x :a)
    {
        if(v[x] == 1)
        {
            ans++;
        }

        for(int i = x; i<1000001; i+=x)
        {
            v[i]++;
        }
    }
    cout << ans << endl;
}


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


Measured memory_bytes: 7876
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <limits>
#include <numeric>

using namespace std;
typedef long long int ll;
typedef long double ld;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }                   // 最大公約数
ll lcm(ll a, ll b) { return a * b / gcd(a, b); };                      // 最小公倍数
ll getDigit(ll num) { return log10(num) + 1; }                         // 桁数
ll digitSum(ll n) { return (n < 10) ? n : digitSum(n / 10) + n % 10; } // 各桁の和
#define MOD 1e9 + 7
#define pb push_back
#define rep(i, n) for (ll i = 0; i < n; i++)
#define repn(i, n) for (ll i = 1; i <= n; i++)
#define repi(i, a, b) for (ll i = ll(a); i < ll(b); ++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265359

template <typename T>
void printVector(string name, vector<T> vec)
{
    cout << name << ": ";
    rep(i, vec.size())
    {
        cout << vec[i] << " ";
    }
    cout << endl;
}

void Main()
{
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i, n) cin >> p[i];
    int max = *max_element(all(p));
    int sum = accumulate(all(p), 0);
    int ans = sum - max / 2;
    cout << ans << endl;
    return;
}

signed main(void)
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
s = input()
n = len(s)
s_re =s[::-1]
s_first = s[:(n-1)//2]
s_first_re = s_first[::-1]
s_second = s[(n+3)//2-1:]
s_second_re = s_second[::-1]

print(['No','Yes'][s == s_re and s_first==s_first_re and s_second == s_second_re])

Measured memory_bytes: 9040
/*input
2
ip cc
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define eb emplace_back
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define EL cout<<'\n'
#define BS(a,x) binary_search(ALL(a),x)
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
template<typename T>
ostream& operator<<(ostream& out,vector<T> V){
	REP(i,SZ(V)) out<<V[i]<<((i!=SZ(V)-1)?" ":"");
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=20;
const ll INF64=1e18;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}


int main(){
	IOS;
	int a,b,c;
	cin>>a>>b>>c;
	cout<<max(0,b+c-a);
	return 0;
}


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

typedef long long ll;

#define rep(i,n) for(ll i=0; i<n; i++)
const ll INF = 100100100100100100;

int main() {
    ll R, C, K; cin >> R >> C >> K;
    vector<vector<vector<ll>>> dp(R+5, vector<vector<ll>>(C+5, vector<ll>(5, -1)));
    // ll dp[3005][3005][5];
    vector<vector<ll>> item(R+5, vector<ll>(C+5, 0));

    rep(i, R+1) {
        rep(j, C+1) {
            rep(k, 5) dp[i][j][k] = -1;
        }
    }
    rep(i, K) {
        ll r, c, v; cin >> r >> c >> v;
        r--; c--;
        item[r][c] = v;
    }
    dp[0][0][0] = 0;
    dp[0][0][1] = item[0][0];

    rep(i, R) {
        rep(j, C) {
            rep(k, 4) {
                if(dp[i][j+1][k] < dp[i][j][k]) dp[i][j+1][k] = dp[i][j][k];
                if(dp[i][j+1][k+1] < dp[i][j][k]+item[i][j+1]) dp[i][j+1][k+1] = dp[i][j][k]+item[i][j+1];
                ll tmp = -1*INF;
                rep(l, 4) if(tmp < dp[i][j][l]) tmp = dp[i][j][l];
                dp[i+1][j][0] = tmp;
                dp[i+1][j][1] = tmp+item[i+1][j];          
            }
        }
    }    

    ll ans = -1;
    rep(i, 4) if(ans < dp[R-1][C-1][i]) ans = dp[R-1][C-1][i];

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 708800
import java.util.*;
public class Main {
    public static void main(String[] args){
	Scanner buf = new Scanner(System.in);
	int n;
	int[] data = new int[3];
	n = buf.nextInt();
	while(n != 0){
	    data[0] = buf.nextInt();
	    data[1] = buf.nextInt();
	    data[2] = buf.nextInt();
	    Arrays.sort(data);
	    if((data[0]*data[0]) + (data[1]*data[1]) == (data[2]*data[2])) System.out.println("YES");
	    else System.out.println("NO");
	    n--;
	}
    }
} 

Measured memory_bytes: 23380
/* monkukui 競技プログラミング用のテンプレート  (ここから) */
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
using ll = long long int;
using lnt = long long int;
using graph = vector<vector<long long int>>;
using wgraph = vector<vector<pair<long long int, long long int>>>;
long long int INF = 1001001001001001LL;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;
long long int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
long long int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
inline void yes(){ cout << "yes" << endl; }
inline void Yes(){ cout << "Yes" << endl; }
inline void YES(){ cout << "YES" << endl; }
inline void no(){ cout << "no" << endl; }
inline void No(){ cout << "No" << endl; }
inline void NO(){ cout << "NO" << endl; }
inline void possible(){ cout << "possible" << endl; }
inline void Possible(){ cout << "Possible" << endl; }
inline void POSSIBLE(){ cout << "POSSIBLE" << endl; }
inline void impossible(){ cout << "impossible" << endl; }
inline void Impossible(){ cout << "Impossible" << endl; }
inline void IMPOSSIBLE(){ cout << "IMPOSSIBLE" << endl; }

#define rep(i,n) for(long long int i = 0; i < (n); i++)
#define rrep(i,n) for(long long int i = 1; i <= (n); i++)
#define drep(i,n) for(long long int i = (n)-1; i >= 0; i--)
#define srep(i,s,t) for(long long int i = s; i < t; i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back

/* monkukui 競技プログラミング用のテンプレート (ここまで)*/

int main(){
   
  int n; cin >> n;
  vector<int> b(n);
  rep(i, n - 1) cin >> b[i];
  int ans = b[0] + b[n - 2];
  rep(i, n - 2) ans += min(b[i], b[i + 1]);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 888
#include <stdio.h>

int main(void)
{
  int n, lcm, gcd;

  scanf("%d", &n);

  if (n % 2 == 0) {
    lcm = 2;
  } else {
    lcm = 1;
  }

  gcd = 2 * n / lcm;
  printf("%d\n", gcd);
  return 0;
}

Measured memory_bytes: 128
// ABC 049 C - Daydream
package main

import (
    "fmt"
    "strings"
)

func main() {

    var s string
    fmt.Scan(&s)

    s = reverse(s)
    s = strings.Replace(s, "resare", "", -1)
    s = strings.Replace(s, "esare", "", -1)
    s = strings.Replace(s, "remaerd", "", -1)
    s = strings.Replace(s, "maerd", "", -1)

    var res string
    if len(s) == 0 {
        res = "YES"
    } else {
        res = "NO"
    }
    fmt.Println(res)
}

func reverse(s string) string {
    bs := []byte(s)
    for i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 {
        bs[i], bs[j] = bs[j], bs[i]
    }
    return string(bs)
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
 
using namespace std;
 
typedef long long int ll;
#define pb push_back
#define mp make_pair

ll a[1001],dp[2][100002];

int main(){
	int n,i,j,k;
	ll m = 1000000007;
	scanf("%d%d",&n,&k);
	for(i=1;i<=n;i++)
		scanf("%lld",&a[i]);
	for(i=0;i<=k;i++)
		dp[0][i]=0;
	for(i=0;i<=n;i++)
		dp[i%2][0]=1;
	for(i=1;i<=n;i++){
		for(j=1;j<=k;j++){
			dp[i%2][j]=dp[(i-1)%2][j] + dp[i%2][j-1];
			dp[i%2][j]=dp[i%2][j]%m;
			if(j>a[i]){
				dp[i%2][j] -= dp[(i-1)%2][j-a[i]-1];
				if(dp[i%2][j]<m)
					dp[i%2][j]+=m;
			}
			dp[i%2][j]=dp[i%2][j]%m;
		}
	}

	printf("%lld\n",dp[n%2][k] );
	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;
int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }
int sub(int a, int b) { return (a -= b) < 0 ? a + mod : a; }

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  #ifdef LOCAL
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  #endif

  int q;
  cin >> q;
  set <string> st;
  while(q--){
    string s;
    cin >> s;
    st.insert(s);
  }
  cout << st.size();
}

Measured memory_bytes: 19276