akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <queue>
#include <string.h>
#define P pair<int,int>
using namespace std;
int dh[]={-1,0,1,0};
int dw[]={0,-1,0,1};
char field[100][100];
int H,W;
bool input() {
	cin >> H >> W ; if(!H && !W) return false;
	for(int i=0;i<H;i++) for(int j=0;j<W;j++) cin >> field[i][j] ;
	return true;
}
bool inBoard(int h,int w) {
	if(0<=h && h<H && 0<=w && w<W) return true;
	return false;
}
int main() {
	while(input()) {
		bool tmp[100][100]={0}; queue<P> q;
		int cnt=0;
		for(int i=0;i<H;i++) {
			for(int j=0;j<W;j++) {
				if(tmp[i][j]) continue;
				q.push(P(i,j)); tmp[i][j]=true; cnt++;
				while(!q.empty()) {
					int h,w;
					h=q.front().first; w=q.front().second; q.pop();
					for(int k=0;k<4;k++) {
						if(!inBoard(h+dh[k],w+dw[k]) || field[i][j]!=field[h+dh[k]][w+dw[k]] || tmp[h+dh[k]][w+dw[k]])
							continue;
						q.push(P(h+dh[k],w+dw[k])); tmp[h+dh[k]][w+dw[k]]=true;
					}
				}
			}
		}
		cout << cnt << '\n' ;
	}
}

Measured memory_bytes: 1236
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n); i++) 
#define dunk(n) cout << n << endl
#define all(a) (a).begin(),(a).end()
typedef pair<int,int> P;
typedef long long ll;

int main() {
    char x;
    cin >> x;
    if(isupper(x)){
        dunk('A');
    }
    else dunk('a');
    return 0;
}

Measured memory_bytes: 3632
x = int(input())
if x <= 11:
    if x <= 6:
        print(1)
    else:
        print(2)
else:
    ans = (x // 11) * 2
    x = x % 11
    if x == 0:
        print(ans)
    elif x <= 6:
        print(ans + 1)
    else:
        print(ans + 2)

Measured memory_bytes: 9176
s = list(input())

mode = 0
count = 0

ans = 0

for c in s:
    if mode == 0:
        if c == 'W':
            continue
        else:
            mode = 1
            count = 1
    else:
        if c == 'B':
            count += 1
        else:
            ans += count

print(ans)




Measured memory_bytes: 4840
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef pair<int, int> pint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(int a, int b) {
	return a > b;
}

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//aCbを1000000007で割った余りを求める
llint convination(llint a, llint b) {
	llint ans = 1;
	for (llint i = 0; i < b; i++) {
		ans *= a - i;
		ans %= 1000000007;
	}
	for (llint i = 1; i <= b; i++) {
		ans *= modinv(i, 1000000007);
		ans %= 1000000007;
	}
	return ans;
}

int main() {
	vint a;
	while (1) {
		int x;
		cin >> x;
		if (x != 0)a.push_back(x);
		else {
			break;
		}
	}
	rep(i, a.size()) {
		cout << "Case " << i + 1 << ": " << a[i] << endl;
	}
	return 0;
}


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

int main(){
   int n;
   cin >> n;
   int m = n;
   int sum = 0;
   while(m) sum += m%10, m /= 10;
   cout << (n % sum == 0 ? "Yes" : "No") << endl;
   return 0;
}

Measured memory_bytes: 384
# include <iostream>
# include <vector>
# include <queue>
# include <functional>
# include <algorithm>

constexpr int MAX_N = 100000, INF = (int)1e7, MAX_M = 200000;

using ll = long long int;
using P = std::pair<ll, ll>;

struct edge {
	int to_, cost_;
	edge() = default;
	bool canfree = false;
	edge(int to, int cost) : to_(to), cost_(cost) {}
};

int n, m, c;
ll sum;

std::vector<edge> G[MAX_N];

int d[MAX_N];
P data[MAX_M];
int A[MAX_M], B[MAX_M], D[MAX_M];

void dijkstra(int s) {
	std::fill(d, d + n, INF);
	std::priority_queue<P, std::vector<P>, std::greater<P>> que;
	d[s] = 0;
	que.push(P(d[s], s));

	while (!que.empty()) {
		P p = que.top(); que.pop();
		int v = p.second;

		for (int i = 0; i < G[v].size(); ++i) {
			edge e = G[v][i];
			if (d[e.to_] > d[v] + e.cost_) {
				d[e.to_] = d[v] + e.cost_;
				que.push(P(d[e.to_], e.to_));
			}
		}
	}
}

ll solve() {
	dijkstra(0);
	for (int i = 0; i < m; ++i) {
		data[i].first = std::max(d[A[i]], d[B[i]]);
		data[i].second = D[i];
	}
	std::sort(data, data + m);
	for (int i = 1; i < m; ++i)
		data[i].second += data[i - 1].second;
	ll ans = sum;
	for (int i = 0; i < m; ++i)
		ans = std::min(ans, sum - data[i].second + data[i].first*c);
	return ans;
}

int main() {
	std::cin >> n >> m >> c;
	int a, b, d;
	for (int i = 0; i < m; ++i) {
		std::cin >> a >> b >> d;
		sum += d;
		--a;
		--b;
		A[i] = a;
		B[i] = b;
		D[i] = d;
		G[a].push_back(edge(b, d));
		G[b].push_back(edge(a, d));
	}
	std::cout << solve() << std::endl;
	return 0;
}

Measured memory_bytes: 19432
#include <iostream>
using namespace std;
int main()
{
    int N;
    string S;
    cin >> N >> S;
    int count{1};
    for (int i = 1; i < N; i++)
    {
        if (S[i - 1] != S[i])
        {
            count++;
        }
    }
    cout << count << '\n';

    return 0;
}


Measured memory_bytes: 512
N, L = map(int, input().split())

if L >= 0:
    sub = L
elif L < 0 and abs(L) < N:
    sub = 0
elif L < 0 and abs(L) >= N:
    sub = L+N-1

result = int(N*(L-1) + (N*(N+1))/2 - sub)

print(result)

Measured memory_bytes: 38256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<iostream>
#include<fstream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<functional>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};




signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ull t1,t2,a1,a2,b1,b2;
    ull ans=0;
    cin>>t1>>t2>>a1>>a2>>b1>>b2;
    if(a1<b1){
        swap(a1,b1);
        swap(a2,b2);
    }
    ull A1=t1*a1,B1=t1*b1,A2=A1+t2*a2,B2=B1+t2*b2;
    if(A2==B2){
        cout<<"infinity"<<endl;
        return 0;
    }
    if(a2>b2||A2>B2){
        cout<<0<<endl;
        return 0;
    }
    ans++;
    ull s=B2-A2;
    ull t=A1-B1;
    cout<<t/s*2+1-(t%s==0)<<endl;
    return 0;
}

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

const string T= "abcdefghijklmnopqrstuvwxyz.?! ";

string conv(const string &s) {
  int n = s.size();
  if(n % 2 != 0) return "NA";
  string res;
  for(int i = 0; i < n; i += 2) {
    int a = s[i] - '0';
    int b = s[i+1] - '0';
    if(1 <= a && a <= 6) ; else return "NA";
    if(1 <= b && b <= 5) ; else return "NA";
    int k = (a-1)*5 + (b-1);
    res += T[k];
  }
  return res;
}

int main() {
  string s;
  while(cin >> s) {
    cout << conv(s) << endl;
  }
  return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define all(v) v.begin(), v.end()

const ll mod=1000000007;

int countBits(int in){
  int res=0;
  for(int i=0;i<10;i++){
    int msk=1<<i;
    if((in&msk)!=0){
      res++;
    }
  }
  return res;
}

template<typename T>
void show2dVector(vector<vector<T>>& v){
  for(int i=0;i<v.size();i++){
    int m=v[i].size();
    cout<<i<<" : ";
    for(int j=0;i<m;i++){
      cout<<v[i][j]<<" ";
    }
    cout<<endl;
  }
}

void bfs(const vector<vector<int>>&g, int v, vector<bool>& seen){
  seen[v]=true;
  cout<<v<<" ";
  for(auto next: g[v]){
    if(seen[next]){
      continue;
    }
    bfs(g,next,seen);
  }
}

bool dfs(vector<vector<int>> &g,int start,int goal,vector<bool>&seen){
  bool res=false;
  seen[start]=true;
  if(start==goal){
    return true;
  }
  for(auto next: g[start]){
    if(seen[next]){
      continue;
    }
    res=dfs(g,next,goal,seen);
    if(res){
      break;
    }
  }
  return res;
}

ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string outputYesNo(bool ans){
  return (ans?"unsafe":"safe");
}
int main() {
  int s,w;cin>>s>>w;
  string ans=outputYesNo(w>=s);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define long long long
#define itn int

char mp[1010][1010];
int dp[1010][1010];

signed main ( ) {

    ios::sync_with_stdio(0);
    cin.tie(0);

    int h, w;
    cin >> h >> w;
    for ( int i = 1; i <= h; i++ ) {
        for ( int j = 1; j <= w; j++ ) {
            cin >> mp[i][j];
        }
    }

    dp[1][1] = 1;

    for ( int i = 1; i <= h; i++ ) {
        for ( int j = 1; j <= w; j++ ) {
            dp[i][j] += dp[i-1][j] * !!(mp[i-1][j]-'#');
            dp[i][j] %= (int)1e9 + 7;
            dp[i][j] += dp[i][j-1] * !!(mp[i][j-1]-'#');
            dp[i][j] %= (int)1e9 + 7;
        }
    }

    cout << dp[h][w] << endl;

    return 0;
}

Measured memory_bytes: 5248
//“ In order to be irreplaceable, one must always be different”
#include <bits/stdc++.h>
using namespace std;
# define ll long long
#define endl "\n"
# define pi 3.14159265359
# define str string
# define vll vector<ll>
# define vstr vector<str>
# define vchar vector<char>
# define pb push_back
# define popb pop_back
# define pf push_front
# define popf pop_front
# define sll set<ll>
# define schar set<char>
//find()
//erase(x) removes element x
//erase(position,position)
# define qll queue<ll>
# define qstr queue<str>
//front(),back()
# define stll stack<ll>
# define ststr stack<str>
//top()
# define dll deque<ll>
//at()
# define mll map<ll,ll>
#define mchar map<char, ll>
# define mstr map<str,ll>
# define mss map<str,str>
# define mci map<char,ll>
# define vp vector< pair<ll,ll> >
#define mp make_pair
#define ff first
#define ss second
#define pll pair<ll,ll>
# define f(x,y) for(int x=0;x<y;x++)
# define r(x,y) for(int x=y;x>=0;x--)
# define fr(x,y,z) for(int x=y;x<z;x++)
# define rr(x,y,z) for(int x=y;x>z;x--)
ll power(ll a , ll b){ll res=1;for(ll i=0; i<b; ++i){res*=a;}return res;}
ll logx(ll base, ll num){int cnt=0;while(num!=1){num/=base; ++cnt;}return cnt;}
ll gcd(ll a, ll b){
    if(b == 0)
        return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b){
    return (a*b)/gcd(a, b);
}
void print(vll a){
    for(int i=0;i<a.size();i++){
        cout<<a[i]<<' ';
    }
    cout<<endl;
}
vll inp(int n){
    vll a;
    ll x;
    f(i,n){
        cin>>x;
        a.pb(x);
    }
    return a;
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll a,b,c;

 cin >> a >> b >> c;

 ll d = c - a - b;
 if(d > 0 && d * d > 4 * a * b){
 cout << "Yes" << endl;
 } else {
 cout << "No" << endl;
 }
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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;
int main(){
  int n,m,x;
  cin>>n>>m>>x;
  vector<vector<int>>a(n,vector<int>(m+1));
  rep(i,n){
    rep(j,m+1){
      cin>>a.at(i).at(j);
    }
  }
  
  int ans=1001001001;
  for (int tmp = 0; tmp < (1 << 12); tmp++) {
    bitset<12> s(tmp);
    bool ex=true;
    vector<int>e(m,0);
    int now=0;
    rep(i,n){
      if(s.test(i)){
        now+=a.at(i).at(0);
        rep2(j,1,m+1){
          
            e.at(j-1)+=a.at(i).at(j);
          
        }
      }
    }
    rep(i,m){
      if(e.at(i)<x){
        ex=false;
      }
    }
    if(ex){
      ans=min(ans,now);
    }
    
  }  
  if(ans==1001001001){
    cout<<-1<<endl;
  }
  else{
  cout<<ans<<endl;  
  }
}



Measured memory_bytes: 3632
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct Edge{
    ll to, weight;
    Edge(ll t, ll w) : to(t), weight(w){}
};
using graph = vector<vector<ll>>;
using Graph = vector<vector<Edge>>;


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

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    ll n;
    cin>>n;
    vector<ll> ans;
    for(ll i=0;i<40;++i){
        ll flag = pow(2, i+1);
        if(n % flag == 0){
            ans.push_back(0);
        }else{
            n -= pow(-2, i);
            ans.push_back(1);
        }

        if(n == 0){
            break;
        }
    }

    for(ll i=0;i<ans.size();++i){
        cout<<ans[ans.size()-i-1];
    }
    cout<<endl;

    return 0;
}

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

int main() {
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  for (int i = 0; i < tx - sx; i++) cout << 'R';
  for (int i = 0; i < ty - sy; i++) cout << 'U';
  for (int i = 0; i < tx - sx; i++) cout << 'L';
  for (int i = 0; i < ty - sy; i++) cout << 'D';

  cout << 'D';
  for (int i = 0; i < tx - sx + 1; i++) cout << 'R';
  for (int i = 0; i < ty - sy + 1; i++) cout << 'U';
  cout << "LU";
  for (int i = 0; i < tx - sx + 1; i++) cout << 'L';
  for (int i = 0; i < ty - sy + 1; i++) cout << 'D';
  cout << 'R' << endl;
}

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

#define MAX 300
int main(void)
{
  int H[MAX],W[MAX];
  int i,j,k,l;

  for(i=0;i<MAX;i++)
    {
      scanf("%d %d",&H[i],&W[i]);
      if((H[i]==0)&&(W[i]==0))
	break;
    }
  for(l=0;l<i;l++)
    {
      for(k=0;k<H[l];k++)
	{
	  if(k%2==0)
	    {
	      for(j=0;j<W[l];j++)
		{
		  if(j%2==0)
		    printf("#");
		  else
		    printf(".");
		}
	      printf("\n");
	    }
	  else
	    {
	      for(j=0;j<W[l];j++)
		  {
		    if(j%2==0)
		      printf(".");
		    else
		      printf("#");
		  }
	      printf("\n");
	    }
	}
      printf("\n");
    }
}



Measured memory_bytes: 2108
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
using namespace std;
 
const double EPS = 1e-9;
 
struct data{
  double lm, rm, m;//l-min, r-max
  int bit; 
  data(double l=0, double r=0, double m=0, int b=0):lm(l),rm(r),m(m),bit(b){}
};
 
bool equal(double a, double b){
  return fabs(a-b) < EPS;
}
 
int n;
double r;
vector<double> v;
 
void solve(){
  if(n == 1){
    cout << 0.0 << endl;
    return;
  }
 
  vector<data> res[7];
  double ans = -1.0;
  for(int i=0;i<n;i++) res[1].push_back(data(0,0,v[i],(1<<i)));
  for(int i=2;i<=n;i++){
    for(int j=1;j<i;j++){
      int x1 = j, x2 = i - j;
      for(int k=0;k<res[x1].size();k++){
        for(int l=0;l<res[x2].size();l++){
          if((res[x1][k].bit & res[x2][l].bit) != 0) continue;
          data pos;
          double a = res[x2][l].m / (res[x1][k].m + res[x2][l].m);
          double b = 1.0 - a;
          pos.lm = min(-a + res[x1][k].lm, b + res[x2][l].lm);
          pos.rm = max(b + res[x2][l].rm, -a + res[x1][k].rm);
          pos.m = res[x1][k].m + res[x2][l].m;
          pos.bit = res[x1][k].bit | res[x2][l].bit;
          if(pos.rm - pos.lm > r || equal(pos.rm-pos.lm,r)) continue;
          else if(i == n) ans = max(ans, pos.rm - pos.lm);
          else res[i].push_back(pos);
        }
      }
    }
  }
  if(ans < 0) cout << -1 << endl;
  else printf("%.9f\n",ans);
}
 
int main(){
  int T;
  cin >> T;
  while(T--){
    cin >> r >> n;
    v.clear();
    for(int i=0;i<n;i++){
      int x;
      cin >> x;
      v.push_back(x);
    }
    solve();
  }
}

Measured memory_bytes: 2104
package main

import (
	"fmt"
)

func main() {
	var N int
	var ans int
	var active int
	var h []int

	fmt.Scan(&N)
	for i := 0; i < N; i++ {
		var tmp int
		fmt.Scan(&tmp)
		h = append(h, tmp)
	}

	for i := 0; i < N; i++ {
		if h[i] > active {
			ans += h[i] - active
			active = h[i]
		} else {
			active = h[i]
		}
	}
	fmt.Println(ans)
}


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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n;
    cin >> n;
    ll ans = 0;
    for(i = 1;i <= n;++i){
        if(i%3 == 0 || i% 5 == 0){
            continue;
        }
        ans += i;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>

using namespace std;

int main() {
	int n;
	cin >> n;
	
	int result = 0;
	for (int i = 1; i <= n; i += 2) {
		int y = 0;
		for (int j = 1; j <= n; ++j) {
			if (i % j == 0)
				++y;
		}
		
		if (y == 8)
			++result;
	}
	
	cout << result << 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 all(x)    (x).begin(),(x).end()
typedef long long ll;
const int MOD = (int)1e9 + 7;

int main(){
  int n,m;
  cin >> n >> m;
  vector<ll> item(n);
  ll sum = 0;
  rep(i,n){
    int a;
    cin>>a;
    sum += a;
    item[i] = a;
  }
  //sort(all(item));
  vector<ll> last;
  rep(i,n){
    int x = item[i];
    int prev = 0;
    //cout<< ">>" << endl;
    //cout<< x << endl;
    rep(j,30){
      ll y = pow(2,j+1);
      int margin = x - (int)(x/y);
      int buf = margin - prev;
      prev = margin;
      //cout << buf << endl;
      if(buf<=0) break;
      last.push_back(-buf);
    }
  }
  sort(all(last));
  int ls = last.size();
  //rep(i,ls) cout << last[i] <<endl;
  ll pos = 0;
  rep(i,m){
    if(i>=ls) break;
    pos += last[i];
  }
  //cout << pos << endl;
  cout << sum + pos << endl;
}



Measured memory_bytes: 35812
#include <stdio.h>
int main(void){
    int n, m, X, Y;
    scanf("%d%d%d%d", &n,&m,&X,&Y);
    int x[n], y[m];
    for (int i = 0; i < n; i++){
        scanf("%d", &x[i]);
    }
    for (int i = 0; i < m; i++){
        scanf("%d", &y[i]);
    }

    int flag = 0;
    int count_x, count_y;
    for (int z = X + 1; z <= Y; z++){
        count_x = 0;
        count_y = 0;
        for (int i = 0; i < n; i++){
            if (x[i] < z) count_x++;
        }
        for (int i = 0; i < m; i++){
            if (y[i] >= z) count_y++;
        }
        if (count_x == n && count_y == m) flag = 1;
    }
    if (flag) printf("%s\n", "No War");
    else printf("%s\n", "War");

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
constexpr int INF = 1e9;

int main() {
  int n, m, x;
  cin >> n >> m >> x;
  vector<int> c(n);
  vector<vector<int>> a(n, vector<int>(m));
  for (int i = 0; i < n; i++) {
    cin >> c[i];
    for (int j = 0; j < m; j++) cin >> a[i][j];
  }

  int r = INF;
  for (int b = 0; b < (1 << n); b++) {
    int cs = 0;
    vector<int> s(m);
    for (int i = 0; i < n; i++) {
      if (!(b >> i & 1)) continue;
      cs += c[i];
      for (int j = 0; j < m; j++) s[j] += a[i][j];
    }
    if (*min_element(s.begin(), s.end()) >= x) {
      r = min(r, cs);
    }
  }
  cout << (r == INF ? -1 : r) << endl;
}


Measured memory_bytes: 3632
main()
{
    int N, M, C, A[20], B[20], i, j, ans=0, c;
    scanf("%d%d%d", &N, &M, &C);
    for(i=0;i<M;i++)scanf("%d",&B[i]);
    for(j=0;j<N;j++)
    {
        c=0;
        for(i=0;i<M;i++)
        {
            scanf("%d",&A[i]);
            c+=A[i]*B[i];
        }
        if(c+C>0)ans++;
    }
    printf("%d", ans);
}


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

using namespace std;
typedef long long ll;

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

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


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

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

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

#define CMAX 26

void solve()
{
  ll D; cin >> D;
  vector<ll> c(CMAX + 1); rep1(i, CMAX) cin >> c[i];
  vector<vector<ll>> s(D + 1, vector<ll>(CMAX + 1));
  rep1(i, D) rep1(j, CMAX) cin >> s[i][j];

  vector<ll> t(D + 1); rep1(i, D) {cin >> t[i];}
  vector<ll> last(CMAX + 1, 0);
  /*  rep1(i, CMAX) last[i] = 0;
    rep1(i, CMAX) {
      cerr << last[i] << " ";
    } cout << endl;
  */
  ll sat = 0;
  ll dis;
  for(ll day = 1; day <= D; day++) {
    //cerr << day << ":\n";
    sat += s[day][t[day]];
    //cerr << "sat:" << sat << endl;
    last[t[day]] = day;
    /*rep1(i, CMAX) {
      cerr << last[i] << " ";
    } cout << endl;
    */
    dis = 0;
    rep1(i, CMAX) {
      dis += c[i] * (day - last[i]);
    }
    //cerr << "dis:" << dis << "\n";
    
    sat -= dis;

    cout << sat << endl;
  }
}


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


Measured memory_bytes: 3684
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void co(void){cout << '\n';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); cout << '\n';}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); cout << '\n';}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr ll INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
//constexpr ll MOD = 998244353;
const ld PI = acos(-1);
constexpr ld EPS = 1e-11;

Vec a;

ll f(ll l, ll d, ll m){
	if(m == 2) return abs(a[l] - a[l + d]);
	
	//bool flg = true;
	//rep(i, n) flg &= (a[l + d * i] != 1);

	ll res = 0;
	if(m & 1) return f(l, d * 2, (m + 1) / 2);
	else return abs(f(l, d * 2, m / 2) - f(l + d, d * 2, m / 2));
}

int main(void){
	ll n;
	cin >> n;
	string s;
	cin >> s;
	a.resize(n);
	bool flg = true;
	rep(i, n){
		a[i] = s[i] - '1';
		flg &= (a[i] != 1);
	}

	if (flg) rep(i, n) a[i] /= 2;
	else
		rep(i, n) if (a[i] == 2) a[i] = 0;

	ll ans = f(0, 1, n);
	if (flg) ans *= 2;
	co(ans);

	return 0;
}


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

int main(){
    int A[3][3];
    int B;
    bool mark[3][3]={0};
    string ans="No";
    int i,j,k;
    for(i=0; i<3; i++){
        for(j=0; j<3; j++){
            cin >> A[i][j];
        }
    }
    int N;
    cin >> N;

    for(k=0; k<N; k++){
        cin >> B;
        for(i=0; i<3; i++){
            for(j=0; j<3; j++){
                if(A[i][j]==B) mark[i][j]=true;
            }
        }
    }

    for(i=0; i<3; i++){
        if(mark[i][0] && mark[i][1] && mark[i][2]) ans="Yes";
        if(mark[0][i] && mark[1][i] && mark[2][i]) ans="Yes";
    }
    if(mark[0][0] && mark[1][1] && mark[2][2]) ans="Yes";
    if(mark[0][2] && mark[1][1] && mark[2][0]) ans="Yes";    

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3616
using System;
class Program{
	static void Main(){
		long[] s=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
		long[][] arr=new long[s[0]][];
		long a=0,b=0;
		for(int i=0;i<s[0];i++){
			arr[i]=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
			a=Math.Max(a,arr[i][0]);
		}
		Array.Sort(arr,ca);
		for(int i=0;i<s[0]&&arr[i][1]>a&&s[1]>0;i++){
			s[1]-=arr[i][1];
			b++;
		}
		if(s[1]<=0){Console.WriteLine("{0}",b);}
		else{Console.WriteLine("{0}",s[1]/a+(s[1]%a==0?0:1)+b);}
	}
	static int ca(long[] a,long[] b){
		if(a[1]<b[1]){return 1;}
		else if(a[1]>b[1]){return -1;}
		else{return 0;}
	}
}

Measured memory_bytes: 22348
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string.h>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<vector>
#include<sstream>
#include<queue>
#include<stack>
#include<string>
#include<climits>
#include<map>
#include<set>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define INF 1<<30
#define F first
#define S second
using namespace std;
typedef pair<int,int> P;
int famine[10000];

void add(string s){
  reverse(s.begin(),s.end());
  bool plus = false;
  int A,B,C,i;
  for(i=0;i<10000;i++){
    A = i<s.length()?s[i]-'0':0;
    B = famine[i];
    C = plus?1:0;
    plus = A+B+C>=10?true:false;
    famine[i] = (A+B+C)%10;
  }    
  bool cle = false;
 
}

int main(){
  string s;
  int sam = 0,val;
  bool config;

  for(int i=0;i<10000;i++)famine[i] = 0;
  while(getline(cin,s,'\n')){
    for(int i=0;i<s.length();i++)if(!isdigit(s[i]))s[i] = ' '; 
    stringstream ss;
    for(ss<<s;ss>>val;){
      stringstream sss;
      sss << val;
      add(sss.str());
    }    
  }
  bool cle = false;
  for(int i=10000;i>=0;i--){
    if(!cle && famine[i] == 0)continue;
    cle = true;
    cout << famine[i];
  }
  cout << endl;
return 0;
}

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

int main(){
    
    int N;
    cin >> N;
    //cout << 927*1.08 <<endl;
    for(int i = 0;i < 100000;i++){
        if(int(i*1.08)==N){
            cout << i <<endl;
            return 0;
        }
    }
    cout << ":("<<endl;
    
}
    
    



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  ll n;
  cin >> n;
  if(n==0){
    cout << 0 << endl;
    return 0;
  }
  ll N = n;
  vector<int> ans;
  vector<ll> n_2(55);
  n_2[0]=1;
  for(int i=1;i<=40;i++){
    n_2[i]=n_2[i-1]*(-2);
  }
  int cnt1=0;
  for(int i=40;i>=0;i--){
    //cout << N-(n_2[i]) << " " << N;
    if(abs(N-(n_2[i])) <= 2*abs(N)){
      ans.pb(1);
      cnt1++;
      //cout << " " << 1 << endl;
      N -= (n_2[i]);
    }
    else {
      if(cnt1) ans.pb(0);
      //cout << " " << 0 << endl;
    }
  }
  for(auto i:ans) cout << i;
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>	
#include<vector>
#define ll long long
using namespace std;
ll a[200010][3];
ll n;
ll seg[800000];
ll seg1[800000];
ll update(ll pos, ll val, ll node, ll x, ll y) {
	if (pos < x || y < pos)return seg[node];
	if (x == y) {
		return seg[node] += val;
	}
	ll mid = (x + y) / 2;
	return seg[node] = update(pos, val, node * 2, x, mid) + update(pos, val, node * 2 + 1, mid + 1, y);
}
ll update1(ll pos, ll val, ll node, ll x, ll y) {
	if (pos < x || y < pos)return seg1[node];
	if (x == y)return seg1[node] += val;
	ll mid = (x + y) / 2;
	return seg1[node] = update1(pos, val, node * 2, x, mid) + update1(pos, val, node * 2 + 1, mid + 1, y);
}
ll check(ll val, ll node, ll x, ll y) {
	if (x == y)
		return x;
	ll mid = (x + y) / 2;
	if (seg[node*2] >= val)
		return check(val, node * 2, x, mid);
	else
		return check(val-seg[node*2], node * 2 + 1, mid + 1, y);
}
ll query(ll lo, ll hi, ll node, ll x, ll y) {
	if (hi < x || y < lo)return 0;
	if (lo <= x && y <= hi)return seg[node];
	ll mid = (x + y) / 2;
	return query(lo, hi, node * 2, x, mid) + query(lo, hi, node * 2 + 1, mid + 1, y);
}
ll query1(ll lo, ll hi, ll node, ll x, ll y) {
	if (hi < x || y < lo)return 0;
	if (lo <= x && y <= hi)return seg1[node];
	ll mid = (x + y) / 2;
	return query1(lo, hi, node * 2, x, mid) + query1(lo, hi, node * 2 + 1, mid + 1, y);
}
vector<ll> vt;
ll getidx(ll x) {
	return lower_bound(vt.begin(), vt.end(), x) - vt.begin();
}
int main()
{
	scanf("%lld", &n);
	for (int i = 0; i < n; i++) {
		scanf("%lld", &a[i][0]);
		if (a[i][0] == 1) {
			scanf("%lld %lld", &a[i][1], &a[i][2]);
		}
		vt.push_back(a[i][1]);
	}
	sort(vt.begin(), vt.end());
	ll sum = 0;
	ll xx = 0;
	vt.erase(unique(vt.begin(), vt.end()), vt.end());
	for (int i = 0; i < n; i++) {
		if (a[i][0] == 1) {
			sum += a[i][2];
			xx++;
			update(getidx(a[i][1]), 1, 1, 0, vt.size());
			update1(getidx(a[i][1]), a[i][1], 1, 0, vt.size());
		}
		else {
			ll ch = (xx + 1) / 2;
			ll oo = check(ch, 1, 0, vt.size());
			ll dap = sum;
			dap += (query(0, oo, 1, 0, vt.size())*vt[oo] - query1(0, oo, 1, 0, vt.size()));
			dap += (query1(oo, vt.size(), 1, 0, vt.size()) - query(oo, vt.size(), 1, 0, vt.size())*vt[oo]);
			printf("%lld %lld\n",vt[oo], dap);
		}
	}
}

Measured memory_bytes: 17392
import sys
input = sys.stdin.readline
n, q = map(int,input().split())
A = list(map(int,input().split()))[::-1]
X = [int(input()) for i in range(q)]

S = [A[0]]
for i in range(1, n):
    S.append(S[-1] + A[i])

AA = A[::-1]
T = [AA[0], AA[1]]
for i in range(2, n):
    T.append(T[-2] + AA[i])

su = sum(A)
# print(S,T)

for i in range(q):
    l = 0
    r = (n+1)//2-1 + 1
    m = (l+r)//2
    x = X[i]
    while r-l > 1:
        # print(m,l,r,abs(x-A[m+1]) ,abs(x-A[m*2+1]))
        if m == 0 or abs(x-A[m]) >= abs(x-A[m*2]):
            l = m
        else:
            r = m
        m = (l+r)//2
    ans = S[l]
    # print("l", l)
    if n - 2*(l+1) > 0:
        ans += T[n-2*(l+1)-1]
    print(ans)
        


Measured memory_bytes: 68036
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  long long int ans=LLONG_MAX;
  cin >>n;
  int a[n];
  for(int i=0;i<n;i++)cin >>a[i];
  for(int i=-100;i<101;i++){
    long long int temp=0;
    for(int j=0;j<n;j++)temp+=(a[j]-i)*(a[j]-i);
    ans=min(temp,ans);
  }
  cout <<ans <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,r) for(int i = 0; i < (r); i++)
#define pb push_back
#define ALL(a) a.begin(), a.end()
#define fastio ios::sync_with_stdio(0);cin.tie(0)
using ll = long long;
using ull = unsigned long long;

int main() {
  fastio;
  int N;
  unordered_map<string , int> mp; // kind -> count
  cin >> N;
  rep(i, N) {
    string kind;
    cin >> kind;
    mp[kind]++;
  }
  cout << mp.size() << endl;
  
  #ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
}


Measured memory_bytes: 17684
#include <iostream>
#include <vector>
#include <string.h>
#include <queue>
using namespace std;
struct edge{int to, cap, rev;};
int INF = 10000000;
int iter[1002];
int level[1002];

void bfs(vector< vector<edge> > &G, int s){
  memset(level,-1,sizeof(level));
  level[s] = 0;
  queue<int> que;
  que.push(s);
  while(!que.empty()){
    int v = que.front();
    que.pop();
    for(int i = 0; i < G[v].size(); ++i){
      edge &e = G[v][i];
      if(e.cap > 0 && level[e.to] < 0){
	level[e.to] = level[v] + 1;
	que.push(e.to);
      }
    }
  }
}

int dfs(vector< vector<edge> > &G, int v, int t, int f){
  if(v == t) return f;
  for(int &i = iter[v]; i < G[v].size(); ++i){
    edge &e = G[v][i];
    if(e.cap > 0 && level[v] < level[e.to]){
      int d = dfs(G,e.to,t,min(f,e.cap));
      if(d > 0){
	e.cap -= d;
	G[e.to][e.rev].cap += d;
	return d;
      }
    }
  }
  return 0;
}

int max_flow(vector< vector<edge> > &G, int s, int t){
  int flow = 0;
  for(;;){
    bfs(G,s);
    if(level[t] < 0) return flow;
    memset(iter,0,sizeof(iter));
    int f;
    while((f = dfs(G,s,t,INF)) > 0){
      flow += f;
    }
  }
}

int gcd(int a, int b){
  if(a < b) swap(a,b);
  if(a % b) return gcd(b,a%b);
  return b;
}

int main(){
  int m, n;
  while(cin >> m >> n, m){
    int b[m], r[n];
    vector< vector<edge> > G(n+m+2);
    for(int i = 0; i < m; ++i)
      cin >> b[i];
    for(int i = 0; i < n; ++i)
      cin >> r[i];
    for(int i = 0; i < m; ++i){
      for(int j = 0; j < n; ++j){
	if(gcd(b[i],r[j]) != 1){
	  G[i].push_back((edge){j+m,1,G[j+m].size()});
	  G[j+m].push_back((edge){i,0,G[i].size()-1});
	}
      }
    }
    int s = n + m, t = n + m + 1;
    for(int i = 0; i < m; ++i){
      G[s].push_back((edge){i,1,G[i].size()});
      G[i].push_back((edge){s,0,G[s].size()-1});
    }
    for(int i = 0; i < n; ++i){
      G[i+m].push_back((edge){t,1,G[t].size()});
      G[t].push_back((edge){i+m,0,G[i+m].size()});
    }
    cout << max_flow(G,s,t) << endl;
  }
  return 0;
}

Measured memory_bytes: 7284
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int a, b;
  cin >> a >> b;
  string s;
  cin >> s;

  int num = 0;
  for(int i = 0; i < a; i++){
    if(s[i] != '-') num++;
  }

  for(int i = 0; i < b; i++){
    if(s[a + 1 + i] != '-') num++;
  }

  if(s[a] == '-') num++;
  if(num == (a + b + 1)) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<typename T>
struct BIT{
    //1-index
    //0-indexで取ると無限ループする
    private:
    V<T> arr;
    int n;

    public:
    BIT(int siz){
        n=siz;
        arr.assign(n+1,0);
    }
    //一点更新 aにvを加える
    void add(T a,T v){
        //x+=(x&-x) 初項a,それ以降a<=2^Nが列挙
        for(T x=a;x<=n;x+=(x&-x)){
            arr[x]+=v;
        }
    }
    T sum(T a){
        // 1からaまでの区間和
        T ret=0;
        for(T x=a;x>0;x-=(x&-x))ret+=arr[x];
        return ret;
    }
    T get(T x){//x番目に大きい数　// 区間和がw以上となる最小のindを返す
        if(x<=0) return 0;
        T N=1;
        while(N*2<=n)N*=2;
        T v=0;
        for(T i=N;i>0;i/=2){
            if(v+i<=n&&arr[v+i]<x){
                x-=arr[v+i];
                v+=i;
            }
        }
        return v+1;
    }
    T query(int l,int r){
        return sum(r)-sum(l);
    }
};
map<ll,ll> mp;
int main(){
  ll n,k;
  cin>>n>>k;
  V<ll> a(n);
  for(int i=0;i<n;i++)cin>>a[i];
  V<ll> sum(n+1);
  for(int i=0;i<n;i++)sum[i+1]=sum[i]+a[i];
  V<ll> d;
  int cnt=1;
  for(int i=0;i<=n;i++)d.emplace_back(sum[i]-k*i);
  sort(all(d));
  for(int i=0;i<=n;i++){
    if(!mp.count(d[i]))mp[d[i]]=cnt++;
  }
  BIT<ll> t(cnt+5);
  ll ans=0;
  for(int i=0;i<=n;i++){
    ans+=t.query(0,mp[sum[i]-i*k]);
    t.add(mp[sum[i]-i*k],1);
  }
  cout<<ans<<"\n";
}

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

using namespace std;
using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define rep(i, N) for (ll i = 0; i < (N); i++)
#define For(i, a, b) for (ll i = (a); i < (b); i++)
#define all(A) (A).begin(), (A).end()

int main(){
    ll N, A, B;
    cin >> N >> A >> B;
    ll tmp = A + B;
    ll ans = 0;
    ans += N / tmp * A;
    N %= tmp;
    ans += min(A, N);

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
#include<string>
#include<cstring>
#include<map>
#include<tuple>
#include<algorithm>

using namespace std;

#define REP(i, n) for(int i=0;i<(int)n;i++)
#define REPS(i, n) for(int i=1;i<=(int)n;i++)
#define RREP(i, n) for(int i=n-1;i>=0;i--)
#define RREPS(i, n) for(int i=n;i>0;i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define pb push_back
#define eb emplace_back
#define endl '\n'
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

int r, n, m;
string s;
vector<string> ans;

void dfs(string &s, int i, int used){
	if(i == s.size()){
		ans.pb(s);
		return ;
	}
	if(s[i]=='a' || (1&(used >> (s[i]-'a')))) dfs(s, i+1, used);
	if(s[i] < 'z' && 0 == (1&(used >> (s[i]-'a'+1)))){
		s[i] ++;
		dfs(s, i+1, used | (1 << (s[i]-'a')));
		s[i] --;
	}
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	while(cin >> s, s != "#"){
		n = s.size();
		dfs(s, 0, 0);
		cout << ans.size() << endl;
		if(ans.size() <= 10) for(auto &s : ans) cout << s << endl;
		else{
			REP(i, 5) cout << ans[i] << endl;
			REP(i, 5) cout << ans[ans.size()-5+i] << endl;
		}
		ans.clear();
	}
}

Measured memory_bytes: 2348
def calc(S):
	S = list(S)
	if S[0] == 'A' and S[2:-1].count('C') == 1:
		S[0] = 'a'
		idx = S[2:-1].index('C')
		S[2+idx] = 'c'
		for i in S:
			if i < 'a' or 'z' < i:
				return False
	else:
		return False
	return True
	
inp = raw_input()
print 'AC' if calc(inp) else 'WA'


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

int main() {
	int a, b, c; cin >> a >> b >> c;
	bool ok = false;
	for (int i = 1; i <= b; i++)
	{
		if(a * i % b == c) {
			ok = true;
			break;
		}
	}
	if(ok) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}


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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T1, class T2> inline void minup(T1& m, T2 x){ if(m>x) m=static_cast<T2>(x); }
template<class T1, class T2> inline void maxup(T1& m, T2 x){ if(m<x) m=static_cast<T2>(x); }

#define INF 1000000000
#define MOD 1000000007
#define EPS 1E-12

const int N = 3;
int a[N];
int n;

int main()
{
  cin >> n;
  rep(i, n) cin >> a[i];
  sort(a, a+n);

  erep(i, 1, a[0]){
    bool ok = true;
    rep(j, n) if(a[j]%i) ok = false;
    if(ok) cout << i << endl;
  }

  return 0;
}

Measured memory_bytes: 1176
#include <iostream>
#include <cmath>

using namespace std;

const int MAX = 1e5;

int main(){
  int n,m,len;
  int dp[MAX] = {0};

  cin >> n >> m;
  for(int i = 1 ; i < n ; i++){
    cin >> len;
    dp[i] = dp[i-1] + len;
  }

  int a,ans = 0,pos = 0;
  for(int i = 0 ; i < m ; i++){
    cin >> a;
    ans += abs(dp[a+pos] - dp[pos]);
    ans %= 100000;
    pos += a;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1560
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 3
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	h := getNextInt64(scanner)
	w := getNextInt64(scanner)

	if h == 1 || w == 1 {
		fmt.Fprintln(writer, 1)
		return
	}

	ans := (w-w>>1)*(h-h>>1) + (w>>1)*(h>>1)
	fmt.Fprintln(writer, ans)
}


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

int main(){
  int N, ans = 0;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; ++i){
    cin >> A[i];
    ans += A[i] - 1;
  }
  cout << ans << endl;
  return 0;
}


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

 int main()
 {
 	int n,a,b;
 	cin >> n>>a>>b;
 	int x=0,y=0,z=0;
 	for (int i = 0; i < n; i++){
 		int t;
 		cin >> t;
 		if(t<=a){
 			x++;
 		}else if(t<=b){
 			y++;
 		}else{
 			z++;
 		}
 	}
 	int ans;
 	if(x<=y&&x<=z){
 		ans=x;
 	}else if(y<=x&&y<=z){
 		ans=y;
 	}else{
 		ans=z;
 	}
 	cout << ans << endl;
 }

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

int main(){

    int n;
    cin >> n;
    int map[2][n];
    for(int i = 0;i < 2;i++){
        for(int j = 0;j < n;j++){
            cin >> map[i][j];
        }
    }

    int ans = 0;
    for(int i = 0;i < n;i++){//はじめに右にi回進み、下に進み、その後全て右へ
        int tmp = 0;
        for(int j = 0;j <= i;j++){
            tmp += map[0][j];
        }
        tmp += map[1][i];
        for(int j = i+1;j < n;j++){
            tmp += map[1][j];
        }

        if(tmp > ans){
            ans = tmp;
        }
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
//#include<bits/stdc++.h>
using ll = long long;
using namespace std;
const ll INF = 10000000000000000;
const ll mod = 1000000007;
//printf("%.10f\n", n);
signed main() {
	ll n, m, a = 0, b = 0, cnt = 0, ans = 0; cin >> n;
	cout << n / 3 << endl;
	cin >> n; return 0;
}

Measured memory_bytes: 256
n, m, c = map(int, input().split())
b = list(map(int, input().split()))
ans = 0
for i in range(n):
    a = list(map(int, input().split()))
    s = c
    for j in range(m):
        s += a[j] * b[j]
    if s > 0:
        ans += 1
print(ans)


Measured memory_bytes: 9180
n = gets.to_i
h = gets.strip.split.map(&:to_i)
cnt = 1
max = h[0]
if n > 1
	(1..n - 1).each do | i |
	
		if h[i] >= max
			cnt += 1
			max = h[i]
		end
	end
end
puts cnt

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

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> l(n);
  for (int i = 0; i < n; i++) {
    cin >> l[i];
  }
  sort(l.begin(), l.end());
  int sum = 0;
  for (int i = 0; i < n - 1; i++) {
    sum += l[i];
  }
  if (sum > l.back()) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;

int main(){
    int k;
    string s;
    cin >> k >> s;
    if(s.size() <= k){
        cout << s << endl;
    }else{
        rep(i,k) cout << s[i];
        cout << "..." << endl;
    }
    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

ll mpow(ll x, ll n) {
  ll ans=1;
  while(n>0) {
    if(n&1) {
      ans=ans*x%mod;
    }
    x=x*x%mod;
    n>>=1;
  }
  return ans;
}

vec tfact(1e7+1);
void fact(ll n) {
  for(ll i=0;i<=n;i++) {
    if(i==0) {
      tfact[i]=1;
    }
    else {
      tfact[i]=tfact[i-1]*i%mod;
    }
  }
}

ll comb(ll n, ll k) {
  return tfact.at(n)*mpow(tfact.at(k),mod-2)%mod*mpow(tfact.at(n-k),mod-2)%mod;
}

int main() {
  ll k;
  string s;
  cin >> k >> s;
  ll n=s.size();
  ll ans=0;
  fact(n+k);
  for(ll i=0;i<=k;i++) {
    ans+=mpow(25,i)*comb(n+k,i);
    ans%=mod;
  }
  cout << ans << endl;
}

Measured memory_bytes: 83396
#include<stdio.h>

int main(void) {

	int n, i;
	int a[100];

	scanf("%d", &n);

	for (i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	for (i = n - 1; i >= 0;i--) {
		printf("%d", a[i]);
		if (i == 0) {
			continue;
		}
		printf(" ");
		
	}

	printf("\n");

	return(0);
}


Measured memory_bytes: 2104