akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;
import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve(args);
    }

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();
        int N = scanner.nextInt();
        int M = scanner.nextInt();
        HashMap<Integer, List<Integer>> map = new HashMap<Integer, List<Integer>>();
        for (int i = 0; i < M; i++) {
            int a = scanner.nextInt();
            int b = scanner.nextInt();
            List<Integer> list = map.get(a);
            if (list == null) {
                list = new ArrayList<Integer>();
                map.put(a, list);
            }
            list.add(b);
        }
        List<Integer> list = map.get(1);
        if (list == null) {
            System.out.println("IMPOSSIBLE");
        } else {
            for (int c: list) {
                List<Integer> list2 = map.get(c);
                if (list2 != null) {
                    for (int d: list2) {
                        if (d == N) {
                            System.out.println("POSSIBLE");
                            return;
                        }
                    }
                }
            }
            System.out.println("IMPOSSIBLE");
        }
    }

    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";

        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public String next() {
            try {
                if (i < s.length) return s[i++];
                String line = br.readLine();
                while (line.equals("")) {
                    line = br.readLine();
                }
                s = line.split(reg, 0);
                i = 0;
                return s[i++];
            } catch (Exception e) {
                e.printStackTrace();
            }
            return null;
        }

        public int nextInt() {
            try {
                return Integer.parseInt(next());
            } catch (Exception e) {
                e.printStackTrace();
            }
            return -1;
        }

        public double nextDouble() {
            try {
                return Double.parseDouble(next());
            } catch (Exception e) {
                e.printStackTrace();
            }
            return -1;
        }

        public long nextLong()  {
            try {
                return Long.parseLong(next());
            } catch (Exception e) {
                e.printStackTrace();
            }
            return -1;
        }
    }
}


Measured memory_bytes: 73728
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<50;
const double pi=acos(-1);
const double eps=1e-8;
const vi emp;

int n,ans=0;
string s;

int main(){
	cin>>s>>n;
	for(int i=0;i<n;i++){
		string t;
		cin>>t;
		int T=t.size();
		t+=t.substr(0,s.size()-1);
		bool flag=0;
		for(int i=0;i<T;i++) if(s==t.substr(i,s.size())) flag=1;
		if(flag) ans++;
	}
	cout<<ans<<endl;
}

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


int main()
{
	ll N;
	cin>>N;
	ll mn=1e15+1;
	rep(i,5)
	{
		ll v;
		cin>>v;
		mn=min(mn,v);
	}
	cout<<4+(N+mn-1)/mn<<endl;
	return 0;
}


Measured memory_bytes: 3596
#include<algorithm>
#include<cmath>
#include<functional> //sortのgreater
#include<iostream>
#include<numeric> //iota(整数列の生成),gcdとlcm(c++17)
#include<string> //文字列
#include<vector>

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

using namespace std;
typedef long long ll;

int main()
{
    // Input
    string in, after;
    cin >> in;
    cin >> after;

    if (in == after.substr(0, after.length() - 1)) {
        cout << "Yes";
    } else {
        cout << "No";
    }

    return 0;
}


Measured memory_bytes: 3036
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input! {
        s: String,
    }
    let ans = match &s[..] {
        "SUN" => 7,
        "MON" => 6,
        "TUE" => 5,
        "WED" => 4,
        "THU" => 3,
        "FRI" => 2,
        "SAT" => 1,
        _ => 0,
    };
    println!("{}", ans)
}


Measured memory_bytes: 4352
import copy

N, C= map(int,input().split())
XV = sorted([list(map(int,input().split())) for _ in range(N)])
acmXV = []
dbl_acmXV = []

for i, xv in enumerate(XV):
  x,v = xv
  if i == 0:
    acmXV.append(v-x)
    dbl_acmXV.append(v-x*2)
  else:
    acmXV.append(v-(x-XV[i-1][0])+acmXV[i-1])
    dbl_acmXV.append(v-(x-XV[i-1][0])*2+dbl_acmXV[i-1])

acmXV_rev = [0 for _ in range(N)]
dbl_acmXV_rev = [0 for _ in range(N)]
for i in range(N-1, -1, -1):
  x,v = XV[i]
  if i == N-1:
    acmXV_rev[i] = v-(C-x)
    dbl_acmXV_rev[i] = v-(C-x)*2
  else:
    acmXV_rev[i] = (v-(XV[i+1][0]-XV[i][0])+acmXV_rev[i+1])
    dbl_acmXV_rev[i] = (v-(XV[i+1][0]-XV[i][0])*2+dbl_acmXV_rev[i+1])


max_acmXV_rev = copy.deepcopy(acmXV_rev)
max_dbl_acmXV_rev = copy.deepcopy(dbl_acmXV_rev)
for i in range(N-2,-1,-1):
  max_acmXV_rev[i] = max(max_acmXV_rev[i], max_acmXV_rev[i+1])
  max_dbl_acmXV_rev[i] = max(max_dbl_acmXV_rev[i],max_dbl_acmXV_rev[i+1])

ans = max(0,max(acmXV),max(acmXV_rev))
for i in range(N-1):
  ans = max(ans, dbl_acmXV[i]+max_acmXV_rev[i+1], acmXV[i]+max_dbl_acmXV_rev[i+1]) 
print(ans)

Measured memory_bytes: 123992
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
	return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

class Program
{
    public static void Main()
    {
	var tmp = ReadIntArray();
	int h = tmp[0], w = tmp[1];

	const int M = 'z' - 'a' + 1;
	int[] ct = new int[M];
	
	for (int i = 0; i < h; i++)
	{
	    string s = ReadLine();
	    for (int j = 0; j < s.Length; j++)
	    {
		char c = s[j];
		ct[c-'a']++;
	    }
	}

	int x = w / 2;
	int y = h / 2;

	for (int i = 0; i < x*y; i++)
	{
	    bool found = false;
	    for (int j = 0; j < M; j++)
	    {
		if (ct[j] >= 4)
		{
		    ct[j] -= 4;
		    found = true;
		    break;
		}
	    }
	    if (!found)
	    {
		WriteLine("No");
		return;
	    }
	}

	int z = 0;
	if ((w&1) == 1) z += y;
	if ((h&1) == 1) z += x;

	for (int i = 0; i < z; i++)
	{
	    bool found = false;
	    for (int j = 0; j < M; j++)
	    {
		if (ct[j] >= 2)
		{
		    ct[j] -= 2;
		    found = true;
		    break;
		}
	    }
	    if (!found)
	    {
		WriteLine("No");
		return;
	    }
	}

	WriteLine("Yes");
    }
}


Measured memory_bytes: 13396
N, Q = map(int, input().split())
S=input()

t=[0]*(N+1)

# iはSのインデックス。i,i+1がACならtのi+1に。
for i in range(N):
    t[i+1]=t[i] + (1 if S[i:i+2]=='AC' else 0)

for i in range(Q):
    l, r = map(int, input().split())
    print(t[r-1]-t[l-1])

Measured memory_bytes: 7748
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#ifndef debug_on
#define debug_on 0
#endif

#define dbg \
    if(debug_on) cerr << "DEBUG:"
#define ast(cond)           \
    do {                    \
        if((cond) == false) \
        {                   \
            if(debug_on)    \
            cerr << "ASSERT" << #cond " failed at line:" << __LINE__ << endl;   \
            exit(1);        \
        }                   \
    }while(0)

int main(int, char *[])
{
    int A, B, C;
    uint64_t K;
    cin >> A >> B >> C >> K;

    int diff = A - B;
    if(K % 2)
        diff = -diff;

    cout << diff << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
const long long INF = 1ll << 60;

int main() {
  int N;
  cin >> N;
  vector<pair<pair<string, int>, int>> p(N);
  rep(i,N){
    string S;
    int P;
    cin >> S >> P;
    p[i] = make_pair(make_pair(S, -P), i+1);
  }
  sort(p.begin(), p.end());
  rep(i,N) cout << p[i].second << endl; 
  return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,x,n) for(ll i=x;i<n;i++) 
#define S(v) sort(v.begin(),v.end());


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n, curr = 1000;
    cin>>n;
    vector<ll> v(n);
    loop(i,0,n)cin>>v[i];
    ll i = 0;
    while(i<n){
        ll stocks = curr/v[i], j = i+1;
        while(v[j] >= v[j-1] &&  j<n){
            j++;
        }
        curr =curr -  stocks*v[i]  + v[j-1] *stocks;
        i = j;
        // cout<<j<<" ";
    }
    cout<<curr<<endl;

    
    

}

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

typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll,ll> lll;

const ll MOD = 1000000007;
const ll INF = 1e9+5;
const double eps = 1e-7;
const double PI = acos(-1.0);

#define FOR(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define RFOR(i,a,b) for(long long i = (long long)(a); i >= (long long)(b); i--)
#define ull unsigned long long
#define deb(x )     cerr << #x << " = "<< x << endl;
#define endl    "\n"
#define coud(a,d) cout << fixed << showpoint << setprecision(d) << a;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define fill(x, y) memset(x, y, sizeof(y))
#define all(x) (x).begin(), (x).end()
#define bitcount(x) __builtin_popcount(x)
#define cps CLOCKS_PER_SEC
#define verify(x) if(x >= MOD) x -= MOD;

inline void debug_vi(vi a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
inline void debug_vll(vll a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
inline void print_case(int tn) {cout<<"Case #"<<tn<<": ";}

template<typename T>
using minpq = priority_queue<T, vector<T>, greater<T>>;

template<typename T>
using maxpq = priority_queue<T>;
/*----------------------------------------------------------------------*/

int main(){
    std::ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    int l,r,d; cin>>l>>r>>d;
    int res = 0;
    for(int i = 0; i <= r; i += d) {
        if(i >= l) res++;
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 3580
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
template<class T> inline bool chmin(T& a, T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a=b;return true;}return false;}
vector<ll> pw2(62,1);vector<ll> pw10(19,1);

int main(){
    {rep1(i,61) pw2[i]=2*pw2[i-1];}
    {rep1(i,18) pw10[i]=10*pw10[i-1];}
    
    ll N,M; cin>>N>>M;
    ll ans=0;
    vector<ll> k(M);
    vector<ll> p(M);
    vector<vector<ll> > s(M,vector<ll>(N));
    rep(i,M){
        cin>>k[i];
        rep(j,k[i]){
            cin>>s[i][j];
        }
    }
    rep(i,M) cin>>p[i];
    rep(i,pw2[N]){
        //BIT全探索
        vector<ll> BIT(N);
        ll tmps=i;
        rrep(i2,N){
            BIT[i2]=tmps/pw2[i2];
            tmps%=pw2[i2];
        }
        
        //check
        bool check=true;
        rep(j,M){
            ll tmp=0;
            rep(l,k[j]){
                if(BIT[s[j][l]-1]==1) tmp++;
            }
            if(tmp%2!=p[j]) check=false;
        }
        
        if(check) ans++;
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    cout << fixed << setprecision(10);
    int n,k;
    cin >> n >> k;
    int ans = 1;
    rep(i,n){
        if(ans*2 < ans+k) ans *= 2;
        else ans += k;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    string s;
    cin>>s;
    int n=s.size();
    int sum=0,num;
    rep(i,n){
        num=s[i]-'0';
        sum+=num;
    }
    if(sum%9==0) cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 3716
#include <stdio.h>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
	int n;
	cin >> n;
	int* a = new int[n];

	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	int max = INT_MIN;
	int minpos = 0;
	for (int i = 0; i < n; i++)
	{
		if (minpos > i)
		{
			if (max < a[minpos] - a[i])
			{
				max = a[minpos] - a[i];
			}
			continue;
		}
		minpos = i + 1;
		for (int j = i + 1; j < n; j++)
		{
			if (a[minpos] - a[j] < 0)
			{
				minpos = j;
			}
			if (max < a[j] - a[i])
			{
				
				max = a[j] - a[i];
			}
		}
	}
	cout << max << endl;
    return 0;
}



Measured memory_bytes: 3864
//In The Name Of Allah
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define double long double 
#define fi first
#define se second
#define pii pair<int, int>

signed main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
  int n;
  cin >> n;
  int a[n];
  int cnt[13] = {0};
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    cnt[a[i]]++;
  }
  vector<int> v1(1, 0), v2;
  if (cnt[0] > 0) {
    cout << "0\n";
    return 0;
  }
  if (cnt[12] > 0) v1.push_back(12);
  for (int i = 1; i < 12; i++) {
    if (cnt[i] == 1) {
      v2.push_back(i);
    } else if (cnt[i] == 2) {
      v1.push_back(i);
      v1.push_back(24 - i);
    } else if (cnt[i] > 2) {
      cout << "0\n";
      return 0;
    }
  }
  int ans = 0;
  for (int b = 0; b < (1 << sz(v2)); b++) {
    vector<int> v = v1;
    for (int i = 0; i < sz(v2); i++) {
      if (b & (1 << i)) {
        v.push_back(v2[i]);
      } else {
        v.push_back(24 - v2[i]);
      }
    }
    int mn = 34324;
    for (int i = 0; i < sz(v); i++) {
      for (int j = i + 1; j < sz(v); j++) {
        int d = abs(v[i] - v[j]);
        mn = min({mn, d, 24 - d});
      }
    }
    ans = max(ans, mn);
  }
  if (sz(v2) == 0) {
    auto v = v1;
    int mn = 34324;
    for (int i = 0; i < sz(v); i++) {
      for (int j = i + 1; j < sz(v); j++) {
        int d = abs(v[i] - v[j]);
        mn = min({mn, d, 24 - d});
      }
    }
    ans = max(ans, mn);
  }
  cout << ans << "\n";
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void){
   
   int numbers[31];
   char a;
   int i,j,k;
   int w,n;
   
   for(k=1;k<=30;k++) numbers[k]=k;
   
   scanf("%d",&w);
   scanf("%d",&n);
   
   for(k=0;k<n;k++){
       scanf("%d %c %d",&i,&a,&j);
       numbers[0]=numbers[i];
       numbers[i]=numbers[j];
       numbers[j]=numbers[0];
   }
   
   for(k=1;k<=w;k++){
       printf("%d\n",numbers[k]);
   }
   return 0;
    
}




Measured memory_bytes: 2040
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define MOD 1000000007
#define INF 1 << 30

using namespace std;
typedef long long ll;

int main(void) {
	int num, i, a;
	cin >> num;
	vector<int> d(num + 1);
	for (i = 1; i <= num; i++) {
		cin >> a;
		d[a] = i;
	}
	for (i = 1; i <= num; i++)
		cout << d[i] << " ";
	cout << "\n";
	return 0;
}

Measured memory_bytes: 1152
#include <cstdio>
#include <algorithm>

using namespace std;

int main()
{
	long long P, Q, C, A[500000];

	int N;

	scanf("%d", &N);

	scanf("%lld", &P);
	scanf("%lld", &Q);

	long long zenbugaishoku = 0;

	for (int i = 0; i < N; i++)
	{
		scanf("%lld", &C);

		zenbugaishoku += C;

		A[i] = C - (Q - i) * P;
	}

	sort(A, A + N);

	long long Answer = zenbugaishoku;

	long long sum = zenbugaishoku;

	for (int i = 0; i < N; i++)
	{
		sum -= A[i];

		sum += 2 * i * P;

		Answer = max(sum, Answer);
	}

	printf("%lld\n", Answer);

	return 0;
}

Measured memory_bytes: 6636
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  string s;
  cin >> s;
  if (s[2] == s[3] && s[4] == s[5]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

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

#ifndef ULLONG
typedef unsigned long long ULLONG;
#endif
#ifndef LLONG
typedef long long LLONG;
#endif

static void B_task();

int main()
{
	B_task();
	
	fflush(stdout);
	return 0;
}

template <class _Ty> inline _Ty tp_abs(const _Ty& a)
{
	//	usage:  tp_abs<type name>(a);

	return ((a < 0) ? (a * -1) : a);

}

static void B_task()
{
	int N;
	scanf(" %d", &N);

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

	sumW[0] = W[0];
	for (int i = 1; i < N; i++) {
		sumW[i] = sumW[i - 1] + W[i];
	}

	int diffMin = 10000000;
	for (int i = 1; i < N - 1; i++) {
		int sum1 = sumW[i];
		int sum2 = sumW[N - 1] - sumW[i];

		diffMin = std::min(diffMin, tp_abs<int>(sum1 - sum2));
	}

	printf("%d\n", diffMin);
}


Measured memory_bytes: 256
# 回文にならない = 同じ文字は2個以上離れている
# → 最も登場する文字の個数と最も登場しない文字の個数の差が1以下なら良い

S = input()

count = [0]*3

for s in S:
	if s == 'a':
		count[0] += 1
	if s == 'b':
		count[1] += 1
	if s == 'c':
		count[2] += 1

if max(count)-min(count) <= 1:
	print('YES')
else:
	print('NO')

Measured memory_bytes: 3188
#include <bits/stdc++.h>
 
using namespace std;
 
const int mod = 998244353;
 
int a, dp[4030];
 
int main() {
    int n, s;
    cin >> n >> s;
    int ans = 0;
    for (int i = 1; i <= n; ++i) {
        cin >> a;
        for (int j = s - a; j >= 1; --j) {
            (dp[a + j] += dp[j]) %= mod;
        }
      
      
        (dp[a] += i) %= mod;
        (ans += dp[s]) %= mod;
    }
  
  
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <bitset>
#include <stack>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
#define MOD 1000000007
#define more(a,b) (((a)>(b))?(a):(b))
#define less(a,b) (((a)<(b))?(a):(b))
using namespace std;

int main(void)
{
	int N, K; cin >> N >> K;
	vector<int> p(N);
	lli sum_K = 0;
	rep(i, 0, N) {
		cin >> p[i];
		if (i < K)sum_K += p[i];
	}
	lli tmp = sum_K;
	rep(i, K, N) {
		tmp = tmp + p[i] - p[i - K];
		sum_K = more(tmp, sum_K);
	}

	double ans = 0.5*(K + sum_K);

	printf("%.10lf\n", ans);

	return 0;
}

Measured memory_bytes: 1024
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;

class Main {
	public static void main(String args[]) throws IOException {
		@SuppressWarnings("resource")
		Scanner cin = new Scanner(System.in);
		ArrayList<String> inLines = new ArrayList<String>();
		for (; cin.hasNext();) {
			inLines.add(cin.nextLine());
		}
		Solver solver = new Solver();
		solver.solve(inLines);
	}
}

class Solver {

	public void solve(ArrayList<String> inLines) {
		final int mod = 1000000007;
		int N = Integer.parseInt(inLines.get(0));
		int[] arr = new int[N + 1];
		for (int i = 2; i <= N; i++)
			arr[i] = i;

		long ans = 1;
		for (int i = 2; i <= N; i++) {
			if (arr[i] == i) {
				int cnt = 1;
				for (int j = i + 1; j <= N; j++) {
					for (; arr[j] % i == 0; arr[j] /= i) {
						cnt++;
					}
				}
				ans = (ans * (cnt + 1)) % mod;
				// System.out.println(ans);
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 9680
#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(unused_imports)]
#![allow(dead_code)]
use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

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

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

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

static W: &'static [usize] = &[0,2,5,5,4,5,6,3,7,6];

fn main() {
    input!{
        N: usize,
        M: usize,
        A: [usize; M],
    }
    let mut A = A;
    A.sort();
    A.reverse();
    let mut dp = vec![None; N+1];
    dp[0] = Some(0);
    for n in 0..N+1 {
        for &d in &A {
            let w = W[d];
            if n + w > N {
                continue;
            }
            let l = match dp[n] {
                None => continue,
                Some(l) => l,
            };
            dp[n+w] = match dp[n+w] {
                None => Some(l+1),
                Some(max_l) => Some(max(max_l, l+1)),
            };
        }
    }

    let mut digits = vec![];
    let mut n = N;
    while n > 0 {
        let mut ok = false;
        for &d in &A {
            let w = W[d];
            if n < w {
                continue;
            }
            let l = dp[n].unwrap();
            if dp[n - w] == Some(l - 1) {
                digits.push(b'0' + d as u8);
                n -= w;
                ok = true;
                break;
            }
        }
        assert!(ok);
    }
    let answer = String::from_utf8(digits).unwrap();
    println!("{}", answer);
}



Measured memory_bytes: 4352
#include <stdio.h>

int main(void) {
	int m, d, r;
	
	while(1) {
	    //成績を入力する
	    scanf("%d%d%d", &m, &d, &r);
	    
	    //全て-1だったら処理を終了する
	    if((m == -1) && (d == -1) && (r == -1)) {
	        break;
	    }
	    
	    //中間試験、期末試験のどちらかを欠席した場合
	    if((m == -1) || (d == -1)) {
	        printf("F\n");
	    }
	    //中間試験と期末試験の合計が80以上の場合
	    else if((m + d) >= 80) {
	        printf("A\n");
	    }
	    //合計が65以上80未満の場合
	    else if((m + d) >= 65) {
	        printf("B\n");
	    }
	    //合計が50以上65未満の場合
	    else if((m + d) >= 50) {
	        printf("C\n");
	    }
	    //合計が30以上50未満の場合
	    else if((m + d) >= 30) {
	        //再試験の点数が50以上の場合
	        if(r >= 50) {
	            printf("C\n");
	        }
	        else {
	            printf("D\n");
	        }
	    }
	    //合計が30未満の場合
	    else {
	        printf("F\n");
	    }
	}
	return 0;
}


Measured memory_bytes: 2040
import Foundation

#if swift(>=4.0)
extension String {
    func split(by separator: String) -> [String] {
        return self.components(separatedBy: separator)
    }
    func toArray() -> [String] {
        return self.map{String($0)}
    }
}
func exponentiate(_ lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#else
extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
    var count: Int {
        return self.characters.count
    }
    func toArray() -> [String] {
        return self.characters.map{String($0)}
    }
    func uppercased() -> String {
        return self.uppercaseString
    }
    func lowercased() -> String {
        return self.lowercaseString
    }
}
//extension Array where Element == String {
//    func joined(separator separator: String) -> String {
//        return self.joinWithSeparator(separator)
//    }
//}
extension Array where Element: Comparable {
    func max() -> Element {
        return self.maxElement()!
    }
    func min() -> Element {
        return self.minElement()!
    }
    func sorted() -> Array {
        return self.sort()
    }
    func reversed() -> Array {
        return self.reverse()
    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
func exponentiate(lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: String) -> [String] {
    return readLine()!.split(by: separator)
}
func readIntSplit(by separator: String) -> [Int] {
    return readLine()!.split(by: separator).map{Int($0)!}
}

/*************** テストスペース ***************/

//var min, min2, count: Int!
//for i in 1...10 {
//    let x = Int(readLine()!)!
//    if i == 1 {
//        min = x
//        count = 1
//    } else if x < min {
//        min2 = min
//        min = x
//        count = 1
//    } else if x == min && count == 1 {
//        min2 = x
//        count = 2
//    }
//}
//print(min2)

/*************** メインプログラム ***************/

let input = readIntSplit(by: " ")
let (N, A, B) = (input[0], input[1], input[2])
var ans = 0
for i in 1...N {
    if A...B ~= (String(i).toArray().reduce(0){$0+Int($1)!}) {
        ans += i
    }
}
print(ans)


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

typedef long long ll;
vector<ll > v(3001);
int n;
ll dp[3001][3001];
ll answer(int start, int end){
	if(start == end) return v[start];
	if(start > end) return 0;
	if(dp[start][end] != -1) return dp[start][end];
	ll x = v[start] + min(answer(start+2, end), answer(start+1, end-1));
	ll y = v[end] + min(answer(start+1, end-1), answer(start, end-2));
	return dp[start][end] = max(x, y);
}

int main(){
	cin >> n;
	ll sum = 0;
	v.resize(n);
	for(auto &i : v) {cin >> i; sum += i;}
	memset(dp, -1, sizeof(dp));
	cout << 2*answer(0, n-1) - sum << endl;
	return 0;
}


Measured memory_bytes: 70784
#include <stdio.h>
int main() {
  char s[3][101];
  int i,n=0,a[3]={0};
  for (i=0; i<3; i++) {
    scanf("%s",s[i]);
  }
  for (i=0; i<300; i++) {
    if (s[n][a[n]]!='a'&&(s[n][a[n]]!='b'&&s[n][a[n]]!='c')) {
      if (n==0) {
        printf("A\n");
      } else if (n==1) {
        printf("B\n");
      } else {
        printf("C\n");
      }
      return 0;
    }
    n=s[n][a[n]++]-'a';
  }
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>

using namespace std;

void print_v(const int& h, const int& w, const vector<vector<int>>& s) {
    for (int i=0; i<h; i++) {
        for (int j=0; j<w; j++) {
            cout << s[i][j] << " ";
        }
        cout << endl;
    }
}

int main() {
    int h,w;
    cin >> h >> w;
    vector<string> s(h);
    for (int i=0; i<h; i++) cin >> s[i];
    vector<vector<int>> right(h, vector<int> (w,1));
    vector<vector<int>> left(h, vector<int> (w,1));
    vector<vector<int>> up(h, vector<int> (w,1));
    vector<vector<int>> down(h, vector<int> (w,1));

    for (int j=0; j<w; j++) {
        for (int i=0; i<h; i++) {
            if (s[i][j] == '#') {
                up[i][j] = 0;
                continue;
            }
            if (i==0) continue;
            up[i][j] += up[i-1][j];
        }
    }

    for (int j=0; j<w; j++) {
        for (int i=h-1; i>=0; i--) {
            if (s[i][j] == '#') {
                down[i][j] = 0;
                continue;
            }
            if (i==h-1) continue;
            down[i][j] += down[i+1][j];
        }
    }

    for (int i=0; i<h; i++) {
        for (int j=0; j<w; j++) {
            if (s[i][j] == '#') {
                left[i][j] = 0;
                continue;
            }
            if (j==0) continue;
            left[i][j] += left[i][j-1];
        }
    }

    for (int i=0; i<h; i++) {
        for (int j=w-1; j>=0; j--) {
            if (s[i][j] == '#') {
                right[i][j] = 0;
                continue;
            }
            if (j==w-1) continue;
            right[i][j] += right[i][j+1];
        }
    }

    int ans = 0;
    for (int i=0; i<h; i++) {
        for (int j=0; j<w; j++) {
            int cnt = up[i][j] + down[i][j] + right[i][j] + left[i][j] - 3;
            ans = max(ans, cnt);
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 67200
N,M = [int(i) for i in input().split()]
S = []
C = []

for i in range(M):
   s,c = [int(i) for i in input().split()]
   S.append(s)
   C.append(c)

ans = [-1] * N
for i in range(M):
    if ans[S[i] - 1] != -1 and ans[S[i] - 1] != C[i]:
        print(-1)
        exit()
    elif S[i] - 1 == 0 and C[i] == 0 and N != 1:
        print(-1)
        exit()
    ans[S[i]-1] = C[i]

for i in range(1,N):
    if ans[i] == -1:
        ans[i] = 0

if ans[0] == -1 and N != 1:
    ans[0] = 1
elif N == 1 and ans[0] == -1:
    ans[0] = 0

print(''.join(map(str,ans)))

Measured memory_bytes: 38384
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) throws Exception {
        Thread thread = new Thread(null, new TaskAdapter(), "", 1 << 27);
        thread.start();
        thread.join();
    }

    static class TaskAdapter implements Runnable {
        @Override
        public void run() {
            InputStream inputStream = System.in;
            OutputStream outputStream = System.out;
            FastReader in = new FastReader(inputStream);
            PrintWriter out = new PrintWriter(outputStream);
            ATakoyaki solver = new ATakoyaki();
            solver.solve(1, in, out);
            out.close();
        }
    }

    static class ATakoyaki {
        public void solve(int testNumber, FastReader s, PrintWriter w) {
            int n = s.nextInt(), x = s.nextInt(), t = s.nextInt();
            w.println(((n - 1) / x + 1) * t);
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {

            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {

                curChar = 0;

                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }

            return buf[curChar++];
        }

        public int nextInt() {

            int c = read();

            while (isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            int res = 0;

            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();

                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));

            return res * sgn;
        }

        public boolean isSpaceChar(int c) {

            if (filter != null)
                return filter.isSpaceChar(c);

            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 32716
#pragma GCC optimize "03"
#include "bits/stdc++.h"
using namespace std;
 
#define ll long long int
#define ld long double
#define pi pair<int, int>
#define pb push_back
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
 
const int N = 1e5 + 5;
const int mod = 1e9 + 7;
const int inf = 1e9 + 9;
 
int h[N];

signed main() {
	IOS;
	#ifdef LOCAL
		freopen("input.txt","r", stdin);
		freopen("output.txt","w",stdout);
	#endif
	int n, ans = 0, x = 0;
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> h[i];
		if(h[i] <= h[i-1])
			x++;
		else
			x = 0;
		ans = max(ans, x);
	}	
	cout << ans;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> X(M);
    rep(i, M) cin >> X[i];
    sort(ALL(X));
    vector<int> Y(M - 1);
    rep(i, M - 1) Y[i] = X[i + 1] - X[i];
    sort(ALL(Y));
    ll ans = 0;
    rep(i, M - N) {
        ans += Y[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons;

void main()
{
    readln;
    auto AS = readln.split.to!(int[]);

    long ret;
    foreach (a; AS) {
        while (!(a&1)) {
            a >>= 1;
            ++ret;
        }
    }
    
    writeln(ret);
}

Measured memory_bytes: 2684
#ifdef __GNUC__
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#endif

#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <sstream>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <vector>

using namespace std;

typedef long long LL;
typedef long double LD;
typedef pair<LL, LL> II;
typedef pair<LL, II> III;
typedef priority_queue<III, vector<III>, greater<>> Queue;
static const LL INF = 1LL << 60;

LL gcd(LL a, LL b) { return b ? gcd(b, a % b) : a; }
LL lcm(LL a, LL b) { return (a / gcd(a, b)) * b; }


void solve(long long N, std::vector<long long>& A, std::vector<long long>& B) {
	vector<int> ac(N + 1), bc(N + 1);
	for (int i = 0; i < N; i++) {
		ac[A[i]] += 1;
		bc[B[i]] += 1;
	}
	bool possible = true;
	int shift = 0;
	for (int i = 1; i <= N; i++) {
		if (ac[i] + bc[i] > N) {
			possible = false;
			break;
		}
		ac[i] += ac[i - 1];
		bc[i] += bc[i - 1];
		shift = max(shift, ac[i] - bc[i - 1]);
	}
	cout << (possible ? "Yes" : "No") << endl;
	if (possible) {
		for (int i = 0; i < N; i++) {
			if (i) cout << " ";
			cout << B[(i - shift + N) % N];
		}
		cout << endl;
	}
}

int main() {
	long long N;
	std::cin >> N;
	std::vector<long long> A(N);
	for (int i = 0; i < N; i++) {
		std::cin >> A[i]; // A[i]--;
	}
	std::vector<long long> B(N);
	for (int i = 0; i < N; i++) {
		std::cin >> B[i]; // B[i]--;
	}
	solve(N, A, B);
	return 0;
}


Measured memory_bytes: 8020
#include <iostream>
#include <vector>
#include<string>
#include <algorithm>

#define ll         long long

#define veci         vector<int>
#define vecs         vector<string>

#define vecpii       vector<pair<int,int>>
#define vecpis       vector<pair<int,string>>
#define vecpss       vector<pair<string,string>>
#define mkp        make_pair

#define vecvi        vector<vector<int>>
#define vecvs        vector<vector<string>>

using namespace std;

int main()
{
  ll int x,y;
  cin >> x;
  y = 100;
  for (int i = 1;; i++) {
    y = (ll int)(y * 1.01);
    if (y >= x) {
      cout << i;
      break;
    }
  }


  return 0;
}


Measured memory_bytes: 3676
n = int(input())
p = list(map(int, input().split()))
x = 0
count = 0


for a in p:
  if x < n-1:
    if p[x-1] < a < p[x+1] and x != 0:
      count += 1
    elif a < p[x-1] and a > p[x+1] and x != 0:
      count += 1
  x += 1
    

print(count)

  

Measured memory_bytes: 3060
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

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

    int m[n];
    int sums = 0;
    for(int i=0;i<n;i++){
        cin >> m[i];
        sums = sums + m[i];
    }
    sums = x - sums;
    sort(m, m+n);
    cout << sums / m[0] + n << endl;
    return 0;
       
}

Measured memory_bytes: 256
//84104971101048411497 - Can you guess what does this mean?
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef complex<double> point;
#define mapii map<int, int>
#define debug(a) cout << #a << ": " << a << endl
#define debuga1(a, l, r) fto(i, l, r) cout << a[i] << " "; cout << endl
#define fdto(i, r, l) for(int i = (r); i >= (l); --i)
#define fto(i, l, r) for(int i = (l); i <= (r); ++i)
#define forit(it, var) for(__typeof(var.begin()) it = var.begin(); it != var.end(); it++)
#define forrit(rit, var) for(__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); rit++)
#define ii pair<int, int>
#define iii pair<int, ii>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define maxN 55
#define oo 2000000007
#define sz(a) (int)a.size()

const double PI = acos(-1.0);

double fRand(double fMin, double fMax)
{
    double f = (double)rand() / RAND_MAX;
    return fMin + f * (fMax - fMin);
}

template <class T>
T min(T a, T b, T c) {
    return min(a, min(b, c));
}

template <class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

ll n, A, B, C, D;

int main () {
    cin >> n >> A >> B >> C >> D;
    fto(x, 0, n-1) {
        int y = n-1-x;
        ll l = A+C*x-D*y, r = A+D*x-C*y;
//        printf("%d %d %lld %lld\n", x, y, l, r);
        if (l <= B && B <= r) {
            puts("YES");
            return 0;
        }
    }

    puts("NO");

    return 0;
}


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

int main(void) {
	int depth[20001],d = 0;
	string str;
	vector<int> area,b;
	cin >> str;

	for (int i = 0; i < 20000; i++) {
		depth[i] = -9999999;
	}
	depth[0] = 0;
	for (int i = 0; i < str.length(); i++) {
		if (str[i] == '\\') {
			d -= 1;
		} else if(str[i] == '\/') {
			d += 1;
			for (int j = i - 1; j >= 0; j--) {
				if (depth[j] == d) {
					if (b.size() != 0 && b.back() > j) {
						int a = 0;
						while (b.size() != 0 && b.back() > j) {
							a += area.back();
							area.pop_back();
							b.pop_back();
						}
						area.push_back(i - j + a);
						b.push_back(j);
					} else {
						area.push_back(i - j);
						b.push_back(j);
					}
					break;
				}
			}
		}
		depth[i + 1] = d;
	}
	/*
	for (int i = 0; depth[i] != -9999999; i++) {
		cout << depth[i] << endl;
	}
	*/
	int allsize = 0;
	for (int i = 0; i < area.size(); i++) {
		allsize += area[i];
	}
	cout << allsize << endl;
	cout << area.size();
	for (int i = 0; i < area.size(); i++) {
		cout << " " << area[i];
	}
	cout << endl;
	return 0;
}

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

using namespace std;



int main(void)
{
    int N;
    vector <int> C,V;

    cin >> N;

     for(int i=0;i<N;i++)
     {
         int x;
         cin >> x;
         C.push_back(x);
     }

    for(int i=0;i<N;i++)
    {
        int x;
        cin >> x;
        V.push_back(x);
    }
    int sum=0;

    for(int i=0;i<N;i++)
    {
        if(C[i]>V[i])
        {
            sum+=(C[i]-V[i]);
        }
    }
    cout << sum << endl;


    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int arr[3][3];
    int b[1000], chk[3][3]={0};
    for(int i=0 ; i<3 ; i++){
        for(int j=0 ; j<3 ; j++){
            cin>>arr[i][j];
        }
    }
            int n;
            cin>>n;
            for(int i=0 ; i<n ; i++)
            cin>>b[i];
    
    for(int i=0 ; i<n ; i++){
        for(int j=0 ; j<3 ; j++){
            for(int k=0 ; k<3 ; k++){
                if(arr[j][k]==b[i]) chk[j][k]=1;
            }
        }
    }
    for(int i=0 ; i<3 ; i++){
    if(chk[0][i] and chk[1][i] and chk[2][i])
    {cout<<"Yes"; return 0;}
    }
    for(int i=0 ; i<3 ; i++){
    if(chk[i][0] and chk[i][1] and chk[i][2])
    {cout<<"Yes"; return 0;}
    }
    if(chk[0][0] and chk[1][1] and chk[2][2]){
        cout<<"Yes"<<endl;
        return 0;
    }
    if(chk[1][1] and chk[2][0] and chk[0][2]){
        cout<<"Yes"<<endl;
        return 0;
    }
    cout<<"No"<<endl;
    return 0;
}


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

using namespace std;
using ll = long long;
using ld = long double;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()

#define READ(x) (cin >> (x))
#define WRITE_N(x) (cout << (x) << endl)
#define WRITE(x) (cout << (x))
#define WRITE_YESNO(x) (WRITE_N(x ? "Yes" : "No"))

bool is_hate_number(int n, vector<int> &D) {
  for (auto x:D) {
    if (to_string(n).find(to_string(x)) != string::npos) {
      return true;
    }
  }
  return false;
}

int main() {
  // get values from input
  cin.tie(0);
  ios::sync_with_stdio(false);

  int N, K;
  cin >> N >> K;

  vector<int> D(K);
  for (auto i = 0; i < K; ++i) {
    cin >> D[i];
  }

  // main procedure
  int ans = N;
  while (true) {
    if (!is_hate_number(ans, D)) {
      break;
    }
    ans++;
  }

  // output
  WRITE_N(ans);

  return 0;
}


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

{
	int m,n,i,k,q,sum;
	string p;
	cin>>n;
	p=to_string(n);
	q=p.size();
	for(i=0;i<q;i++)
	{
		if(p[i]=='7')
		{
			cout<<"Yes";
			break;
		}
	}
	if(i==q)
	{
		cout<<"No";
	}
}


Measured memory_bytes: 3688
N,Y = list(map(int,input().split()))

for i in range(N+1):
  for j in range(N+1-i):
    k = N-i-j
    if 10000*i+5000*j+1000*k == Y:
      print(i,j,k)
      exit()

print('-1 -1 -1')

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define N 100'005
int a[2]={};
char s[N];
int main(){
	scanf("%s", s);
	int n = strlen(s);
	int ans = 0;
	REP(i, n){
		int j = s[i]-'0';
		if(a[1-j]){
			ans+=2;
			a[1-j]--;
		}else{
			a[j]++;
		}
		DEBUG("%d %d\n", a[0], a[1]);
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;
const double pi = acos(-1.0);

using Graph = vector<vector<int>>;

bool dfs(Graph &g, int v, int cnt, vector<int> &color) {
    color[v] = cnt;
    for(auto x : g[v]) {
        if(color[x] != -1) {
            if(color[x] == cnt) return false;
            continue;
        }
        if(!dfs(g, x, 1-cnt, color)) return false;
    }
    return true;
}

int main() {
    ll n, m; cin >> n >> m;
    Graph g(n);
    vector<int> color(n, -1);
    rep(i, m) {
        int a, b; cin >> a >> b; a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    bool fl = true;
    rep(i, n) if(color[i] == -1) if(!dfs(g, i, 0, color)) fl = false;
    ll a = 0;
    rep(i, n) if(color[i] == 0) a++;
    cout << (fl ? a*(n-a)-m : n*(n-1)/2-m) << endl;
}


Measured memory_bytes: 9508
n = int(input())

t1 = [[0] * 10 for i in range(3)]
t2 = [[0] * 10 for i in range(3)]
t3 = [[0] * 10 for i in range(3)]
t4 = [[0] * 10 for i in range(3)]


def print_t(t):
    for i in t:
        print(" " + " ".join(map(str, i)))


for i in range(n):
    b, f, r, v = map(int, input().split())
    if b == 1:
        t1[f - 1][r - 1] = t1[f - 1][r - 1] + v
    elif b == 2:
        t2[f - 1][r - 1] = t2[f - 1][r - 1] + v
    elif b == 3:
        t3[f - 1][r - 1] = t3[f - 1][r - 1] + v
    elif b == 4:
        t4[f - 1][r - 1] = t4[f - 1][r - 1] + v

print_t(t1)
print("####################")
print_t(t2)
print("####################")
print_t(t3)
print("####################")
print_t(t4)



Measured memory_bytes: 5620