akhauriyash/Code-Regression huggingface dataset:
from collections import deque
from copy import deepcopy

N,M = map(int,input().split())
Matrix = [[False for x in range(N)] for y in range(N)]

Path = []
for i in range(M) :
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    Path.append((a,b))
    Matrix[a][b] = True
    Matrix[b][a] = True

ans = 0
for i in range(M) :
    Matrix_duplicated = deepcopy(Matrix)
    a,b = Path[i]
    Matrix_duplicated[a][b] = False
    Matrix_duplicated[b][a] = False
    Visited = []
    Queue = deque([0])
    while Queue :
        now = Queue.popleft()
        Visited.append(now)
        for i in range(N) :
            if Matrix_duplicated[now][i] :
                Matrix_duplicated[now][i] = False
                Matrix_duplicated[i][now] = False
                Queue.append(i)
    if len(list(set(Visited))) != N :
        ans += 1
print(ans)


Measured memory_bytes: 3572
#include<iostream>
using namespace std;
int main()
{
	int N;
	cin >> N;
	char S[N];
	scanf("%s", S);
	int i,Wcnt[N],Ecnt[N];
	Wcnt[0] = 0;
	for (i = 1; i < N; i++) {
		Wcnt[i] = Wcnt[i - 1];
		if (S[i - 1] == 'W') {
			Wcnt[i] = Wcnt[i] + 1;
		}
	}
	Ecnt[N - 1] = 0;
	for (i = N - 2; i >= 0; i--) {
		Ecnt[i] = Ecnt[i + 1];
		if (S[i + 1] == 'E') {
			Ecnt[i] = Ecnt[i] + 1;
		}
	}
	int ans = Wcnt[0] + Ecnt[0];
	for (i = 1; i < N; i++) {
		if (Wcnt[i] + Ecnt[i] < ans) {
			ans = Wcnt[i] + Ecnt[i];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2944
#include <iostream>
#include <string>
#include <cmath>

using namespace std;

int main()
{
    string s;

    cin >> s;

    int n = s.size();
    long x = stol(s);
    long ans = 0;
    for (int i = 0; i < pow(2, n - 1); ++i) {
        long xx = x;
        int d = 10;
        int k = i;
        while (k != 0) {
            if (k & 1) {
                ans += xx % d;
                xx /= d;
                d = 10;
            } else {
                d *= 10;
            }
            k >>= 1;
        }
        ans += xx;
    }

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<algorithm>
#include<queue>
#include<vector>
using namespace std;
vector<pair<int,int> > g[100];
int ijk[100][100];
bool v[100][100];
int main(){
	int a,b,c,d,e;
	while(scanf("%d%d%d%d%d",&a,&b,&c,&d,&e),a+b+c+d+e){
		for(int i=0;i<100;i++)g[i].clear();
		for(int i=0;i<b;i++){
			int p,q,r;
			scanf("%d%d%d",&p,&q,&r);
			p--;
			q--;
			g[p].push_back(make_pair(q,r));
		}
		for(int i=0;i<a;i++)
			for(int j=0;j<a;j++){
				ijk[i][j]=99999999;
				v[i][j]=false;
			}
		ijk[c-1][c-1]=0;
		priority_queue<pair<int,pair<int,int> > >Q;
		Q.push(make_pair(0,make_pair(c-1,c-1)));
		while(Q.size()){
			int cost=-Q.top().first;
			int at1=Q.top().second.first;
			int at2=Q.top().second.second;
			Q.pop();
			if(v[at1][at2])continue;
			v[at1][at2]=true;
			if(at1==at2){
				for(int i=0;i<g[at1].size();i++){
					if(!v[g[at1][i].first][g[at1][i].first]&&ijk[g[at1][i].first][g[at1][i].first]>cost+g[at1][i].second){
						ijk[g[at1][i].first][g[at1][i].first]=cost+g[at1][i].second;
						Q.push(make_pair(-cost-g[at1][i].second,make_pair(g[at1][i].first,g[at1][i].first)));
					}
				}
			}
			for(int i=0;i<g[at1].size();i++){
				if(!v[g[at1][i].first][at2]&&ijk[g[at1][i].first][at2]>cost+g[at1][i].second){
					ijk[g[at1][i].first][at2]=cost+g[at1][i].second;
					Q.push(make_pair(-cost-g[at1][i].second,make_pair(g[at1][i].first,at2)));
				}
			}
			for(int i=0;i<g[at2].size();i++){
				if(!v[at1][g[at2][i].first]&&ijk[at1][g[at2][i].first]>cost+g[at2][i].second){
					ijk[at1][g[at2][i].first]=cost+g[at2][i].second;
					Q.push(make_pair(-cost-g[at2][i].second,make_pair(at1,g[at2][i].first)));
				}
			}
		}
		printf("%d\n",ijk[d-1][e-1]);
	}
}

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

using namespace std;


typedef int32_t h_int32;
typedef int64_t h_int64;
typedef uint32_t uh_int32;
typedef uint64_t uh_int64;
typedef h_int64 h_int;

#define REP( i, n ) for(int i = 0; i < ( int )( n ); ++i )
#define REPR( i, n ) for(int i = ( int )( n ); i >= 0; --i)
#define FOR( i, a, n ) for(int i = ( int )( a ); i < ( int )( n ); ++i )
#define FORR( i, a, n ) for(int i = ( int )( n ); i >= ( int )( a ); --i)

#define VINIT( v, type, n )vector<type> v; v.resize( n );
#define VINIT2( v, type, n, a )vector<type> v; v.resize( n, a );
#define VCIN( v, type, n ) VINIT( v, type, n ) REP( i, n ) cin >> v[i];

#define DOUT( x ) cerr << #x << " = " << x << "\n";
#define COUT( x ) cout << ( x ) << "\n";

#define INF 999999999


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

        int n, m;
        cin >> n >> m;


        vector<int> tmp;
        set<int> nn;
        REP( i, m )
        {
                int a, b;
                cin >> a >> b;
                if( a == 1 )
                {
                        tmp.push_back( b - 1 );
                }
                if( b == n )
                {
                        nn.insert( a - 1 );
                }
        }
        REP( i, tmp.size() )
        {
                if(nn.find( tmp[i] ) != nn.end() )
                {
                        COUT( "POSSIBLE" );
                        return 0;
                }
        }
        COUT( "IMPOSSIBLE" );

        return 0;
}


Measured memory_bytes: 5368
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int T, N;
ll A[MAX_N];
string S;

int ran = 0;
ll B[310][110];

void gauss() {

	int nran = 0;
	rep(j, 0, 60) {
		int at = -1;
		rep(i, nran, ran) {
			if(B[i][j]) at = i;
		}
		if(at == -1) continue;
		swap(B[nran++], B[at]);
		rep(i, 0, ran) {
			if(i == nran - 1 || !B[i][j]) continue;
			rep(k, 0, 60) {
				B[i][k] ^= B[nran - 1][k];
			}
		}
	}
	ran = nran;

	// debug(ran);
	// rep(i, 0, ran) {
	// 	debug(vi(B[i], B[i] + 5));
	// }
}

void solve() {
	cin >> T;
	while(T--) {
		ran = 0;
		memset(B, 0, sizeof(B));
		cin >> N;
		rep(i, 0, N) cin >> A[i];
		cin >> S;
		bool found = false;
		rer(i, N, 0) {
			// debug(T, i, ran);
			if(S[i] == '0') {
				rep(j, 0, 60) {
					B[ran][j] = (((1ll << j) & A[i]) > 0);
				}
				ran++;
				gauss();
			}
			else {
				int pr = ran;
				rep(j, 0, 60) {
					B[ran][j] = (((1ll << j) & A[i]) > 0);
				}
				ran++;
				gauss();
				if(pr < ran) {
					found = true;
				}
			}
		}
		cout << found << "\n";
	}
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}




Measured memory_bytes: 3976
N,M,K = map(int, input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))

a,b=[0],[0]
for i in range(N):
    a.append(a[i]+A[i])
for i in range(M):
    b.append(b[i]+B[i])

ans,j =0,M
for i in range(N+1):
    if a[i]>K:
        break
    while b[j]>K-a[i]:
        j-=1
    ans =max(ans,i+j)
print(ans)

Measured memory_bytes: 127140
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    int A[200010], F[200010];
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> F[i];
    sort(A, A + N);
    sort(F, F + N, greater<int>());
    int ans = INF2;
    int ok = INF2;
    int ng = -1;
    while(abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;
        int cost = 0;
        rep(i, N) {
            int lack = max(0LL, A[i] * F[i] - mid);
            int add = (lack + F[i] - 1) / F[i];
            cost += add;
        }
        if(cost <= K) ok = mid;
        else ng = mid;
    }
    cout << ok << endl;


    return 0;
}


Measured memory_bytes: 6792
/************************************ PALESTINE *****************************************
 Suhaib     ________   |     |   |     |        /\      _______    _______   صهيب صوالحه
            |          |     |   |     |       /  \        |       |     |
            |_______   |     |   |_____|      /____\       |       |_____)
                    |  |     |   |     |     /      \      |       |     )
            ________|  \_____/   |     |    /        \   __|___    |_____|   Sawalha
************************************* PALESTINE ****************************************/

#include <bits/stdc++.h>
//#include "TheReality.h"
//#include "People.h"

using namespace std;

typedef long long ll;

#define yes cout << "YES" << endl
#define no cout << "NO" << endl
#define out(n) cout << n << endl

#define fi(n) for (ll i = 0 ; i < n ; ++i)
#define fo(m) for (size_t o = 0 ; o < m ; ++o)
#define w(t) while (t--)

typedef vector <ll> vll;
typedef multiset <ll> msell;
typedef stack <ll > stll;
typedef queue <ll> qll;
typedef deque <ll> dll;
typedef map <ll,ll> mll;
typedef pair <ll,ll> pll;
typedef vector <pair <ll,ll>> vpll;

#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

void solve (){

ll n , k;
cin >> n >> k;
ll arr [n];
k--;
fi(n){cin >> arr [i];}
ll ans = INT_MAX;
fi(n){
    if (i - k < 0) {continue;}
    ll Max = arr[i], Min = arr[i-k];
    if (Min > 0) {
        ans = min(ans, Max);
    }
    else if (Max < 0) {
        ans = min(ans, -Min);
    }
    else {
        ll m = min(abs(Max), abs(Min));
        ans = min(ans, m + Max-Min);
    }
}
out(ans);
}

int main(){
    FAST;/*
ll t;
cin >> t;
w(t) {solve();}
*/
solve();


return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
//#define DEBUG
#define REP(i, nn ) for(int i = 0 ; i < (int) nn; i++)
#define deb(x) std::cerr << #x << " " << x << endl;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
template<typename... T>
void read(T& ... a){
    ((cin >> a),...);
}
template<typename... T>
void write(T... a){
    ((cout << a << "\n"),...);
}

template<typename... T>
void write_space(T... a){
    ((cout << a << " "),...);
}
constexpr int mxV = 1e5;
constexpr int mxN = 100;
ll INF = 1e10;
ll dp[mxN][mxV];
void solve(){
    int n, W;
    read(n, W);
    vector<pair<ll,ll>> item(n);
    REP(i,n){
        ll w, v;
        cin >> w >> v;
        item[i] = {w,v};
    }
    //sort(item.begin(), item.end());
    for(int k = 1; k <= item[0].second; k++){
        dp[0][k] = item[0].first;
    }
    for(int k = item[0].second + 1 ; k <= mxV ; k++){
        dp[0][k] = INF;
    }

    for(int i = 1; i < n ; i++){
        for(int k = 1 ; k <= mxV ; k++){
            dp[i][k] = dp[i-1][k];
            if( item[i].second >= k){
                dp[i][k] = min(item[i].first, dp[i][k]);
            }else{
                dp[i][k] = min(dp[i][k], dp[i-1][k- item[i].second] + item[i].first); 
            }
        }
        // deb(i);
        // deb(dp[i][W]);
    }
    ll ans = 0;
    for(int k = 0; k <= mxV; k++){
        if(dp[n-1][k] <= W){
            ans = k;
        }
    }
    cout << ans << endl;
}

int main()
{
    //making data IO Fast
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    /****************************/
    solve();
    return 0;
}



Measured memory_bytes: 81764
#include <bits/stdc++.h>
#include<iostream>
#include<fstream>
#define ll long long
using namespace std;

int main(){
    int mod = 1e9+7;
    int N, X;
    cin >> N >> X;
    vector<int> S(N+1);
    for(int i=1; i<=N; i++) cin >> S[i];
    sort(S.begin(), S.end());

    vector<vector<ll>> dp = vector<vector<ll>>(X+1, vector<ll>(N+1, 0));
    for(int x=0; x<=X; x++){
        dp[x][1] = x%S[1];
    }
    
    for(int n=1; n<N; n++){
        for(int x=0; x<=X; x++){
            dp[x][n+1] = (dp[x%S[n+1]][n]%mod + dp[x][n]*n % mod)%mod;
        }
    }
    cout << dp[X][N] << endl;
}


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

using namespace std;
const long long MOD = 1e18;

vector<pair<long long, long long>> factorize(long long n) {
    vector<pair<long long, long long>> a;

    for (long long i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            int cnt = 0;
            while (n % i == 0) {
                n /= i;
                cnt++;
            }
            a.push_back(make_pair(i, cnt));
        }
    }
    if (n > 1) a.push_back(make_pair(n, 1));
    return a;

}

int main() {
    int a, b, c, d, e;
    cin >> a >> b >> c >> d >> e;
    if (a == 0) cout << 1;
    if (b == 0) cout << 2;
    if (c == 0) cout << 3;
    if (d == 0) cout << 4;
    if (e == 0) cout << 5;


    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset
typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
//void IO(){
//	#ifndef ONLINE_JUDGE
//	    freopen("input.txt", "r", stdin);
//	    freopen("output.txt", "w", stdout);
//	#endif
//}
// end of Template

int pre[3][200],n,a[3][200],mx;
int main(){
	//IO();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    for(int i=1;i<=2;i++){
        for(int j=1;j<=n;j++){
            cin>>a[i][j];
        }
    }
    for(int i=1;i<=n;i++){
        pre[1][i] = pre[1][i-1]+a[1][i];
    }
    for(int i=n;i>=1;i--){
        pre[2][i] = pre[2][i+1]+a[2][i];
    }
    for(int i=1;i<=n;i++){
        int temp = pre[1][i] + pre[2][i];
        mx = max(mx,temp);
    }
    cout<<mx<<newl;
}


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

int main()
{
	int n, m, x, y, box[200000];
	bool boxred[200000];
	
	cin >> n >> m;
	
	fill(box + 1, box + n + 1, 1);
	boxred[1] = true;

	for (int i = 1; i <= m; i++){
		cin >> x >> y;
		if (boxred[x] && box[x] == 1){
			boxred[x] = false;
			boxred[y] = true;
		}
		else if (boxred[x]){
			boxred[y] = true;
		}

		box[x]--;
		box[y]++;
	}
		
	cout << count(boxred + 1, boxred + n + 1, true) << endl;

	return (0);
}

Measured memory_bytes: 768
import java.util.ArrayList;
import java.util.Scanner;

class Main{



	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		int N = sc.nextInt();
		ArrayList<String> cc = new ArrayList<String>();
		String[] word = new String[N];
		for(int i = 0;i < N;i++){
			word[i] = sc.next();
		}
		cc.add(word[0]);
		for(int i = 1;i < N;i++){
			if(word[i-1].charAt(word[i-1].length()-1) != word[i].charAt(0)){
				System.out.println("No");
				return;
			}else{
				for(int j = 0;j < cc.size();j++){
					if(cc.get(j).equals(word[i])){
						System.out.println("No");
						return;
					}
				}
				cc.add(word[i]);
			}
		}
		System.out.println("Yes");

	}


}




class Pair implements Comparable{
	int from;		//p
	int end;		//y
	int num;
	int bango;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return from - otherpair.from;
	}
}



Measured memory_bytes: 21844
a, b, c, x, y = map(int, input().split())
if a+b >2*c:
    mini = min(x,y) #ABセットで揃えられる枚数
    ab_cost = mini * 2 * c
    remain = max(x-mini, y-mini)
    if x > y:
        remain_cost = min(remain * a, remain*2*c)
    else:
        remain_cost = min(remain * b, remain*2*c)
    print(ab_cost + remain_cost)
else:
    print(a*x+b*y)

Measured memory_bytes: 3064
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] heights = new int[n];
		for (int i = 0; i < n; i++) {
		    heights[i] = sc.nextInt();
		}
		ArrayList<ArrayList<Integer>> graph = new ArrayList<>();
		for (int i = 0; i < n; i++) {
		    graph.add(new ArrayList<>());
		}
		for (int i = 0; i < m; i++) {
		    int a = sc.nextInt() - 1;
		    int b = sc.nextInt() - 1;
		    graph.get(a).add(b);
		    graph.get(b).add(a);
		}
		int count = 0;
		for (int i = 0; i < n; i++) {
		    boolean flag = true;
		    for (int x : graph.get(i)) {
		        if (heights[i] <= heights[x]) {
		            flag = false;
		            break;
		        }
		    }
		    if (flag) {
		        count++;
		    }
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 71904
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
const int mod=1000000007;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,m;cin >> n >> m;
	ll ans=min(n,m/2);
	m-=ans*2;
	if(m>0) ans+=m/4;
	cout << ans << endl;
}

Measured memory_bytes: 256
import numpy as np
n,d = tuple(map(int,input().split()))

x = [np.array(tuple(map(int,input().split()))) for _ in [0]*n]

ans = 0
for i in range(n):
  for j in range(i+1,n):
    if np.linalg.norm(x[i]-x[j]).is_integer():
      ans+=1
print(ans)

Measured memory_bytes: 20772
N, S = map(int, input().split())
A = list(map(int, input().split()))

MOD = 998244353

dp = [[0]*(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] = (dp[i][j]*2 + 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: 139316
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

int main(int argc, const char * argv[]) {

    // source code
    // char s[4];
    int N, M;
    cin >> N >> M;
    int min_L = 1, min_R = 100000;
    rep(i, N){
      int L, R;
      cin >> L >> R;
      if (L > min_L){
        min_L = L;
      }
      if (R < min_R){
        min_R = R;
      }
    }
    if (min_L > min_R ){
      cout << 0 <<endl;
    }else{
      cout << min_R - min_L + 1 <<endl;
    }

    return 0;
}

Measured memory_bytes: 256
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
#include <iomanip>
#include <set>
#include <stack>
#include <bitset>

////多倍長整数, cpp_intで宣言
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;

#pragma GCC target ("avx2")
#pragma GCC optimization ("Ofast")
#pragma GCC optimization ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define repeat(i, n, m) for(int i = n; i < (m); ++i)
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printim(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a) //少数出力
#define printLdb(a) printf("%.50Lf\n", a) //少数出力
#define printdbd(a) printf("%.16lf\n", a) //少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str()) //string出力
#define all(x) (x).begin(), (x).end()
#define deg_to_rad(deg) (((deg)/360.0L)*2.0L*PI)
#define rad_to_deg(rad) (((rad)/2.0L/PI)*360.0L)
#define Please return
#define AC 0
#define manhattan_dist(a, b, c, d) (abs(a - c) + abs(b - d)) /*(a, b) から (c, d) のマンハッタン距離 */
#define inf numeric_limits<double>::infinity();
#define linf numeric_limits<long double>::infinity()

using ll = long long;
using ull = unsigned long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1e9 + 7;
constexpr ll mod = 998244353;
constexpr long double eps = 1e-6;
const long double PI = acosl(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);
	while (c != '\n' && c != -1 && c != ' ') {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

ll LSB(ll n) { return (n & (-n)); }

template<typename T>
inline T chmin(T& a, const T& b) {
	if (a > b)a = b;
	return a;
}

template<typename T>
inline T chmax(T& a, const T& b) {
	if (a < b)a = b;
	return a;
}


/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	int n;
	scanf("%d", &n);
	ll ans = 0;
	for (int a = 1; ; ++a) {
		for (int b = 1; ; ++b) {
			if (n - a * b > 0)++ans;
			else break;
		}
		if (n - a <= 0)break;
	}
	printf("%lld\n", ans);

	Please AC;
}


Measured memory_bytes: 3752
function main()
  
  N = parse(Int,readline())
  A = map(x -> parse(Int,x), split(readline()))
  B = zeros(Int,N)
  
  check = true
  
  for i in 1:N
    if A[i] % 2 == 0
      B[i] = A[i]
    end
  end
  
  for i in 1:N
    if B[i] % 3 != 0 && B[i] % 5 != 0
      check = false
      println("DENIED")
      break
    end
  end
  
  if check
    println("APPROVED")
  end
  
end

main()

Measured memory_bytes: 168224
local mmi, mma = math.min, math.max
local n, t = io.read("*n", "*n")
local a = {}
for i = 1, n do
  a[i] = io.read("*n")
end
local maxdiff = 0
local maxdiff_cnt = 0
local curmin = a[1]
for i = 2, n do
  if curmin < a[i] then
    if maxdiff < a[i] - curmin then
      maxdiff = a[i] - curmin
      maxdiff_cnt = 1
    elseif maxdiff == a[i] - curmin then
      maxdiff_cnt = maxdiff_cnt + 1
    end
  end
  curmin = mmi(curmin, a[i])
end
print(maxdiff_cnt)


Measured memory_bytes: 2928
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Text.RegularExpressions;
using System.Threading;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] inputLongArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            int A = inputLongArray[0];
            int B = inputLongArray[1];

            Console.WriteLine(A*B);
        }
    }
}

//文字列の入力
//string s = Console.ReadLine();
//整数の入力
//long n = long.Parse(Console.ReadLine());
//文字列配列の入力
//string[] inputStrArray = Console.ReadLine().Split(' ');
//整数配列の入力
//long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

//Console.WriteLine();
//Console.ReadKey();


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

// Shrotening
#define fst first
#define snd second
#define pb push_back

// Loop
#define FOR(i,a,b) for(auto i=(a);i<(b);++i)
#define RFOR(i,a,b) for(auto i=(a);i>=(b);--i)

#define REP(i,a) for(long i=0;i<(a);++i)
#define RREP(i,a) for(long i=(a);i>=0;--i)

#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)

//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) std::sort((a).begin(), (a).end())
#define UNIQUE(a) std::sort((a).begin(), a.end()), a.erase(std::unique((a).begin(), a.end()), a.end());
#define SUM(a) std::accumulate((a).begin(), (a).end(), 0);

//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);

//debug message
bool debug = true;
#define MSG(s)   if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}

//alias
typedef long long LL;
typedef std::vector<char> VC;
typedef std::vector<int>  VI;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;

typedef std::vector< VC > VC2;
typedef std::vector< VI > VI2;
typedef std::vector< VL > VL2;
typedef std::vector< VLL > VLL2;

typedef std::pair<int,int> PII;

int N, Y;

void check() {
    for(int i=0; i<=N; ++i) {
        for(int j=0; i+j<=N; ++j) {
            int k = std::max(0, N - i - j);
            int X = i * 10000 + j * 5000 + k * 1000;
            if(X == Y) {
                std::cout << i << " " << j << " " << k << std::endl;
                return;
            }
        }
    }
    std::cout << "-1 -1 -1" << std::endl;
}

int main() {
    std::cin >> N >> Y;
    check();
}

Measured memory_bytes: 256
def main():
    n, x = map(int, input().split())
    a = list(map(int, input().split()))
    ans = 1100100100100100100
    mina = [10000000000 for i in range(n)]
    for i in range(n):
        for j in range(n):
            mina[j] = min(mina[j], a[i - j])
        sumb = sum(mina)
        ans = min(ans, sumb + i * x)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader( new InputStreamReader(System.in));
		int a,b;
		String buf = br.readLine();
		StringTokenizer st= new StringTokenizer(buf, " ");

		a=Integer.parseInt(st.nextToken());
		b=Integer.parseInt(st.nextToken());


		System.out.println(a*b + " " + 2*(a+b));


	}
}

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

int main() {
    int n, f; cin >> n >> f;
    map<pair<string, string>, int> cnt;
    for(int i = 0; i < n; ++i) {
        int m; cin >> m;
        vector<string> v(m);
        for(int j = 0; j < m; ++j) {
            cin >> v[j];
        }
        sort(begin(v), end(v));
        for(int j = 0; j < m; ++j) {
            for(int k = j + 1; k < m; ++k) {
                cnt[make_pair(v[j], v[k])] += 1;
            }
        }
    }
    vector<pair<string, string>> ans;
    for(auto& p : cnt) {
        if(p.second >= f) ans.push_back(p.first);
    }
    cout << ans.size() << endl;
    for(auto& p : ans) {
        cout << p.first << " " << p.second << endl;
    }
}



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

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

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
string s[100005];
ll d[100005][10][10][10];
int main(){
    ll n,x,y,z;
    cin>>n>>x>>y>>z;
    for(int i=1;i<=n;i++){
        cin>>s[i];
    }
    x=min(x,(ll)3);y=min(y,(ll)3);z=min(z,(ll)3);
    d[0][x][y][z]=1;
    for(int i=1;i<=n;i++){
        for(int j=0;j<=4;j++){
            for(int k=0;k<=4;k++){
                for(int t=0;t<=4;t++){
                    if(s[i]=="AB"){
                        if(k-1>=0&&j+1<=4) d[i][j+1][k-1][t]|=d[i-1][j][k][t];
                        if(j-1>=0&&k+1<=4) d[i][j-1][k+1][t]|=d[i-1][j][k][t];
                    }
                    if(s[i]=="AC"){
                        if(t-1>=0&&j+1<=4) d[i][j+1][k][t-1]|=d[i-1][j][k][t];
                        if(j-1>=0&&t+1<=4) d[i][j-1][k][t+1]|=d[i-1][j][k][t];
                    }
                    if(s[i]=="BC"){
                        if(t-1>=0&&k+1<=4) d[i][j][k+1][t-1]|=d[i-1][j][k][t];
                        if(k-1>=0&&t+1<=4) d[i][j][k-1][t+1]|=d[i-1][j][k][t];
                    }
                }
            }
        }
    }
    int nx=-1,ny=-1,nv=-1;
    for(int j=0;j<5;j++){
        for(int k=0;k<5;k++){
            for(int t=0;t<5;t++){
                if(d[n][j][k][t]){
                    nx=j;ny=k;nv=t;break;
                }
            }
        }
    }
    if(nx==-1||ny==-1||nv==-1){
        cout<<"No"<<endl;
        return 0;
    }
    cout<<"Yes"<<endl;
    vector<char> ans;
    for(int i=n;i>=1;i--){
        if(s[i]=="AB"){
            if(nx-1>=0&&ny+1<=4&&d[i-1][nx-1][ny+1][nv]){
                ans.push_back('A');
                nx--;ny++;
            }
            else{
                ans.push_back('B');
                nx++;ny--;
            }
        }
        else if(s[i]=="AC"){
            if(nx-1>=0&&nv+1<=4&&d[i-1][nx-1][ny][nv+1]){
                ans.push_back('A');
                nx--;nv++;
            }
            else{
                ans.push_back('C');
                nx++;nv--;
            }
        }
        else if(s[i]=="BC"){
            if(nv-1>=0&&ny+1<=4&&d[i-1][nx][ny+1][nv-1]){
                ans.push_back('C');
                nv--;ny++;
            }
            else{
                ans.push_back('B');
                nv++;ny--;
            }
        }
    }
    reverse(ans.begin(),ans.end());
    for(int i=0;i<ans.size();i++){
        cout<<ans[i]<<endl;
    }
}

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

typedef long long int ll;
int main(){
    ll N , K;
    cin >> N >> K;
    vector<ll> A(N);
    ll L,R;
    for(int i = 0;i < N;i++){
        cin >> A[i];
        if(A[i] == 1){
            L = i;
            R = N - i - 1;
        }
    }
    if((L+R) % (K-1) == 0){
        cout << (L+R) / (K-1) << endl;
    }else{
        cout << (L+R) / (K-1) + 1 << endl;
    }
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<iomanip>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
#define LINF (long long)4e18

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;
 

int main(){
    int r; cin >> r;
    int ans = 3 * r * r;
    cout << ans << endl;

}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

class Dice {
 public:
  void rotate(char c, int *n) {
    int m[6];
    rep(j, 6) m[j] = n[j];
    if (c == 'N') {
      m[0] = n[1];
      m[1] = n[5];
      m[4] = n[0];
      m[5] = n[4];
      rep(j, 6) n[j] = m[j];
    } else if (c == 'S') {
      m[0] = n[4];
      m[1] = n[0];
      m[4] = n[5];
      m[5] = n[1];
      rep(j, 6) n[j] = m[j];
    } else if (c == 'W') {
      m[0] = n[2];
      m[2] = n[5];
      m[3] = n[0];
      m[5] = n[3];
      rep(j, 6) n[j] = m[j];
    } else if (c == 'E') {
      m[0] = n[3];
      m[2] = n[0];
      m[3] = n[5];
      m[5] = n[2];
      rep(j, 6) n[j] = m[j];
    } else if (c == 'R') {
      m[1] = n[3];
      m[2] = n[1];
      m[3] = n[4];
      m[4] = n[2];
      rep(j, 6) n[j] = m[j];
    } else {
      m[1] = n[2];
      m[2] = n[4];
      m[3] = n[1];
      m[4] = n[3];
      rep(j, 6) n[j] = m[j];
    }
  }

  bool is_tf(int t, int f, int *n) {
    if (t == n[5]) {
      rep(i, 2) {
        rotate('N', n);
      }
    } else if (t != n[0]) {
      rep(i, 4) {
        rotate('R', n);
        if (t == n[1]) {
          break;
        }
        if (i == 3) {
          return false;
        }
      }
      rotate('N', n);
    }
    rep(i, 4) {
      rotate('R', n);
      if (f == n[1]) {
        break;
      }
      if (i == 3) {
        return false;
      }
    }
    return true;
  }

  bool is_yn(int t, int f, int *n, int *m) {
    if (is_tf(t, f, n)) {
      int cnt = 0;
      for (int i = 2; i < 6; ++i) {
        if (m[i] == n[i]) {
          ++cnt;
        }
      }
      if (cnt == 4) {
        return true;
      } else
        return false;
    } else
      return false;
  }
};

int main() {
  int n[6], m[6];
  rep(i, 6) cin >> n[i];
  rep(i, 6) cin >> m[i];

  Dice d;
  rep(i, 5) {
    if (d.is_yn(m[i], m[i + 1], n, m)) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  
  cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 3108
import itertools
n=int(input())
p=tuple(map(int,input().split()))
q=tuple((map(int,input().split())))

l=[]
for i in range(n):
    l.append(i+1)
al=list(itertools.permutations(l))

for i in range(len(al)):
    if al[i]==p:
        p_ord=i
    if al[i]==q:
        q_ord=i

print(abs(p_ord-q_ord))

Measured memory_bytes: 8052
#include <bits/stdc++.h>
//#include <mylib.h>
using namespace std;
//cin.sync_with_stdio(false);

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define FOR_EQ(i,a,b) for(int i = (a); i <= (b); ++i)
#define FOR_RE(i,a,b) for(int i = (a); i > (b); --i)
#define rep(i,n) FOR(i,0,n)
#define rep_eq(i,n) FOR_EQ(i,0,n)
//1個上から時計周り
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
//上右下左
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> Vector;
typedef vector<Vector>	DVector;
int n;

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> n;
    int a[2][n];
    
    rep(i, 2){
        rep(j, n){
            cin >> a[i][j];
        }
    }
    
    int cumulative_sum[2][n];
    rep(i, 2){
        rep(j, n){
            if(i == 0){
                if(j == 0){
                    cumulative_sum[0][0] = a[0][0];
                }else{
                    cumulative_sum[i][j] = cumulative_sum[i][j - 1] + a[i][j];
                }
            }
            else{
                if(j == 0){
                    cumulative_sum[i][j] = cumulative_sum[i - 1][j] + a[i][j];
                }else{
                    cumulative_sum[i][j] = max(cumulative_sum[i][j - 1], cumulative_sum[i - 1][j]) + a[i][j];
                }
            }
        }
    }
    cout << cumulative_sum[1][n-1] << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i = (a);i<=(b);i++)
#define ROF(i,a,b) for(int i = (a);i>=(b);i--)
#define MST(a,x) memset(a,x,sizeof(a))
#define ll long long
#define PB push_back
#define PH push
#define MP make_pair
#define FT first
#define SD second
#define N 3005
#define M 51
#define INF 1000000007
#define MOD 1000000007
#define MOD2 1000000009
#define eps 1e-14
using namespace std;
inline int Max(int a,int b){return (((b-a)>>(32-1))&(a^b))^b;}
inline int Min(int a,int b){return (((b-a)>>(32-1))&(a^b))^a;}
int a[N],b[N];
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    while(cin>>n)
    {
        int mx = 0;
        MST(b,0);
        FOR(i,1,n)
        {
            cin>>a[i];
            b[a[i]]++;
            mx = max(mx,a[i]);
        }
        if(mx == 1)
        {
            if(n == 2)cout<<"Possible"<<endl;
            else cout<<"Impossible"<<endl;
            continue;
        }
        int f = 1;
        int mn = mx/2;
        ROF(i,mx,mn+1)
        {
            if(b[i]<2)
            {
                f = 0;
                break;
            }
        }
        if(mx%2 == 0)
        {
            if(b[mx/2]!=1)f = 0;
        }
        else
        {
            if(b[mx/2+1]!=2)f = 0;
        }

        if(mx%2)mn = mx/2;
        else mn = mx/2-1;
        FOR(i,1,mn)
        {
            if(b[i]>0)
            {
                f = 0;
                break;
            }
        }
        if(f)cout<<"Possible"<<endl;
        else cout<<"Impossible"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bitset>
using namespace std;
const int maxsize = 4*1e6+1;

int main(){
	int n;
	cin >> n;
	
	int sum=0;
	bitset<maxsize> dp;
	dp[0] = 1;
	for(int i=0; i<n; i++){
		int a;
		cin >> a;
		sum += a;
		dp |= dp << a;
	}
	for(int i=(sum+1)/2; i<sum+1; i++){
		if(dp[i] == 1){
			cout << i << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<map>
#include<numeric>
#include<set>
#include<string>
#include<utility>
#include<vector>
#include<queue>
#include<deque>

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MAX 1000000001
using namespace std;
typedef long long ll;

int a,b;

int main(){
  std::cin >> a >> b;
  if(b%a==0)std::cout << (a+b) << '\n';
  else std::cout << (b-a) << '\n';
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>

int field[14][14];

void dfs(int r,int c);

int main()
{
	int num;
	char buf[14];
	while(1)
	{
		num=0;
		memset(field,0,sizeof(field));
		for(int i=1;i<=12;i++)
		{
			if(std::cin.eof())break;
			std::cin.getline(buf,14);
			if(buf[0]=='\0')
			{
				i--;
				continue;
			}
			for(int j=1;j<=12;j++)
			{
				field[i][j]=buf[j-1]-'0';
			}
		}
		if(std::cin.eof())break;
		
		for(int i=1;i<=12;i++)
		{
			for(int j=1;j<=12;j++)
			{
				if(field[i][j]==1)
				{
					dfs(i,j);
					num++;
				}
			}
		}
		std::cout<<num<<std::endl;
	}
	return 0;
}

void dfs(int r,int c)
{
	field[r][c]=0;
	if(field[r-1][c]==1){dfs(r-1,c);}
	if(field[r+1][c]==1){dfs(r+1,c);}
	if(field[r][c-1]==1){dfs(r,c-1);}
	if(field[r][c+1]==1){dfs(r,c+1);}
}

Measured memory_bytes: 0
N,D = map(int,input().split())
count = 0
X = [0]*N
Y = [0]*N
for i in range(N):
    X[i],Y[i]=map(int,input().split())
d_2 = D**2
for i in range(N):
    if X[i]**2 + Y[i]**2 <= d_2:
        count += 1
print(count)


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

int main() {
  string S;
  cin >> S;
  
  string agct = "AGCT";
  int ans = 0;
  for(int i = 0; i < S.size(); ++i) {
    for (int j = i; j < S.size(); ++j) {
      string temp = S.substr(i, j + 1);
      int count = 0;
      rep(k, temp.size()) {
        if (agct.find(temp[k]) != string::npos) {
          count++;
        } else {
          count = 0;
          ans = max(ans, count);
        }
      }
      ans = max(ans, count);
    }
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        int[] array = new int[n];

        for (int i = 0; i < n; i++) {
            array[i] = sc.nextInt();
        }
        Arrays.sort(array);

        int m = array[n - 1];

        int idea = 0;
        int c = 0;
        for (int i = 0; i < n - 1; i++) {
            int v = Math.min(array[i], m - array[i]);
            if (v > idea) {
                idea = v;
                c = array[i];
            }
        }

        System.out.println(m + " " + c);
    }
}

Measured memory_bytes: 51736
#include <bits/stdc++.h>
#include <cctype>
using namespace std;
 
#define MD 1000000007
typedef long long int ll;

int main(){
    int n,k;
    cin>>n>>k;
    map<int,int> mp;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        if(!mp.count(a)){//キーaが見つからなかったら
            mp[a]=1;
        }else{
            mp[a]++;
        }
    }
    ll cnt=mp.size();//cntは初期種類の数
    if(cnt<=k){
        cout<<0<<endl;
        
    }else{
        vector<int> data;
        for(auto itr=mp.begin();itr!=mp.end();itr++){
            data.push_back(itr->second);
        }
        sort(data.begin(),data.end());
        ll ans=0;
        for(int i=0;i<cnt-k;i++){
            ans+=data[i];
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 10748
#include <iostream>
using namespace std;
int N, M;
int X;
int sum = 0, p = 0;

int main()
{
    cin >> N >> M;
    sum = 1900.0 * M + 100.0 * (N - M);
    p = 1;
    for(int i = 1; i <= M; i++)
    {
        p = p * 2;
    }
    int ans = 0.0, s = sum;

    cout << sum * p << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <random>

int main(void){
    int n; std::cin >> n;
    std::vector<int> A(n + 1, 0);
    for(long long int x = 1; x * x <= n; ++x){
        for(long long int y = 1; y * y + x * x <= n; ++y){
            for(long long int z = 1; ; ++z){
                const long long int v = x * x + y * y + z * z + (x * y) + y * z + z * x;
                if(v <= n){
                    A[v]++;
                }
                else break;
            }
        }
    }
    for(int i = 1; i <= n; ++i) std::cout << A[i] << '\n';
}

Measured memory_bytes: 3588
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define print(x) cout<<x<<endl
#define printyes cout<<"Yes"<<endl
#define printno cout<<"No"<<endl
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}

double distance(ddatas& x,ddatas& y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}
void judgement(int a){
  if(a){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  if(a){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}

int main(){
  ll i,A,B,C,ans;
  cin>>A>>B;
  print(A-(A>B));
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>

const int MaxN = 200000;

int N;
int A[MaxN + 5];
int Buc[MaxN + 5];

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

void solve() {
  long long s = 0;
  for (int i = 1; i <= N; ++i) {
    s -= 1LL * Buc[A[i]] * (Buc[A[i]] - 1) / 2;
    Buc[A[i]]++;
    s += 1LL * Buc[A[i]] * (Buc[A[i]] - 1) / 2;
  }
  for (int i = 1; i <= N; ++i) {
    s -= 1LL * Buc[A[i]] * (Buc[A[i]] - 1) / 2;
    Buc[A[i]]--;
    s += 1LL * Buc[A[i]] * (Buc[A[i]] - 1) / 2;
    printf("%lld\n", s);
    s -= 1LL * Buc[A[i]] * (Buc[A[i]] - 1) / 2;
    Buc[A[i]]++;
    s += 1LL * Buc[A[i]] * (Buc[A[i]] - 1) / 2;
  }
}

int main() {
  init();
  solve();
  return 0;
}

Measured memory_bytes: 3584