akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<math.h>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<set>
#include<map>
#define INF 999999
#define EPS 1.0e-6

using namespace std;

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

int x, y, s;

int rate(int a, int r) {
	return floor(a*(100 + r) / 100);
}
int main()
{
	int n;
	cin >> n;
	if (n == 0)cout << 1 << endl;
	if (n == 1)cout << 2 << endl;
	if (n == 2)cout << 1 << endl;
	if (n >= 3)cout << 0 << endl;



	return 0;
}



Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for( int i = 0 ; i < n ; i++ )
typedef long long ll ;
int main() {
  int N ;
  cin >> N ;
  int ans = 1 ;
  map<int,int> mp ;
  mp[N] = 1  ;
  while(1){
    ans++ ;
    if( N % 2 == 1 )N = 3*N+1 ;
    else N /= 2 ;
    mp[N] = mp[N] + 1 ;
    if(mp[N] == 2 ){
      cout << ans << endl;
      return 0 ;
    }
  }
}

Measured memory_bytes: 256
#include <stdbool.h>
#include <stdio.h>
int main() {
	int x, n, p[100];
	bool isEx;
	scanf("%d%d", &x, &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &p[i]);
	}
	for (int i = 0; i < 100; i++) {
		int s = x - i;
		isEx = false;
		for (int j = 0; j < n; j++) {
			if (p[j] == s) {
				isEx = true;
			}
		}
		if (!isEx) {
			printf("%d\n", s);
			break;
		}
		s = x + i;
		isEx = false;
		for (int j = 0; j < n; j++) {
			if (p[j] == s) {
				isEx = true;
			}
		}
		if (!isEx) {
			printf("%d\n", s);
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 1736
#include<iostream>
using namespace std;
int main(){
  int n;
  int a,b;
  cin>>n>>a>>b;
  
  int ans = 0;
  for(int i = 1; i <= n; i++){
    int sum = 0;
    int temp = i;
    while(temp > 0){
      sum += temp % 10;
      temp /= 10;
    }
    if(a <= sum && sum <= b){
      ans += i;
    }
  }
  
  cout<<ans<<endl;
  return(0);
}

Measured memory_bytes: 256
function main()
	S=chomp(readline())
	cnt=zeros(Int,2019)
	a=0
	p=1
	cnt[1]=1
	ans=0
	for i=length(S):-1:1
		a=(a+p*(Int(S[i])-48))%2019
		p=p*10%2019
		ans+=cnt[a+1]
		cnt[a+1]+=1
	end
	println(ans)
end
main()


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

typedef long long int ll;

int main()
{
    ll n, ans = 0;
    string s;
    cin >> n >> s;

    for(ll i = 0;i < 10;i++){
        ll cnt = 0;
        bool f = false;
        char t = '0' + i;
        while(n > cnt){
            if(s[cnt] == t){
                //cout << s[cnt];
                cnt++;
                f = true;
                break;
            }
            cnt++;
        }
        if(f){
            f = false;
            for(ll j = 0;j < 10;j++){
                ll cnt2 = cnt;
                t = '0' + j;
                while(n > cnt2){
                    if(s[cnt2] == t){
                        cnt2++;
                        f = true;
                        break;
                    }
                    cnt2++;
                }
                if(f){
                    for(ll k = 0;k < 10;k++){
                        f = false;
                        ll cnt3 = cnt2;
                        t = '0' + k;
                        while(n > cnt3){
                            if(s[cnt3] == t){
                                f = true;
                                break;
                            }
                            cnt3++;
                        }
                        if(f){
                            ans++;
                        }
                    }
                }
            }
        }
    }

    cout << ans;

    return 0;
}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    OP(min(a, b) + min(c, d));
    return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;
const int N = 1e5 + 5;
int a[N];
int n, p;

int main() {
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        p = a[i] - p;
    }
    p /= 2;
    for (int i = 0; i < n; ++i) {
        cout << p * 2 << ' ';
        p = a[i] - p;
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 4004
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
int main(){
  int a,b;
  cin>>a>>b;
  if(a==b){
    cout<<2*a<<endl;
  }
  else{
    cout<<2*max(a,b)-1<<endl;
  }
}

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

using namespace std;
typedef long long LL;

#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}
}star;
#define DEBUG if(0)
#endif

#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}

class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }};

int main() {
	int N, K;
	while (cin >> N >> K) {
		vector<LL> x(N);
		cin >> x;
		LL ret = 1e18;
		for (int i : range(N - K+1)) {
			LL lb = x[i];
			LL ub = x[i + K - 1];
			if (ub <= 0) {
				chmin(ret, abs(lb));
			}
			else if (lb >= 0) {
				chmin(ret, abs(ub));
			}
			else {
				chmin(ret, 2 * abs(ub) + abs(lb));
				chmin(ret, 2 * abs(lb) + abs(ub));
			}
		}
		cout << ret << endl;
	}

	return 0;
}


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

int main(){
	ll h,w,n;cin>>h>>w>>n;
  	ll res=0,cnt=0;
  	ll a=max(h,w),b=min(h,w);
  	while(res<n and cnt<b){
    	res+=a;cnt++;
    }
  	cout<<cnt<<"\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define dunk(a) cout << (a) << "\n"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<vector<int>> a(10, vector<int>(10));
	rrep(i, n + 1) {
		int b = i % 10;
		int c = i;
		while (c >= 10) {
			c /= 10;
		}
		a[b][c]++;
	}
	int ans = 0;
	rep(i, 10)rep(j, 10) ans += a[i][j] * a[j][i];
	dunk(ans);
	return 0;
}


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

int main()
{
int i;
int A;
int B;
bool bA;
bool bB;
char S[ 10 ];

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

	cin >> S;

	i = S[ 0 ] - '0';
	A = S[ 1 ] - '0';
	A += i * 10;

	i = S[ 2 ] - '0';
	B = S[ 3 ] - '0';
	B += i * 10;

	bA = ( A > 0 && A < 13 );
	bB = ( B > 0 && B < 13 );

	if( bA && bB )
		cout << "AMBIGUOUS" << endl;
	else if( bA )
		cout << "MMYY" << endl;
	else if( bB )
		cout << "YYMM" << endl;
	else
		cout << "NA" << endl;

	return 0;
}


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

#define N 17

int m, n;
int map[N][N];
int dx[] = {1, 0};
int dy[] = {0, 1};
int memo[N][N];

int getWay(int x, int y)
{
	int ret = 0;
	int i;
	
	if (memo[x][y] != -1){
		return (memo[x][y]);
	}
	
	if (x == m - 1 && y == n - 1){
		return (1);
	}
	
	for (i = 0; i < 2; i++){
		int nx = x + dx[i];
		int ny = y + dy[i];
		
		if (nx < m && nx >= 0 && ny < n && ny >= 0){
			if (map[nx][ny] == 1){
				ret += getWay(nx, ny);
			}
		}
	}
	
	return (memo[x][y] = ret);
}

int main(void)
{
	int i, j;
	int num;
	
	scanf("%d%d", &m, &n);
	
	while (m != 0){
		scanf("%d", &num);
		for (i = 0; i < m; i++){
			for (j = 0; j < n; j++){
				map[i][j] = 1;
				memo[i][j] = -1;
			}
		}
		
		for (i = 0; i < num; i++){
			int x, y;
			
			scanf("%d%d", &x, &y);
			map[x - 1][y - 1] = 0;
		}
		
		printf("%d\n", getWay(0, 0));
		scanf("%d%d", &m, &n);
	}
	
	
	return (0);
}

Measured memory_bytes: 600
s=input()
x='keyence'
if s==x:
  print('YES')
  exit()
if s.count(x)>0:
  p=s.split('keyence')
  if p[0]=='' or p[1]=='':
    print('YES')
    exit()
  elif p[0]+p[1]=='keyence':
    print('YES')
    exit()
for i in range(1,len(x)):
  a=x[:i]
  b=x[i:]
  if s.count(a)>0 and (s.index(a)==0 and s[len(s)-len(b):]==b):
    print('YES')
    exit()
  else:
    continue
print('NO')

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

#define rep(i,x,y) for(ll i=(x);i<(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#ifdef LOCAL
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define dassert(...) assert(__VA_ARGS__)
#else
#define dump(x)
#define debug(x)
#define dassert(...)
#endif
//#define int long long

typedef long long ll;
const ll MOD = 1e9 + 7;
const long double EPS = 1e-8;

ll dfs(ll current, vector<int> A, ll N, ll M, long long Q, std::vector<long long> & a, std::vector<long long> & b, std::vector<long long> & c, std::vector<long long> & d) {
    if (!A.empty() && A.back() > M) return 0;
    if (A.size() == N+1) {
        ll answer = 0;
        rep(i,0,Q) {
            if (A[b[i]] - A[a[i]] == c[i]) {
                answer += d[i];
            }
        }
        return answer;
    }
    ll answer = 0;
    rep(i,0,M) {
        A.push_back(current);
        answer = max(answer, dfs(current, A, N, M, Q, a, b, c, d));
        A.pop_back();
        current++;
    }
    return answer;
}

void solve(long long N, long long M, long long Q, std::vector<long long> a, std::vector<long long> b, std::vector<long long> c, std::vector<long long> d){
    cout << dfs(1, {0}, N, M, Q, a, b, c, d) << endl;
}

signed main(){
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    long long Q;
    scanf("%lld",&Q);
    std::vector<long long> a(Q);
    std::vector<long long> b(Q);
    std::vector<long long> c(Q);
    std::vector<long long> d(Q);
    for(int i = 0 ; i < Q ; i++){
        scanf("%lld",&a[i]);
        scanf("%lld",&b[i]);
        scanf("%lld",&c[i]);
        scanf("%lld",&d[i]);
    }
    solve(N, M, Q, std::move(a), std::move(b), std::move(c), std::move(d));
    return 0;
}


Measured memory_bytes: 3684
N, M = map(int, input().split())
MOD = 10**9 + 7
x = list(map(int, input().split()))
y = list(map(int, input().split()))

cumsum_x = [0] * N
cumsum_y = [0] * M
cumsum_x[0] = x[0]
cumsum_y[0] = y[0]
for i, xi in enumerate(x[1:], 1):
  cumsum_x[i] = (cumsum_x[i-1] + xi) % MOD

for i, yi in enumerate(y[1:], 1):
  cumsum_y[i] = (cumsum_y[i-1] + yi) % MOD

X = Y = 0
for i, xi in enumerate(x):
  X += (cumsum_x[-1] - cumsum_x[i] - (N - i - 1)*xi) % MOD
  X %= MOD

for i, yi in enumerate(y):
  Y += (cumsum_y[-1] - cumsum_y[i] - (M - i - 1)*yi) % MOD
  Y %= MOD

print(X*Y % MOD)

Measured memory_bytes: 19964
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int W, H;
		for (;;) {
			H = sc.nextInt();
			W = sc.nextInt();
			if (H == 0)
				break;
			for (int i = 0; i < H; i++) {
				for (int j = 0; j < W; j++) {
					if (i == 0 || j == 0 || i == H - 1 || j == W - 1) {
						System.out.print("#");
					} else {
						System.out.print(".");
					}
				}
				System.out.println();
			}

			System.out.println();
		}
		sc.close();
	}
}



Measured memory_bytes: 32628
n = int(input())
l = [list(map(int,input().split())) for i in range(n)]

for i in range(n):
  if l[i][0] % 2 != (l[i][1]+l[i][2]) % 2:
    print("No")
    exit()
  if l[i][0] < l[i][1]+l[i][2]:
    print("No")
    exit()
  if i > 0 :
    if abs(l[i][0]-l[i-1][0]) < abs(l[i][1]-l[i-1][1])+abs(l[i][2]-l[i-1][2]):
      print("No")
      exit()
print("Yes")

Measured memory_bytes: 27300
n = int(input())
list = []

for i in range(1, n + 1):
    if i % 3 == 0 and i % 5 == 0:
        'FizzBuzz'
    elif i % 3 == 0:
        'Fizz'
    elif i % 5 ==0 :
        'Buzz'
    else:
        list.append(i)

print(sum(list))

Measured memory_bytes: 29908
#include <stdio.h>

int main() {
    int A, B, C;
    scanf("%d %d", &A, &B);
    C=B/2;
    if(A >= 13){
        printf("%d", B);
    }else{
        if(6 <= A){
            printf("%d",C);
        }else{
            printf("0");
        }
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define endl "\n"
#define all(v) (v).begin(),(v).end()
#define sz(v) (v).size()
// #define int long long
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define d0(x) cout<<(x)<<" "
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define d5(a,b,c,d,e) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<endl
#define d6(a,b,c,d,e,f) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<" "<<(f)<<endl
bool desc_sort(const int & lhs,const int & rhs)
{
    return lhs>rhs;
}
bool desc_pii_sort(const pii & lhs , const pii & rhs)
{
    return lhs>rhs;
}
bool second_sort(const pii & lhs , const pii & rhs)
{
    pii a,b;
    a.F = lhs.S;
    a.S = lhs.F;
    b.F = rhs.S;
    b.S = rhs.F;
    return a<b;
}
template<class T> ostream& operator<<(ostream &os, vector<T> V) {
    os << "[ ";
    for(auto v : V) os << v << " ";
    return os << "]";
}
template<class T> ostream& operator<<(ostream &os, set<T> S){
    os << "{ ";
    for(auto s:S) os<<s<<" ";
    return os<<"}";
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
    return os << "(" << P.first << "," << P.second << ")";
}
template<class L, class R> ostream& operator<<(ostream &os, map<L,R> M) {
    os << "{ ";
    for(auto m:M) os<<"("<<m.F<<":"<<m.S<<") ";
    return os<<"}";
}
#define TRACE
#ifdef TRACE
    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cerr << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ',');
        cerr.write(names, comma - names) << " : " << arg1<<" | ";
        __f(comma+1, args...);
    }
#else
    #define trace(...)
#endif


// #define int long long
#define modd 1e0



inline ll fast_expo(ll base,ll power,ll modulo=modd){
    base%=modulo;
    if (base<0LL) base+=modulo;
    ll x=base,cnt=power,ans=1LL;
    while(cnt){
        if (cnt&1LL) ans=(ans*x)%modulo;
        x=(x*x)%modulo;
        cnt>>=1LL;
    }
    // int tmp=ans;
    return ans;
}
inline ll inv(ll base,ll modulo=modd){
    return fast_expo(base,modulo-2LL,modulo);
}



signed main()
{
    #ifdef _SUBLIME
    ifstream cin("input.txt");
    ofstream cout("output.txt");
    #endif
    fio;
    int a;
    cin>>a;
    a = a + a*a + a*a*a;
    d1(a);
    return 0;
}

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

using namespace std;
using LL = long long;

constexpr int N = 3e4;
constexpr int INF = 1e9;

int cache[N];

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

    int H, n;
    cin >> H >> n;
    for (int i = 0; i < N; i++) cache[i] = INF;

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

    cache[0] = 0;
    for (int i = 1; i < N; i++) {
        for (int j = 0; j < n; j++) {
            if (vp[j].first <= i) {
                cache[i] = min(cache[i], cache[i - vp[j].first] + vp[j].second);
            }
        }
    }

    int result = INF;
    for (int i = H; i < N; i++) result = min(result, cache[i]);
    cout << result << endl;
}

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

int main(){
	int n,s=0,k;
	
	cin>>n;
	
	k=n;
	
	do{
		s+=k%10;
		k=k/10;
	}while(k!=0);
	
	if(n%s==0){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

n,q=get_i
s=get_nsp
table=array(n+1,1,0)
flag=false
n.times do|i|
  val=0
  if s[i]=="A"
    flag=true
  elsif flag and s[i]=="C"
    val=1
    flag=false
  else
    flag=false
  end
  table[i+1]=table[i]+val
end
q.times do
  l,r=get_i
  #l-=1
  #r-=1
  puts table[r]-table[l]
end

Measured memory_bytes: 10876
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define INF 10000000000
#define mod 1000000007
#define X 1000000
typedef long long int ll;
ll finv[X];
ll fac[X];
ll inv[X];
ll usort(const void *a, const void *b){return *(ll*)a-*(ll*)b;}
ll dsort(const void *a, const void *b){return *(ll*)b-*(ll*)a;}
ll ssort(const void *a, const void *b){return strcmp((char*)a,(char*)b);}
ll min(ll a,ll b){
  if(a>b)return b;
  return a;
}
ll max(ll a,ll b){
  if(a>b)return a;
  return b;
}
ll z(ll a){return max(a,-a);}
ll gcd(ll a,ll b){if(!b){return a;}else{return gcd(b,a%b);}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
ll kt(ll a){
  ll sum=0;
  while(a){
    a/=10;
    sum++;
  }
  return sum;
}
ll ks(ll a){
  ll sum=0;
  while(a){
    sum+=a%10;
    a/=10;
  }
  return sum;
}
ll nCr(int n,int k){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for (int i=2;i<X;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;
  }
  return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}
int main(void){
  ll a,b;
  scanf("%lld %lld",&a,&b);
  PRL(lcm(a,b));
  return 0;
}


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;


int main() {
    ll N; cin >> N;
    vector<string> S(N);
    REP(i,N){
        cin >> S[i];
        sort(ALL(S[i]));
    }
    sort(ALL(S));

    ll cnt = 0;
    ll ans = 0;
    string str = S[0];
    REP(i,N){
        if(str == S[i]){
            cnt++;
        }else{
            ans += cnt*(cnt-1)/2;
            str = S[i];
            cnt = 1;
        }
    }
    ans += cnt*(cnt-1)/2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6440
x, k, d = map(int, input().split())

if abs(x) > k * d:
  print(abs(x) - k * d)
else:
  y = abs(x) // d
  if (k - y) % 2 == 0:
    print(abs(x) - d * y)
  else:
    print(abs(abs(x) - d * (y + 1)))

Measured memory_bytes: 9104
N, M, X = map(int,input().split())
list = [list(map(int,input().split())) for i in range(N)]

anslis = [1000000000000] * (2**N)

for i in range(2**N):
    kin = 0
    skil = [0] * M
    for j in range(N):
        if((i >> j) & 1):
            kin = kin + list[j][0]
            for k in range(M):
                skil[k] = skil[k] + list[j][k+1]

    if min(skil) >= X:
        anslis[i] = kin

if min(anslis) == 1000000000000:
    print(-1)
else:
    print(min(anslis))

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

using namespace std;

const int N = 1e6 + 6;

vector< int > g[N];
bool used[N];
int a[N], b[N];

int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  memset(used, 0, sizeof used);
  for (int i = 0; i < m; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    u--; v--;
    g[u].push_back(v);
    g[v].push_back(u);
    used[u] = used[v] = 1;
  }
  set< int > st;
  for (int i = 0; i < n; i++) {
    a[i] = i;
    b[i] = N;
    st.insert(i);
  }
  while (!st.empty()) {
    auto it = st.begin();
    int u = *it; st.erase(it);
    for (int v : g[u]) {
      if (b[v] <= a[u] && a[v] <= b[u]) continue;
      b[v] = min(b[v], a[u]);
      a[v] = min(a[v], b[u]);
      st.insert(v);
    }
  }
  long long cnt = 0;
  for (int i = 0; i < n; i++)
    cnt += !used[i];
  long long ans = cnt * (n-cnt) * 2 + cnt * cnt;
  int same = 0, la = 0, lb = 0, all = 0;
  for (int i = 0; i < n; i++) {
    if (!used[i]) continue;
    if (min(a[i], b[i]) == i) all++;
    la += a[i] == i;
    lb += b[i] == i;
  }
  for (int i = 0; i < n; i++) {
    if (!used[i]) continue;
    if (min(a[i], b[i]) != i) continue;
    if (a[i] == b[i]) {
      if (a[i] != i) continue;
      ans += all;
    }
    else {
      if (a[i] < b[i])
        ans += la;
      else
        ans += lb;
    }
  }
  printf("%lld\n", ans);
  return 0;
}

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

vector<int> dp;
vector<vector<int>> edge;

int rec(int v){

  if(dp[v]!=-1){
    return dp[v];
  }

  int ans=0;
  for(auto to:edge[v]){
    ans=max(ans,rec(to)+1);
  }
  return dp[v]=ans;
}

int main(){

  int N,M;
  cin >> N >> M;

  edge=vector<vector<int>>(N);
  dp=vector<int>(N,-1);
  int now,to;
  for(int i=0;i<M;i++){
    cin >> now >> to;now--;to--;
    edge[now].push_back(to);
  }

  int ans = 0;
  for(int i=0;i<N;i++){
    ans = max(ans,rec(i));
  }

  cout << ans << endl;

}

Measured memory_bytes: 8192
N = gets.to_i
A = gets.split.map(&:to_i)

sum = A.inject(&:+)
min = 10 ** 9 * 2 + 1
s = 0

0.upto(N - 2) do |i|
  s = s + A[i]
  a = sum - s
  min = (s - a).abs < min ? (s - a).abs : min
end

puts min

Measured memory_bytes: 17284
import java.util.Scanner;

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

    //input
    int d = sc.nextInt();
    int[] c = new int[26]; //array of decrease
    for(int i = 0; i < c.length; i++){
      c[i] = sc.nextInt();
    }
    int[][] s = new int[d][26]; //two dimensional array of increase
    for(int row = 0; row < s.length; row++){ //day
      for(int col = 0; col < s[row].length; col++){ //contest number
        s[row][col] = sc.nextInt();
      }
    }
    int[] t = new int[d]; //array of contest numbers of the day
    for(int i = 0; i < t.length; i++){
      t[i] = sc.nextInt();
    }

    //output
    int value = 0;
    for(int i = 0; i < t.length; i++){
      int contestNum = t[i]-1;
      int day = i+1;
      value += s[day-1][contestNum]; //increase
      for(int j = 0; j < c.length; j++){
        if( !(j == contestNum) ){
          int daySinceLast = day;
          for(int m = 0; m < i; m++){
            if( j == t[m]-1 ){
              daySinceLast = day-m-1;
            }
          }
          value -= c[j]*(daySinceLast); //decrease (amount of decrease * days since last one)
        }
      }
      System.out.println(value);
    }

  }
}


Measured memory_bytes: 38232
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a, b) ((a < b) ? a : b)
#define _max(a, b) ((a < b) ? b : a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a) ? 1 : -1)
#define SORT(v) sort(v.begin(), v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int main() {
    cout << fixed << setprecision(10);
    int n;
    cin >> n;
    vector<int> a(n);
    REP(i, n) {
        cin >> a[i];
    }
    SORT(a);
    REP(i, n - 1) {
        if(a[i] == a[i + 1]) {
            cout << "NO";
            return 0;
        }
    }
    cout << "YES";
    return 0;
}

Measured memory_bytes: 1024
n = int(input())
c = [0] * n
d = [0] * n
for i in range(n):
  c[i],d[i] = map(int,input().split())
f = 0

for i in range(n-2):
  if c[i] == d[i] and c[i+1] == d[i+1] and c[i+2] == d[i+2]:
    f = 1
if f == 0:
  print('No')
else:
  print('Yes')

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

int main(){
    string number;
    cin>>number;
    if(number[0]==number[1] and number[0]==number[2])
        cout<<"Yes"<<endl;
    else if(number[1]==number[2] and number[1]==number[3])
        cout<<"Yes"<<endl;
    else  cout<<"No"<<endl;
    return 0;
}


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

int n,p[15],q[15],a[15],cnt,c1,c2,vis[15];

void dfs(int x)
{
	if(x==n+1) {
		cnt++;
		int f=0,g=0;
		for(int i=1;i<=n;++i) {
			if(a[i]==p[i]) f++;
			if(a[i]==q[i]) g++;
		}
		if(f==n) c1=cnt;
		if(g==n) c2=cnt;
		return ;
	}
	for(int i=1;i<=n;++i) {
		if(!vis[i]) {
			a[x]=i;
			vis[i]=1;
			dfs(x+1);
			vis[i]=0;
		}
	}
}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i) scanf("%d",p+i);
	for(int i=1;i<=n;++i) scanf("%d",q+i);
	dfs(1);
	printf("%d",abs(c1-c2));
}

Measured memory_bytes: 256
#include <iostream>

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

    int a, b, c;
    std::cin >> a >> b >> c;
    std::cout << (a < b ? (b < c ? a + b : a + c) : (a < c ? b + a : b + c)) << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <numeric>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
long long int F, H, I, J, K, L, M, N, S, T;

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

	vector<string> sv(3);
	cin >> sv[0] >> sv[1] >> sv[2];

	int current = 0;
	while (true) {
		if (sv[current].length() == 0) {
			cout << char('A' + current) << endl;
			return 0;
		}
		int next = sv[current][0] - 'a';
		sv[current] = sv[current].substr(1);
		current = next;
	}
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int zero = 0;
        int ichi = 0;
        for(int i = 0; i < s.length(); i++) {
            if(s.charAt(i) == '0') zero++;
            else ichi++;
        }
        int res = 2 * Math.min(zero, ichi);
        System.out.println(res);
    }
}


Measured memory_bytes: 39484
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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;
}

int main() {
  int x;
  cin >> x;
  if (x < 1200)
    cout << "ABC" << endl;
  else
    cout << "ARC" << endl;
}

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

int sch(long i,long Min,long Max){
	if(Min <= i && i <= Max){
		return 1;
	}else{
		cout << i << endl;
		exit(1);
		//return 0;
	}
}

int main(){
	
	int a;
	string s,t,u;
	int i,j,k;
	
	cin >> a;
	sch(a,1,100);
	
	cin >> s >> t;
	
	if(s.length() != a)exit(1);
	if(t.length() != a)exit(1);
	
	for(i=0;i<a;i++){
		
		cout << s[i] << t[i];
	}
		
	cout << endl;

	
return 0;
}


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

using namespace std;

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

    int n;
    cin >> n;
    int mx = -1e9, sum = 0;
    for(int i = 0; i < n; i++)
    {
        int p;
        cin >> p;
        mx = max(mx, p);
        sum += p;
    }
    sum -= mx / 2;

    cout << sum;

    return 0;
}


Measured memory_bytes: 256
S = input()
A = int(S[:2])
B = int(S[2:])
flag1 = 1 <= A and A <= 12
flag2 = 1 <= B and B <= 12
if flag1:
	if flag2:
		print('AMBIGUOUS')
	else:
		print('MMYY')
else:
	if flag2:
		print('YYMM')
	else:
		print('NA')

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

public class Main{
    static MyReader in = new MyReader();
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args){
        int N, K;
        {int[] a = in.ii(); N = a[0]; K = a[1];}
        int[] D = in.ii();
        ArrayList<Integer> list = new ArrayList<>();
        for(int i = 0; i < 10; i++)
            list.add(i);
        for(int i = 0; i < K; i++)
            list.remove(Collections.binarySearch(list, D[i]));

        loop: for(int i = N; i <= 10*N; i++){
            for(int j = i; j > 0; j /= 10)
                if(Collections.binarySearch(list, j%10) < 0)
                    continue loop;
            out.print(i);
            out.flush();
            return;
        }          
    }  

    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }

        String s(){
            try{return readLine();}catch(IOException e){return "";}
        }

        String[] ss(){
            return s().split(" ");
        }

        int i(){
            return Integer.parseInt(s());
        }

        int[] ii(){
            String[] ss = ss();
            int[] ii = new int[ss.length];
            for(int j = 0; j < ss.length; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }

        long l(){
            return Long.parseLong(s());
        }

        long[] ll(){
            String[] ss = ss();
            long[] ll = new long[ss.length];
            for(int j = 0; j < ss.length; j++) ll[j] = Long.parseLong(ss[j]);
            return ll;
        }
    }
}


Measured memory_bytes: 21460
import java.util.*;

 // Compiler version JDK 11.0.2

 public class Main
 {
   public static void main(String args[])
   { 
    Scanner sc= new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int d = sc.nextInt();
    
    
    while(a>0 && c>0)
    {
      
      c=c-b;
      if(c>0)
      
      a=a-d;
      
      
    }
    if(a>0)
    System.out.println("Yes");
    else
    System.out.println("No");
   }
 }


Measured memory_bytes: 35780
#define _USE_MATH_DEFINES 
#include <iomanip> 
#include <cmath>  
#include<iostream>
#include <fstream>
#include<vector>
#include<algorithm>
#include<bitset>
#include<map>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl

int n, m, k, p = 1;

int main() {
	cin >> n >> m;
	k = 1900 * m + 100 * (n - m);
	repi(i, 0, m) p *= 2;
	wrln(k*p);
	return 0;
}

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

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

    for (int x=1; x<=10000; ++x) {
        int a = x * 8 / 100;
        int b = x * 10 / 100;
        if (a == A and b == B) {
            cout << x << endl;
            return 0;
        }
    }

    puts("-1");
}

Measured memory_bytes: 256
import java.io.*;

class Main
{
    public static void main (String[ ] args) throws Exception
    {
        BufferedReader br = new BufferedReader (new InputStreamReader (System.in));
        //StringBuffer sb = new StringBuffer();
        
        String[] strAry = (br.readLine()).split(" ");
        int a = Integer.parseInt(strAry[0]);
        int b = Integer.parseInt(strAry[1]);
        int c = Integer.parseInt(strAry[2]);
        
        int cnt = 0;
        for(int i = a; i <= b; i++)
        {
            if(0 == (c % i))
            {
                cnt++;
            }
        }
        System.out.println(cnt);
    }
}

Measured memory_bytes: 24296
//
/*==========================================================*/
/*    Template ver 2017-0720    |    Created by JollyBee    */
/* DOMINUS pascit me, et nihil mihi deerit (Psalmorum 23:1) */
/*==========================================================*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
const double EPS=(double)1e-9;
const double PI=(double)acos(-1.0);
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define FOR(i,n) for(int i=0;i<n;i++)
#define REPP(i,l,r,c) for(int i=l;i<=r;i+=c)
#define REP(i,l,r) REPP(i,l,r,1)
#define FORD(i,n) for(int i=n-1;i>=0;i--)
#define REVV(i,l,r,c) for(int i=l;i>=r;i-=c)
#define REV(i,l,r) REVV(i,l,r,1)
//random
int irand(int lo, int hi){
    return (((double)rand())/(RAND_MAX+1.0)) * (hi-lo+1) + lo;
}
//ll to string
string toString(ll x) {
    stringstream ss;
    ss << x;
    return ss.str();
}
//string to ll
ll toNumber(string S) {
    ll ret;
    sscanf(S.c_str(),"%lld",&ret);
    return ret;
}
// std::fill(start, end, value);
// for(auto it: DS){}

const int INF=(int)2e9;
const ll MOD=(ll)1e9+7;
/*==========================================================*/
/*                     END OF TEMPLATE                      */
/* DOMINUS pascit me, et nihil mihi deerit (Psalmorum 23:1) */
/*==========================================================*/

int main(){
    int n,x; scanf("%d %d", &n, &x);
    int res = -1;
    REP(i,1,n){
    	int a; scanf("%d", &a);
    	int diff = abs(a-x);
    	if(res == -1) res = diff;
    	res = __gcd(res, diff);
    }
    printf("%d\n", res);
    return 0;
}

Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<cstdio>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<utility>
#include<algorithm>
#include<cstring>
#include<sstream>
#include <iomanip>

using namespace std;

typedef long long ll ;
typedef double db;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector< pair<int,int> > vii;
const double pi = 2*acos(0) ;

#define pf		  	printf
#define sf			  scanf
#define pb(a)         push_back(a)
#define mp			make_pair
#define fi			 first
#define se			 second
#define for0(i,n)        for(int i=0;i<n;i++)
#define for1(i,n)        for(int i=1;i<=n;i++)
#define forab(i,a,b)       for(int i=a;i<=b;i++)
#define lcm(a, b)     ((a)*((b)/gcd(a,b)))
#define sq(a)		   (a)*(a)
#define nw				"\n"
#define abs(x)		fabs(x)
#define pcase(z,x)    cout<<"Case "<<z<<": "<<x<<"\n"
bool is_prime(int n){
	if(n==2) return 1;
	if(n%2==0) return 0;
	for(int i=3 ; i*i<=n ; i+=2){
		if(n%i==0) return 0;
		}
	return 1;
	}
int main()
{
	int n,i,x;
	cin>>n;
	for(i=n ; ; i++){
		if(is_prime(i)){
			x=i;
			break;
			}
		}
	cout<<x<<nw;
	
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define pii pair<int, int>
#define pll pair<long long, long long>
const double PI = acos(-1);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    ll N,A,B,C,D; cin >> N >> A >> B >> C >> D;

    B -= A;
    ll c = -(N-1LL)*C;
    ll d = -(N-1LL)*D;
    bool ok = false;
    rep(i,N) {
        if (c >= B && B >= d) ok = true;
        c += C+D;
        d += C+D;
    }

    cout << (ok ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string.h>
#include<queue>
#include<utility>
#include<algorithm>
#include<math.h>
using namespace std;
int N,d[100005]={0};
int main(){
	cin>>N;
	if(N%2==1){
		cout<<0;
		return 0;
	}
	for(int i=0;i<N;i++){
		scanf("%d",&d[i]);
	}
	sort(d,d+N);
	/*for(int i=0;i<N;i++){
		printf("%d",d[i]);
	}*/
	int ans=d[N/2]-d[N/2-1];
	cout<<ans;
	return 0;
}

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

#define MAX 1024

int LCS[MAX][MAX];

int solve(string s1,string s2){
  if(s1.length() > s2.length())
	swap(s1,s2);
  for(int i=1;i<=s1.length();i++){
    for(int j=1;j<=s2.length();j++){
      if(s1[i-1]==s2[j-1])
	LCS[i][j]=LCS[i-1][j-1]+1;
      else
	LCS[i][j]=max(LCS[i][j-1],LCS[i-1][j]);
    }
  }
  return LCS[s1.length()][s2.length()];
}


int main(){
  string s1, s2;
  int n;
  cin >> n;
  for(int i=0;i<n;i++){
    for(int i=0;i<MAX;i++){
      for(int j=0;j<MAX;j++){
        LCS[i][j] = 0;
      }
    }
    cin>>s1>>s2;
    cout<<solve(s1,s2)<<endl;
    /*
    for(int i=0;i<=s1.length();i++){
      for(int j=0;j<=s2.length();j++){
	cout << LCS[i][j] << "  " ;
      }
      cout << endl;
    }*/
  }

}

Measured memory_bytes: 5312
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
import itertools

kouho = list(itertools.permutations([a, b, c, d, e]))
ans = 10 ** 6
for k in kouho:
    temp = 0
    for t in range(5):
        amari = k[t] % 10
        if amari != 0 and t != 4:
            temp += 10 - amari
        temp += k[t]
    ans = min(ans, temp)
print(ans)


Measured memory_bytes: 9196
#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

long long int gcd(long long int a, long long int b){
	if(b == 0)return a;
	return gcd(b,a % b);
}

long long int lcm(long long int a, long long int b){
	return a * b / gcd(a,b);
}

int main(){
	int a[3], m[3], p[3] = {1,1,1}, c[3] = {0};
	while(1){
		memset(c,0,sizeof(c));
		scanf("%d%d%d%d%d%d",a,m,a+1,m+1,a+2,m+2);
		//cin >> a[0] >> m[0] >> a[1] >> m[1] >> a[2] >> m[2];
		if(!a[0])break;
		for(int i=0;i<3;i++){
			do{
			p[i] = a[i] * p[i] % m[i];
			c[i]++;
			}while(p[i] != 1);
		}
		cout << lcm(lcm(c[0],c[1]),c[2]) << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>

using namespace std;

const int LIM = 501;

string f[LIM];
string b[LIM];
string r[LIM];

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

  int h, w;
  cin >> h >> w;
  for (int i = 0; i < h; ++i)
    cin >> f[i];

  bool type = false;
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      if (!type)
        b[i] += '#';
      else
        b[i] += '.';
    }
    b[i][0] = '.';
    if (type)
      b[i][w - 1] = '#';
    for (int j = 0; j < w; ++j)
      if (f[i][j] == '#')
        b[i][j] = '#';
    type ^= true;
  }

  type = false;
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      if (!type)
        r[i] += '.';
      else
        r[i] += '#';
    }
    r[i][w - 1] = '.';
    if (!type)
      r[i][0] = '#';
    for (int j = 0; j < w; ++j)
      if (f[i][j] == '#')
        r[i][j] = '#';
    type ^= true;
  }

  for (int i = 0; i < h; ++i)
    cout << r[i] << '\n';
  cout << '\n';
  for (int i = 0; i < h; ++i)
    cout << b[i] << '\n';
  cout << endl;

  return 0;
}


Measured memory_bytes: 1536
# -*- coding: utf-8 -*-
from heapq import heappop, heappush
def inpl(): return list(map(int, input().split()))
INF = float("inf")
N = int(input())
G = []
for _ in range(N):
    I = inpl()
    G.append(zip(*[I[3::2], I[2::2]]))

def dijkstra(G):
    C = [INF]*(N)
    C[0] = 0
    visited = [False] * (N)
    Q = [[0, 0]]

    while Q:
        c, u = heappop(Q)
        if C[u] < c:
            continue
        visited[u] = True
        for d, v in G[u]:
            if visited[v]:
                continue
            e = c + d
            if e < C[v]:
                C[v] = e
                heappush(Q, [e, v])
    return C

for i, c in enumerate(dijkstra(G)):
    print(i, c)


Measured memory_bytes: 40248
#include <bits/stdc++.h>
#include <cstdio>
#include <cstdlib>

#ifdef _MSC_VER
#include <Windows.h>
#else
#include <unistd.h>
#endif

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();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD=(double)1e9+7;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))


int main(){
    int N;
    cin>>N;
    int cnt=0;
    int sum1=0,sum2=0;
    vector<int>p;
    REP(i,N){
        int a;
        cin>>a;
        if(a%10!=0){
            p.PB(a);
            sum2+=a;
            cnt++;
        }else{
            sum1+=a;
        }
    }
    SORT(p);

    if(cnt==0){
        cout<<0<<endl;
    }else if(sum2%10==0){
        cout<<sum1+sum2-p[0]<<endl;
    }else{
        cout<<sum1+sum2<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
Uses math;
var
	n,i,z,w,a,b:Longint;
begin
	read(n,z,w);
	if n=1 then begin
		read(b);
		writeln(abs(b-w));
		exit;
	end;
	for i:=1 to n-2 do read(a);
	read(a,b);
	writeln(Max(abs(b-w),abs(a-b)));
end.



Measured memory_bytes: 128
//#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

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

#define debug(s) cout << #s << " = " << s << endl
#define all(v) (v).begin(), (v).end()
#define KeepUnique(v) (v).erase( unique(all(v)), v.end() )
#define MEMSET(a, val) memset(a, val, sizeof (a))
#define PB push_back
#define endl '\n'
typedef long long ll;

inline int myrand(int l, int r) {
	int ret = rand(); ret <<= 15; ret ^= rand();
	if(ret < 0) ret = -ret; ret %= (r-l+1); ret += l;
	return ret;
}

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

typedef pair<int, int> ii;

template<typename T> using min_pq =
	std::priority_queue<T, vector<T>, greater<T> >;

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

int32_t main () {
	// freopen("in", "r", stdin);
    int n, k;
    cin >> n >> k;
    vector<int> v(n);
    for(int &b : v) cin >> b;
    vector<int> L, R;
	for(int i = 0; i < n; i++)
		if(v[i] >= 0) R.emplace_back(v[i]);
	for(int i = n - 1; i >= 0; i--)
		if(v[i] < 0) L.emplace_back(-v[i]);
	if(L.size() == 0) {
		cout << R[k - 1] << endl;
	} else if(R.size() == 0) {
		cout << L[k - 1] << endl;
	} else {
		// for(int b : L) cout << b << ' '; cout << endl;
		// for(int b : R) cout << b << ' '; cout << endl;
		int mn = 1e9;
		if(L.size() >= k) mn = min(mn, L[k - 1]);
		if(R.size() >= k) mn = min(mn, R[k - 1]);
		for(int Left = 1, Right = k - 1; Left < k; Left++, Right--) {
			if(L.size() < Left or R.size() < Right) continue;
			mn = min({mn, 2 * L[Left - 1] + R[Right - 1], 2 * R[Right - 1] + L[Left - 1]});
		} cout << mn << endl;
	}
}

Measured memory_bytes: 1404
#include<stdio.h>

#define MAX 100000


int partition(int A[], int p, int r){
  int x, i, j, t;
  x = A[r];
  i = p - 1;
  for( j = p ; j < r ; j++ ){
    if( A[j] <= x ){
      i++;
      t = A[i];
      A[i] = A[j];
      A[j] = t;
    }
  }
  t = A[i+1];
  A[i+1] = A[r];
  A[r] = t;
  return i + 1;
}

int main(){
  int A[MAX], i, q, n;

  scanf("%d", &n);
  for( i = 0 ; i < n ; i++){
    scanf("%d", &A[i]);
  }
  q = partition(A, 0, n-1);

  for( i = 0 ; i < n ; i++){
    if(i) printf(" ");
    if(i == q) printf("[");

    printf("%d", A[i]);

    if(i == q) printf("]");
  }
  printf("\n");
  return 0;
}



Measured memory_bytes: 2088
#include<iostream>
#include<algorithm>
#include<cstdlib>
using namespace std;

int main(){
  int c1, c2, c3, d1, d2;
  cin >> c1 >> c2 >> c3;
  d1 = c2 -c1; d2 = c3 - c2;
  for(int i = 1; i < 3; i++){
    cin >> c1 >> c2 >> c3;
    if(d1 != (c2 - c1) || d2 != (c3 - c2)){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<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); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

    ll n, d;
    cin >> n >> d;
    vector<vector<ll>> x(n, vector<ll>(d));
    REP(i, n) REP(j, d) cin >> x[i][j];

    ll ans = 0;
    REP(i, n) FOR(j, i+1, n) {
        double diff = 0;
        REP(k, d) {
            diff += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
        }
        // cout << diff << endl;
        diff = sqrt(diff);
        if((ll)diff == diff) {
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256