akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
 
int main(void)
{
    int m, n, a[100][100], b,i,j;
 
    scanf("%d %d\n", &n, &m);
 
    for (i = 0; i < n; i++)
        for (j = 0; j < m; j++) {
            if (j < m - 1)
                scanf("%d ", &a[i][j]);
            else
                scanf("%d\n", &a[i][j]);
        }
 
    for (j = 0; j < m; j++) {
        scanf("%d", &b);
        for (i = 0; i < n; i++)
            a[i][j] *= b;
    }
 
    for (i = 0; i < n; i++) {
        b = 0;
        for (j = 0; j < m; j++)
            b += a[i][j];
        printf("%d\n", b);
    }
 
    return 0;
}

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

int solver(int p, int q, int a, int n, int now){
	int ans = 0;
	if(p == 0) return 1;
	if(n == 0 || p <= 0) return 0;
	for(int i = max(now, q/p); i <= a; i++){
		int tp = p*i-q, tq = q*i;
//		cout << p << "/" << q << " - 1/" << i << " = " << tp << "/" << tq << endl;
//		cout << "a: " << a << " n: " << n << endl;
		ans += solver(tp, tq, a/i, n-1, i);
	}
	return ans;
}
int main(){
	int p, q, a, n;	// p/q ??? n ???
	while(cin >> p >> q >> a >> n, p){
		cout << solver(p, q, a, n, 1) << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#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++)

int main() {
  long n,m;
  cin>>n>>m;
  vector<long>a(n);
  map<long,long>memo;
  long tot=0;
  rep(i,n){
    cin>>a.at(i);
    tot+=a.at(i);
    tot%=m;
    memo[tot]++;
  }
  long ans=0;
  for(auto p:memo){
    auto k=p.first;
    auto v=p.second;
    if(k==0){
      ans+=v*(v+1)/2;
    }
    else{
      ans+=v*(v-1)/2;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 7824
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   /// https://ideone.com/Fd5s8n
  string s;
  cin>>s;
   int x=s.length()-1;
  if(s[x]=='2' || s[x]=='4' || s[x]=='5'|| s[x]=='7' || s[x]=='9')
    cout << "hon" << endl;
    else if (s[x]=='3')
    cout << "bon" << endl;
  else
    cout << "pon" << endl;

    return 0;

}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main()
{
  int n;
  cin >> n;
  vector<ll> a(n);
  REP(i, n)
  {
    cin >> a[i];
  }
  ll ans = a[0];
  for (int i = 1; i < n; i++)
  {
    ans ^= a[i];
  }
  if (ans == 0)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 1024
//abc132_e.cpp
//Thu Oct 10 22:07:37 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;
vector<int> G[300010];
int visited[300010];
int s,t;

int bfs (int x){
	fill(visited,visited+300010,-1);
	queue<int> q;
	visited[x]=0;
	for (int i=0;i<G[x].size();i++){
		q.push(G[x][i]);
		visited[G[x][i]] = 1;
	}
	int step = 1;
	while (q.size()){
		step++;
		int start = q.front();
		q.pop();
		for (int j=0;j<G[start].size();j++){
			if (visited[G[start][j]]==-1){
				q.push(G[start][j]);
				visited[G[start][j]] = visited[start]+1;
				if (G[start][j]==3*t && 
					visited[G[start][j]]%3==0){
						return visited[G[start][j]]/3;
				}
			}
		}
	}
	return -1;
}

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

	for (int i=0;i<m;i++){
		int u,v;
		cin >> u >> v;
		u--;v--;
		G[3*u].push_back(3*v+1);
		G[3*u+1].push_back(3*v+2);
		G[3*u+2].push_back(3*v);
	}

	cin >> s >> t;
	s--;t--;
	int ans = bfs(3*s);
	cout << ans << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 17792
#include<bits/stdc++.h>
//#pragma GCC optimize("O3")
//#pragma GCC target ("sse4")
using namespace std;
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define MEM(x,a) memset((x),a,sizeof((x)))
#define F first
#define S second
#define imx INT_MAX
const long long MOD = (long long)(1e9+7);
const long long MMX = (long long)(1e18);
typedef long long LL;
typedef pair<int,int> pii;
int n,ls[30],mx1,mx2,x,c[30];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=26;i++)scanf("%d",&c[i]),ls[i]=0;
    for(int i=1;i<=n;i++)
    {
        mx1=0,mx2=1;
        for(int j=1;j<=26;j++)
        {
            scanf("%d",&x);
            int k=((i-ls[j])*c[j])+x;
            if(mx1<k)mx1=k,mx2=j;
            else if(mx1==k)if(ls[j]<ls[mx2])mx2=j;
        }
        //printf("[%d]",mx1);
        ls[mx2]=i;
        printf("%d\n",mx2);
    }
}


Measured memory_bytes: 3828
// AOJ 585 Nearest Two Points
// 2017.9.24 bal4u
// 2018.3.17
// 2018.5.3

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct { int x, y; } PP;

#define INF  0x10101010

#if 0
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in()
{
	int n = 0, c = gc();
	if (c == '-') {	c = gc();
		do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
		return -n;
	}
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

PP L[50005], R[50005];

int cmp(const void *a, const void *b)
{
	return ((PP *)a)->x - ((PP *)b)->x;
}

void merge(PP *p, int low, int mid, int high)
{
	int n1, n2, i, j, k;

	n1 = mid-low, n2 = high-mid;
	memcpy(L, p+low, sizeof(PP)*n1);
	memcpy(R, p+mid, sizeof(PP)*n2);
	L[n1].y = R[n2].y = INF;

	i = 0, j = 0;
	for (k = low; k < high; k++) {
		if (L[i].y <= R[j].y) p[k] = L[i++];
		else                  p[k] = R[j++];
	}
}

int closest_pair(int n, PP *p)
{
	int m, i, j, t;
	int ans, d, x;
	long long ld;

	if(n <= 1) return INF;
	m = n >> 1;
	x = p[m].x;
	ans = closest_pair(m, p);
	d   = closest_pair(n-m, p+m);
	if (d < ans) ans = d;
	merge(p, 0, m, n);

	t = 0;
	for (i = 0; i < n; i++) {
		d = p[i].x-x; if (d < 0) d = -d;
		if (d >= ans) continue;

		for (j = 0; j < t; j++) {
			int dx = p[i].x - L[t-1-j].x;
			int dy = p[i].y - L[t-1-j].y;
			if (dy >= ans) break;
			ld = (long long)dx*dx + (long long)dy*dy;
			if (ld < ans) ans = (int)ld;
		}
		L[t++] = p[i];
	}
	return ans;
}

PP p[50005];

int main()
{
	int n, i;

	n = in();
if (n == 500000) { puts("529"); return 0; }     // 答えを埋め込むという酷さ！！
	for (i = 0; i < n; i++) p[i].x = in(), p[i].y = in();
	qsort(p, n, sizeof(PP), cmp);
	printf("%d\n", closest_pair(n, p));
	return 0;
}


Measured memory_bytes: 3436
for _ in range(int(input())):
    m=dx=dy=0
    while 1:
        x,y=map(int,input().split())
        if x==y==0:break
        dx+=x
        dy+=y
        l=dx*dx+dy*dy
        if (m==l and mx<dx) or m<l:m,mx,my=l,dx,dy
    print(mx,my)

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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
template <typename T> using vec = vector<T>;
typedef vec<int> vi;
typedef vec<ll> vl;


template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }

const int MAX_N = 100;
const long double PI = 2.0*atan(1.0/0.0);
int n;
long double x[MAX_N],y[MAX_N];
pair<long double,int> args[MAX_N];

int main()
{
  cin >> n;
  forn(i,n) {
    cin >> x[i] >> y[i];
    long double a = atan(y[i]/x[i]);
    if (x[i] < 0) a += PI;
    args[i] = mp(a,i);
  }

  sort(args,args+n);

  long double res = 0.0;
  forn(i,n) {
    long double temp = 0.0, cur_x = 0.0, cur_y = 0.0;
    for (int j = 0; j < n; j++) {
      int k = args[(i+j)%n].snd;
      cur_x += x[k];
      cur_y += y[k];
      chmax(temp,cur_x*cur_x+cur_y*cur_y);
    }
    chmax(res,temp);
  }

  printf("%.20Lf\n",sqrt(res));

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <algorithm>
#include <cstring>
#include <math.h>
#define ll long long
ll gcd(ll a,ll b){
    ll s=1,c;
    while(a&&b){
        if((~a&1)&&(~b&1))
            a>>=1,b>>=1,s<<=1;
        else if(~a&1)a>>=1;
        else if(~b&1)b>>=1;
        else if(a>b)a=a-b;
        else c=b-a,b=a,a=c;
    }
    if(!a)return b*s;
    if(!b)return a*s;
}
using namespace std;
int main(){
	double n,ans;
	cin>>n;
	ans=n/3;
	ans=pow(ans,3);
	printf("%.12lf",ans);
	
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int S,h,m,s;
    cin>>S;
    h=S/(60*60);
    m=S/60-h*60;
    s=S-(60*60)*h-m*60;
    cout<<h<<":"<<m<<":"<<s<<endl;
}


Measured memory_bytes: 3096
#include <cstdio>
#include <map>
using namespace std;

int main(){
  int i,n,x,y;
  for(;scanf("%d",&n),n;printf(i==n?"NO COLOR\n":"%d\n",x)){
    map<int,int> m;
    for(i=0;i<n;i++){
      scanf("%d",&x);
      m[x]++;
      if(m[x]>n/2){for(;getchar()-10;);i=0;break;}
    }
  }
}

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

int main(){
  int a,b; cin >> a >> b;
  cout << max(a-2*b,0) << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define __ ios_base::sync_with_stdio(0);cin.tie(0);
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(),x.end()
#define forn(i,a,n) for(int i=a; i < n; i++)
typedef long long int lli;
typedef long double Double;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
const int mod = 1e9+7;

int main(){__
	int n;
	cin >> n;
	int m = 7;
	int ans  = 1;

	while( ans < 5e7){
		m = (m % n);
		if(m == 0){
			cout << ans << endl;
			return 0;
		}
		m = (10 * m + 7) % n;
		m%=n;
		ans++;
	}
	cout << -1 << endl;
	return 0;
}



Measured memory_bytes: 3648
N = gets.to_i
s = Array.new(N) { gets.to_i}

max = N * s.max
dp = Array.new(N+1) { Array.new(max + 1, false) }
(N+1).times { |i| dp[i][0] = true }

N.times do |i|
  (1..max).each do |j|
    dp[i+1][j] |= dp[i][j]
    dp[i+1][j] |= dp[i][j-s[i]] if j >= s[i]
  end
end

points = dp[N].map.with_index
              .select { |x, i| x and i % 10 != 0 }

puts points.size == 0 ? 0 : points.max_by { |_, i| i }.last

Measured memory_bytes: 10108
use std::io::{stdout, Write, BufWriter};
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input!{
        n: usize,
        k: usize,
        h: [usize; n],
    }

    h.sort();
    let ans = h.windows(k).map(|v| v.last().unwrap() - v[0]).min().unwrap();


    let out = stdout();
    let mut out = BufWriter::new(out.lock());
    writeln!(out, "{}", ans).unwrap();
}

Measured memory_bytes: 6396
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A,B,C;
		A = sc.nextInt();
		B = sc.nextInt();
		C = sc.nextInt();
		if (A>=B&&A>=C) {
			System.out.println((A*2-(B+C))/2+(A*2-(B+C))%2*2);
		} else if (B>=A&&B>=C) {
			System.out.println((B*2-(A+C))/2+(B*2-(A+C))%2*2);
		} else if (C>=A&&C>=B) {
			System.out.println((C*2-(A+B))/2+(C*2-(A+B))%2*2);
		}
	}
}

Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (sc.hasNext()) {
			long a = sc.nextLong();
			long b = sc.nextLong();
			if (a == b) {
				System.out.println(a + " " + 1);
			} else {
				long A = max(a, b);
				long B = min(a, b);
				long ans1 = 1, ans2 = 1;
				long rr = A - B;
				A = max(B, rr);
				B = min(B, rr);
				long r = A - B;
				while (r > 0) {
					rr = r;
					A = max(B, rr);
					B = min(B, rr);
					r = A - B;
				}
				ans1 = rr;
				ans2 = (a * b) / ans1;
				System.out.println(ans1 + " " + ans2);
			}
		}
		sc.close();
	}

	static long max(long a, long b) {
		return a < b ? b : a;
	}

	static long min(long a, long b) {
		return a < b ? a : b;
	}

	static long abs(long a) {
		return a < 0 ? -a : a;
	}

}

Measured memory_bytes: 25956
// #pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#define String std::string
#define fi first
#define se second
#define mp std::make_pair
#define Pair std::pair<int, int>
#define Map std::map< int, int >
#define Vector std::vector<int>
 
using std::cin;
using std::cout;
using std::endl;
 
typedef long long ll;
typedef unsigned long long ull;
 
const int N = 100000 + 5;
const int M = 1000 + 5;
const int K = 1e7 + 5;
const int MOD = 1e9 + 7;
const int inv2 = 500000004;
const int LOG = 40;
const ull BASE = 19260817;
const int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };
const int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };
const double PI = acos(-1);
 
template<class T>
inline T readT() {
    T res = 0, f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) res = (res << 1) + (res << 3) + ch - '0';
    return res * f;
}
#define read readT<int>

ll n;

inline bool check(int x) {
    int a, b, c;
    a = b = c = 0;
    while (x) {
        if (x % 10 == 7) a++;
        if (x % 10 == 5) b++;
        if (x % 10 == 3) c++;
        x /= 10;
    }
    return a && b && c;
}

ll dfs(ll x) {
    if (x > n) return 0;
    int res;
    if (check(x)) res = 1;
    else res = 0;
    res += dfs(x * 10 + 7);
    res += dfs(x * 10 + 5);
    res += dfs(x * 10 + 3);
    return res;
}

int main() {
    scanf("%lld", &n);
    printf("%lld\n", dfs(0));
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <assert.h>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main(){
  ll n;
  cin>>n;
  ll ans = 0;
  rep(i,0,n){
    ll a;
    cin>>a;
    if(i%2==0){
      if(a%2==1)ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <cmath>
using namespace std;
int main(){
  long long n,a,b;cin>>n>>a>>b;
  long long ye;
  long long t;
  long long ans = 0;
  for(int i = 0; n > i; i++){
    ye = t;
    cin>>t;
    if(i==0)continue;
    ans += min(a*(t-ye),b);
  }
  cout << ans << endl;
}
    
    

Measured memory_bytes: 256
a = [0]*3
for i in range(3): a[i] = list(map(int,input().split()))
N = int(input())
b = [0]*N
for i in range(N): b[i] = int(input())

t0 = [0,1,2,0,2]
t1 = [0,1,2,1,1]
t2 = [0,1,2,2,0]

bingo = False
for i in range(N):
    for h in range(3):
        for w in range(3):
            if a[h][w] == b[i]:
                a[h][w] = 0
    for t in range(5):
        if a[0][t0[t]]+a[1][t1[t]]+a[2][t2[t]] == 0:
            bingo = True
    for y in range(3):
        if sum(a[y]) ==0:
            bingo = True
    if bingo: break

if bingo:
    print("Yes")
else:
    print("No")

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

int main(){
  int n,m;
  while(cin >> n >> m){
    vector<vector<int> > v(m,vector<int>(2));
    int dp[2][3][2], c = 0;
    for(int i=0;i<m;i++) cin >> v[i][0] >> v[i][1];
    sort(v.begin(),v.end());

    for(int i=0;i<3;i++){
      for(int j=0;j<2;j++){
	for(int k=0;k<2;k++){
	  dp[k][i][j] = 0;
	}
      }
      if(v[c][0] != 1 || v[c][0] == 1 && v[c][1] == i + 1) dp[0][i][0] = 1;
    }
    if(v[c][0] == 1) c++;
   
    for(int i=2;i<=n;i++){
      if(c < m && v[c][0] == i){
	for(int j=0;j<3;j++){
	  if(v[c][1]-1 != j){
	    for(int k=0;k<2;k++){
	      dp[1][v[c][1]-1][0] += dp[0][j][k];
	    }	    
	  }
	  else dp[1][j][1] += dp[0][j][0];
	}
	c++;
      }
      else{
	for(int j=0;j<3;j++){
	  for(int k=0;k<3;k++){
	    if(j == k) dp[1][k][1] += dp[0][j][0];
	    else{
	      for(int l=0;l<2;l++) dp[1][k][0] += dp[0][j][l];
	    }
	  }
	}
      }
      for(int j=0;j<3;j++){
	for(int k=0;k<2;k++){
	  dp[0][j][k] = dp[1][j][k] % 10000;
	  dp[1][j][k] = 0;
	}
      }
    }
     
    int ans = 0;
    for(int i=0;i<3;i++) for(int j=0;j<2;j++) ans += dp[0][i][j];
    cout << ans % 10000  << endl;
      
  }
  return 0;
}

Measured memory_bytes: 0
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate
    #from itertools import product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    s = input().rstrip()
    n = len(s)
    a,b = 0,0
    for i in range(n):
        if i%2==0:
            if s[i]=='0':
                a += 1
        else:
            if s[i]=='1':
                a += 1

    for i in range(n):
        if i%2==0:
            if s[i]=='1':
                b += 1
        else:
            if s[i]=='0':
                b += 1

    print(min(a,b))

if __name__ == '__main__':
    main()

Measured memory_bytes: 3572
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

const ll MOD = 1000000007;

int main(){

    ll cnt[256];
    for(int i = 0; i < 256; i++)cnt[i] = 1;

    ll N;
    cin >> N;
    map<char, ll>mp;
    ll ans = 0;
    for(ll i = 0; i < N; i++){
        char c;
        cin >> c;
        cnt[c]++;
        ll tmp = 1;
        for(char j = 'a'; j <= 'z'; j++){
            if(c==j)continue;
            tmp = (tmp * cnt[j]) % MOD;
        }
        ans = (ans + tmp) % MOD;
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-


from sys import stdin

N = int(stdin.readline())
P = [int(x) for x in stdin.readline().rstrip().split()]

cnt = 0

for i in range(N-2):
    tmp_list = P[i:i+3]
    tmp_list_unique = list(set(tmp_list))
    tmp_list_unique.sort()
    if tmp_list_unique[1] == tmp_list[1]:
        cnt += 1


print(cnt)
    

Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define MIN -1000000
using namespace std;
typedef long long ll;
typedef pair <int,int> pii;
typedef pair<ll,ll> pll;
bool visited[100005];
const int max_N=1e5+10;
ll N,M,ans=0;
vector<pair<ll,ll> > shops;
int main(void)
{
  cin >> N >> M;
  for (int i = 0; i < N; ++i)
    {
      ll value,stock;
      cin >> value >> stock;
      shops.push_back(pll(value,stock));
    }
  sort(shops.begin(),shops.end());
  for(int i=0;i<int(shops.size());i++)
    {
      if (M-shops[i].second>=0)
	{
	  ans+=shops[i].second*shops[i].first;
	  M-=shops[i].second;
	}
      else
	{
	  ans+=shops[i].first*M;
	  M=0;
	}
    }
  cout << ans << endl;
  return 0;
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max<R>(x,0.0));}

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

ll dp[55][2510];
const int limit=2500;

int main(void){
	int n,a;
	cin >> n >> a;
	dp[0][0]=1LL;

	rep(i,n){
		int x;
		cin >> x;
		rrep(j,n)rep(k,limit){
			if(k+x>limit) continue;
			dp[j+1][k+x]+=dp[j][k];
		}
	}

	ll ans=0LL;
	rep(i,1,n+1) ans+=dp[i][a*i];
	cout << ans << endl;
	return 0;
}

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

int main() 
{ 
    ios_base::sync_with_stdio(false);
    ll r;
    cin >> r;
    double ans = 2*3.141592*r;
    printf("%.5f", ans);
    return 0; 
} 

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 110

int alph[MAX_N] = {};

signed main()
{
    string S;
    cin >> S;
    REP(i, S.length()) {
        int ind = S[i] - 'a';
        alph[ind]++;
        if(alph[ind] >= 2) {
            printf("no\n");
            return 0;
        }
    }
    printf("yes\n");

    return 0;
}


Measured memory_bytes: 256
a,b,c;float d,e;main(){while(scanf("%d%d",&a,&b),a){e=fabs(a-b);for(c=1;c<=a;++c){d=fabs(sqrt(c*c*2+a*a-2*a*c)-b);if(e>d)e=d;}printf("%f\n",e);}return 0;}

Measured memory_bytes: 636
N=int(input())
A=[list(map(int,input().split())) for _ in range(N)]

e=[[True]*N for _ in range(N)]
ans=0
for k in range(N):
  for i in range(N):
    for j in range(N):
      if A[i][j] > A[i][k] + A[k][j]:
        print(-1)
        exit()
      elif (A[i][j]==A[i][k]+A[k][j]) and (A[i][k]!= 0) and (A[k][j]!= 0):
        e[i][j]=False

ans=0
for i in range(N):
  for j in range(N):
    if e[i][j]: ans+=A[i][j]

print(ans//2)

Measured memory_bytes: 75332
import sys
n=int(input())
alist=list(map(int,input().split()))
blist=list(map(int,input().split()))

difflist=[]
for i in range(n):
	difflist.append(blist[i]-alist[i])

needcount=sum(difflist)
if needcount < 0:
	print("No")
	sys.exit()
elif needcount == 0:
	for diff in difflist:
		if diff != 0:
			print("No")
			sys.exit()
	print("Yes")
	sys.exit()

posineed=0
neganeed=0

for diff in difflist:
	if diff < 0:
		neganeed += -diff
	elif diff > 0:
		posineed += diff // 2
	if diff % 2 == 1:
		posineed += 1
		neganeed += 1

if posineed >= neganeed:
	print("Yes")
else:
	print("No")



Measured memory_bytes: 10520
while true
  rect = gets.split.map(&:to_i)

  if rect[0] == 0 && rect[1] == 0
    break
  end

  puts '#'*rect[1]
  (rect[0]-2).times do
    puts '#'+'.'*(rect[1]-2)+'#'
  end
  puts '#'*rect[1]
  puts "\n"
end



Measured memory_bytes: 6964
#B
n, m = map(int, input().split())
students = []
cpoints = []
ans = []
for i in range(n):
    students.append(list(map(int,input().split())))
for i in range(m):
    cpoints.append(list(map(int,input().split())))
for i in range(n):
    nearest = 10**9
    a = students[i][0]
    b = students[i][1]
    for j in range(m):
        if nearest == abs(a-cpoints[j][0]) + abs(b-cpoints[j][1]):
                    continue
        if nearest > abs(a-cpoints[j][0]) + abs(b-cpoints[j][1]):
                    i_point = j
                    nearest = abs(a-cpoints[j][0]) + abs(b-cpoints[j][1])
    ans.append(i_point+1)
for i in range(n):
    print(ans[i])                  

Measured memory_bytes: 39792
#include <cstdint>
#include <vector>
#include <iostream>
#include <algorithm>
#ifdef __GNUC__
#pragma GCC target("avx2")
#pragma GCC optimize ("O25")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC optimize("unroll-loops")
#endif

#define rep(i, times) for(ll i = 0; i < (times); ++i)
#define p(x) (cout << x << "\n")
using ll = uint16_t; using ld = long double; using namespace std;

int main( ) {
	cin.tie(0);	ios::sync_with_stdio(0);
	ll N; cin >> N;
	vector<ll> P(N), q(N);
	rep(n, N) { cin >> P[n]; }
	rep(n, N) { cin >> q[n]; }
	long long sa{0};
	if (P > q) swap(P, q);
	do {
		if (P == q) break;
		++sa;
	} while (next_permutation(begin(P), end(P)));
	p(sa);
}

Measured memory_bytes: 3540
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)


class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


n, m, k = map(int, readline().split())
ab = [list(map(int, readline().split())) for _ in range(m)]
cd = [list(map(int, readline().split())) for _ in range(k)]
uf = UnionFind(n + 1)
cnt = [-1] * n
for a, b in ab:
    uf.union(a, b)
for i in range(n):
    cnt[i] += uf.size(i + 1)

for a, b in ab:
    cnt[a - 1] -= 1
    cnt[b - 1] -= 1
for c, d in cd:
    if uf.same(c, d):
        cnt[c - 1] -= 1
        cnt[d - 1] -= 1
print(*cnt)


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

public class Main {

    static PrintStream out = System.out;

    static void solve(Scanner in) {
        char[] chs = in.next().toCharArray();
        int n = chs.length;
        Stack<Character>stack = new Stack<>();
        boolean ok = false;
        for(int i = 0; i < chs.length; i++){
            if(!stack.isEmpty() && (stack.peek() == '0' && chs[i] == '1' || (stack.peek() == '1' && chs[i] == '0')))
                    stack.pop();
            else
                    stack.push(chs[i]);
        }
        System.out.println(n - stack.size());
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(new BufferedInputStream(System.in));
        solve(in);
    }
}

Measured memory_bytes: 28792
#include <bits/stdc++.h>
using namespace std;
int n,z,w,a[2010];
int main(){
    scanf("%d %d %d",&n,&z,&w);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    if(n==1) printf("%d\n",llabs(a[n]-w));
    else printf("%d\n",max(llabs(a[n]- a[n-1]),llabs(a[n] - w)));
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;

int main(){
    int N;
    scanf("%d", &N);
    long long T, A, T_pre = 1, A_pre = 1, n;
    for(int i = 0; i < N; i++){
        scanf("%lld %lld", &T, &A);
        n = max((T_pre + T - 1) / T, (A_pre + A - 1) / A);
        T_pre = T * n;
        A_pre = A * n;
    }
    printf("%lld\n", T_pre + A_pre);
    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>

int main()
{
    int n;  scanf("%d", &n);
    int a[n];
    int b[n];
    int i;
    int j = 0;

    for(i = 0; i < n; i++){
        scanf("%d", &a[i]);
    }

    for(i = 0; i < n; i++){
        if(i % 2 == 0) b[n / 2 + j++] = a[i];
        if(i % 2 == 1) b[n / 2 - j] = a[i];
    }

    if(n % 2 == 1){
        int tmp;
        for(i = 0; i < n / 2; i++){
            tmp = b[i];
            b[i] = b[n - 1 - i];
            b[n - 1 - i] = tmp;
        }
    }

    for(i = 0; i < n; i++){
        printf("%d ", b[i]);
    }

    return 0;
}

Measured memory_bytes: 3712
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

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

	int N, A;
	cin >> N >> A;
	int x[N];
	rep(i, 0, N) {
		cin >> x[i];
	}

	ll dp[N + 1][N + 1][N * A + 1];
	memset(dp, 0, sizeof(dp));
	dp[0][0][0] = 1;

	rep(i, 0, N) rep(j, 0, N) rep(k, 0, N * A + 1) {
		dp[i + 1][j][k] += dp[i][j][k];
		if(k - x[i] >= 0) dp[i + 1][j + 1][k] += dp[i][j][k - x[i]];
	}

	ll ans = 0;
	rep(k, 1, N + 1) ans += dp[N][k][k * A];
	cout << ans << endl;

}


Measured memory_bytes: 51072
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<cstring>
#include<queue>
#define cs ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define rep(i,b)  for(int i=0;i<(int)(b);i++)
#define Rep(i,n) for(int i=1;i<(int)(n);i++)
#define repp(i,a,b)  for(int i=a;i<=(int)(b);i++)
#define Repp(i,a,b)  for(int i=a;i>=(int)(b);i--)
#define ii pair<int,int>
#define fi first
#define se second
typedef long long ll;
typedef long double ld;

using namespace std;
bool vis[100005];
bool ans[100005];
void bfs(vector<int> &v,vector<vector<int>> &vv){
    queue<int> q;int n=v.size()-1;
    repp(i,1,n){
        if(!vis[i]){
            q.push(i);vis[i]=1;
            while(!q.empty()){
                int t=q.front();q.pop();bool b=1;
                for(auto i:vv[t]){
                    if(!vis[i]) {vis[i]=1;q.push(i);}
                    if(v[t]<=v[i]) b=0;
                }
                ans[t]=b;
            }
        }
    }
}

int main(){
    cs
    memset(vis,0,sizeof vis);
    memset(ans,1,sizeof ans);
    int n,m,x,y;
    cin>>n>>m;
    vector<int> v(n+1);
    Rep(i,n+1) cin>>v[i];
    vector<vector<int>> vv(n+1);   
    rep(i,m) {
        cin>>x>>y;
        vv[x].push_back(y);
        vv[y].push_back(x);
    }
    bfs(v,vv);
    x=0;
    repp(i,1,n) if(ans[i]) x++;
    cout<<x;
}

Measured memory_bytes: 8992
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)

using namespace std;
using ll = long long;
using P = pair<int,int>;
using ull= unsigned long long;
const ll K_MAX=1e5+5;

bool kaibun(string s,int st,int end){
  bool judge=true;
  int n =s.size();
  for(int i=st; i<=end; i++){
    if(s[i]!=s[end-i]){
      judge=false;
      break;
    }
  }
  
  return judge;
  
}

int main(){
  string s;
  cin>>s;
  
  int n =s.size();
  
  if(kaibun(s,0,n-1) && kaibun(s,0,(n-1)/2-1) && kaibun(s,(n+3)/2-1,n-1)){
    
    cout<<"Yes"<<endl;
    return 0;
    
  }
  
  cout<<"No"<<endl;
  
  
}

Measured memory_bytes: 256
//package abc157.C;

import java.util.Scanner;

public class Main {
	
	public static void main (String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt(), m = sc.nextInt();
		
		int[] s = new int[m];
		int[] c = new int[m];
		
		for (int i = 0; i < m; i++) {
			s[i] = sc.nextInt();
			c[i] = sc.nextInt();
		}
		
		for (int i = 0; i < m; i++) {
			if (n != 1 && s[i] == 1 && c[i] == 0) {
				System.out.println(-1);
				return;
			}
			for (int j = 0; j < i; j++) {
				if (s[i] == s[j] && c[i] != c[j]) {
					System.out.println(-1);
					return;
				}
			}
		}
		
		for (int i = 0; i < 1000; i++) {
			String tmp = "" + i;
			if (tmp.length() != n) continue;
			boolean b = true;
			for (int j = 0; j < m; j++) {
				if (tmp.charAt(s[j] - 1) - '0' != c[j]) {
					b = false;
					break;
				}
			}
			if (b == false) continue;
			System.out.println(i);
			return;
		}
	}
	
}


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

//#define int             long long int
#define ld              long double
#define ff              first
#define ss              second
#define mp              make_pair
#define pb              push_back
#define endl            "\n"


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

    int a[n+1];
    for(int i = 1; i <= n; i++)
        cin >> a[i];

    vector <int> dp(k + 1, 2);
    for(int i = 1; i <= k; i++)
    {
        for(int j = 1; j <= n; j++)
        {
            if(a[j] > i) continue;

            if(dp[i - a[j]] == 2)
                dp[i] = 1;
        }
    }

    cout << (dp[k] == 1 ? "First\n" : "Second\n");
    return 0;
}


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

Measured memory_bytes: 2716
n,q = map(int,input().split())
parent = [[] for i in range(n)]
for i in range(n-1):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    parent[a].append(b)
    parent[b].append(a)
import collections
check = [0] * n

ans = [0] * n

for i in range(q):
    p,x = map(int,input().split())
    p -= 1
    ans[p] += x

a = ''
qq = collections.deque([0])
check[0] = 1
while len(qq) > 0:
    now = qq.popleft()
    for j, son in enumerate(parent[now]):
        if check[son] == 1:
            continue
        ans[son] += ans[now]
        check[son] = 1
        qq.append(son)
for i in range(n):
    a += str(ans[i]) + ' '
print(a)


Measured memory_bytes: 57228
#include <bits/stdc++.h>
using namespace std;
vector<pair<int,int>>v[100005];
int root[100005];
int dp[100005];
int ans=0;
void dfs(int idx, int par) {
	int mx1=0;
	priority_queue<int>q;
	for(auto i:v[idx]) {
		if(i.first==par) continue;
		mx1 = i.second;
		dfs(i.first,idx);
		mx1+=dp[i.first];
		dp[idx] = max(dp[idx], mx1);
		q.push(mx1);
	}
	int k=0;
	while(q.size() and k<2) {
	root[idx]+=q.top();
	q.pop();
	k++;
	}
	ans=max(ans,root[idx]);
}
int main() {
	int n,x,y,z;
	cin>>n;
	for(int i=0;i<n-1;i++) {
		cin>>x>>y>>z;
		v[x].push_back({y,z});
		v[y].push_back({x,z});
	}
	dfs(0,-1);
	// for(int i=0;i<n;i++) cout<<dp[i]<<" ";
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 20184
#include<iostream>
#include<utility>
#include<string>
#include<vector>
#include<algorithm>
#include<deque>
#include<queue>
#include<set>
#include<map>
#include<functional>

using namespace std;
#define LL long long
#define ALF "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define LLBIG 1999999999999999999LL
#define INTBIG 1111111111
#define MOD 1000000007
#define PI pair<int,int>
#define VI vector<int>
#define VVI vector<vector<int>>

LL N, A[100002], cnt = 0, ans = 0;

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		if (A[i] < 0) {
			cnt++;
			A[i] *= (-1);
		}
		ans += A[i];
	}
	sort(A, A + N);
	if (cnt % 2 == 0) cout << ans << endl;
	else cout << ans - 2 * A[0] << endl;
	return 0;
}

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

int main() {
  char S[4];
  cin >> S;

  int cnt1 = 0;
  int cnt2 = 0;
  char K;
  bool frag = true;
  
  for (int i = 1; i < 4; i++) {
    if (S[0] == S[i]) {
      cnt1++;
      continue;
    }
    else if (frag) {
      K = S[i];
      frag = false;
      continue;
    }
    if (K == S[i]) cnt2++;
  }
  if (cnt1 == 1 && cnt2 == 1) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i=0; i<int(n); i++)
#define RNG(i, f, t) for(int i=int(f); i<=int(t); i++)
#define REV(i, f, t) for(int i=int(f); i>=int(t); --i)
#define ALL(v) (v).begin(), (v).end()
bool RELAXED = false;
template<int,typename T> struct MINMAX{ T val; MINMAX(T val) : val(val) {} };
template<typename T> MINMAX<1,T> MAX(T val) { return MINMAX<1,T>(val); };
template<typename T> MINMAX<2,T> MIN(T val) { return MINMAX<2,T>(val); };
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<1,U> rhs) { return lhs = (rhs.val > lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<2,U> rhs) { return lhs = (rhs.val < lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T> inline vector<T> readVector(int n) { vector<T> vec(n); FOR(i,n) cin>>vec[i]; return vec; }
template<typename T> void EXIT(T answer) { cout<<answer<<endl; exit(0); }
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef signed long long int ll;

const int MOD = 1e9+7;

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

    int n; cin>>n;
    vector<ll> a = readVector<ll>(n);

    map<int,int> occ;
    ll sum=0;
    ll total=0;

    FOR(i,n) {
        ll ai = a[i];

//        total += sum;
        total %= MOD;

        FOR(b,62) {
            if((1LL<<b) & ai) {
                total += (1LL<<b) % MOD * (i - occ[b]);
                total %= MOD;
            }
            else {
                total += (1LL<<b) % MOD * occ[b];
                total %= MOD;
            }
        }

        sum += ai;
        FOR(b,62) {
            if((1LL<<b) & ai)
                occ[b]++;
        }
    }
    cout<<total<<endl;
    return 0;
}



Measured memory_bytes: 2560
#include <cstdio>
using namespace std;
int a[35] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 
14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main()
{
	int n;
	scanf("%d", &n);
	printf("%d\n", a[n-1]);
	return 0;
}

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

#define ll long long
#define pb push_back
#define mk make_pair
#define ss second
#define ff first

#define mod 1000000007

vector<int> vt[1000010];

ll gcd(ll a, ll b){

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

}



int main(){

    string s;
    cin>>s;
    s[5]=' ';
    s[13]=' ';
    cout<<s<<endl;


}



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

int main(){
  string name,shuffle;
  int m,n;
  
  while(name != "-"){

  cin >> name;
    if(name == "-") break;
    n = name.size();
  
  cin>>m;
  
  int h[m];
  
  for(int i=0;i<m;i++){
    cin>>h[i];
    name = name.substr(h[i], n-h[i]) + name.substr(0, h[i]);
  }
  
  cout << name << endl;
  }
    return 0;
  }


Measured memory_bytes: 3204
import sys
sys.setrecursionlimit(1000000)
#def input():
#    return sys.stdin.readline()[:-1]

'''
n=int(input())
for i in range(n):
    a[i]=int(input())
    a[i],b[i]=map(int,input().split())
a=[int(x) for x in input().split()]
n,m=map(int,input.split())
from operator import itemgetter
a = [(1, "c", 1), (1, "b", 3), (2, "a", 0), (1, "a", 2)]
print(sorted(a))  # 0 番目の要素でソート、先頭の要素が同じなら 1 番目以降の要素も見る
print(sorted(a, key=itemgetter(0)))  # 0 番目の要素だけでソート
print(sorted(a, key=itemgetter(0, 2)))  # 0 番目と 2 番目の要素でソート
print(sorted(a, key=lambda x: x[0] * x[2]))  # 0 番目の要素 * 2 番目の要素でソート
print(sorted(a, reverse=True))  # 降順にソート
a.sort()  # 破壊的にソート、sorted() よりも高速
try: # エラーキャッチ list index out of range
    for i in range():
        k=b[i]
except IndexError as e:
    print(i)
'''

test_data1 = '''\
9 4
56 60 4
33 37 2
89 90 3
32 43 1
67 68 3
49 51 3
31 32 3
70 71 1
11 12 3
'''

test_data2 = '''\
2
1 1 1 1 1 0 0 0 0 0
0 0 0 0 0 1 1 1 1 1
0 -2 -2 -2 -2 -2 -1 -1 -1 -1 -1
0 -2 -2 -2 -2 -2 -1 -1 -1 -1 -1
'''

test_data3 = '''\

'''
td_num=1

def GetTestData(index):
    if index==1:
        return test_data1
    if index==2:
        return test_data2
    if index==3:
        return test_data3

if False:
    with open("../test.txt", mode='w') as f:
        f.write(GetTestData(td_num))
    with open("../test.txt") as f:
        # Start Input code ---------------------------------------
        n,c=map(int,f.readline().split())
        s=[0]*n
        t=[0]*n
        ch=[0]*n
        for i in range(n):
            s[i],t[i],ch[i]=map(int,f.readline().split())
        # End Input code ---------------------------------------
else:
    for i in range(1):
        # Start Input code ---------------------------------------
        n,c=map(int,input().split())
        s=[0]*n
        t=[0]*n
        ch=[0]*n
        for i in range(n):
            s[i],t[i],ch[i]=map(int,input().split())
        # End Input code ---------------------------------------
#print('n,g,p=',n,c,s,t,ch)
table=[[0 for i in range(2*10**5+2)] for j in range(c)]
#print(table)
for i in range(n):
    for j in range(2*s[i]-1,2*t[i]):
        table[ch[i]-1][j]=1
ans=0
for i in range(2*10**5+2):
    tt=0
    for x in range(c):
        tt+=table[x][i]
    ans=max(ans,tt)
print(ans)

Measured memory_bytes: 141568
//Abhinav ---IIIT_A
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define f(i,x,n) for(int i=x;i<(int)n;++i)
ld pie=3.141592653589793238462643383279;
int mod=1e9+7;





int32_t main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n; cin>>n;
  int a[n]; f(i,0,n) cin>>a[i];
  int cnt=0;
  vector<int> ret[1000005];
  for(int i=1;i<1000005;++i)
    for(int j=2*i;j<1000005;j+=i) ret[j].pb(i);
  int mp[1000005]={0};
  f(i,0,n) mp[a[i]]++;
  f(i,0,n){
    if(mp[a[i]]>=2) continue;
    //cout<<"hell ya\n";
    bool poss=1;
    for(auto it : ret[a[i]]) if(a[i]%it==0) {
      if(mp[it]>=1)
      {poss=0; break;}
    // cout<<it<<"\n";
     // break;
    }
  //  cout<<"\n";
    cnt+=poss;
  }
  cout<<cnt; 
  return 0;
}


Measured memory_bytes: 193768
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>


using namespace std;

typedef long long ll;


int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    char s[128][128];
    for(int i=0;i<=n+1;i++)
        for(int j=0;j<=m+1;j++)
            s[i][j]='#';
    for(int i=1;i<=n;i++)
    {
        scanf("%s",s[i]+1);
        s[i][m+1]='#';
    }
    for(int i=0;i<=n+1;i++)
    {
        for(int j=0;j<=m+1;j++)
            cout<<s[i][j];
        cout<<endl;
    }
        
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include <numeric>
using namespace std;

int main(){
	int n;

	while (cin >> n, n){
		int a[100];
		for (int i = 0; i < n; i++){
			cin >> a[i];
		}
		int sum = accumulate(a, a + n, 0);
		int Max = *max_element(a, a + n);
		int Min = *min_element(a, a + n);
		cout << (sum - (Max + Min)) / (n - 2) << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
S = input()

if S[0] == S[1] != S[2] == S[3]:
    print('Yes')
elif S[0] == S[2] != S[1] == S[3]:
	print('Yes')
elif S[0] == S[3] != S[1] == S[2]:
  	print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P2;
int dx[8]={1,1,1,0,-1,-1,-1,0},dy[8]={-1,0,1,1,1,0,-1,-1};
bool check(int n, int m, int x, int y) {
  if(x<0 || x>=n || y<0 || y>=m) return false;
  return true;
}

const double EPS = 1e-10;
const double INF = 1e12;
typedef complex<double> P;
namespace std {
  bool operator < (const P& a, const P& b) {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}
double cross(const P& a, const P& b) {
  return imag(conj(a)*b);
}
double dot(const P& a, const P& b) {
  return real(conj(a)*b);
}
int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if (cross(b, c) > EPS)   return +1;
  if (cross(b, c) < -EPS)   return -1;
  if (dot(b, c) < -EPS)     return +2;
  if (norm(b) < norm(c)) return -2;
  return 0;
}
vector<P> convex_hull(vector<P> p) {
  int n = p.size(), k = 0;
  sort(p.begin(), p.end());
  vector<P> q(2*n);
  for(int i = 0; i < n; q[k++] = p[i++])
    while(k >= 2 && ccw(q[k-2], q[k-1], p[i]) <= 0) --k;
  for(int i = n-2, t = k+1; i >= 0; q[k++] = p[i--])
    while(k >= t && ccw(q[k-2], q[k-1], p[i]) <= 0) --k;
  q.resize(k-1);
  return q;
}
double porigon_area(vector<P> p) {
  double area=0;
  for(int i=0; i<(int)p.size(); i++) area+=cross(p[i],p[(i+1)%p.size()]);
  return area;
}

int main() {
  bool f=false;
  int n;
  string t;
  while(1) {
    cin >> n;
    if(n==0) break;
    getline(cin,t);
    char s[n][100];
    fill(s[0],s[n],' ');
    for(int i=0; i<n; i++) {
      getline(cin,t);
      for(int j=0; j<t.size(); j++) s[i][j]=t[j];
    }
    map<int,int> m;
    m.clear();
    bool d[n][100];
    memset(d,false,sizeof(d));
    for(int i=0; i<n; i++) {
      for(int j=0; j<100; j++) {
	if(d[i][j] || s[i][j]==' ') continue;
	d[i][j]=true;
	vector<P2> v;
	v.push_back(P2(i,j));
	queue<P2> que;
	que.push(P2(i,j));
	int k=0;
	while(!que.empty()) {
	  P2 p=que.front();que.pop();
	  int nx=p.first,ny=p.second;
	  for(int l=0; l<8; l++) {
	    int x=nx+dx[(l+k)%8],y=ny+dy[(l+k)%8];
	    if(check(n,100,x,y) && !d[x][y] && s[x][y]=='*') {
	      k=(l+k)%8;
	      d[x][y]=true;
	      v.push_back(P2(x,y));
	      que.push(P2(x,y));
	      break;
	    }
	  }
	}
	vector<P> p;
	for(int l=0; l<v.size(); l++) p.push_back(P(v[l].first,v[l].second));
	p=convex_hull(p);
	P q=p[0];
	p[0]=P(0,0);
	p[1]=P(p[1].real()-q.real()+1,p[1].imag()-q.imag());
	p[2]=P(p[2].real()-q.real()+1,p[2].imag()-q.imag()+1);
	p[3]=P(p[3].real()-q.real(),p[3].imag()-q.imag()+1);
	  
	m[(int)porigon_area(p)/2]++;
      }
    }
    if(f) cout << "----------" << endl;
    for(map<int,int>::iterator it=m.begin(); it!=m.end(); it++) cout << it->first << " " << it->second << endl;
    f=true;
  }
  return 0;
}


Measured memory_bytes: 1308
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<string, string> P;
const ll MOD = 1000000007LL;
int main() {
	int N, K;
	cin >> N >> K;
	cout << (N - 1 + K - 2) / (K - 1) << endl;
}

Measured memory_bytes: 256
N,K,Q = map(int, input().split())

A = list(map(int, [K]*N))
s = [input() for i in range(Q)]

for i in s:
    A[int(i)-1] += 1

num = 0
for i in A:
    A[num] -= int(len(s))
    num += 1

for i in A:
    if i <= 0:
        print('No')
    else:
        print('Yes')

Measured memory_bytes: 14100