akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
const long long cc=924844033;
int n,p;
long long dp[2010][2010],f[2010][2010][2],w[2010][2010];
main()
{
	cin>>n>>p;
	f[0][0][0]=1;
	w[0][0]=1;
	for (int i=1;i<=(n-1)/p;i++)
	{
		f[i][0][0]=1;
		w[i][0]=1;
	    for (int j=1;j<=((n-1)/p+1)/2;j++)
	    {
	    	f[i][j][0]=(f[i-1][j][0]+f[i-1][j][1])%cc;
	    	f[i][j][1]=f[i-1][j-1][0];
	    	w[i][j]=(f[i][j][0]+f[i][j][1])%cc;
		}
    }
    dp[0][0]=1;
    int m=2*min(n-p,p);
    //int m=2*(((n-1)%p)+1);
    for (int i=1;i<=m;i++)
    {
    	int len=(i+1)/2;
    	for (int j=0;j<=n;j++)
    	{
    		for (int k=0;k<=((n-len)/p+1)/2;k++)
    		 if (j-k>=0)
    		 {
			   long long tmp=(dp[i-1][j-k]*w[(n-len)/p][k])%cc;
			   dp[i][j]=(dp[i][j]+tmp)%cc;
			 }
		}
	}
	long long ans,t=n%2?-1:1;
	ans=(dp[m][n]*t+cc)%cc;
	for (int i=n-1;i>=0;i--)
	{
		t=(t*(n-i))%cc;
		t=(cc-t)%cc;
		long long tmp=(dp[m][i]*t)%cc;
		ans=(ans+tmp)%cc;
	}
	cout<<ans<<endl;
}

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

using namespace std;

#define debug(x) cout << #x << "==" << x << endl;

const int inf = 100000000;

typedef long long ll;

int main() {
  ios::sync_with_stdio(false);

  int N;
  cin >> N;

  vector<int> a(N);
  for(int i = 0; i < N; i++) { cin >> a[i]; }

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

  int li = 0;
  int ri = N - 1;
  int removed = 0;
  while( li < ri ) {

    while ( li + 1 < N && a[li] != a[li+1] ) { li++; }
    
    while ( 0 <= ri-1 && a[ri] != a[ri-1] ) {  ri--; }
    
    if( li >= ri ) { break; }

    li++;
    ri--;
    removed += 2;

  }

  cout << N - removed << "\n";
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <tuple>
#include <functional>

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep2(i,a,n) for(int i = a; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> PLL;

int main() 
{
    int x1,y1,x2,y2; 
    cin >> x1>>y1>>x2>>y2;
    int dx = x2 - x1;
    int dy = y2 - y1;

    printf("%d %d %d %d\n", x2 - dy, y2 + dx, x1 - dy, y1 + dx);
    return 0;
}



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

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll n; cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    ll maxi=0,mini=0;
    vector<bool> color(8,false);
    rep(i,n){
        if(a[i]<3200) color[a[i]/400]=true;
        else maxi++;
    }
    rep(i,8) if(color[i]) mini++;
    maxi+=mini;
    if(mini==0) mini=1;
    cout << mini << " " << maxi << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
#define pb push_back

template<class T> inline bool chmin(T &a, T b){
	if(a>b){a=b;return true;}
	return false;
}
template<class T> inline bool chmax(T &a, T b){
	if(a<b){a=b;return true;}
	return false;
}
constexpr int mod = 1e9+7;
constexpr int inf = 3e18;


signed main(){
	int A;
	string s;
	cin>>A>>s;
	string t=s.substr(0,len(s)-3)+s.substr(len(s)-2);
	int B=stoi(t);
	cout<<A*B/100<<endl;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int MOD=1e9+7;
int n;
ll ans,a[200005],s[200005],sum;
int main(){
    cin>>n;
    for(int i=1;i<=n;i++)  
     {
     	cin>>a[i];
     	s[i]=s[i-1]+a[i];
     }
    for(int i=1;i<=n;i++)
    {
    	sum=(sum+(s[n]-s[i])%MOD*a[i]%MOD)%MOD;
    }
    cout<<sum;
	return 0;
}


Measured memory_bytes: 6772
#include <bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define int long long
#define mod 1000000007

int dp[105][100005];

int solve1(int* a, int i, int k, int n) {
	if (k < 0)return 0;
	if (k == 0)return 1;
	if (i > n)return 0;
	if (dp[i][k] != -1)return dp[i][k];
	dp[i][k] = (mod + solve1(a, i, k - 1, n) + solve1(a, i + 1, k, n) - solve1(a, i + 1, k - a[i] - 1, n)) % mod;
	return dp[i][k];
}

void solve() {
	int n;
	cin >> n;
	int k;
	cin >> k;
	int a[n + 1];
	int i;
	for (i = 1; i <= n; i++)cin >> a[i];

	memset(dp, -1, sizeof(dp));
	dp[0][0] = 1;
	for (i = 1; i <= n; i++)dp[i][0] = 1;
	for (i = 1; i <= k; i++)dp[0][i] = 0;
	int len = solve1(a, 1, k, n);
	cout << len << endl;
	return;
}


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

Measured memory_bytes: 93480
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18,MOD = 1e9 + 7;
const int INT_INF = 1e9,INT_MOD=1e9+7;
#define rep(i, N) for(int i = 0; i < N; i++)
typedef pair<int, int> Pi;
typedef pair<double, double> P;
signed main(){
    ll x;cin>>x;
    ll st=100;
    for(int i=0;;i++){
        if(st<x){
            st+=st/100;

        }else{
            cout<<i<<endl;
            break;
        }
    }
    
    return 0;
}

Measured memory_bytes: 3640
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		int z = sc.nextInt();
		int ans = 0;
		for(int i = 1 ;; i++) {
			if(x < y * i + z * (i + 1)) {
				break;
			} else {
				ans++;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 25556
from collections import Counter

mod = 1000000007


def inverse(a):
    return pow(a, mod - 2, mod)


def usearch(x, a):
    lft = 0
    rgt = len(a) + 1
    while rgt - lft > 1:
        mid = (rgt + lft) // 2
        if a[mid] <= x:
            lft = mid
        else:
            rgt = mid
    return lft

s = ['SUN', 'MON','TUE','WED','THU','FRI','SAT']

def main():
    a = input()
    print(7 - s.index(a))

main()


Measured memory_bytes: 3316
ans = []
for i in range(9,201):
    if i%2 == 1:
        counter = 0
        for k in range(1,i+1):
            if i%k == 0:
                counter += 1
        if counter == 8:
            ans.append(i)

n = int(input())

answer = 0
for i in range(len(ans)):
    if n >= ans[i]:
        answer += 1
print(answer)

Measured memory_bytes: 3060
import java.util.*;
public class Main
{
  public static void main(String args[])
  {
    Scanner sc = new Scanner(System.in);
    long a = sc.nextLong();
    long b = sc.nextLong();
    long c = sc.nextLong();
    long d = sc.nextLong();
    long count =0 ;
    if( a == b)
    {
        if( (a%c)==0 && (a%d)==0 )
            System.out.println(0);
        else 
            System.out.println(1);
    }
    else
    {
        long a1 = a/c;
        long a11 = a%c;
        if( a11 != 0)
            a1++;
        long a2 = b/c;
        count = a2-a1+1;
        
        long b1=a/d;
        long b11 = a%d;
        if( b11 != 0)
            b1++;
        long b2 =b/d;
        count = count+(b2-b1+1);
        
        long gcdnum = gcd(c , d);
        long lcm = (c*d)/gcdnum;
        long c1 = a/lcm;
        if(a % lcm == 0)
            c1--;
        long c2 = b/lcm;
        count = count-(c2-c1);
        // System.out.println("a1="+a1+" a2="+a2+" b1="+b1+" b2="+b2+" c1="+c1+" c2="+c2);
        // System.out.println(count);
        System.out.println((b-a+1)-count);
    }
    
    
  }
  
    
    static long gcd(long a, long b) 
    { 
      if (b == 0) 
        return a; 
      return gcd(b, a % b);  
    }
      
}

Measured memory_bytes: 21716
#include <iostream>
#include <string>
#include <queue>
#include <algorithm>
using namespace std;

int main(){
    int n, q, t;
    string name;

    queue<pair<string, int> > Q;
    
    cin >> n >> q;

    for (int i = 0; i < n; i++){
        cin >> name >> t;
        Q.push(make_pair(name, t));
    }

    pair<string, int> u;
    int elaps = 0, a;

    while ( !Q.empty() ){
        u = Q.front(); Q.pop();
        a = min(u.second, q);
        u.second -= a;
        elaps += a;
        if (u.second > 0){
            Q.push(u);
        } else {
            cout << u.first << " " << elaps << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 6308
import sys
from itertools import accumulate

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    s = input()

    black, white = [0] * n, [0] * n
    for i in range(n):
        if s[i] == "#":
            black[i] = 1
        else:
            white[i] = 1

    acc_b = [0] + list(accumulate(black))
    acc_w = [0] + list(accumulate(white))

    res = f_inf
    for left in range(n + 1):
        change_w = acc_b[left]
        change_b = acc_w[n] - acc_w[left]
        res = min(res, change_w + change_b)
    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 29568
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
template<class T, class Compare = less<T> >
using MaxHeap = priority_queue<T, vector<T>, Compare>;
template<class T, class Compare = greater<T> >
using MinHeap = priority_queue<T, vector<T>, Compare>;
using llong = long long;


int main() {
    llong x, y;
    llong sx, sy;
    llong tx, ty;

    cin >> x >> y;

    sx = sy = tx = ty = 0;

    llong c = 0;
    llong d = 0;
    while (sx > x || x > tx ||
           sy > y || y > ty) {
        switch(d) {
        case 0:
            tx += llabs(ty - sy) + 1;
            break;
        case 1:
            ty += llabs(tx - sx) + 1;
            break;
        case 2:
            sx -= llabs(ty - sy) + 1;
            break;
        case 3:
            sy -= llabs(tx - sx) + 1;
            break;
        }

        c = (c + 1) % 3;
        d = (d + 1) % 4;
    }

    cout << c + 1 << endl;

    return 0;
}



Measured memory_bytes: 3104
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
using namespace std;
int main(){
  int h,w;
  cin>>h>>w;
  char a[h][w];
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>a[i][j];
    }
  }
  for(int i=0;i<w+2;i++){
    cout<<'#';
  }
  cout<<endl;
  for(int i=0;i<h;i++){
    cout<<'#';
    for(int j=0;j<w;j++){
      cout<<a[i][j];
    }
    cout<<'#'<<endl;
  }
  for(int i=0;i<w+2;i++){
    cout<<'#';
  }
  cout<<endl;

      
 return 0;   
}
  


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
typedef long long ll;




int main(){
    ll H,W,K;cin>>H>>W>>K;
    char c[320][320];
    rep(i,0,H)rep(j,0,W)cin>>c[i][j];
    int num[320][320];
    vector<int> zero;
    int aru,cn=1,sta=0,II;
    rep(i,0,H){
        aru=0;
        rep(j,0,W)if(c[i][j]=='#')aru=1;
            
        if(!aru)zero.push_back(i);
        else{
            rep(j,0,W){
                
                if(c[i][j]=='#'&&sta==1)cn++;
                else if(c[i][j]=='#'&&sta==0)sta=1;
                num[i][j]=cn;
            }
            rep(j,0,zero.size()){
                rep(k,0,W){
                    num[zero.at(j)][k]=num[i][k];
                }
            }
            II=i;
            break;
        }
        
        
    }
    rep(i,II+1,H){
        
        sta=0;
        aru=0;
        rep(j,0,W)if(c[i][j]=='#')aru=1;
        if(!aru){
            rep(j,0,W){
                num[i][j]=num[II][j];
            }
        }
        else{
            cn++;
            rep(j,0,W){
                if(c[i][j]=='#'&&sta==0)sta=1;
                else if(c[i][j]=='#'&&sta==1)cn++;
                num[i][j]=cn;
            }
            II=i;
        }
    }
    rep(i,0,H){
        rep(j,0,W){
            cout<<num[i][j];
            if(j!=W-1)cout<<" ";
        }
        cout<<endl;
    }
}







Measured memory_bytes: 1280
#include <iostream>

using namespace std;

int main()
{
    string s ;
    cin >> s ;
    for ( int i=0 ; i<s.length() ; i++ )
    {
        if ( s[i] == ','  ){
           s[i] = ' ' ;
        }
     cout << s[i] ;
 }
    return 0;
}

Measured memory_bytes: 256
import sys
input_data = input()
input_numbers = input_data.split()

if __name__ == '__main__':
    a = int(input_numbers[0])
    b = int(input_numbers[1])
    c = int(input_numbers[2])
    tmp = 0

    if c < a :
        tmp = a
        a = c
        c = tmp

    if  a > b :
        tmp = b
        b = a
        a = tmp

    if b > c :
        tmp = c
        c = b
        b = tmp

    print('{0} {1} {2}'.format(a, b, c))


Measured memory_bytes: 5596
#include <iostream>
#include <string>
#include <string.h>
using namespace std;

const string ss[] = {"dream", "dreamer", "erase", "eraser"};
bool dp[100005];

int main()
{
	string S;
	cin >> S;
	memset(dp, 0, sizeof(dp));
	dp[0] = true;
	for (int pos = 0; pos < S.size(); pos++) {
		if (!dp[pos]) continue;
		for (int i = 0; i < 4; i++) {
			if (S.compare(pos, ss[i].size(), ss[i]) == 0) {
				dp[pos + ss[i].size()] = true;
			}
		}
	}
	if (dp[S.size()]) {
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}
	return 0;
}


Measured memory_bytes: 892
#include <iostream>
#include <complex>
#include <cmath>
using namespace std;
typedef complex<double> xy_t;
double cross_product(xy_t a, xy_t b){ return (conj(a)*b).imag();}
double x[4],y[4];
int main() {
	while(true){
		for(int i=0; i<4;++i) cin >> x[i] >> y[i];
		if(!cin) break;
		xy_t a(x[0],y[0]),b(x[1],y[1]),c(x[2],y[2]),p(x[3],y[3]);
		bool ok = cross_product(a-p,b-p)*cross_product(b-p,c-p)>0
				  && cross_product(b-p,c-p)*cross_product(c-p,a-p)>0;
		cout << (ok ? "YES" : "NO") << endl;
	}
	return 0;
}

Measured memory_bytes: 1220
N = int(input())
X = [int(x) for x in list(input().split())]
max_x = max(X)
min_x = min(X)
d = max_x - min_x
middle = (d//2)
P = middle + min_x
ans = 0
for i in range(N):
  ans += (max_x-X[i])**2
for i in range(d):
  n_ans = 0
  P = min_x + i
  for j in range(N):
    n_ans += (P-X[j])**2
  if (n_ans < ans):
    ans = n_ans
print(int(ans))

Measured memory_bytes: 9172
#include <bits/stdc++.h>
 
using namespace std;
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
 
const long long INF = 1LL << 60;
#define PI 3.14159265359 
bool dp[100100];


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

    if(s[0] == s[1] && s[1] == s[2])cout <<"No" << endl;
    else cout <<"Yes" << endl;



}

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

#ifdef DEBUG
#define debug(x) cout << #x << ": " << x << endl
#else
#define debug(x)
#endif

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REPS(i, n) for(int i = 1; i <= (n); i++)
#define ALL(v) (v).begin(), (v).end()

#define pb push_back
#define mp make_pair
#define mt make_tuple

using namespace std;

using ll = long long;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;

const ll INF = 1e18;
const ll MOD = 1e9+7;

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, const T &b) { if (a>b) { a = b; return true;} return false; }


signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    ll X; cin >> X;
    for(int A = 0; A <= 1000; A++)
    {
        for(int B = 0; B <= 1000; B++)
        {
            if(pow(A, 5) - pow(B, 5) == X)
            {
                cout << A << " " << B << endl;
                return 0;
            }
            if(pow(A, 5) + pow(B, 5) == X)
            {
                cout << A << " " << -B << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 4116
#include <stdio.h>
#include <limits.h>

int A[2000001], size = 0;

int extract(void);
void increaseKey(int, int);
void insert(int);
int extractMax(void);
void maxHeapify(int);

int main()
{
  int k, max;
  char input[10];

  while(1)
    {
      scanf("%s",input);

      if(input[0] == 'e' && input[1] == 'n')break;
      if(input[0] == 'i')
	{
	  scanf("%d",&k);
	  insert(k);
	}
      else
	{
	  max = extractMax();
	  printf("%d\n",max);
	}
    }

  
  return 0;
}

int extract(void)
{
  int maxv;
  if(size < 1)return -INT_MAX;
  maxv = A[1];
  A[1] = A[size--];
  maxHeapify(1);
  return maxv;
}

void increaseKey(int i, int k)
{
  int temp;
  
  if(k < A[i])return;
  A[i] = k;
  while(i > 1 && A[i/2] < A[i])
    {
      temp = A[i];
      A[i] = A[i/2];
      A[i/2] = temp;
      i = i/2;
    }
}

void insert(int k)
{
  int i;
  
  size++;
  A[size] = -INT_MAX;
  increaseKey(size, k);
}

int extractMax(void)
{
  int max;
  max = A[1];
  A[1] = A[size];
  size--;
  maxHeapify(1);
  return max;
}

void maxHeapify(int i)
{
  int l, r, largest, temp;

  l = 2*i;
  r = 2*i+1;

  if(l <= size && A[l] > A[i])largest = l;
  else largest = i;

  if(r <= size && A[r] > A[largest])largest = r;

  if(largest != i)
    {
      temp = A[i];
      A[i] = A[largest];
      A[largest] = temp;

      maxHeapify(largest);
    }
}



Measured memory_bytes: 5592
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        int n = Integer.parseInt(in.nextLine().trim());
        int[][] arr = new int[n][3];
        int[][] dp = new int[n+1][3];
        int idx = 0;
        while(idx < n){
            String[] temp = in.nextLine().trim().split("\\s");
            arr[idx][0] = Integer.parseInt(temp[0]);
            arr[idx][1] = Integer.parseInt(temp[1]);
            arr[idx][2] = Integer.parseInt(temp[2]);
            idx++;
        }

        for(int i = 1; i <= n; i++){
            dp[i][0] = Math.max(dp[i-1][1]+arr[i-1][1], dp[i-1][2]+arr[i-1][2]);
            dp[i][1] = Math.max(dp[i-1][0]+arr[i-1][0], dp[i-1][2]+arr[i-1][2]);
            dp[i][2] = Math.max(dp[i-1][1]+arr[i-1][1], dp[i-1][0]+arr[i-1][0]);
        }
        System.out.println(Math.max(dp[n][0], Math.max(dp[n][1], dp[n][2])));
        
    }
}

Measured memory_bytes: 165296
#!python3.4
# -*- coding: utf-8 -*-
# abc154/abc154_c
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N = i2n()
    A = i2nn()
    S = set(A)
    print('YES' if len(A) == len(S) else 'NO')
    return

main()


Measured memory_bytes: 27472
extern crate core;

use std::io::{self, Read};

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = run(input.trim().to_string());
    println!("{}", output);
}

fn run(input: String) -> String {
    let list = input
        .split_whitespace()
        .map(|x| x.parse::<i64>().unwrap())
        .collect::<Vec<_>>();
    (std::cmp::min(list[0], list[1]) + std::cmp::min(list[2], list[3])).to_string()
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!(super::run($input.to_string()), $output.to_string());
                }
            )*
        }
    }
}

tests! {
    test1: "600\n300\n220\n420" => "520",
    test2: "555\n555\n400\n200" => "755",
    test3: "549\n817\n715\n603" => "1152",
}


Measured memory_bytes: 4352
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#define _USE_MATH_DEFINES
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;

int a[310][310];
vector<int> sport[310];
bool b[310][310];

int main() {
    int N, M;
    cin >> N >> M;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) {
            int sp;
            cin >> sp;
            sp--;
            a[i][j] = sp;
            if (j == 0) {
                sport[sp].push_back(i);
            }
        }
    }
    for (int i = 0; i < N; i++) {
        fill(b[i], b[i] + M, true);
    }
    int ans = intmax;
    for (int i = 0; i < M; i++) {
        int nowmax = -1;
        int maxsp = -1;
        for (int j = 0; j < M; j++) {
            int s = sport[j].size();
            if (s > nowmax) {
                nowmax = sport[j].size();
                maxsp = j;
            }
        }
        if (nowmax < ans) {
            ans = nowmax;
        }
        for (int j = 0; j < nowmax; j++) {
            int pers = sport[maxsp][j];
            for (int k = 0; k < M; k++) {
                if (b[pers][k] == true && a[pers][k] != maxsp) {
                    sport[a[pers][k]].push_back(pers);
                    break;
                }
            }
        }
        for (int j = 0; j < N; j++) {
            for (int k = 0; k < M; k++) {
                if (a[j][k] == maxsp) {
                    b[j][k] = false;
                }
            }
        }
        sport[maxsp].clear();
    }
    cout << ans << endl;
}


Measured memory_bytes: 1280
import java.util.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] p = new int[n];
        for (int i = 0; i < n; i++) {
            p[i] = in.nextInt();
        }
        int ans = 0;
        for (int i = 1; i < n - 1; i++) {
            if ((p[i - 1] < p[i] && p[i] < p[i + 1]) || (p[i + 1] < p[i] && p[i] < p[i - 1])) {
                ans++;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21716
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <array>
#include <cmath>
#include <iterator>
#include <utility>
#include <set>
#include <random>
#include <map>
#include <stack>
#include <queue>
#include <list>
 
using namespace std;
 
int main() {
    long long n, m;
    long long count = 0;
    cin >> n >> m;
    if (m < 2)
    {
        cout << 0 << endl;
    }
    else if (n <= m / 2)
    {
        count += n;
 
        m = m - n * 2;
 
        count += (m / 4);
 
        cout << count << endl;
    }
    else
    {
        cout << m / 2 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
# xの根を求める
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]


# xとyの属する集合の併合
def unite(x, y):
    x = find(x)
    y = find(y)

    if x == y:
        return False
    else:
        # sizeの大きいほうがx
        if par[x] > par[y]:
            x, y = y, x
        par[x] += par[y]
        par[y] = x
        return True


# xとyが同じ集合に属するかの判定
def same(x, y):
    return find(x) == find(y)


# xが属する集合の個数
def size(x):
    return -par[find(x)]

# 初期化
# 根なら-size,子なら親の頂点
N,M = map(int,input().split())
par = [-1]*(N+1)
p = list(map(int,input().split()))
for _ in range(M):
    x,y = map(int,input().split())
    unite(x,y)
ans = 0
for i, pi in enumerate(p,1):
    if same(i,pi):
        ans += 1
print(ans)

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

res = 0
tmp_count = 0
tmp_hight = 0
for i in range(N):
    if tmp_hight >= H[i]:
        tmp_count += 1
        if tmp_count > res:
            res = tmp_count
    else:
        tmp_count = 0
    tmp_hight = H[i]

print(res)


Measured memory_bytes: 15020
#[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, v: [usize; n],);
    let mut v = v;

    for i in (1..n).rev() {
        if v[i] + 1 == v[i - 1] {
            v[i - 1] -= 1;
        } else if v[i] >= v[i - 1] {
            continue;
        } else {
            println!("No");
            return;
        }
    }
    println!("Yes");
}


Measured memory_bytes: 4352
#include<stdio.h>
int main(){
    int x,y,d;
    scanf("%d%d",&x,&y);
    
    if(x>=y){
        while(y !=0){
            d=y;
            y=x%y;
            x=d;            
        }
        printf("%d\n",x);
    }
    
    else{
        while(x != 0){
            d=x;
            x=y%x;
            y=d;
        }
        printf("%d\n",y);
    }
    return 0;
}


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

int main() {
	int n;
	int spade[13] = {};
	int heart[13] = {};
	int club[13] = {};
	int diamond[13] = {};

	char suit;
	int temp;

	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> suit;

		switch (suit) {
		case 'S':
			cin >> temp;
			spade[temp-1] = 1;
			break;
		case 'H':
			cin >> temp;
			heart[temp-1] = 1;
			break;
		case 'C':
			cin >> temp;
			club[temp-1] = 1;
			break;
		case 'D':
			cin >> temp;
			diamond[temp-1] = 1;
			break;
		}
	}

	for (int j = 0; j < 13; j++) {
		if (spade[j] != 1) {
			printf("S %d\n", j+1);
		}
	}
	for (int j = 0; j < 13; j++) {
		if (heart[j] != 1) {
			printf("H %d\n", j+1);
		}
	}
	for (int j = 0; j < 13; j++) {
		if (club[j] != 1) {
			printf("C %d\n", j+1);
		}
	}
	for (int j = 0; j < 13; j++) {
		if (diamond[j] != 1) {
			printf("D %d\n", j+1);
		}
	}

	return 0;
}

Measured memory_bytes: 3220
#include <iostream>

using namespace std;

int main()
{
    string o, e;

    cin >> o;
    cin >> e;
    for (int i = 0; i < e.size(); ++i) {
        cout << o[i] << e[i];
    }
    if (o.size() - e.size() == 1) {
        cout << o[o.size()-1];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.ArrayList;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
		
		// 입력
		String s = br.readLine();
		boolean firstA = false;
		boolean thirdC = false;
		boolean hasOtherCapital = false;
		int aCount = 0;
		int cCount = 0;
		
		if(s.length() >= 4 && s.length() <=10){
			for(int i = 0 ; i < s.length() ; i++){
				switch(s.charAt(i)){
				case 'A':
					aCount++;
					if(i == 0){
						firstA = true;
					}
					break;
				case 'C':
					cCount++;
					if(i > 1 && i < s.length()-1){
						thirdC = true;
					}
					break;
				default:
					if(s.charAt(i) > 65 && s.charAt(i) <= 90){
						hasOtherCapital = true;
					}
				}
			}
			
			if(firstA == true && thirdC == true && cCount == 1 && hasOtherCapital == false){
				bw.write("AC");
				bw.flush();
			}else{
				bw.write("WA");
				bw.flush();
			}
		}else{
			bw.write("WA");
			bw.flush();
		}
		
		bw.close();
		br.close();
	}
}

Measured memory_bytes: 22356
#include <bits/stdc++.h>
using namespace std;
long long N, A[87], CurrentMoney = 1000;
 int main() {
 cin >> N;
 for (int i = 1; i <= N; i++) cin >> A[i];
 for (int i = 1; i <= N - 1; i++) {
 long long Stocks = 0;
 if (A[i] < A[i + 1]) Stocks = CurrentMoney / A[i];
 CurrentMoney += (A[i + 1] - A[i]) * Stocks;
 }
 cout << CurrentMoney << endl;
}


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

int x,y;

int main(){
    while(1){
        cin>>x>>y;
        if(x==0 && y==0)break;
        if(x<y)cout<<x<<" "<<y<<endl;
        else cout<<y<<" "<<x<<endl;
    }
    return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;

int main()
{
  string s;
  cin >> s;
  REP(i, s.size())
  {
    if ((i + 1) % 2 == 1)
    {
      if (s[i] != 'R' && s[i] != 'U' && s[i] != 'D')
      {
        cout << "No" << endl;
        return 0;
      }
    }
    else
    {
      if (s[i] != 'L' && s[i] != 'U' && s[i] != 'D')
      {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
   int x,y,z;
   int buf = 0;
    scanf("%d %d %d",&x,&y,&z);
    
    buf=x;
    x=y;
    y=buf;
    buf=x;
    x=z;
    z=buf;
       
    printf("%d %d %d\n",x,y,z);

    return 0;
}


Measured memory_bytes: 1696
#include<bits/stdc++.h>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
using ll = long long;
using ld =long double;
//#define int ll
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
int dx[]={0,0,1,-1};
int dy[]={1,-1,0,0};
int W,H;
bool inrange(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
using namespace std;
typedef pair<int, int> pii;
typedef pair<int,pii> piii;
#define MP make_pair
signed main(){
    int h,w,D;cin>>h>>w>>D;
    vector<vector<int>>v(h,vector<int>(w));
    map<int,pii>mp;
    rep(i,h)rep(j,w){
        cin>>v[i][j];
        mp[v[i][j]]=pii(i,j);
    }
    map<pii,int>d;
    for(int i=0;i<D;i++){
        int cost=0;
        int base=i;
        int now=i;
        for(;;){
            now+=D;
            if(now>h*w)break;
            pii pnt=mp[now];
            pii before=mp[now-D];
            cost+=abs(pnt.first-before.first)+abs(pnt.second-before.second);
            d[pii(base,now)]=cost;
        }
    }
    int Q;
    cin>>Q;
    rep(i,Q){
        int a,b;cin>>a>>b;
        int base=a%D;
        cout<<abs(d[pii(base,a)]-d[pii(base,b)])<<endl;
    }
}


Measured memory_bytes: 12800
#include<stdio.h>
int main(void){
	int n,a,b;
	scanf("%d",&n);scanf("%d",&a);scanf("%d",&b);
	int i,y=0;
	for(i=0;i<=n;i++){
		int s=i/10000+(i/1000)%10+(i/100)%10+(i/10)%10+i%10;
		if(s>=a&&s<=b)y+=i;
	}
	printf("%d\n",y);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
vector<vector<long long > > A(310, vector<long long > (310)), dist(310, vector<long long > (310));
int main() {
    int n;
    cin >> n;
    for(int i=0;i<n;i++)
	{
        for(int j=0;j<n;j++)
		{
            cin >> A[i][j];
            dist[i][j]=A[i][j];
        }
    }
    for(int k=0;k<n;k++) 
	{
        for(int i=0;i<n;i++)
		{
            for(int j=0;j<n;j++)
			{
                dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
            }
        }
    }
    long long ans=0;
    for(int i=0;i<n-1;i++)
	{
        for(int v=i+1;v<n;v++)
		{
            if(dist[i][v]<A[i][v])
			{
                cout<<-1<<endl;
                return 0;
            }
            int flag = 0;
            for(int j=0;j<n;j++)
			{
                if(j!=i&&j!=v&&dist[i][v]==dist[i][j]+dist[j][v])
				{
                    flag=1;
                }
            }
            if(!flag)
			{
                ans+=dist[i][v];
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
bool T=false;
int main(){
    long long A,B,K;cin>>A>>B>>K;
    if(A-K>=0)A-=K;
    else if(B-K+A>=0){
        B-=K-A;
        A=0;
    }
    else {
        A=0;B=0;
    }
    cout<<A<<" "<<B<<endl;
}

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

int main(){

    int x,a,b;
    cin >> x >> a >>b;

    if(b-a<=0){
        cout << "delicious" <<endl;
    }else if(b-a<=x){
        cout << "safe" <<endl;
    }else{
        cout << "dangerous" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, M, A = 0;

  cin >> N;
  vector<string> blue(N);
  for (int i = 0; i < N; i++) {
    cin >> blue.at(i);
  }

  cin >> M;
  vector<string> red(M);
  for (int i = 0; i < M; i++) {
    cin >> red.at(i);
  }
  
  for (int i = 0; i < N; i++) {
    int count = 0;
    string X = blue.at(i);
    for (int j = 0; j < N; j++) {
      if (blue.at(j) == X) {
        count++;
      }
    }
    for (int j = 0; j < M; j++) {
      if (red.at(j) == X) {
        count--;
      }
    }
    if (count > A) {
      A = count;
    }
  }

  
  cout << A;
}

Measured memory_bytes: 256
import collections
N = int(input())
A = list(map(int, input().split()))


dic = collections.defaultdict(int)

for x in A:
    dic[x] += 1

dic = list(dic.items())
dic = [x for x in dic if x[1] >= 2]
dic = sorted(dic, reverse=True, key=lambda x: x[0])

if len(dic) >= 2:
    if dic[0][1] >= 4:
        print(dic[0][0] * dic[0][0])
    else:
        print(dic[0][0] * dic[1][0])
else:
    print(0)


Measured memory_bytes: 21412
/******************************************
* NICK : nikhilsinghh59 *
******************************************/
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"

#define PB push_back
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
const int M = 1e9+7;

int main()
{   
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif

    ll x,y,z;
    cin >> x >> y >> z;

    swap(x , y);
    swap(x , z);
    cout << x << " " << y << " " << z;
    
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int N;
    cin >> N;
    string S,T;
    cin >> S >> T;
    for (size_t i = 0; i < N; i++)
    {
        cout << S[i] << T[i];
    }
    cout << endl;
    
}

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

using namespace std;

#define f first
#define s second
#define mp make_pair
#define all(x) x.begin(), x.end()
#define MOD 1000000007
#define EPS 1e-9
#define X real()
#define Y imag()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using vi = vector<int>;
using ii = pair<int, int>;
using vii = vector<ii>;
using point = pair<double, double>;
using Vector = complex<double>;

int main() {

	ios_base :: sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int a, b, c;
	cin >> a >> b >> c;
	if(a + b + c >= 22) cout << "bust\n";
	else cout << "win\n";
    return 0;
}


Measured memory_bytes: 256
n,k,q = map(int,input().split())
a=[int(input()) for i in range(q)]
b=[k-q]*n
c=[0]*n

for i in range(q):
    b[a[i]-1] +=1
    
for i in range(n):
    if b[i]<=0:
        c[i]='No'
    else:
        c[i]='Yes'

for i in range(n):
    print(c[i])


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


/*
ll gcds(ll a,ll b){
    if(a<b){
        swap(a,b);
    }
    ll r=a%b;
    if(r==0){
        return b;
    }
    while(r>0){
        r=a%b;
        a=b;
        b=r;
    }
    return a;
}


ll lcms(ll a,ll b){
    ll mmr=gcds(a,b);
    a=a/mmr;
    b=b/mmr;
    return a*b*mmr;
}
*/


int main(){
    vector<vector<int>> A(3,vector<int> (3));
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            cin>>A.at(i).at(j);
        }
    }
    int N;
    cin>>N;
    vector<int> b(N);
    for(int i=0;i<N;i++){
        cin>>b.at(i);
    }
    vector<vector<int>> D(3,vector<int> (3,0));
    for(int i=0;i<N;i++){
        for(int j=0;j<3;j++){
            for(int l=0;l<3;l++){
                if(A.at(j).at(l)==b.at(i)){
                    D.at(j).at(l)=1;
                }
            }
        }
    }
    int tmp=0;
    for(int i=0;i<3;i++){
        if(D.at(i).at(0)==1 && D.at(i).at(1)==1 && D.at(i).at(2)==1){
            tmp=1;
        }
        if(D.at(0).at(i)==1 && D.at(1).at(i)==1 && D.at(2).at(i)==1){
            tmp=1;
        }
    }
    if(D.at(0).at(0)==1 && D.at(1).at(1)==1 && D.at(2).at(2)==1){
        tmp=1;
    }
    if(D.at(2).at(0)==1 && D.at(1).at(1)==1 && D.at(0).at(2)==1){
        tmp=1;
    }
    if(tmp==1){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }

 
}

Measured memory_bytes: 256
import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(500000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n,m=map(int,input().split())
s=input()
t=input()
g=math.gcd(n,m)
for i in range(g):
    # print(s[n//g*i])
    if s[n//g*i]!=t[m//g*i]:
        print(-1)
        break
else:
    print(n*m//g)

Measured memory_bytes: 68424
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <stack>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <math.h>

using namespace std;

typedef long long ll;
typedef pair<int,int>ii;
const int N=1000005;

int arr[51],n,p;
ll dp[51][2];
ll solve(int i,int mod){
  if(i==n){
    return mod==p;
  }
  if(dp[i][mod]!=-1)
    return dp[i][mod];
  return dp[i][mod] = solve(i+1,mod) + solve(i+1,(mod+arr[i])%2);
}
int main()
{
   //freopen("test.in","r",stdin);
   cin>>n>>p;
   for(int i=0;i<n;i++)cin>>arr[i];
   memset(dp,-1,sizeof(dp));
   cout<<solve(0,0);
   return 0;
}


Measured memory_bytes: 256
N, S = map(int,input().split())
A = list(map(int,input().split()))
mod = 998244353
dp = [[0 for j in range(S + 1)] for i in range(N + 1)]
dp[0][0] = 1
for i in range(N) : 
    for j in range(S + 1) : 
        dp[i + 1][j] += 2 * dp[i][j]
        dp[i + 1][j] %= mod 
        if j + A[i] <= S : 
            dp[i + 1][j + A[i]] += dp[i][j]
            dp[i + 1][j + A[i]] %= mod
print(dp[N][S])

Measured memory_bytes: 147496
#include<bits/stdc++.h>
#define mxn 1000010
#define db double
#define LL long long
#define ldb long double
#define pb push_back
#define ppb pop_back
#define pf push_front
#define pii pair<int,int> 
#define mp make_pair
#define fr first
#define sc second
#define x1 faqx1
#define y1 faqy1
#define x2 faqx2
#define y2 faqy2
using namespace std;
int n,sl,fh,ans,p[mxn];
char s[mxn],a[mxn];
int rd()
{
	sl=0;fh=1;
	char ch=getchar();
	while(ch<'0'||'9'<ch) {if(ch=='-') fh=-1; ch=getchar();}
	while('0'<=ch&&ch<='9') sl=sl*10+ch-'0',ch=getchar();
	return sl*fh;
}
int main()
{
	scanf("%s",s+1);n=strlen(s+1);int x,y;
	if(n&1) x=y=(n+1)/2; else y=(x=n/2)+1;
	for(;x&&y<=n;--x,++y)
		if(s[x]!=s[y])
			ans++;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

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

func main() {
	var s string
	fmt.Scan(&s)

	ca, cb, cc := 0, 0, 0
	for _, r := range s {
		switch r {
		case 'a':
			ca++
		case 'b':
			cb++
		case 'c':
			cc++
		}
	}
	if len(s) > 1 && (abs(ca-cb) > 1 || abs(cb-cc) > 1 || abs(cc-ca) > 1) {
		fmt.Println("NO")
	} else {
		fmt.Println("YES")
	}
}


Measured memory_bytes: 1280
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	t, a := scanFloat64(), scanFloat64()
	ans := 0
	x := 1e9
	for i := 0; i < n; i++ {
		h := scanFloat64()
		p := math.Abs(t - h*0.006 - a)
		if p < x {
			x = p
			ans = i + 1
		}
	}
	fmt.Fprintln(wr, ans)
}


Measured memory_bytes: 1752
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static class Card {
		private String design;
		private int number;
		private int inputIndex;

		public Card(String design, int number, int inputIndex) {
			this.design = design;
			this.number = number;
			this.inputIndex = inputIndex;
		}

		public String getDesign() {
			return this.design;
		}

		public int getNumber() {
			return this.number;
		}

		public int getInputIndex() {
			return this.inputIndex;
		}
	}

	public static int partition(Card[] a, int p, int r) {
		Card tmp;

		int x = a[r].getNumber();
		int i = p - 1;

		for(int j = p; j < r; j++) {
			if (a[j].getNumber() <= x) {
				i = i + 1;
				tmp = a[i];
				a[i]= a[j];
				a[j] = tmp;
			}
		}

		tmp = a[i + 1];
		a[i + 1] = a[r];
		a[r] = tmp;

		return i + 1;
	}

	public static void quickSort(Card[] a, int p, int r ) {
		if(p < r) {
			int q = partition(a, p, r);
			quickSort(a, p, q - 1);
			quickSort(a, q + 1, r);
		}
	}


	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int cardOfNumber = Integer.parseInt(br.readLine());

		Card[] cards = new Card[cardOfNumber];

		for(int i = 0; i < cardOfNumber; i++) {
			String[] cardElement = br.readLine().split(" ");
			String design = cardElement[0];

			int number = Integer.parseInt(cardElement[1]);

			int index = i + 1;

			Card card = new Card(design, number, index);
			cards[i] = card;

		}

		/*
		------------------------------
		Scanner scan = new Scanner(new InputStreamReader(System.in));
		------------------------------

		int matrixLength = scan.nextInt();

		int[] a = new int[matrixLength];

		for(int i = 0; i < matrixLength; i++) {
		------------------------------
			a[i] = scan.nextInt();
		------------------------------
		}
		 */

		quickSort(cards, 0, cardOfNumber - 1);
		
		StringBuilder sb = new StringBuilder();
		boolean isStable = true;
		for(int i = 0; i < cardOfNumber; i++) {
			sb.append(cards[i].getDesign());
			sb.append(" ");
			sb.append(cards[i].getNumber());
			sb.append(System.getProperty("line.separator"));
			if(i < cardOfNumber - 1){
				if(cards[i].getNumber() == cards[i + 1].getNumber()) {
					if(cards[i].getInputIndex() > cards[i + 1].getInputIndex()) {
						isStable = false;
					}
				}
			}
			
		}
		if(isStable) {
			System.out.println("Stable");
		} else {
			System.out.println("Not stable");
		}
		
		System.out.print(sb.toString());
	}
}

Measured memory_bytes: 70856
//     . .. ... ..... be naame khodaa ..... .... ... .. .     \\

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

typedef long long ll;
typedef long double ld;

inline int in(){int x, y; y = scanf("%d", &x); return x;}

const int N = 202;

int main() {
	int n = in();
	vector <int> a, b;
	bool bad = false;
	for(int i = 0; i < n; i++) {
		b.push_back(in() - 1);
		if(b[i] > i)
			bad = true;
	}
	for(int i = n - 1; i >= 0; i--) {
		int ind = -1;
//		for(int x : b)
//			cerr << x + 1 << " ";
		for(int j = 0; j < b.size(); j++) {
			if(b[j] == j)
				ind = j;
		}
//		cerr << "=> " << ind << endl;
		if(ind == -1) {
			bad = true;
			break;
		}
		a.push_back(ind);
		vector <int> nex;
		for(int j = 0; j < b.size(); j++)
			if(j != ind)
				nex.push_back(b[j]);
		b = nex;
	}
	if(bad) {
		cout << "-1\n";
	}
	else {
		for(; a.size(); a.pop_back())
			cout << a.back() + 1 << "\n";
	}
}



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

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			long n = long.Parse(Console.ReadLine());
			var array = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

			long sum = 0;

			for (var j = 0; j <= n; ++j) {
				if (j == 0) {
					sum += Math.Abs(array[j]);
				} else if (j == n) {
					sum += Math.Abs(array[j - 1]);
				} else {
					sum += Math.Abs(array[j] - array[j - 1]);
				}
			}

			for (var i = 1; i <= n; ++i) {
				var total = sum;
				if (i == 1) {
					total += Math.Abs(0 - array[1])
						- Math.Abs(array[1] - array[0])
						- Math.Abs(0 - array[0]);
				} else if (i == n) {
					total += Math.Abs(0 - array[n - 2])
						- Math.Abs(array[n - 1] - array[n - 2])
						- Math.Abs(0 - array[n - 1]);
				} else {
					total += Math.Abs(array[i] - array[i - 2])
						- Math.Abs(array[i - 1] - array[i - 2])
						- Math.Abs(array[i] - array[i - 1]);
				}

				Console.WriteLine(total.ToString());
			}

			Console.Out.Flush();

			Console.ReadLine();
		}
	}
}



Measured memory_bytes: 29272