akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;



#define ll long long
#define ull unsigned long long
#define rep(i,N) for (ll i=0;i<N;i++)
#define loop(i,N,M) for(ll i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)

ll debugFlag = false;
template<typename T> void debug(T&);
template<typename T> void debug(T&, bool);
template<typename T> void debug(vector<T>&);
template<typename T> void debug(vector<T>&, bool);
template<typename T, typename U> void debug(pair<T, U>&);
template<typename T, typename U> void debug(pair<T, U>&, bool);

template<typename T>
void debug(T& obj) {
	debug(obj, true);
}

template<typename T>
void debug(T& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << obj;
	if (lnFlag) cout << endl;
}

template<typename T>
void debug(vector<T>& obj) {
	debug(obj, true);
}

template<typename T>
void debug(vector<T>& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << "[";
	rep(i, obj.size()) {
		if (i != 0) cout << ",";
		debug(obj[i], false);
	}
	cout << "]";
	if (lnFlag) cout << endl;
}

template<typename T, typename U>
void debug(pair<T, U>& obj) {
	debug(obj, true);
}

template<typename T, typename U>
void debug(pair<T, U>& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << "(";
	debug(obj.first, false);
	cout << ",";
	debug(obj.second, false);
	cout << ")";
	if (lnFlag) cout << endl;
}

bool isPrime(ll num) {

	bool flag = true;
	for (int i = 2; i <= sqrt(num); i++) {
		if (num%i == 0) {
			flag = false;
			break;
		}
	}

	return flag;
}


void solve() {

	ll N, K;
	string S;
	cin >> N >> K >> S;

	ll bad = 0;
	ll good = 0;

	for (ll i = 0; i < N - 1; i++) {
		if (S[i] == 'L' && S[i + 1] == 'R') good++;
		if (S[i] == 'R' && S[i + 1] == 'L') bad++;
	}

	ll repair = min(K, min(good, bad));
	K -= repair;
	good -= repair;
	bad -= repair;

	ll ans = N - (bad * 2);
	if (S[0] == 'L') ans--;
	if (S[N - 1] == 'R') ans--;

	if (K > 0 && good > 0 && S[0] == 'L') {
		ans++;
		K--;
		good--;
	}
	if (K > 0 && good > 0 && S[N - 1] == 'R') {
		ans++;
		K--;
		good--;
	}

	if (bad > 0 && K > 0 && S[0] == 'R') {
		ans++;
		bad--;
		K--;
	}
	if (bad > 0 && K > 0 && S[N - 1] == 'L') {
		ans++;
		bad--;
		K--;
	}

	cout << ans;

}


int main(int argc, char* argv[]) {
	if (argc == 2 && string(argv[1]) == "debug") debugFlag = true;
	solve();
	return 0;
}


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

#define forn(i,x,n)       for(int i=x; i<n; i++)
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

void zeus()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
int h, w, k;
vector<pii> dir = {{0, 1}, {1, 0}, { -1, 0}, {0, -1}};
bool isin(int i, int j) {
	return (i > 0 && j > 0 && i <= h && j <= w);
}
void bfs(int x1, int y1, int x2, int y2, vector<vector<char>> pond, vector<vi>& visited, vector<vi>& dist) {

	visited[x1][y1] = 1;
	dist[x1][y1] = 0;
	queue<pii> q;
	q.push({x1, y1});

	while (!q.empty()) {
		pii x = q.front();
		q.pop();
		// cout << x.ff << " " << x.ss << endl;

		forn(i, 0, 4) {

			forn(j, 1, k + 1) {
				int i1 = x.ff + j * dir[i].ff;
				int j1 = x.ss + j * dir[i].ss;

				if (!isin(i1, j1)) {
					break;
				}
				if (pond[i1][j1] == '@') {
					break;
				}
				if (visited[i1][j1] && dist[i1][j1] < 1 + dist[x.ff][x.ss]) {
					break;
				}
				if (!visited[i1][j1]) {
					visited[i1][j1] = 1;
					dist[i1][j1] = 1 + dist[x.ff][x.ss];
					q.push({i1, j1});
					// cout << i1 << " " << j1 << endl;
				}
				if (i1 == x2 && j1 == y2) {
					return;
				}
			}
		}
	}

}
int32_t main()
{
	zeus();
	cin >> h >> w >> k;
	int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
	vector<vector<char>> pond(h + 1, vector<char>(w + 1));
	vector<vector<int>> visited(h + 1, vector<int>(w + 1));
	vector<vector<int>> dist(h + 1, vector<int>(w + 1));

	forn(i, 1, h + 1) {
		forn(j, 1, w + 1) {
			cin >> pond[i][j];
		}
	}

	if (pond[x1][y1] == '@' || pond[x2][y2] == '@') {
		cout << -1 << endl;
		return 0;
	}
	bfs(x1, y1, x2, y2, pond, visited, dist);

	if (visited[x2][y2] == 0) {
		cout << -1 << endl;
	}
	else {
		cout << dist[x2][y2] << endl;
	}



}

Measured memory_bytes: 44124
#include<bits/stdc++.h>
#define ll long long
#define f(i,l,r) for(int i=l;i<r;i++)
using namespace std;
string s,t,ans="";
ll dp[3001][3001];
ll solve(int l,int r)
{
    if(dp[l][r]!=-1)
    return  dp[l][r];
    if(l==s.size()||r==t.size())
    {
        return dp[l][r]=0;
    }
    if(s[l]==t[r])
    {
        return dp[l][r]=1+solve(l+1,r+1);
    }
    else
    {
        return dp[l][r]=max(solve(l+1,r),solve(l,r+1));
    }
    
}
void put(int l,int r)
{
    if(l==s.size()||r==t.size())
        return;
    if(s[l]==t[r])
    {
        ans+=s[l];
        put(l+1,r+1);
    }
    else
    {
        if(dp[l+1][r]>dp[l][r+1])
            put(l+1,r);
        else
        {
            put(l,r+1);
        }
        
    }
    
    
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    for(int i=0;i<3001;i++)
        for(int j=0;j<3001;j++)
            dp[i][j]=-1;
    cin>>s>>t;
    //cout<<s<<t;
    solve(0,0);
    put(0,0);
    cout<<ans;
    return 0;
}

Measured memory_bytes: 70912
#include <stdio.h>
#include <string.h>

int main(int argc, char const *argv[]) {
  char S[4];
  int answer = 0;
  //入力
  scanf("%s", S );
  //計算
  for (size_t i = 0; i < 4; i++) {
    if ( S[i] == '+' ) {
      answer ++;
    } else {
      answer --;
    }
  }
  //出力
  printf("%d\n", answer );
  return 0;
}

Measured memory_bytes: 128
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/* 
 * File:   main.c
 * Author: kundaikwangwari
 *
 * Created on July 16, 2019, 2:19 PM
 */

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

int HeapSize;

void swap(int *A, int i, int j){
    
    int temp = A[i];
    A[i] = A[j];
    A[j] = temp;
}

void MaxHeapify(int *A, int i){
    
    int LF, RL, PN, largest;
    LF = 2*i;
    RL = 2*i + 1;
      // select the node which has the maximum value
      if((LF <= HeapSize) && (A[LF] > A[i]))largest = LF;
      else largest = i;
      if((RL <= HeapSize) && (A[RL] > A[largest]))largest = RL;
    
     if(largest != i){
         // value of children is larger than that of i
         swap (A,i,largest);
         MaxHeapify(A,largest);
     }
    

 
}


int main(int argc, char** argv) {

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

    for(int i = (n+1/2)+1; i >= 1 ;i--){
        MaxHeapify(A,i);
    }
    
    for(int i = 1; i < n + 1; i++){
        
      printf(" %d",A[i]);  
        
    }
    printf("\n");
    return (0);
}




Measured memory_bytes: 3684
import java.util.Scanner;

/**
 *
 * @author k16075kk
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int n = sc.nextInt();
            if (n == 0) {
                break;
            }
            int[] s = new int[n];
            int sum = 0;
            for (int i = 0; i < n; i++) {
                s[i] = sc.nextInt();
                sum += s[i];
            }
            double m = sum / (double) n;
            double a = 0.0;
            for (int i = 0; i < n; i++) {
                a += (s[i] - m) * (s[i] - m);
            }
            a = a / (double) n;

            System.out.println(Math.sqrt(a));

        }
    }

}



Measured memory_bytes: 31256
#include <iostream>

using namespace std;

int main() {
    string str;
    cin >> str;
    
    int ans=0;
    for(int i=0; i<str.size()-1; i++) {
        if(str[i]!=str[i+1]) {
            ans++;
        }
    }
    
    cout << ans << endl;


    return 0;
    
}

Measured memory_bytes: 512
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;


void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,k;
    cin >> n >> k;
    string s;
    cin >> s;
    if(s[k-1]>='A'&&s[k-1]<='Z') s[k-1] = s[k-1] - 'A' + 'a';
    cout << s;

    return 0;
}

Measured memory_bytes: 3656
#include<map>
#include<set>
#include<cmath>
#include<regex>
#include<queue>
#include<stack>
#include<bitset>
#include<vector>
#include<cstdio>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<unordered_map>

#pragma warning(disable:4996)
using namespace std;

int main() {
	double r1, r2;
	scanf("%lf%lf",&r1,&r2);
	printf("%.12f\n",r1*r2/(r1+r2));
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

int main() {
  int n;
  map<string, int> mp;
  cin >> n;
  rep(i, n) {
    string s;
    cin >> s;
    mp[s]++;
  }
  vector<P> v;
  for (auto m : mp) {
    v.push_back(P(m.second, m.first));
  }
  sort(v.begin(), v.end());
  int m = v.back().first;
  for (auto p : v) {
    if (m == p.first) {
      cout << p.second << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 29344
/***** author :  C0d1ngPhenomena *****/

#include <bits/stdc++.h>
#define endl "\n"
#define ll long long int
#define TestCases int T; cin>>T; while(T--)
#define rep(i,a,b) for(ll i = a; i < b; i++)
#define revrep(i,a,b) for(ll i = b-1; i >= a; i--)
#define vll vector<ll>
#define vvll vector < vll >
#define pll pair<ll, ll>
#define vpll vector <pll>
#define mp(x,y) make_pair(x,y)
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define alld(c) c.begin(),c.end(),greater<int>()
#define mem(a,val) memset(a,val,sizeof(a))
#define f first
#define s second
#define pb push_back
using namespace std;

int main()
{
	std::ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	string str;
	cin >> str;
	ll sum = 0;

	rep(i, 0, str.length())
	sum += str[i] - 48;

	if (sum % 9 == 0)
		cout << "Yes";
	else
		cout << "No";

	return 0;
}







Measured memory_bytes: 3788
def sum_subarrays(A, mod=10**9+7):
    N = len(A)
    S = [0]
    for a in A:
        S.append(S[-1] + a)
        S[-1] %= mod
    return sum((2 * i - N) * s % mod for i, s in enumerate(S)) % mod

n,m = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
mod = 10 ** 9 + 7
diff_x = [x[i+1]-x[i] for i in range(n-1)]
diff_y = [y[i+1]-y[i] for i in range(m-1)]
ans = sum_subarrays(diff_x) * sum_subarrays(diff_y) % mod
print(ans)  

Measured memory_bytes: 23056
#include <iostream>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(n);++i)
const int INF = 1e9;


int main() {
  int N, K; cin >> N >> K;
  int dp[N];

  int h[N];
  rep(i, N) {
    dp[i] = INF;
    cin >> h[i];
  }
  dp[0] = 0;
  rep(i, N-1) {
    rep(j, K) {
      if (i+j+1 >= N)
        break;
      dp[i+j+1] = min(dp[i+j+1], abs(h[i] - h[i+j+1]) + dp[i]);
    }
  }
  cout << dp[N-1] << endl;

  return 0;
}


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

signed main(){
  int A,B;
  cin>>A>>B;
  string ans="Yay!";
  if(A>8||B>8)ans=":(";
  cout<<ans<<endl;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
 
#define ll long long
#define ull unsigned long long
#define db long double
#define pb push_back
#define ppb pop_back
#define F first
#define S second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <ll> vll;

typedef tree <pii, null_type, less <pii>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int N = 2e6, P = 29;
const pii MOD = {1e9 + 7, 1e9 + 9};
string s, t;

struct Num {
	int x = 0, y = 0;
	Num(int a = 0) {
		x = a, y = a;
	}
	Num operator + (const Num & a) const {
		Num res;
		res.x = x + a.x;
		if (res.x >= MOD.F) {
			res.x -= MOD.F;
		}
		res.y = y + a.y;
		if (res.y >= MOD.S) {
			res.y -= MOD.S;
		}
		return res;
	}
	Num operator - (const Num & a) const {
		Num res;
		res.x = x - a.x;
		if (res.x < 0) {
			res.x += MOD.F;
		}
		res.y = y - a.y;
		if (res.y < 0) {
			res.y += MOD.S;
		}
		return res;
	}
	Num operator * (const Num & a) const {
		Num res;
		res.x = (ll)x * a.x % MOD.F;
		res.y = (ll)y * a.y % MOD.S;
		return res;
	}
	bool operator == (const Num & a) const {
		return x == a.x && y == a.y;
	}
};

Num h[N], p[N], T;
int a[N], good[N];

int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	cin >> s >> t;
	int n = s.size(), m = t.size();
	string c = s;
	while ((int)c.size() < n + m) {
		c += s;
	}
	int k = c.size();
	p[0] = 1;
	for (int i = 1; i <= k; i++) {
		p[i] = p[i - 1] * P;
		h[i] = h[i - 1] + p[i] * (c[i - 1] - 'a');
	}
	for (int i = 1; i <= m; i++) {
		T = T + p[i] * (t[i - 1] - 'a');
	}
	for (int i = 1; i <= n; i++) {
		if (T * p[i - 1] == h[i + m - 1] - h[i - 1]) {
			a[i - 1] = 1;
		}
	}
	int g = __gcd(n, m);
	for (int i = 0; i < g; i++) {
		good[i] = 1;
	}
	for (int i = 0; i < n; i++) {
		if (a[i] == 0) {
			good[i % g] = 0;
		}
	}
	for (int i = 0; i < g; i++) {
		if (good[i]) {
			cout << -1;
			return 0;
		}
	}
	int ans = 0;
	vi vec, tmp;
	for (int i = 0; i < g; i++) {
		vec.clear();
		tmp.clear();
		int j = (i + m) % n;
		while (true) {
			vec.pb(a[j]);
			if (j == i) {
				break;
			}
			j = (j + m) % n;
		}
		int one = 0;
		while (!vec.empty() && vec.back() == 1) {
			one++;
			vec.ppb();
		}
		while (one--) {
			tmp.pb(1);
		}
		for (int j : vec) {
			tmp.pb(j);
		}
		vec.clear();
		int sz = tmp.size(), last = -1, res = 0;
		for (int i = 0; i <= sz; i++) {
			if (i == sz || tmp[i] == 0) {
				res = max(res, (i - 1) - last);
				last = i;
			}
		}
		ans = max(ans, res);
	}
	cout << ans;
}


Measured memory_bytes: 44692
a, b = map(int, input().split())
t = 0
w = 0
k = a*b
if a > b:
    t = b
    w = a
else:
    t = a
    w = b
for i in range(1,t):
    if w * i % t == 0:
        k=w*i
        break
print(k)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
const int N = 1e6 + 5;
const ll mod = 998244353;
const int DEG = 30;
const double pi = acos(-1.0);
const double eps = 1e-8;
const int inf = 0x3f3f3f3f;
static auto faster_iostream = []() {
    std::ios::sync_with_stdio(false);  // turn off sync
    std::cin.tie(nullptr);             // untie in/out streams
    return 0;
}();
int a[N];
int main(){
	int n;
	while(cin >> n){
		for(int i = 1; i <= n; i++){
			cin >> a[i];
		}
		int ans = 0;
		vector<int> v;
		for(int i = 2; i <= n - 1; i++){
			v.clear();
			v.push_back(a[i - 1]);
			v.push_back(a[i]);
			v.push_back(a[i + 1]);
			sort(v.begin(), v.end());
			if(v[1] == a[i]){
				ans++;
			}
		}
		cout << ans << endl;
	}
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) ll aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) string aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main() {
		
	vec(A)
      int i=0;
  int maxi=10;
	fx(5){
		vecp(A)
         if(A.at(x)%10!=0&&maxi>A.at(x)%10){
          i=x;
           maxi=A.at(x)%10;
         }
	}
	int ans=0;

	fx(5){
		ans+=A.at(x);
		if(x!=i&&A.at(x)%10!=0){
			ans+=10-A.at(x)%10;
		}
	}
	ce(ans)
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void sreach(int aim, int nofA, int A[]) {
        int bin[] = new int[nofA];
        int n = 0;
        int x = 0;
        int maxX = 1;
        int ans = 0;
        for (int i = 0; i < nofA; i++) {
            maxX = maxX * 2;
        }
        maxX--;
        for (int xvalue = maxX; xvalue >= 0; xvalue--) {
            x = xvalue;
            while (x >= 2) {
                bin[n] = x % 2;
                n++;
                x = x / 2;
            }
            bin[n] = x;
            for (int i = n + 1; i < nofA; i++) {
                bin[i] = 0;
            }
            for (int i =  nofA-1; i>=0; i--) {
                if (bin[i] == 1)
                    ans = ans + A[i];
            }
            if (ans == aim) {
                System.out.println("yes");
                break;
            }
            if(x == 0)System.out.println("no");
            n = 0;
            ans =0;
        }
    }
    
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = 1, q = 1;
        n = scan.nextInt();
        int a[] = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = scan.nextInt();
        }
        q = scan.nextInt();
        int m[] = new int[q];
        for (int i = 0; i < q; i++) {
            m[i] = scan.nextInt();
        }
        scan.close();
        for (int i = 0; i < q; i++) {
            sreach(m[i], n, a);
        }
    }
}


Measured memory_bytes: 27868
N, M = list(map(int, input().split()))
H = list(map(int, input().split()))
good = [True]*N
for _ in range(M):
    a, b = list(map(int, input().split()))
    a -= 1
    b -= 1
    if H[a] >= H[b]:
        good[b] = False
    if H[a] <= H[b]:
        good[a] = False
print(good.count(True))


Measured memory_bytes: 86072
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024*1024), bufio.MaxScanTokenSize)
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	n := nextInt()

	switch n % 10 {
	case 2, 4, 5, 7, 9:
		fmt.Println("hon")
		break
	case 0, 1, 6, 8:
		fmt.Println("pon")
		break
	case 3:
		fmt.Println("bon")
		break
	}
}


Measured memory_bytes: 1788
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

//Amazing Graze
public class Main{

	class R{
		int x, y;
		public R(int x, int y) {
			this.x = x;
			this.y = y;
		}
	}
	class Scanner {
		int nextInt() {
			try {
				int c = System.in.read();
				while (c != '-' && (c < '0' || '9' < c))
					c = System.in.read();
				if (c == '-') return -nextInt();
				int res = 0;
				do {
					res *= 10;
					res += c - '0';
					c = System.in.read();
				} while ('0' <= c && c <= '9');
				return res;
			} catch (Exception e) {
				return -1;
			}
		}
	}
	
	@SuppressWarnings("unchecked")
	void run(){
		Scanner sc = new Scanner();
		int N = 250, M = 45;
		List<R>[][] l = new List[N][N];
		for(int i=0;i<N;i++)for(int j=0;j<N;j++)l[i][j]=new ArrayList<R>();
		int[][] d = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,0},{0,1},{1,-1},{1,0},{1,1}};
		for(;;){
			int AN = sc.nextInt(), BN = sc.nextInt(), R = sc.nextInt();
			if((AN|BN)==0)break;
			for(int i=0;i<N;i++)for(int j=0;j<N;j++)l[i][j].clear();
			for(int i=0;i<AN;i++){
				int x = sc.nextInt(), y = sc.nextInt();
				l[x/M][y/M].add(new R(x, y));
			}
			int res = 0;
			while(BN--!=0){
				int x = sc.nextInt(), y = sc.nextInt();
				Set<Integer> u = new HashSet<Integer>();
				for(int k=0;k<9;k++){
					int nx = x+d[k][0]*4*R, ny = y+d[k][1]*4*R;
					if(0<=nx&&nx<10000&&0<=ny&&ny<10000)u.add((nx/M)*N+ny/M);
				}
				for(int v:u)for(R r:l[v/N][v%N])res+=(r.x-x)*(r.x-x)+(r.y-y)*(r.y-y)<=16*R*R?1:0;
			}
			System.out.println(res);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 21000
#include <cstdio>
#include <memory.h>
#include <cstring>
#include <vector>
#include <deque>
#include <cstdlib>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <functional>
#include <iostream>
#include <set>
#include <list>
#include <map>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
using namespace std;

typedef unsigned long long llu;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<string, int> psi;
const ll MOD = 1e9 + 7;
const long double PI = 3.141592653589793238462643383279502884197;

priority_queue<int, vector<int>, greater<int> > pq;
vector<int> v;

int n;
int vec[100000];

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &vec[i]);
		vec[i] *= 2;
	}
	sort(vec, vec + n);

	int a = vec[n - 1];
	int b = a / 2;

	int miv = 2e9, mivi;
	for (int i = 0; i < n; i++) {
		if (miv > abs(b - vec[i])) {
			miv = abs(b - vec[i]);
			mivi = vec[i];
		}
	}

	printf("%d %d\n", a / 2, mivi / 2);
}

Measured memory_bytes: 640
import bisect

n=int(input())
l=list(map(int,input().split()))

l.sort()

ans=0

for i in range(n-2):
  for j in range(i+1,n-1):
    t=l[i]+l[j]-1
    index=bisect.bisect_right(l,t,j,n)
    ans+=max(0,index-j-1)
print(ans)

Measured memory_bytes: 43740
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<limits.h>
#define INF 100000
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)

using namespace std;
typedef pair<int,int> P;
int w,h;
int imap[21][21];
int fin;
int djd[20][2]; // 0->x ,1->y
int mmaapp[20][20];
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};

int bfs(int sp,int gp){
  int mmap[21][21];
 
  for(int i=0;i<21;i++)for(int j=0;j<21;j++)mmap[i][j] = INF;
  queue<P> que;
  que.push(P(djd[sp][0],djd[sp][1]));
  mmap[djd[sp][1]][djd[sp][0]]=0;

  while(que.size()){
    P p = que.front();que.pop();

    if(p.first == djd[gp][0] && p.second == djd[gp][1])return mmap[djd[gp][1]][djd[gp][0]];

    for(int i=0;i<4;i++){
      int nx = p.first+dx[i],ny = p.second+dy[i];
      if(0<=nx && nx < w && 0<=ny && ny < h && mmap[ny][nx] == INF && imap[ny][nx] != -1){
	que.push(P(nx,ny));
	mmap[ny][nx] = mmap[p.second][p.first] + 1;
      }
    }
  }
  return -1;
}



int main(){
  char in;
  int count;
  int permutationtest[66];
  while(true){
    cin >> w >> h;
    if(w+h == 0)break;
    rep(i,66)permutationtest[i] = 0;  
    count=1;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	cin >> in;
	switch(in){
	case '.':
	  imap[i][j]=0;
	  break;
	case 'o':
	  imap[i][j]=0;
	  djd[0][0]=j;
	  djd[0][1]=i;
	  break;
	case 'x':
	  imap[i][j]=-1;
	  break;
	case '*':
	  imap[i][j]=0;
	  djd[count][0]=j;
	  djd[count][1]=i;
	  count++;
	  break;
	default:

	  break;
	}
      }
    }
    fin=INF;
    for(int i=0;i<count;i++){
      for(int j=0;j<count;j++){
	mmaapp[i][j] = bfs(i,j);
	fin = min(fin,mmaapp[i][j]);
      }
   
    }
   
   
   
    for(int i=0;i<count-1;i++){
      permutationtest[i] = i+1;
   
    }
    
    
    
    int sum;
    int ans=INF;
    do{
      sum=0;
      sum+=mmaapp[0][permutationtest[0]];
    
      for(int i=1;i<count-1;i++){
	sum+=mmaapp[permutationtest[i-1]][permutationtest[i]];
      }
    
      ans=min(ans,sum);
    }while(next_permutation(permutationtest,permutationtest+(count-1)));

    if(fin < 0)cout << "-1" << endl;// finの初期化忘れてた
    else cout << ans << endl;


  }


  return 0;
}

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

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#include <map>
#include <set>
#define all(x) (x).begin(),(x).end()

const int MOD = 1e9 + 7;

void solve(){

}
int main(){
    string N;
    cin >> N;
    if (N[0] == N[2]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


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

using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
template <typename T> constexpr T inf = numeric_limits<T>::has_infinity ? numeric_limits<T>::infinity() : numeric_limits<T>::max() / 4;

#define REP(i, stop) FOR(i, 0, stop)
#define FOR(i, start, stop) for (int i = start, i##_len = stop; i < i##_len; ++i)
#define RREP(i, n) for (int i = n; i-- > 0;)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define COMP(key) [](const auto& a, const auto& b) { return a.key < b.key; }

struct InitCpp { InitCpp() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } initCpp;

class UnionFind { private: std::vector<size_t> P; std::vector<size_t> S; public: size_t find(size_t x) { return P[x] == x ? x : P[x] = find(P[x]); } public: UnionFind(size_t n) { P.resize(n); iota(P.begin(), P.end(), 0); S.resize(n); fill(S.begin(), S.end(), 1); } void unite(size_t x, size_t y) { x = find(x); y = find(y); if (x == y) return; if (S[x] < S[y]) { P[x] = y; S[y] += S[x]; } else { P[y] = x; S[x] += S[y]; } } bool same(size_t x, size_t y) { return find(x) == find(y); } size_t size(size_t x) { return S[find(x)]; } };

signed main() {
  vector<i64> F(1001);
  F[0] = 1;
  F[1] = 2;
  FOR(i, 2, 1001) {
    F[i] = (F[i - 1] + F[i - 2]) % 1001;
  }
  i64 v, d;
  while (cin >> v >> d) {
    UnionFind uf(v + 1);
    for (i64 i = 1; i <= v; ++i) {
      for (i64 j = i + 1; j <= v; ++j) {
        if (abs(F[i] - F[j]) < d) {
          uf.unite(i, j);
        }
      }
    }
    set<i64> roots;
    for (i64 i = 1; i <= v; ++i) {
      roots.insert(uf.find(i));
    }
    cout << roots.size() << endl;
  }
}



Measured memory_bytes: 3240
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x);i<=(y);i++)
using namespace std;
#define N 105
int n,m,a[N],cnt,len;
int main(){
	scanf("%d%d",&n,&m);
	rep (i,1,m) scanf("%d",&a[i]),cnt+=(a[i]&1);
	if (m==1){
		if (n==1) printf("1\n1\n1");else printf("%d\n2\n%d 1\n",n,n-1);
		return 0;
	}
	if (cnt>2) return puts("Impossible"),0;
	rep (i,1,m)
		if (a[i]&1)
			if (!(a[1]&1)) swap(a[1],a[i]);else swap(a[m],a[i]);
	rep (i,1,m) printf("%d ",a[i]);puts("");
	len=m;if (a[m]==1) len--;
	printf("%d\n",len);
	rep (i,1,m){
		if (i==1) printf("%d ",a[1]+1);
		else if (i==m){if (a[m]>1) printf("%d ",a[m]-1);}
		else printf("%d ",a[i]);
	}
	return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
#include<boost/operators.hpp>
#include<boost/dynamic_bitset.hpp>

namespace adaptor = boost::adaptors;
using index_t = std::size_t;
	
void Main()
{
	int N;
	std::cin >> N;
	for (auto a : boost::irange(1, 10))
	{
		for (auto b : boost::irange(1, 10))
		{
			if (a * b == N)
			{
				std::cout << "Yes" << std::endl;
				return;
			}
		}
	}
	std::cout << "No" << std::endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>

using namespace std;
typedef long long ll;

int gcd(int x, int y) {
  if (x < y) swap(x, y);
  while (y > 0) {
    int r = x % y;
    x = y;
    y = r;
  }
  return x;
}

/*迷路
const int INF = 50;

typedef pair<int,int> P;
char field[52][52];
int d[51][51];
int r,c;
int sx,sy;
int gx,gy;

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

int bfs(){
    queue<P> que;
    for(int i=0;i<r;i++){
        for(int j=0;j<c;j++){
            d[i+1][j+1] = INF;
        }
    }
    que.push(P(sy,sx));
    d[sy][sx]=0;
while(que.size()){
    P p=que.front();
    que.pop();
    if(p.second==gx&&p.first==gy) break;
    for(int i=0;i<4;i++){
        int nx=p.second+dx[i];
        int ny=p.first+dy[i];

        if(1<=nx&&nx<=c&&1<=ny&&ny<=r&&field[ny][nx]!='#'&&d[ny][nx]==INF){
            que.push(P(ny,nx));
            d[ny][nx] = d[p.first][p.second] + 1;
        }
    }
}
return d[gy][gx];
}
*/

int main(){
    int n;
    cin>>n;
    int a[n];
    for(int i = 0; i< n; i++) cin>>a[i];
    int x[n];
    for(int i = 0; i< n; i++){
        if(i == 0) x[i] = 0;
        else if(i == 1) x[i] = a[0];
        else{
            x[i] = gcd(x[i-1],a[i-1]);
        }
    }
    int y[n];
    for(int i = 0; i< n; i++){
        if(i == 0) y[n-1-i] = 0;
        else if(i == 1) y[n-1-i] = a[n-1];
        else{
            y[n-1-i] = gcd(y[n-i],a[n-i]);
        }
    }
    int max = 0;
    for(int i = 0; i<n; i++){
        if(max<gcd(x[i],y[i])) max = gcd(x[i],y[i]);
    }
    cout<<max<<endl;
    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>

typedef long long ll;

int main(int argc, char* argv[])
{
  ll n;
  std::cin >> n;

  std::vector< ll > va(n, 0);
  std::vector< ll > vb(n, 0);
  std::vector< ll > vc(n, 0);
  for (int i = 0; i < n; i++) {
    std::cin >> va[i];
  }
  for (int i = 0; i < n; i++) {
    std::cin >> vb[i];
  }
  for (int i = 0; i < n; i++) {
    std::cin >> vc[i];
  }

  std::sort(va.begin(), va.end());
  std::sort(vc.begin(), vc.end());

  std::vector< ll >::iterator ita;
  std::vector< ll >::iterator itb;
  std::vector< ll >::iterator itc;

  ll ans = 0;

  for (itb = vb.begin(); itb != vb.end(); itb++) {
    ll A = std::lower_bound(va.begin(), va.end(), *itb) - va.begin();
    ll C = std::upper_bound(vc.begin(), vc.end(), *itb) - vc.begin();
    //std::cout << (va.size() - std::distance(va.begin(), ita)) << " " << *itb << " " << (vc.size() - std::distance(vc.begin(), itc)) << std::endl;
    ans += A * (n - C);
  }

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


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

int main(){
  string A,B,C;
  cin >> A >> B >> C;
  cout << (char)('A' + (A[0] - 'a')) << (char)('A' + (B[0] - 'a')) << (char)('A' + (C[0] - 'a')) << endl;
  return 0;
}

Measured memory_bytes: 256
from collections import Counter


N, P = map(int, input().split())
S = input()

cnt = 0
if P in [2, 5]:
    for i, s in enumerate(S):
        if int(s) % P == 0:
            cnt += (i + 1)
else:
    T = [0] * (N + 1)
    mods = Counter({0: 1})
    for i, s in enumerate(reversed(S)):
        T[N - 1 - i] = (T[N - i] + int(s) * pow(10, i, P)) % P
        mods[T[N - 1 - i]] += 1
    for t in T:
        mods[t] -= 1
        cnt += mods[t]

print(cnt)


Measured memory_bytes: 44620
#include <bits/stdc++.h>
using namespace std;
#define N 100010
#define mod 1000000007
long long css[N],ned[N],f[21][N],fac[N],inv[N],a[N];
inline int read() {
	int x=0;
	char ch=getchar();
	while (!isdigit(ch)) ch=getchar();
	while (isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	return x;
}
inline long long C(long long n,long long m) {
	if (n<m) return 0;
	if (n==m) return 1;
	return fac[n]*inv[m]%mod*inv[n-m]%mod;
}
inline int cmp(int x,int y) {
	return x>y;
}
int main() {
	// freopen("shiratsuyu.in","r",stdin);
	// freopen("shiratsuyu.out","w",stdout);
	int n=read(),m=read(),len=1<<n;
	fac[0]=inv[0]=inv[1]=1;
	for (int i=2;i<=len;i++) inv[i]=inv[mod%i]*(mod-mod/i)%mod;
	for (int i=1;i<=len;i++) fac[i]=fac[i-1]*(long long)i%mod,inv[i]=inv[i]*inv[i-1]%mod;
	for (int i=1;i<=m;i++) a[i]=read();
	sort(a+1,a+m+1,cmp);
	for (int i=1;i<len;i++) ned[i]=(ned[i>>1]<<1)+(i&1),css[i]=(css[i>>1]+(i&1))&1;
	f[0][0]=1;
	for (int i=1;i<=m;i++) {
		for (int j=0;j<len;j++) {
			f[i][j]=f[i-1][j];
			for (int k=0;k<n;k++) {
				if ((1<<k)&j) (f[i][j]+=f[i-1][j^(1<<k)]*C((1<<n)-ned[j^(1<<k)]-a[i],(1<<k)-1)%mod*fac[1<<k])%=mod;
			//if (i==1 && j==1) cout<<f[1][1]<<endl;
			}
		}
	}
	//cout<<f[1][0]<<endl;
	long long ans=0;
	for (int i=0;i<len;i++) (ans+=(css[i]?-1:1)*f[m][i]*fac[(1<<n)-ned[i]-1]%mod+mod)%=mod;
	cout<<ans*(1<<n)%mod<<endl;
	return 0;
}

Measured memory_bytes: 16640
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <vector>
#include <string>
using namespace std;

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  int ans=0;
  int maxnum=0;
  maxnum=std::max(a,max(b,c));
  ans=maxnum*10+a+b+c-maxnum;
  cout << ans << endl;

  return 0;
}

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

int main() {
	int N;
	cin >> N;
	int min = 1000000000;
	int max = 1;
	for (int i = 0; i < N; i++) {
		int A;
		cin >> A;
		if (min > A) min = A;
		if (max < A) max = A;
	}
	cout << max - min;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;

typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) 
{
    os << "{ ";
    for(auto& y : x) 
    {
        os << y << " ";
    }
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) 
{
    return os << "[" << p.ff << ", " << p.ss << "]";
}

ll gcd(ll a, ll b)
{
    if(b==0)
    {
        return a;
    }

    return gcd(b, a%b);
}

ll modexp(ll a, ll b, ll c)
{   
    a%=c;

    ll ans = 1;

    while(b)
    {
        if(b&1)
        {
            ans = (ans*a)%c;
        }

        a = (a*a)%c;
        b >>= 1;
    }

    return ans;
}

ll nxt()
{
    ll x;
    cin >> x;
    return x;
}

const ll L = 2e5+5;

ll seg[4*L];
ll h[L], a[L];
ll dp[L];

ll merge(ll a, ll b)
{
    return max(a, b);
}

void update(ll pos, ll tl, ll tr, ll idx, ll val)
{
    if(tl == tr)
    {
        seg[pos] = val;        
        return;
    }

    ll mid = tl + (tr - tl)/2;

    if(tl <= idx && idx <= mid)
    {
        update(2*pos, tl, mid, idx, val);
    }

    else
    {
        update(2*pos+1, mid+1, tr, idx, val);
    }

    seg[pos] = merge(seg[2*pos], seg[2*pos+1]);
}

ll query(ll pos, ll tl, ll tr, ll l, ll r)
{
    if(tl > r || tr < l)
    {
        return 0;
    }

    if(tl >= l && tr <= r)
    {
        return seg[pos];
    }

    ll mid = tl + (tr-tl)/2;

    return merge(query(2*pos, tl, mid, l, r), query(2*pos+1, mid+1, tr, l, r));
}

void solve()
{
    ll n = nxt();    

    for(ll i=0; i<n; i++)
    {
        cin >> h[i];
    }

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

    for(ll i=0; i<n; i++)
    {
        ll best = query(1, 1, n+1, 1, h[i]);
        dp[h[i]] = best + a[i];

        update(1, 1, n+1, h[i]+1, dp[h[i]]);

        // cout << dp[h[i]] << endl;
    }

    cout << query(1, 1, n+1, 1, n+1) << endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    ll T = 1;
    // T = nxt();

    while(T--)
    {
        solve();
    }

    return 0;
}

Measured memory_bytes: 10496
x = list(map(int,input().split(" ")))
n,m = x
h = list(map(int,input().split(" ")))
lowerlist = [1] * n

for i in range(m):
    ab = list(map(int,input().split(" ")))
    a,b = ab
    # print(ab)
    if h[a-1] >= h[b-1]:
        lowerlist[b-1] = 0
    if h[b-1] >= h[a-1]:
        lowerlist[a-1] = 0

print(sum(lowerlist))

Measured memory_bytes: 20124
#include <stdio.h>
#include <string.h>
int main(){
  long long n;
  char m[12];
  int a;
  scanf("%lld",&n);

  sprintf(m,"%lld",n);

  for(int i=0;i<strlen(m);i++){
    a+=(int)m[i]-48;
  }

  if(n%a==0){
    printf("Yes");
  }else{
    printf("No");
  }
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
typedef long long ll;
int c[2005][2005],s[2005][2005];
int add(int x1, int y1, int x2, int y2){
    if((x1 > x2) || (y1 > y2)) return 0;
    else return s[x2][y2] - s[x1-1][y2] - s[x2][y1-1] + s[x1-1][y1-1];
}
int main(){
    int n,k; cin >> n >> k;
    fill(c[0], c[2004], 0);
    rep(i,n){
        int x,y; char cc; cin >> x >> y >> cc;
        if(cc == 'W') y += k;
        x %= (2*k); y %= (2*k);
        c[x+1][y+1]++;
    }
    FOR(i, 1, 2*k+2){
        FOR(j, 1, 2*k+2){
            s[i][j] = c[i][j] + s[i-1][j] + s[i][j-1] - s[i-1][j-1];
        }
    }

    int ans = -1e9;
    FOR(i,1,k+1){
        FOR(j,1,k+1){
            int tmp = add(i, j, i+k-1, j+k-1) + add(i+k, j+k, 2*k, 2*k) + add(1, 1, i-1, j-1) + add(i+k, 1, 2*k, j-1) + add(1, j+k, i-1, 2*k);
            ans = max(ans,max(tmp, n - tmp));
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 31616
def main():
    n,a = map(int,input().split())
    x = [int(x) for x in input().split()]
    dp= [[[0 for _ in range(2501)] for _ in range(n+1)] for _ in range(n)]

    dp[0][0][0] = 1
    dp[0][1][x[0]] = 1

    for i in range(1,n):
        for j in range(n+1):
            for k in range(2501):
                if k<x[i]:
                    dp[i][j][k] = dp[i-1][j][k]
                else:
                    dp[i][j][k] = dp[i-1][j][k] + dp[i-1][j-1][k-x[i]]
    ans = 0
    for i in range(1,n+1):
        ans += dp[-1][i][a*i]
    print(ans)
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 94044
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
//#define int long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (10);   小数点以下１０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//string s = to_string(int数);
//int n = stoi(string文字列);

int main() {
  int k,x;
  cin >>k>>x;
 
  for(int i=x-k+1; i<x+k-1;i++) {
  cout << i << " ";
  }
  
  cout << x+k-1 << endl;
  
}

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

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

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

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

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

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

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

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

use std::collections::BinaryHeap;

fn main() {
    input! {
        n: usize, m: usize,
        ranges: [(i32, i32); m]
    }

    let inf = 10i32.pow(5) + 1;
    let mut heap = BinaryHeap::new();
    for (a, b) in ranges {
        heap.push((-a, b));
    }
    heap.push((-inf, inf));
    let mut ans = 0;
    let (a, b) = heap.pop().unwrap();
    let mut left = a;
    let mut right = b;
    while !heap.is_empty() {
        let (a, b) = heap.pop().unwrap();
        let a = -a;
        if a == left {
            if b < right { right = b; }
        } else {
            left = a;
            if a >= right {
                ans += 1;
                right = b;
            } else {
                if b < right { right = b; }
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 8572
N=input()

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors


L=make_divisors(N)
L.sort()

ans=0

for x in L:
	if x==1: continue
	if N%(x-1)==N/(x-1):
		ans+=(x-1)

print ans


Measured memory_bytes: 31340
/*
*	User: Isanchez_Aguilar
*	Problem: AtCoder 
*/
#include <bits/stdc++.h>

using namespace std;
using Double = double;

int n;
vector<int> freq(4);
Double memo[301][301][301];
bool visited[301][301][301];

Double dp(int i, int j, int k)
{
	if (i + j + k == 0)
		return 0;

	Double& curr = memo[i][j][k];

	if (not visited[i][j][k])
	{
		visited[i][j][k] = true;
		curr = Double(n) / Double(i + j + k);

		if (i > 0)
			curr += Double(i) * dp(i - 1, j, k) / Double(i + j + k);

		if (j > 0)
			curr += Double(j) * dp(i + 1, j - 1, k) / Double(i + j + k);

		if (k > 0)
			curr += Double(k) * dp(i, j + 1, k - 1) / Double(i + j + k);
	}

	return curr;
}

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

	cin >> n;

	for (int i = 0; i < n; ++i)
	{
		int v;
		cin >> v;
		++freq[v];
	}

	memset(memo, 0, sizeof memo);
	memset(visited, false, sizeof visited);

	cout << fixed << setprecision(9) << dp(freq[1], freq[2], freq[3]);

	return 0;
}

Measured memory_bytes: 240000
#include <stdio.h>
int main(void){
    int w,h,i,j;
    while(1){
        scanf("%d %d\n",&h, &w);
        if(w==0 && h==0)break;
        for(j=1;j<=h;j++){
            if(j == 1 || j == h) {
                for(i=1;i<=w;i++){
                    printf("#");
                }
                printf("\n");
            }else {
                for(i=1;i<=w;i++){
                    if(i==1 || i==w) printf("#");
                    else printf(".");
                }
                printf("\n");
            }
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2052
#include <bits/stdc++.h>
#define MAX_INT 2100000000
#define ex5 (100000+10)
using namespace std;
typedef long long int ll;
#ifdef COMPILE_IN_VCPP
#include <windows.h>
HWND GetConsoleHwnd(void)
{
#define MY_BUFSIZE 1024 // Buffer size for console window titles.
	HWND hwndFound;         // This is what is returned to the caller.
	char pszNewWindowTitle[MY_BUFSIZE]; // Contains fabricated// WindowTitle.
	char pszOldWindowTitle[MY_BUFSIZE]; // Contains original// WindowTitle.
	ULARGE_INTEGER nt;
	nt.QuadPart = GetTickCount64();
	GetConsoleTitle(pszOldWindowTitle, MY_BUFSIZE);
	wsprintf(pszNewWindowTitle, "%d%d/%d", nt.HighPart, nt.LowPart, GetCurrentProcessId());
	SetConsoleTitle(pszNewWindowTitle);
	Sleep(40);
	hwndFound = FindWindow(NULL, pszNewWindowTitle);
	SetConsoleTitle(pszOldWindowTitle);
	return(hwndFound);
}
#endif
int main()
{
#ifdef COMPILE_IN_VCPP
	SetWindowPos(GetConsoleHwnd(), HWND_TOPMOST, 0, 0, 0, 0,
		(SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW));
#endif
	int r;
	cin >> r;
	cout << 3 * r * r << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int N, S;
  S = 0;
  cin >> N;
  for (int n = N; n != 0; n /= 10) {
    S += n % 10;
  }
  
  if (N % S == 0){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" <<endl;
  }
}
  
  
  


Measured memory_bytes: 256
#ifdef __APPLE__
#include "bits:stdc++.h"
#else
#include <bits/stdc++.h>
#endif
#define REPP(i,j,n) for(LL i=j;i<n;++i)
#define REP(i,n) REPP(i,0,n)
#define F first
#define S second

using namespace std;
typedef long long LL;
typedef pair<LL,LL> PLL;

auto scan = []{static LL a;scanf("%lld",&a);return a;};
#define MAXN 1000000
#define PI ( acos((long double) (-1)))
vector<LL> lis;
PLL A[MAXN];
LL r = 0;
bool mid(LL a,LL b,LL x){
  if(a>b)swap(a,b);
  return a<=x && x<=b;
}
double coun(LL s, LL p,LL q){
  return (PI*10-20)*q + 100 * s - (20 - PI * 5) * p;
}
int main(){
  LL x1 = scan(), y1 = scan(), x2 = scan(), y2 = scan(), N =scan();
  if(x1>x2){
    swap(x1,x2);
    swap(y1,y2);
  }
  REP(i,N){
    A[r++]={scan(),scan()};
    if(!mid(x1,x2,A[r-1].F) || !mid(y1,y2,A[r-1].S))--r;
  }
  sort(A,A+r);
  if(y1<y2){
    REP(i,r){
      if(lis.empty() || lis.back()<A[i].S)lis.push_back(A[i].S);
      else *lower_bound(lis.begin(),lis.end(),A[i].S)=A[i].S;
    }
  }else{
    REP(i,r){
      if(lis.empty() || lis.back()< - A[i].S)lis.push_back(-A[i].S);
      else *lower_bound(lis.begin(),lis.end(), -A[i].S)= -A[i].S;
    }
  }
  LL s =abs(x2 - x1 )+ abs(y2 - y1), p = lis.size(), q = 0;
  if(lis.size() == min(abs(x2 - x1),abs(y2 - y1)) + 1)--p,++q;
  printf("%.20f\n",coun(s,p,q));
}

Measured memory_bytes: 6516