akhauriyash/Code-Regression huggingface dataset:
def C(N, S):
    n_diff_chars = S.count(".")
    cand_list = [n_diff_chars]
    for c in S:
        if c == ".":
            n_diff_chars -= 1
        else:
            n_diff_chars += 1
        cand_list.append(n_diff_chars)
    print(min(cand_list))


if __name__ == "__main__":
    N = int(input())
    S = input()
    C(N, S)


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

int L, N, X[200000];
ll r[200001], l[200001], MAX;
int main()
{
	cin >> L >> N;
	for (int i = 0; i < N; ++i)
    {
        cin >> X[i];
    }
	for (int i = 0; i < N; ++i)
    {
        l[i + 1] = l[i] + X[i] * 2;
    }
	for (int i = N - 1; i >= 0; --i)
    {
        r[i] = r[i + 1] + (L - X[i]) * 2;
    }
	for (int i = 0; i < N; ++i)
    {
		ll cnt = X[i] + l[i] + r[i + 1];
		if (i >= N - (i + 1))
		{
			cnt -= l[i - (N - (i + 1))];
		}
		else
		{
			cnt -= r[i + 1 + i + 1];
		}
		MAX = max(MAX, cnt);

		cnt = L - X[i] + l[i] + r[i + 1];
		if (i <= N - (i + 1))
		{
			cnt -= r[i + 1 + i];
		}
		else
		{
			cnt -= l[i - (N - (i + 1)) - 1];
		}
		MAX = max(MAX, cnt);
	}

	cout << MAX << endl;

	return 0;
}


Measured memory_bytes: 4096
#include <iostream>
#include <vector>
#include <utility>

using namespace std;

int dfs(int to, int from, int count, int n, vector<vector<bool> > &vec, vector<int> &pre, vector<int> &low) {
	int ret = 0;
	if(pre[to] == n+1 && low[to] == n+1) {
		pre[to] = count;
		low[to] = count;
	}

	for(int i=1; i<n+1; i++) {
		if(i == from) continue;
		if(!vec[to][i]) continue;

		int next = pre[i];
		if(next == n+1) {
			ret += dfs(i, to, count+1, n, vec, pre, low);
			if(pre[to] < low[i]) ret++;
		}
		low[to] = min(low[to], low[i]);
	}

	return ret;
}

int solv(int n, int m, vector<pair<int, int> > &v) {
	vector<vector<bool> > vec(n+1, vector<bool>(n+1, false));
	for(int i=0; i<m; i++) {
		pair<int, int> &p = v[i];
		vec[p.first][p.second] = true;
		vec[p.second][p.first] = true;
	}

	vector<int> pre(n+1, n+1);
	vector<int> low(n+1, n+1);

	return dfs(1, -1, 0, n, vec, pre, low);
}

int main(void) {
	int n, m;
	vector<pair<int, int> > v;

	cin >> n;
	cin >> m;
	for(int i=0; i<m; i++) {
		int a,b;
		cin >> a;
		cin >> b;
		v.push_back(make_pair(a, b));
	}

/*
	n = 7;
	m = 7;
	v.push_back(make_pair(1, 3));
	v.push_back(make_pair(2, 7));
	v.push_back(make_pair(3, 4));
	v.push_back(make_pair(4, 5));
	v.push_back(make_pair(4, 6));
	v.push_back(make_pair(5, 6));
	v.push_back(make_pair(6, 7));
*/
	cout << solv(n,m,v) << endl;


	return 0;
}




Measured memory_bytes: 256
#pragma region _head

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<iomanip>
#include<queue>
#include<stack>
#include<numeric>
#include<utility>
#include<regex>

#pragma region _define

#define f(i,a,b) for(int i=a;i<b;i++)
#define f_vI(v,n) f(i,0,n)cin>>v[i]
#define f_v2I(v1,v2,n) f(i,0,n)cin>>v1[i]>>v2[i]
#define f_v3I(v1,v2,v3,n) f(i,0,n)cin>>v1[i]>>v2[i]>>v3[i]
#define f_vO(v,n) f(i,0,n)cout<<v[i]<<endl
#define all(a) a.begin(),a.end()
#define size(s) s.size()
#define check() cout<<"! ! !"
#define endl "\n"
#define _y() cout<<"Yes"<<endl
#define _Y() cout<<"YES"<<endl
#define _n() cout<<"No"<<endl
#define _N() cout<<"NO"<<endl

#pragma endregion

#pragma region _using

using namespace std;

using LL = long long;
using st = string;
using vi = vector<LL>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vc = vector<char>;
using vs = vector<st>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using si = stack<LL>;
using ss = stack<st>;
using pi = pair<LL, LL>;
using v_pi = vector<pi>;

#pragma endregion

#pragma region _graph

#define node 50  //グラフの最大位数　適宜変更
//bool graph[node][node]; bool visited[node] = { false };
#define link(a,b,m) f(i,0,m){cin>>a[i]>>b[i]; a[i]--; b[i]--; graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;}

#pragma endregion

LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b) * b);
}

//階乗計算
LL factorial(LL n) {
	LL a = 1, ret = 1;
	while (a < n) {
		a++;
		ret *= a;
		//ret %= 1000000007;
	}
	return ret;
}

#pragma endregion 

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

	int n;
	cin >> n;
	vi a(n);
	f_vI(a, n);
	LL ans = 1e9;
	f(i, 0, n-1) {
		ans = min(ans, gcd(a[i + 1], a[i]));
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef int ftype;
 
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second 
#define debug(x)  do{cerr<<#x<<": "<<x<<"\n";}while(0)
#define debugv(x) do{cerr<<#x<<": ";for(auto&e: (x))cerr<<e<<" ";cerr<<"\n";}while(0)
#define fori(i, n) for (int i = 0; i < (int)(n); ++i)
#define forn(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n); i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define RETURN(x) do{cout << x << '\n'; return 0;}while(0)
#define FIRSTWIN do{cout << "Monocarp\n"; return 0;}while(0)
#define SECONDWIN do{cout << "Bicarp\n"; return 0;}while(0)

const int MAXN = 5e5+5;
const int MOD = 1e9+7;
const LL INF = 1e18+1;

int N;
int D[MAXN];
LL ans;

int main() {
#ifdef OJ
    freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin >> N;
    fori(i,N) cin >> D[i];
    fori(i,N) {
        fore(j,i+1,N-1) ans += D[i]*D[j];
    }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    ll n, k;
    cin >> n >> k;
    map<int,ll> m;
    REP(i,n) {
        int a, b;
        cin >> a >> b;
        m[a] += b;
    }
    int ans = 0;
    ll count = 0;
    for(auto item:m) {
        count += item.second;
        if (count >= k) {
            ans = item.first;
            break;
        }
    }

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

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

int main(){
	int H, W;
	cin >> H >> W;
	int a[H][W];
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			cin >> a[i][j];
		}
	}
	int i = 0, j = 0, nexti = 0, nextj = 0, N = 0;
	vector<int> y, x, Y, X;
	if(nexti % 2 == 0 && nextj == W - 1){
		nexti++;
	}else if(nexti % 2 == 0){
		nextj++;
	}else if(nextj == 0){
		nexti++;
	}else{
		nextj--;
	}
	while(nexti < H){
		if(a[i][j] % 2){
			N++;
			y.push_back(i+1);
			x.push_back(j+1);
			if(i % 2 == 0 && j == W - 1){
				i++;
			}else if(i % 2 == 0){
				j++;
			}else if(j == 0){
				i++;
			}else{
				j--;
			}
			a[i][j]++;
			Y.push_back(i+1);
			X.push_back(j+1);
		}else{
			if(i % 2 == 0 && j == W - 1){
				i++;
			}else if(i % 2 == 0){
				j++;
			}else if(j == 0){
				i++;
			}else{
				j--;
			}			
		}
		if(nexti % 2 == 0 && nextj == W - 1){
			nexti++;
		}else if(nexti % 2 == 0){
			nextj++;
		}else if(nextj == 0){
			nexti++;
		}else{
			nextj--;
		}
	}
	cout << N << endl;
	for(int i=0; i<N; i++){
		cout << y[i] << " " << x[i] << " " << Y[i] << " " << X[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 5220
import java.util.*;
public class Main {
    public static void main(String[] args){
      Scanner s = new Scanner(System.in);
      Integer N = s.nextInt();
      Integer M = s.nextInt();
      Integer X = s.nextInt();
      int[] C = new int[N];
      int[][] A = new int[N][M];
      for(int i = 0; i < N; i++) {
    	  C[i] = s.nextInt();
    	  for(int j = 0; j < M; j++) {
    		  A[i][j] = s.nextInt();
    	  }
      }
      
      int resultPrice = 0;
      int[] resultParam = new int[M];
      for(int k = 0; k < (1<<N); k++) {
    	  int currentPrice = 0;
    	  int[] currentParam = new int[M];
    	  for(int m = 0; m < N; m++) {
    		  if(((k>>m) & 1 )== 1) {
    			  addArrays(currentParam, A[m]);
    			  currentPrice += C[m];
    		  }
    	  }
    	  if(check(currentParam, X)) {
    		  resultPrice = resultPrice > currentPrice || resultPrice == 0 ? currentPrice : resultPrice;
    	  }
      }
      System.out.println(resultPrice == 0 ? -1: resultPrice);
    }
  
  	private static boolean check(int[] result, int x) {
		int count = 0;
		for(int s : result) {
			if(s >= x)
				count++;
		}
		return count == result.length;
	}
	
	private static void addArrays(int[] origin, int[] current) {
		for(int i = 0; i < current.length; i++) {
			origin[i] += current[i];
		}
	}
}

Measured memory_bytes: 36372
#ifdef DEBUG_IS_VALID
#define DEB 1 
#define _LIBCPP_DEBUG 0
#else
#define DEB 0
#define NDEBUG
#endif

#include <bits/stdc++.h>
using namespace std;

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(long long i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(long long i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#define fi first
#define se second
#pragma GCC optimize ("-O3")

using namespace std;

#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){cout << "{"; for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vp = vector<Pl>;
using vvp = vector<vp>;

const int INF = 1<<29;
const long long LINF=1LL<<59;


void solve(long long N, long long K, std::vector<long long> p){
  vl s(N+1);
  rep(i,N) s[i+1] = s[i] + (p[i] + 1);
  ll ma = 0;
  rep(i, N-K+1){
    // [i, i+K)
    ll temp = s[i+K] - s[i];
    chmax(ma, temp);
  }
  cout << double(ma) / 2.0 << endl;
}

int main(){
  std::cout << std::fixed << std::setprecision(15);
  long long N;
  scanf("%lld",&N);
  long long K;
  scanf("%lld",&K);
  std::vector<long long> p(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&p[i]);
  }
  solve(N, K, std::move(p));
  return 0;
}


Measured memory_bytes: 3328
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
ans=sum(b)
for i in range(len(a)-1):
  if a[i+1]-a[i]==1:
    ind=a[i]
    ans+=c[ind-1]
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define N 100005
#define MOD 1000000007
#define dd double
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n;
	cin>>n;

	int o = n;

	int t = o*n;

	int j = t*n;

	int res = o+t+j;



	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb emplace_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
#define dupli(a) erase(unique(all(a)),a.end())
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
void outs(ll a,ll b){if(a>=inf-100)out(b);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}

int main(){
    ll a,b,c,d;cin>>a>>b>>c>>d;
    if((a-1)/d>=(c-1)/b)out("Yes");
    else out("No");
}

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

using namespace std;

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 
#define INF (1LL<<50)
#define MOD 1000000007

signed main(){

	lli a,b;
	cin>>a>>b;
	if(a>=13){
		cout<<b<<endl;
	}
	else if(a<=5){
		cout<<0<<endl;
	}
	else
		{cout<<b/2<<endl;}


	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>

using namespace std;
int selectedSort(int,int*);
void show(int,int*,int);

int main(void){
    int n,sw;
    int const MAX=100;
    int num[MAX];
    cin>>n;
    for(int i=0;i<n;++i){
        cin>>num[i];
    }
    sw = selectedSort(n,num);
    show(n,num,sw);
    return 0;
}

int selectedSort(int n, int* addr){
    int min,sw=0;
    for(int i=0;i<n;++i){
        min=i;
        for(int j=i;j<n;++j){
            if(addr[j]<addr[min]){
                min=j;
            }
        }
        if(i!=min){
            swap(addr[i],addr[min]);
            ++sw;
        }
    }
    return sw;
}

void show(int n, int* addr, int sw){
    for(int i=0;i<n;++i){
        if(i) printf(" ");
        printf("%d",addr[i]);
    }
    printf("\n");
    printf("%d\n",sw);
}


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

// typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

// rep
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(x) cerr << #x << ": " << x << '\n'
#define DEBUGP(x) cerr << #x << ": " << x.first << " \t" << x.second << '\n'

int n;
string s;
signed main()
{
    cin >> n; 
    cin >> s;

    map<char, int> mp;
    REP(i, n){
        mp[s[i]]++;
    }

    int cnt = 1;
    int col = 0;
    for (auto m : mp){
        cnt *= m.second;
        col++;
    }
    if (col != 3){
        cout << "0" << endl;
        return 0;
    }

    REP(i, n){
        REP(j, n){
            int a, b, c;
            a = i;
            b = i + j;
            c = i + 2*j;
            if (c >= n) break;
            if (s[a] != s[b] && s[b] != s[c] && s[c] != s[a]) cnt--;
        }
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
using namespace std;
int main()
{
	long long H,S;
	int N;
	cin>>H>>N;
	for(int i=0;i<N;i++)
	{
		long long A;
		cin>>A;
		S+=A;
	}
	if(S>=H){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
//Hey u r too far away to know this
//CHIRAGA196
#include <bits/stdc++.h>
using namespace std;
#define     ff                  first
#define     pb                  push_back
#define     ss                  second
#define     IOS                 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define     all(v)              v.begin(), v.end()
#define     allr(v)             v.rbegin(), v.rend()
#define       int               long long
#define       endl             '\n'
const   int N = 1e6+5, Mod = 1e9 + 7;
int32_t main(){
        IOS;
        
        string s; cin>>s;
        int mx = 0, cnt = 0;
        for(auto x:s){
        	if(x == 'S'){
        		mx = max(mx, cnt);
        		cnt = 0;
        	}
        	else cnt++;
        }
        mx = max(mx, cnt);
        cout << mx ;
        return 0;
}

Measured memory_bytes: 3636
/*
    written by Pankaj Kumar.
    country:-INDIA
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll ;
typedef set<pair<int,int>> spi;
typedef set<pair<ll,ll>> spl;
typedef vector<pair<int,int>> vpi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<pair<ll,ll>> vpl;
typedef vector<string> vs;
typedef map<ll,ll> ml;
typedef set<string> ss;
typedef set<char>sc;
typedef set<int> si;
typedef set<ll> sl;
#define pan cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
// define values.
#define mod 1000000007
#define phi 1.618
/* Bit-Stuff */
#define get_set_bits(a) (__builtin_popcount(a))
#define get_set_bitsll(a) ( __builtin_popcountll(a))
#define get_trail_zero(a) (__builtin_ctz(a))
#define get_lead_zero(a) (__builtin_clz(a))
#define get_parity(a) (__builtin_parity(a))
/*  Abbrevations  */
#define ff first
#define ss second
#define mp make_pair
#define line cout<<endl;
#define pb push_back
#define Endl "\n"
// loops
#define loop(i,start,end) for(ll i=ll(start);i<ll(end);i++)
#define loop0(num) for(ll i=0;i<ll(num);i++)
#define forin(arr,n) for(ll i=0;i<n;i++) cin>>arr[i];
// Some print
#define no cout<<"NO"<<endl;
#define yes cout<<"YES"<<endl;
#define cc ll test;cin>>test;while(test--)
// sort
#define all(V) (V).begin(),(V).end()
#define srt(V) sort(all(V))
#define srtGreat(V) sort(all(V),greater<ll>())
// function

ll power(ll x,ll y)
{
    ll res=1;
    while(y>0)
    {
        if(y%2==1)res*=x;
        y/=2; x*=x;
    }
    return res;
}
/* ascii value 
A=65,Z=90,a=97,z=122
*/
/*  -----------------------------------------------------------------------------------*/
ll solve()
{
    ll maxo=1e6+5;
    vector<ll> fre(maxo,0),count(maxo,0);
    ll temp,n,hcf=0;
    cin>>n;
    for(ll i=0;i<n;i++)
    {
        cin>>temp;
        fre[temp]++;
        if(i==0)
            hcf=temp;
        else
            hcf=__gcd(hcf,temp);
    }
    for(ll i=1;i<maxo;i++)
    {
        for(ll j=i;j<maxo;j+=i)
        {
            count[i]+=fre[j];
        }
    }
    ll flag=0;
    for(ll i=2;i<maxo;i++)
    {
        if(count[i]>1)
        {
            flag=1;
            break;
        }
    }
    if(flag==0)
        cout<<"pairwise coprime"<<endl;
    else if(hcf==1)
        cout<<"setwise coprime"<<endl;
    else
        cout<<"not coprime"<<endl;
    return 0;
}

int main()
{
    //freopen("input.txt"a, "r", stdin);
    // cc
    // {
        solve();
    // }
}


Measured memory_bytes: 18616
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector< vector<int> > VVI;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()

int main(){
  int N;
  cin>>N;
  VI A(N);
  rep(i,N) cin>>A[i];
  ll ans=0;
  rep(i,N){
    if(i){
      if(A[i]-A[i-1]>1){
        ans=-1;
        break;
      }else if(A[i]-A[i-1]==1){
        ans++;
      }else ans+=A[i];
    }else{
      if(A[i]){
        ans=-1;
        break;
      }
    }
  }
  cout<<ans<<endl;
}





Measured memory_bytes: 1152
import java.util.Scanner;

class Main {

	public static void main(String[] args) {

		Scanner sc = null;
		try {
			sc = new Scanner(System.in);
			String inBall = "A";
			while (sc.hasNext()) {
				String[] cup = sc.next().split(",");
				if(inBall.equals(cup[0])){
					inBall = cup[1];
				}else if(inBall.equals(cup[1])){
					inBall = cup[0];
				}
			}
			System.out.println(inBall);

		} finally {
			sc.close();
		}
	}
}

Measured memory_bytes: 17152
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<string.h>
#include <iomanip>
#include <sstream>
using namespace std;

int main() {
  int N, D;
  long long ans = 1;
  string s;

  cin >> D >> N;

  while(D > 0){
    ans = ans*100;
    D--;
  }
  if( N == 100){
    cout << ans*N+ans << endl;
  }else{
    cout << ans*N << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char *argv[]) {
	int N;
	string S;
	cin >> N >> S;
	int W = 0, E = 0;
	for (auto c : S) {
		if (c == 'W') W += 1;
		if (c == 'E') E += 1;
	}

	pair<int, int> l = {0, 0}, r = {W, E};
	int ans = N;
	for (int i = 0; i < N; i++) {
		if (S[i] == 'W') {
			r.first --;
		} else {
			r.second --;
		}
		ans = min(ans, l.first + r.second);
		if (S[i] == 'W') {
			l.first ++;
		} else {
			l.second ++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 900
#include <iostream>
#include <sstream>
#include <cstdio>
#include <string>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <vector>
#include <map>

using namespace std;

struct node{
    node(){
		parent=-1;
		depth=0;
		s=-1;
	}
	void set(const int c1,const int c2){
		leaf.first=c1;
		leaf.second=c2;
	}
	int s;
	int height;
	int parent;
	int depth;
	//vector<int> leaf;
	pair<int,int> leaf;
};

int dp(int id);

node dnode[100000];

string spe,si,spo;

int main()
{
	int N,id,c1,c2;
	queue<int> que;
	cin>>N;
	for(int i=0;i<N;i++){
		cin>>id>>c1>>c2;
		dnode[id].set(c1,c2);
	}
	//*
	for(int i=0;i<N;i++){
		if(dnode[i].leaf.first!=-1){
			dnode[dnode[i].leaf.first].parent=i;
			if(dnode[i].leaf.second!=-1){
				dnode[dnode[i].leaf.second].s=dnode[i].leaf.first;
				dnode[dnode[i].leaf.first].s=dnode[i].leaf.second;
			}
		}
		if(dnode[i].leaf.second!=-1){
			dnode[dnode[i].leaf.second].parent=i;
		}
	}//*/
	for(int i=0;i<N;i++){
		if(dnode[i].parent==-1){
			dp(i);
			break;
		}
	}//*/
	cout<<"Preorder"<<endl;
	cout<<spe<<endl;
	cout<<"Inorder"<<endl;
	cout<<si<<endl;
	cout<<"Postorder"<<endl;
	cout<<spo<<endl;
}
int dp(int id)
{
    char dstr[101];
    sprintf(dstr," %d",id);
    spe+=dstr;
	if(dnode[id].leaf.first!=-1){
		dp(dnode[id].leaf.first);
	}
	sprintf(dstr," %d",id);
    si+=dstr;
    if(dnode[id].leaf.second!=-1){
		dp(dnode[id].leaf.second);
	}
	sprintf(dstr," %d",id);
    spo+=dstr;
    return id;
}

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

int main(void){
    int h, w, d;
    cin >> h >> w >> d;
    
    int a[90001][2];
    int input;
    int i, j;
    for(i = 0; i < h; i++){
        for(j = 0; j < w; j++){
            cin >> input;
            a[input][0] = i;
            a[input][1] = j;
        }
    }
    
    int p[90001] = {0};
    for(i = d + 1; i <= h * w; i++){
        p[i] = p[i - d] + abs(a[i][0] - a[i - d][0]) + abs(a[i][1] - a[i - d][1]);
    }
    
    
    int q;
    cin >> q;
    
    int l, r;
    for(i = 1; i <= q; i++){
        cin >> l >> r;
        cout << p[r] - p[l] << endl;
    }
    
    return 0;
}


Measured memory_bytes: 2176
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int lld;

const lld mod = 1e9+7;
const lld INF = 1e9;
//const lld MAXN = 1e9;

int main()
{
	int n;
	cin >> n;
	vector<char> s(n);
	for(int i = 0; i < n; i++)
	{
		cin >> s[i];
	}
	for(int i = 0; i < n; i++)
	{
		if (s[i] == 'Y')
		{
			cout << "Four" << endl;
			return 0;
		}
	}
	cout << "Three" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
using namespace std;
 
int main() {
	double a, b, C;
	cin >> a; cin >> b; cin >> C;
	double S, L, h;
	S = a * b * sin(C * M_PI / 180.0) / 2.0;
	L = a + b + sqrt(a * a + b * b - 2 * a * b * cos(C * M_PI / 180.0));
	h = 2.0 * S / a;
	cout << setprecision(10) << S << endl;
	cout << L << endl;
	cout << h << endl;
	return 0;
}

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

typedef long long ll;
typedef pair<int, int> P;

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 31;
// clang-format on

int main(void)
{
  string S;
  ll K;
  cin >> S >> K;

  // K = 1 ならどんなときも 1 文字目
  if (K == 1) {
    cout << S[0] << endl;
  }
  else {
    // もし 1 文字目が 1 なら 2 文字目、そうでなければ 1 文字目が K の範囲ない
    bool is_all_one = true;
    int idx = 0;
    for (int i = 0; i < K; i++) {
      if (S[i] != '1') {
        is_all_one = false, idx = i;
        break;
      }
    }
    if (is_all_one) {
      cout << S[0] << endl;
    }
    else {
      cout << S[idx] << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 256
//using UnityEngine;
using System;
using System.IO;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

public class Sample7{

	public static void Main(){

		string line;

		line = Console.ReadLine ();

		char[] lineChars = line.ToCharArray ();

		char[] reverse = ReverseSequence (lineChars);


		string result = "";

		foreach (var r in reverse) {

			result += r.ToString ();
		}

		Console.WriteLine (result);

	}


	public static char[] ReverseSequence(char[] str){

		return str.Reverse ().ToArray ();

	}

}

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

int main(){
	
	double x[5],xp,y[5],yp;
	int i,t;
	while(0<=scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&x[0],&y[0],&x[1],&y[1],&x[2],&y[2],&xp,&yp)){
		x[3]=x[0];
		y[3]=y[0];
		x[4]=x[1];
		y[4]=y[1];
		t=0;
		for(i=0;i<3;i++){
			if(((y[i+1]-y[i])/(x[i+1]-x[i])*(xp-x[i])+y[i]-yp)*((y[i+1]-y[i])/(x[i+1]-x[i])*(x[i+2]-x[i])+y[i]-y[i+2])<=0){
				t=1;
				break;
			}
		}

		if(t==1){
			printf("NO\n");
		}else{
			printf("YES\n");
		}

	}

	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define endl '\n';
#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll POSITIVE_INFINITY = 9223372036854775807;
const ll NEGATIVE_INFINITY = -9223372036854775807;
const ll MOD = 1000000007;
const ld PI = acos(-1.0);

template <typename T> inline T bigMod(T A,T B,T M = MOD){A %= M;T ret = 1;while(B){if(B & 1) ret = (ret * A) % M;A = (A * A) % M;B = B >> 1;}return ret;}
template <typename T> inline T invMod (T A,T M = MOD){return bigMod(A,M-2,M);}

const int N = 200005;

int main(){
  FASTER;
  int n;
  cin >> n;
  int ans = 0;
  int a = 0;
  int b = 0;
  int c = 0;
  for (int i = 0; i < n; i++){
    string ar;
    cin >> ar;
    for (int i = 0; i + 1 < ar.size(); i++){
      if (ar[i] == 'A' && ar[i + 1] == 'B'){
        ans++;
      }
    }
    if (ar[0] == 'B' && ar[ar.size() - 1] == 'A'){
      c++;
    }
    else if (ar[0] == 'B'){
      b++;
    }
    else if (ar[ar.size() - 1] == 'A'){
      a++;
    }
  }
  ans += min(a, b);
  if (c > 0){
    if (a || b){
      ans += c;
    }
    else {
      ans += (c - 1);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
//https://arc061.contest.atcoder.jp/tasks/arc061_a
//例題2-1-1 部分和 bit全探索 https://qiita.com/drken/items/e77685614f3c6bf86f44

#include<iostream>

using namespace std;
typedef long long ll;

int main(void){
  string s; cin>>s;
  ll sum = 0;
  ll tmp;
  for(int bit=0; bit < (1<<(s.length()-1)); ++bit){
    tmp = (int)(s[0] -'0');
    for(int i=0; i<s.length()-1; ++i){
      if( bit & (1 << i) ){
        sum += tmp; tmp = (int)(s[i+1] - '0');
      }
      else tmp = 10*tmp + (int)(s[i+1] - '0');
    }
    sum += tmp;
  }
  cout << sum << endl;
  return 0;
}

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

static const long long INF=1e18;
static const int MOD=1000000007;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int N; cin >> N;
    ll a[N];
    ll ans=1;
    for(int i=0;i<N;i++){
        cin >> a[i];
        if(a[i]==0){
            cout << 0 << endl;
            return 0;
        }
    }
    for(int i=0;i<N;i++){
        if((INF/ans)>=a[i]){
            ans*=a[i];
        }else{
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 4404
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
using namespace std;
typedef long long ll;

const int INF = 1001001001;

int main() {
    int N; ll K;
    cin >> N >> K;
    vector<int> A(N), F(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    for (int i = 0; i < N; i++)
    {
        cin >> F[i];
    }
    sort(A.begin(), A.end());
    sort(F.begin(), F.end());
    reverse(F.begin(), F.end());

    ll left = -1, right = 1e12;
    while (left+1 < right) {
        ll mid = (left+right)/2;

        bool ok = [&] {
            ll ex = 0;
            for (int i = 0; i < N; i++)
            {
                ex += max(A[i]-mid/F[i], 0ll);
            }
            return ex <= K;
        }();

        if(ok) {
            right = mid;
        } else {
            left = mid;
        }
    }
    cout << right << endl;

    return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int h[] = new int[n];

		for(int i = 0; i < n; i++){
			h[i] = sc.nextInt();
		}

		int count = 0;;
		while(true){
			//0じゃないところを探す
			int start = -1;
			for(int i = 0; i < n; i++){
				if(h[i] != 0){
					start = i;
					break;
				}
			}

			if(start < 0){
				break;
			}

			count++;

			for(int i = start; i < n; i++){
				if(h[i] == 0){
					break;
				}

				h[i]--;
			}
		}

		System.out.println(count);
	}
}


Measured memory_bytes: 21844
#include<stdio.h>

int main(void){
  int p[100],rank[100];
  int n,m;
  int i,j;
  int tmp;

  while(1){
    scanf("%d %d ",&n,&m);
    if(!n && !m)break;

    for(i=0;i<m;i++){
      p[i] = 0;
      rank[i] = i;
    }
    
    for(i=0;i<n;i++){
      for(j=0;j<m;j++){
	scanf("%d ",&tmp);
        p[j] += tmp;
      }
    }

    for(i=0;i<m-1;i++){
      for(j=i+1;j<m;j++){
	if(p[rank[i]]<p[rank[j]]){
	  tmp = rank[i];
	  rank[i] = rank[j];
	  rank[j] = tmp;
	}
	if(p[rank[i]]==p[rank[j]]){
	  if(rank[i]>rank[j]){
	    tmp = rank[i];
	    rank[i] = rank[j];
	    rank[j] = tmp;
	  }
	}
      }
    }

    for(i=0;i<m;i++){
      printf("%d",rank[i]+1);
      if(i!=m-1)putchar(' ');
    }
    putchar('\n');
  }

  return 0;
}

Measured memory_bytes: 424
#include<iostream>
#include<string>
#include<sstream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<numeric>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};


int main()
{

    int N,K;
    cin >> N >> K;

    double cum[1005] = {};
    for (int i=0; i<1001; ++i)
    {
        cum[i+1] += cum[i] + i+1;
    }

    vector<double> exp;
    vector<double> cum_exp;
    cum_exp.push_back(0);

    for (int i=0; i<N; ++i)
    {
        int tmp;
        cin >> tmp;
        exp.push_back(cum[tmp]/tmp);
        cum_exp.push_back(cum_exp.back() + exp.back());
    }

    double ans = 0;
    for(int i=1 ;i<=N-K+1; ++i)
    {
        if(cum_exp[i+K-1]-cum_exp[i-1] > ans) ans = cum_exp[i+K-1]-cum_exp[i-1];
    }

    printf("%.10f",ans);


    

    return 0;
}

Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    int d=max({a,b,c});
    int e=min({a,b,c});
    int f=a+b+c-d-e;
    if(d%2==e%2&&e%2==f%2){
        cout<<(d-e+d-f)/2<<endl;
    }
    else if(d%2==e%2&&e%2!=f%2){
        cout<<(d-e+d+1-f)/2+1<<endl;
    }
    else if(d%2!=e%2&&e%2!=f%2){
        cout<<(d-f+d+1-e)/2+1<<endl;
    }
    else{
        cout<<(d-e+d-f)/2<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int inf = 1e9;
double pi = 3.14159265359;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, b, a) for (int i = a - 1; i >= b; i--)
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dxx[8] = {1, 1, 1, 0, 0, -1, -1, -1}, dyy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

int main() {
    int n;
    cin >> n;
    int a[n];
    rep (i, 0, n) cin >> a[i];
    ll ans = a[0] / 2;
    a[0] %= 2;
    rep (i, 1, n) {
        if (a[i] == 0) continue;
        ans += (a[i - 1] + a[i]) / 2;
        a[i] = (a[i - 1] + a[i]) % 2;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 640
# -*- coding: utf-8 -*-

n=int(input())
a=list(map(int, input().split()))
a.sort()
d=[0 for _ in range(8)]

flg=False
minim=-1
for i in range(n):
    if a[i]<400:
        d[0]=1
    elif a[i]<800:
        d[1]=1
    elif a[i]<1200:
        d[2]=1
    elif a[i]<1600:
        d[3]=1
    elif a[i]<2000:
        d[4]=1
    elif a[i]<2400:
        d[5]=1
    elif a[i]<2800:
        d[6]=1
    elif a[i]<3200:
        d[7]=1
    else:
        if flg==False:
            minim=sum(d)
            flg=True
        d[0]+=1

if minim==-1:
    minim=sum(d)
elif minim==0:
    minim=1
print(minim,end=' ')
print(sum(d))


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=5000005;
ll n,m;
map<ll,ll>sq;
ll sum[N]={0};
ll a[N];
int main(){
	ll ans=0;
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		sum[i]=sum[i-1]+a[i];
		
	}
	for(int i=1;i<=n;i++){
		sum[i]=(sum[i]-i%m+m)%m;
		
	}
	ll mn=min(m-1,n);
	for(int i=0;i<=mn;i++){
		ans+=sq[sum[i]];
		sq[sum[i]]++;
	}
	for(int i=mn+1;i<=n;i++)
    {
        sq[sum[i-m]]--;
        ans+=sq[sum[i]];
        sq[sum[i]]++;
    }	
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 16384
#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()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define sum accumulate
typedef long long ll;
const int INF = 100000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 1000000007ll;
int main(){
	int n,k;
	std::cin >> n>>k;
	std::vector<int> l(n);
	rep(i,n)std::cin >> l[i];
	sort(all(l),greater<int>());
	std::cout << sum(aall(l,k),0) << std::endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll;
#define rep(i, a, b) for (int i = a; i <= b; ++ i)
const int N = 500005;
using namespace std;
int n, m, bit[N], f[N];
vector <int> vec[N];
struct poi { int l, r; } a[N], b[N];
bool cmpl(poi a, poi b) { return a.l < b.l; }
bool cmpr(poi a, poi b) { return a.r < b.r; }
void put(int x, int y) { for ( ; x <= m; x += x & (- x)) bit[x] += y; } 
int get(int x) { int ret = 0; for ( ; x; x -= x & (- x)) ret += bit[x]; return ret; }
int pre(int x, int y) { return (x / y - 1) * y; }
int main() {
	scanf("%d%d", &n, &m);
	rep(i, 1, n) scanf("%d%d", &a[i].l, &a[i].r), b[i] = a[i];
	sort(a + 1, a + n + 1, cmpr), sort(b + 1, b + n + 1, cmpl);
	rep(i, 1, m) rep(j, 1, m / i) vec[i * j].push_back(i);
	int ltop = 1, rtop = 1;
	rep(i, 1, m) {
		for ( ; ltop <= n && b[ltop].l <= i; ++ ltop) put(b[ltop].l, 1);
		for ( ; rtop <= n && a[rtop].r < i; ++ rtop) put(a[rtop].l, - 1);
		int sz = vec[i].size();
		rep(j, 0, sz - 1) f[vec[i][j]] += ltop - rtop - get(pre(i, vec[i][j]));
	}
	rep(i, 1, m) printf("%d\n", f[i]);
	return 0;
}

Measured memory_bytes: 26112
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/* 
 * File:   main.c
 * Author: Ivan
 *
 * Created on July 19, 2018, 2:20 AM
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX 5000001

/*
 * 
 */

int H, Heap[MAX];

void maxHeapify(int i);
int extract();
void insert(int key);

int main(int argc, char** argv) {
    int key;
    char command[15];
    while (1)
    {
        scanf("%s", command);
        if (strcmp(command, "extract") == 0) printf("%d\n", extract());
        if (strcmp(command, "insert") == 0)
        {
            scanf("%d", &key);
            insert(key);
        }
        else if (strcmp(command, "end") == 0) break;
    }
    return (EXIT_SUCCESS);
}

void maxHeapify(int i)
{
    int left, right, max, temp;
    left = i*2;
    right = i*2+1;
    
    if (left <= H && Heap[left] > Heap[i]) max = left;
    else max = i;
    if (right <= H && Heap[right] > Heap[max]) max = right;
    
    if (max != i)
    {
        temp = Heap[i];
        Heap[i] = Heap[max];
        Heap[max] = temp;
        maxHeapify(max);
    }
}

int extract()
{
    int max;
    if (H < 1) return -1;
    max = Heap[1];
    Heap[1] = Heap[H--];
    maxHeapify(1);
    return max;
}

void insert(int key)
{
    Heap[++H] = -1;
    int i = H, temp;
    if (key < Heap[i]) return;
    Heap[i] = key;
    while ( i > 1 && Heap[i/2] < Heap[i])
    {
        temp = Heap[i];
        Heap[i] = Heap[i/2];
        Heap[i/2] = temp;
        i = i/2;
    }
}


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

using namespace std;

int n,a[300000];
long long ans;

int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;++i){
		scanf("%d",&a[i]);
		a[i]-=i;
	}
	sort(a+1,a+n+1);
	for (int i=1;i<=n/2;++i) ans+=a[n-i+1]-a[i];
	printf("%lld\n",ans);
	
	return 0;
}
			

Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,move(vector<T>(w))))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,move(vector<T>(w,i))))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
	ll n = in(), m = in(), k = in();
	REP(i, n + 1) {
		REP(j, m + 1) {
			if (i * m + j * n - 2 * i * j == k) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
}

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

int main()
{
	unsigned int a, b, c;
	while (cin >> a >> b) {
		a += b;
		c = 0;
		do {
			a /= 10;
			c++;
		} while (a);
		cout << c << endl;
	}
    return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
#define ll long long
// #define mp make_pair
#define F first
#define S second
#define db double
#define pb push_back
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
#define all(a) a.begin(),a.end()
using namespace std;
using namespace __gnu_pbds;

// typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_multiset;
 
 ll mod=1e9 +7;
 
ll expo(ll base,ll exponent,ll mod){
    ll ans=1;
    while(exponent!=0){
        if(exponent&1) ans=(1LL*ans*base)%mod;
        base=(1LL*base*base)%mod;
        exponent>>=1;
    }
    return ans%mod;
}
 
vector<bool>  prime(90000002,true);
void Sieve() 
{ 
   
    for (int p=2; p*p<=90000001; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=90000001; i += p) 
                prime[i] = false; 
        } 
    } 
}

const ll M=3000006;
ll f[M],inv[M];

void compute(){
    f[0]=1;
    rep(i,1,M-1){
        f[i]=(1LL*i*f[i-1])%mod;
    }
    inv[M-1]=expo(f[M-1],mod-2,mod);
    for(ll i=M-2;i>=0;i--){
        inv[i]=(1LL*(i+1)*inv[i+1])%mod;
    }
}
ll C(ll n,ll r){
    return (1LL*((1LL*f[n]*inv[r])%mod)*inv[n-r])%mod;
}

int main()
{
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    // compute();
    // Sieve();
    ll tests=1;
    // cin>>tests;
    while(tests--)
    {
        ll n,x,t;
        string s;
        cin>>s;
        ll rem=0;
        for(auto x:s)
        {
          rem+=x-'0';
          rem%=9;
        }
        if(rem==0) cout<<"Yes";
        else cout<<"No";

    }

    return 0;
}

Measured memory_bytes: 14592
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        try {
            // 標準入力
            InputStreamReader isr = new InputStreamReader(System.in);
            BufferedReader br = new BufferedReader(isr);
            String strArr[] = br.readLine().split(" ");
            int count5 = 0;
            int count7 = 0;
            for (int i = 0; i < strArr.length; i++) {
                int temp = Integer.parseInt(strArr[i]);
                if (temp == 5) {
                    count5++;
                } else if (temp == 7) {
                    count7++;
                }
            }
            if (count5 == 2 && count7 == 1) {
                System.out.println("YES");
            } else {
                System.out.println("NO");
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

Measured memory_bytes: 19412
/*Huyyt*/
#include<bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
#define pb push_back
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll LLmaxn = 2e18;
const int N = 2e3 + 5;
int n;
int s;
int dp[N][N];
int pos[2][N];
int pre[2][N * 2][N];
void init()
{
        for (int kind = 0; kind <= 1; kind++)
        {
                for (int i = 0; i < s; i++)
                {
                        for (int j = n - 1; j >= 1; j--)
                        {
                                pre[kind][i][j - 1] += pre[kind][i][j];
                        }
                }
                for (int i = 0; i < s - 1; i++)
                {
                        for (int j = 0; j < n; j++)
                        {
                                pre[kind][i + 1][j] += pre[kind][i][j];
                        }
                }
        }
        for (int i = 0; i <= n; i++)
        {
                for (int j = 0; j <= n; j++)
                {
                        dp[i][j] = INT_MAX;
                }
        }
        dp[0][0] = 0;
}
int main()
{
        cin >> n;
        s = n * 2;
        for (int i = 0; i < s; i++)
        {
                string ch;
                cin >> ch;
                int kind = 1;
                int x;
                cin >> x;
                x--;
                if (ch[0] == 'W')
                {
                        kind = 0;
                }
                pos[kind][x] = i;
                pre[kind][i][x]++;
        }
        init();
        for (int i = 0; i <= n; i++)
        {
                for (int j = 0; j <= n; j++)
                {
                        if (i < n)
                        {
                                int p = pos[0][i];
                                dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + pre[0][p][i + 1] + pre[1][p][j]);
                        }
                        if (j < n)
                        {
                                int p = pos[1][j];
                                dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + pre[0][p][i] + pre[1][p][j + 1]);
                        }
                }
        }
        cout << dp[n][n] << endl;
        return 0;
}


Measured memory_bytes: 78720
package main

import "fmt"

func main() {
	var N, Y int
	fmt.Scanf("%d %d", &N, &Y)

	for i := 0; i < N+1; i++ {
		for j := 0; j < N+1; j++ {
			if k := N - i - j; k >= 0 {
				if 10000*i+5000*j+k*1000 == Y {
					fmt.Println(i, j, k)
					return
				}
			}
		}
	}
	fmt.Println(-1, -1, -1)
}


Measured memory_bytes: 512
#define _GIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;

int g[15][15];

int main(void) {
  int N;
  cin >> N;
  rep(i, N) {
    rep(j, N) {
      g[i][j] = -1;
    }
  }
  rep(i, N) {
    int m;
    cin >> m;
    rep(j, m) {
      int x, y;
      cin >> x >> y;
      --x;
      g[i][x] = y;
      // i番目の人はx番目の人から見て正直者か？
    }
  }

  int ans = 0;
  rep(i, 1<<N) {
    // すべての正直者パターンを作る
    vector<int> d(N);
    rep(j, N) {
      if (i >> j & 1) {
        d[j] = 1;
      }
    }

    bool ok = true;
    rep(j, N) {
      if (d[j]) {
        // jさんが正直者ならば、証言が成立するか？
        rep(k, N) {
          if (g[j][k] == -1) {
            // kからの証言はない
            continue;
          }
          if (g[j][k] != d[k]) {
            ok = false;
          }
        }
      }
    }
    if (ok) {
      ans = max(ans, __builtin_popcount(i));
    }
  }

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

Measured memory_bytes: 256