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

int main() {
	int N;
	string S;
	cin >> N >> S;
	int result=0;
	for (int i = 1; i < N; i++) {
		int sum_ = 0;
		string X = S.substr(0, i);
		string Y = S.substr(i, N - i);
		sort(X.begin(), X.end());
		X.erase(unique(X.begin(), X.end()), X.end());
		sort(Y.begin(), Y.end());
		Y.erase(unique(Y.begin(), Y.end()), Y.end());
		for (int j = 0; j < X.length(); j++) {
			string X_sub = X.substr(j, 1);
			for (int k = 0; k < Y.length(); k++) {
				string Y_sub = Y.substr(k, 1);
				if (X_sub == Y_sub) {
					sum_ += 1;
				}
			}
		}
		if (sum_ > result) result = sum_;
	}
	cout << result << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>
#include<math.h>

#define DIV 1000000007
using namespace std;
using ll = long long;

int main(void) {
    int N;
    cin >> N;

    vector<int> cnt(N + 1);
    for (int i = 0; i < N-1; i++) {
        int x;
        cin >> x;
        cnt[x]++;
    }

    for (int i = 1; i <= N; i++) {
        cout << cnt[i] << endl;
    }

}

Measured memory_bytes: 4012
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<bitset>
#include<random>
#include<cstdint>
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
#define shosu setprecision(17)
  
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<char,P> Q;
ll longinf=(1ll<<60);
ll inf=1ll<<29;

int n;
int main(){
      int n;
      cin>>n;
      ll a[n];
      rep0(i,n){
            cin>>a[i];
      }
      sort(a,a+n);
      vector<P> p;
      ll now=a[0];
      int nowitr=0;
      p.push_back({a[0],1});
      rep1(i,n-1){
            if(a[i]==now){
                  p[nowitr].second++;
            }
            else{
                  nowitr++;
                  p.push_back({a[i],1});
                  now=a[i];
            }
      }
      int nn=p.size();
      //rep0(i,nn) cout<<p[i].first<<" "<<p[i].second<<endl; 
      sort(p.begin(),p.end());
      ll beki=1ll<<32;
      ll ans=0;
      bool used[n];
      fill(used,used+n,false);
      while(beki>0){
            rep0(i,nn){
                  P aa={beki-p[i].first,0};
                  auto j=lower_bound(p.begin(),p.end(),aa) - p.begin();
                  if(j<nn){
                  if(p[i].first+p[j].first==beki){
                        while((i==j)&&(p[i].second>=2)){
                              p[i].second-=2;
                              ans++;
                        }
                        if(i==j){
                              break;
                        }
                        while((p[i].second>=1)&&(p[j].second>=1)){
                              ans++;
                              p[i].second--;
                              p[j].second--;
                        }
                  }
                  }
            }
            beki>>=1;
      }
      cout<<ans<<endl;
      return 0;
}

Measured memory_bytes: 7280
n = int(input())
x = list(map(int,input().split()))
y = sorted(x)
m = (y[(n-2)//2]+y[n//2])/2
for i in range(n):
    if x[i] <= m:
        print(y[n//2])
    else:
        print(y[(n-2) // 2])


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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  double r, g;
  cin >> r >> g;
  cout << g * 2 - r << '\n';
}


Measured memory_bytes: 3756
//https://beta.atcoder.jp/contests/dwacon5th-prelims/tasks/dwacon5th_prelims_d
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}}star;
#define DEBUG if(0)
#endif
#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}
class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }};
int N;
int D;
int cnt[1123][1123];
int B[2123][2123];
int C[2123][2123];
bool f(int r){
    //cout<<(r/D)*(LL)(r/D)<<endl;
    for(int i:range(D)){
        for(int j:range(D)){
            bool ok=true;
            for(int s:range(D)){
                for(int t:range(D)){
                    int ni=(i+s)%D;
                    int nj=(j+t)%D;
                    LL rc=r/D;
                    if(ni<r-rc*D)rc++;
                    LL cc=r/D;
                    if(nj<r-cc*D)cc++;
                    if(rc*cc<cnt[s][t]){
                        ok=false;
                    }
                }
            }
            if(ok)return true;
        }
    }
    return false;
}
bool ff(int r){

    LL a=(r/D)*(LL)(r/D);
    LL b=(r/D)*(LL)(r/D+1);
    LL c=(r/D+1)*(LL)(r/D+1);
    int md=r%D;
    int sum=0;
    for(int i:range(D))for(int j:range(D)){
        B[i+1][j+1]=B[i+1+D][j+1]=B[i+1][j+1+D]=B[i+1+D][j+1+D]=0;
        C[i+1][j+1]=C[i+1+D][j+1]=C[i+1][j+1+D]=C[i+1+D][j+1+D]=0;

        if(cnt[i][j]>c)return false;
        if(cnt[i][j]<=a)continue;
        sum++;
        if(cnt[i][j]<=b){
            B[i+1][j+1]=B[i+1+D][j+1]=B[i+1][j+1+D]=B[i+1+D][j+1+D]=1;
        }
        if(cnt[i][j]<=c){
            C[i+1][j+1]=C[i+1+D][j+1]=C[i+1][j+1+D]=C[i+1+D][j+1+D]=1;
        }
    }
    for(int i:range(2*D))for(int j:range(2*D)){
        B[i+1][j+1]+=B[i+1][j]+B[i][j+1]-B[i][j];
        C[i+1][j+1]+=C[i+1][j]+C[i][j+1]-C[i][j];
    }
    for(int i:range(D))for(int j:range(D)){
        int k = 0;
        k+= C[i+md][j+md]-C[i][j+md]-C[i+md][j]+C[i][j];
        k+= B[i+md][j+D]-B[i][j+D]-B[i+md][j+md]+B[i][j+md];
        k+= B[i+D][j+md]-B[i+md][j+md]-B[i+D][j]+B[i+md][j];
        if(k==sum)return true;
    }
    return false;
}
int main(){
    cin>>N>>D;
    //if(D>30)return -1;
    for(int i:range(N)){
        int x,y;
        cin>>x>>y;
        cnt[x%D][y%D]++;
    }
    int lb=0,ub=1e7;
    while(ub-lb>1){
        const int mid=(lb+ub)/2;
        if(ff(mid))ub=mid;
        else lb=mid;
    }
    cout<<lb<<endl;
    return 0;
}

Measured memory_bytes: 39808
n,m=map(int,input().split())
k=n*(n-1)/2
l=m*(m-1)/2
k=int(k)
l=int(l)
if n>=2 and m>=2:
    print(k+l)
elif n>=2 and m<2:
    print(k)
elif n<2 and m>=2:
    print(l)
else:
    print(0)

Measured memory_bytes: 3060
import math
N = int(input())
m = int(math.sqrt(N))
a = 0
ans = 0
count = 1

for i in range(1, m+1):
    if N % i == 0:
        a = i

a = max(a, (N//a))

while True:
    if a >= 10:
        count += 1
        a = a// 10
    else:
        break
    
print(count)

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

class Main {

	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		try {
			String input = br.readLine();
			String[] splitInput = input.split(" ");

			int W = Integer.parseInt(splitInput[0]);
			int H = Integer.parseInt(splitInput[1]);
			int x = Integer.parseInt(splitInput[2]);
			int y = Integer.parseInt(splitInput[3]);
			int r = Integer.parseInt(splitInput[4]);
			
			if (
					!(
					       (x >= -100 && y <= 100)
					    && (y >= -100 && y <= 100)
					    && (W >=    0 && W <= 100)
					    && (H >=    0 && H <= 100)
					    && (r >=    0 && r <= 100)
				     )
				) {
				throw new IllegalArgumentException();
			}
			
			int intialW = 0;
			int intialH = 0;
			
			String ans;
			if (((y - r) < intialH || (y - r) > H)) {
				ans = "No";
			} else if (((y + r) < intialH || (y + r) > H)) {
				ans = "No";
			} else if (((x - r) < intialW || (x - r) > W)) {
				ans = "No";
			} else if (((x + r) < intialW || (x + r) > W)) {
				ans = "No";
			} else {
				ans = "Yes";
			}
			
			System.out.println(ans);

			
			
		
		} catch(NumberFormatException e) {
			e.printStackTrace();
		} catch(IllegalArgumentException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

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

int main() {
	int x;
	cin>>x;
	while(x!=0){
		
	int n=0;
	x=1000-x;
	
	if(x>=500){
		n=x/500;
		x=x%500;
	}
	if(x>=100){
		n+=x/100;
		x=x%100;
	}
	if(x>=50){
		n+=x/50;
		x=x%50;
	}
	if(x>=10){
		n+=x/10;
		x=x%10;
	}
	if(x>=5){
		n+=x/5;
		x=x%5;
	}
	if(x>=1){
		n+=x/1;
	}
	if(x==1){
		n=1;
	}
	cout<<n<<endl;
	cin>>x;
	}
	
	
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<long int> a(n);
    int i;

    for(i=0; i<n; i++){
        cin >> a.at(i);
    }
    sort(a.begin(),a.end(),greater<int>());

    long long int ans=0;
    for(i=1; i<n; i++){
        ans+=a.at(i/2);
    }
    cout << ans << endl;
}

Measured memory_bytes: 4824
#include<bits/stdc++.h>
using namespace std;
string s;
int main()
{
	cin>>s;
	for(int i=0;i<s.size();i++)
	{
		for(int j=s.size()-1;j>i;j--)
		{
			if(s[j]==s[i])
			{
				cout<<"no"<<endl;
				return 0;
			}
		}
	}
	cout<<"yes"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fre(i,t,n)  for(int i =(t);i<=(n);++i)
#define fer(i,n,t)  for(int i =(n);i>=(t);--i)
#define mp make_pair
#define pb push_back
typedef long long ll;
void smain();
int main(){
    ios::sync_with_stdio(false);
    smain();
    return 0;
}
const int maxn = 1e5+100;
ll P[maxn];
ll X[maxn];
ll ans=0;
void smain(){
    int N;
    ll S;
    cin>>N>>S;
    fre(i,1,N)  cin>>X[i]>>P[i];
    int i=1,j=N;
    int flag=-1;
    while(X[i]<S&&X[j]>S)
    {
        if(P[i]>=P[j]){
            P[i]+=P[j];
            if(flag!=1) flag=1,ans+=(X[j]-X[i]);
            --j;
        }
        else{
            P[j]+=P[i];
            if(flag!=0) flag=0,ans+=(X[j]-X[i]);
            ++i;
        }
    }
    ans+=max(abs(S-X[i]),abs(S-X[j]));
    cout<<ans<<endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <deque>
#include <cmath>
#include <map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include "iomanip"
#include <cstdio>
#include <cstring>
#include <set>
#include <vector>
#include <fstream>
#include <algorithm>
#include <queue>
#include <cassert>
#include <stack>

using namespace std;



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


    string r;
    cin >> r;
    vector<int> a (25);
    for (char c : r){
        a[c - 'A']++;
    }
    int count = 0;
    for (int c : a){
        if (c > 1){
            count++;
        }
    }

    cout << (count == 2 ? "Yes" :"No");
    return 0;
}




void print(vector<int> &b) {
    for (auto i : b) {
        cout << i << " ";
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    int n;
    cin >> n;
    vector<ll> a(n), b(n);
    REP(i, n) cin >> a[i] >> b[i];
    
    ll sum = 0;
    for(int i = n-1; i >= 0; i--) {
        a[i] += sum;
        if (a[i] % b[i] == 0) sum = sum;
        else sum += b[i] - (a[i] % b[i]);
    }

    cout << sum << endl;
    
    return 0;
}

Measured memory_bytes: 4760
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <algorithm>
#include <queue>
#include <iterator>
#include <functional>
#include <numeric>
#include <cmath>
#include <stack>
#include <limits>
#include <ctime>

using namespace std;

#define ll long long
#define sc(n) static_cast<ll>(n)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int main() {
	IO;
#ifdef _DEBUG
	ifstream cin("In.txt");
#endif	
	ll n,t;
	vector<vector<ll> > vc(3, vector<ll>(3));
	for (auto& i : vc) {
		for (auto& j : i) {
			cin >> j;
		}
	}
	cin >> n;
	for (size_t q = 0; q < n; q++) {
		cin >> t;
		for (auto& i : vc) {
			for (auto& j : i) {
				if (j == t) {
					j = 0;
				}
			}
		}
	}
	for (int i = 0; i < 3; i++) {
		int s = 0;
		for (int j = 0; j < 3; j++) {
			s += vc[i][j];
		}
		if (!s) {
			cout << "Yes" << endl;
			return 0;
		}
	}

	for (int i = 0; i < 3; i++) {
		int s = 0;
		for (int j = 0; j < 3; j++) {
			s += vc[j][i];
		}
		if (!s) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	int s = 0;
	for (int j = 0; j < 3; j++) {
		s += vc[j][j];
	}
	if (!s) {
		cout << "Yes" << endl;
		return 0;
	}

	s = 0;
	for (int j = 0; j < 3; j++) {
		s += vc[2-j][j];
	}
	if (!s) {
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#include <iomanip>
#define fi first
#define se second
#define fcout(n) cout<<fixed<<setprecision((n))
#define cinl(str) getline(cin,(str))
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=10000009;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };
int A=0;
void judge(char x,char y,char z){
	if(x=='o'&&y=='o'&&z=='o'){
		cout<<'o'<<endl;
		A++;
	}
	if(x=='x'&&y=='x'&&z=='x'){
		cout<<'x'<<endl;
		A++;
	}
}
int main() {
	string c;
	while(true){
		A=0;
		cin>>c;
		if (cin.eof())break;
		judge(c[0],c[1],c[2]);
		judge(c[0],c[4],c[8]);
		judge(c[0],c[3],c[6]);
		judge(c[1],c[4],c[7]);
		judge(c[2],c[5],c[8]);
		judge(c[2],c[4],c[6]);
		judge(c[3],c[4],c[5]);
		judge(c[6],c[7],c[8]);
		if(A==0){
			cout<<'d'<<endl;
		}
	}
}

Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
#define int int64_t
#define endl '\n'
vector<int> sums;

int get(int l, int r) {
     if (l) {
          return sums[r] - sums[l - 1];
     } else {
          return sums[r];
     }
}

signed main() {
     ios::sync_with_stdio(false);
     cin.tie();
     cout.tie();
     int n, k;
     cin >> n >> k;
     vector<int> a(n);
     for (auto &el : a) {
          cin >> el;
     }
     cout << (n-3 + k)/(k-1) ;
     return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> p(n);
  rep(i, n) cin >> p[i];
  int k = 0;
  rep(i, n) if(p[i] != i + 1) k++;
  if(k <= 2) puts("YES");
  else puts("NO");
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define MAX 100000

int parent(int i){return i/2;}
int left(int i){return 2*i;}
int right(int i){return 2*i+1;}

int main(){
	int H,i,A[MAX+1];//1????????????????????????????????????
	cin>>H;
	for (i = 1; i <= H; ++i) {cin>>A[i];	}
	for (i = 1; i <= H; ++i) {
		cout<<"node "<<i<<": key = "<<A[i]<<", ";
		if(parent(i)>=1)cout<<"parent key = "<<A[parent(i)]<<", ";
		if(left(i)<=H)cout<<"left key = "<<A[left(i)]<<", ";
		if(right(i)<=H)cout<<"right key = "<<A[right(i)]<<", ";
		cout<<endl;
	}
}

Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define ll long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define fr(i,a,b) for(int i=a;i<b;i++)
#define frr(i,a,b) for(int i=a;i>=b;i--)
//vector
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define pp pop_back
//pair
#define pi pair<int ,int >
#define mk make_pair
#define ff first
#define ss second
//set
#define si set<int>
#define sit set<int>::iterator 
using namespace std;
int main()
{
fast;
int x,y;cin>>x>>y;
int t=(y-2*x)/2,tt=(4*x - y)/2;
if(t>=0 && tt>=0 && (t+tt==x)) cout<<"Yes\n";
else cout<<"No\n";
return 0;
}

Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
#define vec vector<ll>
#define mat vector<vector<ll> >
#define fi first
#define se second
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
typedef long double ld;
typedef complex<double> comp;
const ll inf=1e9+7;
const ll mod=998244353;
const int MAX=1000010;



int siz[100010];
int par[100010];
int depth[100010];
void init(int n){
  for(int i=0;i<=n;i++){
      par[i]=i;
      depth[i]=0;
  }
  rep(i,n+1){
      siz[i]=1;
  }
}
int root(int x){
  return par[x]==x?x:par[x]=root(par[x]);
}
bool same(int x,int y){
  return root(x)==root(y);
}
void unite(int x,int y){
  x=root(x);
  y=root(y);
  ll sx=siz[x];
  ll sy=siz[y];
  if(x==y)return;
  if(depth[x]<depth[y]){
      par[x]=y;
  }else{
      par[y]=x;
      if(depth[x]==depth[y])depth[x]++;
  }
  siz[root(x)]=sx+sy;
}


signed main(){
    ll n;cin>>n;
    init(n);
    ll k;cin>>k;
    vector<ll>p(n);
    vector<ll>c(n);
    rep(i,n){
        cin>>p[i];
        p[i]--;
        unite(i,p[i]);
    }
    rep(i,n)cin>>c[i];
    ll ans=-inf*inf;
    rep(i,n){
        ll cnt=0;
        ll ma=c[p[i]];
        ll now=i;
        ll j;
        for(j=0;j<min(siz[root(i)],k);j++){
            now=p[now];
            cnt+=c[now];
            ma=max(ma,cnt);
        }
        if(j<k&&cnt>0){
            cnt=cnt*(k/siz[root(i)]-1);
        }else{
            ans=max(ma,ans);
            continue;
        }
        ma=max(ma,cnt);
        now=i;
        rep(l,k%siz[root(i)]+siz[root(i)]){
            now=p[now];
            cnt+=c[now];
            ma=max(ma,cnt);
        }
        ans=max(ma,ans);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3832
#include<stdio.h>
int main(){
	int a = 0;
	int b;
	int c;
	int d;
	scanf("%d", &a);
	b = a/3600;
	c = (a%3600)/60;
	d = (a%3600)%60;
	printf("%d:%d:%d\n", b, c, d);
	return 0;
}

Measured memory_bytes: 2692
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
using edge = struct { int to; int cost; };
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 (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  IOS;
  int n; cin >> n;
  vector<int> a(n);

  int ans = 0;
  REP(i,n) {
    int a; cin >> a;
    if ((i+1) % 2 == 1 && a % 2 == 1) ans++;
  }
  COUT(ans);
  return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>

using namespace std;


bool isprime(int a){
  for (int i = 2; i <= sqrt(a); i++){
    if (a % i == 0)
      return false;
  }

  return true;
}

int ret(int a){
  if (isprime(a))
    return a;
  else
    return ret(++a);
}

int main(void){
  int x;
  cin >> x;

  cout << ret(x) << endl;

  return 0;
}


Measured memory_bytes: 256
// Template
#include <bits/stdc++.h>
#define rep_override(x, y, z, name, ...) name
#define rep2(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, r) for (int i = (l); i < (r); ++i)
#define rep(...) rep_override(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr int inf = 1001001001;
constexpr ll INF = 3003003003003003003;
template <typename T> inline bool chmin(T& x, const T& y) {if (x > y) {x = y; return 1;} return 0;}
template <typename T> inline bool chmax(T& x, const T& y) {if (x < y) {x = y; return 1;} return 0;}
struct IOSET {IOSET() {cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10);}} ioset;

constexpr int D = 365;
int c[26], d[D][26], t[D];

void input() {
    cin >> c[0];
    rep(i, 26) cin >> c[i];
    rep(i, D) rep(j, 26) cin >> d[i][j];
}
void output() {
    rep(i, D) cout << t[i] + 1 << "\n";
}

// day 日目までのスコアを求める
int score(int day) {
    int ans = 0;
    int last[26];
    rep(i, 26) last[i] = -1;
    rep(i, day + 1) {
        ans += d[i][t[i]];
        rep(j, 26) ans -= c[j] * (i - last[j]);
    }
    return ans;
}

int main() {
    input();
    
    // 貪欲
    rep(i, D) {
        int max_score = -inf, max_id = -1;
        rep(j, 26) {
            t[i] = j;
            if (chmax(max_score, score(i))) max_id = j;
        }
        t[i] = max_id;
    }
    
    output();
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<ll> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e18;

int main(){
    int n;
    cin >> n;
    int k = n %10;
    if(k==3){
        cout << "bon" << endl;
        return 0;
    }
    else if(k==1||k==0||k==6||k==8){
        cout << "pon" << endl;
    }
    else{
        cout << "hon" << endl;
    }
    return 0;
}

Measured memory_bytes: 3596
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	double a;
	cin>>a;
	a/=3;
	cout<<shosu(9)<<a*a*a<<endl;
}






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

int main() {
	int k, n, ans;
	cin >> k >> n;
	for (int i = 0; i < n; i++)cin >> ans;
	ans = 1;
	k -= n;
	while (k > 0) {
		k -= (n - 1);
		ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353
dd = [(0,-1),(1,0),(0,1),(-1,0)]
ddn = [(0,-1),(1,-1),(1,0),(1,1),(0,1),(-1,-1),(-1,0),(-1,1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)

n = I()
s = S()
r = 0
for i in range(1,n):
    if s[i] == 'E':r+=1
res = r
temp = r
for i in range(1,n):
    if s[i-1] == 'W':temp += 1
    if s[i] == 'E':temp -= 1
    if temp<res:res = temp
print(res)





Measured memory_bytes: 6480
#include<iostream>
using namespace std;
int main(){
	int a,b;
	char op;
	while(true){
		cin>>a>>op>>b;
		if(op=='?')break;
		switch(op){
		case '+':
			cout<<a+b<<endl;
			break;
		case'-':
			cout<<a-b<<endl;
			break;
		case'*':
			cout<<a*b<<endl;
			break;
		case'/':
			cout<<a/b<<endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 3096
from collections import defaultdict


def solve(pre_is_positive, a_list):
    total = 0
    ans = 0
    for a in a_list:
        total += a
        if pre_is_positive and total >= 0:
            ans += abs(total) + 1
            total = -1
        elif not pre_is_positive and total <= 0:
            ans += abs(total) + 1
            total = 1
        pre_is_positive = total > 0

    return ans


def main():
    n = int(input())
    a_list = list(map(int, input().split()))
    print(min(solve(True, a_list), solve(False, a_list)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 14588
/* 
* ID: juryc
* PROG: Prediction and Restriction
* LANG: C++
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
int n,k; cin>>n>>k;
int r,s,p; cin>>r>>s>>p;
string t; cin>>t;
array<char,3> c={'r','s','p'};
vector<array<int,3> > dp(n,{0,0,0}); 
auto f=[&](char a,char b){ if(a=='s'&&b=='r') return r; else if(a=='p'&&b=='s') return s; else if(a=='r'&&b=='p') return p; return 0; };
for(int i=0;i<n;i++){
for(int j=0;j<3;j++){
if(i<k){ dp[i][j]=f(t[i],c[j]); }
else {
for(int m=0;m<3;m++){
if(m==j) continue;
else dp[i][j]=max(dp[i][j],dp[i-k][m]+f(t[i],c[j])); 
}
}
}
}
ll ans=0;
vector<int> vis(n,0); 
for(int i=0;i<n;i++){
if(vis[i]) continue;
else {
int j=i;
while(j+k<n){  j+=k; vis[j]=1;  }
ans+=*max_element(dp[j].begin(),dp[j].end()); 
}
}
cout<<ans<<"\n"; 
return 0;
}



Measured memory_bytes: 5088
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <limits>
using namespace std;
using ll = long long;

const int p=1e9+7;

ll mpow(ll x, ll n) { //x^nの計算
  ll res = 1;
  while (n > 0) {
    if (n & 1){
      res = res*x % p;  // n の最下位bitが 1 ならば x^(2^i) をかける
    }
    x = x*x % p;
    n = n >> 1;  // n を1bit 左にずらす
  }
  return res;
}

int main(){
  int N;
  cin >> N;
  ll ans=mpow(10,N)-2*mpow(9,N)+mpow(8,N);
  while(ans<0){
    ans+=p;
  }
  cout << ans%p << endl;
}

Measured memory_bytes: 3592
#include<stdio.h>
char S[100005];
int i,f,l,p,e,e2,np;
int main()
{
	for(;gets(S),S[0]!='#';)
	{
		for(i=1,e=f=0,p=(S[0]-'0'-1)%3;S[i];i++)
		{
			np=(S[i]-'0'-1)%3;
			if(!f)//right
			{
				if(p>np)
					e++;
				else 
					f=!f;
			}
			else//left
			{
				if(p<np)
					e++;
				else 
					f=!f;
			}
			p=np;
		}
		for(i=1,e2=f=0,p=(S[0]-'0'-1)%3;S[i];i++)
		{
			np=(S[i]-'0'-1)%3;
			if(f)//right
			{
				if(p>np)
					e2++;
				else 
					f=!f;
			}
			else//left
			{
				if(p<np)
					e2++;
				else 
					f=!f;
			}
			p=np;
		}
		printf("%d\n",e<e2?e:e2);
	}
	return 0;
}

Measured memory_bytes: 604
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>

using namespace std;

#define ll long long

void solve()
{
    ll a, b;
    cin >> a >> b;
    if (a < b)
    {
        for (ll i = 0; i < b; i++)
        {
            cout << a;
        }
        cout << endl;
    }
    else
    {
        for (ll i = 0; i < a; i++)
        {
            cout << b;
        }
        cout << endl;
    }
}

int main()
{
    solve();
    return 0;
}


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

int main()
{
    int d,m,a=0,mm,n,nn;
    cin>>m>>d;
    for(int i=22;i<=d;i++)
    {
    	int aa=i;
        n=aa%10;
        nn=aa/10;
        if(n<2||nn<2) continue;
        mm=n*nn;
        if((mm<=m)&&(mm>=4)) a++;
    }
    cout<<a;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#include <cmath>

using namespace std;

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const ll inf = 1e18+7;
const ll mod = 1e9+7;

//階乗
int factorial(int k){
    int result=1;
    for (int i=1;i<=k;++i){
        result*=i;
    }
    return result;
}

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

    int sum=1,ans=0;

    while(b>sum){
        ans++;
        sum+=a-1;
    }

    cout<<ans<<endl;
}



Measured memory_bytes: 256
N=int(input())

P= [tuple(map(int,input().split())) for i in range(N)]


from math import sqrt
def d(p1,p2):
    x1,y1=p1
    x2,y2=p2
    return sqrt((x1-x2)**2 + (y1-y2)**2)

s=0
n=0

import itertools
from functools import reduce
for p in itertools.permutations(P):
    s += sum( [ d(p[i],p[i+1]) for i in range(N-1) ] )
    n+=1
print(s/n)


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

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	long long max;
	cin >> max;

	long long answer;
	for (long long i = 0; i < max; --i) {
		long long temp = i * i;
		if (temp <= max) {
			answer = temp;
		} else {
			break;
		}
		
	}
	cout << answer << endl;
	return 0;
}

Measured memory_bytes: 888
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
#include <set>
using namespace std;

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


int main(){
	int n;
	cin >> n;
	map<string, int64_t> mp;
	rep(i, n) {
		string s;
		cin >> s;
		sort(s.begin(), s.end());
		mp[s]++;
	}
	int64_t res = 0;
	for (auto s : mp) {
		int64_t num = s.second;
		if (num >= 2) res += num*(num-1)/2;
	}
	cout << res << endl;
}

Measured memory_bytes: 11136
using System;
class A{
  public static void Main(){
    var s = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
    Console.WriteLine((Math.Abs(s[0]-s[2])<=s[3] || (Math.Abs(s[0] - s[1]) <= s[3] && Math.Abs(s[2] - s[1]) <= s[3])?"Yes":"No"));
  }
}

Measured memory_bytes: 11092
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class MainClass
{
    static void Main()
    {
        int N = int.Parse(ReadLine());
        var D = ReadLine().Split().Select(int.Parse).ToArray();
        var A = new int[N];
        int max = 0;
        for (int i = 0; i < N; i++)
        {
            A[D[i]]++;
            max = Max(max, D[i]);
        }
        if (A[0] != 1||D[0]!=0)
        {
            WriteLine(0);return;
        }
        Modular ans = 1;
        for (int i = 0; i < max; i++)
        {
            ans *= Modular.Pow(A[i], A[i + 1]);
        }
        WriteLine((long)ans);
    }
}
class Modular
{
    private const long M = 998244353;
    private long value;
    public Modular(long value) { this.value = value; }
    public static implicit operator Modular(long a)
    {
        var m = a % M;
        return new Modular((m < 0) ? m + M : m);
    }
    public static Modular operator +(Modular a, Modular b)
    {
        return a.value + b.value;
    }
    public static Modular operator -(Modular a, Modular b)
    {
        return a.value - b.value;
    }
    public static Modular operator *(Modular a, Modular b)
    {
        return a.value * b.value;
    }
    public static Modular Pow(Modular a, long n)
    {
        switch (n)
        {
            case 0:
                return 1;
            case 1:
                return a;
            default:
                var p = Pow(a, n / 2);
                return p * p * Pow(a, n % 2);
        }
    }
    public static Modular operator /(Modular a, Modular b)
    {
        return a * Pow(b, M - 2);
    }
    private static readonly List<int> facs = new List<int> { 1 };
    private static Modular Fac(int n)
    {
        for (int i = facs.Count; i <= n; ++i)
        {
            facs.Add((int)(Math.BigMul(facs.Last(), i) % M));
        }
        return facs[n];
    }
    public static Modular Ncr(int n, int r)
    {
        return (n < r) ? 0
             : (n == r) ? 1
                        : Fac(n) / (Fac(r) * Fac(n - r));
    }
    public static explicit operator int(Modular a)
    {
        return (int)a.value;
    }
}


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

int main() {
  int N;
  long long C,K;
  cin >> N >> C >> K;
  vector<long long> T(N);
  for(int i=0;i<N;i++){
    cin >> T.at(i);
  }
  sort(T.begin(),T.end());
  int count=0;
  for(int i=0;i<N;){
    count++;
    int NEW=i;
    while(i<N && T.at(i)-T.at(NEW) <=K  && i-NEW<C){
      i++;
    }
  }
    cout << count << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
int main(void){
    int A, B, M;
    int a[100000+5], b[100000+5];
    int x[100000+5], y[100000+5], c[100000+5];
    
    scanf("%d %d %d", &A, &B, &M);
    for(int i=1; i<=A; i++)scanf("%d", &a[i]);
    for(int i=1; i<=B; i++)scanf("%d", &b[i]);
    for(int i=0; i<M; i++)scanf("%d %d %d", &x[i], &y[i], &c[i]);
    
    int ans=0;
    
    // 割引券無し
    int min=a[1];
    for(int i=1; i<A; i++)if(a[i]<min)min=a[i];
    ans+=min;
    
    min=b[1];
    for(int i=1; i<B; i++)if(b[i]<min)min=b[i];
    ans+=min;
    
    // 割引券
    for(int i=0; i<M; i++){
        if(a[x[i]]+b[y[i]]-c[i]<ans)ans=a[x[i]]+b[y[i]]-c[i];
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 3688
import * as fs from 'fs';

//in
// 2
// ip cc
//out
// icpc
function main(inp: string) {
    const n: number = parseInt(inp.split('\n')[0]);
    const [s, t]: string[] = inp.split('\n')[1].split(' ').map(String);

    let ans :string='';
    for (let i: number = 0; i < n; i++) {
        ans += s[i]+t[i];
    }
    console.log(ans);
}

main(fs.readFileSync('/dev/stdin', 'utf8').trim());

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

typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;

#define rep(idx, N) for (u64 idx = 0; idx < N; idx++)

int main() {
  i32 n;
  cin >> n;

  u64 ans = 0;
  rep(i, n) {
    auto v = i + 1;
    if (v % 3 == 0 || v % 5 == 0) {
    } else {
      ans += v;
    }
  }

  cout << ans;

  return 0;
}


Measured memory_bytes: 3600
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	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

	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
		if len(os.Args) > 2 {
			wfp, _ = os.Create(os.Args[2])
		}
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)

	n := getNextInt(scanner)
	bc := make(Bacouples, n)

	for i := 0; i < n; i++ {
		bc[i].a = getNextInt64(scanner)
		bc[i].b = getNextInt64(scanner)
		bc[i].s = bc[i].a + bc[i].b
	}

	sort.Sort(bc)

	var ans int64

	for i := 0; i < n; i++ {
		if i%2 == 0 {
			ans += bc[i].a
			continue
		}
		ans -= bc[i].b
	}

	fmt.Fprintln(writer, ans)
	writer.Flush()
}

type Bacouple struct {
	a, b, s int64
}

type Bacouples []Bacouple

func (a Bacouples) Len() int           { return len(a) }
func (a Bacouples) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a Bacouples) Less(i, j int) bool { return a[i].s > a[j].s }


Measured memory_bytes: 5632
module Main where
import Debug.Trace
main = do
  n:l:_ <- map read . words <$> getLine
  print $ solve n l
  return ()

solve :: Int -> Int -> Int
solve n l = sum [l .. l + n - 1] - minAbs
  where
    minAbs = loop l [l .. l + n - 1]
    loop k (x:xs)
      | abs k > abs x = loop x xs
    loop k (_:xs) = loop k xs
    loop k [] = k
      


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

namespace ABC098A
{
    class Program
    {
        private static int max;

        static void Main(string[] args)
        {
            int a,b,max;
            var word = Console.ReadLine().Split(' ');

            a = int.Parse(word[0]);
            b = int.Parse(word[1]);

           max = a + b;

            if (max<a-b)
                max = a - b;
            if (max<a*b)
                max = a * b;

            Console.WriteLine(max);

            Console.ReadKey();




        }
    }
}


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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a.at(i);
    }
    
    int64_t ans = 0;
    int max_a = 0;
    for (int i = 0; i < n; i++) {
        if (i == 0) {
            max_a = a.at(i);
        }
        else {
            if (a.at(i) > max_a) {
                max_a = a.at(i);
            }
            else {
                ans += max_a - a.at(i);
            }
        }
    } 

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

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

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

    if((b-a)%2ll == 0){
        cout << (b - a) / 2ll << endl;
        return 0;
    }
    else{
        cout << min(a-1ll, (n - b))+(b-a + 1ll)/2ll << endl;
	    return 0;
    }
}


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

#define For(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define Rep(i,n) For(i,0,n)
#define dbg(x) cout<<#x"="<<x<<endl

#define MAX_MN 10000000

int N, M;
bool table[MAX_MN];

int main(int argc, char const *argv[])
{
	while(1){
		scanf("%d %d", &M, &N);
		if(N == 0) break;
		Rep(i,MAX_MN) table[i] = true;
		Rep(i,M) table[i] = false;
		int count = 0;
		for(int i = M; count < N; count++){
			for(int j = i;j < MAX_MN; j += i){
				table[j] = false;
			}
			int k = i+1;
			while(table[k] == false) k++;
			i = k;
			//printf("%d\n", i);
		}
		Rep(i,MAX_MN){
			if(table[i] == true){
				printf("%d\n", i);
				break;
			}
		}
	}
	return 0;
}

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

namespace ABC153A
{
	class Program
	{
		static void Main(string[] args)
		{
			int h,a, n;
			var word = Console.ReadLine().Split(' ');
			h = int.Parse(word[0]);
			a = int.Parse(word[1]);
			if (h % a == 0)
			{
				Console.WriteLine(h / a);
			}
			else if (h % a > 0)
			{
				Console.WriteLine(h / a + 1);
			}
			Console.ReadKey();
		}
	}
}


Measured memory_bytes: 11092
#include <stdio.h>
#define MAX 200000


int isPrime[MAX];
int N,P;

void solve(){
	int i,j,n,p=0;
	for(n=2*N+1;;n++){
		for(i=N+1;i<n;i++){
			for(j=i;i+j<=n;j++){
				if(i+j==n&&isPrime[i]&&isPrime[j]){
					p++;
					if(p==P){
						printf("%d\n",n);
						return;
					}
				}
			}
		}
	}
}

int main(void){
	int i,j;
	for(i=2;i<MAX;i++)isPrime[i]=1;
	for(i=2;i<MAX;i++){
		if(isPrime[i]){
			for(j=2;i*j<MAX;j++){
				isPrime[i*j]=0;
			}
		}
	}
	while(scanf("%d %d",&N,&P),~P){
		solve();
	}
	return 0;
}

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

int n;

int main() {
    cin >> n;
    vector<int> a(n, 0);
    for(int i = 0; i < n; ++i) cin >> a.at(i);

    vector<long long> cnt(100100, 0);
    for(int i = 0; i < n; ++i) {
        long long aa, bb, cc;
        aa = a.at(i)-1; bb = a.at(i); cc = a.at(i)+1;
        if(a.at(i) == 0) {
            cnt.at(bb)++; cnt.at(cc)++;
        }else {
            cnt.at(aa)++; cnt.at(bb)++; cnt.at(cc)++;
        }
    }

    long long mcnt = 0;
    for(int i = 0; i <= 100000; ++i) {
        chmax(mcnt, cnt.at(i));
    }
    cout << mcnt << endl;
}

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

int main () {
  int N,M,A,B,D;
  D=0;
  cin >> N >> M;
  vector<int> H(N),C(N);
  for (int i=0; i<N; i++) {
    cin >> H.at(i);
    C.at(i)=1;
  }
  for (int i=0; i<M; i++) {
    cin >> A >> B;
    if (H.at(A-1)>H.at(B-1)) {
      C.at(B-1)=0;
    }
    if (H.at(A-1)<H.at(B-1)) {
      C.at(A-1)=0;
    }
    if (H.at(A-1)==H.at(B-1)) {
      C.at(A-1)=0;
      C.at(B-1)=0;
    }
  }
  for (int i=0; i<N; i++) {
    D+=C.at(i);
  }
  cout << D << endl;
}

Measured memory_bytes: 4032
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
using namespace std;
int b[101][1001];
int main() {
	int n, m, a;
	while (cin >> n >> m >> a&&n != 0 && m != 0 && a != 0) {
		for (int i = 0; i <= n; i++) {
			for (int j = 0; j <= 1000; j++) b[i][j] = i;
		}
		int h, p, q;
		for (int i = 0; i < m; i++) {
			cin >> h >> p >> q;
			b[p][h] = q;
			b[q][h] = p;
		}
		for (int i = 1000; i >= 0; i--) {
			a = b[a][i];
		}
		cout << a << endl;
	}
}

Measured memory_bytes: 3448
#! /usr/bin/env ruby
# -*- coding: utf-8 -*-

class Main
  def solve
    # insert your code
    STDIN.each_line do |line|
      a, b = line.split.map &:to_i
      if a == 0 and b == 0
        puts 1
      else
        puts Math.log10(a+b).floor + 1
      end
    end
    return nil    
  end
end


if __FILE__ == $PROGRAM_NAME
  h = Main.new
  h.solve
end

Measured memory_bytes: 6152
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, gcd, lcm 
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <vector> // vector
#include <set> // set
#include <string> // string
#include <queue> // queue
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <unordered_map> // hashed by keys
#include <iomanip> //cout<<setprecision(n)
#define rep(i,n) for(int i = 0; i < n; i++)

typedef long long ll; // at least int64 > 9*10^18
typedef unsigned long long ull; // at least uint64

int main() {
  int n;
  std::cin >> n;
  std::cout << 180*(n-2) << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define llong long long
#define INF (__INT32_MAX__ / 2)

using namespace std;
typedef pair<int, int> ipair;
llong modulo(llong left, llong right) { return (left % right + right) % right; }

int N, A[100002], d[100002], dsum[100002];
int main(int argc, char **argv) {
    cin >> N;
    
    //「番号順に」
    
    for(int i = 1; i <= N; ++i) {
        cin >> A[i];
        d[i] = abs(A[i] - A[i - 1]);
        dsum[i] = dsum[i - 1] + d[i];
    }
    A[N + 1] = 0;
    d[N + 1] = abs(A[N + 1] - A[N]);
    dsum[N + 1] = dsum[N] + d[N + 1];

    for(int i = 1; i <= N; ++i) {
        int res = dsum[i - 1] + dsum[N + 1] - dsum[i + 1] + abs(A[i - 1] - A[i + 1]);
        cout << res << endl;
    }
}

Measured memory_bytes: 2432
h,w=map(int,input().split())
n=int(input())
arr=list(map(int,input().split()))
ans=[[0]*w for _ in range(h)]
cnt=0
apos=0
for i in range(h*w):
  if (i//w)%2==0:
    th=i//w
    tw=i%w
  else:
    th=i//w
    tw=w-1-i%w
  ans[th][tw]=apos+1
  cnt+=1
  if cnt==arr[apos]:
    apos+=1
    cnt=0
for i in range(h):
  print(*ans[i])

Measured memory_bytes: 3920
#include <stdio.h>

int main(){
   int n,m,x,i,j,c[12],a[12][12],u[13],min,s[12],cs,mino;

   scanf("%d %d %d",&n,&m,&x);
   min=1;
   for (i=0;i<n;i++) {
      scanf("%d",&c[i]);
      min+=c[i];
      u[i]=0;
      for (j=0;j<m;j++) scanf("%d",&a[i][j]);
   }
   mino=min;
   u[n]=0;
   for (;;) {
      for (i=0;i<n;i++)
         if (u[i]==0) {
            u[i]=1;
            break;
         } else u[i]=0;
      if (i==n) break;
      for (i=0;i<m;i++) s[i]=0;
      cs=0;
      for (i=0;i<n;i++)
         if (u[i]) {
            for (j=0;j<m;j++) s[j]+=a[i][j];
            cs+=c[i];
         }
      for (i=0;i<m;i++)
         if (s[i]<x) break;
      if (i==m && cs<min) min=cs;
   }
   if (min<mino) printf("%d\n",min);
   else          puts("-1");
   return 0;
}


Measured memory_bytes: 1732