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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	for(auto &e:u) fill_v<T>(e,v...);
}

int main() {
//  cin.tie(0);
//  ios::sync_with_stdio(false);
  int64 N, Q;
  scanf("%lld %lld", &N, &Q);
  fenwick_tree<int64> ft(N);
  REP(i, N) {
    int64 a;
    cin >> a;
    ft.add(i, a);
  }
  REP(i, Q) {
    int64 t, a, b;
//    cin >> t >> a >> b;
    scanf("%lld %lld %lld", &t, &a, &b);
    if (t == 0) {
      ft.add(a, b);
    } else {
//      cout << ft.sum(a, b) << endl;
      printf("%lld\n", ft.sum(a, b));
    }
  }
}


Measured memory_bytes: 8204
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define f first
#define s second
#define all(container) container.begin(),container.end()
#define fast ios::sync_with_stdio(0); cin.tie(0)
#define int long long
const int mod = 1e9+7;  
int power(int a,int b) { if(b==0) return 1; int res = power(a,b/2); if(b&1) return res * res * a; else return res * res; }


int32_t main(){
    
  fast;
  int k,x; cin >> k >> x;
  if(k*500>=x) cout << "Yes\n";
  else cout << "No\n";

  

  return 0;
}

Measured memory_bytes: 256
a, b, c, x, y = map(int, input().split())
ans = 0
if a+b > c*2:
    ans += min(x, y) * 2 * c
    if [a, b][[x, y].index(max(x, y))] > c*2:
        ans += (max(x, y) - min(x, y)) * 2 * c
    else:
        ans += (max(x, y) - min(x, y)) * [a, b][[x, y].index(max(x, y))]
else:
    ans = a*x + b*y
print(ans)

Measured memory_bytes: 3064
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		int[][] a = new int[h][w];
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				a[i][j] = sc.nextInt();
			}
		}
		sc.close();

		List<String> ans = new ArrayList<String>();
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w - 1; j++) {
				if (a[i][j] % 2 == 1) {
					a[i][j]--;
					a[i][j + 1]++;
					ans.add((i + 1) + " " + (j + 1) + " " + (i + 1) + " " + (j + 2));
				}
			}
		}
		for (int i = 0; i < h - 1; i++) {
			if (a[i][w - 1] % 2 == 1) {
				a[i][w - 1]--;
				a[i + 1][w - 1]++;
				ans.add((i + 1) + " " + w + " " + (i + 2) + " " + w);
			}
		}
		System.out.println(ans.size());
		for (String s : ans) {
			System.out.println(s);
		}
	}
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    vector<ll> counter(N + 1, 0);
    counter[0] = 3;
    ll ans = 1;
    rep(i, N) {
        ll a = A[i];
        ans *= counter[a];
        ans %= MOD;
        counter[a]--;
        counter[a + 1]++;
    }
    cout << ans % MOD << '\n';
}

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


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include<set>
#include<map>
#include<bitset>
#define rep(i,a,b)  for(i=a;i<b;i++)
#define itrep(at)	for(auto it=at.begin();it!=at.end();it++)
#define lli long long int
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define db double
#define M 1000000007
#define pi 3.1415926535897932384626433832795028841971

#define MAX 100005

using namespace std;
lli min(lli a,lli b){return a<b?a:b;}
lli min(lli a,lli b,lli c){a=min(a,b);a=min(a,c);return a;}
lli max(lli a,lli b){return a>b?a:b;}
lli max(lli a,lli b,lli c){a=max(a,b);a=max(a,c);return a;}
lli dsum(lli n){lli ans=0;while(n){ans+=(n%10);n/=10;}return ans;}

struct pll{
	lli x,y;
};
bool comp(pll a,pll b){
	if(a.x==b.x)	return a.y<b.y;
	else	return a.x<b.x;
}
void fun(db h[],lli n)
{
	lli i,j;
	db ans=0;
	vector<db>dp(n+1,0);
	dp[0]=1-h[1];dp[1]=h[1];
	for(i=2;i<=n;i++){
		vector<db>tdp=dp;
		dp[0]=tdp[0]*(1-h[i]);
		for(j=1;j<=i;j++){
			dp[j]=tdp[j]*(1-h[i])+tdp[j-1]*h[i];
		}
	}
	lli nn=(n+1)/2;
	for(i=nn;i<=n;i++)	ans+=dp[i];
	cout << fixed << setprecision(10);
	cout << ans << endl;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	char ch;
	db aa,bb,cc;
	string s1,s2,s3,str;
    lli i,j,k,a,b,n,m,sum=0,temp,t;
    cin >> n;
    db h[n+1];
    rep(i,1,n+1)	cin >> h[i];
    fun(h,n);
    
    return 0;
}

















/* UJJWAL KESHRI */

Measured memory_bytes: 384
#include <vector>
#include <utility>
#include <cstdio>
#include <iostream>
#define INF (100000000)
using namespace std;
struct Card{
  char c;
  int n;
};

int partition(Card* A, int p, int r){
  int x = A[r].n;
  int i = p-1;
  for (int j = p ; j< r ; j++){
    if (A[j].n <= x){
      i = i+1;
      swap(A[i],A[j]);
    }
  }
  swap(A[i+1],A[r]);
  return i+1;
}


void quickSort(Card* A, int p, int r){
  if (p < r){
    int q = partition(A, p ,r);
    quickSort(A, p, q-1);
    quickSort(A, q+1, r);
  }
}

void merge(Card* A, int left, int mid, int right){
  int n1 = mid - left;
  int n2 = right - mid;
  Card cInf = {' ', INF};
  vector<Card> L(n1+1), R(n2+1);
  for( int i = 0; i < n1 ; ++i)
    L[i] = A[left + i] ;
  for( int i = 0; i < n2 ; ++i)
    R[i] = A[mid + i];
  L[n1] = cInf;
  R[n2] = cInf;
  int i = 0, j = 0;
  for (int k = left ; k < right ; ++k){
    if (L[i].n <= R[j].n){
      A[k] = L[i];
      i = i + 1;
    }
    else {
      A[k] = R[j];
      j = j + 1;
    }
  }
}

void mergeSort(Card* A, int left, int right){
  if (left+1 < right){
    int mid = (left + right)/2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}

int main(){
  int n;
  Card A[100000], B[100000];
  cin >> n;
  for(int i=0;i<n;++i){
    cin >> A[i].c >> A[i].n;
    B[i] = A[i];
  }
  quickSort(A, 0, n-1);
  mergeSort(B, 0, n);
  bool flag = false;
  for (int i=0;i<n && !flag;++i)
    if (A[i].c != B[i].c) flag = true;

  cout << (!flag?"Stable":"Not stable") << endl;
  for (int i=0;i<n;++i)
    cout << A[i].c << " " << A[i].n << "\n";
  return 0;
}



Measured memory_bytes: 5060
import sys
input = sys.stdin.readline

N=int(input())

abc=[]
kohuku=[]

for k in range(N):
    abc=list(map(int,input().split()))

    if k==0:
        kohuku.append(abc)
    else:
        tuika=[0,0,0]
        tuika[0]=max(kohuku[k-1][1],kohuku[k-1][2])+abc[0]
        tuika[1]=max(kohuku[k-1][0],kohuku[k-1][2])+abc[1]
        tuika[2]=max(kohuku[k-1][0],kohuku[k-1][1])+abc[2]
        kohuku.append(tuika)

print(max(kohuku[N-1]))


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

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>

const int maxn = 1e5+10;
const int mod = 1e9+7;

using namespace std;

void solve(){
	int n,m;
	cin>>n>>m;
	int tn = (n*(n-1))/2;
	int tm = (m*(m-1))/2;
	cout<<tn+tm<<endl;
}

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

//13*6 = 78

Measured memory_bytes: 3632
#include <stdio.h>

int sum[1000010], num[1000010];

int main(void)
{
	int m, s;
	int i, i2, n, ind;
	int max, min;
	
	while (1){
		
		scanf("%d", &n);
		
		if (n == 0){
			break;
		}
		
		for (i = 0; i < n; i++){
			sum[i] = 0;
			scanf("%d", &num[i]);
			
			for (i2 = 0; i2 < 4; i2++){
				scanf("%d %d", &m, &s);
				sum[i] += s + m * 60;  
			}
		}
		
		for (i = 0; i < 2; i++){
			min = sum[0];
			ind = 0;
			for (i2 = 0; i2 < n; i2++){
				if (min > sum[i2]){
					ind = i2;
					min = sum[ind];
				}
			}
			printf("%d\n", num[ind]);
			sum[ind] = 20000000;
		}
		
		for (i = 0; i < 2; i++){
			max = 0;
			for (i2 = 0; i2 < n; i2++){
				if (max < sum[i2] && sum[i2] != 20000000){
					ind = i2;
					max = sum[i2];
				}
			}
			if (i == 1){
				printf("%d\n", num[ind]);
			}
			sum[ind] = 0;
		}
	}
	return (0);
}

Measured memory_bytes: 2668
#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) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int 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 gcd(int x,int y){
	
	if(x%y==0){
		return y;
	}else{
		return gcd(y,x%y);
	}
	
}


int main() {

int N;
double X,Y;
cin>>N;
fx(N){
	double z;
	string S;
	cin>>z>>S;
	if(S=="JPY"){
		X+=z;
	}else{
		Y+=z;
	}
}
cout << fixed << setprecision(10) << X+Y*380000 << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
void pre(){}
void solve(){
    long long int n,w,x,y,a,b;cin>>n>>w;
    long long int dp[n+1][100001];
    long long int inp[n][2];
    for(long long int i=0;i<=n;i++){
        for(long long int j=0;j<=100000;j++){
            dp[i][j]=w+1;
        }
    }
    for(long long int i=0;i<n;i++){cin>>inp[i][0];cin>>inp[i][1];}
    pair<long long int,long long int>arr[n];
    for(long long int i=0;i<n;i++)arr[i]={inp[i][1],inp[i][0]};
    sort(arr,arr+n);
    long long int j;
    dp[0][0]=0;
    long long int ans = 0;
    for(long long int i=1;i<=n;i++){
        for(long long int j=0;j<=100000;j++){
            dp[i][j]=dp[i-1][j];
        }
        for(long long int j=0;j<=100000;j++){
            if(dp[i-1][j]+arr[i-1].second<=w){
                dp[i][j+arr[i-1].first] = min(dp[i][j+arr[i-1].first],dp[i-1][j]+arr[i-1].second);
                ans=max(ans,j+arr[i-1].first);
            }
        }
    }
    cout<<ans<<"\n";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    pre();
    long long int num = 1;
    //cin>>num;
    for(long long int i=0;i<num;i++){
       	solve();
    }   
}

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


#define fo(i, n) for(i=0; i<n; i++)
#define Fo(i, k, n) for(i=k; i<n; i++)
#define w(x)  int x; cin>>x; while(x--)
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define watch2(x,y) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<"\n"

#define ll  long long
#define all(c) (c).begin(),(c).end()
#define endl "\n"

typedef vector<int> vl;
typedef vector< vl > vvl;
typedef pair< int, int> pll;
typedef map< int, int> mll;
void c_p_c()
{
#ifndef ONLINE_JUDGE
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
void parray(int a[],int n){
    for(int i=0;i<n;i++){
    cout<<a[i]<<" ";
    }
    cout<<endl;
}

int main() {
    int i,n,k;
    c_p_c();
    cin>>n>>k;
    // cout<<"aa"<<endl;
	ll a,b,d=0,c;
	for (int i = 0; i < n; ++i)
	{
		cin>>a>>b;
		a=a*a;
		b=b*b;
		c=a+b;
		// watch(sqrt(c));
		if(sqrt(c)<=k)
			d++;
	}
	cout<<d<<endl;

    return 0;
}


Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define mem(x,v) memset(x,v,sizeof(x))
#define Rep(i,a,b) for(register int i=(a);i<=int(b);++i)
#define rep(i,a,b) for(register int i=(a);i<int(b);++i)
#define Dep(i,a,b) for(register int i=(a);i>=int(b);--i)
#define gc getchar
#define pc putchar
#define fi first
#define se second
inline ll read(){
    ll x=0,f=1;char c=gc();
    for(;!isdigit(c);c=gc())if(c=='-')f=-1;
    for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c^48);
    return x*f;
}
inline void write(ll x){if(x<0)x=-x,pc('-');if(x>=10)write(x/10);putchar(x%10+'0');}
inline void writeln(ll x){write(x);pc('\n');}
inline void wri(ll x){write(x);pc(' ');}
const int maxn = 2e5+233;;
//神仙结论https://img.atcoder.jp/agc032/editorial.pdf 
int a[maxn],n,m;
bool check(int k){
	k *= 2;
	rep(i,k,k+(2*n-k)/2)
		if(a[i]+a[2*n-(i-k)-1]<m) return false;
	return true;
}
int main(){
	n = read(),m = read();
	rep(i,0,n*2) a[i] = read();
	sort(a,a+2*n);
	int l = 0,r = n,ans = n;
	while(l <= r){
		int mid = (l + r) >> 1;
		if(check(mid)){
			ans = mid;
			r = mid - 1;
		} else l = mid + 1;
	}ans*=2;
	int mx = -1;
	rep(i,0,ans/2) mx=max(mx,a[i]+a[ans-i-1]);
	rep(i,ans,ans+(2*n-ans)/2) mx=max(mx,a[i]+a[2*n-(i-ans)-1]-m);
	writeln(mx);
	return 0;
}

Measured memory_bytes: 1024
from copy import deepcopy

def main():
    n = int(input())
    a = list(map(int, input().split()))
    div2 = [0] * n
    div4 = deepcopy(div2)
    notdiv4 = deepcopy(div2)
    for i in range(n):
        if a[i] % 4 == 0:
            div4[i] = 1
        elif a[i] % 2 == 0:
            div2[i] = 1
        else:
            notdiv4[i] = 1
    num_notdiv4 = sum(notdiv4)
    num_notdiv4 += sum(div2) % 2
    if num_notdiv4 - 1 > sum(div4):
        print('No')
    else:
        print('Yes')

if __name__ == '__main__':
    main()


Measured memory_bytes: 14764
using System;

public class Program
{

    public void Solve()
    {
        var sc = new Scanner();
        int X = sc.NextInt();
        int Y = sc.NextInt();
        long ans = 0;
        if (X == 1 && Y == 1)
        {
            ans += 400000;
        }

        if (X == 1)
        {
            ans += 300000;
        }
        if (X == 2)
        {
            ans += 200000;
        }
        if (X == 3)
        {
            ans += 100000;
        }
        
        if (Y == 1)
        {
            ans += 300000;
        }
        if (Y == 2)
        {
            ans += 200000;
        }
        if (Y == 3)
        {
            ans += 100000;
        }
        
        Console.WriteLine(ans);
    }

    public static void Main(string[] args)
    {
        new Program().Solve();
    }
}

class Scanner
{
    public Scanner()
    {
        _pos = 0;
        _line = new string[0];
    }

    const char Separator = ' ';
    private int _pos;
    private string[] _line;

    #region スペース区切りで取得

    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = Console.ReadLine().Split(Separator);
            _pos = 0;
        }

        return _line[_pos++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }

    #endregion

    #region 型変換

    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }

    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }

    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }

    #endregion

    #region 配列取得

    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = Console.ReadLine().Split(Separator);

        _pos = _line.Length;
        return _line;
    }

    public int[] IntArray()
    {
        return ToIntArray(Array());
    }

    public long[] LongArray()
    {
        return ToLongArray(Array());
    }

    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }

    #endregion
}

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

using namespace std;

typedef long long ll;
typedef long double ld;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, cnt = 0;
  ll d;
  cin >> n >> d;
  d *= d;
  for (int i = 1; i <= n; i++) {
    ll x, y;
    cin >> x >> y;
    x = x * x + y * y;
    cnt += (x <= d);
  }
  cout << cnt << "\n";
  return 0;
}


Measured memory_bytes: 3636
from itertools import accumulate

while True:
  n = int(input())
  if n == 0:
    break

  def to_sec(time):
    h, m, s = map(int, time.split(":"))
    return 3600 * h + 60 * m + s
  section = [0] * (60 * 60 * 24)
  for _ in range(n):
    t1, t2 = map(to_sec, input().split())
    section[t1] += 1
    section[t2] -= 1

  section_acc = accumulate(section)
  print(max(section_acc))


Measured memory_bytes: 6844
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
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;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (int i = 0; i < sz(v); i++) {
        os << v[i];
        if (i < sz(v) - 1) os << " ";
    }
    return os;
}
int main() {
    string s;
    cin >> s;
    s[1] = (s[1] == 'R' ? 'B' : 'R');
    cout << s << endl;
}

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

#define ll long long int
#define li int64_t

int main()
{
	string s,t;
	cin>>s>>t;
	int max = -1;
	for(int i=0;i<=s.length()-t.length();i++)
	{
		int count = 0;
		for(int j = 0;j<t.length();j++)
		{
			if(t[j] == s[i+j])
			{
				count++;
			}
		}
		if(count>max)max = count;
	}	
	cout<<t.length()-max;
}

Measured memory_bytes: 3628
#include <iostream>
#include <locale>
#include <string>
#include <algorithm>
#include <deque>
using namespace std;

int main() {
	string deck;
	int m;
	
	while (true) {
		cin >> deck;
		if (deck == "-") break;
		cin >> m;
		
		deque<char> que;
		for(int i=0; i<deck.size();i++)
			que.push_front(deck[i]);
			
		for(int i=0; i<m; i++) {
			int h;
			
			cin >> h;
			char ch;
			for(int j=0; j<h; j++) {
				ch = que.back(); 
				que.pop_back();
				que.push_front(ch);
			}
		}
		for_each(que.rbegin(), que.rend(), [](char ch){
    		cout << ch;
		});
		cout << endl;

	}
	
	return 0;
}


Measured memory_bytes: 3164
#include <cstdio>
#include <algorithm>

using namespace std;

int main() {
    int c, count = 0, ans = 0;
    while ((c = getchar()) != EOF && c != '\n') {
        if (c == 'A' || c == 'G' || c == 'C' || c == 'T') count++;
        else count = 0;
        ans = max(ans, count);
    }
    printf("%d\n", ans);
    return 0;
}

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

int main(){
        int n, m, gbg;
        scanf("%d %d", &n, &m);
        int hit[m];
        for(int i=0; i<m; i++) scanf("%d %d", &hit[i], &gbg);
        sort(hit, hit+m);

        int ans=0;
        for(int i=m-1; i>0; i--) ans += max(0, n-hit[i]);
        printf("%d\n", ans);
        return 0;
}


Measured memory_bytes: 3252
//-----------------------
// author : xyqkoala
// time : 2020-07-16
//-----------------------

#include<iostream>
#include<vector>
#include<string>
#include<deque>
#include<unordered_map>
#include<unordered_set>
#include<queue>
#include<algorithm>
#include<cmath>
#include<numeric>
using namespace std;

typedef long long LL;
const int MOD = 1e9+7;

void solve();


int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int T = 1;
	// cin>>T;
	while(T--){
		solve();
	}
	return 0;
}


void solve(){
	int n;
	cin>>n;
	int sm = 0;
	vector<int> nums(n);
	for(int i=0;i<n;i++){
		cin>>nums[i];
		sm ^= nums[i];
	}
	for(int i=0;i<n;i++){
		if(i) cout<<" ";
		cout<<(sm^nums[i]);
	}
	cout<<endl;
}


Measured memory_bytes: 3952
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define pb push_back
#define ss second

using namespace std;

const ll INF=99999999999999;

vector<ll> dist(100005, INF);

vector<pair<ll,ll> > adj[100005];


ll solve(ll arr[], int n)
{
   
    ll ans = arr[0];
 
    for (int i=1; i<n; i++)
    {
      ll p=( ((arr[i]*1)) /
                (__gcd(arr[i], ans)) );
        ans *=p;
	}
 
    return ans;
}

void go_run(ll src)
{
 
   priority_queue< pair<ll,ll>, vector <pair<ll,ll> > , greater<pair<ll,ll> > > pq;
   
    pq.push(make_pair(0LL, src));
    dist[src] = 0;
 
    while (!pq.empty())
    {
        
        ll u = pq.top().second;
        pq.pop();
 
        vector< pair<ll,ll> >::iterator i;
        
        for (i=adj[u].begin(); i != adj[u].end(); ++i)
        {
    
            ll v = (*i).first;
            ll weight = (*i).second;
 
            if (dist[v] > dist[u] + weight)
            {
                dist[v] = dist[u] + weight;
                pq.push(make_pair(dist[v], v));
            }
        }
    }
}
 
int main()
{

 ll a,b,c,d,i,p,n,q,k;
 
  cin>>n;
  
  p=n-1;
  
  while(p--)
  {
  	cin>>a>>b>>c;
  	adj[a].pb(mp(b,c));
  	adj[b].pb(mp(a,c));
  }
  
  cin>>q>>k;
  
  go_run(k);
  
  while(q--)
  {
  	cin>>a>>b;
  	
  	cout<<dist[a]+dist[b]<<"\n";
  }
   
	return 0;
 
} 

Measured memory_bytes: 11120
import java.util.*;

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

    Scanner scanner = new Scanner(System.in);
    int a = scanner.nextInt();
    int b = scanner.nextInt();
    int c = scanner.nextInt();

    if(a < b && b < c){
      System.out.println("Yes");

    }
    else{
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 26124
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

ll N, K, W, H, M;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

vector<ll> v;

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
    cin >> N >> K;
    v.resize(N);
    REP(i,N) cin >> v[i];
    sort(ALL(v));
    ll l = -1e18;
    ll h = 1e18;
    while(h > l+1){
        ll c = (l + h)/2;
        ll k = 0;
        for(int i = 0; i < N; ++i){
            if(v[i] > 0){
              	ll tmp = c >= 0 ? c/v[i]: (c -v[i] + 1)/v[i];
                int s = upper_bound(v.begin(), v.end(), tmp)-v.begin();
              	k += s > i ? s-1: s; 
            }
            else if(v[i] < 0){
              	ll tmp = c >= 0 ? (-1)*(c/abs(v[i])): (abs(c) + abs(v[i]) - 1)/abs(v[i]);
                int s = v.end() - lower_bound(v.begin(), v.end(), tmp);
                k += N - s <= i ? s-1: s;  
            }
            else k += c >= 0 ? N-1: 0; 
        }
        if(K <= k/2) h = c;
        else l = c;

    }
    cout << h ;
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath> // 変数名にy1が使えなくなるかも…。
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <limits>
#include <functional>
#include <string>

typedef __int128_t int128_t;
std::istream &operator>>(std::istream& input, int128_t& value) { // int128_tの入力。入力が64bitに収まる前提。
    long long tmp; input >> tmp; value = tmp;
    return input;
}
std::ostream &operator<<(std::ostream& output, const int128_t value) { // int128_tの出力。出力が64bitに収まる前提。
    output << (long long)value;
    return output;
}

#define rep(i, begin, end) for(int64_t i = (begin); i <= (end); i++)
#define rev(i, begin, end) for(int64_t i = (begin); (end) <= i; i--)

void printvec(const std::vector<int>& vec) {
    for (int i = 0; i < vec.size(); i++) { std::cout << vec[i] << " "; } std::cout << std::endl;
}

const int MAX_N = 1e5 + 10;
int N;
int H[MAX_N];
int dp[MAX_N][2] = {};

int main(int argc, char **argv) {
    std::cin >> N;
    rep (i, 1, N) {
        std::cin >> H[i];
    }

    dp[0][0] = 1;
    rep (i, 1, N) {
        if (dp[i-1][0]) {
            if (H[i-1] <= H[i]) {
                dp[i][0] = 1;
            }
            if (H[i-1] <= H[i] - 1) {
                dp[i][1] = 1;
            }
            
        }
        if (dp[i-1][1]) {
            if (H[i-1] - 1 <= H[i]) {
                dp[i][0] = 1;
            }
            if (H[i-1] - 1 <= H[i] - 1) {
                dp[i][1] = 1;
            }
        }
    }

    if (dp[N][0] == 1 || dp[N][1] == 1) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }

    

    return 0;
}

Measured memory_bytes: 1408
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
typedef long long ll;
const int INF = 1001001001;

int main() {
    int N;
    string s;

    cin >> N;

    vector<int> C(4, 0);

    rep(i, N) {
        cin >> s;
        if(s=="AC") {
            C[0]++;
        } else if(s=="WA") {
            C[1]++;
        } else if(s=="TLE") {
            C[2]++;
        } else if(s=="RE") {
            C[3]++;
        }
    }
        cout << "AC" << " " << "x" << " " << C[0] << endl;
        cout << "WA" << " " << "x" << " " << C[1] << endl;
        cout << "TLE" << " " << "x" << " " << C[2] << endl;
        cout << "RE" << " " << "x" << " " << C[3] << endl;

    return 0;
    
}

Measured memory_bytes: 3632
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<queue>
#include<stack>
#include<list>
#include<set>
#include<cstring>
#include<string>
using namespace std;
const int oo=-100;
int a[55][55];
int main(){
	int n,m;
    scanf("%d %d",&n,&m);
    char c;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++){
            cin>>c;
            if(c=='#'){
                a[i][j]=oo;
                a[i-1][j-1]++;
                a[i-1][j]++;
                a[i-1][j+1]++;
                a[i][j-1]++;
                a[i][j+1]++;
                a[i+1][j-1]++;
                a[i+1][j]++;
                a[i+1][j+1]++;
            }
        }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++)
            if(a[i][j]<0)printf("#");
            	else printf("%d",a[i][j]);
        printf("\n");
    }   
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y);
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
const int INF = 1001001001;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
istream& operator>>(istream&i,mint&a){i>>a.x;return i;}
ostream& operator<<(ostream&o,const mint&a){o<<a.x;return o;}


// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

mint choose (int n, int a) {
    mint x = 1, y = 1;
    rep(i,a) {
        x *= n-i;
        y *= i+1;
    }
    return x / y;
}

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    mint ans = mint(2).pow(n);
    ans -= 1;
    ans -= choose(n,a);
    ans -= choose(n,b);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3584
import java.util.*;
import java.io.PrintWriter;
public class Main{
	static long[] dp;
	static int[][] a;
	static int n;
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		n=sc.nextInt();
		dp=new long[1<<n];
		Arrays.fill(dp,(long)-2e10);
		a=new int[n][n];
		for(int i=0; i<n; i++){
			for(int j=0; j<n; j++){
				a[i][j]=sc.nextInt();
			}
		}
		System.out.println(dfs((1<<n)-1));
	}
	static long dfs(int bit){
		if(dp[bit]!=(long)-2e10){
			return dp[bit];
		}
		long re=0;
		for(int i=0; i<n; i++){
			for(int j=i+1; j<n; j++){
				if((1&bit>>i)==1 && (1&bit>>j)==1){
					re+=a[i][j];
				}
			}
		}
		for(int i=(bit-1)&bit; i>0; i=(i-1)&bit){
			re=Math.max(re,dfs(i)+dfs(bit^i));
		}
		return dp[bit]=re;
	}
}


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

int n, k;
bool d[10];

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> n >> k;
	for(int i=0; i<k; ++i){
		int tmp;
		cin >> tmp;
		d[tmp] = true;
	}
	while(true){
		bool f = true;
		int tmp = n;
		while(tmp > 0){
			if(d[tmp % 10])
				f = false;
			tmp /= 10;
		}
		if(f){
			cout << n << "\n";
			break;
		}
		++n;
	}
}

Measured memory_bytes: 256
import sys
from collections import deque
import copy

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [X, Y] = [long(input_raw[0]), long(input_raw[1])]
    print X + Y/2

if __name__ == '__main__':
    main()


Measured memory_bytes: 2932
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,k,ans=0;
	string s;
	cin>>n>>k>>s;
	char t=s[0];
	for(int i=1;i<n;i++)
	{
		if(t==s[i])ans++;
		else t=s[i];
	}
	cout<<min(n-1,ans+k*2);
	return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();

		if(n%k == 0)System.out.println("0");
		else System.out.println("1");

	}
}

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

int main() {
  ll n,m; cin >> n >> m;
  vector<bool> AC(n,true); vector<ll> WA(n,0);
  ll a = 0; ll w = 0;
  
  rep(i, m){
    ll p; string s; 
    cin >> p >> s;
    
    if(AC[p-1] && s == "AC"){
      AC[p-1] = false;
      a++;
      w += WA[p-1];
    }
    if(s == "WA"){
      WA[p-1]++;
    }
  }
  cout << a << " " << w << endl;
}

Measured memory_bytes: 4004
#include<vector>
#include<map>
#include<algorithm>
#include<set>
#include<iostream>
#include<string>
#include<set>
#include<queue>
#include<random>

using namespace std;

#pragma GCC optimize("Ofast")
#pragma GCC optimize("fast-math")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")

#define pb push_back
#define ld long double
#define int long long
#define mp make_pair

mt19937 rnd(51);

const int N = 2e5 + 10;
vector<int> a(N);
vector<int> g[N];
vector<int> d(N, 1e18);
vector<bool> used(N);
vector<int> kek(N);

void dfs(int v, int ans){
    used[v] = 1;
    int j = lower_bound(d.begin(), d.end(), a[v]) - d.begin();
    pair<int,int> p = {-1, -1};
    if (d[j - 1] < a[v]){
        ans = max(ans, j);
        if (a[v] < d[j]){
            p = {j, d[j]};
            d[j] = a[v];
        }
    }
    kek[v] = ans;
    for (auto to : g[v]){
        if (!used[to]){
            dfs(to, ans);
        }
    }
    if (p != mp(-1ll, -1ll)){
        d[p.first] = p.second;
    }
}

int32_t main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 0; i < n - 1; i++){
        int a, b;
        cin >> a >> b;
        g[a].pb(b);
        g[b].pb(a);
    }
    d[0] = -1e18;
    dfs(1, 0);
    for (int i = 1; i <= n; i++){
        cout << kek[i] << endl;
    }
	return 0;
}


Measured memory_bytes: 36128
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <unordered_set>

using namespace std;

int main() {
  string a, b;
  cin >> a >> b;

  if (a.size() < b.size()) {
    cout << "LESS" << endl;
    return 0;
  } else if (a.size() > b.size()) {
    cout << "GREATER" << endl;
    return 0;
  }

  int ia = 0, ib = 0;
  while (ia < a.size() && ib < b.size()) {
    if (a[ia] < b[ib]) {
      cout << "LESS" << endl;
      return 0;
    } else if (a[ia] > b[ib]) {
      cout << "GREATER" << endl;
      return 0;
    } else {
      ia++;
      ib++;
    }
  }
  cout << "EQUAL" << endl;
}


Measured memory_bytes: 256
// #include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>


using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,a,b) for(int i=(a);i<(b);i++)

template<class T> inline void chmin(T& a, T b) {if (a > b) a = b;}
template<class T> inline void chmax(T& a, T b) {if (a < b) a = b;}


int main() {
  int n;cin>>n;
  int sum=0;
  int temp;
  int ans=0;
  vector<int> a(n,0);
  rep(i,n){
    cin>>temp;
    a[i]=temp;
    sum+=temp;
  }
  int mean = floor(float (sum)/n+0.5);
  rep(i,n){
    ans+=(a[i]-mean)*(a[i]-mean);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
use std::io;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let v:Vec<u32> = procon_read();
	let n = v[0];
	let k = v[1];
	let mut p:Vec<u32> = procon_read();
	p.sort();
	let mut sum = 0;
	for i in 0..k as usize {
	    sum += p[i];
	}
	println!("{}", sum);
}

Measured memory_bytes: 2160
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<vector>
#include<set>
using namespace std;

#define ll long long
#define in ({ll x=0;int o=0,c=getchar();for(;!isdigit(c);c=getchar()) o=c=='-';for(;isdigit(c);c=getchar()) x=x*10+c-'0';o?-x:x;})
#define inchar ({char c=getchar();while(c==' '||c=='\n') c=getchar();c;})
#define instring ({string s;char c=getchar();while(c==' '||c=='\n') c=getchar();while(c!=' '&&c!='\n') s+=c,c=getchar();s;})

#define FOR(i,a,b) for(auto i=a;i<=b;i++)
#define ROF(i,a,b) for(auto i=b;a<=i;i--)
#define rr(x) " "<<#x<<'='<<x<<" "

#define bitnum(x) __builtin_popcountll(x)
#define bitl(x) (64-__builtin_clzll(x))
#define bit(x,i) ((x>>(i-1))&1ll)
#define on(x,i) (x|(1ll<<(i-1)))
#define off(x,i) (x&~(1ll<<(i-1)))

#define mt make_tuple
#define pi pair<int,int>
#define x first
#define y second

#define VEC(i,a) for(auto&i:a)
#define pb push_back
#define allv(a) a.begin(),a.end()
#define endv(a) (int)a.size()-1

#define ifnot(x) if(!(x))
#define middle(a,b) (a+(b-(a))/2)
#define bp(x) ((x)*(x))
#define pw2(x) (1ll<<x)

#define Min(a,b) ({bool o=false;if(a>b) {a=b;o=true;};o;})
#define Max(a,b) ({bool o=false;if(a<b) {a=b;o=true;};o;})
////////////////////////////////////////// HUX
const int N=1e5+5;
int a[N],n,k;
main()
{
    int res=0;
    n=in,k=in;
    FOR(i,1,n) res+=in>=k;
    cout<<res;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int m=1e9+7;
int main()
{
    long long int n,k,a[200005],c,i,b[200005],j;long long s=0;
    scanf("%lld %lld",&n,&k);
    a[0]=0;b[n]=n;
    for(i=1;i<=200004;i++)
    {
        a[i]=(a[i-1]+i);
    }
    for(i=n;i>=0;i--)
    {
        b[i]=(b[i+1]+i);
    }
        //for(i=k-1,j=n-k+1;i<=n;i++,j--)
    //{
        //printf("%d\n",b[j]-a[i]);
   // }

    for(i=k-1,j=n-k+1;i<=n;i++,j--)
    {
        s=s+(b[j]-a[i]+1);
        s%=m;
    }

        printf("%lld",s%m);

}


Measured memory_bytes: 4852
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<ctime>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<queue>
#include<vector>
#include<iostream>
#include<algorithm>
#define ll long long
#define dd double
using namespace std;
int main() {
	ll n, m;
	cin >> n >> m;
	cout << n - m + 1 << endl;
}

Measured memory_bytes: 256
(let ((a (concatenate 'list (read-line)))
      (b (concatenate 'list (read-line)))
      (c (concatenate 'list (read-line))))
  (defun f (chr)
    (cond ((char= #\a chr) (if a (f (pop a)) (princ "A")))
          ((char= #\b chr) (if b (f (pop b)) (princ "B")))
          ((char= #\c chr) (if c (f (pop c)) (princ "C")))))
  (f #\a))

Measured memory_bytes: 11108
#include <regex>
#include "bits/stdc++.h"
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define INF (INT_MAX / 2)
#define LINF (LLONG_MAX / 2)
#define EPS (1.0e-8)
const int MGN = 10;
const int ARY_SZ_MAX = (int)1e7;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>;
using vc = vector<char>; using vvc = vector<vc>;
using vb = vector<bool>; using vvb = vector<vb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>; using psl = pair<string, ll>;


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


  int N; cin>>N;
  string S; cin>>S;

  int ans = 0;
  REP(i,N-2) {
    if (S[i]=='A' && S[i+1]=='B' && S[i+2]=='C') ans++;
  }

  cout << ans << endl;


  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main()
{
	double N;
	scanf("%lf", &N);

	double i, j;
	for (i = floor(sqrt(N)); i >= 1; i--) {
		j = floor(N / i);
		if (i * j == N)  break;
	}
    printf("%.0lf", -2+i+j);
	return 0;
}

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

int main(){
    string s;
    cin>>s;
    for(int i=0;i<3;i++){
        if(s[i]==s[i+1]){
            cout<<"Bad"<<endl; 
            return 0;
        }
    }
    cout<<"Good"<<endl;
    return 0;
}

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

int main(){
    int n,m,x;
    cin >> n >> m >> x;
    vector<int> y(m);
    rep(i,n)cin >> y[i];
    int a = 0,b = 0,s = 0,t = n-1;
    for(int i = x;i < n;i++){
        for(int j = s;j <= m;j++){
            if(y[j] < i){
              	s = j;
              	continue;
            }
            else if(y[j] == i){
                a++;
                s = j;
                break;
            }
            break;
        }
    }
    for(int i = x;i >= 0;i--){
        for(int j = t;j >= 0;j--){
            if(y[j] > i) {
              	t = i;
              	continue;
            }
            else if(y[j] == i){
                b++;
                t = j;
              	break;
            }
        }
    }
    cout << min(a,b) << endl;
}


Measured memory_bytes: 256
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
int getDigit(long long n);      // 数字の桁数を取得する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      ((a)/GCD((a),(b))*(b))
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

typedef long long ll;
typedef unsigned long long ull;

// code
// ------------------------------------------------
int main() {

  ll a,b,c,d;
  cin >> a >> b >> c >> d;

  ll a_c = (a-1) / c;
  ll a_d = (a-1) / d;
  ll a_c_d = (a-1) / LCM(c ,d);
  ll b_c = b / c;
  ll b_d = b / d;
  ll b_C_d = b / LCM(c , d);

  ll ans = (b - a + 1) - (b_c - a_c) - (b_d - a_d) + (b_C_d - a_c_d );

  cout << ans << endl;

  return 0;
}
// funcの実体
// ------------------------------------------------
int getDigit(ll n)
{
  int i = 1;
  while(1)
  {
    n = n / 10;
    if(n == 0)
      break;
    i++;
  }
  return i;
}
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


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

int main(){
    string s;
    cin >> s;
    for(int i=0; i<s.size()-1; i++){
        if(s[i] == s[i+1]){
            cout << "Bad";
            return 0;
        }
    }
    cout << "Good";
    return 0;
}


Measured memory_bytes: 256
import sys
from bisect import bisect
from itertools import accumulate


def main():
    input = sys.stdin.buffer.readline
    n = int(input())
    a = sorted(map(int, input().split()))
    b = sorted(map(int, input().split()))
    c = sorted(map(int, input().split()))
    # 各中部パーツを乗せられる下部パーツの個数
    # b_c_cnt = [len(c[bisect(c, b[i]) :]) for i in range(n)]
    b_c_cnt = [0] * n
    past = 0
    for i in range(n):
        pos = bisect(c, b[i], lo=past)
        past = pos
        b_c_cnt[i] = n - pos

    # b_c_cntに後ろから累積和をとる
    acc = list(accumulate(b_c_cnt[::-1]))[::-1] + [0]
    ans = 0
    past = 0
    for i in range(n):
        pos = bisect(b, a[i], lo=past)
        ans += acc[pos]
        past = pos
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 31460
N, M = map(int, input().split())
ps = [[i for i in input().split()] for i in range(M)]

ac = 0
penalty = 0
check = [0 for i in range(N)]
for i in range(M):
    p, S = ps[i]
    if check[int(p)-1] != -1:
        if S == "AC":
            ac += 1
            penalty += check[int(p)-1]
            check[int(p)-1] = -1
        if S == "WA":
            check[int(p)-1] += 1

print("{} {}".format(ac, penalty))

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

	#define E "\n"
	#define int long long 
	#define f(i,l,n) for(int i=l;i<n;i++)




	int solve()
	{
		int n,m,x;
		cin >> n >> m >> x;
		int a[n+1][m+1],c[n];

		f(i,0,n)
		{
			cin >> c[i];
			f(j,0,m) cin >> a[i][j];
		}
		int N=1<<n,ans=1e18,algo[m];

		f(i,1,N+1) 
		{
			int temp=i;
			memset(algo,0,sizeof algo);
			int cnt=0,rupe=0;
			f(j,0,n)
			{
				if((1<<j)&temp) 
				{
					rupe+=c[j];

					f(t,0,m)
					{
					  algo[t]+=a[j][t];
					}
				}
			}
			f(t,0,m) cnt+=(algo[t]>=x);
			//cout<<i<<" "<<cnt<<E;
			if(cnt>=m)
			ans=min(ans,rupe);
		}
		if(ans==1e18) ans=-1;
		cout<<ans;

		return 0;
	}

		


		int32_t main()
		{

		 	int t=1;
		 	//cin >> t;
		 	while(t--)
		 	{
		 		solve();
		 		///cout<<(1<<1);
		 	}

		}

Measured memory_bytes: 3640
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 1000000007;
//const int MOD = 998244353;
//const long long int MOD = 998244353;

long long int N, M, K, H, W, L, R;
//int N, M, K, H, W, L, R;

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

	cin >> N;
	vector<vector<pair<int, long long int>>>edge(N);
	for (int i = 1; i < N; i++) {
		cin >> L >> R >> K;
		edge[L - 1].push_back({ R - 1,K });
		edge[R - 1].push_back({ L - 1,K });
	}
	vector<long long int>dis(N, MOD*MOD);
	dis[0] = 0;
	queue<int>Q;
	Q.push(0);
	while (!Q.empty()) {
		int cn = Q.front();
		Q.pop();
		for (auto i : edge[cn]) {
			if (dis[i.first] > dis[cn] + i.second) {
				dis[i.first] = dis[cn] + i.second;
				Q.push(i.first);
			}
		}
	}
	for (int i = 0; i < N; i++)cout << dis[i] % 2 << endl;
	return 0;
}


Measured memory_bytes: 8704