akhauriyash/Code-Regression huggingface dataset:
/*
[ ( ^ _ ^ ) ]
*/

// problem: atc/abc162_e

import java.io.*;
import java.util.*;


public class Main {
    int INF = (int)1e9;
    long MOD = 1000000007;

    long pow(long a, long n) {
        long rs = 1;
        while (n > 0) {
            if (n % 2 == 1) {
                rs *= a;
                rs %= MOD;
            }
            n >>= 1;
            a *= a;
            a %= MOD;
        }
        return rs;
    }

    long mul(long a, long b) {
        return (a*b)%MOD;
    }

    void solve(InputReader in, PrintWriter out) throws IOException {
        int n = in.nextInt();
        int k = in.nextInt();
        int rs = 0;
        long[] dp = new long[k+1];
        for(int i=k; i>=1; i--) {
            dp[i] = pow(k/i, n);
            for(int j=2*i; j<=k; j+=i) {
                dp[i] -= dp[j];
                if(dp[i]<0) dp[i] += MOD;
            }
            rs += (i*dp[i])%MOD;
            if(rs>=MOD) rs -= MOD;
        }
        out.println(rs);
    }
    

    public static void main(String[] args) throws IOException {
        InputReader in = new InputReader();
        PrintWriter out = new PrintWriter(System.out);
        int t = 1;//in.nextInt();
        while(t-- >0) {
            new Main().solve(in, out);
        }
        out.close();
    }
    
    public static void show(Object... o) {
        System.out.println(Arrays.deepToString(o));
    }
    
    static class InputReader {
        static BufferedReader br;
        static StringTokenizer st;
        public InputReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() { return Integer.parseInt(next()); }
        long nextLong() { return Long.parseLong(next()); }
        double nextDouble() { return Double.parseDouble(next()); }
    }
}

Measured memory_bytes: 26924
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>


using namespace std;
string yn(bool a)
{
  if (a){return "Yes";}
  else{return "No";}
}

bool sosuu(int n)
{
  int i=3;
  if(n==1){return false;}
  if(n==2){return true;}
  if(n%2==0){return false;}
  while(true)
  {
    if(n%i==0&&n!=i){return false;}
    if(i>sqrt(n)+1){break;}
    i+=2;
  }
  return true;

}

int main()
{
  ios::sync_with_stdio(false);
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(a+b>c+d){cout<<"Left";}
  else if(a+b<c+d){cout<<"Right";}
  else{cout<<"Balanced";}

}

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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = int(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = int(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = int(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = int(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = int(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = (1 << 30) - 1;
const long long LLINF = 1LL << 61;
const long long MOD = 1000000007LL;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

class UnionFind{
    vector<int> par;
    vector<long long> wei;
    int groupCount;

public:
    void init(int n = 0){
        par.resize(n);
        fill(par.begin(), par.end(), -1);

        wei.resize(n);
        fill(wei.begin(), wei.end(), 0LL);

        groupCount = n;

        return;
    }

    UnionFind(int n = 0){
        init(n);
    }

    int root(int x){
        if(par[x] < 0){
            return x;
        }
        int r = root(par[x]);
        wei[x] += wei[par[x]];
        return par[x] = r;
    }

    bool same(int x, int y){
        return root(x) == root(y);
    }

    int size(int x){
        return -par[root(x)];
    }

    long long weight(int x){
        root(x);
        return wei[x];
    }

    long long diff(int x, int y){
        if(!same(x, y)){
            return LLONG_MIN;
        }
        return weight(y) - weight(x);
    }

    bool unite(int x, int y, long long w = 0){
        w += weight(x) - weight(y);

        x = root(x);
        y = root(y);

        if(x == y){
            return false;
        }

        if(size(x) < size(y)){
            swap(x, y);
            w = -w;
        }

        par[x] += par[y];
        par[y] = x;
        wei[y] = w;
        --groupCount;

        return true;
    }

    int number_of_group(void){
        return groupCount;
    }
};

template<typename T>
bool chmax(T &_a, T _b){
    if(_a < _b){
        _a = _b;
        return true;
    }else{
        return false;
    }
}

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

    int n;
    cin >> n;

    vector<lint> x(n), y(n);
    rep(i, n){
        cin >> x[i] >> y[i];
    }

    vector< LLP > v;
    rep(i, n){
        rep(j, n){
            if(x[i] == x[j] && y[i] == y[j]){
                continue;
            }
            v.emplace_back(x[i] - x[j], y[i] - y[j]);
        }
    }

    UnionFind uf(n);
    lint ans = n;
    rep(i, v.size()){
        lint p = v[i].first, q = v[i].second;
        uf.init(n);
        rep(j, n){
            rep(k, n){
                if(x[j] - x[k] == p && y[j] - y[k] == q){
                    uf.unite(j, k);
                }
            }
        }
        ans = min(ans, (lint)uf.number_of_group());
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
import java.util.*;
import java.io.*;

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 M = Math.max(A,Math.max(B,C));
        
        System.out.println(A+B+C+9*M);
        
    }
}


Measured memory_bytes: 23124
x, y, z, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

ab = []
for i in a:
    for j in b:
        ab.append(i+j)
ab.sort(reverse=True)
ab = ab[:k]

abc = []
for i in ab:
    for j in c:
        abc.append(i+j)
        
abc.sort(reverse=True)
for i in abc[:k]:
    print(i)


Measured memory_bytes: 151512
#include <stdio.h>

int main (void){

	unsigned long S;
	int h;
	int m;
	int s;

	scanf ("%d",&S);

	if (S<0) exit(1);
	else if (S>86400-1) exit(1);

	else
	h = S/3600;
	m = (S - h*3600)/60;
	s = S - (h*3600 + m*60);	

	printf ("%d:%d:%d\n",h ,m ,s);

	return 0;
}

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

vector<int> temp(10e7, 0);

int main() {
    int n, k, r, s, p, ans = 0;
    string t;
    cin >> n >> k >> r >> s >> p >> t;
    for(int i = 0; i < k; i++) {
        switch(t.at(i)) {
            case 'r':
                ans += p;
                break;
            case 's':
                ans += r;
                break;
            case 'p':
                ans += s;
                break;
        }
    }
    for(int i = k; i < n; i++) {
        if(t.at(i) == t.at(i - k)) {
            t.at(i) = '.';
            continue;
        }
        switch(t.at(i)) {
            case 'r':
                ans += p;
                break;
            case 's':
                ans += r;
                break;
            case 'p':
                ans += s;
                break;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 391040
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		FastScanner in = new FastScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskD solver = new TaskD();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskD {
		public void solve(int testNumber, FastScanner in, PrintWriter out) {
			long x = in.nextLong();
			long y = in.nextLong();
			out.println(Math.abs(x - y) > 1 ? "Alice" : "Brown");
		/*
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				out.print(win(i,j)?1:0);
			}
			out.println();
		}
		out.println();
		*/
		}

	}

	static class FastScanner {
		private BufferedReader in;
		private StringTokenizer st;

		public FastScanner(InputStream stream) {
			in = new BufferedReader(new InputStreamReader(stream));
		}

		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					String rl = in.readLine();
					if (rl == null) {
						return null;
					}
					st = new StringTokenizer(rl);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

	}
}



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

int main() {
  int N, K, x; // ボールの個数N,マシンBのx軸上の位置K,各ボールのx軸上の位置xを定義
  int a = 0; // マシンの移動距離の総和をaと定義
  cin >> N >> K;
  
  for (int i = 0; i < N; i++) {
    cin >> x;
    if (x < (K - x)) { // マシンA,Bからのボールの距離を比較し小さい方をaに代入
      a += 2 * x;
    }
    
    else
      a += 2 * (K - x);
  }
  
  cout << a << endl;
}

Measured memory_bytes: 256
import Control.Monad
import Data.List
import Data.Array.Unboxed
import qualified Data.ByteString.Char8 as B

main = do
    (h:w:_)<-map read.words<$>getLine::IO[Int]
    as <- replicateM h $ map read.words<$>getLine::IO[[Int]]
    let ass = listArray ((1,1),(h,w)) $ concat as :: UArray (Int,Int) Int
    let bs = listArray (1,h) $ map sum as :: UArray Int Int
    --
    ans1 <- (<$>) concat $ forM [1..h] $ \ih -> do
        let ows = fiw ih w ass 1
        return $ pairs ih w ows
    --
    let ans2 = (++) ans1 $ pairsh h w $ fih h bs 1
    print $ length ans2
    putStr $ unlines $ map (unwords.(map show)) ans2
--
fiw h w ass iw
    | iw > w = []
    | odd (ass ! (h,iw)) = iw : fiw h w ass (iw+1) 
    | otherwise = fiw h w ass (iw+1)
fih h bs ih
    | ih > h = []
    | odd (bs ! ih) = ih : fih h bs (ih+1) 
    | otherwise = fih h bs (ih+1)
--
pairs _ _ [] = []
pairs h w [x]
    | w == x = []
    | otherwise = mvw h x w
pairs h w (f:t:r) = mvw h f t ++ pairs h w r
--
mvw h f t = map (\i->[h,i,h,i+1])  [f..t-1]
--
pairsh _ _ [] = []
pairsh h w [x] = []
pairsh h w (f:t:r) = mvh w f t ++ pairsh h w r
--
mvh w f t = map (\i->[i,w,i+1,w]) [f..t-1]


Measured memory_bytes: 54780
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> N;
    vi a(N + 1, 0);
    REPS(i, 100)
    REPS(j, 100)
    REPS(k, 100) {
        int n = i * i + j * j + k * k + i * j + j * k + i * k;
        if (n <= N) {
            a[n]++;
        }
    }
    REPS(i, N) {
        cout << a[i] << endl;
    }
}

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

int main() {
	int n,l;
	string s[100000];
	cin>>n>>l;
	for(int i=0;i<n;i++) cin>>s[i];
	sort(s,s+n);
	for(int i=0;i<n;i++) cout<<s[i];
	cout<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(void){
  	char b;
  	scanf("%c",&b);
  	if(b == 'A') printf("T\n");
  	if(b == 'C') printf("G\n");
 	if(b == 'G') printf("C\n");
 	if(b == 'T') printf("A\n");
	return 0;
}

Measured memory_bytes: 128
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        int N = scan.nextInt();
        int K = scan.nextInt();
        String S = scan.next();
        char sArray[] = S.toCharArray();

        int red = 0, blue = 0;//red = RL, blue = LR
        char prev = sArray[0];
        int answer = 0;

        for (int i = 1; i < N; i++) {
            if(prev == 'L' && sArray[i] == 'R') {
                prev = 'R';
                blue++;
            } else if (prev == 'R' && sArray[i] == 'L') {
                prev = 'L';
                red++;
            } else if (prev == 'L' && sArray[i] == 'L') {
                answer++;
            } else if (prev == 'R' && sArray[i] == 'R') {
                answer++;
            }
        }
        int less = red > blue ? blue : red;
        int more = red < blue ? blue : red;

        if(K <= less) {
            answer += 2*K;
        } else {
            answer += 2*less + more - less;
        }
        os.println(answer);
    }
}

Measured memory_bytes: 28280
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cfloat>
#include <algorithm>
#include <numeric>
#include <vector>
#include <iterator>
#include <set>
using namespace std;

const double PI=acos(-1);

int main(){
    int n;
    long l[87];
    cin >> n;

    l[0] = 2; l[1] = 1;
    for(int i = 2; i < 87; i++){
        l[i] = l[i-1] + l[i-2];
    }

    cout << l[n] << endl;
    
    return 0;
}

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

using namespace std;

int main(){
	int N, K, ans = 1000000000; cin >> N >> K;
	vector<int> h(N);
	for(int i = 0; i < N; ++i) cin >> h[i];
	sort(h.begin(), h.end());
	for(int i = 0; i < N - K + 1; ++i){
		ans = min(ans, abs(h[i] - h[i + K - 1]));
	}
	cout << ans << endl;
}


Measured memory_bytes: 640
#085 C

N,Y =map(int,input().split())
for i in range(N+1):
    for j in range(N-i+1):
        k=N-(i+j)
        if i * 10000 + j * 5000 + k *1000 ==Y and (i+j+k)==N:
            print(i,j,k)
            exit()
print(-1,-1,-1)

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

#define int             long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define REPR( i, m )    for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )  FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()
#define MP              make_pair

typedef pair<int, int> P;

template<class T>bool chmax( T& a, const T& b ) { if( a < b ) { a = b; return 1; } return 0; }
template<class T>bool chmin( T& a, const T& b ) { if( a > b ) { a = b; return 1; } return 0; }

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

signed main(){
    int N;
    while( cin >> N, N ){
        vector<int> a( N );
        int sum = 0;
        REP( i, N ) {
            cin >> a[i];
            sum += a[i];
        }

        double ave = sum / N;
        int ans = 0;
        REP( i, N ){
            if( a[i] <= ave ) ans++;
        }

        cout << ans << endl;
    }
}



Measured memory_bytes: 3128
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define pr(...) GET_MACRO(__VA_ARGS__,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)
#define Pr(a) (#a)<<"="<<(a)<<" "
#define pr1(a) cerr<<Pr(a)<<endl;
#define pr2(a,b) cerr<<Pr(a)<<Pr(b)<<endl;
#define pr3(a,b,c) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<endl;
#define pr4(a,b,c,d) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<endl;
#define pr5(a,b,c,d,e) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<Pr(e)<<endl;
#define pr6(a,b,c,d,e,f) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<Pr(e)<<Pr(f)<<endl;
#define int long long
#define double long double
using namespace std;
const int INF = 1LL<<55;
const int mod = 924844033;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
typedef long long ll;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}
const int N = 2010;
int n,K;
int dp[N*3][N][2];

int Add(int &a,int b){return a = (a%mod + b%mod + mod)%mod;}
int Sub(int &a,int b){return a = (a%mod - b%mod + mod)%mod;}

void DP(){
  for(int i=1;i<=K;i++) dp[i][0][1] = 1;
  for(int i=1;i<=K;i++) dp[i+K][0][0] = 1;
  
  for(int i=1;i<=n;i++)
    for(int cnt=0;cnt<=n;cnt++)
      for(int flag = 0; flag <= 1; flag++){
        int a = dp[i][cnt][flag];
        Add(dp[i+2*K][cnt][0], a); //使わない。
        if(i + K <= n) Add(dp[i+2*K][cnt+1][1], a); //下側を使う
        if(flag == 0 && i <= n) Add(dp[i+2*K][cnt+1][0], a);//上側を使う
      }
}

unordered_map<int,int> DP2(){
  
  unordered_map<int,int> res[2];
  res[0][0] = 1;
  
  int N = n + 2 * K;
  for(int i=0;i<2*K;i++){ // 下から
    int I = i%2;
    res[!I] = res[I];
    
    for(int j=1;j<=n;j++){ //何個使ったか
      int a = (dp[N-i][j][0] + dp[N-i][j][1]) % mod; //通り数
      if(a == 0) continue;
      for(auto &p:res[I]){
        int k = p.first; //個数
        int b = p.second; //通り数
        res[!I][j + k] += a * b;
        res[!I][j + k] %= mod;
      } 
    }
  }
  return res[2*K%2];
}

signed main(){
  vector<int> F(2010,1);
  for(int i=1;i<2010;i++) F[i] = (F[i-1] * i)%mod;
  cin>>n>>K;
  DP();
  auto A = DP2();
  int ans = 0;
  
  for(auto a:A){
    int f = (a.first % 2)? -1:1;
    int cnt = a.second * F[n-a.first] % mod;
    Add(ans, f * cnt);
  }
  cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 186880
program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils,Classes;
var
  h,w,i,j,count,x,y,sw,m,n,a,b:Integer;
  s123,s1,s2,s3:string;
  tf:Boolean;
  nyu:TStringList;
begin
  try
    { TODO -oUser -cConsole Main : ここにコードを記述してください }
    nyu:=TStringList.Create;
    Readln(s123);
    s123:=UpperCase(s123);
    nyu.CommaText:=s123;

    Writeln(nyu[0][1]+nyu[1][1]+nyu[2][1]);
    Readln;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.


Measured memory_bytes: 256
Option Strict On

Module Module1
    Sub Main()
        'let'
        Dim tmp() As Long =
            Array.ConvertAll(Of String, Long) _
            (Console.ReadLine().Split(), AddressOf Long.Parse)
        Dim a As Long = tmp(0)
        Dim b As Long = tmp(1)
        Dim c As Long = tmp(2)
        Dim d As Long = tmp(3)

        Dim arr() As Long = New Long() {a, b, c}

        'var'
        Dim flg As Boolean

        If Math.Abs(a - c) > d Then
            For i As Int32 = 0 To UBound(arr) - 1
                If Math.Abs(arr(i) - arr(i + 1)) > d Then
                    flg = True
                End If
            Next
        End If

        Console.WriteLine(New String() {"Yes", "No"}(Convert.ToInt32(flg)))

    End Sub


End Module


Measured memory_bytes: 13268
h, w = map(int, input().split())
graph = []
for _  in range(h):
    graph.append(input())

ans = [[0]*w for i in range(h)]
pattern = [[-1, -1], [-1, 0], [-1, 1], [0, -1], [0, 1], [1, -1], [1, 0], [1, 1]]
for y in range(h):
    for x in range(w):
        if graph[y][x] == '#':
            ans[y][x] = float('INF')

            for dy, dx in pattern:
                ny, nx = y + dy, x + dx
                if ny < 0 or ny >= h or nx < 0 or nx >= w:
                    continue

                ans[ny][nx] += 1
        else:
            continue

for line in ans:
    print(''.join(map(str, line)).replace('inf', '#'))


Measured memory_bytes: 3064
import java.io.*;
public class Main {
		public static void main(String[] arg) throws IOException {
			InputStreamReader is = new InputStreamReader(System.in); 
	        BufferedReader br = new BufferedReader(is);
			String str = br.readLine();
			String[] spl = str.split(" ");
			int[] array = new int[spl.length];

			for(int i = 0 ; i < spl.length ; i++){
				array[i] = Integer.parseInt(spl[i]);
			}
			if(array[2]-array[4]>=0&&array[2]+array[4]<=array[0] &&
					array[3]-array[4]>=0&&array[3]+array[4]<=array[1]){
				System.out.println("Yes");
			}else{
				System.out.println("No");
			}
	}

}

Measured memory_bytes: 24472
#include <algorithm>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <string>

using namespace std;

int main() {
  long long A, B, C, K;
  cin >> A >> B >> C >> K;

  long long r = 0;
  long long an = min(K, A);
  r += an;

  long long bn = min(K - an, B);

  long long cn = min(K - an - bn, C);
  r -= cn;
  cout << to_string(r) << endl;
  
  return 0;
}
 


Measured memory_bytes: 3036
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
template <class T> void cumulative_sum( T array, size_t N );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;

ll* cost_array;

void dfs( vector <vector <pair <int, ll> > >& tree_matrix, int x, ll cost ){
	cost_array[ x ] = cost;
	if (cost == k_mod)
		cost = 0;
	for(auto p: tree_matrix[ x ]){
		if (cost_array[ p.first ] == 0)
			dfs( tree_matrix, p.first, cost + p.second );
	}
}

int main( void ){
	int N;
	cin >> N;
	vector <vector <pair <int, ll> > > tree_matrix( N + 2 );
	cost_array = new ll[ N + 2 ]();
	rep( i, 0, N - 1 ){
		int a, b, c;
		cin >> a >> b >> c;
		tree_matrix[ a - 1 ].push_back( make_pair( b - 1, c ));
		tree_matrix[ b - 1 ].push_back( make_pair( a - 1, c ));
	}
	int Q, K;
	cin >> Q >> K;
	dfs( tree_matrix,  K - 1, k_mod );
	rep( i, 0, Q ){
		int x, y;
		cin >> x >> y;
		cout << cost_array[ x - 1 ] + cost_array[ y - 1 ] << endl;
	}
}

int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
template <class T> void cumulative_sum( T array, size_t N ) {
	rep( i, 1, N + 1 ){
		array[ i ] += array[ i - 1 ];
	}
}
template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}


Measured memory_bytes: 14336
#include <algorithm>
#include <cstdint>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using namespace std;

using lint=int64_t;
using uint=uint32_t;
using ulint=uint64_t;

template<class T>
using vector2d=vector<vector<T>>;

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

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

template <class T>
void OutVec(const vector<T>& vec){
  for(int i = 0; i < vec.size() - 1; ++i){
    cout<<vec[i]<<" ";
  }
  cout<<vec.back()<<endl;
}

template <class T>
void OutVec2d(const vector2d<T>& vec){
  for(auto v:vec){
    OutVec(v);
  }
}

int main(){
  cout << std::fixed << std::setprecision(16);
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  int n;
  cin>>n;
  unordered_set<int> result;
  if(n==3){
    result.insert(2);
    result.insert(5);
    result.insert(63);
  }
  else if(n==4){
    result.insert(2);
    result.insert(5);
    result.insert(63);
    result.insert(20);
  }
  else if(n==5){
    result.insert(2);
    result.insert(5);
    result.insert(63);
    result.insert(20);
    result.insert(30);
  }
  if(n<=5){
    vector<int> res_vec;
    for(auto v:result){
      res_vec.push_back(v);
    }
    OutVec(res_vec);
    return 0;
  }

  int sum=0;

  int k=0;
  for(;;k++){
    result.insert(6*k+2);
    sum+=6*k+2;
    if(result.size()==n) break;
    result.insert(6*k+3);
    sum+=6*k+3;
    if(result.size()==n) break;
    result.insert(6*k+4);
    sum+=6*k+4;
    if(result.size()==n) break;
    result.insert(6*k+6);
    sum+=6*k+6;
    if(result.size()==n) break;

  }

  if(sum%6==2){
    result.erase(8);
    if(result.find(6*(k))==result.end()){
      result.insert(6*(k));
    }else
    if(result.find(6*(k+1))==result.end()){
      result.insert(6*(k+1));
    }else
    result.insert(6*(k+2));
  }else if(sum%6==3){
    result.erase(9);
    if(result.find(6*(k))==result.end()){
      result.insert(6*(k));
    }else
    if(result.find(6*(k+1))==result.end()){
      result.insert(6*(k+1));
    }else
    result.insert(6*(k+2));
  }else if(sum%6==5){
    result.erase(9);
    if(result.find(6*(k)+4)==result.end()){
      result.insert(6*(k)+4);
    }else
    if(result.find(6*(k+1))==result.end()){
      result.insert(6*(k+1)+4);
    }else
    result.insert(6*(k+2)+4);
  }
  vector<int> res_vec;
  for(auto v:result){
    if(v>30000) abort();
    res_vec.push_back(v);
  }
  OutVec(res_vec);
  return 0;


  return 0;
}



Measured memory_bytes: 2040
from sys import stdin
from functools import lru_cache


# 最小化問題
def chmin(a,b):
    if a > b: return b
    else: return a


@lru_cache(maxsize=1000)
def rec(i):
    if i==0:
        return 0
    else:
        res = float('inf')
        if i>0:
            res = chmin(res,rec(i-1)+abs(h_arr[i]-h_arr[i-1]))
        if i>1:
            res = chmin(res,rec(i-2)+abs(h_arr[i]-h_arr[i-2]))
        return res


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N = int(_in[0])  # type:int
    h_arr = [0] * (N+2)
    h_arr[0:N] = list(map(int,_in[1].split(' ')))  # type:list(int)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    # dp[i]:=カエルが足場iへと移動するのに必要な最小コスト
    dp = [float('inf')] * (N+2)  # 最小化問題
    dp[0] = 0                    # 初期条件
    
    # 貰うDP
    for i in range(0,N):
        dp[i] = chmin(dp[i],dp[i-1]+abs(h_arr[i]-h_arr[i-1]))
        if i > 1:
            dp[i] = chmin(dp[i],dp[i-2]+abs(h_arr[i]-h_arr[i-2]))
    cnt = dp[N-1]

    # 配るDP
    #for i in range(0,N):
    #    dp[i+1] = chmin(dp[i+1],dp[i]+abs(h_arr[i]-h_arr[i+1]))
    #    dp[i+2] = chmin(dp[i+2],dp[i]+abs(h_arr[i]-h_arr[i+2]))
    #cnt = dp[N-1]

    # メモ化再帰
    #cnt = rec(N-1)
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;

#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define pb push_back

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (int i = (b); i >= (a); i--)
#define R0F(i, a) ROF(i, 0, a-1)
#define trav(x, a) for (auto& x: a)

const int MX  = 2e5+5;
const int MOD = 1e9+7;
const ll  INF = 1061109567; // 4557430888798830399LL
const ld  EPS = 1e-9;
const ld  PI  = acos(-1);

int N,M,dp[MX];
vi adj[MX];

int solve_dp(int u) {
    int& res = dp[u];
    if (res != -1) return res;
    res = 0;
    trav(v,adj[u]) {
        res = max(res,solve_dp(v)+1);
    }
    return res;
}

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    cin >> N >> M;

    F0R(i,M) {
        int u,v; cin >> u >> v;
        --u,--v;
        adj[u].pb(v);
    }

    memset(dp,-1,sizeof dp);

    int res = 0;
    F0R(i,N) res = max(res,solve_dp(i));

    cout << res << "\n";
}


Measured memory_bytes: 10240
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
using ll = long long;


// 排他的論理和の加法の逆元は自分自身なので f(A,B) = f(0,A-1) ^ f(0,B)
// f(0,x) は2進xの1の位が1なら1の位だけ, 0なら1の位以外はそのまま
// 1の位はmod4で1か2なら1, 他は0
ll f(ll x){
    if(x % 4 == 0){
        return x;
    }else if(x % 4 == 1){
        return 1;
    }else if(x % 4 == 2){
        return x+1;
    }else{
        return 0;
    }
}

int main() {
    ll A,B;
    cin >> A >> B;
    ll ans = f(A-1)^f(B);
    cout << ans;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <sstream>

using namespace std;
vector<int> arr, tmp;
int cnt;

void print(vector<int>& arr) {
	int n = arr.size();
	for (int i = 0; i < n; ++i) {
		cout << arr[i];
		if (i != n - 1) cout << " ";
	}
	cout << endl;
}

void insert_sort(vector<int>& arr) {
	int n = arr.size();
	for (int i = 0; i < n; ++i) {
		for (int j = i; j > 0; --j) {
			if (arr[j - 1] > arr[j])
				swap(arr[j - 1], arr[j]);
		}
		print(arr);
	}
}

void bubble_sort(vector<int>& arr) {
	int n = arr.size();
	int cnt = 0;
	for (int i = 0; i < arr.size(); ++i) {
		for (int j = n - 1; j > i; --j) {
			if (arr[j] < arr[j - 1]) {
				swap(arr[j - 1], arr[j]);
				cnt++;
			}
		}
	}
	print(arr);
	cout << cnt << endl;
}

void select_sort(vector<int>& arr) {
	int n = arr.size();
	int cnt = 0;
	for (int i = 0; i < n; ++i) {
		int mi_idx = i;
		for (int j = i; j < n; ++j) {
			if (arr[j] < arr[mi_idx])
				mi_idx = j;
		}
		cnt += (i != mi_idx);
		swap(arr[i], arr[mi_idx]);
	}
	print(arr);
	cout << cnt << endl;
}

void merge(vector<int> &arr, int a, int b, int c) {
	for (int i = a; i <= c; ++i)
		tmp[i] = arr[i];

	int i = a;
	int j = b + 1;
	while (i <= b && j <= c) {
		cnt++;
		if (tmp[i] <= tmp[j]) arr[a++] = tmp[i++];
		else arr[a++] = tmp[j++];
	}
	while (i <= b) { arr[a++] = tmp[i++]; cnt++; };
	while (j <= c) { arr[a++] = tmp[j++]; cnt++; }
}

void merge_sort(vector<int>& arr, int l, int r) {
	if (l < r) {
		int mid = l + (r - l) / 2;
		merge_sort(arr, l, mid);
		merge_sort(arr, mid+1, r);
		merge(arr, l, mid, r);
	}
}

// hoare
// lumuto

int partition_lumuto(vector<int>& arr, int l, int r) {
	int i = -1;
	int j = 0;
	while (j <= r) {
		if (arr[j] <= arr[r])
			swap(arr[++i], arr[j]);
		++j;
	}
	return i;
}

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

	arr.assign(n, 0);
	tmp.assign(n, 0);
	cnt = 0;
	for (int i = 0; i < n; ++i)
		cin >> arr[i];
	int p = partition_lumuto(arr, 0, n - 1);
	for (int i = 0; i < n; ++i) {
		if (i == p) cout << "[";
			cout << arr[i];
		if (i == p) cout << "]";
		if (i != n-1) cout << " ";
	}
	cout << endl;

	return 0;
}



Measured memory_bytes: 3500
#include <stdio.h>
#include <stdlib.h>
#include "time.h"
#include "unistd.h"
#include "string.h"
#include <math.h>
int ans;
int i=0;
int main(int argc, char* argv[]){
  char a[7];
  scanf("%s",a);
  if (a[2]==a[3] && a[4]==a[5]) {
    printf("Yes");
  }else{
    printf("No");
  }
}


Measured memory_bytes: 128
let nl = readLine()!.split(separator: " ").map { Int($0)! }
let n = nl[0], m = nl[1]
let hn = readLine()!.split(separator: " ").map { Int($0)! }
var ab = [[Int]](repeating: [Int](), count: n)

for _ in 0..<m {
  let abj = readLine()!.split(separator: " ").map { Int($0)! }
  ab[abj[0] - 1] = ab[abj[0] - 1] + [abj[1]]
  ab[abj[1] - 1] = ab[abj[1] - 1] + [abj[0]]
}
var cn = 0
for i in 0..<n {
  if let max = ab[i].max(by: { hn[$0 - 1] < hn[$1 - 1] }) {
    if hn[max - 1] < hn[i] {
      cn += 1
    }
  } else {
    cn += 1
  }
}
print(cn)

Measured memory_bytes: 15824
#include<string>
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using ll = long long;

#define rep(i, n) for(ll i = 0; i < (int)(n); i++)
#define reps(i,x) for(ll i=1;i<=(int)(x);i++)
#define rrep(i,x) for(ll i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(ll i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define mp make_pair
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007 
using namespace std;
ll n, m;
string s;
ll in[100050][2];
ll sum[100050];

ll mx1[100050];
ll mx2[100050];
int main() {
	ll N, C, i, j;
	cin >> N >> C;
	for (i = 1; i <= N; i++) cin >> in[i][0] >> in[i][1];
	for (i = 1; i <= N; i++) sum[i] = sum[i - 1] + in[i][1];

	ll ans = 0;
	ans = max(ans, sum[N] - C);

	for (i = 1; i <= N; i++) mx1[i] = max(mx1[i - 1], sum[i] - 2 * in[i][0]);
	for (i = N; i >= 1; i--) mx2[i] = max(mx2[i + 1], (sum[N] - sum[i - 1]) - (C - in[i][0]));
	for (i = 0; i <= N; i++) ans = max(ans, mx1[i] + mx2[i + 1]);

	for (i = 1; i <= N; i++) mx1[i] = max(mx1[i - 1], sum[i] - in[i][0]);
	for (i = N; i >= 1; i--) mx2[i] = max(mx2[i + 1], (sum[N] - sum[i - 1]) - 2 * (C - in[i][0]));
	for (i = 0; i <= N; i++) ans = max(ans, mx1[i] + mx2[i + 1]);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4096
#include <cstdio>
#include <cstring>
using namespace std;

char s[20];

int main( )
{
	scanf( "%s", s+1 );
	if ( strlen( s+1 )<4 )
		printf( "No\n" );
	else
		if ( s[1]=='Y' && s[2]=='A' && s[3]=='K' && s[4]=='I' )
			printf( "Yes\n" );
		else
			printf( "No\n" );
	return 0;
}


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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using ll = long long;
using P = pair<ll,ll>;
using graph = vector<vector<int>>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll INF = 1LL<<60;
const ll mod = 1000000007LL;

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

int dp[3005][3005];
int subdp[3005][3005];

int main(){
    int N,T;
    cin>>N>>T;
    vector<vector<int>> v(N,vector<int>(2));
    rep(i,N) cin>>v[i][1]>>v[i][0];
    sort(v.begin(),v.end());
    rep(i,N){
        rep(j,T){
            chmax(dp[i+1][j],dp[i][j]);
            if(j+v[i][1]<T) chmax(dp[i+1][j+v[i][1]],dp[i][j]+v[i][0]);
        }
    }
    int time = T-1;
    vector<bool> use(N);
    int ans = 0;
    for(int i = N-1; i >= 0; i--){
        if(time>=v[i][1]){
            if(dp[i+1][time]==dp[i][time - v[i][1]] + v[i][0]){
                time -= v[i][1];
                use[i]=true;
                continue;
            }
        }
    }
    vector<vector<int>> nouse;
    rep(i,N){
        if(!use[i]) nouse.push_back({v[i][0],v[i][1]});
    }
    rep(i,N){
        rep(j,T){
            chmax(dp[i+1][j],dp[i][j]);
            if(j+v[i][1]<T) chmax(dp[i+1][j+v[i][1]],dp[i][j]+v[i][0]);
        }
    }
    int m = nouse.size();
    rep(i,m){
        rep(j,T){
            chmax(subdp[i+1][j],subdp[i][j]);
            if(j+nouse[i][1]<T) chmax(subdp[i+1][j+nouse[i][1]],subdp[i][j]+nouse[i][0]);
        }
    }
    vector<int> exceptmax(N);
    rep(i,N){
        if(use[i]) exceptmax[i] = dp[N][T-1]-v[i][0]+subdp[m][v[i][1]];
        else exceptmax[i] = dp[N][T-1];
    }
    rep(i,N) chmax(ans,exceptmax[i]+v[i][0]);
    cout<<ans<<endl;
}

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

int main(){
  int n;
  cin >>n;
  long long s=1;
  for (int i=1;i<=n;i++){
    s*=i;
    if(s>=(1000000000+7)){
      s=s%(1000000000+7);
    }
  }
  cout << s <<endl;
}


Measured memory_bytes: 3560
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define PI (acos(-1))

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e15;
const int INF=1e9;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int w,h,n;
	cin>>w>>h>>n;
	vector<vector<bool>> g(h,vector<bool>(w,true));
	rep(i,n){
		int x,y,a;
		cin>>x>>y>>a;
		if(a==1){
			rep(k,h)rep(j,x){
				g[k][j]=false;
			}
		}else if(a==2){
			rep(k,h)FOR(j,x,w){
				g[k][j]=false;
			}
		}else if(a==3){
			rep(j,w)rep(k,y){
				g[k][j]=false;
			}
		}else{
			rep(j,w+1)FOR(k,y,h){
				g[k][j]=false;
			}
		}
	}
	int ans=0;
	rep(i,h)rep(j,w){
		if(g[i][j]) ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<map>
#include<set>
#include<algorithm>
#include<cmath>
using namespace std;

int s[100005];

int main(){
	int n,m;
	memset(s,0,sizeof(s));
	scanf("%d %d",&n,&m);
	for(int i = 1;i <= m;i++){
		int a,b;
		scanf("%d %d",&a,&b);
		s[a]++;
		s[b]++;
	}
	for(int i = 1;i <= n;i++){
		if(s[i] % 2 != 0){
			printf("NO");
			return 0;
		}
	}
	printf("YES");
}

Measured memory_bytes: 512
n = int(input())
a = list(map(int, input().split()))
c = [0 for i in range(n)]

for i in range(n, n//2, -1):
  if a[i-1]:
    c[i-1] = 1
for i in range(n//2, 1, -1):
  t = i
  tt = 0
  cnt = 1
  while t<=n:
    tt += c[t-1]
    cnt += 1
    t = i*cnt
  if (a[i-1]==1 and tt%2==0) or (a[i-1]==0 and tt%2==1):
    c[i-1] = 1

ttt = sum(c)
if (ttt%2==0 and a[0]==1) or (ttt%2==1 and a[0]==0):
  c[0] = 1
  ttt += 1
#print(c)
ans = []
for i in range(n):
  if c[i]:
    ans.append(i+1)
print(ttt)
if ttt:
  print(*ans)

Measured memory_bytes: 71528
t = input()
while t:
    b = [map(int, raw_input().split()) for i in xrange(9)]
    for i in xrange(9):
        pnt = ""
        for j in xrange(9):
            error = False
            ix = j//3*3; iy = i//3*3
            for k in xrange(9):
                # tate
                if k!=i and b[k][j] == b[i][j]:
                    error = True
                    break
                # yoko
                if k!=j and b[i][k] == b[i][j]:
                    error = True
                    break
                # 3 kake 3
                y = iy + k/3; x = ix + k%3
                if (x != j or y != i) and b[y][x] == b[i][j]:
                    error = True
                    break

            pnt += "*%d"%b[i][j] if error else " %d"%b[i][j]
        print pnt
    if t>1:
        print
    t -= 1

Measured memory_bytes: 4260
#include<algorithm>
#include<iostream>
#include<cstring>
#include<iomanip>
#include<sstream>
#include<cstdio>
#include<string>
#include<vector>
#include<bitset>
#include<queue>
#include<cmath>
#include<stack>
#include<set>
#include<map>
#define rep(i,x,n) for(int i=x;i<=n;i++)
#define per(i,n,x) for(int i=n;i>=x;i--)
#define sz(a) int(a.size())
#define rson mid+1,r,p<<1|1
#define pii pair<int,int>
#define lson l,mid,p<<1
#define ll long long
#define pb push_back
#define mp make_pair
#define se second
#define fi first
using namespace std;
const double eps=1e-8;
const int mod=1e9+7;
const int N=1e5+10;
const int inf=1e9;
char s[N];
int n;
int main(){
    //ios::sync_with_stdio(false);
    //freopen("in","r",stdin);
    scanf("%s",s);
    n=strlen(s);
    int x=0,y=0;
    for(int i=0;i<n;i++){
        if(i%2!=s[i]-'0') x++;
        else y++;
    }
    cout<<min(x,y)<<endl;
    return 0;
}

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

int main(void){
    int a,b;
    while(cin>>a>>b){
        a+=b;
        b=1;
        for(int i=1; i<=7; i++){
            b*=10;
            if(a<b){
                cout<<i<<endl;
                break;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
"""
https://atcoder.jp/contests/dp/tasks/dp_a

"""
import sys
from sys import stdin
input = stdin.readline


def solve(N, ashiba):
    dp = [0] * N
    for i in range(1, N):
        dp[i] = min(dp[i-1] + abs(ashiba[i] - ashiba[i-1]), dp[i-2] + abs(ashiba[i] - ashiba[max(i-2, 0)]))
    return dp[-1]


def main(args):
    N = int(input())
    ashiba = [int(a) for a in input().split()]
    ans = solve(N, ashiba)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 14000
from sys import stdin
 
n,m,c = map(int, input().split())
b = list(map(int, input().split()))

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

Measured memory_bytes: 9192
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(sc.hasNext()){
			String[] c000 = new String[]{"'","?","W",","};
			String[] c10010 = new String[]{"Z","-","X","Y"};
			String[] c10011 = new String[]{"J","M","B","G","U","V","N","Q"};
			
			String s = sc.nextLine();
			StringBuffer stn = new StringBuffer();
			StringBuffer ans = new StringBuffer();
			String t, u, v, w;
			int p;
			
			for(int i=0;i<s.length();i++){
				p = s.codePointAt(i);
				if(p==32) stn.append("11010");
				else if(p==46) stn.append("11011");
				else if(p==44) stn.append("11100");
				else if(p==45) stn.append("11101");
				else if(p==39) stn.append("11110");
				else if(p==63) stn.append("11111");
				else{
					t = Integer.toBinaryString(p-65);
					for(int j=0;j<5-t.length();j++) stn = stn.append("0");
					stn.append(t);
				}
			}
			
			for(int i=0;i<stn.length()-2;i++){
				while(true){
					p = ans.length();
					t = stn.substring(i,i+3);
					if(t.compareTo("101")==0) ans.append(" ");
					else if(t.compareTo("110")==0) ans.append("E");
					else if(t.compareTo("111")==0) ans.append("P");
					if(p<ans.length() || i+3==stn.length()){
						i+=2;
						break;
					}
	
					u = stn.substring(i,i+4);
					if(u.compareTo("0001")==0) ans.append("D");
					else if(u.compareTo("0101")==0) ans.append("C");
					else if(u.compareTo("0110")==0) ans.append("K");
					else if(u.compareTo("0111")==0) ans.append("I");
					else if(u.compareTo("1000")==0) ans.append("R");
					if(p<ans.length() || i+4==stn.length()){
						i+=3;
						break;
					}
					
					v = stn.substring(i,i+5);
					if(v.compareTo("01001")==0) ans.append("F");
					else if(v.compareTo("00100")==0) ans.append("L");
					else if(v.compareTo("00101")==0) ans.append("O");
					else if(v.compareTo("00110")==0) ans.append("S");
					else if(v.compareTo("00111")==0) ans.append("T");
					if(p<ans.length() || i+5==stn.length()){
						i+=4;
						break;
					}
					
					w = stn.substring(i,i+6);
					if(t.compareTo("000")==0) ans.append(c000[(stn.codePointAt(i+4)-48)*2 + (stn.codePointAt(i+5)-48)]);
					else if(w.compareTo("010000")==0) ans.append("H");
					else if(w.compareTo("010001")==0) ans.append(".");	
					else if(w.compareTo("100101")==0) ans.append("A");	
					if(p<ans.length() || i+7==stn.length()){
						i+=5;
						break;
					}
					
					if(v.compareTo("10010")==0) ans.append(c10010[(stn.codePointAt(i+6)-48)*2 + (stn.codePointAt(i+7)-48)]);
					else if(v.compareTo("10011")==0) ans.append(c10011[(stn.codePointAt(i+5)-48)*4 + (stn.codePointAt(i+6)-48)*2 + (stn.codePointAt(i+7)-48)]);
					i+=7;
					break;
				}		
			}
			System.out.println(ans);
		}
	}	
}

Measured memory_bytes: 26192
import scala.math._
import scala.collection.mutable.ListBuffer

object Main {
  //rt.gc()??§??¬??????????????¬?????????????????????
  //val rt = Runtime.getRuntime()
  val sc = new java.util.Scanner(System.in)
  def solve(sai: Iterator[Int], mas:Array[Int], p: Int): Int = {
    if(p < mas.size - 1) {
      val s = sai.next()
      if(p+s < mas.size-1) {
        1 + solve(sai, mas, p+s+mas(p+s))
      } else {
        1
      }
    } else {
      0
    }
  } 
  def main(args: Array[String]) {
    while(true) {
      val n,m = sc.nextInt
      if((n,m) == (0,0)) {
        return
      }

      val masu = (1 to n).map(_ => sc.nextInt()).toArray
      var p = 0
      val sai = (1 to m).map(_ => sc.nextInt()).toIterator
      println(solve(sai, masu, 0))
    }
  }
}

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

int main() {
  int X, A, B;
  cin >> X;

  A = X / 500;
  B = (X % 500) / 5;
  
  int ans;
  ans = A * 1000 + B * 5;
  
  cout << ans << endl;
}


Measured memory_bytes: 256
void main() {
	auto ip = readAs!(ulong[]), N = ip[0], M = ip[1];
	auto A = readAs!(ulong[]);
	alias Pair = Tuple!(ulong, "B", ulong, "C");
	Pair[] pairs = A.sort().group.map!(v => Pair(v[1], v[0])).array;
	foreach(_; 0..M) {
		auto ip2 = readAs!(ulong[]), B = ip2[0], C = ip2[1];
		pairs ~= Pair(B, C);
	}
	pairs.sort!((a, b) => a.C > b.C)();
	ulong res;
	ulong cnt;
	foreach(p; pairs) {
		if(p.B > N - cnt) {
			res += (N - cnt) * p.C;
			break;
		} else {
			cnt += p.B;
			res += p.C * p.B;
		}
	}
	res.writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(15);

  int n;
  cin >> n;
  vector<int> h(n);
  for (int i = 0; i < n; ++i) {
    cin >> h[i];
  }

  int ans = 0, cnt = 0;
  for (int i = 1; i < n; ++i) {
    // cerr << h[i] << " ";
    if (h[i - 1] >= h[i]) {
      ++cnt;
    } else {
      cnt = 0;
    }
    ans = max(ans, cnt);
    // cerr << cnt << '\n';
  }

  cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 3708