akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input!{
        n: usize
    }
    let ans = if n %2 ==0 {
        n/2
    }else{
        n/2 + 1
    };
    println!("{}", ans);

}

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

int main() {
    int N;
    cin >> N;
    vector<int> d(N);
    for (int i = 0; i < N; i++) {
        cin >> d.at(i);
    }

    sort(d.begin(), d.end());

    // 半分の値と遜次の値が同じでなければ分割可能
    cout << ( (d.at(N/2-1) == d.at(N/2))
        ? 0
        : d.at(N/2) - d.at(N/2-1)
    ) << endl;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
#include<string>
using namespace std;
#define ll long long 
int main(){
    string s,s1;
    cin>>s>>s1;
    int len=s.size();
    if(s.substr(0,len)==s1.substr(0,len))
    cout<<"Yes";
    else
    {
        cout<<"No";
    }
    
    return 0;
}


Measured memory_bytes: 3624
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<cctype>
#define qmin(x,y) (x=min(x,y))
#define qmax(x,y) (x=max(x,y))
using namespace std;

inline char gc() {
//	static char buf[100000],*p1,*p2;
//	return (p1==p2)&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
	return getchar();
}

template<class T>
int read(T &ans) {
	ans=0;char ch=gc();T f=1;
	while(!isdigit(ch)) {
		if(ch==EOF) return -1;
		if(ch=='-') f=-1;
		ch=gc();
	}
	while(isdigit(ch))
		ans=ans*10+ch-'0',ch=gc();
	ans*=f;return 1;
}

template<class T1,class T2>
int read(T1 &a,T2 &b) {
	return read(a)!=EOF&&read(b)!=EOF?2:EOF;
}

template<class T1,class T2,class T3>
int read(T1 &a,T2 &b,T3 &c) {
	return read(a,b)!=EOF&&read(c)!=EOF?3:EOF;
}

typedef long long ll;
const int Maxn=210000;
const int inf=0x3f3f3f3f;

int n,w,tot;
ll f[Maxn],v;

signed main() {
//	freopen("test.in","r",stdin);
	read(n,tot);
	memset(f,0x3f,sizeof(f));f[0]=0;
	int now=0;
	for(int i=1;i<=n;i++) {
		read(w,v);
		for(int j=now+v;j>=v;j--) f[j]=min(f[j],f[j-v]+w);
		now+=v;
	}
	for(int i=now;i>=0;i--) f[i]=min(f[i],f[i+1]);
	int ans=0;
	while(f[ans]<=tot) ans++;
	printf("%d\n",ans-1);
	return 0;
}



Measured memory_bytes: 1792
import java.io.PrintWriter
import java.lang.Math.min

fun solve(out: PrintWriter): Boolean = with(out) {
    val arg = readLine()!!.split(" ").map{it.toInt()}
    println(min(arg[1]*arg[0], arg[2]))
    return false
}

// with(PrintWriter(System.out))
// with(File("out.txt").printWriter())
// with(File(args[1]).printWriter())
fun main(args: Array<String>) = with(PrintWriter(System.out)){
//    System.setIn(File(args[0]).inputStream())
    while(solve(this));
    flush()
}

Measured memory_bytes: 38120
function Main(input) {
  input = input.split("\n");
  var n = input[0];
  var ans ="";

  for(i=0;i<n.length;i++){
    if(n.substr(i,1)=="0"){
      ans+=0;
    }else if(n.substr(i,1)=="1"){
      ans+=1;
    }else{
      ans=ans.substr(0,ans.length-1);
    }
  }

  console.log('%s', ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef long long ll;
typedef long long integer;
//////////////////////////////////////////////////
int main(){
    int N; SCD(N);
    static integer a[400002];
    REP(i,3*N){ //0-indexed
        integer x; SCLLD(x);
        a[i] = x;
    }

    priority_queue<integer,vector<integer>,greater<integer> >leftQ;
    priority_queue<integer>rightQ;

    static integer left[400002] = {};
    static integer right[400002] = {};

    REP(i,N){
        leftQ.push(a[i]);
        left[N] += a[i];

        rightQ.push(a[3*N-i-1]);
        right[2*N] += a[3*N-i-1];

    }

    FOR(i,N+1,2*N+1){
        integer newv = a[i-1];
        leftQ.push(newv);
        integer prev = leftQ.top();
        leftQ.pop();
        left[i] = left[i-1] - prev + newv;

        newv = a[3*N-i];
        rightQ.push(newv);
        prev = rightQ.top();
        rightQ.pop();
        right[3*N-i] = right[3*N-i+1] - prev + newv;
    }

    integer ans = -100000000000000;

    FOR(i,N,2*N+1){
        ans = max(ans,left[i] - right[i]);
    }

/*     DEBUG;

    for(int i = 2*N;N<=i;i--){
        PRINTLLD(right[i]);
    }
 */
    PRINTLLD(ans);
    return 0;
}

Measured memory_bytes: 9324
#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, s, e) for (ll i = s; i < e; i++)
#define Forr(i, s, e) for (ll i = s; i > e; i--)
#define pb push_back
#define ll long long
#define int ll
#define mp make_pair

signed main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    cout << fixed << setprecision(8);
    string s, t;
    cin >> s >> t;
    ll fr = s.size();
    For(i, 0, s.size() - t.size() + 1)
    {
        ll temp = 0;
        For(j, 0, t.size())
        {
            if (s[i + j] != t[j])
                temp++;
        }
        fr = min(fr, temp);
    }
    cout << fr << endl; 
    return 0;
}

Measured memory_bytes: 3604
n = int(input())
s1 = list(input())
s2 = list(input())

mod = 1000000007

pre = 0
ans = 3
i = 0
while i < n:
    if s1[i] == s2[i]:
        if pre == 1:
            ans = ans * 2 % mod
        pre = 1
        i += 1
    else:
        if pre == 2:
            ans = ans * 3 % mod
        else:
            ans = ans * 2 % mod
        pre = 2
        i += 2

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define FOR(i, N) for (long i = 0; i < (N); i++)

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int H, W, M;
    cin >> H >> W >> M;
    vector<pair<int, int>> B(M);
    vector<int> Bomb_Count_W(W, 0);
    vector<int> Bomb_Count_H(H, 0);
    map<pair<int, int>, int> Bomb_Map;

    FOR(m, M) {
        cin >> B[m].first >> B[m].second;
        B[m].first--;
        B[m].second--;
        Bomb_Count_H[B[m].first] += 1;
        Bomb_Count_W[B[m].second] += 1;
        Bomb_Map[{B[m].first, B[m].second}]++;
    }

    int max_H_bomb = 0;
    int max_W_bomb = 0;
    vector<int> W_candidate;
    vector<int> H_candidate;

    FOR(h, H) {
        if (max_H_bomb < Bomb_Count_H[h]) {
            max_H_bomb = Bomb_Count_H[h];
        }
    }

    FOR(w, W) {
        if (max_W_bomb < Bomb_Count_W[w]) {
            max_W_bomb = Bomb_Count_W[w];
        }
    }

    int max_W_columns = 0;
    int max_H_rows = 0;

    FOR(h, H) {
        if (max_H_bomb == Bomb_Count_H[h]) {
            max_H_rows++;
            H_candidate.emplace_back(h);
        }
    }

    FOR(w, W) {
        if (max_W_bomb == Bomb_Count_W[w]) {
            max_W_columns++;
            W_candidate.emplace_back(w);
        }
    }

    if (M < max_W_columns * max_H_rows) {
        cout << max_W_bomb + max_H_bomb << endl;
        return 0;
    } else {
        for (int w : W_candidate) {
            for (int h : H_candidate) {
                if (Bomb_Map[{h, w}] == 0) {
                    cout << max_W_bomb + max_H_bomb << endl;
                    return 0;
                }
            }
        }

        cout << max_H_bomb + max_W_bomb - 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 30840
from sys import stdin
N = int(stdin.readline().rstrip())
data = [int(x) for x in stdin.readline().rstrip().split()]

d1 = sorted(data)[(N//2)-1]
d2 = sorted(data)[(N//2)]

for i in data:
    if i <= d1:
        print(d2)
    else:
        print(d1)

Measured memory_bytes: 26016
n = gets.to_i
a = gets.split.map(&:to_i)
M = 1000000007
asum = 0
sum = 0
a.reverse!
(n-1).times do |i|
  asum += a[i]
  asum %= M
  sum += (asum * a[i+1]) % M
  sum %= M
end
puts sum

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

public class Main{
    public static void main(String args[]) throws Exception{
    	final int SCORE_MAX= 1000;
    	final int SCORE_MIN= 0;
        Scanner scan= new Scanner(System.in);
        int N_tot,N_net;
        int sum,max,min,buf;
        while( (N_tot= scan.nextInt())>0 ){
        	N_net= N_tot-2;
        	sum= 0;
        	max= SCORE_MIN; min= SCORE_MAX;
        	for(int i=0;i<N_tot;i++){
        		buf= scan.nextInt();
        		sum += buf;
        		if( buf>max ){ max=buf; }
        		if( buf<min ){ min=buf; }
        	}
        	int sum_net= sum- max- min;
        	System.out.println(sum_net/N_net);
        }
    }
}

Measured memory_bytes: 20964
#pragma GCC optimize("O2") 

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

typedef long long int ll;
typedef unsigned long long int ull;

#define test(t)		int t; cin>>t; while(t--)
#define f(i, a, b)	for(int i = a; i < b; ++i)
#define all(a)		a.begin(), a.end()
#define endl 		"\n"
#define deb(x)		cout << #x << "--" << x << "--" << endl;
#define deb2(x,y)	cout << #x << "-" << x << "-" << " ~~ " <<  #y << "-" << y << "-" << endl;
#define deb3(x,y,z)	cout << #x << "-" << x << "-" << " ~~ " <<  #y << "-" << y << "-" << " ~~ " << #z << "-" << z << "-" << endl;
#define deba(arr)	cout << #arr << " ~ [ "; for(auto n: arr) cout << n << " "; cout << "]" << endl;
#define fast 		ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

#define mx9		1000000007
#define mx7		10000007
#define mx6		1000006
#define mx5		200005
#define inf		1<<30                                 
#define eps		1e-9
#define mod		1000000007
#define PI		3.141592653589793238462643383279502884L

void solve()
{
  ll n;
  cin >> n;
  ll a[n], z = 0;
  f(i, 0, n)
  {
    cin >> a[i];
    if(a[i] == 0)
      z += 1;
  }
  if(z >= 1)
  {
    cout << "0" << endl;
    return;
  }
  ll pro = 1;
  f(i, 0, n)
  {
    if(a[i] > 1000000000000000000 / pro)
    {
      cout << "-1" << endl;
      return;
    }
    pro *= a[i];
  }
  cout << pro << endl;
}
int main()
{
    fast;
    //test(t)
        solve();
    return 0;
}


Measured memory_bytes: 4436
#include <iostream>
#include <stdio.h>
#include <string>

using namespace std;

void solve()
{
	int n;
	char c;
	scanf("%d%c", &n, &c);
	while(n--)
	{
		string str;
		getline(cin, str);
		for(int i = 0; i < str.size(); ++i)
		{
			if(str[i] == 'H' && i + 6 < str.size() && str[i + 1] == 'o' && str[i + 2] == 's' && str[i + 3] == 'h' && str[i + 4] == 'i' && str[i + 5] == 'n' && str[i + 6] == 'o')
			{
				str[i + 6] = 'a';
				i += 6;
			}
		}
		cout << str << endl;
	}
}

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

Measured memory_bytes: 1232
# -*- coding: utf-8 -*-
n = int(input())

d = {}
ret = 0
for x in input().split():
    a = int(x)
    if a not in d:
        d[a] = 0

    if d[a] == a:
        ret += 1
    else:
        d[a] += 1

for k,v in d.items():
    if k!=v:
        ret += v
print(ret)


Measured memory_bytes: 23288
#include "iostream"
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <string>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
using namespace std;
using ll=long long;
#define mod  1000000007

int main(int argc, char const *argv[]) {
  int a,b,c,d;
  std::cin >> a >> b >>c >> d;
  if(a+b>c+d)printf("Left\n");
  else if(a+b==c+d)printf("Balanced\n");
  else printf("Right\n");
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<utility>
#include<cstdio>
#include<set>
#include<string>
#include<map>
#include<queue>
#include<stack>
#include <bitset>
using namespace std;
const int mod=1e9+7;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,x,n) for (int i= x;i<n;i++)
#define all(v) v.begin(), v.end()
#define nepe(v) next_permutation(all(v))
using ll = long long;
using vi = vector<int>; 
using vvi = vector<vi>;

typedef pair<int,int> P;
string s;
int k;
ll INF = 10000000000000000;

int main(){
    int S,W;
    cin >>S>>W;
    if(W>=S) cout <<"unsafe"<<endl;
    else cout <<"safe"<<endl;
}

Measured memory_bytes: 3624
n, m = [int(i) for i in input().split()]

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

uf = UnionFind(n)
for i in range(m):
    a, b = [int(i) for i in input().split()]
    uf.union(a-1, b-1)

print(-1 * min(uf.parents))

Measured memory_bytes: 79776
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    ll a, b;
    cin >> a >> b;
    ll t = a+b;
    if(t % 2 == 1){
        cout << "IMPOSSIBLE" << endl;
    }else{
        cout << t/2 << endl;
     }
    return 0;
}

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

int main(){

  int n, flag = 1, cnt = 0;
  string str;

  cin >> n;

  for(int i = 0; i < n; i++){
    cin >> str;
    if(cnt < 0) flag = 0;
    if(str == "A"){
      cnt++;
    }else{
      cnt--;
    }
  }
  if((!cnt && flag == 0) || cnt){
    cout << "NO" << endl;
  }else{
    cout << "YES" << endl;
  }
  return 0;
}


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

using namespace std;

#define INF 2000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;


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

	vector<int> v1, s1;
	vector<int> v2, s2;

	for (int i = 0; i < n; i++) {
		int tmp;
		cin >> tmp;
		v1.push_back(tmp);
	}
	for (int i = 0; i < n; i++) {
		int tmp;
		cin >> tmp;
		v2.push_back(tmp);
	}

	int sum = 0;
	int sum2 = 0;
	for (int i = 0; i < n; i++) {
		sum += v1[i];
		s1.push_back(sum);
		sum2 += v2[i];
	}

	s2.push_back(sum2);
//	cout << sum2 << "\n";
	for (int i = 0; i < n; i++) {
		sum2 -= v2[i];
//		cout << sum2 << "\n";
		s2.push_back(sum2);
	}

	int ans = 0;
	for (int i = 1; i < n-1; i++) {
		int tmp = v1[i] + v2[i] + s1[i-1] + s2[i+1];
//		cout << i << ": " << tmp << " " << v1[i]  << " " << v2[i] << " " << s1[i-1] << " " << s2[i+1] <<  "\n";
		ans = std::max(ans, tmp);
	}

	if (n==1) {
		cout << v1[0] + v2[0] << "\n";
		return 0;
	}

	ans = std::max(ans, v1[0]+v2[0]+s2[1]);
	ans = std::max(ans, v1[n-1]+v2[n-1]+s1[n-2]);
	cout << ans << endl;
}


Measured memory_bytes: 256
def main():
    n = int(input())
    l = list(input())
    R = [0]
    G = [0]
    B = [0]
    Rl = set()
    Gl = set()
    Bl = set()

    for i in range(n):
        if l[i] == "R":
            R.append(R[-1]+1)
            G.append(G[-1])
            B.append(B[-1])
            Rl.add(i+1)
        if l[i] == "G":
            R.append(R[-1])
            G.append(G[-1]+1)
            B.append(B[-1])
            Gl.add(i+1)
        if l[i] == "B":
            R.append(R[-1])
            G.append(G[-1])
            B.append(B[-1]+1)
            Bl.add(i+1)
    ans = 0


    for i in range(1,n-1):
        if l[i] == "R":
            ans += G[i]*(B[-1]-B[i+1])
            ans += B[i]*(G[-1]-G[i+1])
            for j in range(i+1):
                if j+i+1 > n or i-j+1 < 0:
                    break
                else:
                    if j+i+1 in Gl and i-j+1 in Bl:
                        ans -= 1
                    if j+i+1 in Bl and i-j+1 in Gl:
                        ans -= 1
        if l[i] == "G":
            ans += R[i]*(B[-1]-B[i+1])
            ans += B[i]*(R[-1]-R[i+1])
            for j in range(i+1):
                if j+i+1 > n or i-j+1 < 0:
                    break
                else:
                    if j+i+1 in Rl and i-j+1 in Bl:
                        ans -= 1
                    if j+i+1 in Bl and i-j+1 in Rl:
                        ans -= 1
        if l[i] == "B":
            ans += G[i]*(R[-1]-R[i+1])
            ans += R[i]*(G[-1]-G[i+1])
            for j in range(i+1):
                if j+i+1 > n or i-j+1 < 0:
                    break
                else:
                    if j+i+1 in Gl and i-j+1 in Rl:
                        ans -= 1
                    if j+i+1 in Rl and i-j+1 in Gl:
                        ans -= 1
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 9716
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int N,W;
    cin >> N >> W;
    vector<int> w(N), v(N);
    for(int i = 0; i < N; i++)
    {
        cin >> w[i] >> v[i];
    }
    vector<vector<long long>> dp(N+1,vector<long long>(W+1,0LL));
    for(int i = 0; i < N; i++)
    {
        for(int j = 0; j <= W; j++)
        {
            if (j-w[i] >= 0) {
                dp[i+1][j] = max(dp[i+1][j], dp[i][j-w[i]]+v[i]);
            }
            dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
        }
    }
    cout << dp[N][W] <<endl;
}

Measured memory_bytes: 80256
#include<stdio.h>
#include<math.h>
int main()
{
	int a[11][11], n, d, i, j, k, t, sum, num, count=0;
	double dis;
	scanf("%d %d", &n, &d);
	for(i=0; i<n; i++)
		for(j=0; j<d; j++)
			scanf("%d", &a[i][j]);

	for(i=1; i<n; i++)
	{
		for(k=0;k<i;k++)
		{
			sum = 0;
			for(j=0; j<d; j++)
				sum += (a[i][j]-a[k][j])*(a[i][j]-a[k][j]);
			dis = sqrt(sum);
			if(floor(dis)==dis)
				count++;	
		}
			
	}
	printf("%d\n", count);
	return 0;
}

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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 100;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<char> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<long long, vector<long long>, greater<long long> > PQ_ASK;
const int mod = 1000000007;


int main() {
    ll n;
    cin >> n;
    vector<ll> numbers(n);
    rep(i, n) cin >> numbers[i];
    cout << *min_element(numbers.begin(), numbers.end()) << ' '
         << *max_element(numbers.begin(), numbers.end()) << ' '
         << accumulate(numbers.begin(), numbers.end(), 0ll) << endl;

}


Measured memory_bytes: 3168
#include <stdio.h>
#include <string.h>
int comparison(char *a, char *b){
    int a_len = strlen(a);
    int b_len = strlen(b);
    if(a_len < b_len) return -1;
    else if(a_len > b_len) return 1;
    else{
        while(*a != *b){
            if(*a < *b) return -1;
            else if(*a > *b) return 1;
            else{
                a++;
                b++;
            }
        }
        return 0;
    }
}

void printResult(int i){
    switch(i){
        case 1:
        printf("GREATER\n");
        return;
        case 0:
        printf("EQUAL\n");
        return;
        case -1:
        printf("LESS\n");
        return;
    }
}

int main()
{
    int comp;
    char a[102], b[102];
    scanf("%s%s", a, b);
    comp = comparison(a, b);
    printResult(comp);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <map>
#include <queue>
#define rep(i,n) for(int i = 0; i < n; i++)
#define INF 1000000000
#define MOD 1000000007
#define ll long long
using namespace std;

int main(){
    ll x;
    cin>>x;
    ll y=(x/11)*2;
    ll z=x%11;
    if (z==0){
    }else if (z<=6){
        y+=1;
    }else{
        y+=2;
    }
    cout<<y<<endl;;
    return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
int A[3];
int main(){
 for (size_t i = 0; i < 3; i++) {
          
   scanf("%d\n",&A[i] );
 }
 sort(A,A+3); 
 printf("%d\n",A[2]-A[0] );
 return 0;
}

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

using namespace std;

char arr[55][55];
long long H, W;

int main()
{
	int flag = 0;
	scanf("%lld %lld", &H, &W);
	for(int i = 0; i < H; i++) {
		for(int j = 0; j < W; j++) {
			cin >> arr[i][j];
		}
	}

	for(int i = 1; i < H - 1; i++) {
		for(int j = 1; j < W - 1; j++) {
			if(((arr[i][j] == '#') && arr[i][j] != arr[i - 1][j]) && (arr[i][j] != arr[i + 1][j]) && (arr[i][j] != arr[i][j - 1]) && (arr[i][j] != arr[i][j + 1])) {
				flag = 1;
			}
		}
	}

	if(flag == 1) {
		cout << "No";
	}
	else {
		cout << "Yes";
	}
	
	return 0;
}
/*
	Powered by Buggy Plugin
*/


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

int main() {
	int N;
	cin>>N;
	vector<int>A(N);
	for(int i=0;i<N;i++){
		cin>>A.at(i);
	}
	vector<int>B(N);
	for(int i=0;i<N;i++){
		B.at(i)=A.at(i);
	}
	sort(B.begin(),B.end());

	int count=0;
	for(int i=0;i<N;i++){
		if(A.at(i)!=B.at(i))count++;
	}
	
		
	string ans="NO";
	if(count<3)ans="YES";
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back

int main() {
    string s;
    cin>>s;
    int n=s.size();
    if(s[n-1]=='s'){
        s+="es";
        cout<<s;
    }else{
        s+='s';
        cout<<s;
    }
}

Measured memory_bytes: 3624
#include <stdio.h>
#include <inttypes.h>

#define N_MAX 100000
#define M_MAX 100000

int N, M;
int P[M_MAX];
int A[N_MAX + 1];
int B[N_MAX + 1];
int C[N_MAX + 1];

/* sorezore no tetudou ni noru kaisuu */
int count[N_MAX + 1];

int main(void) {
	int i;
	uint64_t answer = 0;
	if (scanf("%d%d", &N, &M) != 2) return 1;
	for (i = 0; i < M; i++) {
		if (scanf("%d", &P[i]) != 1) return 1;
	}
	for (i = 1; i < N; i++) {
		if (scanf("%d%d%d", &A[i], &B[i], &C[i]) != 3) return 1;
	}
	for (i = 1; i < M; i++) {
		if (P[i - 1] < P[i]) {
			count[P[i - 1]]++;
			count[P[i]]--;
		} else {
			count[P[i]]++;
			count[P[i - 1]]--;
		}
	}
	for (i = 1; i <= N; i++) count[i] += count[i - 1];
	for (i = 1; i < N; i++) {
		uint64_t genkin = (uint64_t)A[i] * count[i];
		uint64_t card = C[i] + (uint64_t)B[i] * count[i];
		answer += (genkin < card ? genkin : card);
	}
	printf("%"PRIu64"\n", answer);
	return 0;
}

Measured memory_bytes: 2552
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
int main(void){
    int n;
    cin>>n;
    int ans=0;
    for(int i=1;i<=n;i++){
        string tmp=to_string(i);
        if(tmp.size()%2==1){
            ans++;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3148
#include <stdio.h>
#define MAXL 3000

void swap(int *x, int *y);

int main()
{
    int x[MAXL] = {0};
    int y[MAXL] = {0};
    int i = 0;
    while(i < 3000)
    {
        scanf("%d",x+i);
        scanf("%d",y+i);
        
        if(x[i] == 0 && y[i] == 0) break;
        
        i++;
    }
    
    int length = i;
    
    for(i = 0; i < length; i++)
    {
        swap(x+i,y+i);
        
        printf("%d %d\n",x[i],y[i]);
    }
}

void swap(int *x,int *y)
{
    if(*x > *y)
    {
        int p = *x;
        *x = *y;
        *y = p;
    }
    
    return;
}


Measured memory_bytes: 2684
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vd=vector<double>;
using vvd=vector<vd>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using vs=vector<string>;
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define LINF    	((ll)1ll<<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			3.141592653589793

template<class S,class T>ostream& operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	int n;
	cin>>n;
	vi a(n/2);
	vi b(n/2);
	rep(i,n){
	    if(i%2==0) cin>>a[i/2];
	    if(i%2==1) cin>>b[i/2];
	}
	map<int,int> aa,bb;
	for(auto i:a){
	    if(aa.find(i)==aa.end())aa[i]=0;
	    aa[i]++;
	}
	for(auto i:b){
	    if(bb.find(i)==bb.end())bb[i]=0;
	    bb[i]++;
	}
	vector<pii> A,B;
	for(auto i:aa)A.push_back(i);
	for(auto i:bb)B.push_back(i);
	sort(all(A),[](pii x, pii y){return x.sc>y.sc;});
	sort(all(B),[](pii x, pii y){return x.sc>y.sc;});
	n/=2;
	int ans=INF;
	int p;
	if(A[0].fs!=B[0].fs){
    	p=n-A[0].sc+n-B[0].sc;
    	ans=min(ans,p);
	}
	if(B.size()>1 and A[0].fs!=B[1].fs){
    	p=n-A[0].sc+n-B[1].sc;
    	ans=min(ans,p);
	}
	if(A.size()>1 and A[1].fs!=B[0].fs){
    	p=n-A[1].sc+n-B[0].sc;
    	ans=min(ans,p);
	}
	if(B.size()>1 and A.size()>1 and A[1].fs!=B[1].fs){
    	p=n-A[1].sc+n-B[1].sc;
    	ans=min(ans,p);
	}
	if(ans==INF)ans=n;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 6524
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x, n)                           \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
  cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S, T;
  cin >> S >> T;
  int A, B;
  cin >> A >> B;
  string U;
  cin >> U;
  if (U == S)
    A--;
  else
    B--;
  cout << A << " " << B << endl;
  return 0;
}


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

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

    int N, M;
    cin >> N >> M;
    vector<int> V(M, 0);
    for (int i = 0; i < N; ++i) {
        int K;
        cin >> K;
        for (int j = 0; j < K; ++j) {
            int A;
            cin >> A;
            V.at(A - 1)++;
        }
    }
    int ans = 0;
    for (auto &x : V) {
        if (x == N) {
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }
 
using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;
 
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};
 
const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod


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

int half(int x){
    int count = 0;
    while(x%2==0){
        x /= 2;
        count ++;
    }
    return count;
}
signed main(){
    int N; cin>>N;
    vector<int> A(N);
    REP(i,N) cin>>A[i];
    vector<int> ans(N);
    REP(i,N){
        ans[i] = half(A[i]);
    }
    Sort(ans);
    cout << ans[0]<<endl;
}

Measured memory_bytes: 256
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
 
struct INIT{
    INIT(){
        std::ios::sync_with_stdio(false);
        std::cin.tie(0);
        cout << fixed << setprecision(13);
    }
}INIT;

int h, w, n;

int main(){
    cin >> h >> w >> n;
    cout << min({n / h + (n % h != 0), n / w + (n % w != 0)}) << endl;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, j, n) for (ll i = j; i < n; i++)
#define all(x) (x).begin(),(x).end()
#define INF (1000000000)
#define MOD (1000000007)
#define MAX (100000)
#define pii pair<int, int>

/////////////////////////////////////////////////////////

class XY{
public:
  ll x, y;
  XY() {x = y = 0;}
  XY(ll u, ll v) {x = u; y = v;}
};

template<typename T1, typename T2>
void chmin(T1 &a, T2 b) {if(a > b) a = b;}
template<typename T1, typename T2>
void chmax(T1 &a, T2 b) {if(a < b) a = b;}

template<typename T1, typename T2>
ll mypow(T1 a, T2 n){
  if(n == 0) return 1;
  if(n == 1) return a;
  if(n % 2) return a * mypow(a, n - 1);
  ll tmp = mypow(a, n / 2);
  return tmp * tmp;
}

template<typename T>
int BS(vector<T> V, int left, int right, T key){
  int mid = (left + right) / 2;
  if(V[mid] <= key) left = mid;
  else right = mid;
  if(right - mid == 1) return left;
  else return BS(V, left, right, key);
}

ll comb(ll n, ll r){
	ll res = 1;
  rep(i, 0, r){
    res *= n - i;
    res /= i + 1;
  }
  return res;
}

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

/////////////////////////////////////////////////////////

void Main() {
  int N; cin >> N;
  vector<ll> A(N);
  rep(i, 0, N) cin >> A[i];
  vector<ll> C(N + 1);
  C[0] = 1;
  rep(i, 0, N) C[i + 1] = C[i] + A[i];
  sort(all(C));
  ll res = 0;
  ll cnt = 1;
  rep(i, 1, N + 1){
    if(C[i] == C[i - 1]) cnt++;
    else{
      res += (cnt * (cnt - 1)) / 2;
      cnt = 1;
    }
    if(i == N) res += (cnt * (cnt - 1)) / 2;
  }
  cout << res << endl;
}

/////////////////////////////////////////////////////////

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

  Main();
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
#include <cstdlib> 
using namespace std;
int main() {
  int N;cin >> N;
  int index = 1;
  vector<int> vec(N);
  for(int i=0;i<N;i++){
  	cin >> vec[i];
  }
  for(int i=0;i<N;i++){
  	index = vec[index-1];
    if(index==2){
    	cout << i+1 << endl;
      	break;
    }
    if(i==N-1) cout << -1 << endl;
  }
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vb = vector<bool>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define LINF 1E18*5
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

template<class S, class T>ostream& operator<<(ostream&os, pair<S, T>p) { os << "[" << p.first << ", " << p.second << "]"; return os; };
template<class S>auto&operator<<(ostream&os, vector<S>t) { bool a = 1; for (auto s : t) { os << (a ? "" : " ") << s; a = 0; } return os; }

//int dx[]={1,1,1,0,-1,-1,-1,0},dy[8]={1,0,-1,-1,-1,0,1,1,1};
//
constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

class compare {
public:
	bool operator()(tuple<int, int> a, tuple<int, int> b) {
		return (get<1>(a) < get<1>(b));
	}

};

int main() {
	int a, b;
	cin >> a >> b;
	cout << (a + b / 2) << endl;
}


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

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());

		for(int i = 0; i < n; i++){
			String tmp = br.readLine();

			if(tmp == null){
				break;
			}
			String[] tmpArray = tmp.split(" ");

//			BigDecimal[][] points = new BigDecimal[4][2];
			float [][] fpoints = new float[4][2];
			for(int j = 0; j < fpoints.length ;j++){
//				points[j][0] = new BigDecimal(tmpArray[j*2]);
//				points[j][1] = new BigDecimal(tmpArray[j*1]);
				fpoints[j][0] = Float.parseFloat(tmpArray[j*2]);
				fpoints[j][1] = Float.parseFloat(tmpArray[j*2+1]);
			}

			if((fpoints[1][0]==(fpoints[0][0])) || (fpoints[3][0]==( fpoints[2][0])) ){
				if((fpoints[1][0]==(fpoints[0][0])) && (fpoints[3][0]==( fpoints[2][0])) ){
					System.out.println("YES");
				}
				else {
					System.out.println("NO");
				}
			}

			else if((fpoints[1][1]-fpoints[0][1])/(fpoints[1][0]-fpoints[0][0])
					== (fpoints[3][1]-fpoints[2][1])/(fpoints[3][0]-fpoints[2][0])){
				System.out.println("YES");
			}
			else{
				System.out.println("NO");
			}
		}
	}

}

Measured memory_bytes: 24644
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
int H,W;
string s[500],a[500],b[500];
int main(){
	cin>>H>>W;
	rep(i,H) cin>>s[i];
	rep(i,H){
		if(i%2==0){
			a[i]=string(W-1,'#')+".";
			b[i]=string(W-1,'.')+"#";
		}else{
			a[i]="#"+string(W-1,'.');
			b[i]="."+string(W-1,'#');
		}
	}
	rep(i,H) rep(j,W) if(s[i][j]=='#') a[i][j]=b[i][j]='#';
	rep(i,H) cout<<a[i]<<endl;
	puts("");
	rep(i,H) cout<<b[i]<<endl;
}


Measured memory_bytes: 2048
import numpy as np

def solve(a, b, c, k):
    A = np.array([
            [0,1,1],
            [1,0,1],
            [1,1,0],
        ], dtype=np.int64)
    B = np.eye(3, dtype=np.int64)
    x = 0
    while k >= 2**x:
        if (k & (2**x)) > 0:
            B = np.dot(B, A)
        A = np.dot(A, A)
        x += 1
    a, b, c = np.dot(B, np.array([a,b,c]))
    ans = a - b
    if ans > 10**18:
        return "Unfair"
    else:
        return ans

assert solve(1,2,3,1) == 1
assert solve(2,3,2,0) == -1
assert solve(1000000000,1000000000,1000000000,1000000000000000000) == 0
a, b, c, k = map(int, raw_input().split())
print solve(a,b,c,k)


Measured memory_bytes: 16132
//
//  AOJ 0009 Prime Number
//
//  Created by TaoSama on 2015-03-23
//  Copyright (c) 2015 TaoSama. All rights reserved.
//
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <vector>
#define CLR(x,y) memset(x, y, sizeof(x))

using namespace std;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int N = 1e6 + 10;

bool is_prime[N];
int n, cnt, ans[N];

int main() {
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
//	freopen("out.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(0);

    memset(is_prime, true, sizeof is_prime);
    is_prime[1] = false; ans[1] = 0;
    for(int i = 2; i < 1e6; ++i) {
        if(is_prime[i]) {
            ans[i] = ++cnt;
            for(int j = 2 * i; j < 1e6; j += i)
                is_prime[j] = false;
        } else ans[i] = cnt;
    }

    while(cin >> n) {
        if(n <= 0) cout << 0 << endl;
        else	cout << ans[n] << endl;
    }

    return 0;
}

Measured memory_bytes: 6084
/**
 *    Coded by : lucky_21
 *               --------Lokesh Singh
**/

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

#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define     F           first
#define     S           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<int,int>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)
#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)
#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

typedef double db;
typedef long long ll;

const int N=2e5+5;
const int mod=1e9+7;

signed main(){
    FastIO;
    string s;
    cin>>s;
    ll ans=0;
    int dp[2020]{0};
    rep(i,0,s.size()-1){
        int n=s[i]-'0';
        int tdp[2020]{0};
        tdp[n]=1;
        rep(j,0,2018) if(dp[j]) tdp[(j*10+n)%2019]+=dp[j];
        ans+=tdp[0];
        rep(j,0,2018) dp[j]=tdp[j];
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3792
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
#define MAX_N 100000
int N,M,X,Y;
char a[MAX_N][8];
vector<int> G[MAX_N];
 
map< vector< int > , int > mp;
 
int update(char* s,int n){
  int t=X;
  if(s[4]=='Y')t=Y;
  if(s[3]=='&')return n&t;
  if(s[3]=='|')return n|t;
  if(s[3]=='^')return n^t;
}
 
int rec(int pos,int prev,int depth,int num){
   
  if(prev!=-1){
    num=update(a[pos],num);
    if(G[pos].size()==1) return num;
  }
   
  bool f=depth&1;
  int res=(f?X|Y:0);
  for(int i=0;i<(int)G[pos].size();i++){
    int to=G[pos][i];
    if(to==prev)continue;
    if(f)res=min(res,rec(to,pos,depth+1,num));
    else res=max(res,rec(to,pos,depth+1,num));
  }
  return res;
}
 
int solve(){
  if(N==1)return 0;
  vector< int> w;
  vector< P > v;
  v.push_back( P(X,0) );
  v.push_back( P(Y,1) );
  v.push_back( P(X|Y,2) );
  v.push_back( P(X&Y,3) );
  v.push_back( P( (X|Y)-X ,4) );
  v.push_back( P( (X|Y)-Y ,5) );
  v.push_back( P( (X|Y)-(X&Y) , 6 ) );
  v.push_back( P( 0 , 7 ) );
 
  sort(v.begin(),v.end());
  for(int i=0;i<8;i++)w.push_back(v[i].second);
   
  if(mp.count(w)){
    int id=mp[w];
    for(int i=0;i<8;i++)
      if(id==v[i].second)return v[i].first;
  }
  int ans=rec(0,-1,0,0);
  for(int i=0;i<8;i++){
    if(ans==v[i].first)
      mp[w]=v[i].second;
  }
  return ans;
}
 
int main(){
  scanf("%d %d",&N,&M);
  for(int i=1;i<N;i++)scanf("%s",a[i]);
  for(int i=1;i<N;i++){
    int x,y;
    scanf("%d %d",&x,&y);
    G[x].push_back(y);
    G[y].push_back(x);
  }
  while(M--){
    scanf("%d %d",&X,&Y);
    printf("%d\n",solve());
  }
  return 0;
}

Measured memory_bytes: 17328
#include <iostream>
#include <fstream>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <list>
#include <algorithm>
#include <cmath>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef __int128 lll;
constexpr ll mod = 1000000007;

int c[3][3];

int main() {
    for (int i = 0; i < 3; i++) for (int j = 0; j < 3; j++) cin >> c[i][j];
    int n;
    cin >> n;
    int b;
    for (int i = 0; i < n; i++) {
        cin >> b;
        for (int k = 0; k < 3; k++) for (int j = 0; j < 3; j++) if (c[k][j] == b) c[k][j] = -1;
    }
    for (int i = 0; i < 3; i++) {
        if ((c[i][0] == -1 && c[i][1] == -1 && c[i][2] == -1) || (c[0][i] == -1 && c[1][i] == -1 && c[2][i] == -1)) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    if ((c[0][0] == -1 && c[1][1] == -1 && c[2][2] == -1) || (c[2][0] == -1 && c[1][1] == -1 && c[0][2] == -1)) {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 99999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(150) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  lli A,B,C,D,E,F,N,M,K,L,R,X,Y,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> N;
  Vec(P,int,N,0);rep(i,0,N){cin >> A;P[i]=A%2;}
  sum=pow(3,N);
  num=1;
  rep(i,0,N){
    if(P[i]==0)P[i]=2;
    num*=P[i];
  }
  Out(sum-num);
}

Measured memory_bytes: 256
c=[list(map(int,input().split())) for i in range(3)]

if(c[0][2]-c[0][0]== c[1][2]-c[1][0] and c[1][2]-c[1][0]==c[2][2]-c[2][0]):
    if(c[0][1]-c[0][0]== c[1][1]-c[1][0] and c[1][1]-c[1][0]==c[2][1]-c[2][0]):
        if(c[1][0]-c[0][0]== c[1][1]-c[0][1] and c[1][1]-c[0][1]==c[1][2]-c[0][2]):
            if(c[2][0]-c[0][0]== c[2][1]-c[0][1] and c[2][1]-c[0][1]==c[2][2]-c[0][2]):
                print('Yes')
                exit()
print('No')


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

long long euclid(long long a, long long b){
  long long x=a,y=b;
  if(x<y) swap(x, y);
  if(x%y==0)return y;
  return euclid(y,x%y);
}
int main(){
  long long A, B, C, D;
  cin >> A >> B >> C >> D;
  long long c = (A-1)/C;
  long long cc = B/C;
  long long ccc = cc-c;

  long long d = (A-1)/D;
  long long dd = B/D;
  long long ddd = dd-d;

  long long e = (C*D)/euclid(C, D);
  long long f = (A-1)/e;
  long long ff = B/e;
  long long fff = ff-f;
  cout << B-A+1 -(ccc+ddd-fff) << endl;
  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env ruby

n = gets.chomp.to_i

def calc(num)
  r = 0
  (105..num).each do |i|
    a = []
    if (i % 2 == 0)
      next
    end

    (1..num).each do |j|
      if (i % j == 0)
        a << j
      end
    end
    if (a.size == 8)
      r += 1
      a = []
    end
  end
  return r
end

if (n > 105)
  result = calc(n)
elsif (n == 105)
  result = 1
else
  result = 0
end

puts result

Measured memory_bytes: 3836