akhauriyash/Code-Regression huggingface dataset:
import sys
input = sys.stdin.readline
 
MOD = 10**9 + 7
U = 2 ** 20
 
N = int(input())
A = [int(x) for x in input().split()]
 
arr_0 = [1]*U
arr_1 = [0]*U
 
zero_update = [0] * U #0が出てきて更新した回数
zero_cnt = 0
 
c = 0
for a in A:
  c ^= a
  if c == 0:
    zero_cnt += 1
    continue
  n = zero_cnt - zero_update[c]
  zero_update[c] = zero_cnt
  a = arr_0[c]
  b = arr_1[c]
  a,b = a+n*b,b
  a,b = a,a+b
  a %= MOD
  b %= MOD
  arr_0[c] = a
  arr_1[c] = b
 
answer = 0
if c != 0:
  answer = arr_0[c]
else:
  answer = sum(arr_1[1:])
  answer += pow(2,zero_cnt-1,MOD)
  answer %= MOD
print(answer)


Measured memory_bytes: 63016
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;
template <class T> inline void chmax(T &a, const T b) { a = max(a, b); }
template <class T> inline void chmin(T &a, const T b) { a = min(a, b); }
template <class T> void pp(T v, int n) { REP(i,n) cout<<v[i]<< ' '; cout << endl; }

void inline TorF(bool tf, const string &trueMessage, const string &falseMessage) { 
  cout << (tf ? trueMessage : falseMessage) << endl;
}
void inline YESNO(bool tf) { TorF(tf, "YES", "NO"); }
void inline YesNo(bool tf) { TorF(tf, "Yes", "No"); }

vector<int> primes;
vector<bool> isprime;
vector<ll> cnt;
void init(const int N) {
  isprime = vector<bool> (N+1, true);
  cnt = vector<ll> (N+1, 1);
  cnt[1] = 1;
  //  for(int i = 2; i <= N; i+= 2) cnt[i] = 1;
  isprime[0] = isprime[1] = false;
  for(int i = 2; i <= N; i++) {
    if(isprime[i]) {
      primes.push_back(i);
      for(int j = i+i; j <= N; j += i) isprime[j] = false;
    }
  }
  //  pp(primes, primes.size());
#ifdef DEBUG
  for(int i = 1; i <= N; i++) {
    for(int j = 0; j <= primes.size(); j++) {
      int k = i * primes[j];
      if(k > N) break;
      cnt[k] += cnt[i];
    }
  }
#endif
}

ll g(int n) {
  ll ret = 0;
  for(int i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      if(i*i == n) ret++;
      else ret += 2;
    }
  }
  return ret;
}

ll f(int n) {
  ll ret = 1;
  if(n == 1) return 1LL;
  if(isprime[n]) return 2LL;
  REP(i, primes.size()) {
    if(n == 1) break;
    if(isprime[n]) {
      ret *= 2LL;
      break;
    }
    int cnt = 0;
    while(n % primes[i] == 0) {
      cnt ++;
      n /= primes[i];
    }
    ret *= cnt+1;
  }
  return ret;
}

int main() {
  int N; cin>>N;
  ll ans = 0;
  init(N);
  for(int i = 1; i <= N; i++) {
    ll tmp = f(i);
    //    cout << i << " " << tmp << endl;
    ans += tmp * (ll)i;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 86296
#include <bits/stdc++.h>
#include <atcoder/all> 

using namespace std;
using namespace atcoder;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
// #define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
// int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
// vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'

signed main() {
    int n, q;
    cin >> n >> q;
    dsu uf(n);
    while (q--) {
        int t, u, v;
        cin >> t >> u >> v;
        if (t == 0) {
            uf.merge(u, v);
        }
        else {
            cout << uf.same(u, v) << endl;
        }
    }
    
}

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

int main() {
  int N;
  cin >> N;
  
  vector<int> vec(N);
  for(int i=0; i < N; i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  vec.push_back(0);
  
  int X,Y = 0;
    for(int j=0; j < N; j+=2){
      X += vec.at(j);
      Y += vec.at(j+1);
    }
  
  cout << X - Y << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
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; }
ll mod= 1e9 + 7;


int main(){
  int n;
  cin >>n;
  int g=20000-n;
  cout << g%1000 << endl;

}

Measured memory_bytes: 3632
#include <stdio.h>



#define width 100
#define height 100

char board[width][height];
int main(void){
    // Your code here!
    int W,B;
    scanf("%d %d",&W,&B);
    

    for(int y = 0; y < height/2 ; y++){
        for(int x=0; x < width; x++){
            board[x][y]=0; //W
            board[x][height/2+y]=1; //B
        }
    }
    W--; B--;

    int x,y = 0;
    while(B > 0){
        x = 0;
        while(B > 0 && x < width && y < height/2 ){
            board[x][y] = 1;
            B--;
            x += 2;
        }
        y += 2;
    }
    y = height/2+1;
    while(W > 0){
        x = 0;
        while(W > 0 && x < width && y < height ){
            board[x][y] = 0;
            W--;
            x += 2;
        }
        y += 2;
    }
    
    
    
    printf("%d %d\n", height, width);
    for(int yy = 0; yy < height ; yy++){
        for(int xx = 0; xx < width ; xx++){
            printf("%c",(board[xx][yy]==0)?'.':'#');
        }
        puts("");
    }
}


Measured memory_bytes: 128
n,k = map(int,input().split())
v = list(map(int,input().split()))
idx_k = k
k = min(n,k)

ans = 0
for i in range(k+1):
	for j in range(k-i+1):
		# print(i,j)
		a = v[:i]
		b = v[-j:]
		if len(b) == n:
			b = []
		ab = sorted(a+b+[0])
		idx = min(ab.index(0),idx_k-i-j)
		ans = max(ans,sum(ab[idx:]))
		# print(a,b,ab,idx,sum(ab[idx:]))
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll w,a,b;
    cin>>w>>a>>b;
    ll ans=300000;
    if(b>a+w){
        ans=b-a-w;
    }
    else if(b+w<a){
        ans=a-b-w;
    }
    else{
        ans=0;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Text;
using System.Collections.Generic;
class Solve{
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        string[] str = Console.ReadLine().Split(' ');
        int N = int.Parse(str[0]);
        long K = int.Parse(str[1]);
        string s = Console.ReadLine();
        if(N == 1){
            if(K % 2 == 0 ^ s[0] == 'A'){
                sb.Append("B\n");
            }
            else{
                sb.Append("A\n");
            }
        }
        else{
            bool f = false;
            bool c = false;
            int count = 0;
            for(int i=0;i<N;i++){
                if(!f){
                    if(s[i] == 'A' ^ c){
                        if(K == 1){
                            K--;
                            sb.Append("B");
                            count++;
                        }
                        else{
                            K -= 2;
                            c = !c;
                        }
                        if(K == 0){
                            f = true;
                        }
                    }
                    else{
                        K--;
                        c = !c;
                        if(K == 0){
                            f = true;
                        }
                    }
                }
                else{
                    if(s[i] == 'A' ^ c){
                        sb.Append("A");
                    }
                    else{
                        sb.Append("B");
                    }
                    count++;
                }
            }
            if(K != 0){
                if(N % 2 == 0){
                    c = false;
                    for(int i=0;i<N;i++){
                        if(c){
                            sb.Append("A");
                        }
                        else{
                            sb.Append("B");
                        }
                        c = !c;
                    }
                }
                else{
                    if(K % 2 == 0){
                        sb.Append("A");
                    }
                    else{
                        sb.Append("B");
                    }
                    c = false;
                    for(int i=0;i<N-1;i++){
                        if(c){
                            sb.Append("A");
                        }
                        else{
                            sb.Append("B");
                        }
                        c = !c;
                    }
                }
            } 
            else{
                for(int i=count;i<N;i++){
                    if(c){
                        sb.Append("A");
                    }
                    else{
                        sb.Append("B");
                    }
                    c = !c;
                }
            }
            sb.Append("\n");
        }
    }
}

Measured memory_bytes: 13340
#include<bits/stdc++.h>
#define endl '\n'
#define mod 1000000007
typedef long long int ll;
using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    while(t--){
	   string s,p;
	   cin>>s>>p;
	   int cnt=0;
	   for(int i=0;i<(int)s.size();i++){
		   if(s[i] != p[i])
			   cnt++;
	   }
	   cout<<cnt<<endl;
    
    }
    return 0;
} 


Measured memory_bytes: 3756
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }
template<typename T> inline T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }







int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    
    // なすすべなし
    // 解説みた
    // 実験したらわかったのかな
    
    string s;
    cin >> s;
    
    if (((sz(s) % 2) ^ (s[0] == s[sz(s) - 1])) == 0) {
        cout << "Second" << endl;
    } else {
        cout << "First" << endl;
    }
}


Measured memory_bytes: 512
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// #include<ext/pb_ds/tag_and_trait.hpp>
// using namespace __gnu_pbds;
// #include<boost/multiprecision/cpp_int.hpp>
// namespace multiprecisioninteger = boost::multiprecision;
// using cint=multiprecisioninteger::cpp_int;
using namespace std;
using ll=long long;
#define double long double
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
// using llset=tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>;
#define For(i,a,b) for(i=a;i<(ll)b;++i)
#define bFor(i,b,a) for(i=b,--i;i>=(ll)a;--i)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N,0)
#define brep1(i,N) bFor(i,N,1)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define eb emplace_back
#define print(v) cout<<v<<endl
#define printyes cout<<"Yes"<<endl
#define printno cout<<"No"<<endl
#define printYES cout<<"YES"<<endl
#define printNO cout<<"NO"<<endl
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
#define matoutput(v) do{for(auto outimat:v)output(outimat);}while(0)
const ll mod=1000000007;
// const ll mod=998244353;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

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

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

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

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

vec modncrlistp,modncrlistm;

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

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

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

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

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

int main(){
  // startupcpp();
  // int codeforces;cin>>codeforces;while(codeforces--){
  ll i,j,N,M,ans=0;
  string s;cin>>s;
  s[1]='R'+'B'-s[1];
  print(s);
}

Measured memory_bytes: 3536
package main

import (
	"fmt"
)

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	fmt.Println(gcd(a, b))
}

func gcd(a, b int) int {
	if a%b == 0 {
		return b
	}

	if a >= b {
		return gcd(b, a%b)
	} else {
		return gcd(a, b%a)
	}
}



Measured memory_bytes: 1120
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll>PLL;
#define rep(i,n) for (int i = 0; i < (n); ++i)
ll MOD = 1e4+7;
int main() {
    string s;
    cin >> s;
    map<char, int> mp;
    rep(i, s.length()) {
        ++mp[s[i]];
    }
    for ( auto tmp_mp : mp ) {
        if ( tmp_mp.second&1 ) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


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

typedef long long int ll;
typedef vector<int> vi;			typedef vector<ll> vl;
typedef vector<vi> vvi; 		typedef vector<vl> vvl;
typedef pair<int, int> 	pii;	typedef pair<ll, ll> pll;
typedef vector<pii> vii; 		typedef vector<pll> vll;
typedef map<int,int> mii;
typedef vector<char> vc;
typedef vector<bool> vb;
#define endl '\n'
#define forn(i,n) for(int i=0;i<n;i++)
#define rforn(i,n) for(int i=n-1;i>=0;i--)
#define forne(i,n) for(int i=1;i<=n;i++)
#define rforne(i,n) for(int i=n;i>=1;i--)
#define forse(i,s,e) for(int i=s;i<e;i++)
#define rforse(i,s,e) for(int i=e-1;i>=s;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size()
#define MOD 1000000007
#define F first
#define S second
#define pb push_back
#define in insert
#define mp(a, b) make_pair(a, b)
#define fill(a,x) memset(a,x,sizeof a);
#define trav(a,x) for(auto &a:x)
#define min3(a, b, c) min(min(a, b), c)
#define min4(a, b, c, d) min(min(a, b), min(c, d))
#define max3(a, b, c) max(max(a, b), c)
#define max4(a, b, c, d) max(max(a, b), max(c, d))
#define INF INT_MAX
#ifdef KARAN
	#include "../../trace.h"
#else
    #define trace(args...)
#endif

ll modpow(ll a, ll b, ll m = MOD){a %= m; ll res = 1; 
	while (b) {if (b & 1)res = (res * a) % m; a = (a * a) % m; b >>= 1;} return res;}
ll bpow(ll a, ll b){ll res = 1; while (b) {if (b & 1)res = res * a; a = a * a; b >>= 1;} return res;}
ll modinv(ll a, ll m = MOD) {return modpow(a, m - 2, m);}
void graph(vvi &adj, int m) {int x, y; forn(i, m){cin>>x>>y; adj[--x].pb(--y); adj[y].pb(x);}}

void solve(){
	int n, x, y;
	cin>>n>>x>>y;
	x--; y--;
	int dp[n][n];
	forn(i, n) forn(j, n) dp[i][j] = min3(abs(i-j), abs(x-i) + 1 + abs(y-j), abs(x-j) + 1 + abs(y-i));
	vector<int> cnt(n, 0);
	forn(i, n) forn(j, n) cnt[dp[i][j]]++;
	forne(i, n-1) cout<<cnt[i]/2<<endl;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	#ifdef KARAN
		freopen("inp.txt", "r", stdin);
    	freopen("out.txt", "w", stdout);
    	freopen("err.txt", "w", stderr);
	#endif
	int t=1;
	// cin>>t;
	while(t--)
		solve();
}

Measured memory_bytes: 15872
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
 
using namespace std;
typedef long long int ll;
 
 
int main(int argc, char const *argv[])
{
	ll x, a;
	cin >> x >> a;
	if (x < a)
	{
		cout << 0 << endl;
 
	}
	else{
		cout << 10 << endl;
	}
}

Measured memory_bytes: 256
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

N = int(input())
C = [0] * N
S = [0] * N
F = [0] * N

for i in range(N - 1):
    C[i], S[i], F[i] = map(int, input().split())

ans = [0] * N

for i in range(N):
    cur = S[i] + C[i]
    for j in range(i + 1, N - 1):
        if cur < S[j]:
            cur = S[j] + C[j]
        else:
            d = (cur - S[j])
            cnt = (d + F[j] - 1) // F[j]
            cur = S[j] + cnt * F[j] + C[j]
    ans[i] = cur

for a in ans:
    print(a)

Measured memory_bytes: 3680
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

//typedef pair<int,int> P;



int main(){
	int a,b,c;
	scanf("%d %d %d", &a, &b, &c);

	if(a+b<c){
		printf("No\n");
	}else{
		printf("Yes\n");
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define forE(i,x) for(int i=head[x];i!=-1;i=ne[i])
using namespace std;
typedef long long i64;
typedef unsigned long long u64;
typedef unsigned u32;
typedef pair<int,int> pin;
#define mk(a,b) make_pair(a,b)
#define lowbit(x) ((x)&(-(x)))
#define sqr(a) ((a)*(a))
#define clr(a) (memset((a),0,sizeof(a)))
#define ls ((x)<<1)
#define rs (((x)<<1)|1)
#define mid (((l)+(r))>>1)
#define pb push_back
#define w1 first
#define w2 second
inline void read(int &x){
	x=0;int f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	x*=f;
}
inline void judge(){
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
}
/*******************************head*******************************/
const int maxn=2105;
int f[maxn][maxn];
int fac[maxn*maxn],facinv[maxn*maxn];
const int mod=1e9+7;
inline int powmod(int a,int b){
	int res=1;for(;b;b>>=1){
		if(b&1)res=1ll*res*a%mod;
		a=1ll*a*a%mod;
	}return res;
}
inline void prprpr(){
	fac[0]=1;
	rep(i,1,2000*2001)fac[i]=1ll*fac[i-1]*i%mod;
	facinv[2000*2001]=powmod(fac[2000*2001],mod-2);
	per(i,2000*2001-1,0)facinv[i]=1ll*facinv[i+1]*(i+1)%mod;
}
inline int C(int n,int m){
	if(m<0||n<0||m>n)return 0;
	return 1ll*fac[n]*facinv[m]%mod*facinv[n-m]%mod;
}
inline void add(int &x,int y){
	x=((x+y)>=mod?(x+y-mod):(x+y));
}
int n,k;
inline void solve(){
	read(n);read(k);
	if(k==1){
		puts("1");
		return;
	}
	rep(i,0,n)f[i][0]=1;
	rep(i,0,n)rep(j,i,n){
		if(i)add(f[i][j],f[i-1][j]);
		if(i<j)add(f[i][j],1ll*f[i][j-1]*C((k-1)*(j-1)+i+k-2,k-2)%mod);
	}
	cout<<1ll*fac[n]*f[n][n]%mod<<endl;
}
int main(){
    prprpr();
   solve();
    return 0;
}


Measured memory_bytes: 51456
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<math.h>
#include<stdio.h>

using namespace std;

using ll = long long;

#define rep(i, n) for (ll i = 0; i < n; i++)

const ll INF = 1LL << 60;

typedef pair<ll, double> P;

bool pairCompare(const P& firstElof, const P& secondElof)
{
	return firstElof.second < secondElof.second;
}

bool IsPrime(ll num)
{
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; // 偶数はあらかじめ除く
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			// 素数ではない
			return false;
		}
	}

	// 素数である
	return true;
}

signed main() {
	ll ans = 0;

	ll n, k;
	cin >> n >> k;

	vector<ll>a(n + 1);

	rep(i, n) {
		char s;
		cin >> s;
		if (s == 'R') {
			a[i] = 1;
		}
		else {
			a[i] = 0;
		}
	}
	ll katamari = 1;
	for (ll i = 1; i < n; i++) {
		if (a[i] != a[i - 1])katamari++;
		else {
			ans++;
		}
	}
	rep(i, k) {
		if (katamari >= 3) {
			ans += 2;
			katamari -= 2;
		}
		else if (katamari == 2) {
			ans++;
			katamari--;
		}
		else break;
	}
	cout << ans;
}


Measured memory_bytes: 1024
using System.Text;
using System;

public class UnionFind
{
    private int[] data;
    public UnionFind(int size)
    {
        data = new int[size];
        for (int i = 0; i < size; i++) data[i] = -1;
    }
    public bool Unite(int x, int y)
    {
        x = Root(x);
        y = Root(y);
        if (x != y)
        {
            if (data[y] < data[x])
            {
                var tmp = y;
                y = x;
                x = tmp;
            }
            data[x] += data[y];
            data[y] = x;
        }
        return x != y;
    }
    public bool IsSameGroup(int x, int y) => Root(x) == Root(y);
    public int Root(int x) => data[x] < 0 ? x : data[x] = Root(data[x]);
    public int getMem(int x) => -data[Root(x)];
}


public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var m = int.Parse(line[1]);
        var a = new int[m];
        var b = new int[m];
        for (int i = 0; i < m; i++)
        {
            line = Console.ReadLine().Trim().Split(' ');
            a[i] = int.Parse(line[0]) - 1;
            b[i] = int.Parse(line[1]) - 1;
        }
        Array.Reverse(a);
        Array.Reverse(b);
        putAns(a, b, n, m);
    }
    static void putAns(int[] a, int[] b, int n, int m)
    {
        var ans = new long[m + 1];
        var uf = new UnionFind(n + 10);
        ans[0] =(long) n * (n - 1) / 2L;
        for (int i = 0; i < m; i++)
        {
            if (uf.IsSameGroup(a[i], b[i])) ans[i + 1] = ans[i];
            else
            {
                long wa = uf.getMem(a[i]);
                long wb = uf.getMem(b[i]);
                ans[i + 1] = ans[i] - wa * wb;
                uf.Unite(a[i], b[i]);
            }
        }
        Array.Reverse(ans);
        var sb = new StringBuilder();
        for (int i = 1; i <= m; i++) sb.Append(ans[i].ToString() + "\n");
        Console.Write(sb);
    }
}

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

int main () {
  vector<int> line(3) ;
  
  for (int i = 0  ; i < 3 ; i++ ){
    cin >> line.at(i) ;
  }
  
  sort (line.begin() , line.end() ) ;
  
  if ( line.at(0) == 5 && line.at(1) == 5 && line.at(2) ) {
    cout << "YES" << endl ;
  } else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
# 1 "p.cpp"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "p.cpp"
# 1 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp" 1
       
# 12 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp"
# 1 "/home/tysm/dev/cpplib/bin/../stdlib/bits/stdc++.h" 1
 #include <bits/stdc++.h>
# 13 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp" 2
# 1 "/home/tysm/dev/cpplib/bin/../stdlib/ext/pb_ds/assoc_container.hpp" 1
 #include <ext/pb_ds/assoc_container.hpp>
# 14 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp" 2
# 1 "/home/tysm/dev/cpplib/bin/../stdlib/ext/pb_ds/tree_policy.hpp" 1
 #include <ext/pb_ds/tree_policy.hpp>
# 15 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp" 2







using namespace std;
using namespace __gnu_pbds;

using ii = pair<long long, long long>;
using vi = vector<long long>;
using vd = vector<long double>;
using vb = vector<bool>;
using vii = vector<ii>;
using vvi = vector<vi>;
using vvd = vector<vd>;
using vvb = vector<vb>;
using vvii = vector<vii>;
# 50 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp"
inline long long mod(const long long n, const long long m = ((long long)1e9+7)){
    return (n%m + m)%m;
}

/**
 * Euclidean GCD.
 *
 * Time Complexity: O(log(min(a, b))).
 * Space Complexity: O(log(min(a, b))).
 */
long long gcd(const long long a, const long long b){
    if(a < 0 or b < 0)
        return gcd(abs(a), abs(b));
    if(a == 0)
        return b;
    return gcd(b%a, a);
}

/**
 * Euclidean derivated LCM.
 *
 * Time Complexity: O(log(min(a, b))).
 * Space Complexity: O(log(min(a, b))).
 */
long long lcm(const long long a, const long long b){
    // same as a*b/gcd(a, b) but avoiding overflow.
    return a/gcd(a, b)*b;
}
# 2 "p.cpp" 2

long long n;
vvi adj;
long long dp[2][(long long)1e5+1];

long long solve(long long u, long long c, long long p = -1){
    long long &res = dp[c][u];
    if(res != -1)
        return res;
    res = 1;
    for(long long v:adj[u]){
        if(v == p)
            continue;
        if(c)
            res = mod(res * solve(v, 0, u));
        else
            res = mod(res * mod(solve(v, 0, u) + solve(v, 1, u)));
    }
    return res;
}


int32_t main(){
    (ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL));
    cin >> n;
    adj.resize(n+1);
    for(long long i=1; i<n; ++i){
        long long a, b;
        cin >> a >> b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    memset(dp, -1, sizeof(dp));
    cout << mod(solve(1, 0) + solve(1, 1)) << "\n";
    return 0;
}


Measured memory_bytes: 15616
n = int(input())
l = []
while n != 0:
	a = n % 26
	l.append(a)
	n = n // 26
s = ""
c = ["", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
for i in range(len(l)):
	if l[i] == 0:
		if i != len(l)-1:	
			for j in range(i+1, len(l)):
				if l[j] != 0:
					for k in range(i+1, j):
						l[k] = 25
					l[j] -= 1
					s = "z" + s
					break
	else:
		s = c[l[i]] + s
print(s)


Measured memory_bytes: 9228
import sys
from heapq import heappush as hp, heappop as hpp
N, M = map(int, input().split())
W = [[] for _ in range(M+1)]
for _ in range(N):
    a, b = map(int, sys.stdin.readline().split())
    if a > M:
        continue
    W[a].append(b)

Q = []
ans = 0
for j in range(M+1):
    for b in W[j]:
       hp(Q, -b)
    if Q:
        ans -= hpp(Q)

print(ans)

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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

int main()
{
    map<string, int> m;
    string s,t; cin >> s >> t;
    int a, b; cin >> a >> b;
    m[s] += a;
    m[t] += b;
    string u; cin >> u;
    m[u]--;
    cout << m[s] << " " << m[t] << endl;
}

Measured memory_bytes: 3592
//author rhythmicankur
                                                                  //god_is_almighty
#pragma GCC optimize("O3")
#pragma GCC target ("sse4")
#include<bits/stdc++.h>
#define f 		first
#define s 		second
#define int     long long
#define ll      int
#define ld 		long double
#define pb 		push_back
#define eb 		emplace_back
#define mk 		make_pair
#define vi 		vector<int>
#define pii 		pair<int,int>
#define pip             pair<int,pii>
#define vpi 		vector<pii>
#define sbcount(x) __builtin_popcountll(x)
#define REP(i,n) for (int i = 1; i <= n; i++)
#define trav(a, x)      for(auto& a : x)
#define all(x)          x.begin(), x.end()
#define fill(a,val)	memset(a,val,sizeof(a))
#define 	PI acos(-1)
#define coud(a,b) cout<<fixed << setprecision((b)) << (a)
#define M1 	998244353
#define M2 	1000000007
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;

template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); } 
#define test4(x,y,z,a) 		    cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<"  |  "<<#a<<": "<<a<<endl;
#define test1(x)                cerr<<#x<<": "<<x<<endl
#define test2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define test3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
ll power(ll a,ll b,ll m=M2){ll answer=1;while(b){if(b&1)answer=(answer*a)%m;b/=2;a=(a*a)%m;}return answer;}
using namespace std;
void ctrl(){cout<<"Control"<<endl;}
int make_num(string p){stringstream geek(p); int x = 0; geek >> x;return x;}
string make_str(int x){ostringstream str1; str1 << x; string geek = str1.str(); return geek;}
const int N=1e5+5;
int dp[N][2];
vi v[N];
void dfs(int x,int par)
{
    dp[x][0]=dp[x][1]=1;
    int val=1,val2=1;
    for(auto it:v[x])
    {
        
        if(it!=par)
        {
            dfs(it,x);
            val = (val*dp[it][0])%M2;
            val2 = (val2*(dp[it][0] + dp[it][1]))%M2;
        }
    }
    dp[x][0] = val2;
    dp[x][1] = val;
} 
signed main()
{	ios::sync_with_stdio(0);
	cin.tie(0); 
	cin.exceptions(cin.failbit);
	int n;
    cin>>n;
    for(int i=0;i<n-1;i++)
    {
        int x,y;
        cin>>x>>y;
        x--,y--;
        v[x].pb(y);
        v[y].pb(x);
    }
    dfs(0,0);
    cout<<(dp[0][1]+dp[0][0])%M2;

return 0;
}

Measured memory_bytes: 18928
import collections

n,k=map(int,input().split())
arr=list(map(int,input().split()))
pos=[[] for _ in range(max(arr)+1)]
for i in range(2*n):
  pos[arr[i%n]].append(i)
edge=[[] for _ in range(n)]
cnt=collections.defaultdict(int)
for i in range(n):
  s=pos[arr[i]][cnt[arr[i]]]
  g=pos[arr[i]][cnt[arr[i]]+1]
  edge[s].append((g+1)%n)
  edge[s].append((g+1)//n)
  cnt[arr[i]]+=1
start=0
loop=0
for _ in range(n):
  loop+=edge[start][1]
  start=edge[start][0]
  if start==0:
    break
k%=loop
if k==0:
  print('')
else:
  k-=1
  start=0
  loop=0
  for _ in range(n):
    if loop==k:
      break
    loop+=edge[start][1]
    start=edge[start][0]
  s=set()
  q=collections.deque()
  for i in range(start,n):
    if arr[i] not in s:
      s.add(arr[i])
      q.append(arr[i])
    else:
      while 1:
        tmp=q.pop()
        s.discard(tmp)
        if tmp==arr[i]:
          break
  print(*list(q))

Measured memory_bytes: 103140
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
const int maxn=1050;
ll dp[maxn][maxn];
ll Pow(ll x,ll n){
	ll ans=1,base=x%MOD;
	while(n){
		if(n&1) ans=ans*base%MOD;
		base=base*base%MOD;
		n>>=1;
	}
	return ans;
}
ll fact[maxn],inv[maxn];
void init(){
	fact[0]=1;
	for(int i = 1; i < maxn; ++i) fact[i]=fact[i-1]*i%MOD;
	inv[maxn-1]=Pow(fact[maxn-1],MOD-2);
	for(int i = maxn-2; i >= 0; --i) inv[i]=inv[i+1]*(i+1)%MOD;
}
int main(){
	init();
	int n,A,B,C,D;
	scanf("%d%d%d%d%d", &n,&A,&B,&C,&D);
	for(int i = 0; i <= B; ++i) dp[0][i]=1;
	for(int i = 1; i <= n; ++i){
		for(int j = A; j <= B; ++j){
			if(i==0) dp[i][j]=1;
			else{
				ll &u=dp[i][j];
				u=dp[i][j-1];
				for(int k = C; k <= D&&i-j*k>=0; ++k){
					u+=dp[i-j*k][j-1]*fact[n-i+j*k]%MOD*inv[j*k]%MOD*inv[n-i]%MOD*fact[j*k]%MOD*inv[k]%MOD*Pow(inv[j],k)%MOD;
					u%=MOD;
				}
			}
		}
	}
	cout << dp[n][B] << endl;
	return 0;
}


Measured memory_bytes: 8448
#include <bits/stdc++.h>
#include <ext/hash_map>
#include <ext/numeric>

using namespace std;
using namespace __gnu_cxx;

#define REP(i,n) for( (i)=0 ; (i)<(n) ; (i)++ )
#define rep(i,x,n) for( (i)=(x) ; (i)<(n) ; (i)++ )
#define REV(i,n) for( (i)=(n) ; (i)>=0 ; (i)-- )
#define FORIT(it,x) for( (it)=(x).begin() ; (it)!=(x).end() ; (it)++ )
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define rforeach(it,c) for(__typeof((c).rbegin()) it=(c).rbegin();it!=(c).rend();++it)
#define foreach2d(i, j, v) foreach(i,v) foreach(j,*i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define SZ(x) ((int)(x).size())
#define MMS(x,n) memset(x,n,sizeof(x))
#define mms(x,n,s) memset(x,n,sizeof(x)*s)
#define pb push_back
#define mp make_pair
#define NX next_permutation
#define UN(x) sort(all(x)),x.erase(unique(all(x)),x.end())
#define CV(x,n) count(all(x),(n))
#define FIND(x,n) find(all(x),(n))-(x).begin()
#define ACC(x) accumulate(all(x),0)
#define PPC(x) __builtin_popcountll(x)
#define LZ(x) __builtin_clz(x)
#define TZ(x) __builtin_ctz(x)
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define low(x,i) lower_bound(all(x),i)
#define upp(x,i) upper_bound(all(x),i)
#define NXPOW2(x) (1ll << ((int)log2(x)+1))
#define PR(x) cout << #x << " = " << (x) << endl ;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pii;

const int OO = (int) 2e9;
const double eps = 1e-9;

const int N = 100005;

int n;
int a[N], d[N];
ll sum, tot;

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
//	freopen("in.txt", "rt", stdin);
//	freopen("out.txt", "wt", stdout);
#endif
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];
	}
	tot = n * (n + 1LL) / 2;
	if (sum % tot) {
		puts("NO");
		return 0;
	}
	ll steps = sum / tot;
	ll s = 0;
	for (int i = 0; i < n - 1; i++) {
		d[i] = (a[i + 1] - a[i]);
		if ((steps - d[i]) < 0 || (steps - d[i]) % n) {
			puts("NO");
			return 0;
		}
		s += (steps - d[i]) / n;
	}
	puts("YES");
	return 0;
}


Measured memory_bytes: 1024
import sys
import numpy as np

readline = sys.stdin.readline 

N = int(input())
A = np.array(readline().split(), np.int64)
A_sort = np.sort(A)[::-1] # 降順ソート

count = 0
limit = 1
t = 0
for i in range(N - 1):
    if i == 0:
        count += A_sort[0]
    else:
        count += A_sort[limit]
        t += 1
        if t % 2 == 0:
            limit += 1
        

print(count)

Measured memory_bytes: 52644
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S,T;
  cin >> S >> T;
  int delta = 0;
  for(int i=0;i<S.size();i++){
    if(S[i]!=T[i]){
      delta++;
    }
  }
  cout << delta << endl;
}

Measured memory_bytes: 3848
from operator import itemgetter
N = int(input())

T = list()
for i in range(N):
    S, P = map(str, input().split())
    T.append((S, int(P), str(i+1)))

T = sorted(T, key=itemgetter(1), reverse=True)
T = sorted(T, key=itemgetter(0))
for t in T:
    print(t[2])


Measured memory_bytes: 9128
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <sstream>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <iterator>
#include <functional>
#include <bitset>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
clock_t __my_start_clock = clock();
#else
#define eprintf(...)
#endif

#define TIMESTAMP(x) eprintf("["#x"] Time : %.3lf s.\n", (clock() - __my_start_clock)*1.0/CLOCKS_PER_SEC)
#define TIMESTAMPf(x,...) eprintf("[" x "] Time : %.3lf s.\n", __VA_ARGS__, (clock() - __my_start_clock)*1.0/CLOCKS_PER_SEC)

#define db(x) cerr << #x << " = " << x << endl
#define db2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";
#define db3(x, y, z) cerr << "(" << #x << ", " << #y << ", " << #z << ") = (" << x << ", " << y << ", " << z << ")\n"
#define dbv(a) cerr << #a << " = "; for (auto xxxx: a) cerr << xxxx << " "; cerr << endl


using namespace std;

#ifdef LOCAL
static struct __timestamper {
    string what;
    __timestamper(const char* what) : what(what){};
    __timestamper(const string& what) : what(what){};
    ~__timestamper(){
        TIMESTAMPf("%s", what.data());
    }
} __TIMESTAMPER("end");
#else
struct __timestamper {};
#endif

typedef long long ll;
typedef long double ld;

int main() {
#ifdef LOCAL
    freopen("in", "r", stdin);
#endif

    int n, m;
    while (cin >> n >> m) {
        vector<string> a(n);
        for (int i =0 ; i < n; i++) cin >> a[i];


        const int INF = 1e9;
        vector<vector<int>> dp(n, vector<int>(m, INF));
        dp[0][0] = a[0][0] == '#';
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                if (i + 1 < n) {
                    dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + (a[i + 1][j] != a[i][j]));
                }
                if (j + 1 < m) {
                    dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + (a[i][j + 1] != a[i][j]));
                }
            }
        }
        int res = dp[n - 1][m - 1];
        if (a[n - 1][m - 1] == '#') res++;

        cout << (res + 1) / 2 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef priority_queue<int> p_que;
typedef priority_queue<int, vector<int>, greater<int>()> p_que_rev;
// const int INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};


int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    int ans = 800 * n - 200 * (n / 15);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 504
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

//#include <tuple>

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

int main() {
  string s;
  cin >> s;
  int cnt = 0, max_cnt=0;

  for (char N: s) {
    if (N == 'A') {
      cnt++;
    } else if (N == 'T'){
      cnt++;
    } else if (N == 'C'){
      cnt++;
    } else if (N == 'G'){
      cnt++;
    } else {
      max_cnt = max(cnt, max_cnt);
      cnt = 0;
    }
  }
  max_cnt = max(cnt, max_cnt);

  cout << max_cnt << endl;
}


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

  int main()
  {
    int X, Y;
    cin >> X >> Y;
    if (Y % 2 == 1)
    {
      cout << "No" << endl;
    }
    else
    {
      int Y2 = Y / 2;
      if (X <= Y2 && Y2 <= 2 * X)
      {
        cout << "Yes" << endl;
      }
      else
      {
        cout << "No" << endl;
      }
    }
  }
  

Measured memory_bytes: 3632
//
//AtCoder Beginner Contest 113
//C
//https://atcoder.jp/contests/abc113/tasks/abc113_c
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>
#include <bitset>
#include <numeric>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;

const double PI = 3.14159265358979323846;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

int main()
{
    int n, m;
    cin >> n >> m;

    vector<tuple<int, int, int>> pyi;
    REP(i, m) {
        int p, y;
        cin >> p >> y;
        pyi.push_back(make_tuple(p, y, i));
    }
    sort(ALL(pyi));

    vector<string> ans(m);
    int seq=1;
    int pPrv=-1;
    REP(i, m){
        int p = get<0>(pyi[i]);
        int y = get<1>(pyi[i]);
        int ii = get<2>(pyi[i]);
        
        if (pPrv==p) seq++;
        else{
            seq=1;
            pPrv=p;
        }
        ostringstream sout;
        sout << setfill('0') << setw(6) << p;
        sout << setfill('0') << setw(6) << seq;
        ans[ii] = sout.str();
    }
    REP(i, m){
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 7728
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <string>
#include <cmath>
#define SIZE 300005

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

ll A[SIZE];
ll left[SIZE],right[SIZE];
int n;

bool check(ll X)
{
	right[n]=0;
	for(int i=0;i<n;i+=2) right[n]+=A[i];
	for(int i=n-2;i>=1;i-=2)
	{
		right[i]=right[i+2];
		right[i]-=A[i+1];
		right[i]+=A[i];
	}
	left[1]=A[0]-A[1];
	for(int i=3;i<n;i+=2)
	{
		left[i]=left[i-2];
		left[i]+=A[i-1];
		left[i]-=A[i];
	}
	ll mn=0;
	for(int i=1;i<n;i+=2)
	{
		if(mn+X<=right[i])
		{
			mn=min(mn,left[i]);
		}
	}
	return mn+X<=right[n];
}
int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%lld",&A[i]);
	ll all=0;
	for(int i=0;i<n;i++) all+=A[i];
	if(n%2==0)
	{
		ll s1=0,s2=0;
		for(int i=0;i<n;i++)
		{
			if(i%2==0) s1+=A[i];
			else s2+=A[i];
		}
		printf("%lld %lld\n",max(s1,s2),all-max(s1,s2));
	}
	else
	{
		ll low=0,up=all+1;
		while(up-low>1)
		{
			ll d=(low+up)/2;
			if(check(d)) low=d;
			else up=d;
		}
		printf("%lld %lld\n",low,all-low);
	}
	return 0;
}


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

#define SZ(x) ((int(x.size())))

typedef long long ll;
typedef long double ld;

using namespace std;

string s;
bool N, S, W, E;

int main()
{
    cin >> s;
    for (int i = 0; i < s.length(); i++)
    {
        if (s[i] == 'N')
            N = 1;
        else if (s[i] == 'S')
            S = 1;
        else if (s[i] == 'W')
            W = 1;
        else
            E = 1;
    }
    if ((E ^ W) || (N ^ S))
        cout << "No";
    else
        cout << "Yes";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	string sa = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	
	int n;
	string s;
	cin >> n >> s;

	string ans = "";
	int index;
	for (int i=0; i<s.size(); i++) {
		int index = (s[i] - 'A' + n) % sa.size();
		ans += sa[index];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<iostream>
using namespace std;

char printGrade(int m, int f, int r) {
	if (m == -1 || f == -1)return 'F';

	if (m + f >= 80)return 'A';
	if (m + f >= 65)return 'B';
	if (m + f >= 50)return 'C';
	if (m + f >= 30) {
		if (r >= 50)return 'C';
		return 'D';
	}
	return 'F';
}


int main() {
	
	int m, f, r;

	for (;;) {
		cin >> m >> f >> r;

		if (m == -1 && f == -1 && r == -1)break;

		printf("%c\n", printGrade(m, f, r));
	}

	//system("pause");
	return 0;
}


Measured memory_bytes: 3152
#include <stdio.h>
 
void call(int n) {
int i,d,flag;
//scanf("%d",&n);
for(i=1;i<=n;i++){
 if(i%3==0){
 printf(" %d",i);
}else
{
 d=1;
 flag=0;
 while(flag==0)
 {
  if((i%(10*d)-i%d)/d==3)
  {
    printf(" %d",i);
    flag=1;
  }else{
   d=d*10;
   flag=(i/d==0)?1:0;
  }
 }
}
}
}
 
int main() {
int n;
scanf("%d",&n);
call(n);
printf("\n");
return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < (long long)n; i++)
//#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Vl = vector<ll>;
using vi = vector<int>;
using Graph = vector<vi>;

ll COM(int n, int k) {
  ll res = 1;
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  for (int i = 0; i < k; i++) {
    res *= (n - i);
    res /= (i + 1);
  }
  return res;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(15); //"for float-base
  // problem"
  ll N, odd = 0, even = 0, ans = 0;
  int P;
  cin >> N >> P;
  vi A(N);
  REP(i, N) {
    cin >> A.at(i);
    if (A.at(i) % 2 == 0)
      even++;
    else
      odd++;
  }
  ll ALL = (ll)pow(2, N), allevens = (ll)pow(2, even);
  // cout << "odd = " << odd << " even = " << even << endl;

  REP(i, odd + 1) {
    if (i % 2 == 0) continue;
    ans += COM(odd, i) * allevens;
    //  cout << "i = " << i << " ans = " << ans << endl;
  }
  if (P == 1)
    cout << ans << endl;
  else
    cout << ALL - ans << endl;
}

Measured memory_bytes: 4036
H, W = map(int, input().split())
grid = []
for _ in range(H):
    line = list(map(int, input().split()))
    grid.append(line)

ans = []
last_row = []
for h in range(H):
    line = grid[h]
    for w in range(W-1):
        if line[w] % 2 == 1:
            ans.append((h+1, w+1, h+1, w+2))
            line[w+1] += 1
    last_row.append(line[-1])

for h in range(H-1):
    if last_row[h] % 2 == 1:
        ans.append((h+1, W, h+2, W))
        last_row[h+1] += 1

print(len(ans))
for line in ans:
    print(*line)


Measured memory_bytes: 73052