akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

template <class T>
using lim = numeric_limits<T>;

typedef long long ll;
typedef long double ld;

struct Coord {
	int x;
	int y;
	
	Coord(){
		x = y = 0;
	}
	
	Coord(int _x, int _y){
		x = _x;
		y = _y;
	}
};

unordered_map<int, Coord> numToPoint;
const int maxN = 300;

int computed[maxN*maxN+1];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	memset(computed, 0, sizeof computed);
	int h, w, d;
	cin >> h >> w >> d;
	
	// filling grid and unordered map
	for (int i = 0; i < h; i++){
		for (int j = 0; j < w; j++){
			int temp; cin >> temp;
			numToPoint[temp] = Coord(i,j);
		}
	}
	
	// pre-computing prefix sums
	for (int i = d+1; i <= h*w; i++){
		computed[i] = computed[i-d]+abs(numToPoint[i-d].x-numToPoint[i].x)+abs(numToPoint[i-d].y-numToPoint[i].y);
	}
	
	
	int q; cin >> q;
	
	while(q--){
		int l, r;
		cin >> l >> r;
		
		
		cout << computed[r]-computed[l] << endl;
	}
}


Measured memory_bytes: 5284
def dt(t,t1,t2):
	dt = [int(t2[i]) - int(t1[i]) for i in [0,1,3,4]]
	dt = 60*(10*dt[0] + dt[1]) + 10*dt[2] + dt[3]
	return dt if dt >= t else False
	
n,t = map(int,raw_input().split())
s = [raw_input().split() for i in range(n)]
ans = []
for i in range(1,n):
	a = dt(t,s[i-1][2],s[i][0])
	if a:
		ans.append([s[i][1], a])
print len(ans)
for i in range(len(ans)):
	print " ".join(map(str,ans[i]))

Measured memory_bytes: 4252
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>
#define lpton(i,n) for(int i=0;i<(int)n;i++)
#define lpto0(i,n) for(int i=n;i>-1;i--)
#define lpmn(i,m,n) for(i=m;i<n;i++)
#define ms(l,n,s) memset(l,n,s)
typedef struct rtree{
  int nnode;
  int nparent;
  int brn;
  int first;
  int last;
}rtree;
int dep;
void print(rtree*,int*,int);
int depth(rtree*,int);
char* type(rtree*,int);
int main(){
  int n,rn,cnt=0;
  int cn[100000];
  scanf("%d",&n);
  rtree *rt;
  rt=(rtree*)malloc(sizeof(rtree)*n);
  //cn=(int*)malloc(sizeof(int)*n);
  ms(rt,-1,n*sizeof(rtree));
  lpton(i,n){
    scanf("%d",&rn);
    scanf("%d",&(rt+rn)->brn);
    (rt+rn)->nnode=rn;
    (rt+rn)->first=cnt;
    lpton(j,(rt+rn)->brn){
      scanf("%d",&cn[cnt]);
      (rt+cn[cnt])->nparent=rn;
      cnt++;
    }
    (rt+rn)->last=cnt;
  }
  print(rt,cn,n);
  return 0;
}
void print(rtree *rt,int* cn,int n){
  int j,c;
  lpton(i,n){
    dep=0;
    printf("node %d: parent = %d, depth = %d, %s, [",(rt+i)->nnode,(rt+i)->nparent,depth(rt,i),type(rt,i));
    if((rt+i)->brn!=0)lpmn(j,(rt+i)->first,(rt+i)->last)printf("%d%s",cn[j],(j<(rt+i)->last-1)?", ":"]\n");
    else printf("]\n");
  }
}
int depth(rtree *rt,int i){
  if((rt+i)->nparent==-1)return dep;
  depth(rt,(rt+i)->nparent);
  return dep+=1;
}
char *type(rtree *rt,int i){
if((rt+i)->nparent==-1)return "root";
else if((rt+i)->brn==0)return "leaf";
else return "internal node";
}



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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define INF (1LL<<60)
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rep1(i,n) for(ll i = 1; i <= (n); i++)

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


// 最大公約数
ll gcd(ll a, ll b)
{
  if(b == 0) return a;
  return gcd(b, a % b);
}

// mod m におけるa の逆元
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

// 素因数分解
vector<pair<ll, ll>> prim;
void pf(ll n)
{
  ll s = sqrt(n);
  ll r = 0;
  for(ll i = 2; i <= s; i++) {
    if((n % i) == 0) {
      r = 0;
      do {
	r++;
	n = n / i;
      } while((n % i) == 0);
      prim.push_back({i, r});
    }
  }
  if(n > s) {
    prim.push_back({n, 1});
  }
}

void solve()
{
  ll N, M; cin >> N >> M;
  vector<ll> a(N); rep(i, N) cin >> a[i];
  vector<ll> b(M), c(M); rep(i, M) cin >> b[i] >> c[i];
  vector<pair<ll,ll>> vp;
  sort(a.begin(), a.end());
  ll cnt = 0;
  rep(i, N - 1) {
    cnt ++;
    if(a[i] != a[i + 1]) {
      vp.push_back(make_pair(a[i], cnt));
      cnt = 0;
    }
  }
  vp.push_back(make_pair(a[N-1], cnt+1));

  rep(i, M) {
    vp.push_back(make_pair(c[i], b[i]));
  }
  sort(vp.rbegin(), vp.rend());
  for(auto itr : vp) {
    cerr << itr.first << " " << itr.second << endl;
  }
  
  ll ans = 0;
  cnt = 0;
  for(auto itr : vp) {
    ll ca = min(N - cnt, itr.second);
    ans += itr.first * ca;
    cnt += ca;
  }


  cout << ans << endl;
}


int main(void)
{
  // ll t; cin >> t; rep(i, t)
  solve();
}


Measured memory_bytes: 9824
n,k = map(int,input().split())
a = [int(i) for i in input().split()]

b = [0]*n

if len(list(set(a))) <=k:
    print(0)
else:
    for i in a:
        b[i-1]+=1
    b.sort(reverse=True)
    del b[0:k]
    print(sum(b))

Measured memory_bytes: 26764
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const long long INF=200000000000000;
double pi=3.141592653589793;

const int MOD = 1000000007;

long long gcd(long long a,long long b){
	if(a<b)swap(a,b);
	if(a%b==0)return b;
	return gcd(a%b,b);
}

long long lcm(long long a,long long b){
	return a/gcd(a,b)*b;
}
long myPow(long long x, long long n, long long m=MOD){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}

ll N,M;
vector<ll>A(106);

void batten(ll i,ll k){
	if(i==N)return;
	if((A[i]%k)>(A[i+1]%k)){
		swap(A[i],A[i+1]);
		batten(i+1,k);
		return;
	}else{
		batten(i+1,k);
		return;
	}
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	ll N;
	cin>>N;
	vector<ll>A(N);
	ll sum=0;
	for(int i=0;i<N;i++){
		cin>>A[i];
		sum+=A[i];
	}
	ll nowsum=0;
	ll ans=INF;
	for(int i=0;i<N;i++){
		nowsum+=A[i];
		ll sum1=nowsum;
		ll sum2=sum-nowsum;
		ans=min(ans,abs(sum1-sum2));
	}
	cout<<ans<<endl;
}



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

using namespace std;

typedef long long ll;

int x;

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> x;
    cout << 360 / gcd(360, x) << "\n";
    return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define inlld(x) scanf("%lld", &x)
#define ind(x) scanf("%d", &x)
#define inlld2(x, y) scanf("%lld%lld", &x, &y)
#define inlld3(x, y, z) scanf("%lld%lld%lld", &x, &y, &z)
#define ind2(x, y) scanf("%d%d", &x, &y)
#define ind3(x, y, z) scanf("%d%d%d", &x, &y, &z)

const int N=1e5+5;
const int MOD=1e9+7;

typedef long long ll;
typedef long double ld;

using namespace std;

int main()
{
	ll n;
	inlld(n);
	ll ans = 0;
	for(ll a = 1; a <= n; a++)
	{
		if(a % 3 == 0 || a % 5 == 0)
			continue;
		ans += a;
	}
	printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 3824
#include <stdio.h>
int main(void){
    // Your code here!
    int n, cnt = 0;
    long int sum = 0;
    scanf("%d", &n);
    for(int i=1; i<=n; i++){
        if( i%3 == 0 || i%5 ==0 )continue;
        sum += i;
    }
    printf("%ld", sum);
}


Measured memory_bytes: 1732
L = [int(i) for i in input().split()]

S = sum(L)
S2 = S - L[0]
S1 = S2 - L[1]

if S != 17:
    print('NO')
else:
    if S2==10 and S1==5:
        print('YES')
    elif S2==12 and (S1==5 or S1==7):
        print('YES')
    else:
        print('NO')


Measured memory_bytes: 3060
#include<iostream>

using namespace std;

int main() {
	string S;
	cin >> S;
	int l = S.length();
	if (S[l-1] == 's') {
		cout << S << "es" << endl;
	}
	else {
		cout << S << "s" << endl;
	}





	return 0;
}

Measured memory_bytes: 3624
n = int(input())
apple = []
count = 0
for _ in range(n):
    apple.append(str(input()))
for i in range(1,n):
    if apple[i-1][-1] == apple[i][0] and apple[i-1] not in apple[i:]:
        pass
    else:
        count = 1
        break
if apple[-1] not in apple[:-1] and count == 0 and apple[-2][-1]==apple[-1][0]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9184
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int M = scan.nextInt();
		scan.close();
		for(int i = M / N; i > 0; i--) {
			if(M % i == 0) {
				System.out.println(i);
				System.exit(0);
			}
		}
	}
}

Measured memory_bytes: 23760
// RAKSHIT KADAM
 
//  -- Declare array globally...
 #include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree< int ,  null_type ,  less<int> ,  rb_tree_tag ,  tree_order_statistics_node_update>
// find_by_order returns iterator to  element present at that index...
// order_of_key returns no. of elements having value stricktly less than that given in the order_of_key();
#warning !!!check the size of arrayss!!!
 
// NUMERIC DEFINITIONS :
    #define INF 100000000000000005
    #define inf 1000000003
    #define MOD  1000000007
    #define newMOD  998244353
    #define MAX 200006
    #define pi 3.1415926535897932384626433832795
#define ld long doubles
 #define ll long long
 #define int long long
 
 #define P(gg) for(auto rax:gg){cout<<rax<<" ";}cout<<endl;
 #define Need_for_speed(activated) ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
 #define satisfy ll t; cin>> t; while(t--)
 #define inp(n) int n;cin >> n
 #define mp make_pair
 #define pb push_back
 #define endl "\n"
 #define x first
 #define y second
 #define fore(i,a,b) for(ll i=a;i<b;i++)
 #define forci(i,n) for(ll i=0;i<n;i++)
 #define vi vector<ll>
 #define Endl endl
 #define lb lower_bound
 #define ub upper_bound
#define pii pair<ll,ll>
 
 #define input freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout)
 #define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;
ll gcd(ll a, ll b){if (b == 0)return a;return gcd(b, a % b);}
int power(int x, unsigned int y, unsigned int m){ if (y == 0) return 1;int p = power(x, y/2, m) % m;  p = (p * p) % m;return (y%2 == 0)? p : (x * p) % m;}
ll modInverse(int a, int m){{ return power(a, m-2, m);}}
const int maxn = 200003;
void solve()
{
    ll n;cin>>n;
    cout<<(1000-n%1000)%1000<<endl;
}
signed main()
{
   Need_for_speed(activated);
 
//satisfy
//    {
//  solve();
//   }
//
    solve();
    return 0;
}


Measured memory_bytes: 3648
a, b, c, x, y = gets.chomp.split(' ').map(&:to_i)

if x < y
  a, b = b, a
  x, y = y, x
end

if a + b <= 2 * c
  puts a * x + b * y
else
  if a < c * 2
    puts c * 2 * y + a * (x - y)
  else
    puts c * 2 * x
  end
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pi M_PI
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  string s,t;
  cin >> s >> t;
  rep(k,2) {
    int x=0,f=1;
    for(int i=k; i<s.size(); i+=2,x++) {
      while(x<t.size()&&t[x]!=s[i]) x++;
      if(x>=t.size()) f=0;
    }
    if(f) {
      pr("Yes");
      return;
    }
  }
  pr("No");
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 1005

int a , b , c;

int main()
{
    _FastIO;
    cin >> a >> b >> c;
    cout << c << " " << a << " " << b << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1000000007;
const ll INF=1e9;
const ll IINF=1e18;
struct edge{ll from, to, cost;};

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

ll V,E,P;
vector<edge> es(5000);
vector<ll> d(2500,INF);
vector<bool> can(2500,false);

bool BellmanFord(int s){
    d[s]=0;
    ll count=0;
    while (true){
        bool update=true;
        rep(i,E){
            edge e=es[i];
            if (d[e.from]!=INF&&d[e.to]>d[e.from]+e.cost){
                d[e.to]=d[e.from]+e.cost;
                update=false;
                if (count==V-1&&can[e.to]){
                    return true;
                }
            }
        }
        if (update){
            return false;
        }
        count++;
        if (count==V){
            return false;
        }
    }
}

int main(){
    cin >> V >> E >> P;
    vector<vector<ll>> G(V);
    rep(i,E){
        ll A,B,C;
        cin >> A >> B >> C;
        A--,B--;
        C=P-C;
        es[i]=edge{A,B,C};
        G[B].push_back(A);
    }
    can[V-1]=true;
    queue<ll> que;
    que.push(V-1);
    while(!que.empty()){
        ll v=que.front();
        que.pop();
        for (auto nv:G[v]){
            if (can[nv]){
                continue;
            }
            can[nv]=true;
            que.push(nv);
        }
    }
    if (BellmanFord(0)){
        cout << -1 << endl;
        return 0;
    }
    cout << max((ll)0,-d[V-1]) << endl;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<limits.h>

#define rep(i,begin,end) for(int i=begin; i<end; i++)
#define revrep(i,begin,end) for(int i=begin; i>end; i--)
#define lld long long int

int cmpDsc(const void* a, const void* b){
    lld x = *(lld*)a, y = *(lld*)b;
    if(x < y){
        return 1;
    }
    if(x > y){
        return -1;
    }
    return 0;
}

int main(){
    int n, k;
    scanf("%d %d", &n, &k);
    lld ans = 0;
    lld h[n];
    rep(i, 0, n){
        scanf("%lld", &h[i]);
    }
    qsort(h, n, sizeof(lld), cmpDsc);
    rep(i, 0, n){
        if(i<k){
            continue;
        }else{
            ans += h[i];
        }
    }
    printf("%lld", ans);

    return 0;
}

Measured memory_bytes: 3324
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>

using namespace std;
typedef long long ll;
int a,b,c,x,y;
int ans;
int main(){
	scanf("%d%d%d%d%d",&a,&b,&c,&x,&y);
	if(c * 2 >= a + b){
		printf("%d\n",x * a + y * b);
		return 0;
	}else{
		ans += min(x,y) * c * 2;
		if(x < y){
			ans += (y-x) * min(b,c*2);
		}else ans += (x-y) * min(a,c*2);
	}
	printf("%d\n",ans);
	return 0;
}


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

int n;
ll X, D;
unordered_map<ll, vector<pair<ll,ll>>> mp;

int main() {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  cin>>n>>X>>D;
  if (D==0) {
    if (X!=0) cout<<n+1;
    else cout<<1;
    return 0;
  }

  for (int k=0; k<=n; ++k) {
    ll L=X*k+D*k*(k-1)/2;
    ll R=X*k+D*k*(2*n-k-1)/2;
    if (R<L) swap(L,R);
    ll du=L%abs(D);
    if (du<0) du+=abs(D);
    mp[du].emplace_back(L, R);
  }

  D=abs(D);
  ll ans=0;
  for (auto p: mp) {
    auto &v=p.second;
    vector<pair<ll,ll>> q;

    sort(v.begin(), v.end());
    for (auto &x: v) {
      ll tmp=(x.first-v[0].first)/D;
      q.emplace_back(tmp, tmp+(x.second-x.first)/D);
    }
    sort(q.begin(), q.end());

    ll last=LLONG_MIN;
    for (auto &x: q) {
      if (x.second<=last) continue;
      ans+=x.second-max(last, x.first);
      if (x.first>last) ++ans;
      last=max(last, x.second);
    }
  }
  cout<<ans;
  return 0;
}

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

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

  int m, p, x;
  cin >> m;
  for (int i = 0; i < m; i++) {
    cin >> p >> x;
    cout << s - t[p - 1] + x << endl;
  }
}

Measured memory_bytes: 256
import math
a=[int(i) for i in input().split()]
ans=0
for i in range(1,a[0]+1):
  if i>=a[1]:
    ans+=1/a[0]
  else:
    n=0
    while  i*2**n<a[1]:
      n+=1
    ans+=(1/a[0])*1/2**n
print(ans)

Measured memory_bytes: 3060
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<60)
#define MOD1 1000000007
#define MOD2 998244353
#define MAX_N (1 << 17)
#define YES printf("Yes\n")
#define NO printf("No\n")
#define PN printf("\n")

void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll min3(ll a, ll b, ll c){return (a<=b && a<=c) ? a : b<=c ? b : c;}
ll max3(ll a, ll b, ll c){return (a>=b && a>=c) ? a : b>=c ? b : c;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll mod(ll n){return n%=MOD1;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{ ll a , b;}fr;
int cmp1( const void *p, const void *q ) { return ((fr*)p) ->a - ((fr*)q)->a;}
int cmp2( const void *p, const void *q ) { return ((fr*)q) ->a - ((fr*)p)->a;}
void strsortup(fr*a,int n){qsort(a,n,sizeof(fr),cmp1);}
void strsortdown(fr*a,int n){qsort(a,n,sizeof(fr),cmp2);}

ll inv[200005],finv[200005];
void makeinv(ll n){
    inv[1]=1;finv[0]=finv[1]=1;
    rep(i,2,n+1){
        inv[i]=MOD1 - inv[MOD1%i] * (MOD1 / i) % MOD1;
        finv[i] = finv[i - 1] * inv[i] % MOD1;
    }
}
ll modfac(ll n, ll mod){
    ll x=1;
    rep(i,2,n+1){x*=i%mod;x%=mod;}
    return x;
}

int main(void){
    // char ;
    ll n,k,ans=0;
    scanf("%lld%lld",&n,&k);
    ll a[n];
    rep(i,0,n){
        scanf("%lld",&a[i]);
    }
    sortup(a,n);
    makeinv(POW(10,5));
    ll pro=1;
    rep(i,0,n-k+1){
        ans+=( a[k-1+i] - a[n-k-i] )*pro;
        // ans-=a[n-k-i]*pro;
        // ans%=MOD1;
        // ans+=a[k-1+i]*pro;
        if(ans<0){
            ans-= (ABS(ans)/MOD1+1) *MOD1;
        }
        ans%=MOD1;
        pro=pro*(k+i)%MOD1*inv[i+1]%MOD1;
        // printf("%lld %lld   %lld\n",a[n-k-i],a[k-1+i],pro);
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 2544
#include<stdio.h>
int main(void)
{
	int a = 0, b = 0, c = 0, d = 0, f = 0;
	scanf("%d%d", &a, &b);
	c = b * 2;
	d = a - c;
	if (d>=1)
	{
		printf("%d\n", d);
	}
	else
	{
		printf("0");
	}
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
#include<functional>
#include<cstdlib>
#include<queue>
#include<deque>
const double PI = acos(-1);
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
using ll =long long;
const int mod = 1000000007;

//map<string>a
class mint {
	long long x;
public:
	mint(long long 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;
	}

	friend ostream& operator<<(ostream & os, const mint & m) {
		os << m.x;
		return os;
	}
};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
//組み合わせ
void recursive_comb(vector<int> indexes, int s, int rest, std::function<void(vector<int>)> f) {
	if (rest == 0) {
		f(indexes);
	}
	else {
		if (s < 0) return;
		recursive_comb(indexes, s - 1, rest, f);
		indexes[rest - 1] = s;
		recursive_comb(indexes, s - 1, rest - 1, f);
	}
}

// nCkの組み合わせに対して処理を実行する
void foreach_comb(int n, int k, std::function<void(vector<int>)> f) {
	vector<int>indexes(k);
	recursive_comb(indexes, n - 1, k, f);
}

ll gcd(ll a, ll b) {
	if (a % b == 0) {
		return b;
	}
	else {
		return gcd(b, a % b);
	}
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
};
//fixed << setprecision(2)


int main() {
	int N, D;
	cin >> N >> D;
	int ans = 1;
	N -= D * 2+1;
	while (N > 0) {
		N -= D * 2 + 1;
		ans++;
	}
	cout << ans;
}
	



Measured memory_bytes: 3600
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text.RegularExpressions;

public static partial class Program
{
    //テンプレここから
    public static int ToInt(this string str) => int.Parse(str);
    public static long ToLong(this string str) => long.Parse(str);
    public static int[] ToInt(this string[] strs) => strs.Select(x => x.ToInt()).ToArray();
    public static long[] ToLong(this string[] strs) => strs.Select(x => x.ToLong()).ToArray();
    public static int[] SpInts(this string str, char opr = ' ') => str.Split(opr).ToInt();
    public static long[] SpLongs(this string str, char opr = ' ') => str.Split(opr).ToLong();
    public static string CRL() => Console.ReadLine();
    public static void CWL(object obj) => Console.WriteLine(obj);
    public static int Diff(int a, int b) => (int)Diff(a, (long)b);
    public static long Diff(long a, long b) => Math.Abs(Math.Max(a, b) - Math.Min(a, b));
    public static int Sign(this int i) => Math.Sign(i);
    public static bool IsEven(this int i) => i % 2 == 0;
    public static int[] dx = new int[] { 0, -1, 0, 1 };
    public static int[] dy = new int[] { -1, 0, 1, 0 };
    public static int Gcd(int a, int b) => (int)Gcd(a, (long)b);
    public static long Gcd(long a, long b)
    {
        if (b == 0)
        {
            return a;
        }

        return Gcd(b, a % b);
    }                       //最大公約数
    public static int Lcm(int a, int b) => (int)Lcm(a, (long)b);
    public static long Lcm(long a, long b) => a / Gcd(a, b) * b;    //最小公倍数
    //テンプレここまで
}

public static partial class Program
{
    public static void Main()
    {
        var nq = CRL().SpInts();
        var n = nq[0];
        var q = nq[1];
        var s = CRL();
        var memo = new int[n];
        for (int i = 1; i < n; i++)
        {
            memo[i] = memo[i - 1];
            if (s[i - 1] == 'A' && s[i] == 'C')
            {
                memo[i]++;
            }
        }

        for (int i = 0; i < q; i++)
        {
            var lr = CRL().SpInts();
            var l = lr[0];
            var r = lr[1];
            CWL(memo[r - 1] - memo[l - 1]);
        }
    }
}


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

using namespace std;

inline int ctoi(char c) { if(c < '0' || '9' < c) throw invalid_argument("ctoi error"); return c - '0'; }
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for(int i = (int)(k); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

template <typename T>
inline T gcd(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("gcd error: x <= 0 or y <= 0");
	
	if(x < y) swap(x, y);
	T r = x % y;

	while(r != 0){
		x = y;
		y = r;
		r = x % y;
	}

	return y;
}
template <typename T>
inline T lcm(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("lcm error: x <= 0 or y <= 0");

	return x * y / gcd(x, y);
}

int main(){
	long long int a;
	string s;
	cin >> a >> s;

	int b = 0;
	b += ctoi(s[0]) * 100 + ctoi(s[2]) * 10 + ctoi(s[3]);

	cout << a * b / 100;

	return 0;
}

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

int main() {
  int H, W;
  vector<string> vec;
  string str,
  	 	 cache,
  		 hash;
  
  cin >> H >> W;
  vec = vector<string>(H);
  
  for (int i = 0; i < H; i++) {
    cin >> vec.at(i);
  }
  //cout << vec.at(0) << vec.at(1);
  
  for (int i = 0; i < H+2; i++) {
    hash = "";
    if (i == 0 || i == H+1) {
      for (int j = 0; j < W+2; j++) {
        hash += '#';
      }
      cout << hash << endl;
      continue;
    }
    cout << '#';
    if (i <= H) {
      cout << vec.at(i-1);
    }
    cout << '#' << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
const double PI = acos(-1);
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
    return a < b && (a = b, true);
}
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
    return a > b && (a = b, true);
}
/*-------------------------------------------*/

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

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

    int mn = 100000;
    for(int i = 0; i + t.size() <= s.size(); i++) {
        int cnt = 0;
        rep(j, t.size()) if(s[i + j] != t[j]) cnt++;
        chmin(mn, cnt);
    }

    cout << mn << endl;

    return 0;
}

Measured memory_bytes: 3656
#include <stdio.h>
int main()
{
    int m,b;
    scanf("%d %d", &m, &b);

    if(m==b)
    {
        printf("Draw");
    }
    else if(m==1)
    {
        printf("Alice");
    }
    else if(b==1)
    {
        printf("Bob");
    }
    else if(m>b)
    {
        printf("Alice");
    }
    else{
        printf("Bob");
    }
    return 0;
}

Measured memory_bytes: 1708
input()
w=list(map(int,input().split()))
x=min(w)
m={k:v for k,v in zip(sorted(w),w)if k!=v}
l=list(m.keys())
n=0
while l:
 a=l.pop();b=m[a];l.remove(b)
 if a==m[b]:n+=a+b
 else:
  t=[b]
  while 1:
   c=m[b];t+=[c]
   if c==a:p,q=len(t),min(t);n+=sum(t)+min((p-2)*q,q+(p+1)*x);break
   else:b=c;l.remove(c)
print(n)


Measured memory_bytes: 5720
#include <algorithm>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
using std::cin;
using std::cout;
using std::endl;

namespace UF {

const int MAX_N = 100000;
int parent[MAX_N];
int rank[MAX_N];

void initialize(int n) {
    for (int i = 0; i < n; i++) {
        parent[i] = i;
        rank[i]   = 0;
    }
}

int find(int x) {
    if (parent[x] == x) {
        return x;
    } else {
        return parent[x] = find(parent[x]);
    }
}

void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y)
        return;

    if (rank[x] < rank[y]) {
        parent[x] = y;
    } else {
        parent[y] = x;
    }
    if (rank[x] == rank[y])
        rank[x]++;
}

bool is_same(int x, int y) {
    return find(x) == find(y);
}

} // namespace UF

// verify code

int main(void) {
    int n, q;
    cin >> n >> q;
    UF::initialize(n);
    for (int i = 0; i < q; i++) {
        int c, x, y;
        cin >> c >> x >> y;
        if (c == 0) {
            UF::unite(x, y);
        } else {
            cout << UF::is_same(x, y) << endl;
        }
    }
    return 0;
}



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

int main() {
  int N, M;
  cin >> N >> M;

  vector<int> X(M);
  rep(i,0,M-1) cin >> X[i];
  sort(X.begin(), X.end());

  vector<int> dist(M);
  dist[0] = 0;
  rep(i,1,M-1) dist[i] = abs(X[i] - X[i-1]);
  sort(dist.begin(), dist.end());

  int ans = 0;
  rep(i,0,M-N) ans += dist[i];
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		while ((line = br.readLine()) != null && !line.isEmpty()) {
			int n, m;
			n = Integer.parseInt(line);
			if (n == 0) {
				break;
			}
			m = Integer.parseInt(br.readLine());

			//問題文解析
			line = br.readLine();
			ArrayDeque<Integer> count = new ArrayDeque<Integer>();
			count.add(0);
			int j = -1;
			for (int i = 1; i < m - 1; i++) {
				if (line.charAt(i) == 'O') {
					if ((line.charAt(i - 1) | line.charAt(i + 1)) == 'I') {
						if (i - j == 2) {
							count.offer(count.pollLast() + 1);
						} else {
							count.offer(1);
						}
						j = i;
					}
				}
			}
			//集計
			int sum = 0;
			for (int c : count) {
				if (c >= n) {
					sum += c - n + 1;
				}
			}
			System.out.println(sum);
		}
	}
}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)

using namespace std;

const int MOD = 1000000007;

string A,B,C;
int dp[100][2];

int main() {
  while( cin >> A, A != "0" ) {
    cin >> B >> C;
    reverse(A.begin(),A.end());
    reverse(B.begin(),B.end());
    reverse(C.begin(),C.end());
    memset(dp,0,sizeof dp);
    dp[0][0] = 1;
    int n = (int)A.size();
    rep(i,n) {
      rep(carry,2) {
        rep(c,10) {
          if( C[i] != '?' && c != (C[i]-'0') ) continue;
          if( i == n-1 && c == 0 ) continue;
          rep(a,10) {
            if( A[i] != '?' && a != (A[i]-'0') ) continue;
            if( i == n-1 && a == 0 ) continue;
            rep(b,10) {
              if( B[i] != '?' && b != (B[i]-'0') ) continue;
              if( i == n-1 && b == 0 ) continue;
              if( ( a + b + carry ) % 10 != c ) continue;
              int next_carry = ( a + b + carry >= 10 );
              ( dp[i+1][next_carry] += dp[i][carry] ) %= MOD;
            }
          }
        }
      }
    }
    cout << dp[n][0] << endl;
  }
  return 0;
}

Measured memory_bytes: 1188
#include<iostream>
#include<vector>
using namespace std;
const int N=1e5+2;
bool used[N];
pair<int,int> edge_lis[N];
int deg[N],level[N];
vector<pair<int,int> > adj[N];
void dfs(int x,int idx){
	for(int i=0;i<adj[x].size();i++){
		if(!used[adj[x][i].first]){
			used[adj[x][i].first]=true;
			level[adj[x][i].first]=level[x]+1;
			dfs(adj[x][i].first,adj[x][i].second);
		}
		else{
			if(level[adj[x][i].first]<level[x]-1){
				if(edge_lis[adj[x][i].second].first!=x){
					swap(edge_lis[adj[x][i].second].first,edge_lis[adj[x][i].second].second);
				}
				deg[x]++;
			}
		}
	}
	//cout<<x<<" "<<deg[x]<<endl;
	if(deg[x]&1){
		if(edge_lis[idx].first!=x){
			swap(edge_lis[idx].first,edge_lis[idx].second);
		}
		deg[x]++;
	}
	else{
		if(edge_lis[idx].first==x){
			swap(edge_lis[idx].first,edge_lis[idx].second);
		}
		deg[edge_lis[idx].first]++;
	}
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,m,i,j,k,l;
	cin>>n>>m;
	if(m&1){
		cout<<-1;
		return 0;
	}
	for(i=1;i<=m;i++){
		cin>>j>>k;
		edge_lis[i].first=j;
		edge_lis[i].second=k;
		adj[j].push_back({k,i});
		adj[k].push_back({j,i});
	}
	used[1]=true;
	dfs(1,0);
	for(i=1;i<=m;i++){
		cout<<edge_lis[i].first<<' '<<edge_lis[i].second<<'\n';
	}
}

Measured memory_bytes: 14720
#include <bits/stdc++.h>
using namespace std;
using pp=pair<int,int>;
using ll=long long;

int main() {
  string S;
  cin >> S;
    if (S[S.size()-1]=='s') {
      cout << S << "es" << endl;
    }
  else {
    cout << S << "s" << endl;
  }
}

Measured memory_bytes: 3628
#include <iostream>
#include <bits/stdc++.h> 
using namespace std;
int main() {
    int n;
    cin>>n;
    int h[n];
    for(int i=0;i<n;++i) cin>>h[i];
    int a[n];
    a[0] = 0;
    a[1] = abs(h[1]-h[0]);
    for(int i=2;i<n;++i) a[i] = min(abs(h[i-2]-h[i])+a[i-2],abs(h[i-1]-h[i])+a[i-1]);
    cout<<a[n-1];
}


Measured memory_bytes: 1024
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, double> pid;
typedef pair<double, int> pdi;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;

const double EPS = 1e-9;

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

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

	if (A + B - 1 > N || A * B < N)
	{
		cout << -1 << endl;
		return 0;
	}

	vector<int> ANS(N);

	int P = 0;
	int num = 1;
	rep(i, 0, A)
	{
		int td = min(B, N - P - (A - i) + 1);
		rrep(j, 0, td)
		{
			ANS[P + j] = num++;
		}
		P += td;
	}

	for (auto v : ANS)
	{
		cout << v << " ";
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 5520
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200000






int main() {
	vector<long long>a;
	vector<long long>b;
	vector<long long>c;
	long long l = -1;
	long long r = 1000000000000000;
	long long k, m;
	int n;
	long long x, y, z;
	long long s, ans;
	bool v = true;
	ans = 0;
	scanf("%d %lld", &n,&k);
	f(i, n) {
		scanf("%lld", &x);
		b.push_back(x);
	}
	f(i, n) {
		scanf("%lld", &x);
		a.push_back(x);
	}
	sort(a.begin(), a.end(), greater<long long>());
	sort(b.begin(), b.end());
	while (l + 1 < r) {
		m = (l + r) / 2;
		c.clear();
		f(i, n) {
			x = m / a[i];
			c.push_back(x);
		}
		sort(c.begin(), c.end());
		s = 0;
		f(i, n) {
			s += max((long long)0, b[i] - c[i]);
		}
		if (s <= k)r = m;
		else l = m;
	}
	printf("%lld\n", r);


	return 0;
}

Measured memory_bytes: 7152
#include<iostream>
using namespace std;
int n, i, ok, x, p, sol;
int main(){
    cin>> n >> p;
    for(i = 1; i <= n; i++){
        cin>> x;
        ok |= x % 2;
    }
    if(p == 1 && ok == 0){
        cout<< 0;
        return 0;
    }
    n -= ok;
    cout<< (1LL << n);
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;

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

void solve(){
	int n;
    cin>>n;
    int sum=0;
    vector<int>v;
    for(int i=1;;++i){
        sum+=i;
        v.pb(i);
        if(sum>=n)break;
    }
    if(sum==n){
        for(int x:v)cout<<x<<"\n";
    }
    else {
        for(int x:v){
            if(x==sum-n)continue;
            cout<<x<<"\n";
        }
    }
    return;
}

signed main(){
	std::ios::sync_with_stdio(false);
    std::cin.tie(0);
	solve();
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main() {
	int N,M,W=1;
  long ans=0;
  cin >> N >> M;
  vector<pair<long,long>> A(N);
  for (int i=0;i<N;i++){
    cin >> A.at(i).first >> A.at(i).second;
  }
  sort(A.begin(), A.end());
  while (true) {
  for (int i=0;true;i++){
    for (int I=0;I<A.at(i).second;I++){
      ans=ans+A.at(i).first;
      W=W+1;
      if (W>M) break;
    }
     if (W>M) break;
  }
   if (W>M) break;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i=(a);i<(int)(n);i++)
using namespace std;
typedef long long ll;
struct start { start() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(10);
}; }start;
void in() {}
template <class Head , class... Tail>
void in(Head&& head, Tail&&... tail) {
  cin >> head;
  in(move(tail)...);
}
template <class T>
  void out(T& t) {
  cout << t << '\n';
}
template <class Head , class... Tail>
void out(Head& head , Tail&... tail) {
  cout << head << ' ';
  out(move(tail)...);
}
int main(void) {
  string s;
  int ans=0;
  in(s);
  rep(i,0,3){
    if(s[i]=='a'){
      ans++;
      break;
    }
  }
  rep(i,0,3){
    if(s[i]=='b'){
      ans++;
      break;
    }
  }
  rep(i,0,3){
    if(s[i]=='c'){
      ans++;
      break;
    }
  }
  if(ans==3)out("Yes");
  else out("No");
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define D(x) cerr<<#x<<'='<<x<<'\n';
using namespace std;
typedef long long ll;
const ll P=1000000007;
ll ksm(ll x,ll y)
{
	ll ret=1;
	while (y)
	{
		if (y&1)
			ret=ret*x%P;
		x=x*x%P;
		y>>=1;
	}
	return ret;
}
ll C(ll x,ll y)
{
	ll ret=1;
	for (ll i=x;i>=x-y+1;i--)
		ret=ret*i%P;
	for (ll i=1;i<=y;i++)
		ret=ret*ksm(i,P-2)%P;
	return ret;
}
int main()
{
	ll n,a,b;
	scanf("%lld%lld%lld",&n,&a,&b);
	ll ans=(ksm(2,n)-1-C(n,a)-C(n,b)+3*P)%P;
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma comment(linker, "/stack:200000000")
using namespace std;
#define F first
#define S second
#define EB emplace_back
#define MP make_pair
#define all(o) (o).begin(), (o).end()
#define mset(m,v) memset(m,v,sizeof(m))
#define fr(i,n) for(lli i=0;i<(n);++i)
#define rep(i,a,b) for(lli i=a;i<=b;++i)
#define per(i,a,b) for(lli i=a;i>=b;i--)
#define remin(a,b) (a=min((a),(b)))
#define remax(a,b) (a=max((a),(b))) 
#define sz(x) (lli)(x).size()
#define endl '\n'
typedef long long lli;        typedef long double ld;
typedef pair<lli,lli> ii;     typedef vector<lli> vi;
typedef vector<ii> vii;       typedef vector<vi> graph;
long long MOD=1000000007;     long double EPS=1e-9;
#ifndef ONLINE_JUDGE
#define debarr(a,n)cerr<<#a<<":";for(lli i=0;i<n;i++)cerr<<a[i]<<" ";cerr<<endl;
#define debmat(mat,row,col)cerr<<#mat<<":\n";for(lli i=0;i<row;i++){for(lli j=0;j<col;j++)cerr<<mat[i][j]<<" ";cerr<<endl;}
#define pr(...)dbs(#__VA_ARGS__,__VA_ARGS__)
template<class S,class T>ostream &operator<<(ostream &os,const pair<S,T> &p){return os<<"("<<p.first<<","<<p.second<<")";}
template<class T>ostream &operator<<(ostream &os,const vector<T> &p){os<<"[";for(auto&it:p)os<<it<<" ";return os<<"]";}
template<class T>ostream &operator<<(ostream &os,const set<T>&p){os<<"[";for(auto&it:p)os<<it<<" ";return os<<"]";}
template<class T>ostream &operator<<(ostream &os,const multiset<T>&p){os<<"[";for(auto&it:p)os<<it<<" ";return os<<"]";}
template<class S,class T>ostream &operator<<(ostream &os,const map<S,T>&p){os<<"[";for(auto&it:p)os<<it<<" ";return os<<"]";}
template<class T>void dbs(string str,T t){cerr<<str<<":"<<t<<"\n";}
template<class T,class...S>void dbs(string str,T t,S... s){lli idx=str.find(',');cerr<<str.substr(0,idx)<<":"<<t<<",";dbs(str.substr(idx+1),s...);}
#else
#define pr(...){}
#define debarr(a,n){}
#define debmat(mat,row,col){}
#endif
lli binpow(lli b,lli p,lli mod){lli ans=1;b%=mod;for(;p;p>>=1){if(p&1)ans=ans*b%mod;b=b*b%mod;}return ans;}

void pre(){

}

void solve(){
    map<lli,lli> done;
    map<lli,lli> buffer;
    lli WA=0;
    lli correct=0;
    lli n,m;cin>>n>>m;
    fr(i,m){
        lli a;string b;
        cin>>a>>b;
        if(!done[a]){
            if(b=="AC"){
                correct++;
                WA+=buffer[a];
                done[a]=1;
            }else{
                buffer[a]++;
            }
        }
    }
    cout<<correct<<" "<<WA<<endl;
}

signed main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    //cout<<fixed<<setprecision(15);
    //clock_t begin = clock();
    pre();lli _t=1;//cin>>_t;
    for(lli i=1;i<=_t;i++){
        //cout<<"Case #"<<i<<": ";
        solve();
    }
    // clock_t end = clock();double elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;cerr << elapsed_secs;
}

Measured memory_bytes: 12800
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<vector>
using namespace std;
int main() {
	int i,j,k,l,m,n,o,x,y,z;
	int max = 0;
	int count = 0;
	vector< vector<int> > s;
	s.resize(14);
	for (i = 0; i < 14; i++) {
		s[i].resize(14);
	}
	for (j = 0; j < 14; j++) {
		for (k = 0; k < 14; k++) {
			s[j][k] = 0;
		}
	}
	while (scanf("%d,%d,%d", &x, &y, &z)!=EOF) {
		if (z == 1) {
			s[x + 2][y + 2] += 1;
			s[x + 1][y + 2] += 1;
			s[x + 3][y + 2] += 1;
			s[x + 2][y + 1] += 1;
			s[x + 2][y + 3] += 1;
		}
		else if (z == 2) {
			for (l = x + 1; l <= x + 3; l++) {
				for (m = y + 1; m <= y + 3; m++) {
					s[l][m] += 1;
				}
			}
		}
		else if (z == 3) {
			for (l = x + 1; l <= x + 3; l++) {
				for (m = y + 1; m <= y + 3; m++) {
					s[l][m] += 1;
				}
			}
			s[x][y + 2] += 1;
			s[x + 4][y + 2] += 1;
			s[x + 2][y] += 1;
			s[x + 2][y + 4] += 1;
		}
	}
	for (n = 2; n < 12; n++) {
		for (o = 2; o < 12; o++) {
			if (max < s[n][o]) {
				max = s[n][o];
			}
			if (s[n][o] == 0) {
				count += 1;
			}
		}
	}
	cout << count << endl;
	cout << max << endl;
	return 0;
}

Measured memory_bytes: 3052
#[allow(unused_macros)]
macro_rules! input {
    ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } };
    ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } };
}
#[allow(unused_macros)]
macro_rules! input_inner {
    ( $ next : expr ) => { };
    ( $ next : expr , ) => { };
    ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } };
}
#[allow(unused_macros)]
macro_rules! read_value {
    ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) };
    ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) };
    ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) };
    ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 };
    ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) };
}

fn main() {
    input! {
        n: usize
    }

    let sieve_max = 277765;
    let (primes, _) = sieve(sieve_max);
    let mut acc = vec![];
    for p in primes {
        if p % 5 == 1 {
            acc.push(p);
        }
    }
    for i in 0..n-1 {
        print!("{} ", acc[i]);
    }
    println!("{}", acc[n-1]);
}

#[doc = " return: (primes, is_prime)"]
#[allow(dead_code)]
fn sieve(n: usize) -> (Vec<usize>, Vec<bool>) {
    let mut primes = vec![];
    let mut is_prime = vec![true; n + 1];
    is_prime[0] = false;
    is_prime[1] = false;
    for i in 2..n + 1 {
        if is_prime[i] {
            primes.push(i);
            for j in (2..).map(|j| j * i).take_while(|&j| j <= n) {
                is_prime[j] = false;
            }
        }
    }
    (primes, is_prime)
}


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

int main() {
  int c[9],sum=0;
  bool f=true;
  for(int i=0;i<9;i++){
    cin>>c[i];
    sum+=c[i];
  }

  if(3*(c[0]+c[4]+c[8])!=sum) f=false;

  if(f) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}	


Measured memory_bytes: 256
n=int(input())
arr1=list(map(int,input().split()))
arr2=list(map(int,input().split()))
ans=0
for i in range(n-1,-1,-1): #勇者を後ろから順にみていく
 if arr1[i+1]>=arr2[i]: #i番目の勇者がi+1番目の町のモンスターしか倒せないとき
   ans+=arr2[i]
   continue
 else: #i番目の勇者がi番目の町のモンスターも倒す余裕があるとき
   ans+=arr1[i+1]
   arr2[i]-=arr1[i+1]
   if arr1[i]>arr2[i]: #i番目の勇者がi番目の町のモンスターをすべて倒せないとき
     ans+=arr2[i]
     arr1[i]-=arr2[i] #i番目の勇者が倒せなかったモンスターの数を計算する
   else:  #i番目の勇者がi番目の町のモンスターもすべて倒せるとき
     ans+=arr1[i]
     arr1[i]=0
print(ans)

Measured memory_bytes: 18380
#include <iostream>
using namespace std;
int f(int x){
    int p=0;
    while(x){
        p+=x%10;
        x/=10;
    }
    return p;
}
int main(void){
    // Your code here!
    int n;
    cin>>n;
    if(n%f(n)==0){
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<algorithm>
using namespace std;
#define ll long long 
vector<vector<int>>G(2*1000000);
int T[2*1000000] = {};

int bfs(int i,int ct){
  int tmp;
  for(int j = 0; j< G[i].size();j++){
    tmp = G[i][j];
    if(T[tmp] == 0){
      T[tmp] = ct;
      bfs(tmp,ct);
    }
  }
  return 0;
}


int main() {
  int n,m;
  cin >> n >> m;
  
  int a,b;
  for(int i = 0;i<m;i++){
    cin >> a >> b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  
  int ct = 0;
  for(int i = 1;i < n+1;i++){
    if(T[i] == 0){
      ct++;
      T[i] = ct; 
      bfs(i,ct);
    }
  }
  int res[n+1] ={};
  for(int i = 1;i < n+1;i++){
    //cout << T[i] << " ";
    res[T[i]]++;
  }
  //cout << endl;
  int c = 0;
  for(int i = 1;i < n+1;i++){
    c = max(c,res[i]);
  }
  cout << c;
}


Measured memory_bytes: 66576
#include "bits/stdc++.h"
using namespace std;

vector<int> dx = {1, 0, -1, 0};
vector<int> dy = {0, 1, 0, -1};

int main() {
  int H,W;
  cin >> H >> W;
  vector<string> s(H);
  for(int i=0;i<H;i++){
    cin >> s[i];
  }
  bool res = true;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(s[i][j] == '#'){
        bool exist = false;
        for(int k=0;k<4;k++){
          if(0 <= i+dy[k] && i+dy[k] < H && 0<= j+dx[k] &&
             j+dx[k]< W && s[i+dy[k]][j+dx[k]] == '#'){
            exist = true;
            break;
          }
        }
        res = exist;
      }
      if(!res) break;
    }
    if(!res) break;
  }
  if(res){
    cout << "Yes";
  }else{
    cout << "No";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256