akhauriyash/Code-Regression huggingface dataset:
// warm heart, wagging tail,and a smile just for you!
//
//                            ▒█████▒▒
//                             ██████████▒
//                             ▒████████████▒
//                            ██████████████████
//                           ████████████████████▒
//                          ▒██████████████████████▒
//                          ▒███████████████████████
//                      ▒████▒▒▒▒▒▒█████████████████▒
//                    ███▒▒▒▒▒▒██████████████████████▒▒▒
//                  ▒██▒▒███████████████████████▒▒▒▒▒██████
//                 ▒█████████████████████████▒▒▒▒▒▒█████████▒
//                 ▒█████████████████████▒▒▒▒▒▒██████████████
//                  ▒████         ████▒▒▒▒▒████         ████▒
//              ▒█████▒    ████    ▒▒▒▒███████    ████    ██████▒
//            ▒██▒▒▒▒▒    ██████    █████████    ██████    ██▒▒▒██▒
//           █████████   ████████   █████████   ████████   ▒▒▒▒█████
//          ▒█████████    ██████    ████████▒    ██████    █████████
//          ▒██████████    ████    █████▒▒▒▒▒▒    ████    ██████████
//           ████████████        ▒▒▒▒▒▒▒████████        ███████████▒
//       ▒██████████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒███████████████████████████████████▒
//     ███▒▒▒▒▒▒▒▒▒▒▒▒█████████████████████████████████████████▒▒████████▒
//   ▒▒▒▒▒▒▒▒▒██████████████                         ███████▒▒▒▒███████████
//   █████████████████████████                     ███████▒▒▒██████████████▒
//   █████████████████████████████             ███████▒▒▒██████████████████▒
//   ██████████████████████████████████████████████████████████████████████
//    ██████████████████████████████████████████████████████████████████▒
//      ▒█████████████████▒▒▒▒▒▒▒██████████████████████████████████▒▒▒
//
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  int n,x;
  cin >> n >> x;

  vector<int> a(n);
  REP(i,n) cin >> a[i];
  
  int ans = abs(a[0]-x);
  REP(i,n){
    ans = __gcd(ans,abs(a[i]-x));
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1024
import sys
from bisect import bisect_left
def input():
	return sys.stdin.readline()[:-1]
sys.setrecursionlimit(10**6)

n = int(input())
d = [[int(input()), i+1] for i in range(n)]
check = d[0][0]
d.sort()
ind = [x[1] for x in d]
d = [x[0] for x in d]
if n <= 3:
	print(-1)
	sys.exit()
#print(d)
child = [1 for _ in range(n)]
#print(gap)
ans = []
adj = [[] for _ in range(n)]
for i in range(n-1, 0, -1):
	x = d[i]
	b = bisect_left(d, x - n + 2*child[i])
	#print(i, x, n - 2+child[i], b)
	if d[b] != x - n + 2*child[i] or n <= 2*child[i]:
		print(-1)
		sys.exit()
	else:
		child[b] += child[i]
		ans.append([ind[b], ind[i]])
		adj[ind[b]-1].append(ind[i]-1)
		adj[ind[i]-1].append(ind[b]-1)


res = 0
def dfs(x, p, dis):
	global res
	res += dis
	for v in adj[x]:
		if v == p:
			continue
		else:
			dfs(v, x, dis+1)
	return

dfs(0, -1, 0)
if res == check:
	for a in ans:
		print(*a)
else:
	print(-1)

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

#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define MAX (int)1e9 + 99
#define maxof(a,b,c) max(a,max(b,c))
#define minof(a,b,c) min(a,min(b,c))
#define vi vector<int>
#define vb vector<bool>
#define ll long long
#define ull unsigned long long
#define vll vector<ll>
#define pa pair<int, int>
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define MOD 1000000007
#define bitcnt(x) __builtin_popcount(x)
#define gcd(a,b) __gcd(a,b)
#define all(x) (x).begin(),(x).end()
#define ts(x) to_string(x)
#define set0(x) memset(x, 0, sizeof(x))
const double pi = 3.14159265358979323846;
ll binpow(ll, ll);
ll mult(ll, ll);
ll add(ll , ll);
ll division(ll, ll);
ll nCr(ll, ll);
ll inv(ll);
void calc();
template<class T> istream &operator>>(istream &is, vector<T> &v) { for (T &x : v) is >> x; return is;}
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) {if (!v.empty()) {os << v.front();for (int i = 1; i < v.size(); ++i) os << ' ' << v[i];} return os;}
const int N=50010;
//ll fact[N];

void solve()
{
    int n;
    cin>>n;
    vector<vi> arr(n, vi(n));


    rep(i,n)
    {
        rep(j,n)
        cin>>arr[i][j];
    }

    vi dp(1<<n);
    dp[0] = 1;

    for(int mask = 0; mask < (1<<n)-1; mask++)
    {
        int a = bitcnt(mask);
        rep(b,n)
        {
            if(arr[a][b] & !(mask & (1<<b)))
            {
                int x = mask ^ (1<<b);
                dp[x] = add(dp[x], dp[mask]);
            }
        }


    }


    cout<<dp[(1<<n)-1];
}

int main()
{
    fastio;
    
    int t=1;
    //cin>>t;
    
    rep(i,t)
    {
        solve();
        cout<<"\n";
    }
    return 0;
}

ll add(ll a, ll b){
    a+=b;
    while(a>=MOD) a-=MOD;
    while(a<0) a+=MOD;
    return a;
}

ll mult(ll a, ll b){
    return (a * 1ll * b) % MOD;
}


ll binpow(ll a, ll b){
    ll c = 1;
    while(b > 0)
    {
        if(b % 2 == 1)
            c = mult(c, a);
        a = mult(a, a);
        b /= 2;
    }
    return c;   
}

ll inv(ll a){
    return binpow(a, MOD-2);
}

ll division(ll a, ll b){
    return mult(a, inv(b));
}

/*ll nCr(ll n, ll r){
    if(r > n) return 0;
    return division(fact[n], mult(fact[n-r], fact[r]));
}

void calc(){
    fact[0] = 1;
    srep(i,1,N-1)
        fact[i] = (i*1ll*fac[i-1])%MOD;

}*/

Measured memory_bytes: 11356
using System;
class Program
{
	static void Main()
	{
		string[] s = Console.ReadLine().Split(' ');
		long a = long.Parse(s[1]);
		long b = long.Parse(s[2]);
		Console.WriteLine(((a+b) % 2 == 0) ? "Alice" : "Borys");
	}
}


Measured memory_bytes: 13140
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <iomanip>
#include <limits>

#define roop(i, n) for(int i=0;i<n;i++)
#define DIV 1000000007
//static const long double pi = 3.1415926535897932;

using namespace std;
using ll = long long int;
using ull = unsigned long long;

float myPower(int a, int n) { // aのn乗の計算
	float x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

ll combination(ll n, ll r) {
	if (n < 0 || r < 0 || r > n) return -1;

	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> num(r);
	vector<ll> den(r);

	for (ll i = 0; i < r; i++) {
		num[i] = n - r + i + 1;
		den[i] = i + 1;
	}

	for (ll p = 2; p <= r; p++) {
		ll pivot = den[p - 1];
		if (pivot > 1) {
			ll offset = (n - r) % p;
			for (ll k = p - 1; k < r; k += p) {
				num[k - offset] /= pivot;
				den[k] /= pivot;
			}
		}
	}
	ll result = 1;
	for (ll k = 0; k < r; k++) {
		if (num[k] > 1) result *= num[k];
	}
	return result;
}

vector<string> split(const string& src, const char* delim = ",") {
	vector<string> vec;
	string::size_type len = src.length();

	for (string::size_type i = 0, n; i < len; i = n + 1) {
		n = src.find_first_of(delim, i);
		if (n == string::npos) {
			n = len;
		}
		vec.push_back(src.substr(i, n - i));
	}

	return vec;
}

struct root {
	int i;
	int value;
};

int main() {
	long double a, b, h, m;
	cin >> a >> b >> h >> m;

	long double rad = M_PI * 2 * (h / 12.0 + (m / 60.0)/12.0 - (m/60.0));
	long double colc = (a * a) + (b * b) - 2 * a * b * cosl(rad);
	cout << fixed << setprecision(20) << sqrtl(colc) << endl; 
	return 0;
}

Measured memory_bytes: 4144
//#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
//using namespace atcoder;
#define int long long
   template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
    const int MAX =3001;
const int MOD =998244353;


  
signed main(){
  int n,Q,c,z;
  cin>>n>>Q;
  int x[n],y[n],ans=(n-2)*(n-2);
  fill(x,x+n,n);
  fill(y,y+n,n);
  int p=n-1,q=n-1;
  for(int i=0;i<Q;i++){
    //cerr<<ans<<endl;
    cin>>c>>z;
    if(c==1){
      if(z>p)ans-=x[z];
      else{
        ans-=q-1;
        for(int j=p;j>=z;j--)x[j]=q-1;
        p=z-1;
      }
    }else{
      if(z>q)ans-=y[z];
      else{
        ans-=p-1;
        for(int j=q;j>=z;j--)y[j]=p-1;
        q=z-1;
      }
    }
  }
  cout<<ans<<endl;

}

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

using namespace std;

int main() {
  int W, H, N;
  cin >> W >> H >> N;
  int x1, y1, x2, y2;
  x1 = 0;
  y1 = 0;
  x2 = W;
  y2 = H;
  for (int i = 0; i < N; i++) {
    int x, y, a;
    cin >> x >> y >> a;
    if (a == 1) {
      x1 = max(x1, x);
    } else if (a == 2) {
      x2 = min(x2, x);
    } else if (a == 3) {
      y1 = max(y1, y);
    } else if (a == 4) {
      y2 = min(y2, y);
    }
  }
  if (y2 < y1 || x2 < x1) {
    cout << 0 << endl;
  } else {
    cout << (y2 - y1) * (x2 - x1) << endl;
  }
  return 0;
}


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

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

#define INF 1e9



int main(){
  int A, B, C;
  ll K;
  cin >> A >> B >> C >> K;
  if(K % 2 == 0){
    cout << A - B << endl;
  }
  else{
    cout << B - A << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3

N = int(input())
# print(N)

result = 0
for num in range(1, N+1):
    if num % 2 == 1:
        count = 0
        for i in range(1, num+1):
            if num % i == 0:
                count += 1
        if count == 8:
            result += 1

print(result)


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

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define PI acos(-1.0)
#define sq(n) (n)*(n)

using namespace std;
typedef long long ll;

int main() {
    FAST;

    string s;
    string t;
    cin>>s;
    cin>>t;

    ll s1=s.size();
    ll t1=t.size();
    ll c=0;
    for(ll i=0;i<s1;i++)
    {
        if(s[i]!=t[i])c++;
    }
    cout<<c<<endl;


    return 0;
}



Measured memory_bytes: 3764
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <complex>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <iomanip>
using namespace std;

#define Rep(b, e, i) for(ll i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T,vector<T>,greater<T>>
#define Pqza(T) priority_queue<T>
#define put(x) cout << x;
#define putsp(x) cout << x << ' ';
#define putbd cout << "---------------------------------------------" << endl;
#define putln(x) cout << x << endl;
#define debug(x) cerr << #x << "=" << x << endl;
#define ENJYU std::ios::sync_with_stdio(false);std::cin.tie(0);

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef complex<double> comp;
typedef vector <int> vec;
typedef vector <ll> vecll;
typedef vector <double> vecd;
typedef vector <vec> mat;
typedef vector <vecll> matll;
typedef vector <vecd> matd;

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

const int MAX = 200020;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const ll INFL = 1e18;
const int MOD = 1e9+7;

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

//********************************template END****************************************//

void solve(void){

	int A, B;
	cin >> A >> B;

	cout << (A-1)*(B-1) << endl;

}

int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <functional>
#include <complex>
#include <stack>
#include <tuple>
#include <array>
using namespace std;
#define rep(i,n) for (int i=0; i < (n); i++)


typedef long long int ll;
typedef double D;      // ??§?¨?????????????double???long double?????????
typedef complex<D> P;  // Point
typedef pair<P, P> L;  // Line
typedef vector<P> VP;


const int INF = (1<<30) - 1;
const D EPS = 1e-9;

#define X real()
#define Y imag()
#define LE(n,m) ((n) < (m) + EPS)
#define GE(n,m) ((n) + EPS > (m))
#define EQ(n,m) (abs((n)-(m)) < EPS)


//g++ -std=c++0x -msse4.2 -O3
//#include <bits/stdc++.h>
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    //cout.precision(16);
    
    int N, M;
    while(cin>>N>>M, N|M){
        set<int> infected = {1};
        
        vector<tuple<int, int, int>> packets;
        for(int i=0; i<M; i++){
            int t, s, d; cin >> t >> s >> d;
            packets.push_back(tuple<int, int, int>(t, s, d));
        }
        sort(packets.begin(), packets.end());
        for(int i=0; i<M; i++){
            int t, s, d; tie(t, s, d) = packets[i];
            if(infected.count(s))
                infected.insert(d);
        }
        
        cout << infected.size() << endl;
    }
    
    return 0;
}

Measured memory_bytes: 2376
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <sstream>
#include <set>
#include <tuple>
#include <algorithm>
#include <memory>
#include <numeric>
#include <queue>
#include <functional>
#include <cmath>
#include <cstring>
#include <map>
#include <unordered_map>
#include <sstream>
#include <iomanip>

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

const ll INF = 1LL << 60;
const ll MOD = 1000000007;

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

	ll N;
	cin >> N;

	ll ans = 0;

	ans += 1000 * ll(N / 500);
	N -= (N / 500) * 500;

	ans += 5 * ll(N / 5);

	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF=2147483647;
inline ll read(){
	ll x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-') f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	return x*f;
}
int n;
string s;
int main(){
	n=read();
	cin>>s;
	int len=s.length();
	if(n>=len) cout<<s<<endl;
	else{
		for(int i=0;i<n;i++) printf("%c",s[i]);
		printf("...\n");
	}
	return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w
using namespace std;

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;
 
template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+9;
const double EPS=1e-9;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int n,cnt[100001] = {},ans = 0;
	cin >> n;
	for(int i = 0;i < n;i++){
		int a;
		cin >> a;
		if(a > n) ans++;
		else cnt[a]++;
	}
	for(int i = 0;i <= n;i++){
		if(cnt[i] >= i) ans += cnt[i] - i;
		else ans += cnt[i];
	}
	cout << ans << endl;
	return 0;
}

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

#define endl '\n'
#define rep(i,s,n)      for (int i = s ; i < n ; i++)
#define repp(i,s,n)    for (int i = s ; i <= n ;i++)
#define all(a)      a.begin(),a.end()
#define sz(v)    (int)v.size()
#define NumofDigits(n)    ((long long)log10(n)+1)
#define Unique(n)         (n).erase(unique(all(n)), (n).end())
#define test    int s ; cin >> s; while (s--)
#define readArr    int n ; cin >> n ; int arr[n]; rep(i,0,n)cin>>arr[i]
#define isvowel(a)   (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define fast     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

typedef long long ll ;

void readFromText ()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
#endif // ONLINE_JUDGE
}

const double Pi = acos(-1.0);

bool countIF (int a){
    return a%4==0;
}

bool myFun (int i , int j ) {

}

const int MAX = 2e5 ;
int sum [MAX+1];
int freq [MAX+1];

int main()
{
    fast;
//    readFromText();
    char c ; cin >> c ;
    if (isupper(c))cout <<"A";
    else cout << "a";
    return 0;
}



Measured memory_bytes: 3656
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <utility>

using namespace std;

using ll = long long;
using P = pair<int, int>;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mkp(a, b) make_pair(a, b)
const int inf = 1e+9;



int main() {
	int n, m, k;
	cin >> n >> m >> k;
	rep (i, n + 1) {
		rep(j, m + 1) {
		  if (k == j * i + (n - i) * (m - j)) {
		  	cout << "Yes" << endl;
		  	return 0;
		  }
		}
	} 
	cout << "No" << endl;


	return 0;
}


Measured memory_bytes: 508
N=int(input())

A= list(map(int,input().split()))
B=list(map(int,input().split()))
C=[]
D=[]
count=0
j=A[0]
for i in range(N):

    if A[i]>=B[i]:
        A[i]=A[i]-B[i]
        count+=B[i]

    else:
        if A[i+1]+A[i]>=B[i]:
            A[i+1]=A[i+1]-(B[i]-A[i])
            A[i]=0
            count+=B[i]
        else:

            count+=A[i]+A[i+1]
            A[i + 1] = 0
            A[i] = 0

print(count)

Measured memory_bytes: 19004
#include<stdio.h>
int main(){
	int n,x,a,b;
	scanf("%d",&n);
	
	for(x=3;x<=n;x++){
		a=x/10;
		b=a/10;
		if(x%3==0||x%10==3||x/10==3||a%10==3||b%10==3||x/100==3||x/1000==3||x/10000==3){
			printf(" %d",x);
		}
		
	}
	
	printf("\n");
	
	return 0;
}

Measured memory_bytes: 600
import java.util.*;
import java.io.*;

public class Main {
    public static long MOD = 1000000007;
    public static void main(String[] args) throws IOException{
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        StringTokenizer st = new StringTokenizer(f.readLine());
        int n = Integer.parseInt(st.nextToken());
        int k = Integer.parseInt(st.nextToken());
        long ans = 0;
        long lsum = 0;
        long rsum = 0;
        for(int i = 0; i < k; i++){
            lsum+=i;
            rsum+=(n-i);
            lsum%=MOD;
            rsum%=MOD;
        }
        for(int i = k; i <= n+1; i++){
            ans+=((((rsum-lsum+1)%MOD)+MOD)%MOD);
            ans%=MOD;
            lsum+=i;
            lsum%=MOD;
            rsum+=(n-i);
            rsum%=MOD;
        }
        out.println(ans);


        out.close();
    }

}


Measured memory_bytes: 32744
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

n, m = MAP()

print((n-1) * (m-1))


Measured memory_bytes: 5156
import java.util.Scanner;

public class Main {
	//N枚のせんべいをK人に均等に配ったときに一番多くもらえる人と少ない人との枚数の差

	public static void main(String[] args) {

		int N; //せんべいの枚数
		int K; //人数
		int diff; //差分

		Scanner scan = new Scanner(System.in);

		N = scan.nextInt();
		K = scan.nextInt();

		if ( N % K == 0 ) {
			diff = 0;
		}else {
			diff = 1;
		}

		System.out.println(diff);

		scan.close();

	}

}


Measured memory_bytes: 22864
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input! {
        n: usize,
        v: [i32; n],
    }
    
    let mut v = v.iter().filter(|x| *x % 2 == 0 ).filter(|x| *x % 3 != 0 && *x % 5 !=0);
    match v.next() {
        Some(_) => println!("DENIED"),
        None => println!("APPROVED")
    }
}


Measured memory_bytes: 4352
N = int(input())
A = [int(a) for a in input().split()]
B = [int(a) for a in input().split()]

def calc(n, X, Y):
    Z = [(X[i], Y[i]) for i in range(3) if Y[i] > X[i]]
    k = len(Z)
    if k == 0:
        return n
    if k == 1:
        a = n//Z[0][0]
        return n + a*(Z[0][1]-Z[0][0])
    if k == 2:
        ma = 0
        for a in range(n+1):
            b = (n-a*Z[0][0])//Z[1][0]
            if b >= 0:
                ma = max(ma, n + a*(Z[0][1]-Z[0][0]) + b*(Z[1][1]-Z[1][0]))
        return ma
    ma = 0
    for a in range(n+1):
        for b in range(n+1-a):
            c = (n-a*Z[0][0]-b*Z[1][0])//Z[2][0]
            if c >= 0:
                ma = max(ma, n + a*(Z[0][1]-Z[0][0]) + b*(Z[1][1]-Z[1][0]) + c*(Z[2][1]-Z[2][0]))
    return ma

print(calc(calc(N, A, B), B, A))


Measured memory_bytes: 42300
#include <stdio.h>
 
int main() {
  int H,W,h,w;
  scanf("%d %d\n",&H,&W);
  scanf("%d %d\n",&h,&w);
  int ans = (H*W) - (h*W + (w*H - h*w));
  printf("%d\n",ans);
  return 0;
}

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

int main () {
  int a , b ;
  cin >> a >> b ;
  
  if ( a == 2 || b == 2 ) {
    cout << "No" << endl ;
  } else if ( a == 4 && b == 6 || a == 4 && b == 9 || a== 4 && b == 11 || a == 6 && b == 9 || a == 6 && b == 11 || a == 9 && b == 11 || a == 1 && b == 3 || a == 1 && b == 5 || a == 1 && b == 7 || a == 1 && b == 8 || a == 1 && b == 10 || a == 1 && b == 12 || a == 3 && b == 5 || a == 3 && b == 7 || a == 3 && b == 8  || a == 3 && b == 10 || a == 3 && b == 12 || a == 5 && b == 7 || a == 5 && b == 8 || a == 5 && b == 10 || a == 5 && b == 12 || a == 7 && b == 8 || a == 7 && b == 10 || a == 7 && b == 12 || a == 8 && b == 10 || a == 8 && b == 12 || a == 10 && b == 12 ) {
    cout << "Yes" << endl ;
  } else {
    cout << "No" << endl ;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
int main(){
    const long long inf=1000000000000000000;
    int n,m;
    cin>>n>>m;
    int a[m],b[m],c[m];
    for(int i=0;i<m;i++){
        cin>>a[i]>>b[i]>>c[i];
        a[i]--,b[i]--;
    }
    vector<long long>dist(n,inf);
    dist[0]=0;
    for(int i=0;i<n*2;i++){
        int update=0;
        for(int j=0;j<m;j++){
            if(b[j]==n-1 && dist[b[j]]>dist[a[j]]-c[j])update=1;
            dist[b[j]]=min(dist[b[j]],dist[a[j]]-c[j]);
        }
        if(i>=n && update){
            cout<<"inf"<<endl;
            return 0;
        }
    }
    cout<<-dist[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(){
  int q;
  cin >> q;
  rep(repert, q) {
    string X, Y;
    cin >> X >> Y;
    vector<vector<int>> dp(X.size()+1, vector<int>(Y.size()+1));
    rep(i, X.size()) {
      rep(j, Y.size()) {
        if(X[i] == Y[j]) {
          dp[i+1][j+1] = dp[i][j]+1;
        } else {
          dp[i+1][j+1] = max({dp[i+1][j], dp[i][j+1]});
        }
      }
    }
    cout << dp[X.size()][Y.size()] << endl;
  }
  return 0;
}


Measured memory_bytes: 6764
def check(sw, p, list):
    count = 0
    res = 0
    # print(list)
    for i in range(len(sw)):
        count = 0
        for j in range(sw[i][0]):
            # print(str(sw[i][j+1]) + "  " + str(list) + "  " + str(sw[i][j + 1] in list))
            if(sw[i][j + 1] in list):
                count += 1
        if count % 2 == p[i]:
            res += 1
    # print(count)
    return res == len(sw)

n,m = map(int,input().split())
sw = []

for i in range(m):
    sw.append(list(map(int,input().split())))
    # print()
    # print(sw[i])
p = list(map(int,input().split()))
res = 0
# print(p)

for i in range(2**n):
    list = []
    for j in range(n):
        if(i >> j) & 1 == 1:
            list.append(j+1)
    if(check(sw,p,list)):
        res += 1
print(res)

Measured memory_bytes: 3064
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

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

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getInt()
	}
	return ret
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	S, T := getString(), getString()
	cnt := 0
	for i := 0; i < len(S); i++ {
		if S[i] == T[i] {
			cnt++
		}
	}
	out(cnt)
}


Measured memory_bytes: 1772
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
#include<unordered_set>
typedef long long int ll;
#define REP(i,n) for(int i=0;i<signed(n);i++)
using std::cout;
using std::vector;
using std::endl;
using std::cin;
using std::string;
using std::min;
using std::max;
const ll MOD = 1000000007;
const ll INF = 9e9;
ll N,M,ans=INF;
ll A[300010],S[301000];
int main(){
    std::ios_base::sync_with_stdio(false);
    cin>>N;
    REP(i,N){
        cin>>A[i];
        S[i]+=A[i];
        S[i+1]=S[i];
    }
    //a:右半分の区切り i:真ん中 b:左半分
    //s:右の和 t:左の和
    ll a=0,b=2,s,t;
    REP(i,N-2){
        if(i==b)b++;
        s=(S[i]-S[a])-S[a];
        t=(S[N-1]-S[b])-(S[b]-S[i]);
        bool f=true;
        if(i==0)continue;
        while(f){
            f=false;
            if(a+1==i)continue;
            if(std::abs(s)>labs(s-A[a+1]*2)){
                s-=A[a+1]*2;
                a++;f=true;
            }
        }
        f=true;
        while(f){
            f=false;
            if(b+1==N-1||b==N-1)continue;
            if(std::abs(t)>labs(t-A[b+1]*2)){
                t-=A[b+1]*2;
                b++;f=true;
            }
        }
        ans=min( ans,( max({S[a],S[i]-S[a],S[b]-S[i],S[N-1]-S[b]})
        -min({S[a],S[i]-S[a],S[b]-S[i],S[N-1]-S[b]}) ) );
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

#define endl "\n"

const ll INF = 1e15;
const int MOD = 1e9 + 7;
const double EPS = 1e-7;
const double PI = acos(-1.0);

const int N = 55;

ll n, a[N];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);

    cin >> n;

    ll wrong = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        if (a[i] != i + 1)
            ++wrong;
    }

    cout << (wrong <= 2 ? "YES" : "NO") << endl;
}


Measured memory_bytes: 256
import numpy as np
N = int(input())
ansd = {}
for i in range(N):
    a = int(input())
    if a not in ansd.keys():
        ansd[a] = 1
    else:
        ansd[a] += 1
answers = np.array(list(ansd.values()))
print(sum(answers % 2 == 1))


Measured memory_bytes: 24044
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int turn = 90;
		double x = 0, y = 0;
		while (true) {
			String[] line = scanner.next().split(",");
			double d = Double.parseDouble(line[0]);
			int t = Integer.parseInt(line[1]);
			if (d == 0 && t == 0) break;
			double r = (double)turn * Math.PI / 180;
			x += d * Math.cos(r);
			y += d * Math.sin(r);
			turn -= t;
		}
		System.out.println((int)x);
		System.out.println((int)y);
	}
}

Measured memory_bytes: 25996
#include <iostream>
#include <string>

using namespace std;

int main(void) {
    string S, T;
    cin >> S >> T;
    int ans = 0;
    if(S[0] == T[0]) ++ans;
    if(S[1] == T[1]) ++ans;
    if(S[2] == T[2]) ++ans;
    cout << ans << endl;
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> v(n),c(n);
    rp(i,n) cin >> v.at(i);
    rp(i,n) cin >> c.at(i);
    int ans=0;
    rp(i,n){
        if(v.at(i)-c.at(i)>0)
        ans +=v.at(i)-c.at(i);
    }
    cout << ans << endl;
     return 0;
     
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    

    if(S.charAt(2) == S.charAt(3) && S.charAt(4) == S.charAt(5)){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}




Measured memory_bytes: 21460
S = gets.chomp
T = gets.chomp

max = 0
(0..(S.size - T.size)).each do |n|
  str = S[n..(T.size-1 + n)]
  same_count = str.split("").filter.with_index do |s, i|
    s == T[i]
  end.size
  max = same_count if max < same_count
end
puts T.size - max

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

int dp[100004][20];
string s;

int main() {
	cin>>s;
	memset(dp, 0, sizeof(dp));
	dp[0][0] = 1;
	for(int i = 0;i<s.length();i++)
		for(int j = 0;j<13;j++){
			if(s[i] == '?')
				for(int k = 0;k<10;k++)
					dp[i+1][(j*10+k)%13] = (dp[i+1][(j*10+k)%13] + dp[i][j])%1000000007;
			else
				dp[i+1][(j*10 + (s[i]-'0'))%13] = (dp[i+1][(j*10 + (s[i]-'0'))%13] + dp[i][j])%1000000007;
	}
	cout<<dp[s.length()][5];
	return 0;
}

Measured memory_bytes: 8320
n, k = map(int, input().split())
h = tuple(map(int, input().split()))

INF = float('inf')
dp = [INF] * n
dp[0] = 0
# dp[i] = (足場iにたどり着いた時点でのコストの最小値)

for i in range(n):
    for j in range(i + 1, min(i + k + 1, n)):
        dp[j] = min(dp[j], dp[i] + abs(h[j] - h[i]))

print(dp[n - 1])


Measured memory_bytes: 58080
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include <iomanip>
#include <math.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60
const double PI = 3.14159265358979323846;

P range[100009];

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

	int N; cin >> N;
	for (int i = 0; i < N; i++) {
		int x, l; cin >> x >> l;
		range[i].first = x + l;
		range[i].second = x - l;
	}
	sort(range, range + N);

	int ans = 1;
	int right = range[0].first;
	for (int i = 1; i < N; i++) {
		if (right <= range[i].second) {
			ans++;
			right = range[i].first;
		}
	}
	
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
using namespace std;
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	string s;
	cin>>s;
	if(s=="ABC"){
		cout<<"ARC"<<endl;
	}
	else{
		cout<<"ABC"<<endl;
	}
	return 0;
}

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

int main(){

  int a, b;

  cin >> a >> b;

  if(a < b)
    cout <<"a < b" << endl;
  else if (a > b)
    cout <<"a > b" << endl;
  else
    cout <<"a == b" << endl;

  return 0;
}

Measured memory_bytes: 3076
#include <iostream>

using namespace std;

int main() {
    ios::sync_with_stdio(0), cin.tie(0);
    int a, b;
    cin >> a >> b;
    if (a - 1 > b) cout << a + a - 1 << endl;
    else if (b - 1 > a) cout << b + b - 1 << endl;
    else cout << a + b << endl;
    return 0;
}

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

#define ll long long
#define int long long
#define ld long double
#define endl "\n"
#define debugv(v) cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
#define output(x)   cout << (x ? "YES" : "NO")<<endl;
const ll MOD = 1e9 + 7;
const int N = 2e12+5;
const int demo = 10;
using namespace std;
const ll cfmod=998244353;
ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

signed main(){
    int q=1;
    //cin>>q;
    while(q--) {
        int n;
        cin>>n;
        cout<<n+(n*n)+(n*n*n);
    }
}

Measured memory_bytes: 3184
/* In The Name of Anton*/

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

#define rep(i,n) for(int i=0;i<n;i++)
#define repa(i,a,n) for(int i=a;i<=n;i++)
#define repb(i,a,n) for(int i=a;i>=n;i--)
#define trav(a,x) for(auto a=x.begin();a!=x.end();a++)
#define all(x) x.begin(),x.end()
#define fst first
#define snd second
#define pb push_back
#define mp make_pair
typedef long double ld;
typedef pair <int,int> pii;
typedef vector <int> vi;
typedef long long ll;

const int mxN=1e3+5;
int a[mxN][mxN];
string s[mxN];
int temp;
int n,m;
vi adj[1000005];

void pre(){

}

void dfs(int i,int j){
  a[i][j]=temp;

  if(i+1<n){
      if(a[i+1][j]==0 && s[i+1][j]=='.'){
        dfs(i+1,j);
      }
  }

  if(i-1>=0){
    if(a[i-1][j]==0 && s[i-1][j]=='.'){
      dfs(i-1,j);
    }
  }

  if(j-1>=0){
    if(a[i][j-1]==0 && s[i][j-1]=='.'){
      dfs(i,j-1);
    }
  }

  if(j+1<m){
    if(a[i][j+1]==0 && s[i][j+1]=='.'){
      dfs(i,j+1);
    }
  }
}

void solve(){
  temp=0;
  cin>>n>>m;

  for(int i=0;i<mxN;i++){
    for(int j=0;j<mxN;j++){
      a[i][j]=0;
    }
  }

  int sx,sy,dx,dy;
  cin>>sx>>sy>>dx>>dy;
  sx--; sy--;
  dx--;
  dy--;

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

  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      if(a[i][j]==0 && s[i][j]=='.'){
        temp++;
        dfs(i,j);
      }
    }
  }

  map <pii,int> m1;

  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){

      int ctemp1=i-2,ctemp2=i+2;
      int dtemp1=j-2,dtemp2=j+2;

      for(int x=ctemp1;x<=ctemp2;x++){
        for(int y=dtemp1;y<=dtemp2;y++){
          if(x>=0 && x<n && y>=0 && y<m){
            if(a[i][j]!=a[x][y] && a[i][j]!=0 && a[x][y]!=0){
              if(m1[{a[i][j],a[x][y]}]==0){
                m1[{a[i][j],a[x][y]}]=1;
                adj[a[i][j]].pb(a[x][y]);
              }
            }
          }
        }
      }
    }
  }

  int s=a[sx][sy];
  int d=a[dx][dy];

  int dis[1000005];
  bool used[1000005];
  memset(dis,-1,sizeof(dis));
  memset(used,false,sizeof(used));

  dis[s]=0;
  used[s]=true;
  queue<int> q;
  q.push(s);

  while(!q.empty()){
    int v=q.front();
    q.pop();
    for (int u : adj[v]) {
        if (!used[u]) {
            used[u] = true;
            q.push(u);
            dis[u] = dis[v] + 1;
        }
    }
  }

  cout<<dis[d]<<"\n";
}

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0);
  pre();
  int t; t=1;
  rep(i,t) solve();
  return 0;
}


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

using namespace std;

vector<vector<int>> F, B;
vector<int> memo1, memo2;

template <class Abel>
class UnionFind{
    vector<int> par_, weight_;
public:
    UnionFind(size_t n){
        par_.assign(n, -1);
        weight_.assign(n, 0);
    }

    int root(int x){
        if (par_[x] < 0) {
            return x;
        }else{
            int res = root(par_[x]);
            weight_[x] += weight_[par_[x]];
            return par_[x] = res;
        }
    }

    int weight(int x){
        root(x);
        return weight_[x];
    }

    int weight(int x, int y){
        return weight(y) - weight(x);
    }

    int size(int x){
        return -par_[root(x)];
    }

    bool IsSame(int x, int y){
        return root(x) == root(y);
    }

    void Merge(int x, int y, Abel w){
        w += weight(x);
        w -= weight(y);
        x = root(x);
        y = root(y);
        if (x == y)
            return;
        if (size(x) < size(y)) {
            w = -w;
            swap(x, y);
        }
        par_[x] += par_[y];
        par_[y] = x;
        weight_[y] = w;
    }
};

int main(){
    int n, m, k;
    cin >> n >> m >> k;
    F.resize(n);
    B.resize(n);
    memo1.assign(n, -1);
    memo2.assign(n, -1);

    for (int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        F[a].push_back(b);
        F[b].push_back(a);
    }
    for (int i = 0; i < k; i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        B[a].push_back(b);
        B[b].push_back(a);
    }

    UnionFind<int> X(n), Y(n);

    for (int i = 0; i < n; i++){
        for (const auto &f: F[i]){
            X.Merge(i, f, 0);
            Y.Merge(i, f, 0);
        }
    }

    for (int i = 0; i < n; i++){
        for (const auto &b: B[i])
            Y.Merge(i, b, 0);
    }

    for (int i = 0; i < n; i++){
        int c = 0;
        for (const auto &b: B[i]){
            if (X.IsSame(i, b))
                c++;
        }
        cout << X.size(i) - 1 - F[i].size() - c << " ";
    }
    cout << endl;
}

Measured memory_bytes: 14200
a = int(input())
b =  input()

if int(a/2) != a/2:
    print('No')
else:
    c = b[0 : int(a/2)]
    #print(c)
    d = b[int(a/2) : a]
    #print(d)
    if c == d:
        print('Yes')
    else:
        print('No')

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

int a[3001];

int main()
{

  int n, ans = 0;
  std::cin >> n;
  for (int k=0; k<n; k++) {
    std::cin >> a[k];
    ans += a[k]-1;
}
  std::cout << ans << '\n';
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,n) for(int i=1;i<=n;i++)
int main()
{
    string s;

    getline(cin,s);

    int l = s.length();

    rep(i,l){
        if(islower(s[i])){
            s[i] = toupper(s[i]);
        }else if(isupper(s[i])){
            s[i] = tolower(s[i]);
        }

    }

    cout << s << endl;

    return 0;

}


Measured memory_bytes: 3160
def main():
  n = int(input())
  l = list(map(int, input().split()))
  lowest = 2 * (10**5)
  ans = 0
  for i in l:
    if i <= lowest:
      lowest = i
      ans += 1
  print(ans)
  
if __name__ == "__main__":
  main()

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

typedef unsigned long long int ll;
typedef std::pair<ll, ll> pii;
using namespace std;

bool s(pii a, pii b) {
    return a.first <= b.first;
}

int main() {
    int N, M;
    vector<pii> v;
    cin >> N >> M;
    ll ans = 0;
    for(int i=0;i<N;i++) {
        ll a,b;
        cin >> a >> b;
        v.push_back(make_pair(a,b));
    }
    stable_sort(v.begin(), v.end(), s);
    ll c=0;
    for(auto i: v) {
        ans+=(ll)(i.first * i.second);
        c+=i.second;
        if(c>=M) {
            ans -= (ll)(i.first*(c-M));
            cout << ans;
            return 0;
        }
    }
}


Measured memory_bytes: 3440
#include <iostream>
#include <cstdint>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <algorithm>

int main(void)
{
    char a;

    std::cin >> a;

    if (a >= 'a') {
        std::cout << "a" << std::endl;
    } else {
        std::cout << "A" << std::endl;
    }

    return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
using namespace std;

//int X[100000];
//int Y[100000];
//int Z[100000];
vector <int> edges[100000];
bool visited[100000];
int main(){
    int N;
    int M;
    cin >> N >> M;
    for(int i = 0; i < M; i++){
        int X;
        int Y;
        int Z;
        cin >> X >> Y >> Z;
        edges[X - 1].push_back(Y - 1);
        edges[Y - 1].push_back(X - 1);
    }

    int ans = 0;
    for(int i = 0; i < N; i++){
        if(visited[i]){
            continue;
        }
        ans ++;
        queue <int> q;
        q.push(i);
        while(!q.empty()){
            int cur = q.front();
            q.pop();
            for(int j = 0; j < edges[cur].size(); j++){
                int next = edges[cur][j];
                if(!visited[next]){
                    visited[next] = true;
                    q.push(next);
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6648
#include<iostream>
#include<queue>
#include<vector>
#include<map>
using namespace std;
typedef pair<int, int> vtx;
typedef pair<int, int> cv;
const int Nmax = 100001;
const int Mmax = 200001;
const int Cmax = 1000001;
const int INF = 1e8;
int N,M;
int P[Mmax],Q[Mmax],C[Mmax];

int main(){
	cin >> N >> M;
	for(int i=0; i<M; i++){
		cin >> P[i] >> Q[i] >> C[i];
	}

	map<vtx, int> encode;
	int n=0;
	for(int i=1; i<=N; i++){
		encode[make_pair(i,-1)] = n++;
	}
	for(int i=0; i<M; i++){
		if(encode.find(make_pair(P[i],C[i])) == encode.end()){
			encode[make_pair(P[i],C[i])] = n++;
		}
		if(encode.find(make_pair(Q[i],C[i])) == encode.end()){
			encode[make_pair(Q[i],C[i])] = n++;
		}
	}
	vector<vector<pair<int, int> > > to(n);
	for(int i=0; i<M; i++){
		to[encode[make_pair(P[i],-1)]].push_back(make_pair(1,encode[make_pair(Q[i],C[i])]));
		to[encode[make_pair(Q[i],-1)]].push_back(make_pair(1,encode[make_pair(P[i],C[i])]));
		to[encode[make_pair(P[i],C[i])]].push_back(make_pair(0,encode[make_pair(Q[i],C[i])]));
		to[encode[make_pair(Q[i],C[i])]].push_back(make_pair(0,encode[make_pair(P[i],C[i])]));
		to[encode[make_pair(P[i],C[i])]].push_back(make_pair(0,encode[make_pair(P[i],-1)]));
		to[encode[make_pair(Q[i],C[i])]].push_back(make_pair(0,encode[make_pair(Q[i],-1)]));
	}

	vector<int> cost(n,INF);
	cost[encode[make_pair(1,-1)]] = 0;
	priority_queue<cv, vector<cv>, greater<cv> > que;
	que.push(make_pair(0, encode[make_pair(1,-1)]));
	while(!que.empty()){
		int v = que.top().second;
		que.pop();
		//cout << c << " " << f/Nmax << " " << f%Nmax << " " << t/Nmax << " " << t%Nmax << endl;
		for(int i=0; i<to[v].size(); i++){
			int c = to[v][i].first;
			int u = to[v][i].second;
			if(cost[u] > cost[v]+c){
				cost[u] = cost[v]+c;
				que.push(make_pair(cost[u],u));
			}
		}
	}

	if(cost[encode[make_pair(N,-1)]] == INF){
		cout << -1 << endl;
	}
	else {
		cout << cost[encode[make_pair(N,-1)]] << endl;
	}
	return 0;
}


Measured memory_bytes: 67828
# Problem https://atcoder.jp/contests/abc095/tasks/abc095_a
# Ruby 3rd Try
ajitama,buta,negi = gets.chomp('\n').split('')
topping = 0
if ajitama == 'o'
    topping += 100
end
if buta=='o'
    topping += 100
end
if negi == 'o'
    topping += 100
end
answer = 700 + topping
puts(answer)

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

long long sti(string s) {
    long long ans = 0;
    for(int i = 0; i < (int)s.size(); i++) {
        ans = ans * 10 + s[i] - '0';
    }
    return ans;
}

long long nn(int x) {
    if(x == 0) return 1;
    return (1LL<<(x-1));
}

long long sum(string s) {
    long long ans = 0;
    for(int i = 1; i <= s.size(); i++) {
        ans += sti(s.substr(0, i)) * nn(s.size()-i) + sum(s.substr(i));
    }
    return ans;
}

int main() {
    string s;
    cin >> s;
    cout << sum(s) << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef double ld;

vector<pair<ll,ll>> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}

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

#define MAX_N 100010
bool x[MAX_N];
ll num[MAX_N];

ll fibl[MAX_N]={0};

ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}

ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    
    return p;
}

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

int main(){
    ll d,g;
    cin >> d >> g;
    if (d<10 && g<10){
        cout << d*g << endl;
    }else{
        cout << -1 << endl;
    }
    return 0;
}


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

using namespace std;

int main()
{
    int n;
    cin>>n;
    int a,b;
    cin>>a>>b;
    for(int i=a;i<=b;i++)
    {
        if(i%n==0)
        {
            cout<<"OK"<<endl;
            return 0;
        }
    }
    cout<<"NG"<<endl;
    return 0;
}


Measured memory_bytes: 3600