akhauriyash/Code-Regression huggingface dataset:
from itertools import accumulate

def main():
    N, K= map(int, input().split())
    p = list(map(int, input().split()))
    # 累積和
    p = [0] + list(accumulate(p))

    # 累積和が最大になる区間、期待値は(1+p)/2、k個分なので以下の式。
    print((max(b - a for a, b in zip(p, p[K:])) + K) / 2)

if __name__ == '__main__':
  	main()

'''
5 3
1 2 2 4 5

10 4
17 13 13 12 15 20 10 13 17 11
'''

Measured memory_bytes: 25152
#include <stdio.h>

int main(){
	int n;
	int buf[5000];
	long goukei;
	long max;
	
	int i,j;
	
	while(1){
		goukei = 0;
		max = -100001;
		scanf("%d",&n);
		if(n == 0)break;
		for(i = 0;i < n;i++){
			scanf("%d",&buf[i]);
		}
		
		for(i = 0;i < n;i++){
			goukei = 0;
			for(j = i;j < n;j++){
				goukei += buf[j];
				if(goukei > max){
					max = goukei;
				}
			}
		}
		
		printf("%ld\n",max);
	}
	
	return 0;
}

Measured memory_bytes: 1048
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
typedef long double ld;
typedef unsigned long long ull;
#define X first
#define Y second
#define mp make_pair
template<class T> using indexed_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<class T, class X> using indexed_map = tree<T, X, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const long long M = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

long long modpow(long long n, long long k, long long MOD);

/**************** code starts here ****************/

struct DSU {
	vector<int> P, S;
	DSU(int n) {
		P.resize(n+1);
		S.resize(n+1, 1);
		for (int i = 1; i <= n; i++) P[i] = i;
	}
	
	int find(int x) {
		while (x != P[x]) x = P[x];
		return x;
	}
	
	void merge(int a, int b) {
		a = find(a); b = find(b);
		if (S[a] < S[b]) swap(a, b);
		
		S[a] += S[b];
		P[b] = a;
	}
	
	int same(int a, int b) {
		return find(a) == find(b);
	}
};

void poppingfever() {
	int n, m; cin >> n >> m;
	int ans = n;

	DSU d(n);
	while (m--) {
		int x, y, z; cin >> x >> y >> z;
		if (!d.same(x, y)) {
			d.merge(x, y);
			ans--;
		}
	}
	cout << ans;
}

/**************************************************/

signed main() {
	#ifdef fastfurioustransform
	freopen("inp.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
	#endif

	ios::sync_with_stdio(0); cin.tie(0);
	//cout << fixed << setprecision(12);

	poppingfever();

	return 0;
}

long long modpow(long long n, long long k, long long MOD) {
	long long ans = 1; n %= MOD;
	while (k > 0) {
		if (k & 1) ans = (ans*n) % MOD;
		k >>= 1; n = (n*n) % MOD;
	}
	return ans; 
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define MAX (ll)(5e3 + 4)
#define MOD (ll)(1e9 + 7)
#define PI (double)(3.14159265)
#define IO ios_base :: sync_with_stdio (false), cin.tie (nullptr);

using namespace std;
using ll = long long;
using ld = long double;

int dp[81][81][2 * 81 * 81], diff[81][81], n, m;
queue<pair<pair<int, int>, int>> q;
pair<int, int> ar[] = {{0, 1}, {1, 0}};
void bfs () {
	while (q.size ()) {
		auto p = q.front ();
		q.pop ();
		for (int i = 0; i < 2; i++) {
			int x = p.first.first + ar[i].first, y = p.first.second + ar[i].second;
			if (x >= n || y >= m) {
				continue;
			}
			int dd = diff[x][y];
			if (dp[x][y][p.second - dd] == 0) {
				dp[x][y][p.second - dd] = 1;
				q.push (make_pair (make_pair (x, y), p.second - dd));
			}
			if (dp[x][y][p.second + dd] == 0) {
				dp[x][y][p.second + dd] = 1;
				q.push (make_pair (make_pair (x, y), p.second + dd));
			}
		}
	}
}

int main () {
	cin >> n >> m;
	int ar[n][m], br[n][m];
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> ar[i][j];
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> br[i][j];
			diff[i][j] = abs (ar[i][j] - br[i][j]);
		}
	}
	q.push ({{0, 0}, 81 * 81 - diff[0][0]});
	q.push ({{0, 0}, 81 * 81 + diff[0][0]});
	bfs ();
	int ma = 80 * 80;
	for (int i = 0; i < 81 * 81 * 2; i++) {
		if (dp[n - 1][m - 1][i] == 1) {
			ma = min (ma, abs (i - 81 * 81));
		}
	}
	cout << ma << "\n";
}
	
		


Measured memory_bytes: 336644
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

constexpr int atcoder_mod = 1e9+7;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	string a=in<string>(),b=in<string>();
	a+=b;
	int N;
	sscanf(a.c_str(),"%d",&N);
	int s = sqrt(N);
	
	out(N==s*s ? "Yes" : "No");
	return 0;
}


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

int main(){
  	int N, K, Q;
  	cin >> N >> K >> Q;
  	vector<int> A(Q);
  	vector<int> B(N);
  
  	for(int i=0; i<Q; i++){
    	cin >> A[i];
      	B[A[i]-1]++;
    }
  
  
  	for(int i=0; i<N; i++){
      	//cout << "B[" << i << "]"<< B[i] << endl;
    	if(K-Q+B[i] > 0){
        	cout << "Yes" << endl;
        }else{
        	cout << "No" << endl;
        }
    }
	return 0;
}

Measured memory_bytes: 1408
s=input()
s1=int(s[0]+s[1])
s2=int(s[2]+s[3])
if 1 <= s1 <= 12 and 1 <= s2 <= 12:
    print("AMBIGUOUS")
elif 1 <= s1 <= 12:
    print("MMYY")
elif 1 <= s2 <= 12:
    print("YYMM")
else:
    print("NA")


Measured memory_bytes: 2940
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>

#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<vs> vvs;

typedef vector<pair<int, int>> vpi;
typedef vector<pair<ll, ll>> vpl;
typedef vector<tuple<int, int, int>> vti;


int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    string s; ll k;
    cin >> s >> k;
    
    bool se_same = s[0] == s[s.size()-1];
    
    vi cnt_list;
    char b = s[0];
    int cnt = 1;
    for(int i=1;i<s.size();i++){
        if (b != s[i]){
            cnt_list.push_back(cnt);
            cnt = 0;
        }
        b = s[i];
        cnt++;
    }

    cnt_list.push_back(cnt);
    
    ll f_cnt = 0;
    rep(i, cnt_list.size()){
        f_cnt += cnt_list[i] / 2;
//        cout << cnt_list[i] << endl;
    }
    
    ll ans;
    if (cnt_list.size() == 1){
        ans = s.size() * k / 2;
    }
    else if (k >= 2 and se_same){
        ll rep_cnt = (f_cnt - cnt_list[0]/2 - cnt_list[cnt_list.size() - 1] / 2) + ((cnt_list[0] + cnt_list[cnt_list.size() - 1]) / 2);
        ans = f_cnt + (rep_cnt * (k-1));
    }
    else{
        ans = f_cnt * k;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#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 k;
  int a, b;
  cin >> k >> a >> b;
  for (int i = a; i <= b; i++){
    if (i % k == 0){
      cout << "OK\n";
      return 0;
    }
  }
  cout << "NG\n";
  return 0;
}


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

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

vector<ll>divisor(ll c){
    vector<ll>ret;
    for(ll i=1;i*i<=c;i++){
        if(c%i==0){
            ret.push_back(i);
            if(i*i!=c)ret.push_back(c/i);
        }
    }
    sort(ret.begin(),ret.end());
    return ret;
}

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}




int main(){
    ll a,b;
    cin>>a>>b;
    ll c=gcd(a,b);
    vector<pair<ll,ll>>ret;
    ret=prime_factorize(c);
    ll ans=ret.size()+1;
    cout<<ans<<endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<stdlib.h>
using namespace std;
int main(){
  int w,n,i,a,b,t;
  string s;
  cin>>w>>n;
  int num[w];
  for(i=0;i<w;i++)num[i]=i+1;
  for(i=0;i<n;i++){
    cin>>s;
    a=atoi((s.substr(0,s.find(","))).c_str());
    b=atoi((s.substr(s.find(",")+1)).c_str());
    t=num[a-1],num[a-1]=num[b-1],num[b-1]=t;
  }
  for(i=0;i<w;i++) cout<<num[i]<<endl;
}

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

using namespace std;

using ll = long long;

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

    int n, ub;
    cin >> n >> ub;
    vector<pair<int, int>> p(n);
    for (int i = 0; i < n; ++i)
        cin >> p[i].first >> p[i].second;

    ll min_area = 4 * 1e9 * 1e9;
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            int cnt = 0;
            ll u = max(p[i].first, p[j].first), b = min(p[i].first, p[j].first);
            ll r = max(p[i].second, p[j].second), l = min(p[i].second, p[j].second);
            for (int k = 0; k < n; ++k) {
                if (b <= p[k].first && p[k].first <= u
                    && l <= p[k].second && p[k].second <= r) ++cnt;
            }
            if (ub <= cnt) min_area = min(min_area, (u - b) * (r - l));
        }
    }

    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            for (int k = j + 1; k < n; ++k) {
                ll u = max({p[i].first, p[j].first, p[k].first});
                ll b = min({p[i].first, p[j].first, p[k].first});
                ll r = max({p[i].second, p[j].second, p[k].second});
                ll l = min({p[i].second, p[j].second, p[k].second});

                int cnt = 0;
                for (int s = 0; s < n; ++s) {
                    if (b <= p[s].first && p[s].first <= u
                        && l <= p[s].second && p[s].second <= r) ++cnt;
                }
                if (ub <= cnt) min_area = min(min_area, (u - b) * (r - l));
            }
        }
    }

    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            for (int k = j + 1; k < n; ++k) {
                for (int t = k + 1; t < n; ++t) {
                    ll u = max({p[i].first, p[j].first, p[k].first, p[t].first});
                    ll b = min({p[i].first, p[j].first, p[k].first, p[t].first});
                    ll r = max({p[i].second, p[j].second, p[k].second, p[t].second});
                    ll l = min({p[i].second, p[j].second, p[k].second, p[t].second});

                    int cnt = 0;
                    for (int s = 0; s < n; ++s) {
                        if (b <= p[s].first && p[s].first <= u
                            && l <= p[s].second && p[s].second <= r) ++cnt;
                    }
                    if (ub <= cnt) min_area = min(min_area, (u - b) * (r - l));
                }
            }
        }
    }

    cout << min_area << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<queue>
#include<functional>
#include<iso646.h>
#include<bitset>

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;

const ll N_MAX = 2 * 1e9;


int main() {

	ll i, j;
	ll P, Q, R;
	cin >> P >> Q >> R;
	ll m = max(P, max(Q, R));
	ll s = P + Q + R;
	cout << s - m << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// AtCoder_A
		Scanner sc = new Scanner(System.in);

		String S = sc.nextLine();
		String T = sc.nextLine();
		int ans = 0;

		for(int i=0; i<3; i++) {
			if(S.charAt(i) == T.charAt(i)) {
				ans++;
			}
		}
		// 出力
		System.out.println(ans);
	    // Scannerクラスのインスタンスをクローズ
		sc.close();
	}
}


Measured memory_bytes: 35596
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long ;
int main(){
    string s;
    cin >> s;
    rep(i,s.size()){
        if(s[i] == ',') cout << " " ;
        else cout << s[i];
    }
    cout << endl;
}

Measured memory_bytes: 3620
require 'pp'

# Nと空白区切の入力値を数値の配列で返却する
def gets_n_and_i_list()
  return gets.chomp.to_i, gets.chomp.split(" ").map(&:to_i)
end

N, a_list = gets_n_and_i_list


index = []

(N-1).step(0, -2){|i| index.push(i)}
if index.last == 0
  1.step(N-1, 2){|i| index.push(i)}
else
  0.step(N-1, 2){|i| index.push(i)}
end

index.each do |e|
  print a_list[e].to_s + " "
end
print "\n"


Measured memory_bytes: 25980
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<bitset>
#include<sstream>
#include<list>
#include<climits>

using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define nrep(i,i0,n) for(int i=(i0);i<(int)(n);++i)
typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vii;
typedef long long ll;


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b,c;cin>>a>>b>>c;
	bool flag=false;
	rep(i,10000){
		if(a*(i+1)%b==c)flag=true;
	}
	if(flag)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
 
int main()
{
  long long x;
  long long ip = 100;
  int n = 0;
  scanf("%lld",&x);
 
  while(x > ip){
    ip += ip / 100;
    n++;
  }
 
  printf("%d",n);
 
  return 0;
}

Measured memory_bytes: 1732
#include<stdio.h>
#include<stdlib.h>

typedef struct {
    char alpa;
    int value;
}CARD;

void babul(int ,CARD *);
void sel(int, CARD *);
void output(int, CARD *, CARD *);

int main() {
    CARD *A,*B,*C;
    int n,i;

    scanf("%d", &n);

    A = malloc(n * sizeof(CARD));
    B = malloc(n * sizeof(CARD));
    C = malloc(n * sizeof(CARD));

    for(i = 0; i < n; i++) {
        scanf(" %c%d", &A[i].alpa, &A[i].value);
        B[i] = A[i];
        C[i] = A[i];
    }

    babul(n, B);
    sel(n, C);

    output(n, B, A);
    output(n, C, A);

    free(A);
    free(B);
    free(C);

    return 0;
}

void babul(int n, CARD *a) {
    int i,end = 0;
    CARD box;

    while(1) {
        for(i = n-1; i > end; i--) {
            if(a[i].value < a[i-1].value) {
                box = a[i];
                a[i] = a[i-1];
                a[i-1] = box;
            }
        }
        end++;
        if(end == n)break;
    }
}
void sel(int n,CARD *a) {
    int i,j,minj;
    CARD box;

    for(i = 0; i < n; i++) {
        minj = i;
        for(j = i; j < n; j++) {
            if(a[j].value < a[minj].value) {
                minj = j;
            }
        }
        if(a[i].value != a[minj].value) {
            box = a[i];
            a[i] = a[minj];
            a[minj] = box;
        }
    }
}

void output(int n, CARD *a, CARD *ans) {
    int i,j,flag = 0;

    for(i = 0; i < n-1; i++) {
        printf("%c%d ",a[i].alpa,a[i].value);
    }
    printf("%c%d\n",a[i].alpa,a[i].value);

    for(i = 0; i < n; i++) {
        for(j = 0; j < n; j++) {
            if(a[i].value == ans[j].value) {
                if(flag == j) break;
                if(a[i].alpa != ans[j].alpa) {
                    printf("Not stable\n");
                    return;
                }else {
                    flag = j;
                    break;
                }
            }
        }
    }
    printf("Stable\n");
}



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

long long roundup(long long x,long long y){
    if(x%y==0)return x/y;
    else return x/y+1;
}

int main(){
    int N;
    cin>>N;
    long long x,y;
    long long t,a,k;
    for(int i=0;i<N;i++){
        if(i==0){
            cin>>x>>y;
        }else{
            cin>>t>>a;
            k=max(roundup(x,t),roundup(y,a));
            x=t*k;
            y=a*k;
        }
    }
    cout<<x+y<<endl;
    return 0;
}

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

int main(){
    int n; cin >> n;
    if(n%2==1){
        int o = n/2 + 1;
        int e = n/2;
        cout << setprecision(10) << 1.0*o/n << endl;
    }else{
        cout << 0.5 << endl;
    }
}

Measured memory_bytes: 3772
N, M = map(int, input().split())
H = list(map(int, input().split()))
grid = []
for i in range(M):
    array = list(map(int, input().strip().split()))
    grid.append(array)

flag = 0
X = 0

S = [1] * N


# for a in range(1, N+1):
#     for b in grid:
#         if b[0] == a:
#             if H[b[1]-1] >= H[a-1]:
#                 break
#         elif b[1] == a:
#             if H[b[0]-1] >= H[a-1]:
#                 break
#     else:
#         X += 1

for b in grid:
    if H[b[0]-1] > H[b[1]-1]:
        S[b[1]-1] = 0
    elif H[b[0]-1] < H[b[1]-1]:
        S[b[0]-1] = 0
    elif H[b[0]-1] == H[b[1]-1]:
        S[b[0] - 1] = 0
        S[b[1] - 1] = 0

X = sum(S)

print(X)

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

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

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

    if (a <= b && b <= a + w)
        cout << 0 << endl;
    else if (a + w < b)
        cout << b - (a + w) << endl;
    else   
        cout << a - (b + w) << endl;
}

Measured memory_bytes: 256
k,s = map(int, input().split())

ans = 0
for right in range(max(s-k, 0), min(s+1, 2*k+1)):
  lower = max(0, right-k)
  upper = min(k, right)
  if right % 2 != 0:
    ans += upper - lower + 1
  else:
    ans += upper - lower + 1
print(ans)

Measured memory_bytes: 3060
#include <array>
#include <algorithm>
#include <functional>
#include <iostream>

int main()
{
	std::array<int,5> v;
	std::cin >> v[0] >> v[1] >> v[2] >> v[3] >> v[4];
	std::sort( v.begin(), v.end(), std::greater<int>() );
	std::cout << v[0] << ' ' << v[1] << ' ' << v[2] << ' ' << v[3] << ' ' << v[4] << '\n';
}

Measured memory_bytes: 1176
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int N = Integer.parseInt(br.readLine());
		String[] dx = br.readLine().split(" ");
		int D = Integer.parseInt(dx[0]);
		int X = Integer.parseInt(dx[1]);

		List<Integer> A = new ArrayList<Integer>();

		for(int i = 0;i<N;i++){
			A.add(Integer.parseInt(br.readLine()));
		}
		int chocount = X;
		for(int i = 0;i<N;i++){
			for(int j = 1;j<=D;j += A.get(i)){
				chocount += 1;
			}
		}

		System.out.println(chocount);
	}

}


Measured memory_bytes: 22612
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input!(
    n: usize,
    v: [i32; n],
    );
    let mut m = 0;
    let mut s = 0;
    let mut flag = true;
    let mut v2: Vec<_> = v;
    while flag {
        m = 0;
        for i in &v2 {
            if i % 2 == 0 {
                if m + 1 == n {
                    s += 1;
                    break;
                }
                m += 1;
            } else {
                flag = false;
                break;
            }
        }
        v2 = v2.iter().map(|c| c / 2).collect();
    }
    println!("{}", s);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int N,Y;
  cin >> N >> Y;
  bool exist = false;
  for(int x=0;x<N+1;x++)
  {
    for(int v=0;v<N-x+1;v++)
    {
        if(10000*(x)+5000*(v)+1000*(N-x-v)==Y)
        {
          cout << x << " " << v << " " << N-x-v << endl;
          exist = true;
          return 0;
        }
    }
  }
  if(exist == false)
  {
    cout << -1 << " " << -1 << " " << -1 << endl;
  }
  return 0;
}


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

int main() {
  
  int N;
  cin >> N;
  
  string A,B;
  
  cin >> A >> B;
  
  for ( int i = 0; i < N; i++){
    cout << A.at(i) << B.at(i);
  }
  
  cout << endl;
  
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func readInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func readString() string {
	sc.Scan()
	return sc.Text()
}

func readInt64() int64 {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return int64(i)
}

func readfloat64() float64 {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return float64(i)
}

func abs(a int) int {
	if a < 0 {
		return a * -1
	}
	return a
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func gcd(x, y int) int {
	if y == 0 {
		return x
	}
	return gcd(y, x%y)
}

const Mod = 1000000007

func ModComb(n, k int) int {
	if k == 0 {
		return 1
	}
	x, y := n, k
	for i := 1; i < k; i++ {
		x = x * (n - i) % Mod
		y = y * (k - i) % Mod
	}
	inv := ModInv(y)
	return x * inv % Mod
}

func ModFact(x int) int {
	fact := 1
	for i := 1; i <= x; i++ {
		fact = fact * i % Mod
	}
	return fact
}

func ModInv(x int) int {
	return ModPow(x, Mod-2)
}

func ModPow(a, n int) int {
	res := 1
	for n > 0 {
		if n%2 != 0 {
			res = res * a % Mod
		}
		a = a * a % Mod
		n /= 2
	}
	return res
}

func pow(a, n int) int {
	if n == 0 {
		return 1
	}

	ans := 0
	if n%2 == 0 {
		ans = pow(a*a, n/2)
	} else {
		ans = a * pow(a*a, (n-1)/2)
	}
	return ans
}

func intSliceReverse(slice []int) []int {
	for i, j := 0, len(slice)-1; i < j; i, j = i+1, j-1 {
		slice[i], slice[j] = slice[j], slice[i]
	}
	return slice
}

func stringReverse(str string) string {
	runes := []rune(str)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func main() {
	sc.Split(bufio.ScanWords)

	n := readInt()
	a := make([]int64, n)

	for i := 0; i < n; i++ {
		a[i] = readInt64()
		if a[i] == 0 {
			fmt.Println("0")
			return
		}
	}

	var ans int64 = 1
	for i := 0; i < n; i++ {
		if a[i] > 1e18/ans {
			fmt.Println("-1")
			return
		}
		ans *= a[i]
	}
	fmt.Println(ans)
}


Measured memory_bytes: 5840
#include <iostream>
#include <stdio.h>

using namespace std;

int readLn(){
    int n;
    scanf("%d", &n);
    return n;
}

int powi(int n, int m){
    int x = n;
    for(int i = 1; i < m; ++i) x *= n;
    return x;
}

int main(void){
    cout << powi(readLn(), 3) << endl;
    return 0;
}

Measured memory_bytes: 3220
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <deque>
#include <queue>

using namespace std;
typedef long long ll;
const int MOD = 1e9+7;

ll cnt[61];

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


int main(){
    ll N;
    cin >> N;
    ll A[N];
    for(int i = 0; i < N; i++){
        cin >> A[i];
        int idx = 0;
        while(A[i] != 0){
            if(A[i]%2 == 1) cnt[idx]++;
            A[i] /= 2;
            idx++;
        }
    }

    ll ans = 0;

    for(int i = 0; i <= 60; i++){
        ans += modpow(2, i, MOD)*((cnt[i]*(N-cnt[i]))%MOD);
        ans %= MOD;
    }
    cout << ans << endl;

}



Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<ll> a(n);
    cin >> a;
    vector<ll> x(n);
    x[0] = accumulate(a.begin(), a.end(), 0ll);
    for(int i = 1; i < n; i += 2) {
        x[0] -= 2 * a[i];
    }
    for(int i = 1; i < n; i++) {
        x[i] = 2 * a[i - 1] - x[i - 1];
    }
    for(int i = 0; i < n; i++) {
        if(i) cout << " ";
        cout << x[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 2944
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

int n,a[3];
int l[8];
ll ans;

void dfs(str s){
  if(s.length()==n){
    ll mp = 0;
    ll length[3];
    length[0] = 0, length[1] = 0, length[2] = 0;
    REP(i,n){
      if(s[i]=='3') continue;
      if(length[s[i]-'0']!=0) mp += 10;
      length[s[i]-'0'] += l[i];
    }
    if(length[0]==0||length[1]==0||length[2]==0) return;
    mp += abs(length[0]-a[0]) + abs(length[1]-a[1]) + abs(length[2]-a[2]);
    ans = min(ans, mp);
  }else{
    dfs(s+'0');
    dfs(s+'1');
    dfs(s+'2');
    dfs(s+'3');
  }
}

int main(){
  cin >> n >> a[0] >> a[1] >> a[2];
  REP(i,n) cin >> l[i];
  ans = INF;
  dfs("");
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<vector>

using namespace std;

int n, m;
int p[12];
int s[12];
vector<int> G[12];
int ans = 0;

void dfs(int v){
    if(v == n+1){
        
        bool flag = true;
        for (int i = 1;i<=m; i++){
            int sum = 0;
            for (int j = 0; j < G[i].size(); j++){
                sum += s[G[i][j]];
            }
            if(sum%2!=p[i]){
                flag = false;
                break;
            }
        }
        if(flag)ans++;
        return;
    }
    for (int i = 0; i <= 1; i++){
        s[v] = i;
        dfs(v + 1);
    }
    return;
}

int main(){
    ios::sync_with_stdio(false);
    cin >> n >> m;
    for (int i = 1; i <= m; i++){
        int cnt,temp;
        cin >> cnt;
        while(cnt--){
            cin >> temp;
            G[i].push_back(temp);
        }
    }
    for (int i = 1; i <= m; i++){
        cin >> p[i];
    }
    dfs(1);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
A = [int(input()) for _ in range(5)]
ans = 0
I = [i for i, a in enumerate(A) if a % 10 == 0]
for i in reversed(I):
    ans += A.pop(i)
if len(A) == 0:
    print(ans)
    exit()
A.sort(key=lambda a: a % 10)
ans += A.pop(0)
for i in range(len(A)):
    A[i] += 10 - (A[i] % 10)
ans += sum(A)
print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include<math.h>
using namespace std;
//#define int long long
#define m_p make_pair
#define mod 1000000007
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define all(v)  v.begin(),v.end()
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>vec[i];
using namespace std;

int jousu(int, int);
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int kurai(int x00, int y00) {
	int z00 = (x00 % jousu(10, y00)) / jousu(10, y00 - 1);
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}




int main() {
	int a, b, c;
	cin >> a >> b >> c;
	cout << max(c - a + b, 0) << endl;
}


Measured memory_bytes: 256
/* ex3_3
    riverstone*/

#include <stdio.h>
 
int main(void){
    // 数値N、進数Kをintで定義し入力する。
    int N,K; 
    scanf("%d%d", &N, &K);
    
    // 桁数
    int digit = 1; 

    //NをKで何回割れるかを数える。
    //while文によりKで割った商が0より大きい間繰り返す
    while (N / K > 0)
    {
        N /= K;     //NにNをKで割った商を代入
        digit += 1;
    }

    // digitを出力
    printf("%d\n", digit);
 
    return 0;
    
}

Measured memory_bytes: 128
#include <stdio.h>

int main()
{
  int ret, i;
  int N, A[200000];
  int max, max2;

  ret = scanf("%d", &N);
  for ( i=0; i<N; i++ )
    ret = scanf("%d", &(A[i]));
  if ( A[0] < A[1] ) {
    max = A[1];
    max2 = A[0];
  }
  else {
    max = A[0];
    max2 = A[1];
  }
  for ( i=2; i<N; i++ ) {
    if ( max < A[i] ) {
      max = A[i];
    }
    else if ( max2 < A[i] ) {
      max2 = A[i];
    }
  }
  for ( i=0; i<N; i++ ) {
    if ( A[i] == max )
      printf("%d\n", max2);
    else
      printf("%d\n", max);
  }
  return 0;
}



Measured memory_bytes: 2304
#include <iostream> 
using namespace std;
#include <cstdio>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
int main()
{
	
	int n;
	cin>>n;
	queue<double>q;
	vector<double>res;
	double f = 0;
	for(int i = 0;i<n;i++)
	{
		cin>>f;
		res.push_back(f);
	}
	
	sort(res.begin(),res.end());
	
	for(auto &x :res)
	{
		q.push(x);
	}
	
	double sum = q.front();
	q.pop();
	while(q.size())
	{
		double fr= q.front();
		q.pop();
		sum = (sum+fr)/2;
	}
	
	cout<<sum<<endl;
	
	return 0;
}

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

int main() {
  ll N;
  cin >> N;
  vector<vector<ll>> F(N, vector<ll>(10));
  vector<vector<ll>> P(N, vector<ll>(11));

  rep (i, N) {
    rep (j, 10) {
      cin >> F[i][j];
    }
  }
  rep (i, N) {
    rep (j, 11) {
      cin >> P[i][j];
    }
  }

  // 全通りためそう
  ll ans = -pow(10, 18);
  rep2 (i, 1, 1 << 10) {
    vector<ll> counts(N, 0);
    rep (j, 10) {
      if (i >> j & 1) {
        rep (k, N) {
          if (F[k][j]) counts[k] += 1;
        }
      }
    }
    ll cnt = 0;
    rep (k, N) {
      cnt += P[k][counts[k]];
    }
    ans = max(ans, cnt);

  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <map>
#include <utility>
#include <math.h>
#include <string.h>
#include <algorithm>
using namespace std;
#define maxn 109
int a[maxn],b[maxn],c[maxn];
int main()
{

    int n;
    scanf("%d",&n);
    for(int i=1;i<n;i++)
        scanf("%d",&b[i]);
     int sum=0;
     sum=b[1]+b[n-1];
     for(int i=2;i<n;i++)
     {
         sum+=min(b[i-1],b[i]);
     }
     printf("%d\n",sum);
    return 0;
}


Measured memory_bytes: 256
integer,allocatable,dimension(:)::a,b,c,d
integer N,M,shortest,SpotName
read*,N,M
allocate(a(N))
allocate(b(N))
allocate(c(M))
allocate(d(M))
do i=1,N
  read*,a(i),b(i)
end do
!本当はなー！!!!N回回す後ろの作業といっしょにしたかったんだけどなああああああ
!後ろのデータ読み取るための処置が面倒くさいからー全部読み込むことにした
do i=1,M
  read*,c(i),d(i)
end do
do i=1,N
  shortest=10**9
  do j=1,M
    if (shortest > abs(a(i)-c(j))+abs(b(i)-d(j)) ) then
      SpotName = j
      shortest = abs(a(i)-c(j))+abs(b(i)-d(j))
    end if
  end do
  print"(I0)",SpotName
end do
end

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define pp pop_back
#define in insert
#define ff first
#define ss second
#define  show for(int j=0;j<v.size();j++) cout<<v[j]<<" ";
#define ld long double
#define e endl
#define bc __builtin_popcount
#define MOD 1000000007
#define INT_SIZE 32
#define me(x) memset(x,0,sizeof(x))
ll fast_expo(ll x,ll p)
{if(p==0) return 1;
else if(p%2==0){ ll t=fast_expo(x,p/2)%MOD;return (t*t)%MOD;} else return (x*(fast_expo(x,p-1))%MOD)%MOD;}
int main()
{
  int n,i,j;
  cin>>n;
  int a[n+1];
  for(i=1;i<=n;i++)
    cin>>a[i];
    int cnt=0;
    int b[n+1]={0};
  for(i=n;i>=1;i--)
  {
      cnt=0;
      for(j=i;j<=n;j+=i)
      {
         if(b[j]==1)
          cnt++;
      }
      if(cnt%2!=a[i])
        b[i]=1;
  }
  int flag=1;
   for(i=n;i>=1;i--)
  {
      cnt=0;
      for(j=i;j<=n;j+=i)
      {
         if(b[j]==1)
          cnt++;
      }
      if(cnt%2!=a[i])
        {flag=-1;
        break;
        }
  }
  if(flag==-1)
    cout<<-1;
  else{
        int ans=0;
        vector<int> v;
    for(i=1;i<=n;i++)
  {
      if(b[i]==1)
        {ans++;
        v.pb(i);}
  }
  cout<<ans<<e;
  if(v.size()>0){
  for(i=0;i<v.size();i++)
    cout<<v[i]<<e;
  }
    }
}


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define LL long long
#define PB push_back
using namespace std;
const int mod = 1000 * 1000 * 1000 + 7;
const int ob = (mod + 1) >> 1;
	
int main()
{
	string s;
	cin >> s;
	for(int i = 0; i < 4; i++)
		cout << s[i];
	cout << " ";
	for(int i = 4; i < 12; i++)
		cout << s[i];
	cout << endl;
}




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

typedef long long ll;

const ll inf = 1e18;
ll x, k, d, pos = inf, neg = -inf;

int main() {
	cin >> x >> k >> d;
	if (x >= 0) {
		ll di = x / d;
		if (di > k)
			pos = min(pos, x - k * d);
		else {
			if (di % 2 != k % 2)
				di--;
			pos = min(pos, x - di * d);
			if (di + 2 <= k)
				neg = max(neg, x - (di + 2) * d);
		}
	}
	else {
		ll di = (-x) / d;
		if (di > k)
			neg = max(neg, x + k * d);
		else {
			if (di % 2 != k % 2)
				di--;
			neg = max(neg, x + di * d);
			if (di + 2 <= k)
				pos = min(pos, x + (di + 2) * d);
		}
	}
	cout << min(pos, -neg) << "\n";
}


Measured memory_bytes: 3636
n=gets.chomp.to_i
F = n.times.map { gets.chomp.split(" ").map { |e| e.to_i  } }
P = n.times.map { gets.chomp.split(" ").map { |e| e.to_i } }


max = -10**9

for i in 1..1024-1 do
  sum = 0
  value = i.to_s(2).reverse
  c = Array.new(n,0)

  for j in 0..9 do
    indx = j

    if value[indx] == "1"
      for k in 0..n-1 do
        if F[k][indx] == 1
          c[k] += 1
        end
      end
    end
  end

 for i in 0..n-1 do
   sum += P[i][c[i]]
 end

 max = max > sum ? max : sum
end

puts max

Measured memory_bytes: 2172
#include <iostream>

using namespace std;

int main() {
    long long n, t;
    cin >> n >> t;

    long long res = 0;
    for (long long i = 0, tl = 0; i < n; i++) {
        long long ti;
        cin >> ti;

        if (tl <= ti) {
            res += t;
        } else {
            res += t + ti - tl;
        }

        tl = ti + t;
    }

    cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <set>
#include <utility>
#include <vector>
#include <cstring>

using namespace std;

int h, w;
vector<string> s;
vector<pair<int, int>> node[400][400];
pair<long long, long long> cnt;

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

void dfs(int x, int y){
    if(s[x][y] == '?') return;
    if(s[x][y] == '#'){
        cnt.first++;
    }else{
        cnt.second++;
    }
    s[x][y] = '?';
    for(auto&& i : node[x][y]){
        dfs(i.first, i.second);
    } 
}

void hawawa()
{
    cin >> h >> w;
    s.resize(h);
    for (auto&& i : s) {
        cin >> i;
    }
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            for(int k = 0; k < 4; k++){
                if(i + dx[k] < 0 || j + dy[k] < 0 || i + dx[k] == h || j + dy[k] == w){
                    continue;
                }
                if(s[i][j] != s[i + dx[k]][j + dy[k]]){
                    node[i][j].push_back(make_pair(i + dx[k], j + dy[k]));
                }
            }
        }
    }
    long long ans = 0;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(s[i][j] == '#'){
                cnt = make_pair(0, 0);
                dfs(i, j);
                ans += cnt.first * cnt.second;
            }
        }
    }
    cout << ans << "\n";
}

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


Measured memory_bytes: 19200
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <set>
#include <map>
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define REPN(i, n) for (int i=1; i <= (int)(n); i++)  // 1 ~ n
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
typedef long long ll;

const int MOD = 1000000007;  // 1 000 000 007


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

    // input
    int AB, BC, CA;
    cin >> AB >> BC >> CA;
//    vector<int> vec(N);
//    REP(i, N) cin >> vec[i];
    
    // calculation
    cout << (AB*BC)/2 << "\n";
    
    return 0;
}


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

int main()
{
    int i,j,l1,f=0;
    char s[105],t[105],s2[105];
    gets(s);
    gets(t);
    l1=strlen(s);
    for(j=0; j<=l1; j++)
    {

        for(i=1; s[i]!='\0'; i++)
        {
            s2[0]=s[l1-1];
            s2[i]=s[i-1];
        }
       // printf("%s\n",s2);
        for(i=0;i<l1;i++)
        {
            s[i]=s2[i];
        }
       // s[l1]='\0';
        if(strcmp(s,t)==0)
        {
            f=1;
            break;
        }
    }
    if(f==1) printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int a, b; cin >> a >> b;
	cout << (a * 3 + b) / 2 << endl;
	
	return 0;
}

Measured memory_bytes: 256
// 2011/09/30 Tazoe

#include <iostream>
#include <string>
using namespace std;

int main()
{
	while(true){
		int n;
		cin >> n;
		if(n==0)
			break;

		int m;
		cin >> m;
		string s;
		cin >> s;

		if(m==0){
			cout << 0 << endl;
			continue;
		}

		bool flg;
		int L;
		if(s[0]=='I'){
			flg = true;
			L = 1;
		}
		else{
			flg = false;
			L = 0;
		}

		int cnt = 0;
		for(int i=1; i<m; i++){
			if(s[i]=='I'){
				if(!flg)
					L++;
				else{
					int N = (L-1)/2;
					if(N>=n)
						cnt += (N-n+1);
					L = 1;
				}
				flg = true;
			}
			else{
				if(flg)
					L++;
				else{
					int N = (L-2)/2;
					if(N>=n)
						cnt += (N-n+1);
					L = 0;
				}
				flg = false;
			}
		}

		if(L>=3){
			int N = (L-1)/2;
			if(N>=n)
				cnt += (N-n+1);
		}

		cout << cnt << endl;
	}

	return 0;
}

Measured memory_bytes: 1972
import java.util.*;

public class Main {
	static class MaxFlow {
		//dinic
		public class Edge {
			int to, cap, rev;

			public Edge(int to, int cap, int rev) {
				this.to = to;
				this.cap = cap;
				this.rev = rev;
			}
		}

		int V;
		ArrayList<ArrayList<Edge>> G;
		int[] level;
		int[] iter;
		public final int INF = 1000000000;
		
		public MaxFlow(int V) {
			this.V = V;
			G = new ArrayList<ArrayList<Edge>>();
			for(int i=0; i<V; i++)
				G.add(new ArrayList<Edge>());
			level = new int[V];
			iter = new int[V];
		}
		
		public void addEdge(int from, int to, int cap) {
			G.get(from).add(new Edge(to, cap, G.get(to).size()));
			G.get(to).add(new Edge(from, 0, G.get(from).size()-1));
		}
		
		void bfs(int s) {
			Arrays.fill(level, -1);
			Queue<Integer> que = new LinkedList<Integer>();
			level[s] = 0;
			que.add(s);
			while(!que.isEmpty()) {
				int v = que.remove();
				for(int i=0; i<G.get(v).size(); i++) {
					Edge e = G.get(v).get(i);
					if(e.cap>0 && level[e.to]<0) {
						level[e.to] = level[v] + 1;
						que.add(e.to);
					}
				}
			}
		}
		
		int dfs(int v, int t, int f) {
			if(v==t) return f;
			for(; iter[v]<G.get(v).size(); iter[v]++) {
				Edge e = G.get(v).get(iter[v]);
				if(e.cap>0 && level[v] < level[e.to]) {
					int d = dfs(e.to, t, Math.min(f, e.cap));
					if(d>0) {
						e.cap -= d;
						G.get(e.to).get(e.rev).cap += d;
						return d;
					}
				}
			}
			return 0;
		}
		
		int getMaxFlow(int s, int t) {
			int flow = 0;
			while(true) {
				bfs(s);
				if(level[t]<0)
					return flow;
				
				Arrays.fill(iter, 0);
				int f;
				while((f = dfs(s, t, INF)) > 0) {
					flow += f;
				}
			}
		}
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		
		boolean[][] leaf = new boolean[H][W];
		int sx=0,sy=0,tx=0,ty=0;
		for(int i=0; i<H; i++) {
			char[] c = sc.next().toCharArray();
			for(int j=0; j<W; j++) {
				if(c[j]!='.') {
					leaf[i][j] = true;
					if(c[j]=='S') {
						sy = i;
						sx = j;
					} else if(c[j]=='T') {
						ty = i;
						tx = j;
					}
				}
			}
		}
		if(sx==tx || sy==ty) {
			System.out.println(-1);
			sc.close();
			return;
		}
		
		MaxFlow mf = new MaxFlow(H*W*2);
		
		for(int i=0; i<H; i++) {
			ArrayList<Integer> list = new ArrayList<>();
			for(int j=0; j<W; j++)
				if(leaf[i][j])
					list.add(j);
			for(int j : list)
				for(int k : list)
					if(j!=k)
						mf.addEdge((i*W+j)*2+1, (i*W+k)*2, 1);
		}
		for(int i=0; i<W; i++) {
			ArrayList<Integer> list = new ArrayList<>();
			for(int j=0; j<H; j++)
				if(leaf[j][i])
					list.add(j);
			for(int j : list)
				for(int k : list)
					if(j!=k)
						mf.addEdge((j*W+i)*2+1, (k*W+i)*2, 1);
		}
		for(int i=0; i<H; i++) {
			for(int j=0; j<W; j++)
				if(leaf[i][j])
					mf.addEdge((i*W+j)*2, (i*W+j)*2+1, 1);
		}
		
		System.out.println(mf.getMaxFlow((sy*W+sx)*2+1, (ty*W+tx)*2));
		sc.close();
	}
}


Measured memory_bytes: 203232
#include <iostream>
#include <string>
#include <vector>
#include <map>

using namespace std;

int main(){
    string s;
    cin >> s;
    int size = s.size();
    if(s[0]==s[size-1]){
        if(size%2==1) cout <<"Second";
        else cout <<"First";
    }
    else{
        if(size%2==0) cout <<"Second";
        else cout <<"First";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 512
/** @Date    : 2017-05-13 20:40:15
  * @FileName: tmp.cpp
  * @Platform: Windows
  * @Author  : Lweleth (SoundEarlf@gmail.com)
  * @Link    : https://github.com/Lweleth
  * @Version : $Id$
  */
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int ,int>
#define MP(x, y) make_pair((x),(y))
#define fi first
#define se second
#define PB(x) push_back((x))
#define MMG(x) memset((x), -1,sizeof(x))
#define MMF(x) memset((x),0,sizeof(x))
#define MMI(x) memset((x), INF, sizeof(x))
using namespace std;

const int INF = 0x3f3f3f3f;
const int N = 1e5+20;
const double eps = 1e-8;


int main()
{
	int a, b, c;
	while(cin >> a >> b >> c)
	{
		if(c >= a && c <= b)
			printf("Yes\n");
		else printf("No\n");
	}
    return 0;
}

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

int Selection_sort(int* A, int N) {
    int tmp_minj, minj, j;
    int count = 0;
    for (int i=0; i<N; i++) {
        minj = i;
        tmp_minj = i;
        for (j=i; j<N; j++) {
            if (A[j] < A[minj]) { minj = j; }
        }
        if (tmp_minj != minj) { swap(A[i], A[minj]); count++; }
    }
    return count;
}

int main(int argc, char const *argv[])
{
    int n, k;
    cin >> n;
    int a[n];
    for (int i=0; i<n; i++) {
        cin >> a[i];
    }
    int* ap;
    ap = a;

    k = Selection_sort(ap, n);

    for (int i=0; i<n; i++){
        if (i == n-1) { cout << a[i] << endl; }
        else { cout << a[i] << " "; }
    }

    cout << k << endl;

    return 0;
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
pair<int, int> p;

int main(){
    int n; cin >> n;
    vector<ll> a(n+1);
    vector<ll> b(n);
    for(int i=0; i<n+1; ++i){cin >> a[i];}
    for(int i=0; i<n; ++i){cin >> b[i];}
    ll res = 0;
    for(int i=0; i<n+1; ++i){res += a[i];} 
    for(int i=0; i<n; ++i){
      	int ai = a[i];
        a[i] -= min(a[i], b[i]);
      	if(b[i]>ai){b[i] -= ai;}else{b[i] = 0;} //cout << b[i] << endl;
      	
        if(b[i]){
            a[i+1] -= min(a[i+1], b[i]);
        }
      	//for(int i=0; i<n+1; ++i){cout << a[i] << ",";} cout << endl;
    }
    for(int i=0; i<n+1; ++i){res -= a[i];}
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 4816