akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;

int main()
{

    ll n,m;
    cin>>n>>m;

    ll arr[n+1];

    for(ll i=0;i<n;i++)cin>>arr[i];

    map <ll,ll> mp;

    for(ll i=0;i<m;i++)
    {
        ll a,b;
        cin>>a>>b;
        mp[b]+=a;
    }

    sort(arr,arr+n);

    for(ll i=0;i<n;i++)
    {

        auto it = mp.end();
        if(mp.size()==0)continue;
        it--;
        if(it->first > arr[i]){
        arr[i] = it->first;
        it->second--;
        if(it->second == 0)
        {
            mp.erase(it->first);
        }
        }
        //cout<<arr[i]<<" ";
    }//cout<<endl;
    ll ans = 0;
    for(ll i=0;i<n;i++)ans+=arr[i];

    cout<<ans<<endl;

}


Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
static const int MOD = 1000000007;
using ll = long long;
int main(){
    int a[5];
    int k;
    for(int i=0; i<5; i++){
        cin>>a[i];
    }
    cin>>k;
    int flag=0;
    for(int i=0; i<4; i++){
        for(int j=i+1; j<5; j++){
           if (a[j]-a[i]>k){
            flag=1;
           }
        }
    }
    if ((flag==1) ? cout<<":("<<endl : cout<<"Yay!"<<endl);
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    final Scanner sc = new Scanner(System.in);

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

    private void run() {
        int k = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();

        for (int i = a; i <= b; i++) {
            if (i % k == 0) {
                System.out.println("OK");
                return;
            }
        }
        System.out.println("NG");
    }
}


Measured memory_bytes: 35736
import java.util.Arrays;
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int a[]=new int[3];
		a[0]=scan.nextInt();	
		a[1]=scan.nextInt();	
		a[2]=scan.nextInt();	
	Arrays.sort(a);
	if(a[0]==5&&a[1]==5&&a[2]==7) {
		System.out.println("YES");
	}
	else {
		System.out.println("NO");
	}
	}
	}


Measured memory_bytes: 21076
//Jai Bhole Ki
#include <bits/stdc++.h>
using namespace std;
#define fast static int fastline = []() { std::ios::sync_with_stdio(false); cin.tie(NULL); return 0; }();
#define ll long long
#define LL unsigned ll
#define pb push_back
#define pi pair<ll,ll>
#define debug(x) cout<<x<<"\n";
#define debug cout<<"debugged\n";
#define minval -2e9
#define maxval 2e9
long double PI =3.14159265358979323846;
 
const ll M=1e9+7;
const ll inf=1e18;
const ll ms=2e5+5;
fast;
ll ans;
ll n,chk,a,b;
void solve()
{
    cin>>n;ll ar[n];
    for(int i=0;i<n;i++)
        cin>>ar[i];
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
            ans+=ar[i]*ar[j];
    }
    cout<<ans<<endl;
}

int main()
{
 // freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
   // int t;cin>>t;while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        for(;;){
            int h = sc.nextInt();
            int w = sc.nextInt();
            if ((h == 0) && (w == 0)) break;
            sc.nextLine();
            for(int i=0 ; i<h ; i++){
                for(int j=0 ; j<w ; j++){
                    System.out.print("#");
                }
                System.out.println();
            }
            System.out.println();
        }
    }
}


Measured memory_bytes: 33352
#include <iostream>
    using namespace std;
     
    int main(){
        int n;
        string s;
        cin >> n >> s;
        int r = 0;
        for(int i = 0; i < n; i++){
            if(s.substr(i, 3) == "ABC"){
                r++;
            }
        }
        cout << r << '\n';
    }	

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

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

int main()
{
	while (true) {
		int n, m, p;

		cin >> n >> m >> p;

		if (n == 0 && m == 0 && p == 0) {
			break;
		}

		vector<vector<vector<int>>> grid(n, vector<vector<int>>(n, vector<int>(n, -1)));
		vector<int> x(p), y(p);

		rep(i, p) {
			cin >> x[i] >> y[i];
			x[i]--;
			y[i]--;
		}

		rep(i, p) {
			int z = 0;

			while (grid[x[i]][y[i]][z] != -1) {
				z++;
			}

			grid[x[i]][y[i]][z] = i % 2;

			rep(j, 13) {
				int seq = 1;
				int nx = x[i];
				int ny = y[i];
				int nz = z;

				while (true) {
					nx += dx[j];
					ny += dy[j];
					nz += dz[j];

					if (nx < 0 || ny < 0 || nz < 0 || nx >= n || ny >= n || nz >= n) {
						break;
					}

					if (grid[nx][ny][nz] == grid[x[i]][y[i]][z]) {
						seq++;
					}
					else {
						break;
					}
				}

				if (seq >= m) {
					if (grid[x[i]][y[i]][z] == 0) {
						cout << "Black " << i + 1 << endl;
						goto End;
					}
					else {
						cout << "White " << i + 1 << endl;
						goto End;
					}
				}

				nx = x[i];
				ny = y[i];
				nz = z;

				while (true) {
					nx -= dx[j];
					ny -= dy[j];
					nz -= dz[j];

					if (nx < 0 || ny < 0 || nz < 0 || nx >= n || ny >= n || nz >= n) {
						break;
					}

					if (grid[nx][ny][nz] == grid[x[i]][y[i]][z]) {
						seq++;
					}
					else {
						break;
					}
				}

				if (seq >= m) {
					if (grid[x[i]][y[i]][z] == 0) {
						cout << "Black " << i + 1 << endl;
						goto End;
					}
					else {
						cout << "White " << i + 1 << endl;
						goto End;
					}
				}
			}
		}

		cout << "Draw" << endl;
	End:
		;
	}

	return 0;
}

Measured memory_bytes: 3140
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);++i)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
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; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
// int d[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  int n;
  cin >> n;
  vector<ll>x(n),y(n),p(n); 
  rep(i,n) cin >> x[i] >> y[i] >> p[i]; 
  vector<ll>ans(n+1,1e18);
  
  //前計算パート．
  //縦の路線の選び方をbitで持ったときの集落iの最短移動距離をdistx[bit][i]とする．
  vector<vector<ll>> distx(1<<n,vector<ll>(n));
  vector<vector<ll>> disty(1<<n,vector<ll>(n));
  for(int bit=0;bit<(1<<n);bit++){
    rep(i,n){
      //大通りとの距離
      distx[bit][i]=abs(x[i]);
      disty[bit][i]=abs(y[i]);
      rep(j,n){
        if(bit&(1<<j)){
          distx[bit][i]=min(distx[bit][i],abs(x[i]-x[j]));
          disty[bit][i]=min(disty[bit][i],abs(y[i]-y[j]));
        }
      }
    }
  }
  for(int bit=0;bit<(1<<n);++bit){
    int cnt = __builtin_popcount(bit);
    for(int i=bit;i>=0;--i){
      i&=bit;//bitで表せる選び方の部分集合i
      ll cost = 0;
      rep(j,n){
        if(!(bit&(1<<j))){
          // bitに含まれる場合は距離0
          cost += min(distx[i][j],disty[bit-i][j])*p[j];
        }
      }
      ans[cnt]=min(ans[cnt],cost);
    }
  }
  rep(i,n+1) cout << ans[i] << endl;
  return 0;
}


Measured memory_bytes: 12956
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int n;
int a[100005];
int b[100005];

int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for(int i = 1; i <= n + 1; i++)
    cin >> a[i];
  for(int i = 1; i <= n; i++)
    cin >> b[i];
  long long ans = 0;
  for(int i = 1; i <= n + 1; i++) {
    if(i > 1) {
      int kill = min(a[i], b[i - 1]);
      a[i] -= kill;
      b[i - 1] -= kill;
      ans += kill;
    }
    int kill = min(a[i], b[i]);
    a[i] -= kill;
    b[i] -= kill;
    ans += kill;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include <string> 
#include <vector>  
#include<math.h>

#define INF 1000000000
using namespace::std;



long Lmax(long x, long y) {
	if (x > y)return x;
	return y;
}

int max(int x, int y) {
	if (x > y)return x;
	return y;
}

long Lmin(long x, long y) {
	if (x < y)return x;
	return y;
}


int min(int x, int y) {
	if (x < y)return x;
	return y;
}

int abs(int x) {
	if (x < 0) {
		return -x;
	}
	return x;
}

int solve(vector<vector<int>> v,int K) {
	vector<vector<int>> map;
	map.resize(4 * K);
	for (int i = 0; i < map.size(); i++) {
		for (int j = 0; j < 4 * K; j++) {
			map[i].push_back(0);
		}
	}

	for (int i = 0; i < v.size(); i++) {
		for (int j = 0; j < 4 * K; j += K) {
			for (int a = 0; a < 4 * K; a += K) {
				int x = v[i][0] % K + j + 1;
				int y = v[i][1] % K + a + 1;
				if ((x + y) % (2 * K) == (v[i][0] + 1 + v[i][1] + 1) % (2 * K)) {
					if (x + K < 4 * K&&y + K < 4 * K) {
						map[x][y]++;
						map[x][y + K]--;
						map[x + K][y]--;
						map[x + K][y + K]++;
					}
				}
			}
		}
	}

	for (int i = 0; i < map.size(); i++) {
		for (int j = 1; j < map.size(); j++) {
			map[i][j] += map[i][j - 1];
		}
	}

	for (int j = 0; j < map.size(); j++) {
		for (int i = 1; i < map.size(); i++) {
			map[i][j] += map[i-1][j];
		}
	}

	int ans = -2000;
	for (int i = 0; i < map.size(); i++) {
		for (int j = 0; j < map.size(); j++) {
			ans = max(ans, map[i][j]);
		}
	}
	return ans;
}




int main() {

	int N, K,X,Y ,x,y,pr;
	string s,t,tt,ss;
	char c;

	cin >>N>>K;
    vector<vector<int>> v;
	v.resize(N);
	for (int i = 0; i < N; i++) {
		cin >> x >> y>> c;
		v[i].push_back(x);
		v[i].push_back(y);
		if (c == 'W') {
			v[i].push_back(0);
		}
		else {
			v[i].push_back(1);
		}
	}

	for (int i = 0; i < v.size(); i++) {
		if (v[i][2] == 1) {
			v[i][2] = 0;
			v[i][1] += K;
		}
		v[i][0] = v[i][0] % (2 * K);
		v[i][1] = v[i][1] % (2 * K);
	}

	cout << solve(v,K)<< endl;
	return 0;
}




Measured memory_bytes: 75392
#include <stdio.h>
int min(int a,int b){
if(a<b)return a;
return b;
}
int main(){
int n,k,ans=1;
scanf("%d%d",&n,&k);
for(int i=0;i<n;i++){
ans=min(ans+k,ans*2);
}
printf("%d\n",ans);
}

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

int main()
{
    ios_base::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    long long arr[n];
    for(int i =0 ;i < n;i++)
    {
        cin >> arr[i];
    }
    priority_queue<long long> pq;
    for(int i = 0;i < n;i++)
    {
        cin >> arr[i];
        int j = 0;
        while(true)
        {
            if((arr[i]>>j) - (arr[i]>>(j + 1)) == 0)
                break;
            pq.push((arr[i]>>j) - (arr[i]>>(j + 1)));
            j++;
        }
    }
    long long sum = 0ll;
    sum = accumulate(arr, arr + n, 0ll);
    while(m-- and pq.size() > 0)
    {
        sum -= pq.top();
        pq.pop();
    }
    cout << max(sum, 0ll);
    return 0;
}



Measured memory_bytes: 35940
# 初期入力
import sys
input = sys.stdin.readline
L,R,d = (int(i) for i in input().split())
count_L =0
count_R =0
for i in range(1,101):
    if i*d <L:
        count_L +=1
    
    if i*d <=R:
        count_R +=1
ans =count_R -count_L
print(ans)

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

#define ll             long long
#define sf             scanf
#define pf             printf
#define nl             printf("\n")
#define TEST           int Test;cin>>Test;for(int _t=1;_t<=Test;_t++)

using namespace std;



int main()
{
	ll x,k,d,ans,rest;
	sf("%lld %lld %lld",&x,&k,&d);
	if(x<0) x = -x;
	if(k<=x/d){
		ans = x-(k*d);
	}
	else{
		rest = x/d;
		x = x - (rest*d);
		k = k-rest;
		if(k%2==0) ans = x;
		else ans = d-x;
	}
	pf("%lld\n",ans);
		
	return 0;
}


Measured memory_bytes: 3796
N=int(input())
H=list(map(int, input().split()))

flg=True
temp_max=0

for i in range(N-1):
    if H[i] - H[i+1] >= 2:
        flg=False
        break
        
    if temp_max - H[i+1] >= 2:
        flg=False
        break
    elif temp_max<H[i+1]:
        temp_max = H[i+1]
if flg:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 14252
import sys
from math import ceil

input = sys.stdin.readline

def main():
    N, H = map(int, input().split())
    A, B = [], []
    
    for i in range(N):
        a, b = map(int, input().split())
        A.append(a)
        B.append(b)
        
    A.sort(reverse=True)
    B.sort(reverse=True)
    
    a = A[0]
    ans = 0
    
    for b in B:
        if a > b or H <= 0: break
        H -= b
        ans += 1
        
    if H > 0: ans += ceil(H / a)
    
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 11316
// यथा चतुर्भिः कनकं परीक्ष्यते निघर्षणच्छेदनतापताडनैः।
// तथा चतुर्भिः पुरुषः परीक्ष्यते त्यागेन शीलेन गुणेन कर्मणा॥
#include <bits/stdc++.h>
using namespace std;
#define lld long long int
#define M 1000000007
#define fors(i,n) for(int i=0;i<n;++i)
#define fore(i,a,b) for(int i=a;i<=b;++i)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define vv std::vector<int>
#define mapii std::map<int,int>
#define mpaci std::map<char,int>
#define umapii std::unordered_map<int,int>
#define umapci std::unordered_map<char,int>
#define seti std::set<int>
#define useti std::unordered_set<int>
#define qi std::queue<int>
#define qc std::queue<char>
#define sti std::stack<int>
#define stc std::stack<char>
#define endl "\n"
#define test(i) cout<<i<<endl
#define tests(i) cout<<"i: "<<i<<endl;
#define itrt int t; cin>>t; fors(i,t)
#define itr1 int t; cin>>t;
#define ff first
#define ss second
#define pb push_back
#define vmp make_pair
#define ppb pop_back
#define sorta(a,n) sort(arr,arr+n)
#define sortv(x) sort(x.begin(),x.end())
#define all(x) x.begin(),x.end() 
#define printv(v) for(auto x: v){ cout<< x << " ";}
#define pi 3.14159265358979323846
#define setprc(x) setprecision(x)
void file(){
    #ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}
bool sortdesk(const pair<int,int> &a, const pair<int,int> &b){return a.ff>b.ff;}
bool sortdesv(const pair<int,int> &a, const pair<int,int> &b){return a.ss>b.ss;}
bool sortascv(const pair<int,int> &a, const pair<int,int> &b){return a.ss<b.ss;}
bool sortasck(const pair<int,int> &a, const pair<int,int> &b){return a.ff<b.ff;}
bool is_prime(int n){if(n==1){return false;}int i=2;while(i*i<=n){if(n%i==0){return false;}i+=1;}return true;}
int gcd(int a, int b){if (b == 0){return a;} return gcd(b, a % b);}
int cntdiv(int n){int cnt=0;for(int i=1;i<=sqrt(n);++i){if(n%i==0){if(n/i==i)++cnt;else{cnt = cnt + 2;}}}return cnt;}
lld posnegmod(lld a,lld b){//return (x%mod+mod)%mod;
long long int r = a % b;
    return r < 0 ? r + b : r;
}
// cout<<fixed<<setprecision(20)
// lld fact(lld n);
// lld nCr(lld n,lld r){return fact(n) / (fact(r) * fact(n - r));}
// lld fact(lld n){ lld res = 1; for(lld i = 2; i <= n; i++){res = res * i;}return res;} 
const int maxi = 1e6+10;
vector<lld> v[maxi];
vector<lld> h(maxi);
vector<long long> a(maxi,0);
lld res=0;
void dfs(int x){
    if(a[x]){
        return;
    }
    a[x]=1;
    int flag=1;
    for(int i:v[x]){
        if(h[x]<=h[i]){
            flag=0;
            break;
        }
    }
    if(flag){
        ++res;
    }
}

void test_case(){
    int n,m;
    cin>>n>>m;
    h.resize(n);
    for(int i=0;i<n;++i){
        cin>>h[i];
    }
    for(int i=0;i<m;++i){
        int x,y;
        cin>>x>>y;
        --x;--y;
        v[x].pb(y);
        v[y].pb(x);
    }
    for(int i=0;i<n;++i){
        dfs(i);
    }
    cout<<res;
    // for(auto x:v){
    //     int flag=1;
    //     for()
    // }
}

int main(){
    fastio;
    file();
    int T=1;
    // int T;
    // cin>>T;
    for(int nr=1;nr<=T;++nr) {
        // cout<<"Case #"<<nr<<": ";
        test_case();
    }
}


Measured memory_bytes: 45704
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <cstring>
#include <string>
#include <cctype>
#include <cassert>
#include <queue>

using namespace std;

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,b,e) for(int i = (b); i <= (e); i++)
#define INF (1001001001)
#define EPS (1e-15)

#define pr(x) do{cerr << (#x) << " = " << (x) << endl;}while(0)
#define pri(x,i) do{cerr << (#x) << "[" << i << "] = " << (x[i]) << endl;}while(0)
#define pra(x,n) rep(__i,n) pri(x,__i);
#define prar(x,b,e) repr(__i,b,e) pri(x,__i);

typedef long long ll;
typedef pair<int, int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;

ll MOD = 1000000007;

int in() {
	int a;
	scanf("%d ", &a);
	return a;
}

bool visit(vector<vint> &G, vint &color, int pos, int c) {
	color[pos] = c;
	for (int x : G[pos]) {
		if (color[x] == c) return false;
		if (color[x] == 0) {
			if (! visit(G, color, x, 3 - c)) return false;
		}
	}
	return true;
}

int main() {
	int N = in();
	int M = in();
	vector<vint> G(N);
	rep(i,M) {
		int A = in() - 1;
		int B = in() - 1;
		G[A].pb(B);
		G[B].pb(A);
	}
	vint color(N, 0);
	queue<pint> Q;
	Q.push(mp(0, 1));
	bool suc = true;
	int twos = 0;
	while(! Q.empty()) {
		pint p = Q.front();
		Q.pop();
		if (color[p.first] == 3 - p.second) {
			suc = false;
		}
		if (color[p.first] == 0) {
			color[p.first] = p.second;
			if (p.second == 2) twos++;
			for (int x : G[p.first]) if (color[x] == 0) {
				Q.push(mp(x, 3 - p.second));
			}
		}
	}
	HOGE:;
	if (suc) {
		pr("succeeded");
		cout << max(0ll, (ll)twos * (N - twos) - M) << endl;
	}
	else {
		pr("failed");
		cout << max(0ll, (ll)N * (N - 1) / 2 - M) << endl;
	}
	return 0;
}


Measured memory_bytes: 6272
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    import itertools
    n,k=map(int, input().split())
    sunukel=[False]*n
    for i in range(k):
        d=int(input())
        l=list(map(int, input().split()))
        for j in l:
            if sunukel[j-1]==False:
                sunukel[j-1]=True
    print(n-sum(sunukel))
resolve()

Measured memory_bytes: 67600
def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
s="keyence"
ss=input()
a=7
b=7
for i in range(7):
 if ss[i]!=s[i]:
    a=i
    break
for i in range(7):
 if ss[-(i+1)]!=s[-(i+1)]:
    b=i
    break

if a+b>=7:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 38408
#include <bits/stdc++.h>
using namespace std;
 
int N, M;
int A[3];
vector<int> G[51];
bool used[51];
bool dp[101][51][51];  // a step, b start, c goal
 
int main(){
 
  cin>>N>>M;
  for(int i=0;i<3;i++)cin>>A[i];
  for(int i=0;i<M;i++){
    int f,t;
    cin>>f>>t;
    f--;t--;
    G[f].push_back(t);
  }
 
  for(int i=0;i<N;i++)
    dp[0][i][i] = true;
  for(int i=1;i<101;i++){
    for(int j=0;j<N;j++){
      for(int k=0;k<N;k++){
        if(dp[i-1][j][k]){
          for(int to : G[k]){
            dp[i][j][to] = true;
          }
        }
      }
    }
  }
   
  used[N-1] = true;
  for(int ite=1;;ite++){
    bool ok = false;
    vector<int> idx;
    for(int i=0;i<N;i++){
      if(used[i])continue;
      int cnt = 0;
      for(int j=0;j<3;j++){
        for(int k=0;k<N;k++){
          if(dp[A[j]][i][k] && used[k]){
              cnt++;
              break;
          }
        }
      }
      // OK
      if(cnt == 3){
        ok=true;
        idx.push_back(i);
      }
    }
    if(ok){
      for(int i : idx) used[i]=true;
      if(used[0]){
        cout<<ite<<endl;
        return 0;
      }
    }
    else{
        cout<<"IMPOSSIBLE"<<endl;
        return 0;
    }
  }
}

Measured memory_bytes: 3416
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD 1000000007
#define MOD2 998244353
#define MOD3 1000000009
#define PI acos(-1)
#define eps (1e-8)
#define INF (1e18)
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
//ifstream cinn("in.in");ofstream coutt("out.out");
int poww(const int &a,int b,const int &m=MOD){if(b==0)return 1;int x=poww(a,b/2,m);x=x*x%m;if(b&1)x=x*a%m;return x;}
int ceil(const int &a,const int &b){return (a+b-1)/b;}
////Read:
//Check corner cases, n==1;
//
////Some function:
//__builtin_popcountll(), is_sorted(),

int n;
int a[15];
int x[15][15],y[15][15];

signed main(){
    FASTER;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        for(int j=0;j<a[i];j++){
            cin>>x[i][j]>>y[i][j];
            x[i][j]--;
        }
    }
    
    int ans=0;
    for(int ii=1;ii<(1<<n);ii++){
        bool ok=1;
        for(int i=0;i<n;i++){
            if((ii&(1<<i))==0)continue;
            for(int j=0;j<a[i];j++){
                if( ((ii>>x[i][j])&1)^y[i][j] )ok=0;
                //    present/absent ^ liar/notLiar
            }
        }
        if(ok)ans=max(ans,(int)__builtin_popcountll(ii));
    }
    
    cout<<ans;
}



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

int main() {
	int n;
	cin >> n;
	if (n % 2 == 0)cout << n * n / 4 << endl;
	else cout << (n - 1) * (n + 1) / 4 << endl;
}

Measured memory_bytes: 256
def examA():
    a, b = LI()
    if a>0:
        ans = "Positive"
        print(ans)
        return
    if b>=0:
        ans = "Zero"
    else:
        judge = b-a
        if judge%2==1:
            ans = "Positive"
        else:
            ans = "Negative"
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

if __name__ == '__main__':
    examA()


Measured memory_bytes: 38256
#include <bits/stdc++.h>
#include <ext/hash_map>
#include <ext/numeric>

using namespace std;
using namespace __gnu_cxx;

#define REP(i,n) for( (i)=0 ; (i)<(n) ; (i)++ )
#define rep(i,x,n) for( (i)=(x) ; (i)<(n) ; (i)++ )
#define REV(i,n) for( (i)=(n) ; (i)>=0 ; (i)-- )
#define FORIT(it,x) for( (it)=(x).begin() ; (it)!=(x).end() ; (it)++ )
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define rforeach(it,c) for(__typeof((c).rbegin()) it=(c).rbegin();it!=(c).rend();++it)
#define foreach2d(i, j, v) foreach(i,v) foreach(j,*i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define SZ(x) ((int)(x).size())
#define MMS(x,n) memset(x,n,sizeof(x))
#define mms(x,n,s) memset(x,n,sizeof(x)*s)
#define pb push_back
#define mp make_pair
#define NX next_permutation
#define UN(x) sort(all(x)),x.erase(unique(all(x)),x.end())
#define CV(x,n) count(all(x),(n))
#define FIND(x,n) find(all(x),(n))-(x).begin()
#define ACC(x) accumulate(all(x),0)
#define PPC(x) __builtin_popcountll(x)
#define LZ(x) __builtin_clz(x)
#define TZ(x) __builtin_ctz(x)
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define low(x,i) lower_bound(all(x),i)
#define upp(x,i) upper_bound(all(x),i)
#define NXPOW2(x) (1ll << ((int)log2(x)+1))
#define PR(x) cout << #x << " = " << (x) << endl ;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pii;

const int OO = (int) 2e9;
const double eps = 1e-9;

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
//	freopen("in.txt", "rt", stdin);
//	freopen("out.txt", "wt", stdout);
#endif
	ll a, b, c;
	cin >> a >> b >> c;
	if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) {
		cout << 0 << endl;
	} else {
		cout << min(a * b, min(a * c, b * c)) << endl;
	}
	return 0;
}


Measured memory_bytes: 256
rangeNum = int(input())
n = list(map(int, input().split()))

for ni in range(rangeNum):
    if n[ni]%2 == 0:
        if n[ni]%3 == 0:
            continue
        elif n[ni]%5 == 0:
            continue
        else:
            print("DENIED")
            exit()
    else:
        continue
print("APPROVED")

Measured memory_bytes: 3060
import sys
from itertools import accumulate

readline = sys.stdin.readline


def eratosthenes(n):
    is_prime = [True] * n
    is_prime[0] = is_prime[1] = False
    is_prime[4::2] = [False] * ((n-1) // 2 - 1)
    m = int(n**.5) + 1
    for i in range(3, m, 2):
        if is_prime[i]:
            is_prime[i*i::2*i] = [False] * ((n - i*i - 1) // (2*i) + 1)
    # return [2] + [i for i in range(3, n, 2) if is_prime[i]]
    return is_prime


prime = eratosthenes(10**5+1)
num = (True if p and prime[(i+1)//2] else False for i, p in enumerate(prime))
cusum = [0] + list(accumulate(num))
Q = int(readline())
for _ in range(Q):
    l, r = map(int, readline().split())
    print(cusum[r+1] - cusum[l])


Measured memory_bytes: 8164
// AOJ 1222: Telescope
// 2017.10.17 bal4u@uu

#include <stdio.h>
#include <string.h>
#include <math.h>

#define PI2 6.283185307179586476925286766559  // 2*PI

double p[42];
double area[42][42][42];
double dp[42][42][42];

int main()
{
	int n, m, i, j, k, l;
	double ans, a;

	while (scanf("%d%d", &n, &m) && n > 0) {
		for (i = 0; i < n; i++) scanf("%lf", p+i);
//		memset(area, 0, sizeof(area));
		for (i = 0; i < n; i++) for (j = i+1; j < n; j++) for (k = j+1; k < n; k++)
			area[i][j][k] = 0.5*(sin((p[j]-p[i])*PI2) + sin((p[k]-p[j])*PI2) + sin((p[i]-p[k])*PI2));

		for (i = 0; i < n; i++) for (j = i+1; j < n; j++) for (k = 2; k <= m; k++) dp[i][j][k] = -1;
		for (i = 0; i < n; i++) for (j = i+1; j < n; j++) dp[i][j][2] = 0;
		ans = 0;
		for (i = 0; i < n; i++) for (l = 2; l < m; l++) for (j = i+1; j < n; j++) for (k = j+1; k < n; k++) {
			if (dp[i][j][l] < 0) continue;
			a = dp[i][j][l] + area[i][j][k];
			if (a > dp[i][k][l+1]) {
				dp[i][k][l+1] = a;
				if (l+1 <= m && a > ans) ans = a;
			}
		}
		printf("%.6lf\n", ans);
    }
	return 0;
}

Measured memory_bytes: 2804
import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner inp = new Scanner(System.in);
        String x = inp.next();
        String y = inp.next();
        int xx = Integer.parseInt(x, 16);
        int yy = Integer.parseInt(y, 16);
        if (xx > yy) System.out.println(">");
        else if (xx == yy) System.out.println("=");
        else System.out.println("<");
    }
}

Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int p[200005];

int root(int x) {return p[x] < 0 ? x : p[x] = root(p[x]);}

void mer(int x, int y) {
    if ((x = root(x)) == (y = root(y))) return;
    if (p[x] > p[y]) swap(x, y);
    p[x] += p[y];
    p[y] = x;
}

int main() {
    ios::sync_with_stdio(false);
    int n, z = 0;
    vector<pair<int, pii>> c;
    pair<pii, int> a[100005] = {}, b[100005] = {};
    cin >> n;
    for (int i = 0; i <= n + n; i++) p[i] = -1;
    for (int i = 1; i <= n; i++) cin >> a[i].first.first >> a[i].first.second, b[i].first.first = a[i].first.second, b[i].first.second = a[i].first.first, a[i].second = b[i].second = i;
    sort(a + 1, a + n + 1); sort(b + 1, b + n + 1);
    for (int i = 1; i < n; i++) c.push_back({a[i + 1].first.first - a[i].first.first, {a[i].second, a[i + 1].second}}), c.push_back({b[i + 1].first.first - b[i].first.first, {b[i].second, b[i + 1].second}});
    sort(c.begin(), c.end());
    for (pair<int, pii> i : c) {
        int u = i.second.first, v = i.second.second, w = i.first;
        if (root(u) != root(v)) {
            mer(u, v);
            z += w;
        }
    }
    cout << z;
}


Measured memory_bytes: 8052
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

bool compare(P a, P b){
    return a.first + a.second < b.first + b.second;
}

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

    int n;
    cin >> n;
    vector<P> v(n);
    rep(i, n){
        int h, p;
        cin >> h >> p;
        v[i] = {h, p};
    }
    sort(ALL(v), compare);

    vector<vector<int>> dp(n + 1, vector<int>(n + 1, INF));
    dp[0][0] = 0;
    rep(i, n){
        for(int j = 0; j <= i; j++){
            dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
            if(dp[i][j] > v[i].first){
                continue;
            }
            dp[i+1][j+1] = min(dp[i+1][j+1], dp[i][j] + v[i].second);
        }
    }

    int ans = 0;
    rep(i, n + 1){
        if(dp[n][i] != INF){
            ans = i;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 195968
#include <iostream>

#define MAX 100100

using namespace std;

// 素数判定済み配列
bool prime[MAX];
// 累積和
int sum[MAX];

void calcPrime();
bool isPrime(int);

int main() {
    calcPrime();
    int q; cin >> q;

    for (int i = 0; i < q; ++i) {
        int l, r; cin >> l >> r;
        cout << (sum[r] - sum[l - 1]) << endl;
    }

    return 0;
}

void calcPrime() {
    for (int i = 0; i < MAX; ++i) prime[i] = true;
    prime[0] = prime[1] = false;

    for (int i = 2; i * i < MAX; ++i) {
        if (!prime[i]) continue;
        for (int j = i; j * i < MAX; ++j) {
            prime[i * j] = false;
        }
    }

    for (int i = 0; i < MAX; ++i) {
        sum[i] = sum[i - 1] + (isPrime(i) ? 1 : 0);
    }
}

bool isPrime(int x) {
    return prime[x] && prime[(x + 1) / 2];
}

Measured memory_bytes: 1152
from itertools import*
n = int(input())
s = [input() for i in range(n)]
s = [s[i][0] for i in range(n)]
d=[0]*128
for t in s:
    d[ord(t[0])]+=1
print(sum(p*q*r for p,q,r in combinations([d[ord(t)] for t in'MARCH'],3)))

Measured memory_bytes: 10672
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    val a: Int = sc.nextLine.toInt
    val b: Int = sc.nextLine.toInt
    val h: Int = sc.nextLine.toInt
    println((a + b) * h / 2)
  }
}


Measured memory_bytes: 25512
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<cstring>
#include<sstream>
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define lb(v,n) lower_bound(v.begin(),v.end(),n)
#define ub(v,n) upper_bound(v.begin(),v.end(),n)


////////////////////////////////////////////////////////////

int main(){
	int a,b,c,x,y;
	cin >> a >> b >> c >> x >> y;
	
	if(x < y ){
		swap(x,y);
		swap(a,b);
	}
	
	long ans = 0;
	if( a + b > c * 2  ){
		ans += c*y*2;
		
		ans += min((x-y)*a , (x-y)*c*2 );

	}
	else{
		ans += a*x + b*y;	
	}
	
	P(ans);

	ret 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{   char a[11],b[11],c[11];
    scanf("%s%s%s",a,b,c);
    printf("%c%c%c",'A'+(a[0]-'a'),'A'+(b[0]-'a'),'A'+(c[0]-'a'));
    return 0;
}


Measured memory_bytes: 128
program main
Implicit None
	integer(8)::n,i,pa(2),pb(2),qa(2),qb(2),s,e
	integer(8),allocatable::v(:),a(:),b(:)
	
	read*,n
	allocate(v(n))
	read*,v
	n =n/2
	allocate(a(n),b(n))
	
	if(minval(v) == maxval(v))then
		print"(i0)",n
		stop
	endif
	
	do i =1,n
		a(i) = v(2*i-1)
		b(i) = v(2*i)
	enddo
	
	call h1(a,n)
	call h1(b,n)
	
	pa = 0
	pb = 0
	qa = 0
	qb = 0
	
	s =1
	do i = 1,n
		if(a(i+1)/=a(i))then
			if(i-s+1 > pa(1))then
				pa(2) = pa(1)
				qa(2) = qa(1)
				pa(1) = i-s+1
				qa(1) = a(i)
				else if(pa(2) < i-s+1)then
				pa(2) = i-s+1
				qa(2) = a(i)
			endif
			s = i+1
		endif
	enddo
	
	s =1
	do i = 1,n
		if(b(i+1)/=b(i))then
			if(i-s+1 > pb(1))then
				pb(2) = pb(1)
				qb(2) = qb(1)
				pb(1) = i-s+1
				qb(1) = b(i)
				else if(pb(2) < i-s+1)then
				pb(2) = i-s+1
				qb(2) = b(i)
			endif
			s = i+1
		endif
	enddo
	
	e = pa(1)+pb(1)
	if(qa(1) == qb(1))then
		if(pa(1)+pb(2) < pa(2)+pb(1) .or. pb(2) == 0)then
			e = pa(2)+pb(1)
			else
			e = pa(1)+pb(2)
		endif
	endif
	
	print"(i0)",2*n-e
end program main

subroutine h1(a,n)
implicit None
	integer(8)::a(n),x
	integer(8)::n,i,ie,i0,i1,i2
	
	do i = n/2,1,-1
		x = a(i);ie = n + 1; i0 = i; i1 = i0 * 2
		do while(i1 < ie)
			i2 = i1 + 1
			if(i2 < ie .and. a(i1) < a(i2)) i1 = i2
			if(a(i1) > x)then
				a(i0) = a(i1);a(i1) = x
				else
				exit
			endif
			i0 = i1;i1 = i0 *2
		enddo
	enddo
	do ie = n,2,-1
		x = a(ie)
		a(ie) = a(1)
		a(1) = x
		i0 =1;i1 =2
		do while(i1 <ie)
			i2 = i1 +1
			if(i2 < ie .and. a(i1) < a(i2)) i1 = i2
			if(a(i1) > x)then
				a(i0) = a(i1);a(i1) = x
				else
				exit
			endif
			i0 = i1;i1 = i0 *2
		enddo
	enddo
end subroutine h1


Measured memory_bytes: 2816
#include <stdio.h>

int main(void) {
	int num;
	scanf("%d", &num);

	int L = num / 100;
	int R = num % 100;


	if (1 <= L && L <= 12) {
		if (1 <= R && R <= 12) {
			puts("AMBIGUOUS");
			return 0;
		}
	}

	if (1 <= L && L <= 12) {
		if (13 <= R || R == 0) {
			puts("MMYY");
			return 0;
		}
	}

	if (1 <= R && R <= 12) {
		if (13 <= L || L == 0) {
			puts("YYMM");
			return 0;
		}
	}

	puts("NA");

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std;
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
#define endl "\n"
inline bool EQ(double a, double b)
{
    return fabs(a - b) < 1e-9;
}
const int INF = 1 << 29;
typedef long long int ll;
inline int two(int n) { return 1 << n; }

inline int test(int n, int b) { return (n >> b) & 1; }
inline void set_bit(int &n, int b) { n |= two(b); }
inline void unset_bit(int &n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n)
{
    int res = 0;
    while (n && ++res)
        n -= n & (-n);
    return res;
}
template <class T>
void chmax(T &a, const T &b) { a = max(a, b); }
template <class T>
void chmin(T &a, const T &b) { a = min(a, b); }

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

    ll n, q, b, c1;
    cin >> n;
    ll a[n];
    ll c[100000 + 10], sum = 0;

    REP(i, 100000 + 10)
    c[i] = 0;
    REP(i, n)
    {
        cin >> a[i];
        c[a[i]]++;
        sum += a[i];
    }
    cin >> q;
    REP(i, q)
    {
        cin >> b >> c1;
        sum = sum - c[b] * b + c[b] * c1;
        c[c1] += c[b];
        c[b] = 0;
        cout << sum << endl;
    }

    return 0;
}

Measured memory_bytes: 5180
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

int main() {
  ll n;
  cin >> n;
  vector<ll> A(n);
  loop(i,0,n) cin >> A[i];
  map<ll, ll> M;
  for (auto &&a: A) {
    M[a-1]++;
    M[a]++;
    M[a+1]++;
  }
  ll max_ = 0;
  for (auto &&m: M) {
    if (max_ < m.second) {
      max_ = m.second;
    }
  }
  cout << max_ << endl;
  return 0;
}


Measured memory_bytes: 9676
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
using Graph = vector<vector<int>>;

int main() {
    // 頂点数と辺数
    int N, M; cin >> N >> M;

    // グラフ入力受取 (ここでは無向グラフを想定)
    Graph G(N);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    // BFS のためのデータ構造
    vector<int> dist(N, -1); // 全頂点を「未訪問」に初期化
    queue<int> que;
    vector<int> ans(N+M,-1);
    // 初期条件 (頂点 0 を初期ノードとする)
    dist[0] = 0;
    que.push(0); // 0 を橙色頂点にする

    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        int v = que.front(); // キューから先頭頂点を取り出す
        que.pop();

        // v から辿れる頂点をすべて調べる
        for (int nv : G[v]) {
            if (dist[nv] != -1) continue; // すでに発見済みの頂点は探索しない
            ans[nv]=v;
            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            dist[nv] = dist[v] + 1;
            que.push(nv);
        }
    }

    // 結果出力 (各頂点の頂点 0 からの距離を見る)
    cout<<"Yes"<<endl;
    for (int v = 1; v < N; ++v) cout << ans[v]+1<<endl;;// << ": " << dist[v] << endl;
}

Measured memory_bytes: 11368
N = int(input())
"""200以下の奇数で約数8個→3*5*7,3^3*5=135,3^3*7=189,3*5*11=165,3*5*13=195"""
if N < 105:
    print(0)
elif N < 135:
    print(1)
elif N < 165:
    print(2)
elif N < 189:
    print(3)
elif N < 195:
    print(4)
else:
    print(5)

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <utility>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;
const int LEN = 100000;

struct fastio {
  int it, len;
  char s[LEN + 5];
  fastio() {
    it = len = 0;
  }
  char get() {
    if(it < len) return s[it++];
    it = 0, len = fread(s, 1, LEN, stdin);
    return len ? s[it++] : EOF;
  }
  bool notend() {
    char c;
    for (c = get();c == ' ' || c == '\n';c = get());
    if (it) it--;
    return c != EOF;
  }
  void put(char c) {
    if(it == LEN) fwrite(s,1,LEN,stdout), it = 0;
    s[it++] = c;
  }
  void flush() {
    fwrite(s, 1, it, stdout);
  }
}buff, bufo;
inline int getint() {
  char c; int res = 0, sig = 1;
  for (c = buff.get(); c < '0' || c > '9'; c = buff.get()) if(c == '-') sig = -1;
  for (;c >= '0' && c <= '9';c = buff.get()) res = res * 10 + (c - '0');
  return sig * res;
}
inline ll getll() {
  char c; ll res = 0, sig = 1;
  for (c = buff.get(); c < '0' || c > '9'; c = buff.get()) if (c == '-') sig = -1;
  for (; c >= '0' && c <= '9'; c = buff.get()) res = res * 10 + (c - '0');
  return sig * res;
}
inline void putint(int x, char suf) {
  if (!x) bufo.put('0');
  else {
    if (x < 0) bufo.put('-'), x = -x;
    int k = 0; char s[15];
    while (x) {
      s[++k] = x % 10 + '0';
      x /= 10;
    }
    for (; k; k--) bufo.put(s[k]);
  }
  bufo.put(suf);
}
inline void putll(ll x, char suf) {
  if (!x) bufo.put('0');
  else {
    if (x < 0) bufo.put('-'), x = -x;
    int k = 0; char s[25];
    while (x) {
      s[++k] = x % 10 + '0';
      x /= 10;
    }
    for (; k; k--) bufo.put(s[k]);
  }
  bufo.put(suf);
}
inline char get_char() {
  char c;
  for (c = buff.get(); c == ' ' || c == '\n'; c = buff.get());
  return c;
}
#define maxn 3005
const ll mod = 998244353;
int n, s, a[maxn], f[maxn][maxn];

int main() {
  n = getint(), s = getint();
  for (int i = 1; i <= n; i++) a[i] = getint();
  for (int i = 1; i <= s; i++) f[1][i] = (a[1] == i);
  for (int i = 2; i <= n; i++) {
    for (int j = 1; j <= s; j++) {
      f[i][j] = f[i - 1][j];
      if (j > a[i]) (f[i][j] += f[i - 1][j - a[i]]) %= mod;
      else if(j == a[i]) (f[i][j] += i) %= mod;
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) (ans += f[i][s]) %= mod;
  putint(ans, '\n');
  bufo.flush();
  return 0;
}


Measured memory_bytes: 35456
/*                              _______                                _________
        |\     |         /\         |      |        /\        |\     |    |
        | \    |        /  \        |      |       /  \       | \    |    |
        |  \   |       /    \       |\-----       /    \      |  \   |    |
        |   \  |      /======\      | \          /======\     |   \  |    |     ====|
        |    \ |     /        \     |  \        /        \    |    \ |    |         |
        |     \|    /          \    |   \      /          \   |     \|    |_________|
    */
    #include<bits/stdc++.h>
    using namespace std;
    #define ll long long
    #define pb push_back
    #define mk make_pair
    #define endl "\n"
    #define vi vector<ll>
    #define vb vector<bool>
    #define pii pair<ll,ll>
    #define ss second
    #define ff first
    #define vpii vector<pii>
    #define vvi vector<vi >
    #define vs vector<string>
    #define vvs vector<vs >
    #define all(x) x.begin(),x.end()
    #define mii map<int,int>
    #define rep(i,n) for(ll i=0;i<n;i++)
    #define per(i,n) for(ll i=n-1;i>=0;i--)
    #define rep1(i,n) for(ll i=1;i<=n;i++)
    #define per1(i,n) for(ll i=n;i>0;i--)
    #define repeat(i,start,n) for(ll i=start;i<n;i++)
    #define inp(arr,n) int arr[n];rep(i,n){ cin>>arr[i];}
    #define inp1(arr,n) ll arr[n+1];rep1(i,n){ cin>>arr[i];}
    #define print(a,n) for(ll i=0;i<n;i++){ cout<<a[i]<<" ";}
    #define print1(a,n) for(ll i=1;i<=n;i++){ cout<<a[i]<<endl;}
    #define M 1000000007
    int main()
    {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        int t=1,T=1;
        //cin>>t;
        while(t--)
        {
            int n,m;
            cin>>n>>m;
            int ans=((n*(n-1))/2)+((m*(m-1))/2);
            cout<<ans;
        }

    }


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main () {
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);cout.tie(NULL);
    ll n,c=0;
    cin>>n;
    map<ll,int> m;
    vector<ll> v;
    ll x;
    for(int i=0;i<n;i++) {
        cin>>x;
        v.push_back(x);
    }
    for(int i=n-1;i>=0;i--) {
        c+=m[i+v[i]];
        m[i-v[i]]++;
    }
    cout <<c;
	return 0;
}


Measured memory_bytes: 27316
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define DEBUG

#ifdef DEBUG
#define var_dump(...) fprintf(stdout, __VA_ARGS__)
#define dump(a) cout << a << "\n";
#else
#define var_dump(...) 42
#define dump(a) 42
#endif

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://beta.atcoder.jp/contests/abc045/tasks/arc061_a

int main() {
    string S; cin >> S;
    int len = S.length();

    ll ans = 0;
    for (int msk = 0; msk < 1 << (len - 1); msk++) {
        ll num = S[0] - '0';

        for (int i = 0; i < len - 1; i++) {
            if (msk & 1 << i) {
                ans += num;
                num = 0;
            }

            num = num * 10 + S[i + 1] - '0';
        }

        ans += num;
    }

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 256
function main(input) {
  const formatted_input = input.split('\n');

  const N = parseInt(formatted_input[0], 10);
  const Vs = formatted_input[1].split(' ').map(x => parseInt(x));
  const Cs = formatted_input[2].split(' ').map(x => parseInt(x));

  values = [];
  for(var i=0 ; i<N ; i++){
    values.push(Vs[i] - Cs[i]);
  }

  values.sort().reverse();

  var acc_values = [values[0]];
  for(var i=1 ; i<N ; i++){
    acc_values[i] = acc_values[i-1] + values[i]
  }

  const result = Math.max(...acc_values);
  if(result < 0){
    console.log(0);
  }else{
    console.log(result);
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));




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

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n,k,q;
    cin>>n>>k>>q;
    int bd =k-q;
    vector<int> pt(n+1,0);

    for(int i =1;i<=q;i++){
        int a;
        cin>>a;
        pt[a]++;
    }
    
    for(int i = 1;i<=n; i++){
        if((pt[i] +bd) > 0) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    return 0;
}


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

using namespace std;

int main() {
  int n;
  double ans = 0.0;
  cin >> n;
  while (n--) {
    double x;
    cin >> x;
    ans += (1/x);
  }
  ans = 1/ans;
  cout << ans;
  return 0;
}

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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int n;
  cin>>n;
  cout<<n*(n+1)/2<<endl;
}

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

typedef long long ll;

int main(){

    int n;
    cin >> n;
    int ans = 0;
    for(int i=0; i < n;i++){
        char c;
        cin >>c;
        if(c=='Y')ans=1;
    }
    if(ans)cout<<"Four"<<endl;
    else cout<<"Three"<<endl;

    return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()

ll a(ll n) {
  if (n == 1) return 1;
  else return 2 * a(n / 2) + 1;
}

int main() {
  ll h;
  cin >> h;
  cout << a(h) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll N=1e5+8;
const ll MOD=1e9+7;
#define  pb push_back
ll H,W,dp[1000][1000];
string a[1000];
bool isvalid(ll i,ll j){
    return i>=0 && j>=0 && i<=H && j<=W;
}
ll solve(ll i,ll j){
    if(!isvalid(i,j))return 0;
    if(dp[i][j]!=-1)return dp[i][j];
    if(a[i][j]=='#')return 0;
    if (i==H && j==W)return 1;
    ll ans=0;
    ans=(ans+solve(i+1,j))%MOD;
    ans=(ans+solve(i,j+1))%MOD;
    return dp[i][j]=ans;
}
int main(){
    cin>>H>>W;
    for(ll i=0;i<H;i++){
        cin>>a[i];
    }
    memset(dp,-1,sizeof dp);
    H--;W--;
    cout<<solve(0,0)<<"\n";
    return 0;
}

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

namespace Main
{
    class Program
    {
        static void Main(string[] args)
        {
         string[] str = Console.ReadLine().Split();
         int N = int.Parse(str[0]);
           int N2 = N;
            int sum = 0;
            while (N > 0)
            {
                sum += (N % 10);
                N /= 10;
            }

        if(N2%sum == 0)
            {
                Console.WriteLine("Yes");
            } else
            {
                Console.WriteLine("No");
            }
        
        

        }
    }
}


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

using namespace std;

int main() {
    int N, a, res=0;
    cin >> N;
    
    for(int i=0; i<N; i++) {
        cin >> a;
        res = res ^ a;
    }

    if(res == 0) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256