akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <list>
#include <queue>
#include <cmath>
#include <numeric>
using namespace std;

int inf = (1 << 30);
int mod = 1e9 + 7;
int64_t inf64 = (1LL << 60);

template <typename T>
T gcd(T a, T b) {
    if(b == 0) return a;
    else return gcd(b, a % b);
}

template <typename T>
T lcm(T a, T b) {
    T g = gcd(a, b);
    return a / g * b;
}

bool check(vector<int> a, int index, int key){
    if(a[index] >= key) return true;
    else return false;
}

int lower_bound(vector<int> a, int key){
    int left = -1, right = a.size();
    while(right - left > 1){
        int mid = left + (left + right) / 2;
        if(check(a, mid, key)) right = mid;
        else left = mid;
    }
    return right;
}

int main(){

    int H, W;
    cin >> H >> W;
    vector<string> S(H);
    for(int i = 0; i < H; i++) cin >> S[i];

    // 横方向の処理
    vector<vector<int>> sum_h(H, vector<int>(W));
    for(int h = 0; h < H; h++){
        int sum = 1;
        for(int w = 0; w < W; w++){
            if(S[h][w] == '.'){
                sum_h[h][w] = sum;
                sum++;
            }else{
                sum_h[h][w] = 0;
                sum = 1;
            }
        }

        int val = 0;
        for(int w = W - 1; w >= 0; w--){
            if(sum_h[h][w] == 0){
                val = 0;
            }else{
                val = max(val, sum_h[h][w]);
                sum_h[h][w] = val;
            }
        }
    }

    // 縦方向の処理
    vector<vector<int>> sum_v(H, vector<int>(W));
    for(int w = 0; w < W; w++){
        int sum = 1;
        for(int h = 0; h < H; h++){
            if(S[h][w] == '.'){
                sum_v[h][w] = sum;
                sum++;
            }else{
                sum_v[h][w] = 0;
                sum = 1;
            }
        }

        int val = 0;
        for(int h = H - 1; h >= 0; h--){
            if(sum_h[h][w] == 0){
                val = 0;
            }else{
                val = max(val, sum_v[h][w]);
                sum_v[h][w] = val;
            }
        }
    }

    int ans = 0;
    for(int h = 0; h < H; h++){
        for(int w = 0; w < W; w++){
            ans = max(ans, sum_h[h][w] + sum_v[h][w] - 1);
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 35712
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)

int N,K;
char S[64];

int main() {

	scanf("%d%d%s", &N,&K,S);

	S[K - 1] -= 'A' - 'a';


	printf("%s\n", S);

	return 0;
}


Measured memory_bytes: 256
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn is_prime(n: u64) -> bool {
    let m = (n as f64).sqrt() as u64;

    for i in 2..m + 1 {
        if n % i == 0 {
            return false;
        }
    }
    true
}

fn main() {
    let mut x: u64 = read();

    loop {
        if is_prime(x) {
            println!("{}", x);
            break;
        }
        x += 1;
    }
}


Measured memory_bytes: 4352
def main():
    N = int(input())
    A = list(map(int,input().split()))
    for a in A:
        if a % 2 == 0:
            if a % 3 == 0 or a % 5 == 0:
                continue
            else:
                print("DENIED")
                exit()
    print("APPROVED")

if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<typeinfo>
#include<functional>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;



    
int main(){
    ll n,m;
    cin>>n>>m;
    vector<ll> a;
    for(int i=1;i*i<=m;i++){
        if(m%i==0){a.push_back(i); a.push_back(m/i);}
    }
    sort(a.begin(),a.end(),greater<ll>());
    for(int i=0;i<a.size();i++){
        if(m/a[i]>=n){cout<<a[i]<<endl; return 0;}
    }
    
    assert(false);
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main(){
    
    ll N, K;
    cin >> N >> K;
    ll v[55];
    for(ll i = 1; i <= N; i++)cin >> v[i];
    ll ans = 0;
    ll dp[55][55][105];
    for(ll i = 0; i < 55; i++){
        for(ll j = 0; j < 55; j++){
            for(ll k = 0; k < 105; k++){
                dp[i][j][k] = -1000000000LL;
            }
        }
    }
    dp[0][N + 1][0] = 0;
    for(ll d = N + 1; d >= 1; d--){
        for(ll l = 0; l + d <= N + 1; l++){
            ll r = l + d;
            for(ll k = 0; k <= K; k++){
                ans = max(ans, dp[l][r][k]);
                dp[l + 1][r][k + 1] = max(dp[l + 1][r][k + 1], dp[l][r][k] + v[l + 1]);
                dp[l + 1][r][k + 2] = max(dp[l + 1][r][k + 2], dp[l][r][k]);
                dp[l][r - 1][k + 1] = max(dp[l][r - 1][k + 1], dp[l][r][k] + v[r - 1]);
                dp[l][r - 1][k + 2] = max(dp[l][r - 2][k + 2], dp[l][r][k]);
            }
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii=pair<int,int>;
#define all(c) begin(c),end(c)
#define rall(c) rbegin(c),rend(c)
#define fore(x,c) for(auto &&x:c)
#define rep(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define rrep(i,n) for(int i=(int)(n);i>=0;--i)
#define sz(c) ((int)c.size())
#define contains(c,x) (c.find(x)!=end(c))
#define inseg(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(0);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------
 
signed main() {
    int a, b;
    cin >> a >> b;
    int res = max(a,b) * 2;
    res -= a==b ? 0 : 1;
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
 
class Main {
    public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();

         if(a<b){
            System.out.println("a < b");
        }
         else if(a > b){
             System.out.println("a > b");
         }
        else if(a==b){
            System.out.println("a == b");
        }
        }
    }


Measured memory_bytes: 26212
#include<iostream>

int main() {
	double X;
	std::cin >> X;

	double okane = 100;
	int nen = 0;

	while (true) {
		okane += okane * 0.01;
		okane = floor(okane);
		nen++;
		if (okane >= X) {
			break;
		}
	}
	std::cout << nen << std::endl;
}

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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const double EPS = 1e-10;

int main() {
    string S, T;
    cin >> S >> T;

    lint mi = LINF;
    for (int i = 0; i < S.size(); i++) {
        string sub = S.substr(i, T.size());
        if (sub.size() != T.size()) continue;
        lint cnt = 0;
        for (int j = 0; j < T.size(); j++) {
            if (T[j] != sub[j]) cnt++;
        }
        mi = min(mi, cnt);
        // d(sub);
        // d(cnt);
    }
    cout << mi << endl;
    return 0;
}

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

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
//#define int long long

using namespace std;

// conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

#define dump(x)  cout << #x << " = " << (x) << endl
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

typedef long long ll;

const ll MOD = 1e9 + 7;

class BVotingJudges {
public:
	void solve(std::istream& in, std::ostream& out) {
	    ll N, M, V, P;
	    in >> N >> M >> V >> P;
	    vector<ll> A(N);
	    REP(i,0,N) in >> A[i];
	    sort(all(A), greater<ll>());
        ll minumumScore;
	    if (V <= P) {
            minumumScore = A[P-1];
	    } else {
	        ll left = 0, right = A[P-1]+M;
	        int cnt = 0;
	        while (right - left > 1) {
	            ll middle = (right + left + 1) / 2;
	            ll size = 0;
	            REP(i,P-1,N) {
	                if (middle >= A[i]) {
	                    size += min(M, middle - A[i]);
	                }
	            }
//                debug(right);
//                debug(left);
//                debug(middle);
//                debug((V - P) * M);
//	            debug(size);
	            if (size >= (V - (P - 1)) * M) {
	                right = middle;
	            } else {
	                left = middle;
	            }
	        }
	        minumumScore = max(right, A[P-1]);
	    }
//	    debug(minumumScore);
	    int answer = 0;
	    REP(i,0,N) {
	        if (minumumScore <= A[i] + M) {
	            answer++;
	        }
	    }
	    out << answer << "\n";
	}
};


signed main() {
	BVotingJudges solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 1024
#![allow(unused_imports)]

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

use std::{i32, i64, u32, u64, usize, f64};
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::io::{stdout, Write, BufWriter};
use std::mem::{swap};

fn main() {
    input! {
        s: i64,
        c: i64,
    }
    println!("{}", min(s, c/2) + max(0, (c - 2*s)/4));
}


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

int main(void){
    string S, T;
    cin >> S >> T;
    int A, B;
    cin >> A >> B;
    string U;
    cin >> U;
    if(S==U){
        cout << A-1 << " " << B << endl;
    }else{
        cout << A << " " << B-1 << endl;
    }
    return 0;
}

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

int descending_compare(const void *a, const void *b){
    if (*(int*)a > *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}

int ascending_compare(const void *a, const void *b){
    if (*(int*)a < *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}

// array pointer = *a, num of element = n, key key
int lower_bound(int *a, int n, int key){
    int ng, mid, ok;
    ng = -1, ok = n-1;
    while (abs(ok - ng) > 1){
        mid = (ok + ng) / 2;
        if (key <= a[mid]){
            ok = mid;
        }else{
            ng = mid;
        }
    }
    if (a[ok] >= key)return ok;
    return n;
}

//greatest common divisor
unsigned long gcd(unsigned long x, unsigned long y){
    if (y == 0){ 
        return x;
    }else if (x > y){
        return gcd(y, x % y);
    }else{
        return gcd(x, y % x);
    }
}

unsigned long lcm(unsigned long x, unsigned long y){
    unsigned long g = gcd(x, y);
    return x*y/g;

}



long long factorial(int x){
    long long rtn = 1;
    int i;
    for (i = x; i > 1; i--){
        rtn = (rtn*i);
    }
    return rtn;
}

/*
int struct_ascending_compare(const void *p, const void *q) {
return ((struct_name*)p)->member_name - ((struct_name*)q)->member_name;
}*/

/*unsigned long long pascal[100][100] = {0};
void make_pascal(void){
    for (int i = 0; i < 100; i++){
        pascal[i][0] = 1;
    }
    pascal[1][1] = 1;
    for (int i = 2; i < 100; i++){
        for (int j = 1; j < 100; j++){
           pascal[i][j] = (pascal[i-1][j-1]+pascal[i-1][j]) % mod;
        }
    }
}*/
long long mod = 1000000007;

//x ^ n
long long mod_pow(long long x, long long n){
    long long res = 1;
    for(int i = 0;i < 60; i++){
        if(n >> i & 1) res = res * x % mod;
        x = x * x % mod;
    }
    return res;
}

char s[100005];

int main(void){
    scanf("%s", s);
    int len = strlen(s);
    if (len == 2){
        if (s[0] == s[1]){
            printf("1 2\n");
        }else{
            printf("-1 -1\n");
        }
        return 0;
    }
    for (int i = 1; i < len-1; i++){
        for (int j = i-1; j <= i+1; j++){
            if ((i != j && s[i] == s[j]) || s[i-1] == s[i+1]) {
                printf("%d %d\n", i, i+2);
                return 0;
            }
        }
    }

    printf("-1 -1\n");
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

	int A, B;
	A = sc.nextInt();
	B = sc.nextInt();

	int count = A - B * 2;
	if (count > 0)
	    System.out.println(count);
	else
	    System.out.println(0);
    }
}

Measured memory_bytes: 21844
#! python3
# dice_iv.py

class dice():
    def __init__(self, arr):
        self.top = arr[0]
        self.south = arr[1]
        self.east = arr[2]
        self.west = arr[3]
        self.north = arr[4]
        self.bottom = arr[5]

    def rotate(self, ope):
        if ope == 'S':
            self.top, self.north, self.bottom, self.south = self.north, self.bottom, self.south, self.top
        elif ope == 'N':
            self.top, self.south, self.bottom, self.north = self.south, self.bottom, self.north, self.top
        elif ope == 'E':
            self.top, self.west, self.bottom, self.east = self.west, self.bottom, self.east, self.top
        elif ope == 'W':
            self.top, self.east, self.bottom, self.west = self.east, self.bottom, self.west, self.top
        elif ope == 'R': # clockwise
            self.south, self.east, self.north, self.west = self.east, self.north, self.west, self.south
        elif ope == 'L': # reversed clockwise
            self.south, self.east, self.north, self.west = self.west, self.north, self.east, self.south
        else:
            pass

    def get_surfaces(self):
        return [self.top, self.south, self.east, self.north, self.west, self.bottom]

def is_same_dice(dc1, dc2):
    judged = False
    if len((dc1.get_surfaces() and dc2.get_surfaces())) == 6:
        opes = ['', 'S', 'E', 'S', 'E', 'S']
        for op in opes:
            dc2.rotate(op)
            for i in range(4):
                if dc1.get_surfaces() == dc2.get_surfaces():
                    judged = True
                    break
                dc2.rotate('R')
            if judged: break
    return judged

n = int(input())
dices = [dice([int(x) for x in input().split(' ')]) for i in range(n)]

judged = True
for i in range(n-1):
    for j in range(i+1, n):
        if is_same_dice(dices[i], dices[j]):
            judged = False

if judged:
    print('Yes')
else:
    print('No')


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

int main() {
  string S;
  cin >> S;
  int ans = 0, num = 0;
  for(int i = 0; i < S.size(); i++){
      for(int j = 1; j <=S.size()-i;j++){
          num = 0;
          for(int k = i; k < i+j; k++){
              //cout << S[k];
              if(S[k] == 'A' || S[k] == 'C' || S[k] == 'G' || S[k] == 'T'){
                  num++;
              }else{
                  break;
              }
          }
          ans = max(ans,num);
          //cout << endl;
      }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>

struct Node {
	int id;
	std::vector<int> edge_to;
	std::vector<int> edge_cost;
	bool done;
	int cost;
};

int min(int x, int y)
{
	return x>y ? y : x;
}

void insert(Node* nodes, std::vector<int>& q, int t)
{
	std::vector<int>::iterator it = q.begin();
	for (; it != q.end(); ++it) {
		if (nodes[*it].id == nodes[t].id) return;
		if (nodes[*it].cost > nodes[t].cost) break;
	}
	q.insert(it, t);
}

int main()
{
	int n; std::cin >> n;
	
	Node* nodes = new Node[n];
	
	for (int i=0; i<n; i++) {
		nodes[i].done = false;
		nodes[i].cost = INT_MAX;
	}
	
	for (int i=0; i<n; i++) {
		int id, deg;
		std::cin >> id >> deg;
		nodes[i].id = id;
		for (int j=0; j<deg; j++) {
			int t, cost;
			std::cin >> t >> cost;
			nodes[i].edge_to.push_back(t);
			nodes[i].edge_cost.push_back(cost);
		}
	}
	
	std::vector<int> que;
	que.push_back(0);
	nodes[0].cost = 0;
	
	while (!que.empty()) {
		int s = que[0]; que.erase(que.begin());
		nodes[s].done = true;
		for (int k=0; k<nodes[s].edge_to.size(); k++) {
			int t = nodes[s].edge_to[k];
			int cost = nodes[s].edge_cost[k];
			if (nodes[t].done) continue;
			nodes[t].cost = min(nodes[t].cost, nodes[s].cost + cost);
			insert(nodes, que, t);
		}
	}
	
	for (int i=0; i<n; i++) {
		std::cout << nodes[i].id << " " << nodes[i].cost << std::endl;
	}
	
	delete[] nodes;
	
	return 0;
}



Measured memory_bytes: 3160
S = ['0'] + list(input())

ans_lst = [0] * (len(S) + 10)
ans_lst[0] = 0
ans_lst[1] = 1
ans_lst[2] = 1 if S[2] == S[1] else 2

for i in range(3, len(S)):
    if S[i] == S[i - 1]:
        ans_lst[i] = max(ans_lst[i], ans_lst[i - 3] + 2)
    else:
        ans_lst[i] = max(ans_lst[i], ans_lst[i - 1] + 1)

print (ans_lst[len(S) - 1])

Measured memory_bytes: 12424
#include <bits/stdc++.h>
#define F first
#define S second
#define $ ios::sync_with_stdio(0);
#define endl '\n'
using namespace std;
using ll = long long int;
using ii = pair<ll, ll>;
using vi = vector<int>;
using vii = vector<ii>;
using graph = vector<vi>;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3f;
const int MAXN = 212345;
const ll mod = 1000000007;
ll fat[MAXN], inv[MAXN];
ll bxp(ll base, int xp) {
    ll ans = 1;
    while (xp) {
        if (xp&1) ans = ans * base % mod;
        base = base * base % mod;
        xp >>=1;
    }
    return ans;
}
ll sol(int x, int y, int a, int b) {
    ll n = a-x + b-y; //linha
    ll k = a-x; // coluna
    ll ans = fat[n] * inv[n-k] % mod;
    ans = ans * inv[k] % mod; 
    return ans;
}
int main() {
    int h, w, a, b;
    scanf("%d %d %d %d", &h, &w, &a, &b);
    fat[0] = 1, inv[0] = 1;
    fat[1] = 1, inv[1] = 1;
    
    for (ll i = 2, j = h+w+2; i<=j; ++i) {
        fat[i] = i*fat[i-1] % mod;
        inv[i] = bxp(fat[i], mod-2);
    }
    int i = 0, j = 1;
    ll ans = 0;
    while (h-a-i >= 1 && b+j<=w) {
        //printf("%d %d\n", h-a-i, b+j);
        ans += (sol(1, 1, h-a-i, b+j) * sol(h-a-i, b+j, h, w) % mod);
        if (ans >= mod) ans -= mod;
        ++i, ++j;
    }
    printf("%lld\n", ans);
}


Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>

using namespace std;

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

	int ans = 1;

	for (int b = 2; b * b <= X; ++b) {
		for (int y = b; y <= X; y *= b) {
			ans = max(ans, y);
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void){
    int n,pm,pe,pj;
    while(cin >> n){
        for(int i=0; i<n; i++){
            cin >> pm >> pe >> pj;
            if(pm==100 || pe==100 || pj ==100)                              cout << "A" << endl;
            else if((pm + pe) / 2 >= 90)                                    cout << "A" << endl;
            else if((pm + pe + pj) / 3 >= 80)                               cout << "A" << endl;
            else if((pm + pe + pj) / 3 >= 70)                               cout << "B" << endl;
            else if((pm + pe + pj) / 3 >= 50 && (pm >= 80) || (pe >= 80))   cout << "B" << endl;
            else                                                            cout << "C" << endl;
        }
    }
}


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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// テーブルを作る前処理
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int N = 1234567;
 
int a[N], pr[N], ne[N], pos[N];

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", a + i);
    pos[a[i]] = i;
  }
  for (int i = 0; i <= n + 1; i++) {
    pr[i] = i - 1;
    ne[i] = i + 1;
  }
  long long ans = 0;
  for (int i = n; i >= 1; i--) {
    int j = pos[i];
    ans += i * 1LL * (j - pr[j]) * (ne[j] - j);
    pr[ne[j]] = pr[j];
    ne[pr[j]] = ne[j];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

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

    lint a, b, c;

    for (lint i = 1; i <= 3500; i++) {
        for (lint j = 1; j <= 3500; j++) {
            lint p = (n * i * j);
            lint q = (4 * i * j - n * i - n * j);
            if (q == 0) continue;
            if (p % q == 0 && p / q > 0) {
                a = i;
                b = j;
                c = p / q;
                printf("%lld %lld %lld\n", a, b, c);
                exit(0);
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define long long long 

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update> pref_trie;
typedef tree<long int,null_type,less<long int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef cc_hash_table<long int,long int, hash<long int>, equal_to<long int>, direct_mask_range_hashing<long int>, 
hash_standard_resize_policy<hash_exponential_size_policy<>, hash_load_check_resize_trigger<true>, true>> ht;


int main(){
   IOS;
 /*    #ifndef ONLINE_JUDGE
         freopen("in.txt",  "r",  stdin);
         freopen("out.txt", "w", stdout);
     #endif */
   
   string s;
   cin>>s;

   if(s == "ABC")
    cout<<"ARC";
  else
    cout<<"ABC";
   return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <map>

using namespace std;

template <class T> T gcd(T a, T b)
{
  if (a < b) {
    T tmp;
    tmp = a; a = b; b = tmp;
  }
  while (b != 0) {
    T r = a % b, q = a / b;
    a = b; b = r;
  }
  return a;
}

template <class T> map<T, int> prime_factor(T n)
{
  map<T, int> ret;
  for (T i = 2; i*i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1) ret[n] = 1;
  return ret;
}

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

  int64_t g = gcd<int64_t>(a, b);
  map<int64_t, int> p = prime_factor<int64_t>(g);

  cout << p.size() + 1 << endl;
  return 0;
}


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

ll comb2(int x) {
    if(x<2) return 0;
    return x*(x-1)/2;
}

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

    const int mod = 2019;

    // 累積(iの位まで見たときに2019で割ったあまり)
    int S[200005];
    int ten = 1;
    S[0];
    for (int i=1; i<=s.size(); i++) {
        int x = (s[s.size()-i] - '0')*ten;
        S[i] = x + S[i-1];
        S[i] %= mod;
        ten *= 10;
        ten %=mod;        
    }

    int M[2019]; // 2019で割ったあまりの数
    rep(i,2019) M[i] = 0;
    for (int i=0; i<=s.size(); i++) {
        M[S[i]]++;
    }

    ll ans = 0;
    rep(i,2019) ans += comb2(M[i]);

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 4416
#pragma GCC optimize "-Ofast"
#include <bits/stdc++.h>

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long long llong;
typedef long double ld;

using namespace std;

template <typename T> void dprint(T begin, T end) {
    for (auto i = begin; i != end; i++) {
        cerr << (*i) << " ";
    }
    cerr << "\n";
}
const ll MOD = 1e9 + 7;

int n, m;
ll ans;

vector<int> eds[16];
int a[16];

int pp[16];
int pw[16];

void run(int x, ll now) {
    if (x == 1) {
        int cnt1[16];
        int cnt2[16];
        memset(cnt1, 0, sizeof(cnt1));
        for (int u: eds[0])
            ++cnt1[a[u]];
        memset(cnt2, 0, sizeof(cnt2));
        for (int u: eds[1])
            ++cnt2[a[u]];
        int g = eds[0].size() + eds[1].size();
        ll cur = now;
        for (int i = 0; cur != 0; ++i) {
            g -= cnt1[i] + cnt2[i];
            ans = (ans + cur * (1 << g)) % MOD;
            cur = (cur * ((1 << cnt1[i]) - 1)) % MOD;
            cur = (cur * ((1 << cnt2[i]) - 1)) % MOD;
        }
        return;
    }
    int cnt[16];
    memset(cnt, 0, sizeof(cnt));
    for (int u: eds[x])
        ++cnt[a[u]];
    int g = eds[x].size();
    ll cur = now;
    for (int i = 0; cur != 0; ++i) {
        g -= cnt[i];
        a[x] = i;
        run(x - 1, (cur * pw[g]) % MOD);
        cur = (cur * pp[cnt[i]]) % MOD;
    }
}

int main() {
    for (int i = 0; i < 16; ++i)
        pw[i] = (1 << i);
    for (int i = 0; i < 16; ++i)
        pp[i] = pw[i] - 1;
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        if (a != 0 || b != 1)
            eds[a].push_back(b);
    }
    run(n - 1, 1);
    ll ans2 = 1;
    for (int i = 0; i < m; ++i)
        ans2 = (ans2 * 2) % MOD;
    ans2 -= ans;
    if (ans2 < 0)
        ans2 += MOD;
    cout << ans2 << "\n";
    return 0;
}




Measured memory_bytes: 384
#include <bits/stdc++.h>
typedef long long ll; 
const ll mod = 1e9+7;
#define fo(i, n) for (int i = 0; i < n; i++)
#define sc(n) scanf("%d", &n) 
using namespace std;

string s;

void solve() {
    cin >> s;
    if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3]) cout << "Bad";
    else cout << "Good";

}

int main() {
    int t = 1;
    //scanf("%d", &t);
    while (t--) {
        solve();
    }
    return 0;
}

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

char pic[200200];

main()
{
	int n,a,b,c,d;
	scanf("%d %d %d %d %d",&n,&a,&b,&c,&d);
	scanf("%s",pic+1);
	if((d<c&&a<b)||(c<d&&b<a))
	{
		int free=0,mf=0;
		if(pic[max(a,b)+1]!='#')
		{
			free++;
		}
		for(int i=max(a,b)-1;i>min(a,b);i--)
		{
			if(pic[i]=='.')
			{
				free++;
			}
			else
			{
				break;
			}
		}
		mf=max(mf,free);
		for(int i=max(a,b)+1;i<=min(c,d)+1;i++)
		{
			if(pic[i]=='.')
			{
				free++;
			}
			else
			{
				free=0;
			}
			mf=max(mf,free);
		}
		if(mf<3)
		{
			printf("No");
			return 0;
		}
	}
	for(int i=min(a,b);i<max(c,d);i++)
	{
		if(pic[i]=='#')
		{
			if(pic[i-1]=='#')
			{
				printf("No");
				return 0;
			}
		}
	}
	printf("Yes");
}

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

int main(){
    int n;
    string s;
    cin>>n>>s;
    
    
    
    int cnt=0;
    
    // for (int i=0;i<n+3;i++){
    //     cin>>s.at(i);
    // }
    for (int i=0;i<n-2;i++){
        if(s.substr(i,3)=="ABC"){
            cnt++;
        }
    }
    cout<<cnt<<endl;
    
    return 0;
}


Measured memory_bytes: 3588
/*
  The Balance of the World
  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1173&lang=jp
*/

#include <iostream>
#include <string>
#include <vector>

using namespace std;


int main(void){
  while(1){
    string s;
    vector<char> v;
    getline(cin, s);
    if(s[0] == '.') break;

    int ptr = 0;
    bool correct = true;
    while(correct && ptr < s.length()){
      switch( s[ptr] ){
        case '(' :
          v.push_back('(');
          ptr++;
          break;
        case '[' :
          v.push_back('[');
          ptr++;
          break;
        case ')' :
          if( !v.empty() && v.back() == '('){
            v.pop_back();
            ptr++;
          }else{
            correct = false;
          }
          break;
        case ']' :
          if( !v.empty() && v.back() == '['){
            v.pop_back();
            ptr++;
          }else{
            correct = false;
          }
          break;
        default:
          ptr++;
          break;
      }
    }

    if(v.empty() && correct){
      cout << "yes" << endl;
    }else{
      cout << "no"  << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 3124
#include<stdio.h>
#include<string.h>
#include<math.h>
#include <stdlib.h>
#include<ctype.h>

//qsort
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

//比較
int max(int a, int b){
	if (a>b) return a;
	else return b;
}

int min(int a,int b) {
	if(a>b) return b;
	else return a;
}


//main関数
int main() {
	int x;
	for(int i=1;i<=5;i++){
		scanf("%d",&x);
		if(x == 0) {
			printf("%d",i);
			return 0;
		}
	}
}



Measured memory_bytes: 1728
#include<bits/stdc++.h>
using namespace std;
int dp[100005];
int n,arr[100005];
int func(int i)
{
    int ans1=0,ans2=0;
    if(i<=0) return 0;
    if(dp[i]!=-1) return dp[i];
    ans1 = abs(arr[i]-arr[i-1])+func(i-1);
    if(i>=2) ans2=abs(arr[i]-arr[i-2])+func(i-2);
    else ans2=123456;
    return dp[i]=min(ans1,ans2);
}
int main()
{
    int i;
    cin>>n;

    for(i=0;i<n;i++) cin>>arr[i];
    memset(dp,-1,sizeof dp);
    int ans = func(n-1);
    cout<<ans;
}


Measured memory_bytes: 4096
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    sc.nextLine()
    val Array(t, a) = sc.nextLine.split(" ").map(_.toInt)
    val candidates = sc.nextLine.split(" ").map(_.toInt)

    println(candidates.zipWithIndex.slice(1, candidates.length).foldLeft((Math.abs((t - candidates.head * 0.006) - a), 1)) {
      case ((presentMin, _), (height, index)) if Math.abs((t - height * 0.006) - a) < presentMin => (Math.abs((t - height * 0.006) - a), index + 1)
      case ((presentMin, presentIndex), _) => (presentMin, presentIndex)
    }._2)
  }

}


Measured memory_bytes: 27288
#include <stdio.h>
int main(void){
  int n,y,i,j,t,s;
  bool found=false;
  scanf("%d%d",&n,&y);
  for (i=0;i<=n&&i<=y/10000;i++){
    s=y-i*10000;
    for (j=0;j<=n-i&&j<=s/5000;j++){
      t=s-j*5000;
      if (t%1000==0){
        if (i+j+(t/1000)==n){
          found=true;
          break;
        }
      }
    }
    if (found) break;
  }
  if (found) printf("%d %d %d\n",i,j,n-i-j);
  else printf("-1 -1 -1\n");
  return 0;
}

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

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

  int ans = 100;

  for (ll i = 1; i * i <= N; ++i) {
    if (N % i == 0) {
      ans = min(ans, (int)max(log10(i), log10(N / i)) + 1);
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 512
import java.awt.Point;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.stream.IntStream;

public class Main{
	public static void main(String[]$) throws IOException{
		new Main().solve();
	}
	static FastScanner s=new FastScanner(System.in);
	static IntStream REPS(int v){return IntStream.range(0,v);}
	static IntStream REPS(int l,int r){return IntStream.rangeClosed(l,r);}
	static int gInt() throws IOException{return s.nextInt();}
	static long gLong() throws IOException{return s.nextLong();}
	static long gDouble() throws IOException{return s.nextLong();}

	private void solve() throws IOException{
		int n=gInt(),m=gInt();

		Point[]edge=new Point[m];
		for(int i=0;i<m;++i)
			edge[i]=new Point(gInt()-1,gInt()-1);
		
		int c=0;
		
		for(int i=0;i<m;++i) {
			UF uf=new UF(n);
			for(int j=0;j<m;++j)if(i!=j) {
				uf.connect(edge[j].x,edge[j].y);
			}
			if(uf.groupSize(0)!=n)
				++c;
		}
		System.out.println(c);
	}

	class UF{
		public int[] uni;
		public UF(int size){
			uni=new int[size];
			Arrays.fill(uni,-1);
		}
		public int root(int t){
			if(uni[t]<0)
				return t;
			return uni[t]=root(uni[t]);
		}
		public boolean connect(int p,int c){
			p=root(p);
			c=root(c);
			if(p==c)
				return false;
			if(uni[p]>uni[c]){
				final int buf=c;
				c=p;
				p=buf;
			}
			uni[p]+=uni[c];
			uni[c]=p;
			return true;
		}
		public boolean isConnected(int a,int b){
			return root(a)==root(b);
		}
		public int groupSize(int t){
			return -uni[root(t)];
		}
	}

	static void yesno(boolean f) {
		yesno(f,"Yes","No");
	}
	static void yesno(boolean f,String yes,String no) {
		System.out.println(f?yes:no);
	}
}
class FastScanner{
	private final BufferedInputStream	in;
	private static final int			bufSize	=1<<16;
	private final byte					buf[]	=new byte[bufSize];
	private int							i		=bufSize;
	private int							k		=bufSize;
	private final StringBuilder			str		=new StringBuilder();

	FastScanner(InputStream in){
		this.in=new BufferedInputStream(in,bufSize);
	}
	int nextInt() throws IOException{
		return (int)nextLong();
	}
	long nextLong() throws IOException{
		int c;
		long x=0;
		boolean sign=true;
		while((c=nextChar())<=32)
			;
		if(c=='-'){
			sign=false;
			c=nextChar();
		}
		if(c=='+'){
			c=nextChar();
		}
		while(c>='0'){
			x=x*10+(c-'0');
			c=nextChar();
		}
		return sign?x:-x;
	}
	int nextChar() throws IOException{
		if(i==k){
			k=in.read(buf,0,bufSize);
			i=0;
		}
		return i>=k?-1:buf[i++];
	}
	String next() throws IOException{
		int c;
		str.setLength(0);
		while((c=nextChar())<=32&&c!=-1)
			;
		if(c==-1){
			return null;
		}
		while(c>32){
			str.append((char)c);
			c=nextChar();
		}
		return str.toString();
	}
	String nextLine() throws IOException{
		int c;
		str.setLength(0);
		while((c=nextChar())<=32&&c!=-1)
			;
		if(c==-1){
			return null;
		}
		while(c!='\n'){
			str.append((char)c);
			c=nextChar();
		}
		return str.toString();
	}
}

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

int main() {
  int64_t L,M,Z=1,Q=1000000007;
  cin>>L>>M;
  int64_t W=sqrt(M);
  for(int64_t i=2;i<=W;i++){
    if(M%i!=0){
      continue;
    }
    int U=0;
    while(M%i==0){
      U++;
      M/=i;
    }
    int64_t A=L+U-1,B=U,C=1;//A,Bを入れる
  for(int64_t i=1;i<=B;i++){
    C=(C*i)%Q;
  }
  int64_t N=Q-2,a=1,b=0,c=1;
  while(N>0){
    a*=2;
    if(N%a!=0){
      N-=a/2;
      int64_t d=C;
      for(int j=0;j<b;j++){
        d=(d*d)%Q;
      }
      c=(c*d)%Q;
    }
    b++;
  }
  C=c;
  for(int i=0;i<B;i++){
    C=(C*(A-i))%Q;
  }//答はC
    Z=(Z*C)%Q;
  }
  if(M!=1){
    Z=(Z*L)%Q;
  }
  cout<<Z<<endl;

}



Measured memory_bytes: 3636
#include <queue>
#include <set>
#include <cstdio>
#include <cstring>
using namespace std;
typedef pair<int,int> pii;
int M[15][15],N[15][15];
int D[4][2]={{-1,0},{0,-1},{1,0},{0,1}};
int main(){
	int n,m,x,y,o,r,c,s,a;
	scanf("%d%d",&n,&m);
	for(y=0;y<n;y++)for(x=0;x<n;x++)scanf("%d",M[y]+x);
	for(;m--;){
		scanf("%d%d",&o,&r);r--;
		if(o==0){
			scanf("%d%d%d",&c,&s,&a);c--;
			if(a){
				memcpy(N,M,sizeof(M));
				for(y=0;y<s;y++)for(x=0;x<s;x++){
					if(a==90)N[r+y][c+x]=M[r+s-x-1][c+y];
					else if(a==180)N[r+y][c+x]=M[r+s-y-1][c+s-x-1];
					else if(a==270)N[r+y][c+x]=M[r+x][c+s-y-1];
				}
				memcpy(M,N,sizeof(M));
			}
		}else if(o==1){
			scanf("%d%d",&c,&s);c--;
			for(y=r;y<r+s;y++)for(x=c;x<c+s;x++)M[y][x]^=1;
		}else if(o==2){
			y=M[r][0];for(x=0;x<n-1;x++)M[r][x]=M[r][x+1];
			M[r][n-1]=y;
		}else if(o==3){
			y=M[r][n-1];for(x=n-1;x>0;x--)M[r][x]=M[r][x-1];
			M[r][0]=y;
		}else if(o==4){
			scanf("%d",&c);c--;
			set<pii>se;
			queue<pii>q;
			q.push(make_pair(r,c));
			for(;!q.empty();){
				pii p=q.front();q.pop();
				for(s=0;s<4;s++){
					y=p.first+D[s][0],x=p.second+D[s][1];
					if(0<=x&&x<n&&0<=y&&y<n&&M[y][x]==M[r][c]){
						pii _p=make_pair(y,x);
						if(se.find(_p)==se.end()){
							se.insert(_p);
							q.push(_p);
						}
					}
				}
			}
			set<pii>::iterator it=se.begin();
			for(;it!=se.end();it++)M[it->first][it->second]^=1;
		}
	}
	for(y=0;y<n;y++)for(x=0;x<n;x++)printf(x<n-1?"%d ":"%d\n",M[y][x]);
}

Measured memory_bytes: 1044
n = int(input())
A = list(map(int, input().split()))
 
#偶数項を正とする場合
even_ans = 0
tot = 0
 
for i in range(n):
    tot += A[i]
    #偶数項では累積和を正とする
    if i % 2 == 1:
        if tot > 0:
            pass
        else:
            even_ans += abs(1 - tot)
            tot = 1
    #奇数項では累積和を負とする
    else:
        if tot < 0:
            pass
        else:
            even_ans += abs(-1-tot)
            tot = -1
 
#奇数項を正とする場合
odd_ans = 0
tot = 0
 
for i in range(n):
    tot += A[i]
    #偶数項では累積和を正とする
    if i % 2 == 1:
        if tot < 0:
            pass
        else:
            odd_ans += abs(-1 - tot)
            tot = -1
    #奇数項では累積和を負とする
    else:
        if tot > 0:
            pass
        else:
            odd_ans += abs(1-tot)
            tot = 1
 
ans = min(even_ans, odd_ans)
print(ans)

Measured memory_bytes: 14648
S = input()
T = input()

ans = 0
for i in range(len(S) - len(T) + 1):
  tmp = 0
  for j in range(len(T)):
    if S[i + j] == T[j]:
      tmp += 1
  ans = max(ans, tmp)

print(len(T) - ans)
  


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

using namespace std;



int main()
{
    int k,a , b;
    cin >>k>>a>>b;
    int ok =0 ;
    for(int i =a; i <=b; i ++)
    {
        if(i % k == 0)
            ok = 1;
    }

    cout << (ok ? "OK" :"NG");

    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()


using namespace std;

typedef long long ll;

static const long long MOD = 1000000007;

int ans, H, W, N;


int main(void) {
    scanf("%d %d %d", &H, &W, &N);
    int x = max(H, W);
   

  
    printf("%d\n", (x+N-1)/x);

	return 0;
}

Measured memory_bytes: 256
r=input().split()
N=int(r[0])
X=int(r[1])
d=[int(s) for s in input().split()]
ans=1
le=0
for i in range(N):
    le+=d[i]
    if le>X:
        print(ans)
        break
    elif i==N-1:
        print(N+1)
    else:
        ans+=1

Measured memory_bytes: 8956
program sc
  implicit none
  integer :: i,muzu
  character(len=4) :: S

  read(*,*) S
  muzu=0
  do i=1,3
     if(S(i:i).eq.S(i+1:i+1)) then
        muzu=1
     endif
  enddo
  if(muzu.eq.0) then
     write(*,'(a)') 'Good'
  else
     write(*,'(a)') 'Bad'
  endif



end program sc

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int N = in();
    int before = 0;
    int answer = 0;
    int count = 0;
    vector<int> A(N);
    REP(i,N)A[i] = in();
    sort(ALL(A));
    REP(i,N){
        if(before != A[i]){
            answer += count%2;
            count = 1;
        }else{
            count++;
        }
        before = A[i];
    }
    answer += count%2;
    cout << answer << "\n";
}

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

using namespace std;

int main()
{
   int n,k;
   cin>>n>>k;
   int r,s,p;
   cin>>r>>s>>p;
   map<char,int>m;
   m['r']=p;
   m['s']=r;
   m['p']=s;
   string t;
   cin>>t;
   int points=0;
   for(int i=0;i<(int)t.length();i++){
        if((i-k)>=0&&t[i]==t[i-k]){
            t[i]='@';
            continue;
        }
        points+=m[t[i]];
   }
   cout<<points<<endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
	int c,n,a[100010],max_=-1,pos,x,f;
	cin>>c>>n;
	for(int i=1;i<=n;i++){
		cin>>x;
		if(i==1){
			f=x;
			pos=x;
			continue;
		}
		max_=max(max_,x-pos);
		pos=x;
	}
	max_=max(c-pos+f,max_);
	cout<<c-max_<<endl; 
}

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

const int MAX_N = 100;
int to[MAX_N][MAX_N];
int ans[MAX_N][2];
bool visited[MAX_N];
int n = 1;

void dfs(int x) {
  if (visited[x]) return;
  visited[x] = true;

  ans[x][0] = n++;
  for (int i=0; to[x][i] != -1; i++) {
    dfs(to[x][i]);
  }
  ans[x][1] = n++;
}

int main() {
  int N;
  cin >> N;
  for (int i=0; i<N; i++) {
    for (int j=0; j<N; j++) {
      to[i][j] = -1;
    }
    ans[i][0] = ans[i][1] = -1;
    visited[i] = false;
  }
  for (int i=0; i<N; i++) {
    int tmp, n;
    cin >> tmp >> n;
    for (int j=0; j<n; j++) {
      int t;
      cin >> t; t--;
      to[i][j] = t;
    }
  }

  for (int i=0; i<N; i++) {
    if (!visited[i]) dfs(i);
  }
  for (int i=0; i<N; i++) {
    cout << i+1 << " " << ans[i][0] << " " << ans[i][1] << endl;
  }
  return 0;
}

Measured memory_bytes: 3148
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;

public class Main {
    public static int n;
    public static int q;
    public static boolean memo[];
    public static int a[];

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = sc.nextInt();
        q = sc.nextInt();
        int m[] = new int[q];
        for (int i = 0; i < q; i++)
            m[i] = sc.nextInt();
        memo = new boolean[500000];

        rec(0, 0);

        for (int i = 0; i < q; i++) {
            if (memo[m[i]] == true) {
                System.out.println("yes");
            } else {
                System.out.println("no");
            }
        }

        sc.close();
    }

    public static void rec(int index, int sum) {
        if (index == n) {
            memo[sum] = true;
            return;
        }
        rec(index + 1, sum);
        rec(index + 1, sum + a[index]);
    }
}


Measured memory_bytes: 27308