akhauriyash/Code-Regression huggingface dataset:
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
long long getDigit(long long n);      // 数字の桁数を取得する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      ((a)/GCD((a),(b))*(b))
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;

// code
// ------------------------------------------------
int main()
{

  ll n;
  cin >> n;
  map<ll,ll> a;
  rep(i,n)
  {
    ll buf;
    cin >> buf;
    a[buf]++;
  }

  ll ans = 1;
  ll mo = 1000000007;

  bool ev_flg = n % 2 == 0;


  // check fase
  ll bef_key = a.begin()->first;

  for(auto m = a.begin(); m != a.end(); ++m)
  {
    if(m == a.begin())
    {
      bef_key = m->first;
      if(!ev_flg)
      {
        if(m->second != 1)
        {
          cout << 0 << endl;
          return 0;
        }
      }
      else
      {
        if(m->second != 2)
        {
          cout << 0 << endl;
          return 0;
        }
      }
      
    }
    else
    {
      if(bef_key + 2 == m->first)
      {
        if(m->second != 2)
        {
          cout << 0 << endl;
          return 0;
        }
        bef_key = m->first;
      }
      else
      {
        cout << 0 << endl;
        return 0;
      }
    }
  }

  // calc fase
  rep(i,n/2)
  {
    ans = (ans % mo * 2) % mo;
  }

  cout << ans << endl;


  return 0;
}
// funcの実体
// ------------------------------------------------
ll getDigit(ll n)
{
  int i = 1;
  while(1)
  {
    n = n / 10;
    if(n == 0)
      break;
    i++;
  }
  return i;
}
ll CalcSumOfDigit(ll n)
{
  ll s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


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

#define ll long long
#define ar array

const int MOD = 1e9+7;
int H,W;
char grid[1001][1001];
ll dp[1001][1001];

int main(){
    cin >> H >> W;
    for(int i=1;i<=H;++i){
        for(int j=1;j<=W;++j){
            cin >> grid[i][j];
        }
    }
    dp[1][1] = 1;
    for(int i=1;i<=H;++i){
        for(int j=1;j<=W;++j){
            if(i==1 and j==1)
                continue;
            dp[i][j] = (dp[i-1][j] + dp[i][j-1])%MOD;
            if(grid[i][j] == '#')
                dp[i][j] = 0;
        }
    }
    cout << dp[H][W] << endl;
    return 0;
}


Measured memory_bytes: 12392
function Main (input){
  input = input.split("\n");
  tmp = input[0].split(" ");
  var N = parseInt(tmp[0],10);
  var i = 0;
  var j = 0;
  var susumi = 0;
  for(i=1;i<=parseInt(Math.sqrt(N));i++){
    if(N % i == 0){
      i=Math.min(i);
      j=N/i;
      susumi=i+j-2;
    }else{"";}
  }
  console.log(Math.min(susumi));
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

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

int h,v;

bool valid(int a,int b){
	return (a<h && a>=0 && b<v && b>=0);
}

int main(){
	cin>>h>>v;
	char c[21][21];
	int mx=0;
	for (int i=0;i<h;i++)
		for (int j=0;j<v;j++)
			 cin>>c[i][j];
	for (int i=0;i<h;i++)
		for (int j=0;j<v;j++){
			if (c[i][j]=='#') continue;
			for (int ii=0;ii<h;ii++)
				for (int jj=0;jj<v;jj++){
					if (c[ii][jj]=='#') continue;
					int d[21][21];
					for (int k=0;k<h;k++)
						for (int kk=0;kk<v;kk++)
							d[k][kk]=-1;
					queue<pair<int,int> > q;
					q.push(make_pair(i,j));
					d[i][j]=0;
					
					while (!q.empty()){
						int x=q.front().first;
						int y=q.front().second;
						q.pop();
						for (int k=0;k<4;k++){
							int nx=dx[k]+x;
							int ny=dy[k]+y;
							if (d[nx][ny]==-1 && c[nx][ny]=='.' && valid(nx,ny)){
								d[nx][ny]=d[x][y]+1;
								q.push(make_pair(nx,ny));
							}
						}
					}
					mx=max(d[ii][jj],mx);
				}
		}
	cout<<mx<<endl;
	return 0;
}


Measured memory_bytes: 256
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [x, a] <- getIntList
    print $ if x < a then 0 else 10

Measured memory_bytes: 380
#include "bits/stdc++.h"
using namespace std;
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define N	    100001
#define rep(i,a,b)  for(int i=a;i<b;i++)
typedef long long ll;

int main() {
	int n, m;
	cin>>n>>m;
	vector<int> dp(n + 1), op(m);
	dp[0] = 1;
	for(int &i : op)
		cin>>i;
	int ind = 0;
	for(int i = 1; i <= n; i++) {
		if(ind < m && i == op[ind]) {
			ind++;
			dp[i] = 0;
		}
		else {
			dp[i] = dp[i - 1];
			if(i > 1)
				dp[i] += dp[i - 2];
			dp[i] = dp[i] % hell;
		}
	}
	cout<<dp[n]<<endl;
	return 0;
}


Measured memory_bytes: 1024
n,q=map(int,input().split())
s=input()
t=[0]*(n+1)
for i in range(n):
    if s[i:i+2]=="AC":
        t[i+1]=t[i]+1
    else:
        t[i+1]=t[i]

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

Measured memory_bytes: 6060
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007
using namespace std;

int main(void){
  int n,a;
  cin >> n >> a;
  if(n%500 <= a) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define F first
#define S second

using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef pair<int, int> pint;
const int Inf = 1e9;
const double EPS = 1e-9;



int main()
{
  string s ;
  cin >> s ;
  int n = s.size() ;
  if(n==1){
    cout <<"No"<<endl ;
    return 0 ;
  }
  vector<char> str(n) ;
  int count = 1 ;
  
  REP(i,n){
    str.at(i) = s.at(i) ;
  }
  
  sort(ALL(str)) ;
  
  int i = 0 ;
  while(i<n-1){
    FOR(j,i+1,n){
      if(str.at(i)==str.at(j)){
        count++ ;
      }
      else{
        break ;
      }
    }
    if(count%2==1){
      cout << "No"<<endl ;
      return 0 ;
    }
    i += count ;
    count = 1 ; 
    if(i==n-1){
      cout <<"No"<<endl ;
      return 0 ;
    }
  }
  
  cout << "Yes"<<endl ;
  
  return 0 ;
}
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define vii vector<int>
#define task "COLORING"
#define pll pair<ll, ll>
#define pii pair< ll, pair< ll, ll > >
#define fi first
#define se second

using ll = long long;
using ld = long double;
using ull = unsigned long long;
const int mod = 1e9 + 7;
using namespace std;
const int N =  3e5 + 5;
ll m, n, k, t, ans, T, a[N];
pll b[N];
inline void sol()
{
	cin >> n;
	m = n / 1000;
	if(n % 1000 != 0)m += 1;
	cout << m * 1000 - n;

}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    if(fopen(task".INP", "r"))
    {
		freopen(task".INP","r",stdin);
		freopen(task".OUT","w",stdout);
    }
    sol();

}


Measured memory_bytes: 3616
#include <stdio.h>
#include <iostream>
#include <set>
#include <bitset>
#include <map>
#include <stack>
#include <algorithm>
#include <math.h>
#include <queue>
#include <vector>
#include <string.h>
#define mem(x,b) memset(x,b,sizeof(x))
#define mp(a,b) make_pair(a,b)
#define debug(a) cout<<a<<endl
#define maxn 200005
using namespace std;
typedef long long ll;
typedef double db;
const int mod=1e9+7;
char a[15];
char b[15];
int slove(){
	if(strlen(a)+1!=strlen(b)){
		return 0;
	}
	for(int i=0;i<strlen(a);i++){
		if(a[i]!=b[i]){
			return 0;
		}
	}
	return 1;
}
int main()
{
    scanf("%s",a);
    scanf("%s",b);
   	if(slove()){
   		puts("Yes");
   	}else{
   		puts("No");
   	}
    return 0;
}


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

using namespace std;

int cntSort;

void printArray(char B[], int A[], int N) {
	for (int i = 0; i < N - 1; i++)
		cout << B[i] << A[i] << " ";
	cout << B[N - 1] << A[N - 1] << endl;
}

void insertionSort(int A[], char B[], int N) {
	for (int i = 1; i < N; i++) {
		int val = A[i];
		char cval = B[i];
		int j = i - 1;
		while (j >= 0 && A[j] > val) {
			A[j + 1] = A[j];
			B[j + 1] = B[j];
			j--;
		}
		A[j + 1] = val;
		B[j + 1] = cval;
	}
}

void bubbleSort(int A[], char B[], int N) {
	for (int i = 0; i < N - 1; i++) {
		for (int j = N - 1; i < j; j--) {
			if (A[j - 1] > A[j]) {
				swap(A[j - 1], A[j]);
				swap(B[j - 1], B[j]);
			}
		}
	}
}

void selectionSort(int A[], char C[], int N) {
	for (int i = 0; i < N; i++) {
		int minj = i;
		for (int j = i + 1; j < N; j++) {
			if (A[j] < A[minj])
				minj = j;
		}
		swap(A[minj], A[i]);
		swap(C[minj], C[i]);
	}
}

void isStable(char A[], char B[], int N) {
	for (int i = 0; i < N; i++) {
		if (A[i] != B[i]){
			cout << "Not stable" << endl;
			return;
		}
	}
	cout << "Stable" << endl;
	return;
}

int main() {
	//??\???---------------------------------------
	int N;
	cin >> N;
	char Cbub[N];
	char Csel[N];
	char Cins[N];
	int Abub[N];
	int Asel[N];
	int Ains[N];
	for (int i = 0; i < N; i++) {
		cin >> Cbub[i];
		Csel[i] = Cbub[i];
		Cins[i] = Cbub[i];
		cin >> Abub[i];
		Asel[i] = Abub[i];
		Ains[i] = Abub[i];
	}

	//?????????-------------------------------------
	selectionSort(Asel, Csel, N);
	bubbleSort(Abub, Cbub, N);
	insertionSort(Ains, Cins, N);

	//????????§???????¨?-------------------------------
	printArray(Cbub, Abub, N);
	isStable(Cbub, Cins, N);
	printArray(Csel, Asel, N);
	isStable(Csel, Cins, N);
}

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

#define int long long
#define pb push_back
#define mp make_pair
#define endl "\n"
#define ss second
#define ff first

#ifndef ONLINE_JUDGE
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << endl;}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << "  ";
	__f(comma + 1, args...);}
#else
#define debug(...)
#endif

const int inf = 2e18;
const int ninf = -2e18;

signed main() {

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
 
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
		freopen("error.txt", "w", stderr);
	#endif

	int d, t, s; cin >> d >> t >> s;
	if (s * t >= d ) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
 
Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

int main() {
    Int n, k, q;
    cin >> n >> k >> q;
    vector<Int> b(n, k - q);
    vector<Int> a(q);
    for (Int i = 0; i < q; i++) {
        cin >> a[i];
        a[i]--;
        b[a[i]]++;
    }
    for (Int i = 0; i < n; i++) {
        dump(b[i] > 0 ? "Yes" : "No");
    }
    return 0;
}

Measured memory_bytes: 2176
S = int(input())
  
#初期化
dp = [0]*S
if S > 2:
  dp[2] = 1
  dp_S = 0

#dp
  for i in range(3,S):
    dp_S += dp[i-3] 
    dp[i] = 1+dp_S

print(dp[S-1]%1000000007)

Measured memory_bytes: 9284
#!/usr/bin/env python3
import sys
try:
    from typing import List
except ImportError:
    pass


def solve(A: "List[int]"):
    print(max(A) - min(A))


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = [int(next(tokens)) for _ in range(3)]  # type: "List[int]"
    solve(A)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <iostream>
#include <cmath>
#include <queue>
#include <sstream>
#include <unordered_map>
#include <algorithm>
#include <set>
#include <vector>
#include <map>

#define ll long long

using namespace std;

//bool isPal(string s) {
//    string s2 = s;
//    reverse(s.begin(), s.end());
//    if (s2 == s) {
//        return true;
//    } else {
//        return false;
//    }
//}

ll a[210000];
ll cnt[210000];
int main() {

    cin.tie(NULL);
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;

    for (int i = 0; i <= 200005; i ++) {
        cnt[i] = 0;
    }

    for (int i = 0; i < n; i ++) {
        cin >> a[i];
        cnt[a[i]] ++;
    }
    ll ans = 0;

    for (int i = 1; i <= 200000; i ++) {
        ans += cnt[i] * (cnt[i] - 1) / 2;
    }

//    cout << ans;

    for (int i = 0; i < n; i ++) {
        cout << ans - cnt[a[i]] * (cnt[a[i]] - 1) / 2 + (cnt[a[i]] - 1) * (cnt[a[i]] - 2) / 2 << "\n";
    }

}


Measured memory_bytes: 5760
/*
for (int i = 0; i < N; ++i){}

// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18
// int 
// // 各桁の和を計算する関数
// int findSumOfDigits(int n) {
//   int amari = 0;
//   int keta = 0;
//   while (n > 0) { // n が 0 になるまで
//     amari += n % 2;
//     if (keta%2==0)
//     n /= 10;
//   }
//   return sum;
// }
 
 

int main() {
	// 入力
	ll D;
	cin >> D;
	// 解法
	if (D==25) cout << "Christmas" << endl;
	if (D==24) cout << "Christmas Eve" << endl;
	if (D==23) cout << "Christmas Eve Eve" << endl;
	if (D==22) cout << "Christmas Eve Eve Eve" << endl;
	
}


Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
sum=0
i=0
while i<=N-1:
  sum+=B[i]
  i+=1
for i in range(N-1):
  K=A[i]
  if A[i+1]==K+1:
    sum+=C[K-1]
  else:
    sum+=0
print(sum)


Measured memory_bytes: 3064
import scala.io.StdIn.{readInt,readLine}
import scala.collection.mutable.ArrayBuffer

object Main {
  def main(args:Array[String]) = {
    var n = 0
    while( {n=readInt;n} != 0 ) {
      val b = new ArrayBuffer[Array[Int]]
      for(i<-1 to n) {
        b += readLine.split(" ").map(_.toInt)
      }
      val limit = readLine.split(" ").map(_.toInt)
      val p = limit(0);val q = limit(1);val r = limit(2);val c = limit(3)
      val list = b.toArray.filter { i => i(1) <= p && i(2) <= q && i(3) <= r && i(1)*4 + i(2)*9 + i(3)*4 <= c }
      if(list.length == 0) println("NA")
      else list.foreach(i=>println(i(0)))
    }
  }
}

Measured memory_bytes: 71424
#include <stdio.h>

int main()
{
    int A[100][100], b[100], c[100];
    int n, x;
    
    scanf("%d %d", &n, &x);
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < x; j++)
        {
            scanf("%d", &A[i][j]);
        }
    }
    for (int i = 0; i < x; i++)
    {
        scanf("%d", &b[i]);
    }
    for (int i = 0; i < n; i++)
    {
        c[i] = 0;
        for (int j = 0; j < x; j++)
        {
            c[i] = c[i] + A[i][j] *b[j];
        }
    }
    for (int i = 0; i < n; i++)
    {
        printf("%d\n", c[i]);
    }
    return 0;
}


Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> data(N);
    for (int i = 0; i < N; i++){
        cin >> data[i];
    }
    reverse(data.begin(), data.end());
    for (int i = 0; i < N; i++){
        cout << data[i];
            if(!(i < N-1))break;
        cout << " ";
    }
    cout << endl;
}


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

template<typename T>
vector<T> uni(vector<T> v) {
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    return v;
}

int main() {
    string s; cin >> s;
    int k; cin >> k;
    int n = s.size();
    vector<string> cand;
    for (int i = 0; i < n; i++) for (int j = 1; j <= k && i + j <= n; j++) {
        cand.emplace_back(s.substr(i, j));
    }
    cout << uni(cand)[k - 1] << endl;
    return 0;
}


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

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

  vector<long long> a;
  for (int i=0; i<n; i++) {
    long long tmp;
    cin >> tmp;
    a.push_back(tmp);
  }

  sort(a.begin(), a.end(), greater<long long>());

  long long edge1=0, edge2=0;
  int cnt=0;
  for (int i=0; i<n-1; i++) {
    if (a[i] == a[i+1] && cnt==1) {
      edge2 = a[i];
      cnt++;
      break;
    }
    if (a[i] == a[i+1] && cnt==0) {
      edge1 = a[i];
      i++;
      cnt++;
    }
  }

  cout << edge1*edge2 << endl;
  return 0;
}


Measured memory_bytes: 1400
n = int(input())
z = [0] * n
for i in range(n):
  x,y,h = map(int,input().split())
  if h != 0:
    k = [x,y,h]
  z[i] = [x,y,h]

for i in range(101):
  for j in range(101):
    H = k[2] + abs(k[0]-i) + abs(k[1]-j)
    for l in z:
      if l[2] != max(H-abs(l[0]-i)-abs(l[1]-j),0):
        break
      if l == z[-1]:
        print(i,j,H)
        exit()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
long long int solve(int n,int k,int v[])
{
    long long int dp[n+1][k+1];
    long long int m=pow(10,9)+7;
    for(int i=0;i<=k;i++)
    {
        dp[1][i]=(i>v[1])?0:1;
    }
    for(int i=2;i<=n;i++)
    {
        for(int j=0;j<=k;j++)
        {
            if(j==0)
            {
                dp[i][j]=dp[i-1][j];
            }
            else
            {
                dp[i][j]=(m+dp[i-1][j]%m+dp[i][j-1]%m-((j-1-v[i]>=0)?dp[i-1][j-1-v[i]]%m:0))%m;
                
            }
        }
    }
    return dp[n][k];
}
int main() {
	int n,k;
	cin>>n>>k;
	int v[n+1];
	for(int i=1;i<=n;i++)
	{
	    cin>>v[i];
	}
	long long int ans=solve(n,k,v);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 81476
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ld long double
#define pb push_back
#define PLL pair<ll,ll>
#define F first
#define S second
#define MP make_pair
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define N 100001

int main()
{
    fastio;
   
    ll a[120]={0};
    
    ll n,k;
    cin >> n>>k;
    
    while(k--)
    {
        ll d;
        cin >> d;
        
        while(d--)
        {
            ll num;
            cin >> num;
            a[num]++;
        }
    }
    ll count=0;
    for(ll i=1;i<=n;i++)
    {
        if(a[i]==0)
        count++;
    }
    
    cout << count <<'\n';
    
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int main(void){
    string s;
    cin>>s;
    bool flag=true;
    if(s[0]!='A')flag=false;
    int count=0;
    for(int i=2;i<s.size()-1;i++){
        if(s[i]=='C')count++;
    }
    if(count!=1)flag=false;
    count=0;
    for(int i=0;i<s.size();i++){
        if(islower(s[i]))count++;
    }
    //cout<<count<<endl;
    if(count!=s.size()-2)flag=false;
    if(flag)cout<<"AC"<<endl;
    else cout<<"WA"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int n, p;
string s;
vector<long long> cnt(10100, 0);

int main() {
    cin >> n >> p >> s;
    cnt.at(0) = 1;
    if(p == 2 || p == 5) {
        if(p == 2) {
            long long cnt2 = 0;
            for(int i = n-1; i >= 0; --i) {
                if((s.at(i) - '0') % 2 == 0) {
                    cnt2 += (i+1);
                }
            }
            cout << cnt2 << endl;
        }else {
            long long cnt5 = 0;
            for(int i = n-1; i >= 0; --i) {
                if((s.at(i) - '0') % 5 == 0) {
                    cnt5 += (i+1);
                }
            }
            cout << cnt5 << endl;
        }
    }else {
        long long power = 1;
        long long ans = 0;
        long long amari = 0;
        for(int i = n-1; i >= 0; --i) {
            amari = (amari + (s.at(i) - '0')*power) % p;
            ans += cnt.at(amari);
            power = (power*10) % p;
            cnt.at(amari)++;
        }
        cout << ans << endl;
    }

}

Measured memory_bytes: 644
import math

def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break

N = list(get_input())

for l in range(len(N)):
    x1,y1,x2,y2,xq,yq = [float(i) for i in N[l].split(",")]

    # l: a*x + b*y + c = 0
    a = y2-y1
    b = x1-x2
    c = y1*(x2-x1) - x1*(y2-y1)
    p = a
    q = b
    A = -a*xq - b*yq - 2*c

    r = x2-x1
    s = y2-y1
    B = xq*(x2-x1) + yq*(y2-y1)

    X = (A*s - B*q)/(p*s-r*q)
    Y = (-A*r + B*p)/(p*s - r*q)

    print(X,Y)



Measured memory_bytes: 5640
#include<stdio.h>
int bubbleSort(int[], int);
int main(){
  int N, i, con;
  int A[100];

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

  con = bubbleSort(A, N);

  printf("%d",A[0]);
  for( i = 1 ; i < N ; i++ ){
    printf(" %d",A[i]);
  }
  printf("\n%d\n",con);
  return 0;
}

int bubbleSort(int A[], int N){
  int j, tmp, con=0;
  int flag=1;
  while( flag ){
    flag = 0;
    for( j = N-1 ; j > 0 ; j-- ){
      if( A[j] < A[j-1] ){
	con++;
	tmp = A[j];
	A[j] = A[j-1];
	A[j-1] = tmp;
	flag = 1;
      }
    }
  }
  return con;
}



Measured memory_bytes: 2124
/*
 * written by Yaqi Zhang
 * University of Wisconsin-Madison
 * 2020
 */

#include<algorithm>
#include<cstring>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stdio.h>
#include<vector>

#define INF 0x3f3f3f3f

using namespace std;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    for(int i = 0; i < h; ++i) {
        cin >> s[i];
    }
    vector<vector<int>> f(h, vector<int>(w));
    for(int i = 0; i < h; ++i) {
        for(int j = 0; j < w; ++j){
            if(i + j == 0) f[0][0] = s[0][0] == '#';
            else {
                f[i][j] = (int) 1e9;
                if(i > 0) f[i][j] = min(f[i][j], f[i - 1][j] + (s[i - 1][j] == '.' && s[i][j] == '#'));
                if(j > 0) f[i][j] = min(f[i][j], f[i][j - 1] + (s[i][j - 1] == '.' && s[i][j] == '#'));
            }
        }
    }
    cout << f[h - 1][w - 1] << '\n';
    return 0;

}



Measured memory_bytes: 384
#define debug(x) cout<<#x<<": "<<x<<endl
#define rep(a, b) for(int unsafe_cnt=a; unsafe_cnt < b;unsafe_cnt++)
#define fn auto
#include <iostream>
#include <stdio.h>
#include <vector>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;

void newline() {cout << endl;}
template <typename T> void display(T input){cout << input;}
template <typename T> void put(T input){display(input); newline();}
void iput(int input) {put(input);}

fn main() -> int {
  int a, b, c;
  cin >> a >> b >> c;
  cout << (2*b-a==c ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
long long n,a[200010],ans,l,temp; 
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	ans=0;
	l=1;
	temp=0;
	for(int r=1;r<=n;r++){
		if((temp^a[r])==(temp+a[r])){
			ans+=r-l+1;
			temp+=a[r];
		}
		else{
			temp-=a[l++];
			while((temp^a[r])!=(temp+a[r])){
				temp-=a[l++];
			}
			ans+=r-l+1;
			temp+=a[r];
		}
	}
	cout<<ans<<endl;
	return 0;
}
/*19
885 8 1 128 83 32 256 206 639 16 4 128 689 32 8 64 885 969 1*/

Measured memory_bytes: 1792
a, b, c = [int(i) for i in input().split()]

cnt = 0
history = set()
while True:
  if (a, b, c) in history:
    print(-1)
    exit(0)
  if a % 2 == 1 or b % 2 == 1 or c % 2 == 1:
    print(cnt)
    exit(0)
  a, b, c = sorted([a, b, c])
  history.add((a, b, c))
  na = b // 2 + c // 2
  nb = a // 2 + c // 2
  nc = a // 2 + b // 2
  a = na
  b = nb 
  c = nc
  cnt += 1

Measured memory_bytes: 9044
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <numeric>
#include <cmath>
#include <cstdlib>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
#define ALL(x) x.begin(), x.end()
#define INF (1001000000)
#define SZ(a) int((a).size())
#define EACH(i,c) for(auto i:c)
#define EXIST(cs,v) (find(ALL(cs),(v))!=cs.end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define UNIQ(c) (c).erase(unique((c).begin(),(c).end()), (c).end());
#define P(p) cout<<(p)<<endl;

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

    string s;
    cin >> s;

    bool flag = true;
    if (!(s[0] == 'A')) flag = false;

    int cnt = count(s.begin()+2, s.end()-1, 'C');
    if (cnt != 1) flag = false;

    FOR(i, 1, s.length()){
        if (isupper(s[i]) && !((i<3 || i<=s.length()-2) && s[i] == 'C')) {
            flag =false;
        }
    }

    if (flag) {
        P("AC");
    }
    else {
        P("WA");
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
ll exp(int a, int x){
    if (x == 0) return 1;
    ll p = exp(a,x/2);
    p *= p;
    p %= mod;
    if (x&1){
        p *= a;
        p %= mod;
    }
    return p;

}
int main(){
    int h,a;
    scanf("%d%d",&h,&a);
    printf("%d ",(h-1)/a+1);
}


Measured memory_bytes: 256
#[allow(unused_macros)]
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 ) * } };
}
#[allow(unused_macros)]
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 ) * } };
}
#[allow(unused_macros)]
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" ) };
}

fn main() {
    input! {
        n: usize,
        a: [u64; n]
    }

    let mut set = std::collections::HashSet::new();

    for i in 0..n {
        if set.contains(&a[i]) {
            set.remove(&a[i]);
        } else {
            set.insert(a[i]);
        }
    }

    println!("{}", set.len());
}


Measured memory_bytes: 8444
#include "bits/stdc++.h"
using namespace std;
#define ll long long

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

    int k;
    cin >> k;
    ll sum=0;
    for(int i=1;i<=k;i++) {
    	for(int j=1;j<=k;j++) {
    		for(int l=1;l<=k;l++) {
    			sum+=__gcd(__gcd(i,j),l);
    		}
    	}
    }
    cout << sum;

	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll gcd(ll a,ll b){
    if (a%b==0){
        return(b);
    }
    else{
        return(gcd(b,a%b));
    }
}
int main(){
    ll N;
    ll X;
    cin >> N >> X;
    ll x[100010];
    ll d[100010];
    for(ll i = 0;i < N;i++){
        cin >> x[i];
        d[i] = X - x[i];
    }
    ll now = d[0];
    for(ll i = 0;i < N;i++){
        now = gcd(d[i], now);
    }
    cout << abs(now);
}



Measured memory_bytes: 1792
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#include <unordered_map>

using namespace std;

#define int long long
#define ll long long
//#define double long double
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

const int INF = 2e9;
const int MB = 20;
const int MOD = 1e9 + 7;

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

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    //int t;
    //cin >> t;
    int t = 1;
    while (t--) solve();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define A_max int(1e5+5)


int main(){
    int n;
    cin >>n;
    int tmp;
    int A[A_max]={};
    REP(i,n){
        scanf("%d",&tmp);
        A[tmp]+=1;
    }

    int syu=0,guu=0;
    REP(i,A_max){
        if(A[i]>0){
            syu+=1;
            if(A[i]%2==0) guu+=1;
        }
    }
    if(guu%2==0){
        cout << syu << endl;
    }
    else cout << syu -1 << endl;
}

Measured memory_bytes: 640
import java.util.*;
public class Main {
	static Scanner sc = new Scanner(System.in);
	static String name;
	static int num;
	public static void main(String[] args) {
		for(int i = 0; i < 9; i++){
			read_and_solve();
		}
	}
	static void read_and_solve(){
		int res = 0;
		int temp = 0;
		name = sc.next();
		num = sc.nextInt();
		temp = num;
		res = num*200;
		num = sc.nextInt();
		res = res + num*300;
		num = num + temp;
		System.out.println(name + " " + num + " " + res);
	}

}

Measured memory_bytes: 12000
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

//エラーが発生したときは勝手にpanicしろって関数にはmustって名前を付ける慣例
func mustParseInt(text string) int {
	num, err := strconv.Atoi(text)
	if err != nil {
		panic(err)
	}
	return num
}

func mustParseFloat(text string) float64 {
	num, err := strconv.ParseFloat(text, 64)
	if err != nil {
		panic(err)
	}
	return num
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)

	var line string
	scanner.Scan()
	line = scanner.Text()

	f := strings.Split(line, " ")
	a := mustParseInt(f[0]) * 2
	b := mustParseInt(f[1])
	t := mustParseInt(f[2]) * 2

	biscuit := 0
	for time := 1; time <= t+1; time = time + 1 {
		if time%a == 0 {
			biscuit = biscuit + b
		}

	}
	fmt.Println(biscuit)
}


Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.TreeMap;






public class Main {
	  static int MOD=1000000007;
	  static long p[][]=new long[405][405];
	  static long sum[][]=new long[405][405];
	  static long dp[][]=new long[61][25005];
	  static long a[]=new long[405];
	  static long b[]=new long[405];
      public static void main(String[] args) {
    	  Scanner in=new Scanner( new BufferedReader(new InputStreamReader(System.in)))	;
          int n=in.nextInt(),m=in.nextInt();
         
          for(int i=0;i<=60;i++)
          {
        	 dp[i]=new long[25005];
          }
          for(int i=1;i<=n;i++)
          {
        	  a[i]=in.nextInt();
          }
          int v=m*n;
          
      
          dp[0][0]=1;
          for(int i=1;i<=n;i++)
          {
        	 
        	for(int j=i;j>=0;j--)
        	{
        		
        		for(int k=v;k>=a[i];k--)
        			{
        			//System.out.println(j+" "+i+" "+(k-a[i]));
        			if(j==0) continue;
        			dp[j][k]+=dp[j-1][k-(int)(a[i])];
        			
        			}
        	}
          }
          long ans=0;
          for(int i=1;i<=n;i++)
          {
        	  ans+=dp[i][m*i];
          }
          System.out.print(ans);
    	  return;
      }
}


Measured memory_bytes: 54356
import java.util.Scanner;

public class Main {
	public static Scanner sc;
	public static void main(String[] args){
		sc = new Scanner(System.in);
		while(true){
			String num = sc.nextLine();
			if(num.equals("0"))break;
			int ans=0;
			for(int i=0;i<num.length();i++){
				ans+=Integer.parseInt(""+num.charAt(i));
			}
			System.out.println(ans);
		}
	}

}

Measured memory_bytes: 27000
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<cmath>
#include<deque>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define INF 1LL << 60
#define MAX 1000000000
int main() {
	int N;
	ll s = 0;
	scanf("%d", &N);
	rep(i, 1, N + 1) {
		if (i % 3 && i % 5)s += i;
	}
	printf("%lld\n", s);
	return 0;
}


Measured memory_bytes: 1736
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int t = sc.nextInt();
    
    if (x > t) {
      System.out.println(x-t);
    } else {
      System.out.println(0);
    }
  }
}

Measured memory_bytes: 20564
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<assert.h>
#define fo(i,a,b) for(int i=(a);i<=(b);++i)
#define fd(i,b,a) for(int i=(b);i>=(a);--i)
#define bfo(i,v,u) for(int i=BB[v],u=B[i][1];i;u=B[i=B[i][0]][1])
#define mset(a,x) memset(a,x,sizeof(a))
#define mcpy(a,b) memcpy(a,b,sizeof(b))
template<typename T> bool chkmin(T &a,const T &b) {return b<a?a=b,1:0;}
template<typename T> bool chkmax(T &a,const T &b) {return b>a?a=b,1:0;}
using namespace std;
typedef long long ll;
int read(){int n=0,p=1;char ch;for(ch=getchar();ch<'0' || ch>'9';ch=getchar())if(ch=='-') p=-1;for(;'0'<=ch && ch<='9';ch=getchar()) n=n*10+ch-'0';return n*p;}
const int N=2e5+5;
int n;
char s[N];
int main()
{
	scanf("%s\n",s+1);n=strlen(s+1);
	ll ans=0,t=0;
	fo(i,1,n)
		if(s[i]=='B') ++t;
		else ans+=t;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 512
var ModUtils = function(mod){
	this.mod = mod;
}
ModUtils.prototype.inv = function(n) {
  function euclidean(a,b){
  	if(a == 1 && b == 0)return {x:1,y:0};
  	var ans = euclidean(b,a%b);
    var x = ans.y;
    var y = ans.x - x * Math.floor(a/b);
    return {x:x,y:y};
  }
  var c = euclidean(this.mod,n).y;
  while(c < 0){c += this.mod}
  return c;
};
ModUtils.prototype.times = function() {
  var initVal = 1;
  var len = arguments.length;
  for(var i = 0; i < len;i++){
  	var elem = arguments[i];
  	initVal *= elem;
    initVal %= this.mod;
  }
  return initVal;
};
ModUtils.prototype.combination = function(n,k){
  k = Math.min(k,n-k);
  var a = this.times(...Array.from({length:k},(v,k)=>n-k));
  var b = this.times(...Array.from({length:k},(v,k)=>k+1));
  var bInv = this.inv(b);
  return this.times(a,bInv);
}

function Main(input){
	input = input.trim()
  var hoge = {G:"C",C:"G",T:"A",A:"T"};
  return hoge[input];
}

// If you are interested in the algorithms I used, 
// there is no need to read down from this line.

((b,c,d)=>"undefined"!=typeof require?console.log(Main(require("fs").readFileSync("/dev/stdin","utf8"))):[b=b.split("\n").slice(1,-1).join("\n"),c=function(){try{return Main(b)}catch(f){return f.stack||f.message}}(),d=typeof c,"string"==d||(c=JSON.stringify(c)),$("<form>").append([[10,b],0,[1,d],0,[10,c]].map(f=>$(f?"<textarea>":"<br>",f&&{rows:f[0],cols:40,text:f[1]}))).appendTo("body")])(`
G
`);

Measured memory_bytes: 21064
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        if((Math.abs(a - b) <= d&&Math.abs(b - c) <= d)||Math.abs(a - c) <= d)System.out.println("Yes");
        else System.out.println("No");





    }

}

Measured memory_bytes: 23892
a = []
b = []
flag = 0
while True:
    H,W = map(int,raw_input().split())
    if H == 0 and W == 0:
        break
    a.append(H)
    b.append(W)
    flag+=1

for k in range(0,flag):
    ans = ""
    for i in range(b[k]):
        ans+="#"
    for j in range(a[k]):
        print ans
    print ""


Measured memory_bytes: 4644
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         sort(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

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

const ll MOD = 1000000007; // 10^9 + 7

void solve() {
  int n; cin >> n;
  vector<int> s(n);
  int sum = 0;
  rep(i, n) {
    cin >> s[i];
    sum += s[i];
  }
  sort(s);

  int i = 0;
  while (i < n && s[i] % 10 == 0) i++;

  // debug2(sum, i);

  if (sum % 10 == 0 && i < n) sum -= s[i];

  if (sum % 10 == 0) outl(0);
  else outl(sum);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


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

/*int n;
  cin >> n;
  vector<int> h(n);*/

int main() {

    string s;
    cin >> s;

    if(s == "SUN"){
        cout << 7 << endl;
    }else if(s == "MON"){
        cout << 6 << endl;
    }else if(s == "TUE"){
        cout << 5 << endl;
    }else if(s == "WED"){
        cout << 4 << endl;
    }else if(s == "THU"){
        cout << 3 << endl;
    }else if(s == "FRI"){
        cout << 2 << endl;
    }else if(s == "SAT"){
        cout << 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int q = sc.nextInt();
		String s = sc.next();

		int[] t = new int[n + 1];
		for (int i = 0; i < n - 1; i++) {
			t[i + 1] = t[i] + (s.substring(i, i + 2).equals("AC") ? 1 : 0);
		}
		for (int i = 0; i < q; i++) {
			int l = sc.nextInt();
			int r = sc.nextInt();
			l--;
			r--;
			int ans = t[r] - t[l];
			System.out.println(ans);
		}
	}
}


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

using namespace std;
#define X first
#define Y second
typedef pair<int,int> P;
const int MAXN=1e5+10,INF=1<<27;
int n,m,x,y,z,dist[MAXN];
set<int> s[MAXN];//±ØÐëÒªÓÃset½øÐÐ´æ´¢£¬ÒòÎª¿ÉÄÜdist×îÐ¡Ê±ÓÐ¶àÖÖ¹«Ë¾¹©Ñ¡Ôñ 
vector<P> G[MAXN];

struct cmp
{
	bool operator() (const P& a,const P& b)
	{return a.X!=b.X?a.X>b.X:a.Y<b.Y;}
};

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d%d",&x,&y,&z);
		G[x].push_back(P(y,z));G[y].push_back(P(x,z));
	}
	
	priority_queue<P,vector<P>,cmp > q;
	for(int i=2;i<MAXN;i++) dist[i]=INF;
	dist[1]=0;q.push(P(0,1));
	while(!q.empty())
	{
		P t=q.top();q.pop();
		int u=t.Y,cost=t.X,tmp;
		if(cost>dist[u]) continue;
		for(int i=0;i<G[u].size();i++)
		{
			int v=G[u][i].X,col=G[u][i].Y;
			tmp=dist[u]+(!s[u].count(col));
			if(tmp==dist[v]) s[v].insert(col);
			else if(tmp<dist[v])
			{
				s[v].clear();s[v].insert(col);
				dist[v]=tmp,q.push(P(dist[v],v));
			}
		}
	}
	printf("%d",(dist[n]==INF)?-1:dist[n]);
	return 0;
}

Measured memory_bytes: 23412
#include <bits/stdc++.h>
#define FOR(I,X,Y) for(int I=X;I<Y;I++)
#define REP(I,X,Y) for(int I=Y-1;I>=X;I--)
#define INF 1000000007
using namespace std;

vector<int> pow2{1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768,65536,131072,262144,524288,1048576,2097152,4194304,8388608,16777216,33554432,67108864,134217728,268435456,536870912};
vector<long long> factorial(2,1);
int nckmodp(int n,int k,int p){
  if(n < k || n <= 0 || k < 0)return 0;
  while(factorial.size() <= n){
    long long i = factorial.size();
    factorial.push_back(i*factorial[i-1]%p);
  }
  long long n1 = factorial[n],n2 = factorial[k],n3 = factorial[n-k];
  vector<long long> a2,a3;
  FOR(i,0,pow2.size()){
    a2.push_back(n2);
    a3.push_back(n3);
    n2 = (n2*n2)%p;
    n3 = (n3*n3)%p;
  }
  n2 = 1;
  n3 = 1;
  FOR(i,0,pow2.size()){
    if(pow2[i]&(p-2)){
      n2 *= a2[i];
      n3 *= a3[i];
      n2 %= p;
      n3 %= p;
    }
  }
  return (n1*n2%p)*n3%p;
}

int main(){
  int n,N,d,M = 0,m = INF;
  set<int> s;
  cin >> n;
  int a[n+1];
  FOR(i,0,n+1){
    cin >> a[i];
    if(s.count(a[i]))N = a[i];
    s.insert(a[i]);
  }
  FOR(i,0,n+1){
    if(N == a[i]){
      m = min(m,i);
      M = max(M,i);
    }
  }
  d = M - m;
  FOR(i,1,n+2){
    if(i == 1)cout << n << endl;
    else cout << ((nckmodp(n+1,i,INF) - nckmodp(n-d,i-1,INF))%INF+INF)%INF << endl;
  }
}


Measured memory_bytes: 7156
import sys,collections;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

n = I()
A1 = Is()
A2 = Is()
ans = 0
for i in range(1,n+1):
    ans = max(ans,sum(A1[:i]+A2[i-1:]))
print(ans)

Measured memory_bytes: 3436
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll price[102];
ll weight[102];
void knap2(ll n, ll c) {
	ll dp[n + 1][c + 1];
	memset(dp, 0, sizeof(dp));
	for (int i = 0; i <= n; i++)
		dp[i][0] = 0;
	for (int i = 0; i <= c; i++)
		dp[0][c] = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= c; j++) {
			dp[i][j] = dp[i - 1][j];
			if (weight[i - 1] <= j)
				dp[i][j] = max(dp[i][j] , price[i - 1] + dp[i - 1][j - weight[i - 1]]);
		}
	}
	cout << dp[n][c];
	return;
}

int main() {
	ll items, capacity;
	cin >> items >> capacity;
	for (ll i = 0; i < items; i++)
		cin >> weight[i] >> price[i];
	knap2(items, capacity);
	return 0;
}

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

int main()
{
    string stra, strc;
    cin >> stra;
    strc = stra;
    for (int i = 0; i < stra.size(); i++){
        strc.at(i) = 'x';
    }
    cout << strc << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
//#include <stdlib.h>
//#include <string.h>
//#include <limits.h>
//#include <math.h>

int main() {
  int a, b;
  scanf("%d%d", &a, &b);
  if (a <= 8 && b <= 8) printf("Yay!\n");
  else printf(":(\n");
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdio>

using namespace std;

int h[12][12];
int n;
int sum[2][12];

int main()
{
  while(true)
  {
    for(int i = 0; i < 12; i++)
    {
      for(int j = 0; j < 12; j++)
        h[i][j] = 0;
    }
    scanf("%d", &n);
    if(!n)
      break;
    for(int i = 0; i < n; i++)
    {
      for(int j = 0; j < n; j++)
        scanf("%d", &h[i][j]);
    }
    for(int i = 0; i <= n; i++)
    {
      for(int j = 0; j <= n; j++)
      {
        printf("%5d", h[i][j]);
        h[i][n] += h[i][j];
        if(j != n)
        h[n][j] += h[i][j];
      }
      printf("\n");
    }
  }
  return 0;
}

Measured memory_bytes: 1204
/*input
615
*/
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef vector<pi> vpi;
typedef vector<vpi> vpii;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<pd> vpd;
typedef vector<bool> vb;
typedef vector<vb> vbb;
typedef std::string str;
typedef std::vector<str> vs;

#define x first
#define y second
#define debug(...) cout<<"["<<#__VA_ARGS__<<": "<<__VA_ARGS__<<"]\n"

const int MOD = 1000000007;
const ll INF = std::numeric_limits<ll>::max();
const int MX = 100101;
const ld PI = 3.14159265358979323846264338327950288419716939937510582097494L;

template<typename T>
pair<T, T> operator+(const pair<T, T> &a, const pair<T, T> &b) { return pair<T, T>(a.x + b.x, a.y + b.y); }
template<typename T>
pair<T, T> operator-(const pair<T, T> &a, const pair<T, T> &b) { return pair<T, T>(a.x - b.x, a.y - b.y); }
template<typename T>
T operator*(const pair<T, T> &a, const pair<T, T> &b) { return (a.x * b.x + a.y * b.y); }
template<typename T>
T operator^(const pair<T, T> &a, const pair<T, T> &b) { return (a.x * b.y - a.y * b.x); }

template<typename T>
void print(vector<T> vec, string name = "") {
	cout << name;
	for (auto u : vec)
		cout << u << ' ';
	cout << '\n';
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	vb galima(1e6 + 107, false);

	vi sk = {100, 101, 102, 103, 104, 105};

	galima[0] = true;

	for (int i = 0; i < 6; ++i)
	{
		for (int j = 0; j <= (int)1e6; ++j)
		{
			if (galima[j]) galima[j + sk[i]] = true;
		}
	}

	int x;
	cin >> x;
	printf(galima[x] ? "1" : "0");
}

/* Look for:
* special cases (n=1?)
* overflow (ll vs int?)
* the exact constraints (multiple sets are too slow for n=10^6 :( )
* array bounds
*/


Measured memory_bytes: 384