akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC_D
{
    class D069
    {
        static void Main(string[] args)
        {
            int[] b = Console.ReadLine().Split(' ').Select(z => int.Parse(z)).ToArray();
            int H = b[0], W = b[1];
            int N = int.Parse(Console.ReadLine());
            int[] a = Console.ReadLine().Split(' ').Select(z => int.Parse(z)).ToArray();

            int[,] c = new int[H, W];
            int index = 0;
            for(int i = 0; i < N; i++)
            {
                for(int j = 0; j < a[i]; j++)
                {
                    int x = index / W;
                    int t = index % (2 * W);
                    int y = t < W ? t : 2 * W-1 - t;
                    c[x, y] = i + 1;
                    index++;
                }
            }

            for(int i = 0; i < H; i++)
            {
                string r = "";
                for(int j = 0; j < W; j++)
                {
                    if (j > 0) r += " ";
                    r += c[i, j];
                }
                Console.WriteLine(r);
            }
        }
    }

}

Measured memory_bytes: 17884
N = int(input())
S = input()
left_w = 0
right_e = S[1:].count("E")
ans = left_w + right_e
for i in range(1, N):
	if S[i - 1] == "W":
		left_w += 1
	if S[i] == "E":
		right_e -= 1
	ans = min(ans, right_e + left_w)
print(ans)

Measured memory_bytes: 3700
#include<bits/stdc++.h>
		using namespace std;
		#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
		#include <ext/pb_ds/assoc_container.hpp> 
		#include <ext/pb_ds/tree_policy.hpp> 
		using namespace __gnu_pbds; 
		#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
		 
		#define ff first
		#define ss second
		#define mp make_pair
		 
		#define pb push_back
		#define endl "\n"
		 
		#define int long long 
		#define double long double
		 
		#define bp __builtin_popcountllm
		#define inf 1e16
		const int N=1e5+5;
		const int M=105;
		const int MOD=1e9+7;
	
		void solve()
		{	
			int h,w;
			cin>>h>>w;
			int ans=h*w;
			ans=(ans+1)/2;
			if(h==1 || w==1)
			cout<<1;
			else
			cout<<ans;
		}

		signed main()  
		{
			FAST
			int t=1;
			//cin>>t;
			while(t--)
			{
				solve();
				
			}
		}
		


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;

int main(){
int N,M;
cin>>N>>M;

vector<int>oks(N+1,true);
for(int i=0;i<M;++i){
int a;cin>>a;
oks[a]=false;
}

vector<long long int>dp(N+1);
dp[0]=1;
for(int now=0;now<N;++now){
for(int next=now+1;next<=min(N,now+2);++next){
if(oks[next]){
dp[next]+=dp[now];
dp[next]%=mod;
}
}
}

cout<<dp[N]<<endl;
return 0;
}


Measured memory_bytes: 1408
#include <cstdio>
#include <climits>
#include <cassert>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <tuple>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define FOR(x,xs) for(auto &x: xs)

using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef vector<int> VI;
typedef vector<ll> VL;

int main() {
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  vector<VI> es(N+1);
  vector<bool> visit(N+1, false);
  REP(i,0,M) {
    int a, b;
    cin >> a >> b;
    es[a].push_back(b);
    es[b].push_back(a);
  }
  stack<int> ans1;
  queue<int> ans2;
  int x = 1;
  visit[x] = true;
  while(true) {
    ans1.push(x);
    bool dead = true;
    FOR(e,es[x]) {
      if(visit[e]) continue;
      visit[e] = true;
      x = e;
      dead = false;
      break;
    }
    if(dead) break;
  }
  x = 1;
  while(true) {
    ans2.push(x);
    bool dead = true;
    FOR(e,es[x]) {
      if(visit[e]) continue;
      visit[e] = true;
      x = e;
      dead = false;
      break;
    }
    if(dead) break;
  }
  ans2.pop();
  cout << ans1.size() + ans2.size() << endl;
  while(!ans1.empty()) {
    int a = ans1.top();
    ans1.pop();
    cout << a << " ";
  }
  while(!ans2.empty()) {
    int a = ans2.front();
    ans2.pop();
    cout << a << " ";
  }
  cout << endl;
  return 0;
}


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

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++)
#define FORI(i, n) for(int (i)=n-1; (i)>=0; (i)--)
template<class T, class U> void umin(T& x, const U& y){ x = min(x, (T)y);}
template<class T, class U> void umax(T& x, const U& y){ x = max(x, (T)y);}
template<class T, class U> void init(vector<T> &v, U x, size_t n) { v=vector<T>(n, x); }
template<class T, class U> void init(vector<T> &v, U x, size_t n, size_t m...) { v=vector<T>(n); for(auto& a : v) init(a, x, m);}

int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) freopen("d:\\code\\cpp\\contests\\stdin", "r", stdin);

    int n;
    ll d;
    cin >> n >> d;
    int sol = 0;
    FOR(i, n){
        ll x, y;
        cin >> x >> y;
        if (x*x + y*y <= d*d)
            sol++;
    }
    cout << sol << endl;

    if (argc == 2 && atoi(argv[1]) == 123456789) cout << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}



Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=100010;
const ll mod=1e9+7;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint& operator+=(const mint a) { if ((x += a.x) >= mod) x -= mod; return *this; }
    mint& operator-=(const mint a) { if ((x += mod-a.x) >= mod) x -= mod; return *this; }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { mint res(*this); return res+=a; }
    mint operator-(const mint a) const { mint res(*this); return res-=a; }
    mint operator*(const mint a) const { mint res(*this); return res*=a; }
    mint pow(ll t) const { if (!t) return 1; mint a = pow(t>>1); a *= a; if (t&1) a *= *this; return a; }
    // for prime mod
    mint inv() const { return pow(mod-2); }
    mint& operator/=(const mint a) { return (*this) *= a.inv(); }
    mint operator/(const mint a) const { mint res(*this); return res/=a; }
};

int main(){
  int n,k;
  cin >> n >> k;
  vector<int> a;
  for(int i=1; i*i<=n; i++){
    a.emplace_back(i);
    a.emplace_back(n/i);
  }
  a.emplace_back(0);
  sort(a.begin(),a.end());
  int sz = a.size();

  vector<vector<mint>> dp(110, vector<mint>(mx,0));
  dp[0][0] = 1;
  rep(i,k){
    rep(j,sz){ dp[i][j+1] += dp[i][j]; }
    rep(j,sz-1){
      dp[i+1][j] = dp[i][sz-2-j]*(a[j+1]-a[j]);
    }
  }

  mint ans = 0;
  rep(i,sz) ans += dp[k][i];
  cout << ans.x << endl;
  return 0;
}

Measured memory_bytes: 87676
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin >>a>>b>>c;
  cout<<fixed<<setprecision(10)<<a*b*sin(c*M_PI/180)/2<<endl;
  cout<<fixed<<setprecision(10)<<a+b+sqrt((pow(a,2)+pow(b,2)-2*a*b*cos(c*M_PI/180)))<<endl;
  cout<<fixed<<setprecision(10)<<b*sin(c*M_PI/180)<<endl;
}


Measured memory_bytes: 3544
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

int main(){
	string s;
	cin >> s;
	for(int i = 0; i < (1 << 3); i++) {
		string ans = "";
		int t = s[0] - '0';
		ans += s[0];
		for(int j = 0; j < 3; j++) {
			if(i & (1 << j)) {
				ans += "+";
				t += s[j+1] - '0';
			} else {
				ans += "-";
				t -= s[j+1] - '0';
			}
			ans += s[j + 1];
		}
		if(t == 7) {
			cout << ans << "=7" << endl;
			return 0;
		}
	}
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        long x = sc.nextLong();
      
      	long yen = 100;
      	long count = 0;
      
      	while(yen < x){
          yen += Math.floor(yen * 0.01);
          count++;
        }
      	System.out.println(count);
	}
}

Measured memory_bytes: 35804
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int N = Integer.parseInt(scan.nextLine());

		String A = scan.nextLine();

		String S = A.substring(0, N);
		String T = A.substring(N + 1);

		String str = "";

		for(int i = 0; i < N; i++){
			str += S.substring(i, i + 1);
			str += T.substring(i, i + 1);
		}
		System.out.println(str);

	}
}

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

using i64 = int64_t;

#define rep(i, x, y) for (i64 i = i64(x), i##_max_for_repmacro = i64(y); i < i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf = 1.01e9;
const i64 inf64 = 4.01e18;
const double eps = 1e-9;

template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

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

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

template<typename T, size_t size> void fill(T (&ary)[size], const T& val){
    fill_n((T*)ary, size, val);
}

void solve() {
    //const i64 mod = 1'000'000'007;

    i64 N,X;
    cin >> N >> X;
    vector<i64> L(N);
    rep(i,0,N){
        cin >> L[i];
    }

    i64 D=0,ans=0;
    if(D<=X) ++ans;
    rep(i,0,N){
        D+=L[i];
        if(D<=X) ++ans;
    }

    cout << ans << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
using namespace std;
signed main(){
    int n,m;
    int kake=1;
    cin >> n >> m;
    int ans = n * 100 + m * 1800;
    REP(i,m){
        kake *= 2;
    }
    cout << ans*kake << endl;

    return 0;
}

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

int main(){
	int n, cnt;	
	cin >> n;
	vector<int> p(n);
	for(int i=0; i<n; i++){
		cin >> p[i];
	}

	cnt = 0;
	for(int i=1; i<n-1; i++){
		if(p[i]>p[i-1] && p[i]<p[i+1]){
			cnt++;
			continue;
		}else if(p[i]<p[i-1] && p[i]>p[i+1]){
			cnt++;
			continue;
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
     Scanner sc = new Scanner(System.in);
     int a = sc.nextInt();
     int b = sc.nextInt();
     int c = sc.nextInt();
     int cnt = 0;
     for( int i = a; i <= b; i++){
      if( c % i == 0){
       cnt++;
      }
     }
     System.out.println(cnt);
    }
}


Measured memory_bytes: 26388
program prob3
    implicit none
    character(len=3) :: S
    read(*,*) S
    if(S(1:1) == '7' .or. S(2:2) == '7' .or. S(3:3) == '7') then
        write(*,*) "Yes"
    else
        write(*,*) "No"
    end if


    stop
contains
end program prob3

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

int main(){
    int N;
    cin >> N;
    vector<int> vec(N);
    for(int i=0;i < N;i++){
        cin >>vec.at(i);
    }
    sort(vec.begin(),vec.end());
    int flag = 0;
    for(int i=0;i < N - 1;i++){
        if(vec.at(i) == vec.at(i+1)){
            flag = 1;
            break;
        }
    }
    if(flag == 0){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
}

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

template <typename T>
using lim = numeric_limits<T>;

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

	int s, w;
	cin >> s >> w;
	cout << (w >= s ? "unsafe" : "safe") << "\n";
}

Measured memory_bytes: 3640
#include <stdio.h>
int main(){
    char s[10001];
    char JOI[]="JOI",IOI[]="IOI";
    while (scanf("%s",s)!=EOF) {
        int joi=0,ioi=0,i=0;
        while (s[i]!='\0') {
            int j=0,k=0;
            while (s[i+j]==JOI[j]) {
                if (j==2) {
                    joi++;
                    break;
                }
                j++;
            }
            while (s[i+k]==IOI[k]) {
                if (k==2) {
                    ioi++;
                    break;
                }
                k++;
            }
            i++;
        }
        printf("%d\n%d\n",joi,ioi);
    }
    return 0;
}

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

using namespace std;

bool solve(){
    int n,m;
    cin>>n>>m;
    if(n==0)return false;
    vector<int> a(n),b(m);
    int as=0,bs=0;
    for (int i = 0; i < n; ++i) {
        cin>>a[i];
        as+=a[i];
    }
    for (int i = 0; i < m; ++i) {
        cin>>b[i];
        bs+=b[i];
    }
    int res=as-bs;
    if(abs(res)%2==1){
        cout<<-1<<endl;
        return true;
    }
    res/=2;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            if((a[i]-b[j])==res){
                cout<<a[i]<<" "<<b[j]<<endl;
                return true;
            }
        }
    }
    cout<<-1<<endl;
    return true;
}
int main(){
    while(solve());
    return 0;
}


Measured memory_bytes: 3000
#include <bits/stdc++.h>
using namespace std;
long long int p(long long int a, long long int b){
	long long int c = 1;
	for(int i = 0;i < b;i++){
		c *= a;
		c = c % 1000000007;
	}
	return c;
}
int main(){
	long long int n;
	long long int a[300000];
	long long int a2, ans = 0;
	long long int b[60];
	for(int i = 0;i < 60;i++) b[i] = 0;
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> a[i];
		a2 = a[i];
		for(int j = 0;j < 60;j++){
			if(a2 % 2){
				b[j]++;
			}
			a2 /= 2;
		}
	}
	for(int i = 0;i < 60;i++){
		ans += ((b[i] * (n - b[i]) % 1000000007) * p(2, i));
		ans %= 1000000007;
	}
	cout << ans << endl;
}

Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second

using namespace std;

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


int main(){
    int k, x;   cin >> k >> x;
    if(k * 500 >= x){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void) {
    int64_t X;
    cin >> X;

    for(int64_t A=-1000; A<=1000; A++) {
        for(int64_t B=-1000; B<=1000; B++) {
            if(A*A*A*A*A - B*B*B*B*B == X) {
                cout << A << ' ' << B << endl;
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3676
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a),i##_end=(b);i<=i##_end;i++)
#define per(i,b,a) for(int i=(b),i##_st=(a);i>=i##_st;i--)
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define Es(x,i) for(Edge *i=G[x];i;i=i->nex)
typedef pair<int,int> pii;
typedef long long ll;
const int inf=~0u>>1,MOD=1e9+7;/*
char *TT,*mo,but[(1<<15)+2];
#define getchar() ((TT==mo&&(mo=((TT=but)+fread(but,1,1<<15,stdin)),TT==mo))?-1:*TT++)//*/
inline int rd() {
	int x=0,c=0,f=1;
	for(; c<'0'||c>'9'; c=getchar())f=c!='-';
	for(; c>='0'&&c<='9'; c=getchar())x=x*10+c-'0';
	return f?x:-x;
}
int main(){
	int n=rd(),m=rd(),k=rd(),flag=0;
	rep(i,0,n)rep(j,0,m){
		if(2*i*j+n*m==m*i+n*j+k){
			flag=1;
			break;
		}
	}
	puts(flag?"Yes":"No");
}

Measured memory_bytes: 256
import copy

MOVEMENT = [(-1, 0), (1, 0), (0, -1), (0, 1)]


def main():
    H, W = [int(s) for s in input().split()]
    MAP = []
    for h in range(H):
        row = input()
        MAP.append(list(row))

    points = []
    for h in range(H):
        for w in range(W):
            if MAP[h][w] == '.':
                points.append((h, w))

    max_step = 0
    for point in points:
        # print(point)
        map = copy.deepcopy(MAP)
        step = search(map, point)
        max_step = max(step, max_step)
    print(max_step)


def search(map, point):
    map[point[0]][point[1]] = "0"

    currents = [point]
    new_points = []
    cost = 1
    while True:
        if len(currents) == 0:
            if len(new_points) == 0:
                # print_map(map)
                return get_max_cost(map)
            currents = new_points
            new_points = []
            cost += 1
        point = currents.pop(0)

        for m in MOVEMENT:
            next_point = (point[0] + m[0], point[1] + m[1])
            if is_valid(map, next_point):
                map[next_point[0]][next_point[1]] = str(cost)
                new_points.append(next_point)


def print_map(map):
    for row in map:
        print("".join(row))


def is_valid(map, point):
    if point[0] < 0 or point[1] < 0:
        return False
    if point[0] >= len(map) or point[1] >= len(map[0]):
        return False
    if map[point[0]][point[1]] == ".":
        return True
    return False


def get_max_cost(map):
    max_cost = 0
    for row in map:
        for col in row:
            if col == '.':
                return None
            elif col == '#':
                continue
            max_cost = max(max_cost, int(col))
    return max_cost


if __name__ == "__main__":
    main()


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

int main()
{
	int h,w,n;
	scanf("%d%d%d",&h,&w,&n);
	
	int k = max(h,w);
	int g = n/k;
	printf("%d\n",g == (double)n/(double)k ?g :g+1);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main(){
   const int mod = 1000000007;
   int N;
   std::cin >> N;
   std::string S[2];
   std::cin >> S[0] >> S[1];

   long long ans = 3;
   if(N>1 && S[0][0]!=S[1][0]) ans *= 2;
   for(int i=1; i<N; ++i){
      if(S[0][i]==S[1][i]){
	 if(S[0][i-1]==S[1][i-1]) ans *= 2;
      }else if(S[0][i-1]!=S[0][i]){
	 if(S[0][i-1]==S[1][i-1]) ans *= 2;
	 else ans *= 3;
      }
   }
   std::cout << ans%mod << std::endl;

   return 0;
}


Measured memory_bytes: 256
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

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

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

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

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

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

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	s := getString()

	m := make(map[byte]int)
	for _, v := range s {
		m[byte(v)]++
	}
	if len(m) == 2 {
		for _, v := range m {
			if v != 2 {
				out("No")
				return
			}
		}
		out("Yes")
		return
	}
	out("No")
	return
}


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

int main()
{
//	freopen("*.in","r",stdin);
//	freopen("*.out","w",stdout);
	string s1,s2;
	cin >> s1 >> s2;
	int cnt = 0;
	for(int i = 0;i < s1.length();i++){
		if(s1[i] != s2[i]){
			cnt++;
		}
	}
	cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3916
# https://atcoder.jp/contests/abc087/tasks/abc087_b

a = int(input())
b = int(input())
c = int(input())
x = int(input())

cnt = 0
for i in range(a + 1):
    for j in range(b + 1):
        for k in range(c + 1):
            if 500 * i + 100 * j + 50 * k == x:
                cnt += 1
print(cnt)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define rep(i, n) FOR(i, 0, n - 1)
using namespace std;
typedef long long ll;
template <class T> inline bool dpmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool dpmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

void solve(long long N, long long M, long long C, vector<long long> B,
           vector<vector<long long>> A) {
    ll ans = 0;
    FOR(i, 0, N-1) {
        int sum = 0;
        rep(m, M) {
            sum += A[i][m] * B[m];
        }
        sum += C;

        if (sum > 0) {
            ans++;
        }
    }

    cout << ans << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips:
// You use the default template now. You can remove this line by using your
// custom template)
int main() {
  long long N;
  cin >> N;
  long long M;
  cin >> M;
  long long C;
  cin >> C;
  vector<long long> B(M);
  for (int i = 0; i < M; i++) {
    cin >> B[i];
  }
  vector<vector<long long>> A(N, vector<long long>(M));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < M; j++) {
      cin >> A[i][j];
    }
  }
  solve(N, M, C, move(B), move(A));
  return 0;
}


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

int main(){
    int n,m; cin>>n>>m;
    vector<pair<int,int>> p(n);
    vector<pair<int,int>> q(m);
    for(int i=0;i<n;i++){
        int a,b; cin>>a>>b;
        p[i]=make_pair(a,b);
    }
    for(int i=0;i<m;i++){
        int c,d; cin>>c>>d;
        q[i]=make_pair(c,d);
    }

    vector<int> ans(n,0);
    for(int i=0;i<n;i++){
        int e=1e9;
        for(int j=0;j<m;j++){
            int d=abs(p[i].first-q[j].first)+abs(p[i].second-q[j].second);
            if(d<e){
                ans[i]=j+1;
                e=d;
            } 
        }
    }
    for(int i=0;i<n;i++) cout<<ans[i]<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define pb 		push_back
#define mp 		make_pair
#define prior   priority_queue
#define MOD 	1000000007
#define INF64 	(long long)1e18
#define INF 	(int)1e9
#define PI 		3.1415926535897932384626433832795 
#define ll      long long
#define ld		long double
#define ret     return
#define NUM 	1000001
const int SIZE = 2e5+4;
void fastio(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}
void input(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
}
void swap(int& a, int& b){
	int t=a;
	a = b;
	b = t;
}
 
void solveTest(){
	
	ll n,x;
	cin>>n>>x;
	vector<ll> v(n);
	ll sum=0;
	for(int i=0;i<n;i++){
		cin>>v[i];
		sum+=v[i];
	}
	if(sum==x){
		cout<<n<<endl;
		return;
	}
	if(x>sum){
		cout<<n-1<<endl;
		return;
	}
	sort(v.begin(),v.end());
	ll cnt=0;
	for(int i=0;i<n;i++){
		if(v[i]<=x){
			cnt++;
			x -= v[i];
		}
	}
	cout<<cnt<<endl;
	return ;
}
 
int main(){
	fastio();
	//input();
 
	int t=1;
	//cin>>t;
	while(t--){
		solveTest();
 
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    double x1, y1, x2, y2;
     
    scanf("%lf%lf%lf%lf", &x1, &y1, &x2, &y2);
    printf("%.8lf\n", hypot(x1-x2, y1-y2));
    
    return 0;
}



Measured memory_bytes: 2112
import itertools
import random

def genrandom(h, w):
    g = [[0]*w for _ in range(h)]
    for i in range(1, h-1):
        for j in range(1, w-1):
            if random.randint(0,1):
                g[i][j] = 1
    return g

def display(g):
    for i in range(len(g)):
        print(''.join('#' if b else '.' for b in g[i]))

h,w = [int(s) for s in input().split()]
g = [[0]*w for _ in range(h)]

for i in range(h):
    s = input()
    for (j,c) in enumerate(s):
        if c == '#':
            g[i][j] = 1

red = [list(g[i]) for i in range(h)]
blue = [list(g[i]) for i in range(h)]

for i in range(h):
    red[i][-1] = 1
    blue[i][0] = 1
    if i % 2 == 0:
        for j in range(1,w-1):
            red[i][j] = 1
    else:
        for j in range(1,w-1):
            blue[i][j] = 1

display(red)
print()
display(blue)
#purp = [[red[i][j]&blue[i][j] for j in range(w)] for i in range(h)]
#assert(purp == g)

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

int main(){

  int a,b,c;
  

  cin >> a >> b >> c;
  if(a==b){
    if(b==c){
  cout << 1 << endl;
    }else{
      cout << 2 << endl;
    }
  }else{
    if(b==c || a==c){
      cout << 2 << endl;
    }else{
      cout << 3 << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
package main

import (
    "fmt"
    "math"
)

func main() {
    var n, cur, ans float64
    var s string

    fmt.Scan(&n, &s)

    for _, c := range s {
        if int(c) == int('I') {
            cur += 1
        } else {
            cur -= 1
        }
        ans = math.Max(ans, cur)
    }
    fmt.Println(ans)
}

Measured memory_bytes: 512
using System;

public class Hello
{
    public static void Main()
    {
        var p = new string[] { "lunch", "dinner", "midnight" };
        while (true)
        {
            var n = int.Parse(Console.ReadLine().Trim());
            if (n == 0) break;
            var a = new int[3];
            var b = new int[3];
            for (int i = 0; i < n; i++)
            {
                string[] line = Console.ReadLine().Trim().Split(' ', ':');
                var h = int.Parse(line[0]);
                var m = int.Parse(line[1]);
                var m2 = int.Parse(line[2]);
                var t1 = 60 * h + m;
                var t2 = m2 - m;
                if (t2 < 0) t2 += 60;
                bool ok;
                ok = t2 <= 8 ? true : false;
                if (t1 >= 660 && t1 <= 899)
                {
                    b[0]++;
                    if (ok) a[0]++;
                }
                else if (t1 >= 1080 && t1 <= 1259)
                {
                    b[1]++;
                    if (ok) a[1]++;
                }
                else if ((t1 >= 1260 && t1 <= 1439) | (t1 >= 0 && t1 <= 119))
                {
                    b[2]++;
                    if (ok) a[2]++;
                }
            }
            for (int i = 0; i < 3; i++)
                if (b[i] == 0) Console.WriteLine("{0} no guest", p[i]);
                else Console.WriteLine("{0} {1}", p[i], a[i] * 100 / b[i]);
        }
    }
}


Measured memory_bytes: 15948
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#define REP(i, n) for(int i=0; i<(n); i++)
#define FOR(i, a, n) for(int i=(a); i<(n); i++)
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<char> vc;

int main(){
    int N;
    cin >> N;
    int ans = 0;
    int count = 0;
    ll preH;
    cin >> preH;
    FOR(i, 1, N){
        ll H;cin>>H;
        if(preH >= H){
            count++;
        }else{
            count = 0;
        }
        if(ans < count) ans = count;
        preH = H;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define MOD (1000000007l)
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)

using namespace std;

void solve() {
  ll N;
  cin >> N;
  ll taro = 0;
  ll hanako = 0;
  rep (i, N) {
    string foo, bar;
    cin >> foo >> bar;
    if (foo > bar) taro += 3;
    else if (foo < bar) hanako += 3;
    else {
      taro++;
      hanako++;
    }
  }
  cout << taro << " " << hanako << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  cout << fixed;
  solve();
  return 0;
}



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

int main() {
  int N, T; cin >> N >> T;
  int ans = 1001;
  for(int i = 0; i < N; i++) {
    int c, t; cin >> c >> t;
    if (t <= T) {
      ans = min(ans, c);
    }
  }
  if(ans == 1001) {
    cout << "TLE" << endl;
  }
  else cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
long long gcd(long long x, long long y) {
	if (y == 0) return x;
	return gcd(y, x % y);
}
int main() {
	int Q;
	cin >> Q;
	while (Q--) {
		long long A, B, C, D;
		cin >> A >> B >> C >> D; ++C;
		long long g = gcd(B, D);
		if (B > D || A - B < 0 || (A % g - C % g + g) % g + C - B < 0) {
			cout << "No" << endl;
		}
		else {
			cout << "Yes" << endl;
		}
	}
	return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

LL n;

int main() {
    ios_base::sync_with_stdio(false);
    cin >> n;
    --n;
    LL cnt = 26;
    int len = 1;
    while (cnt <= n) {
        n -= cnt;
        cnt *= 26;
        ++len;
    }
    string ans(len, 'a');
    forn(i, len) {
        ans[len - 1 - i] = 'a' + (n % 26);
        n /= 26;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3556
#include <iostream>
using std::cout;
using std::endl;
using std::cin;


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

    if(n%10 == 2 || n%10 == 4 || n%10 == 5 || n%10 == 7 || n%10 == 9){
        cout << "hon" << endl;
    } else if(n%10 == 0 || n%10 == 1 || n%10 == 6 ||n%10 == 8){
        cout << "pon" << endl;
    } else{
        cout << "bon" << endl;
    }
    return 0;
}

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

typedef long long ll;
ll D,ans;
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>D;
	if(D%9){
		cout<<0<<'\n';
		return 0;
	}
	D/=9;ll pw=1;
	for(int i=1;i<=17;++i){
		ll tmp=1,d=D,lp=pw,rp=1;pw*=10;
		ll b=(pw-1)/9;
		for(int j=0;j+j<=i;++j){
			tmp*=10-abs(d%(rp*10)/rp)-!j;
			d-=b*(d%(rp*10)/rp);
			b-=lp+rp;lp/=10;rp*=10;
		}
		if(!d)ans+=tmp;
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <cmath>
#include <unordered_map>
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
ll intpow(int n,int m){
    if(m==0)return 1;
    return n*intpow(n,m-1);
}
ll gcd(ll n,ll m){
    n = max(n,m);
    m = min(n,m);
    if(n%m == 0)return m;
    return gcd(m,n%m);
}
ll lcm(ll n,ll m){
    return n*m/gcd(n,m);
}

struct edge{
    int to,id;
};
vector<vector<edge>>G;
int color[100002];
void dfs(int v,int c,int p){
    int i=1;
    for(int j=0;j<G[v].size();j++){
        int u = G[v][j].to;
        int ei =G[v][j].id;
        if(u == p) continue;
        if(i == c)i++;
        color[G[v][j].id]=i;
        dfs(u,i,v);
        i++;
    }
}
int main(){
    int n;cin>>n;
    G.resize(n);
    rep(i,n-1){
        int a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back((edge){b,i});
        G[b].push_back((edge){a,i});
    }
    dfs(0,-1,-1);
    int maxc=0;
    rep(i,n){int t=G[i].size();maxc=max(maxc,t);}
    cout<<maxc<<endl;
    rep(i,n-1)cout<<color[i]<<endl;
}

Measured memory_bytes: 8320
#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=1000000007;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };


int main() {
	int a,b,c;
	cin>>a>>b>>c;
	if(c>=a && c<=b){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Gosu_Hiroo
 */

#include <iostream>
#include <fstream>

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

typedef long long ll;
#define tr(container, it) \
        for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c, x) ((c).find(x) != (c).end())   //O(log n)
#define contains(c, x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mll map<ll,ll>
#define intv(x, a, b)((x)>=a && (x)<=b)
#define  rep(i, _begin, _end) for (__typeof(_end) end = _end, begin = _begin,  i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define  _for(i, end) for (__typeof(end) i = 0, _len = (end); i < (_len); i += 1)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define F first
#define S second
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define what_is(x) cerr << #x << " is " << x << endl;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define mod(x, m) ((((x) % (m)) + (m)) % (m))
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define readint ({int t;cin >> t;t;})
const double PI = 2 * acos(.0);
const int INF = 0x3f3f3f3f;
const ll LLINF = 1000000000000000005LL;;
const ll MOD = (ll) (1e9) + 7;
void _mod(ll &x){x = mod(x, MOD);}
//const ll MOD = (ll) 998244353 ;
const double EPS = 1e-10;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *) array, (T *) (array + N), val);
}

template <typename T>
ostream& operator << (ostream& os, const vector<T> V) {
    for(auto v : V)os << v << " ";
    return os;
}

template <typename T>
ostream& operator << (ostream& os, const set<T> V) {
    for(auto v : V)os << v << " ";
    return os;
}

//#define int ll


class AXORCircle {
public:
    map<int, int> M;
void solve(std::istream& cin, std::ostream& cout) {
    int N;
    cin >> N;
    _for(i,N){
        int t;
        cin >> t;
        M[t] ++;
    }
    if(M.count(0)){
        if(M.size() == 2 && N%3 == 0 && M[0] == N/3 || (M.size() == 1))cout << "Yes";
        else cout << "No";
    }
    else {
        auto it = M.begin();
        if(M.size() ==3){
            int num1 = it->first, cnt1 = it->second;
            it++;
            int num2 = it->first, cnt2 = it->second;
            it++;
            int num3 = it->first, cnt3 = it->second;
            if((num1 ^ num2) == num3 && cnt1 == cnt2 && cnt2 == cnt3)cout << "Yes";
            else cout << "No";
        }
        else cout << "No";
    }

}


};


#undef int
int main() {


	AXORCircle solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	in.tie(0); ios::sync_with_stdio(0); out<<fixed<<setprecision(20);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  int answer = 0;
  if(a<b){
    for(int i=0;i<b;i++){
      answer += a*pow(10,i);
    }
  }
  else{
    for(int i=0;i<a;i++){
      answer += b*pow(10,i);
    }
  }
  cout << answer << endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

using Graph = std::vector<std::vector<int>>;
using WGraph = std::vector<std::vector<std::pair<int, long long>>>;
using ll = long long;
using namespace std;

int main() {
    string s = ""; cin >> s;
    if (s == "AKIHABARA" ||
        s == "KIHABARA" ||
        s == "AKIHBARA" ||
        s == "AKIHABRA" ||
        s == "AKIHABAR" ||
        s == "KIHBARA" ||
        s == "KIHABRA" ||
        s == "KIHABAR" ||
        s == "AKIHBRA" ||
        s == "AKIHBAR" ||
        s == "AKIHABR" ||
        s == "KIHBRA" ||
        s == "KIHBAR" ||
        s == "KIHABR" ||
        s == "AKIHBR" ||
        s == "KIHBR") {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }

    return 0;
}
 

Measured memory_bytes: 384
#include <iostream>
#include <set>
#include <string>
#include <map>
#include <vector>
using namespace std;

const int INF = 1e9, N = 2e5+5;
int n,bit[N];

void update(int x) {
    while(x <= n) {
        bit[x]++;
        x += x & (-x);
    }
}

int get(int x) {
    int ans = 0;
    while(x) {
        ans += bit[x];
        x -= x & (-x);
    }
    return ans;
}

int get_miss(int x,int y) {
    if(x > y) return 0;
    return get(y) - get(x-1);
}

int main() {
    string s;
    cin >> s;
    n = s.size();
    s = "$"+s;
    map<char,set<int>> mp;
    for(int i=1;i<=n;i++) mp[s[i]].insert(i);
    long long ans = 0;
    int lix = 1, rix = n;
    vector<bool> v(n+1);
    while(lix < rix) {
        if(v[lix]) {lix++; continue;}
        if(v[rix]) {rix--; continue;}
        if(s[lix] == s[rix]) {
            v[lix] = 1; v[rix] = 1;
            mp[s[lix]].erase(lix);
            lix++;
            mp[s[rix]].erase(rix);
            rix--;
            continue;
        }
        int l_fix = INF, r_fix = INF;
        auto x = --mp[s[lix]].end();
        if((*x) > lix) {
            l_fix = min(l_fix,rix-(*x)-get_miss(*(x)+1,rix-1));
        }
        auto y = mp[s[rix]].begin();
        if((*y) < rix) {
            r_fix = min(r_fix,(*y)-lix-get_miss(lix+1,(*y)-1));
        }
        if(l_fix < r_fix) {
            //cout << "l_fix: " << l_fix << endl;
            ans += l_fix;
            v[*x] = 1; v[lix] = 1;
            update(*x);
            mp[s[lix]].erase(x);
            mp[s[lix]].erase(lix);
            lix++;
        } else {
            if(l_fix == INF && l_fix == r_fix) {
                cout << "-1";
                return 0;
            }
            //cout << "r_fix: " << r_fix << endl;
            ans += r_fix;
            v[*y] = 1; v[rix] = 1;
            update(*y);
            mp[s[rix]].erase(y);
            mp[s[rix]].erase(rix);
            rix--;
        }
    }
    cout << ans;
}


Measured memory_bytes: 10560
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

/*should use ::toupper/lower as its defined in global scope, not std*/

#define pb push_back
#define eb emplace_back
#define res reserve

#define pii pair<int, int>
#define mp make_pair
#define f first
#define s second

#define pq priority_queue<int, vector<int>, greater<int>>

#define mt make_tuple

#define endl << "\n" 
#define bigint __int128_t; // Not available in all contest systems
#define rr return
#define cc continue

#define feq(a, b) (abs(a - b) < 1e-9)

using ll = long long;

using namespace __gnu_pbds;
using namespace std;

typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const ll INF = 1e17; 
const int MOD = 1e9 + 7;

#define madd(a, b) ((int(a) % MOD + int(b) % MOD) % MOD)
#define msub(a, b) ((int(a) % MOD - int(b) % MOD) % MOD)
#define mmul(a, b) ((int(a) % MOD * int(b) % MOD) % MOD)

#define ue(u, v, g) g[u].eb(v), g[v].eb(u)

const int mxN = (int)1e7 + 10000;

void solve() {

	int n;
	cin >> n;

	switch(n % 10){
		case 2:
		case 4:
		case 5:
		case 7:
		case 9:
		cout << "hon";
		break;
		case 0:
		case 1:
		case 6:
		case 8:
		cout << "pon";
		break;
		case 3:
		cout << "bon";
		break;

	}

}

int main() {

	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int t;
	//cin >> t;
	t = 1;

	while(t--) {
		solve();
	}

}

Measured memory_bytes: 3648
s = input()
n = len(s)
e = 0
def judge(a,b,c):
    if c[a-5:a] == "erase":
        b = 5
        return b
    elif c[a-5:a] == "dream":
        b = 5
        return b
    elif c[a-6:a] == "eraser":
        b = 6
        return b
    elif c[a-7:a] == "dreamer":
        b = 7
        return b
    else:
        return 100
while n >= 5:
    e = judge(n,e,s)
    if e == 100:
        break
    else:
        n = n - e
if n == 0:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3188
/*
AizuOnline A0082
Title
13/3/19 WA
*/
#include <stdio.h>
#define min(x,y) (((x)<(y))?(x):(y))
//Global data section
int kyaku[8];
int merry[8]={1,4,1,4,1,2,1,2};
int order[8]={5,1,6,2,8,4,7,3};
char buf[40];
//
main()
{
  int sum;
  int maxi,maxsum;
  int i,j;

  while(scanf("%d %d %d %d %d %d %d %d",
	      &kyaku[0],&kyaku[1],&kyaku[2],&kyaku[3],
	      &kyaku[4],&kyaku[5],&kyaku[6],&kyaku[7])==8)
    {
      maxsum=-1;
      maxi  =-1;
      for(i=0;i<8;i++)
	{
	  sum = 0;
	  for(j=0;j<8;j++)
	    {
	      sum += min(kyaku[j],merry[(i+j)%8]);
	    }
	  if(sum > maxsum ||( sum==maxsum && order[i]>order[maxi]))
	    {
	      maxi=i;
	      maxsum=sum;
	    }
	  //printf("%d sum %d\n",i,sum);
	}
      for(i=0;i<8;i++)
	{
	  printf("%d",merry[(i+maxi) % 8]);
	  if(i<7)
	    printf(" ");
	}
      printf("\n");
    }
return(0);
}

Measured memory_bytes: 604
#include <stdio.h>

int main() {
	int in[100][2], i;

	for (i = 0; i < 100; i++) {
		scanf("%d %d", &in[i][0], &in[i][1]);
		if (in[i][0] == 0 && in[i][1] == 0)break;
	}

	for (int j = 0; j < i; j++) {
		for (int k = 0; k < in[j][0]; k++) {
			for (int l = 0; l < in[j][1]; l++) {
				printf("#");
			}printf("\n");
		}printf("\n");
	}

	return 0;
}


Measured memory_bytes: 2100
x, y = map(int, input().split())
ans = "No"
for i in range(0, x+1):
    for j in range(0, x+1):

        if i + j > x:
            break

        if i + j != x:
            continue

        if i * 2 + j * 4 == y:
            ans = "Yes"

print(ans)


Measured memory_bytes: 9172
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define vii vector<ll> 
#define pb push_back
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
const int MOD = 1e9 + 7, N = 1e5 + 3;

int main(){
    fast;
    ll n, m;
    cin >> n >> m;
    ll a[m];
    vii b;
    for(int i = 0; i < m; ++i) 
        cin >> a[i];
    if(n >= m){
        cout << "0\n";
        return 0;
    }
    sort(a, a + m);
    for(int i = 0; i < m - 1; ++i) 
        b.pb(abs(a[i] - a[i + 1]));
    sort(b.rbegin(), b.rend());
    ll ans = 0;
    for(int i = n - 1; i < m - 1; ++i) 
        ans += b[i];
    cout << ans;
    cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
    return 0;
}

Measured memory_bytes: 5008
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>

int main(void){
	long long int n;	
	std::cin >> n;
	
	std::vector<long long int> a(n);
	for(int i = 0; i < n; i++){
		std::cin >> a[i];
	}

	for(int i = 0; i < n; i++){
		a[i] -= i + 1;
	}
	std::sort(a.begin(), a.end());

	long long int mid = a[n / 2], cost = 0;
	for(int i = 0; i < n; i++){
		cost += abs(a[i] - mid);	
	}
	
	std::cout << cost << std::endl;
	return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
 
int A[1000000], n;
 
int binarySearch(int key)
{
    int left = 0, right = n, mid;
    while (left < right)
    {
        mid = (left + right) / 2;
        if (key == A[mid])return mid;
        else if (key < A[mid])right = mid;
        else left = mid + 1;
    }

    return 0;
}
 
int main()
{
    int i,q,k,result;
 
    scanf("%d", &n);
    for (i = 0; i < n; i++)
    {
        scanf("%d", &A[i]);
    }

    scanf("%d", &q);

    for (i = 0; i < q; i++)
    {
        scanf("%d", &k);
        if (binarySearch(k))result++;
    }

    printf("%d\n",result);
    
    return 0;
}

Measured memory_bytes: 980
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define INIT(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define INIT2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a*b /gcd(a,b);}

int kaijo(int n){ if(n==1)return 1; else return kaijo(n-1)*n;}

int main(){
  int N; cin>>N;
  int t[N];
  ld x[N];
  ld y[N];
  REP(i,N){
    t[i] = i;
    scanf("%Lf",&x[i]);
    scanf("%Lf",&y[i]);
  }
  ld r = 0;
  ld d = kaijo(N);
  do{
    ld temp = 0;
    REP(i,N-1){
      int a = t[i+1];
      int b = t[i];
      temp += sqrt( pow(x[a]-x[b],2) + pow(y[a]-y[b],2) );
    }
    r += temp/d;
  }while(next_permutation(t,t+N));
  printf("%.7Lf",r);
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int n,m;
int V; // number of Vertex
int s,G;// number of start
vector<pii>g[10000]; // first: to second: cost
vi d(1000,INF); // start->index  mminimum distance
void dijkstra(){
    priority_queue<pii,vector<pii>,greater<pii>>que;
    d[s]=0;
    que.push(pii(0,s));
    while(!que.empty()){
    pii now=que.top(); que.pop();
        int v=now.second;
        if(d[v]<now.first)continue;
        for(int i=0; i<g[v].size();i++){
            pii e=g[v][i];
            if(d[e.first]>d[v]+e.second){
                d[e.first]=d[v]+e.second;
                que.push(pii(d[e.first],e.first));
            }
        }
    }
}
int main(){
    cin>>V>>m;
    rep(i,m){
        int to,from,tiya,rize;
        char gomi; cin>>from>>gomi>>to>>gomi>>tiya>>gomi>>rize;
        g[from].push_back(pii(to,tiya));
        g[to].push_back(pii(from,rize));
    }
    int gotiusa,amausa;
    char gomi;
    cin>>s>>gomi>>G>>gomi>>gotiusa>>gomi>>amausa;
    dijkstra();
    int rize=d[G];
    int hoge=s;
    swap(s,G);
    vi yebi(1000,INF);
    d=yebi;
    dijkstra();
    cout<<gotiusa-amausa-rize-d[G]<<endl;
}

Measured memory_bytes: 3244