akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

double minko(int n, int p, double x[], double y[]) {
  double d = 0.0;
  for (int i=0;i<n;i++)
    d += pow(abs(x[i] - y[i]), p);
  d = pow(d, 1.0 / (double)p);
  return d;
}

double minkomax(int n, double x[], double y[]) {
  double d = 0.0;
  for (int i=0;i<n;i++) {
    double tmp = abs(x[i] - y[i]);
    if (d < tmp)
      d = tmp;
  }
  return d;
}

int main() {
  int n;
  double x[100], y[100];
  cin >> n;
  for (int i=0;i<n;i++)
    cin >> x[i];
  for (int i=0;i<n;i++)
    cin >> y[i];
  
  cout << fixed << setprecision(10)
       << minko(n, 1, x, y) << endl
       << minko(n, 2, x, y) << endl
       << minko(n, 3, x, y) << endl
       << minkomax(n, x, y) << endl;
}



Measured memory_bytes: 3444
#include<iostream>
#include<cstdlib>
#include<string>
#include<map>
#define MAX 100
#include<cstdio>
using namespace std;
int main(){
	map<string,int> mp;
	string str;
	string s="a";
	string box="abcdefghijklmnopqrstuvwxyzabcd";
	while(1){
		printf("?%s\n",s.c_str()); 
		fflush(stdout);
		cin>>str;
		mp[s]++;
		if(mp[str]||s[s.size()-1]!=str[0]){
			cout<<"!OUT"<<endl;
			return 0;
		}
		mp[str]++;
		
		while(1){
			s=str[str.size()-1];
			s+=box[rand()%25];
			s+=box[rand()%25];///;+"a";
			s+="a";
			//cout<<s<<endl;
			if(!mp[s])
				break;
		}
	}
	return 0;
}

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

using namespace std;

double X[100005];
double Y[100005];
char mode[1000005];

int main(){
	int N;
	scanf("%d", &N);
	
	double y_u_max = -1e9;
	double y_u_min = 1e9;
	double y_d_max = -1e9;
	double y_d_min = 1e9;
	double x_l_max = -1e9;
	double x_l_min = 1e9;
	double x_r_max = -1e9;
	double x_r_min = 1e9;
	
	double y_fixed_max = -1e9;
	double y_fixed_min = 1e9;
	double x_fixed_max = -1e9;
	double x_fixed_min = 1e9;
	
	for(int i = 0; i < N; i ++){
		int x, y;
		char z;
		scanf(" %d %d %c", &x, &y, &z);
		X[i] = x;
		Y[i] = y;
		mode[i] = z;
		if(z == 'U' || z == 'D'){
			x_fixed_max = max(X[i], x_fixed_max);
			x_fixed_min = min(X[i], x_fixed_min);
		}else{
			y_fixed_max = max(Y[i], y_fixed_max);
			y_fixed_min = min(Y[i], y_fixed_min);
		}
		
		if(z == 'U'){
			y_u_max = max(Y[i], y_u_max);
			y_u_min = min(Y[i], y_u_min);
		}else if(z == 'D'){
			y_d_max = max(Y[i], y_d_max);
			y_d_min = min(Y[i], y_d_min);
		}else if(z == 'L'){
			x_l_max = max(X[i], x_l_max);
			x_l_min = min(X[i], x_l_min);
		}else{
			x_r_max = max(X[i], x_r_max);
			x_r_min = min(X[i], x_r_min);
		}
	}
	
	//printf("%.1f %.1f %.1f %.1f\n", x_fixed_min, x_fixed_max, y_fixed_min, y_fixed_max);
	
	double ans = 1e18;
	for(int time1 = 0; time1 <= 4e8+1; time1 ++){
		/*double x_max = -1e9;
		double x_min = 1e9;
		double y_max = -1e9;
		double y_min = 1e9;
		
		for(int i = 0; i < N; i ++){
			x_max = max(x_max, X[i]);
			x_min = min(x_min, X[i]);
			y_max = max(y_max, Y[i]);
			y_min = min(y_min, Y[i]);
		}
		double t = time1 / 2.0;
		
		double temp = (x_max-x_min) * (y_max-y_min);*/
		//printf("t=%.1f %.1f %.1f %.2f\n", t, x_max-x_min, y_max-y_min, temp);
		
		double t = time1 / 2.0;
		
		double x_max2 = max(max(x_r_max+t, x_l_max-t), x_fixed_max);
		double x_min2 =min(min(x_r_min+t, x_l_min-t), x_fixed_min);
		
		double y_max2 = max(max(y_u_max+t, y_d_max-t), y_fixed_max); 
		double y_min2 = min(min(y_u_min+t, y_d_min-t), y_fixed_min);
		
		double temp2 = (x_max2-x_min2) * (y_max2-y_min2);
		ans = min(ans, temp2);
		//printf("%.1f\n", y_d_min-t);
		//printf("t=%.1f %.1f %.1f %.1f %.1f %.2f\n", t, y_max, y_max2, y_min, y_min2, temp2);
		
		/*for(int i = 0; i < N; i ++){
			if(mode[i] == 'U'){
				Y[i] += 0.5;
			}else if(mode[i] == 'D'){
				Y[i] -= 0.5;
			}else if(mode[i] == 'L'){
				X[i] -= 0.5;
			}else if(mode[i] == 'R'){
				X[i] += 0.5;
			}
		}*/
	}
	
	printf("%.10f", ans);
	
	return 0;
}


Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
string s,ans;
int n;

P getNum(string str,int x){
  int r=0;
  while('0'<=str[x]&&str[x]<='9')
    r=r*10+str[x]-'0',x++;
  return P(x,r);
}

void dfs(int b,int e){
  int p=b;
  while(p<=e&&ans.size()<=n){
    while('0'<=s[p]&&s[p]<='9'){
      P r=getNum(s,p);
      int x=r.first,num=r.second;
      int y=r.first,z=r.first;
      if(s[x]=='('){
	int c=1;
	y=x+1;
	for(z=y;z<=e&&c;z++){
	  if(s[z]=='(')c++;
	  if(s[z]==')')c--;
	}
	p=z;
	z-=2;
	while(num--)dfs(y,z);
      }else{
	while(num--)ans+=s[x];
	p=x+1;
      }
    }
    while('A'<=s[p]&&s[p]<='Z')
      ans+=s[p++];
  }
}

int main(){
  while(1){
    cin>>s>>n;
    if(s=="0"&&!n)break;
    dfs(0,s.size()-1);
    if(ans.size()<n+1)
      printf("0\n");
    else printf("%c\n",ans[n]);
    ans.clear();
  }
  return 0;
}

Measured memory_bytes: 2132
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def _I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def pf(s): return print(s, flush=True)

H,W=LI()
if H%3==0 or W%3==0:
	print(0)
	exit()
ans=inf
for h in range(H//2, H):
	items=[(H-h)*W, h*(W//2), h*(W-(W//2))]

	big=max(items)
	sml=min(items)
	ans = min(ans,big-sml)
	items=[(H-h)*W,(h//2)*W, (h-(h//2))*W]
	big=max(items)
	sml=min(items)
	ans = min(ans,big-sml)
	#(((() print(h,big,sml,items)

for w in range(W//2, W):
	items=[(W-w)*H,w*(H//2),w*(H-(H//2))]

	big=max(items)
	sml=min(items)
	ans=min(ans,big-sml)
	
	items=[(W-w)*H,(w//2)*H, (w-(w//2))*H]
	big=max(items)
	sml=min(items)
	ans = min(ans,big-sml)

print(ans)


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

ll N, K;

int main(){
	cin >> N >> K;
	vector<ll> A(N);
	for ( int i = 0; i < N; i++ ){
		ll a;
		cin >> a;
		// 要素の和を K で割った余りが要素の数と等しくなるものの数
		//  == 1を引いた要素の和を K で割った余りが0と等しくなる && 要素数がK未満のものの数
		A[i] = (a-1+K)%K;
	}
	
	//
	vector<pair<ll,ll>> Asum(N+1);
	ll sum = 0;
	for ( int i = 0; i < N; i++ ){
		Asum[i] = {sum,i};
		sum = (sum+A[i])%K;
	}
	Asum[N] = {sum,N};
	
	sort(Asum.begin(), Asum.end(),[](pair<ll,ll> l, pair<ll,ll> r){return (l.first*N*2+l.second)<(r.first*N*2+r.second);});
	
//	for ( int i = 0; i < N+1; i++ )
//		cout << i << " : " << Asum[i].first << "/" << Asum[i].second << endl;
	
	ll count = 0;
	for ( int i = 0; i <= N; ){
		int ct = 1;
		while ( i+ct <= N && Asum[i].first == Asum[i+ct].first ) // 同じfirstが連続する数を数える
			ct++;
		// ここで、 Asum[i] から ct個は firstが同じである
		
		if ( ct >= 2 ){
			// secondの差がK未満の組を数える
			int j = i+1;
			for ( int i0 = i; i0 < i+ct; i0++ ){
				while ( j < i+ct && (Asum[j].second-Asum[i0].second) < K )
					j++;
				// cout << "i0=" << i0 << " " << (j-i0-1) << endl;
				count += (j-i0-1);
			}
			
		}
		i += ct;
	}
	
	cout << count << endl;
	return 0;
}



Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
  long long int n;
  cin>>n;
  vector<long long int> a(n);
  for(long long int i=0; i<n; i++){
    cin>>a.at(i);
  }
  long long int ans=0;
  long long int max=a.at(0);
  for(long long int i=1; i<n; i++){
    if(a.at(i)<max){
      ans+=max-a.at(i);
    }else{
      max=a.at(i);
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 4836
#include <stdio.h>
#define N 100005
#define NIL -1
 
typedef struct{
  int p,s,deg,def,h,l,r;
}Node;
Node T[N];
int depth(int id);
int height(int id);
int max(int a, int b);
int main(void){
  int n,i,j,k,z;
  int id,tmp,max,num;
 
  scanf("%d", &n);
  for(i = 0; i < n; i++){
    T[i].p = T[i].s = T[i].deg = T[i].def = T[i].h =NIL;
  }
  for(i = 0; i < n; i++){
    scanf("%d %d %d",&z, &id, &k);
    T[id].p = T[k].p = z;
    T[k].s = id; T[id].s = k;
    if(id==NIL && k==NIL) 
      T[z].deg = 0;
    else if(id!=NIL && k!=NIL) 
      T[z].deg = 2;
    else 
      T[z].deg = 1;
    T[z].l = id; T[z].r = k;
  }
  for(i=0;i<n;i++){
    printf("node %d: parent = %d, ",i,T[i].p);
    printf("sibling = %d, ",T[i].s);
    printf("degree = %d, ",T[i].deg);
    printf("depth = %d, ",depth(i));
    printf("height = %d, ",height(i));
    if(T[i].p==-1) T[i].deg=-1;
    switch(T[i].deg){
      case -1: printf("root");          break;
      case  0: printf("leaf");          break;
      case  1: printf("internal node"); break;
      case  2: printf("internal node"); break;
    }
    printf("\n");
  }
	return 0;
}

int depth(int id){
  int tmp;
  tmp=id;
  for( ; ; ){
    if(T[tmp].p!=NIL)
      T[id].def += 1;
    else break;
    tmp=T[tmp].p;
  }    
  return T[id].def+1; 
}
int height(int id){
    if(T[id].h!=-1)
      return T[id].h;
    if(T[id].l == -1 && T[id].r == -1)
      T[id].h = 0;
    else if(T[id].l == -1)
      T[id].h = height(T[id].r) + 1;
    else if(T[id].r == -1)
      T[id].h = height(T[id].l) + 1;
    else
      T[id].h = max( height(T[id].l), height(T[id].r) ) + 1;
    return T[id].h;
}
int max(int a, int b){
    if(a>b) return a;
    else return b;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
using namespace std;
using ll = long long;
using vi = vector<int>;

int main() {
  int D, T, S;
  cin >> D >> T >> S;
  cout << (S * T >= D ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;


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

    if ((b-a)%2 != 0) cout << "Borys" << endl;
    else cout << "Alice" << endl;

    return 0;
}


Measured memory_bytes: 256
import std.algorithm;
import std.bigint;
import std.concurrency;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.meta;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import std.typecons;


immutable long MOD = 1000000007;


auto solve(long N, string S) {
    long waysToMakePair = 1;
    
    long floatEdges;
    foreach (c; S) {
        bool open;
        if (c == 'B') {
            // 浮いている紐は奇数でなければならない
            open = (floatEdges & 1) == 0;
        } else {
            // 浮いている紐は奇数でなければならない
            open = (floatEdges & 1) != 0;
        }

        if (open) {
            floatEdges++;
        } else {
            waysToMakePair *= floatEdges;
            waysToMakePair %= MOD;
            floatEdges--;
        }
    }

    if (floatEdges != 0 || waysToMakePair == 0)
        return 0;
    
    long facN = 1;
    foreach (i; 1 .. N + 1) {
        facN *= i;
        facN %= MOD;
    }

    return waysToMakePair * facN % MOD;
}


void main() {
    auto input = stdin.byLine.map!split.joiner;

    long N;
    N = input.front.to!long;
    input.popFront;

    string S;
    S = input.front.to!string;
    input.popFront;

    static if (is(ReturnType!solve == void))
        solve(N, S);
    else
        solve(N, S).writeln;
}


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

using namespace std;

int main()
{
    long long int n , i , j;
    cin>>n;
    int h[n];
    vector<int> dp(n,INT_MAX);
    for( i = 0 ; i < n ; i++)cin>>h[i];
    dp[0]=0;
    for( i = 0 ; i < n ; i++)
    {   
       // cout<<dp[i]<<endl;
        for( j = i+1 ; j<=i+2 ; j++)
        {
           if(j<n) dp[j]=min(dp[j],dp[i]+abs(h[j]-h[i]));
        }
    }
    cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1024
N=int(input())
D=list()
for i in range(0,N):
    a,b=map(int,input().split())
    D.append((a,b))
a = ''
for i in range(0,N):
    if D[i][0]==D[i][1]:
        a=a+'1'
    else:
        a=a+'0'
if '111' in a:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 62424
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
ll cnt[100005]={0};
ll cn2[100005]={0};
queue<ll> same_cn[100005];
int main(){
  ll n,m;
  cin>>n>>m;
  for(int i=0;i<n;i++){
    ll a;
    cin>>a;
    cnt[a%m]++;
    cn2[a]++;
  }
  for(int i=0;i<100005;i++) same_cn[i%m].push(cn2[i]);
  ll ans=0;
  for(int i=1;2*i<m;i++){
    ll mv=min(cnt[i],cnt[m-i]);
    cnt[i]-=mv;
    cnt[m-i]-=mv;
    ans+=mv;

    while(cnt[i]>=2&&!same_cn[i].empty()){
      ll tp=same_cn[i].front();
      same_cn[i].pop();
      while(cnt[i]>=2&&tp>=2){
        ans++;
        tp-=2;
        cnt[i]-=2;
      }
    }
    while(cnt[m-i]>=2&&!same_cn[m-i].empty()){
      ll tp=same_cn[m-i].front();
      same_cn[m-i].pop();
      while(cnt[m-i]>=2&&tp>=2){
        ans++;
        tp-=2;
        cnt[m-i]-=2;
      }
    }
  }
  ans+=cnt[0]/2;
  if(m%2==0) ans+=cnt[m/2]/2;
  cout<<ans<<endl;
}


Measured memory_bytes: 69120
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, k = list(map(int, readline().split()))

    count = [0] * (k + 1)

    for x in range(k, 0, -1):
        c = k // x
        cx = pow(c, n, MOD)

        y = 2

        while x * y <= k:
            cx -= count[x * y]
            cx %= MOD
            y += 1

        count[x] = cx

    ans = 0
    for i in range(1, k + 1):
        ans += count[i] * i
        ans %= MOD

    print(ans)

if __name__ == '__main__':
    main()


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

int main(){
	int x, y;
	cin >> x >> y;
	rep(i, x+1) {
		int c = i;
		int t = x - i;
		if (2*c + 4*t == y) {
			cout << "Yes" << endl;
			return 0;
		}
//		cout << "No" << endl;
	}
  cout << "No" << endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, ll> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 100010;
const int MAXM = 100010;
const int MAXK = 510;
const int MAXQ = 200010;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
  int n;
  cin  >> n;
  if (n % 10 == n / 100) cout << "Yes";
  else cout << "No";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
 
using namespace std;
 
int main() {
    int n;
    long sum = 0;
 
    cin >> n;
 
    for (int i = 1; i <= n; i++) {
        if (i % 3 != 0 && i % 5 != 0) {
            sum += i;
        }
    }
 
    cout << sum << endl;
 
    return 0;
}

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout.precision(10);
    cout<<fixed;
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
#endif
	int k, n;
	cin>>k>>n;
	int x[n], a[n];
	for (auto &i : x) cin>>i;
	for (int i = 0; i < n; ++i) {
		if (i+1 == n) a[i] = k - x[i] + x[0];
		else a[i] = x[i+1] - x[i];
	}
	cout<<k - *max_element(a, a+n)<<"\n";
	return 0;
}

Measured memory_bytes: 1792
n,m=map(int,input().split())
a_list=list(map(int,input().split()))
a_list.sort()
from collections import deque
a_list=deque(a_list)
Dict={}
M=m
for i in range(m):
    b,c=map(int,input().split())
    if c in Dict:
        Dict[c]=Dict[c]+b
        M=M-1
    else:
        Dict[c]=b
bc_list=[]
for k, v in sorted(Dict.items(), key=lambda x: -x[0]):
    bc_list.append((k,v))
i=0
v=bc_list[0][1]
while True:
    if v==0:
        i=i+1
        if i==M:
            break
        else:
            v=bc_list[i][1]
    else:
        if a_list[0]<bc_list[i][0]:
            a_list.popleft()
            a_list.append(bc_list[i][0])
            v=v-1
        else:
            break
print(sum(a_list))



Measured memory_bytes: 96876
# coding: utf-8
import numpy as np


def solve(*args: str) -> str:
    n, k = map(int, args[0].split())
    A = np.array(tuple(map(int, args[1].split())))

    l, r = 0, np.max(A)
    while l+1 < r:
        m = (l+r)//2
        if k < np.sum(-(-A//m)-1):
            l = m
        else:
            r = m

    return str(r)


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))


Measured memory_bytes: 50932
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var xa = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        var xx = xa[0];
        var a = xa[1];

        Console.WriteLine(xx < a ? 0 : 10);
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
constexpr auto INF = INT_MAX >> 1;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

int main() {

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

	bool ok = false;
	rep(i, 26) {
		string ss = s;
		ss +='a' + i;
		if (t == ss)ok = true;
	}
	
	cout << (ok ? "Yes" : "No") << endl;

}

Measured memory_bytes: 3596
//بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ
#include <bits/stdc++.h>
using namespace std;
bool a[100001]{};
long long memo[100001];
int n, m;

long long climb(int i){
    if(memo[i] > -1) return memo[i];
    long long v = 0;
    if(i == n) return 1;
    if(!a[i+1]) v += climb(i+1);
    v %= 1000000007ll;
    if(i < n-1 && !a[i+2]) v += climb(i+2);
    v %= 1000000007ll;
    memo[i] = v;
    return v;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    memset(memo, -1, sizeof(memo));
    cin >> n >> m;
    for(int i = 0, tmp = 0; i < m; i++){
        cin >> tmp;
        a[tmp] = true;
    }
    cout << climb(0);
}


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

int main(){
  int H,N;
  
  cin >>H >> N;
  vector<int> a(N,0);
  vector<int> m(N,0);
  for (int i=0;i<N;i++){
    cin >> a.at(i) >> m.at(i);
  }
  
  vector<vector<int>> dp(N,vector<int> (H+1,0));
  dp.at(0).at(0)=0;
  for (int i=1;i<H+1;i++){
    if (i%a.at(0)==0){
      dp.at(0).at(i)=i/a.at(0)*m.at(0);
    }
    else{
      dp.at(0).at(i)=(i/a.at(0)+1)*m.at(0);
    }
  }

    
  for (int i=1;i<N;i++){
    for (int j=0;j<H+1;j++){
      if (j-a.at(i)<0){
        dp.at(i).at(j)=min(dp.at(i-1).at(j),m.at(i));
      }
      else{
        dp.at(i).at(j)=min(dp.at(i-1).at(j),dp.at(i).at(j-a.at(i))+m.at(i));
      }
      
    }
    
  }
  int mincos=dp.at(0).at(H);
  for (int i=0;i<N;i++){
    mincos = min(mincos,dp.at(i).at(H));
  }
  cout << mincos << endl;
}     
      

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

public class Main {
    private void solve() {
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        int t = a;
        a = b;
        b = t;

        t = a;
        a = c;
        c = t;

        out.println(String.format("%d %d %d", a, b, c));
    }

    private static PrintWriter out;
    private static MyScanner sc;

    private static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        private MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }

    public static void main(String[] args) {
        out = new PrintWriter(new BufferedOutputStream(System.out));
        sc = new MyScanner();
        new Main().solve();
        out.close();
    }
}


Measured memory_bytes: 34148
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include<functional>
#include <tuple>
#include <map>
#include<set>
#include <cmath>
#include <stack>
#include<cstdio>
#include<stdio.h>
using namespace std;

int main() {
	int n,cnt=0, ans=0;
	char s;
	cin >> n;
	for (int i = 0;i < n;i++) {
		cin >> s;
		if (s == 'I')cnt++;
		else cnt--;
		ans = max(ans, cnt);
	}
	cout << ans << endl;
}

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

int count2( int A){
  int x = 0;
  while ( A%2 == 0 && A != 0){
    A /= 2;
    x++;
  }
  return x;
}

int main() {
  int N;
  cin >> N;
  int ans = 0;
  for (int i = 0; i < N; i++){
    int a;
    cin >> a;
    ans += count2(a);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
#define endl "\n"

using namespace std;

//ll const N = 100000;

int main()
{
    int N, one, two, three;

    cin >> N;

    one = N % 10;
    N /= 10;

    two = N % 10;
    N /= 10;

    three = N % 10;
    N /= 10;

    if(one == 7 || two == 7 || three == 7)
    {
        cout << "Yes";
    }

    else cout << "No";

    return 0;
}

Measured memory_bytes: 3616
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n");
while(true){
   var nlr=arr.shift().split(" ").map(Number);
   if(nlr.join("")=="000")break;
   var [n,l,r]=[nlr[0],nlr[1],nlr[2]];
   var A = [];
   for(var i=0;i<n;i++) A.push(arr.shift()-0);
   var cnt=0;
   for(var x=l;x<=r;x++){
      var flag=true;
      for(var i=0;i<A.length;i++){
         if(x%A[i]==0){
            flag=false;
            if ((i+1)%2!=0)cnt++;
            break;
         }
      }
      if(flag && n%2==0)cnt++;
   }  
   console.log(cnt);
}


Measured memory_bytes: 16544
//#include <algorithm>
#include <cstdio>
#include <string>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <iomanip>
#include <queue>
#include <stack>


typedef unsigned long long ULONG;
using namespace std;

int main(void) {
	long long  A;
	long double B;

	cin >> A >> B;

	long long ans = (long long)(A * B);

	cout << ans;
  	
	return 0;
}


Measured memory_bytes: 3728
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;


int main() {
    int N, M;
    cin >> N >> M;
    vector<int> L(M);
    vector<int> R(M);
    for (int i = 0; i < M; i++) {
        cin >> L[i] >> R[i];
    }
    int min = 0;
    int max = 100001;
    int ans = 1;
    for (int i = 0; i < M; i++) {
        if ((min > R[i]) or (max < L[i])) {
            ans = 0;
        }else{
            if (min < L[i]) {
            min = L[i];
            } 
            if (max > R[i]) {
                max = R[i];
            }
        }
    }
    if (ans) {
        cout << max - min + 1 << endl;
    }else{
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void){
	int x,i;

	//scanf("%lf",&m);
	
	x = getchar();
	x=getchar();
	
	if(x=='B')
		printf("ARC\n");
	else
		printf("ABC\n");
	
	
	return 0;
}

Measured memory_bytes: 1960
#include <iostream>

using namespace std;

#define ll long long
#define pb push_back
#define st first
#define N 3005
#define nd second
#define ii pair<int,int>
#define fr freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
pair<ll,ll> a[N];
ll dp[N][N][2];
int n,t;
ll f(int cur, int rem, bool type){
	if(rem==0)return 0;
	if(cur==n)return 0;
	if(dp[cur][rem][type]) return dp[cur][rem][type];
	ll &r=dp[cur][rem][type];
	if(!type) 
		r=max(r,f(cur+1,rem-1,1)+a[cur].nd);
	if(rem>=a[cur].st) 
		r=max(r,f(cur+1,rem-a[cur].st,type)+a[cur].nd);
	r=max(r,f(cur+1,rem,type));
	return r;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	//fr
	cin>>n>>t;
	for(int i=0,c,b;i<n;i++){
		cin>>c>>b;
		a[i].st=c;
		a[i].nd=b;
	}
	cout<<f(0,t,0);
}


Measured memory_bytes: 139520
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod=1e9+7;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++){
        cin >> A[i];
    }
    sort(A.begin(), A.end());
    int cnt=0, tmp=0;
    for(int i=0; i<N; i++){
        if(tmp!=A[i]){
            tmp=A[i];
            cnt++;
        }else{
            tmp=0;
            cnt--;
        }
    }
    cout << cnt;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
typedef long long ll;
struct S{
  double volume;
  int price;
  double unit_price;
};
bool price_sort(const S& a,const S& b){
  return a.unit_price < b.unit_price;
}
using namespace std;
int main(void){
  int q,h,s,d;
  double n;
  ll ans=0;
  vector<S> v;
  cin>>q>>h>>s>>d>>n;
  S st={0.25,q,(double)q/0.25};
  v.push_back(st);
  st={0.5,h,(double)h/0.5};
  v.push_back(st);
  st={1,s,(double)s};
  v.push_back(st);
  st={2,d,(double)d/2};
  v.push_back(st);
  sort(v.begin(),v.end(), price_sort);
  for(int i=0;i<4;i++){
    if(n==0) break;
    ans+=(ll)v[i].price*(ll)(n/v[i].volume);
    n-=v[i].volume*(int)(n/v[i].volume);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>


using namespace std;

int main()
{
	int W, H, N;
	int x[100], y[100], a[100];
	cin >> W >> H >> N;
	int Wmax, Hmax, Wmin, Hmin;
	Wmax = W;
	Hmax = H;
	Wmin = 0;
	Hmin = 0;

	for (int i = 1; i < N + 1; ++i) {
		cin >> x[i] >> y[i] >> a[i];

		switch (a[i])
		{
		case 1:
			Hmax = Hmax;
			Hmin = Hmin;
			if (x[i] < Wmin) {
				Wmin = Wmin;
				Wmax = Wmax;

			}else{
				if (x[i] > Wmax) {
				Wmin = 0;
				Wmax = 0;
				}
				else {
					Wmax = Wmax;
					Wmin = x[i];
				}
			}

			break;
		case 2:
			Hmax = Hmax;
			Hmin = Hmin;
			if (x[i] < Wmin) {
				Wmin = 0;
				Wmax = 0;

			}
			else {
				if (x[i] > Wmax) {
					Wmin = Wmin;
					Wmax = Wmax;
				}
				else {
					Wmax = x[i];
					Wmin = Wmin;
				}
			}
			break;
		case 3:
			Wmax = Wmax;
			Wmin = Wmin;
			if (y[i] < Hmin) {
				Hmin = Hmin;
				Hmax = Hmax;

			}
			else {
				if (y[i] > Hmax) {
					Hmin = 0;
					Hmax = 0;
				}
				else {
					Hmax = Hmax;
					Hmin = y[i];
				}
			}
			break;
		case 4:
			Wmax = Wmax;
			Wmin = Wmin;
			if (y[i] < Hmin) {
				Hmin = 0;
				Hmax = 0;

			}
			else {
				if (y[i] > Hmax) {
					Hmin = Hmin;
					Hmax = Hmax;
				}
				else {
					Hmax = y[i];
					Hmin = Hmin;
				}
			}
			break;
		default:
			break;
		}
	}
	

    cout << (Wmax-Wmin)* (Hmax-Hmin) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <functional>
#include <queue>
#include <map>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
const int INF = 100000000;

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

    if(a >= 1 && a <= 9 && b <= 9 && b >= 1){
        cout << a * b << endl;
    }else{
        cout << -1 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
from math import ceil
n, h, *AB = map(int, open(0).read().split())
a = max(AB[::2])
B = sorted(b for b in AB[1::2] if a < b)[::-1]
c = 0
for b in B:
    h -= b
    c += 1
    if h <= 0:
        break
else:
    c += ceil(h / a)
print(c)

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

int main() {
  int a,b,c,d;
  cin>>a>>b;
  int sum=0;
  vector<int> vec(a);
  
  for(int i=0;i<a;i++){
  	cin>>vec.at(i);
    sum+=vec.at(i);
  }
  d=0;
  if(sum%(4*b)>0)d=1;
  sum = sum/(4*b);
  if(d==1)sum++;
  
  c=0;
 // cout<<sum<<endl;
  for(int i=0;i<a;i++){
  	if(vec.at(i)>=sum){
      c++;
      //cout<<vec.at(i)<<endl;
    }
  }
  
  if(c>=b)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  
  
  

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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; }

const long long INF = 1LL << 60;

int main(){
  int x, n;
  cin >> x >> n;
  vector<bool> ok(101, true);
  
  rep(i, n){
    int p; cin >> p;
    ok[p] = false;
  }

  int i = 0;
  while(1){
    if(x-i == 0){
      cout << 0 << endl;
      return 0;
    }
    if(ok[x-i]){
      cout << x-i << endl;
      return 0;
    }
    if(x+i == 101){
      cout << 101 << endl;
      return 0;
    }
    if(ok[x+i]){
      cout << x+i << endl;
      return 0;
    }
    i++;
  }

  return 0;
}


Measured memory_bytes: 3632
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub


import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


def eratosthenes(n):
    p = []
    t = [0] * n

    for i in range(2, int(math.ceil(math.sqrt(n)))):
        if t[i] == 0:
            p.append(i)
            t[i] = i
            for j in range(2*i, n, i):
                if t[j] == 0:
                    t[j] = i

    for j in range(i+1, n):
        if t[j] == j or t[j] == 0:
            p.append(j)
            t[j] = j

    return p, t


@mt
def slv(N, A):
    _, T = eratosthenes(10**6+1)

    used = set()
    for a in A:
        while a != 1:
            p = T[a]
            if p in used:
                break
            while a % p == 0:
                a //= p
            used.add(p)
        if a != 1:
            break

    else:
        return 'pairwise coprime'

    return 'setwise coprime' if reduce(math.gcd, A) == 1 else 'not coprime'


def main():
    N = read_int()
    A = read_int_n()
    print(slv(N, A))


if __name__ == '__main__':
    main()


Measured memory_bytes: 204516
S = input()
K = int(input())
count = 0
count2 = 1
count3 = 1
flag = 0
flag2 = 0
if len(S) == 1:
    print(K // 2)
else:
    for i in range(len(S)-1):
        if S[i] == S[i+1] and flag == 0:
            count += 1
            flag = 1
        else:
            flag = 0
        if S[i] != S[i+1]:
            flag2 = 1
    num = count * K
    if flag2 == 0:
        print(len(S) * K //2)
    else:

        if S[0] == S[-1]:
            if len(S) == 2:
                print(num)
            else:
                flag3 = 0
                for i in range(len(S)-1):
                    if S[i] == S[i+1] and flag3 == 0:
                        count2 += 1
                    else:
                        flag3 = 1
                flag3 = 0
                for i in range(len(S)-1, 0, -1):
                    if S[i] == S[i-1] and flag3 == 0:
                        count3 += 1
                    else:
                        flag3 = 1
                if count2 % 2 != 0 and count3 % 2 != 0:
                    print(num + K - 1)
                else:
                    print(num)
        else:
            print(num)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
const double PI=acos(-1);
using namespace std;
using boost::multiprecision::cpp_int;
#define ll long long
#define ull unsigned long long
#define ul unsigned long
#define ci cpp_int
#define MOD 1000000007

long findmin(long a,long b) {
	return a<b?a:b;
}
long findmax(long a,long b) {
	return a>b?a:b;
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	long n;int k;
	cin>>n>>k;
	int h[n];
	for(long i=0;i<n;i++) {
		cin>>h[i];
	}
	vector<long> dp(n,0);
	//dp[0]=0;
	long x;
	for(long i=1;i<n;i++) {
		int min=INT_MAX;
		for(int j=1;j<=k && (i-j)>=0;j++) {
			x= dp[i-j]+abs(h[i]-h[i-j]);
			if(x<min) {
				min=x;
			}
		}
		dp[i]=min;
	}
	cout<<dp[n-1]<<"\n";
	cout.flush();
	return 0;
}


Measured memory_bytes: 4556
n = int(input())
a, xy = [], []
for _ in range(n):
    a_t = int(input())
    xy_t = [list(map(int, input().split())) for _ in range(a_t)]
    a.append(a_t)
    xy.append(xy_t)

ans = 0
for i in range(2**n):
    flag = True
    for j in range(n):
        if (i >> j) & 1:
            for k in xy[j]:
                if (i >> (k[0]-1)) & 1 != k[1]:
                    flag = False
    if flag:
        ans = max(ans, bin(i).count('1'))
print(ans)

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

#define M 1000000007
#define MM 998244353 
#define ll long long 
#define pb push_back
#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))
#define memf(a) memset(a,false,sizeof(a))
#define all(v) v.begin(),v.end()
#define sz(a) (ll)a.size()
#define F first
#define S second
#define PI 3.1415926536
#define INF 2e18
#define endl "\n"
#define llevel 20
ll power(ll b,ll e,ll m)
{
	if(e==0) return 1;
	if(e&1) return b*power(b*b%m,e/2,m)%m;
	return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
	if(e==0) return 1;
	if(e&1) return b*power(b*b,e/2);
	return power(b*b,e/2);
}

int _runtimeTerror_()
{
	double l;
	cin>>l;
	cout<<fixed<<setprecision(10);
	cout<<pow(l/3,3);
	return 0;
}

int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	#ifdef runSieve
		sieve();
	#endif
	#ifdef NCR
		initialize();
	#endif
	int TESTS=1;
	//cin>>TESTS;
	while(TESTS--)
		_runtimeTerror_();
	return 0;
}


Measured memory_bytes: 256
solve3 [h,w] = loop h
  where
    addSyapu n
      | n == 0 = []
      | otherwise = "#" ++ addDot (n-1)
    addDot n
      | n == 0 = []
      | otherwise = "." ++ addSyapu (n-1)
    loop x = do
      if x == 0
        then putStrLn ""
        else do
        putStrLn $ addSyapu w
        loop2 (x-1)
    loop2 x = do
      if x == 0
        then putStrLn ""
        else do
        putStrLn $ addDot w
        loop (x-1)



main = do
  hws <- input1
  mapM_ solve3 hws

input1 :: IO [[Int]]
input1 = loop []
  where
    loop list = do
      temp <- getLine
      let [h,w] = map read . words $ temp :: [Int]
      if h == 0 && w == 0
        then return list
        else do
        loop (list ++ [[h,w]])



Measured memory_bytes: 4864
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main() {
    int n, x;
    vector<int> m;
    int num = 0;
    int minx = INT32_MAX;
    int tmp;

    cin >> n >> x;

    for (int i = 0; i < n; i++) {
        cin >> tmp;
        m.push_back(tmp);
        num += m[i];
    }

    for(int i = 0; i < (int)m.size(); ++i) {
        if( m[i] < minx )
            minx = m[i];
    }

    x -= num;
    
    while (x >= minx) {
        x -= minx;
        n++;
    }

    cout << n;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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

typedef long long ll;
typedef pair<ll, ll> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  if(n % 1000 == 0) cout << 0 << endl;
  else cout << 1000 - (n % 1000) << endl;
}


Measured memory_bytes: 3636
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace How_many_ways
{
    class Program
    {
        static void Main(string[] args)
        {
            int range = 0;
            int sum = 0;
            List<int> results = new List<int>();

            while(true)
            {
                string input = Console.ReadLine();
                if(input.Equals("0 0"))
                {
                    break;
                }
                string[] temp = input.Split(' ');
                
                range = int.Parse(temp[0]);
                sum = int.Parse(temp[1]);

                int count = 0;

                for (int i = 1; i <= range; i++)
                {
                    for (int j = i + 1; j <= range; j++)
                    {
                        for (int k = j + 1; k <= range; k++)
                        {
                            if (i + j + k == sum)
                            {
                                ++count;
                            }
                        }
                    }
                }

                results.Add(count);
                
            }

            foreach (int item in results)
            {
                Console.WriteLine(item);
            }

            


        }
    }
}



Measured memory_bytes: 18008
#include<iostream>
#include<string>
#include<typeinfo>
using namespace std;
int main()
{
	int n;
	cin >> n;
	int a[n];
	for(int i=0; i<n; i++){
		cin >> a[i];
	}
	
	int cnt=0;
	while(true){
		//	boolean if_alleven=true;
		for(int i=0; i<n; i++){
			if(a[i]%2!=0){
				cout << cnt << endl;
				return 0;
			}
		}
		cnt++;
		for(int i=0; i<n; i++){
			a[i]/=2;	
		}
	}
 
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 100005
#define p 1000000007
using namespace std;
int n;
int cnt[N];
char str[N];
long long ans;
inline void Rd(int &res){
	char c;res=0;
	while(c=getchar(),c<48);
	do res=(res<<3)+(res<<1)+(c^48);
	while(c=getchar(),c>47);
	return;
}
int main(){
	Rd(n);scanf("%s",str+1);
	for(int i=1;i<=n;i++)cnt[str[i]-'a']++;
	ans=1;
	for(int i=0;i<26;i++)ans=ans*(cnt[i]+1)%p;
	ans=(ans+p-1)%p;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 384
import sys

n, m = map(int, sys.stdin.readline().split())
pv = []
for _ in range(m):
    p, s = sys.stdin.readline().split()
    p = int(p) - 1
    v = 1 if s == 'AC' else 0
    pv.append((p, v))

def main():
    wa = [0] * n
    ac = [0] * n
    for p, v in pv:
        wa[p] += (ac[p] | v) ^ 1
        ac[p] |= v
    for p in range(n): wa[p] *= ac[p]
    print(sum(ac), sum(wa))

if __name__ ==  '__main__':
    main()

Measured memory_bytes: 14908
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N, K;
    cin >> N >> K;

    int l[100];
    for (int i = 0; i < N; i++)
    {
        cin >> l[i];
    }
    sort(l, l + N);

    int ans = 0;
    for (int i = N-K; i < N; i++)
    {
        ans += l[i];
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define rev(i,n,a) for(ll i=n-1;i>=a;i--)
#define f first
#define s second
#define vll vector<ll>
#define vvll vector<vector<ll>>
#define vpii vector<pair<int,int>>
#define vpll vector<pll>
#define pll pair<ll,ll>
#define secreterror() ios_base::sync_with_stdio(false);cin.tie(NULL);

void solve(){

    ll n;
    cin>>n;

    string ans="";
    while(n){

        if(n%26==0){
            n=n/26;
            n=n-1;
            ans+='z';
        }
        else
        {
            ll temp=n%26;

            char ch='a'+temp-1;
            ans+=ch;

            n=n/26;
        }
        
    }
    reverse(ans.begin(),ans.end());
    cout<<ans<<endl;
    
}


int main()
{
    secreterror()
    // ll t;
    // cin>>t;
    //while(t--){
        solve();
        
    //}

}

Measured memory_bytes: 3616
/**
*    created: 13.05.2020 17:25:03
**/
#include <bits/stdc++.h>
#define int long long
const int INF = 1e18L + 5;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int n, m; cin >> n >> m;
    vector<int> broken(n+1);
    rep(i,m) {
        int a; 
        cin >> a;
        broken[a] = 1;
    }
    vector<int> dp(n+2);
    dp[n] = 1;
    const int mod = 1000000007;
    dp[n] = 1;
    for (int i = n-1; i >= 0; i--) {
        if (broken[i]) {
            dp[i] = 0;
            continue;
        }
        dp[i] = (dp[i+1] + dp[i+2]) % mod;
    }
    cout << dp[0] << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int dp[1005][1005] = { 0 };
int main() {
	string x, y;
	cin >> x >> y;
	for (int i = 0; i < 1005; i++) dp[i][0] = i;
	for (int i = 0; i < 1005; i++) dp[0][i] = i;
	for (int j = 1; j <= x.size(); j++) {
		for (int k = 1; k <= y.size(); k++) {
			if (x[j-1] == y[k-1]) {
				dp[j][k] = min(dp[j - 1][k] + 1, dp[j][k - 1] + 1);
				dp[j][k] = min(dp[j][k], dp[j - 1][k - 1]);
			}
			else {
				dp[j][k] = min(dp[j - 1][k] + 1, dp[j][k - 1] + 1);
				dp[j][k] = min(dp[j][k], dp[j - 1][k - 1] + 1);
			}
		}
	}
	cout << dp[x.size()][y.size()] << endl;
	return 0;
}


Measured memory_bytes: 7136
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
  
using namespace std;
  
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
  
static const double EPS = 1e-8;
  
static const int tx[] = {0,1,0,-1};
static const int ty[] = {-1,0,1,0};

struct Field{
  int numJ;
  int numO;
  int numI;
  Field() : numJ(0), numO(0), numI(0) {}

};

Field dp[1001][1001];
int main(){
  int W,H;
  while(~scanf("%d %d",&H,&W)){
    int total_queries;
    scanf("%d",&total_queries);
    for(int y=0;y<H;y++){
      char line[1001];
      scanf("%s",line);
      for(int x=0;x<W;x++){
        if(x-1 >= 0) dp[y][x] = dp[y][x-1];
        if(line[x] == 'J') dp[y][x].numJ = (x-1 >= 0 ? dp[y][x-1].numJ + 1 : 1);
        else if(line[x] == 'O') dp[y][x].numO = (x-1 >= 0 ? dp[y][x-1].numO + 1 : 1);
        else if(line[x] == 'I') dp[y][x].numI = (x-1 >= 0 ? dp[y][x-1].numI + 1 : 1);
      }
    }

    for(int query_idx = 0; query_idx < total_queries; query_idx++){
      int lx,ly,rx,ry;
      scanf("%d %d %d %d",&ly,&lx,&ry,&rx);
      ly--; lx--; 
      ry--; rx--; 

      int numJ = 0;
      int numO = 0;
      int numI = 0;
      for(int y=ly;y<=ry;y++){
        numJ += dp[y][rx].numJ - (lx - 1 >= 0 ? dp[y][lx-1].numJ : 0);
        numO += dp[y][rx].numO - (lx - 1 >= 0 ? dp[y][lx-1].numO : 0);
        numI += dp[y][rx].numI - (lx - 1 >= 0 ? dp[y][lx-1].numI : 0);
      }
      printf("%d %d %d\n",numJ,numO,numI);
    }
  }
}

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

#define sp ' '
#define endl '\n'
#define st first
#define nd second
#define sz(x) ((long long int)x.size())
#define pb push_back
#define pob pop_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define forn(YY, yy) for(long long int yy = 0; yy < YY; ++yy)
#define prn(XX) cout << XX << '\n'
#define prs(XX) cout << XX << ' '
#define TEST cout << "TEST\n";

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;

const long long int MOD = 1e9 + 7;
const long long int INF = 2e9 + 13;
const long long int mINF = -2e9 - 13;
const double PI = acos(-1.0);
const double EPS = 1e-9;

ll mx(ll x, ll y){ return (x>y?x:y); }
ll mn(ll x, ll y){ return (x<y?x:y); }

void max_self(ll &x, ll y){ x = mx(x, y); }
void min_self(ll &x, ll y){ x = mn(x, y); }
void add(ll &x, ll y){ x%=MOD; x += (y%MOD); x %= MOD; }
void mul(ll &x, ll y){ x%=MOD; x *= (y%MOD); x %= MOD; }

ll us(ll n, ll x, ll m){
    if(x == 0) return 1;
    ll a = us(n, x>>1, m);
    return (((a*a)%m)*(x&1?n:1))%m;
}

int main(int argc, char **argv){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    ll N, M;
    cin >> N >> M;
    vector<set<ll>> sart(N);
    forn(M, i){
        ll s, c; cin >> s >> c; s--;
        sart[s].insert(c);
    }
    forn(N, i){ if(sart[i].size() > 1){ cout << -1 << endl; return 0; } }
    forn(N, i){ if(*(sart[i].begin()) < 0){ cout << -1 << endl; return 0; } }

    if(sart[0].empty()){
        if(N > 1)
            cout << 1;
        else cout << 0;
        for(ll i = 1; i < N; ++i) cout << *(sart[i].begin());
    }
    else if(*(sart[0].begin()) == 0 and N > 1){ cout << -1 << endl; return 0; }
    else for(ll i = 0; i < N; ++i) cout << *(sart[i].begin());
    
    cout << endl;

    return 0;
}

//cikisir



Measured memory_bytes: 256