akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int mod = pow(10, 9) + 7;
//const int mod = 998244353;
//const int mod = ;
const int INF = 1LL << 60;
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string abc = "abcdefghijklmnopqrstuvwxyz";
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}

signed main()
{
  int A, B;
  cin >> A >> B;
  
  int ans;
  if (A <= 5) ans = 0;
  else if (A <= 12) ans = B / 2;
  else ans = B;
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <utility>
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#include <climits>
#define REP(i,n) for(int i=0;i<n;i++)
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
using namespace std;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
ll gcd(ll a, ll b){return b? gcd(b, a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main() {
	cin.tie(0);
  ios::sync_with_stdio(false);
  int myints[] = {0, 1, 2, 3,4,5,6,7,8,9};
  int D, G;
  int p[D], c[D], all[D];
  cin >> D >> G;
  for(int i = 0; i < D; i++){
    cin >> p[i] >> c[i];
  }
  int ans = 1001;
  do{
    int currentScore = 0;
    int numSolved = 0;
    for(int i = 0; i < D; i++){
      if(myints[i] >= D){
        continue;
      }
      if((G-currentScore) >= (myints[i]+1)*100 * p[myints[i]]){
        currentScore += (myints[i]+1)*100 * p[myints[i]];
        numSolved += p[myints[i]];
      }else{
      for(int j = 0; j < p[myints[i]]; j++){
        currentScore += (myints[i]+1)*100;
        numSolved++;
        if(currentScore >= G){
          if(numSolved < ans){
            ans = numSolved;
          }
          break;
        }
      }}
      
      currentScore += c[myints[i]];
      if(currentScore >= G){
        if(numSolved < ans){
          ans = numSolved;
        }
      }

    }
  }while (next_permutation(myints, myints+10));

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2304
#include "bits/stdc++.h"
using namespace std;

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

int main() {
	int H, W; cin >> H >> W;
	vector<vector<int>>field(H, vector<int>(W));
	vector<vector<int>>froms(H, vector<int>(W,-2));
	vector<pair<int, int>>coords(H*W);
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			int a; cin >> a; a--;
			field[i][j] = a;
			coords[a] = make_pair(j,i);
		}
	}
	int ans = 0;
	for (int i = 0; i < H*W; ++i) {
		int nx = coords[i].first;
		int ny = coords[i].second;
		if (froms[ny][nx] == -2) {
			froms[ny][nx] = i;
		}
		else if (froms[ny][nx] == -1) {
			ans++;
		}
		for (int way = 0; way < 4; ++way) {
			int nextx = nx + dx[way];
			int nexty = ny + dy[way];
			if (nextx >= 0 && nextx < W&&nexty >= 0 && nexty < H) {
				if (froms[nexty][nextx] == -2) {
					froms[nexty][nextx] = froms[ny][nx];
				}
				else if (froms[nexty][nextx] == -1) {
					continue;
				}
				else if (froms[nexty][nextx] == froms[ny][nx]) {
					continue;
				}
				else {
					froms[nexty][nextx] = -1;
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 18652
import copy as cp

n = int(input())
A = list()
for i in range(n):
    A.append(int(input()))

count = 0
#print(A)
def insertionsort(A,n,g):
    global count
    for i in range(g,n):
        v = A[i]
        j = i-g
        while (j >= 0 and A[j] > v):
            A[j+g] = A[j]
            A[j] = v
            j = j - g
            v = A[j+g]
            count += 1

#decision of m and g
G = list()
G.append(int(1))
i = 0
while (G[i] <= n):
    G.append(3*G[i] + 1)
    i += 1
del G[-1]
G.reverse()
m = len(G)
#print(G,m)


#shellsort

for i in range(m):
    insertionsort(A,n,G[i])

#output
print(m)
for k in range(m-1):
    print(str(G[k])+" ",end = "")
print(str(G[m-1]))
print(count)
for k in range(n):
    print(str(A[k]))



Measured memory_bytes: 46056
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define REP1(i, n) for (int i = 1; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; 0 <= i; i--)
#define CIN(A) int A; cin >> A;
#define CIN2(A, B) int A, B; cin >> A >> B;
#define CIN3(A, B, C) int A, B, C; cin >> A >> B >> C;
#define CINVEC(A, N) vector<int> A(N); REP(i, N) cin >> A[i]
#define ANS(ans) cout << (ans) << endl
#define SORT(V) sort(V.begin(), V.end())
#define RSORT(V) sort(V.rbegin(), V.rend())

#define DEBUGV(V) REP(i, V.size()) cout << V.at(i) << " "; cout << endl 

int
main()
{
  ull N; cin >> N;
  vector<ull> T(5); REP(i, 5) cin >> T[i];

  ull neck = 1e15+1;
  REP(i, 5) {
    if (neck > T[i]) neck = T[i];
  }

  ull ans;
  if (N % neck) ans = N / neck + 5;
  else ans = N / neck + 4;

  ANS(ans);

  return 0;
}
/*
  5
  3 2 4 3 5
 */


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int M;
  cin >> N >> M;
  vector<int> X(M);
  for (int i = 0; i < M; i++) {
  cin >> X.at(i);
  }
  std::sort( X.begin(), X.end() );
  //sort of X
  vector<int> difX(M-1);
  for (int i = 0; i < M - 1; i++) {
  difX.at(i) = X.at(i+1) - X.at(i);
  }
  std::sort( difX.begin(), difX.end() );
  int Time = 0;
  for ( int i = 0; i < M - N; i++) {
    Time += difX.at(i);
  }
  cout << Time << endl;
}

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

#define int long long
const int _ = 2e5 + 7;
struct node{
	int cnt0 , cnt1 , inv;
	friend bool operator <(node x , node y){return x.cnt1 * y.cnt0 < x.cnt0 * y.cnt1;}
	friend node operator +(node x , node y){
		return (node){x.cnt0 + y.cnt0 , x.cnt1 + y.cnt1 , x.inv + y.inv + x.cnt1 * y.cnt0};
	}
}now[_]; int N , fa[_] , pre[_];
int find(int x){return fa[x] == x ? x : (fa[x] = find(fa[x]));}
set < pair < node , int > > mn;

signed main(){
	cin >> N; for(int i = 2 ; i <= N ; ++i) cin >> pre[i];
	for(int i = 1 , x ; i <= N ; ++i){
		fa[i] = i; cin >> x; x == 1 ? ++now[i].cnt1 : ++now[i].cnt0;
		if(i != 1) mn.insert(make_pair(now[i] , i));
	}
	while(mn.size()){
		int t = mn.begin()->second; mn.erase(mn.begin()); int cur = find(pre[t]);
		if(cur != 1) mn.erase(make_pair(now[cur] , cur));
		now[cur] = now[cur] + now[t]; fa[t] = cur;
		if(cur != 1) mn.insert(make_pair(now[cur] , cur));
	}
	cout << now[1].inv << endl; return 0;
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n;

int f(int x) {
	int v = 0;
	while(x) { v += x % 10; x /= 10; }
	return v;
}

int main() {
	cin >> n;
	
	cout << (n % f(n) == 0 ? "Yes" : "No") << endl;
	
	return 0;
}


Measured memory_bytes: 256
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N = int(input())
S = input().rstrip()

ans,x = 0,0
for s in S:
    if s == "I":
        x += 1
    else:
        x -= 1
    ans = max(ans,x)

print(ans)

Measured memory_bytes: 3060
#include<stdio.h>

int main() {
    
	int x, y, res;
    
	char s[20];
    
	scanf("%d %d", &x, &y);
    
	res = x * (x - 1) + y * (y - 1);
    
	res /= 2;
    
	printf("%d\n", res);
    
	return 0;
}

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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, a, b;
    cin >> n >> a >> b;
    if (a == 1) {
        if (n == b) {
            vector<int> ans(n);
            for (int i = 0; i < n; i++) ans[i] = n - i;
            cout << ans[0];
            for (int i = 1; i < n; i++) cout << " " << ans[i];
            cout << endl;
        } else {
            cout << -1 << endl;
        }
    } else if (b == 1) {
        if (n == a) {
            vector<int> ans(n);
            for (int i = 0; i < n; i++) ans[i] = i + 1;
            cout << ans[0];
            for (int i = 1; i < n; i++) cout << " " << ans[i];
            cout << endl;            
        } else {
            cout << -1 << endl;
        }
    } else if (n <= a || n <= b) {
        cout << -1 << endl;
    } else {
        vector<int> ans(n);
        if (a <= b) {
            for (int i = 0; i < a; i++) ans[i] = n - a + i + 1;
            int lim = n - a + 1;
            if (b < 2 || b > lim || (n - a + b - 2) / (b - 1) > a) cout << -1 << endl;
            else {
                int idx = a, cnt = 1;
                while (idx < n) {
                    for (int i = 0; i < b - 1; i++) {
                        ans[idx] = min((b - 1) * cnt - i, n - a - i);
                        idx++;
                        if (idx == n) break;
                    }
                    cnt++;
                }
                cout << ans[0];
                for (int i = 1; i < n; i++) cout << " " << ans[i];
                cout << endl;             
            }
        } else {
            for (int i = 0; i < b; i++) ans[i] = b - i;
            int lim = n - b + 1;
            if (a < 2 || a > lim || (n - b + a - 2) / (a - 1) > b) cout << -1 << endl;
            else {
                int idx = b, cnt = 1;
                while (idx < n) {
                    for (int i = 0; i < a - 1; i++) {
                        ans[idx] = max(n - (a - 1) * cnt + i + 1, b + 1 + i);
                        idx++;
                        if (idx == n) break;
                    }
                    cnt++;
                }
                cout << ans[0];
                for (int i = 1; i < n; i++) cout << " " << ans[i];
                cout << endl;             
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include<vector>
#include <utility>
#include <string>

using namespace std;

int main(){
  int n,b,c,i,j,k,x;
  string s;
  cin >> n;
  long long a[n],y[n];
  for(i=0;i<n;i++){
    cin >> a[i];
    y[i]=a[i];
  }
  sort(a,a+n);
  x = a[(n+1)/2-1];
  for(i=0;i<n;i++){
    if(y[i]>x)cout << x << endl;
    else cout << a[(n+1)/2] << endl;
  }
  return 0;
}


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

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    
    int ans;
    ans = min(b, d) - max(a, c);
    if (ans < 0) {
        ans = 0;
    }
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(int)(a); i++)
typedef long long ll;
const ll mod = 1000000007;

struct UnionFind {
  vector<int> par;
  vector<int> rank;
  vector<int> siz;
  UnionFind(int n=1) {
    init(n);
  }
  void init(int n=1) {
    par.resize(n); rank.resize(n); siz.resize(n);
    for (int i=0; i<n; i++) par[i]=i, rank[i]=0;
    for (int i=0; i<n; i++) siz[i]=1;
  }
  int root(int x) {
    if (par[x] == x) return x;
    else {
      int r = root(par[x]);
      return par[x] = r;
    }
  }
  bool issame(int x, int y) {
    return root(x) == root(y);
  }
  bool merge(int x, int y) {
    x = root(x); y = root(y);
    if (x == y) return false;
    if (siz[x] < siz[y]) swap(x, y);
    if (rank[x] == rank[y]) rank[x]++;
    par[y] = x;
    siz[x] += siz[y];
    return true;
  }
  int size(int x) {
    return siz[root(x)];
  }
};

int main()
{
  int n, m; cin >> n >> m;
  vector<int> p(n);
  rep(i, n) {
    cin >> p[i]; p[i]--;
  }
  vector<int> x(m);
  vector<int> y(m);
  UnionFind uf = UnionFind(n);
  rep(i, m) {
    int x, y; cin >> x >> y; x--; y--;
    uf.merge(x, y);
  }
  int ans = 0;
  rep(i, n) {
    if (uf.issame(i, p[i])) ans++;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define vll vector<ll>
#define mod(n) (n) % 1000000007
#define sp << " "
#define precision(n) cout << fixed << setprecision(n);
#define startTime time_t start, end;time(&start);
#define endTime time(&end);double tt = double(end-start);cout<<"Time taken : "<<fixed<<tt<<setprecision(5);cout <<" sec"<< endl;
 
using namespace std;
 
int main() { 
    IOS;
    ll n, k;
    cin >> n >> k;
    vll a(n, 0);
    for (int i = 0; i < n; i++) {
    	cin >> a[i];
    }
    vector<bool> dp(k + 1, false);
    for (int i = 1; i < k + 1; i++) {
    	for (int j = 0; j < n; j++) {
    		if (i >= a[j]) dp[i] = dp[i] || !dp[i - a[j]];
    	}
    }
    if (dp[k]) cout << "First" << endl;
    else cout << "Second" << endl;
}

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

int main(){
  int turns;
  int alice = 0, bob = 0;
  int max = 0;
    cin >> turns;
  vector<int> cards(turns);

  for(int i = 0; i < turns; i++){
    cin >> cards.at(i);
  }
  for(int j = 0; j < turns; j++){
    for(int i = 0; i < turns; i++){
      if(max < cards.at(i))
        max = cards.at(i);
    }
    for(int i = 0; i < turns; i++){
      if(max == cards.at(i)){
         cards.at(i) = -1;
         break;
      }
    }
    alice += max;
    max = 0;
    for(int i = 0; i < turns; i++){
      if(max < cards.at(i))
        max = cards.at(i);
    }
    for(int i = 0; i < turns; i++){
      if(max == cards.at(i)){
         cards.at(i) = -1;
         break;
      }
    }
    bob += max;
    max = 0;
  }
  cout << alice - bob << endl;
}

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

int ncr(int n,int r){ int res=1; if(r>n-r)r=n-r; for(int i=0;i<r;i++) {  res*=n-i;  res/=i+1; } return res; }

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin>>t;
    while(t--){
       int n;
       cin>>n;
       int arr[n];
       for(int i=0;i<n;i++){
           cin>>arr[i];
       }
       int maxh=0;int count=0;
       for(int i=0;i<n;i++){
           if(maxh<=arr[i]){
               maxh=arr[i];
               count++;
           }
       }
       cout<<count;
    }
}
    

Measured memory_bytes: 256
#include <stdio.h>

#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

#define N 200010
#define MAX 1000000000000000000

#include <stdio.h>

int main (void) {
    int s, w;

    scanf("%d %d", &s, &w);

    if (w >= s) puts("unsafe");
    else puts("safe");

    return 0;
}



Measured memory_bytes: 1632
import java.util.*;


import java.io.*;
 
public class Main {
	private static void solve(){
		//Implement solution here.
		int a = ni();
		String s = next();
		System.out.println(a >= 3200 ? s:"red");
	}
	
	//Switch input source (stdin/file)
	private static BufferedReader br  = new BufferedReader(new InputStreamReader(System.in));
	public static void main(String[] args){
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		} 
		solve();
	}
 
	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

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

int main() {

  int N;
  cin >> N;
  
  for (int i = 0; i < N; i++) {
    string S;
    cin >> S;
    if (S == "Y") {
      cout << "Four" << endl;
      break;
    }
    else if (i == N - 1) {
      cout << "Three" << endl;
    }
  }
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <math.h>
#include <climits>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <map> 
#include <set>
#include <string>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
const ll MD = 1000000007;

/* sample input

*/

int main()
{
	int n;
	ll *a[300];
	ll sum = 0;
	ll answer = 0;
	cin>>n;

	for (int i = 0; i < 300; i++) {
		a[i] = new ll[n];
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> a[i][j];
			sum += a[i][j];
		}
	}
	sum /= 2;
	answer = sum;

	//case1 NG
	//for (int k = 0; k < n; k++) {
	//	for (int i = 0; i < n; i++) {
	//		for (int j = i+1; j < n; j++) {
	//			if (a[i][j] > a[i][k] + a[k][j]) {
	//				cout << -1;
	//				return 0;
	//			}
	//			else if (a[i][j] == a[i][k] + a[k][j]&&i!=k&&k!=j) {
	//				answer -= a[i][j];
	//			}
	//		}
	//	}
	//}

	//case1 mod 
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
				for (int k = 0; k < n; k++) {
					if (a[i][j] > a[i][k] + a[k][j]) {
					cout << -1;
					return 0;
				}
				else if (a[i][j] == a[i][k] + a[k][j] && i != k&&k != j) {
					answer -= a[i][j];
					break;
				}
			}
		}
	}

	//case2 OK
	//answer = 0;
	//for (int i = 0; i < n; i++) {
	//	for (int j = i + 1; j < n; j++) {
	//		bool flug = true;
	//		for (int k = 0; k < n; k++) {
	//				if (a[i][j] > a[i][k] + a[k][j]) {
	//				cout << -1;
	//				return 0;
	//			}
	//			else if (a[i][j] == a[i][k] + a[k][j] && i != k&&k != j) {
	//				flug = false;
	//			}
	//		}
	//		if (flug) {
	//			answer += a[i][j];
	//		}
	//	}
	//}


	cout << answer;
	return 0;
}

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

#define int long long

signed main(){
	int n,k;
	cin>>n>>k;

	vector < int > arr(n);
	for(int& i : arr) cin>>i;

	n --; k--;
	if(n%k==0)
		cout<<n/k;
	else
		cout<<n/k + 1;
	return 0;
}


Measured memory_bytes: 3984
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
#define FOR(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define rep(i,n) FOR(i,0,n-1)
#define int long long

int a[200005];

signed main() {

	int a, b; cin >> a >> b;
	int ans = max(a + b, a - b);
	ans = max(ans, a*b);
	rep(i, 100000000000) a = i;
	cout << ans << endl;

}

//cout << ans << endl;

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	int N;
	string S[2];
	cin >> N >> S[0] >> S[1];
	string T[2];
	for (int i = 0; i < N; i++) {
		if (S[0][i] == S[1][i]) {
			T[0].push_back(S[0][i]);
			T[1].push_back(S[0][i]);
		}
		else {
			T[0].push_back(S[0][i]);
			T[1].push_back(S[1][i]);
			i++;
		}
	}
	bool v = true;
	ll ans = 3;
	if (T[0][0] != T[1][0]) {
		ans *= 2;
		v = false;
	}
	//cout << T[0] << endl << T[1] << endl;
	for (int i = 1; i < T[0].size(); i++) {
		if (v) {
			ans *= 2;
			if (T[0][i] == T[1][i]) v = true;
			else v = false;
		}
		else {
			if (T[0][i] == T[1][i]) v = true;
			else {
				ans *= 3;
				v = false;
			}
		}
		ans %= mod;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
/*{{{*/
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#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 FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB emplace_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int h[SIZE];
int d[SIZE];
int main(){
    int N,M;
    R(N,M);
    FOR(i,1,N)R(h[i]);
    FOR(i,1,M){
        int x,y;
        R(x,y);
        if(h[x]<=h[y])d[x]=1;
        if(h[y]<=h[x])d[y]=1;
    }
    W(count(d+1,d+N+1,0));
    return 0;
}


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

using namespace std;

#define mz 1000000007
#define pq priority_queue

int main()
{
    bool flag=0;
    int prex=0,prey=0,pret=0;
    int x,y,t,n;
    scanf("%d",&n);
    while(n--)
    {
        scanf("%d%d%d",&t,&x,&y);
        if(x-prex+y-prey>t-pret || (x-prex+y-prey-t+pret)%2)
            flag=1;
        prex=x;
        prey=y;
        pret=t;
    }
    if(flag)
        printf("No\n");
    else
        printf("Yes\n");
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt(), k = scanner.nextInt();
			System.out.println(IntStream.range(0, n).map(i -> {
				int x = scanner.nextInt();
				return Math.min(x, k - x) * 2;
			}).sum());
		}
	}
}


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

#define INF 1000000007
#define LINF 1000000000000000007

using namespace std;

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

Int gcd(Int x, Int y){
	if(y == 0)
		return x;
	return gcd(y, x % y);
}

Int lcm(Int x, Int y){
	return x * y / gcd(x, y);
}

bool sosuu(int x){
	bool b = 1;
	if(x == 1) b = 0;
	for(int i = 2; i * i <= x; i++){
		if(x % i == 0) {
			b = 0;
			break;
		}
	}
	return b;
}

int n, a[200010], d[200010];
bool b[200010] = {0};

int main(){
	cin >> n;
	
	for(int i = 0; i < n; i++){
		cin >> a[i];
		d[a[i]] = i;
	}
	
	int ans = 0;
	for(int i = 1; i <= n; i++){
		int cnt = 1;
		while(d[i] < d[i+1]){
			i++;
			cnt++;
		}
		ans = max(ans, cnt);
	}
	
	cout << n - ans << endl;
	
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <cctype>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(k,a,b) for(int k=(a); k < (b); k++)
#define FORE(k,a,b) for(int k=(a); k <= (b); k++)
#define REP(k,a) for(int k=0; k < (a); k++)

#define ALL(c) (c).begin(), (c).end()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define RANGE(lb, x, ub) ((lb) <= (x) && (x) < (ub))

#define dump(x) cerr << #x << ": " << (x) << endl;

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

const int INF = 1000000000;
const double EPS = 1e-10;
const double PI = acos(-1.0);

int main(void) {
  int n, m; cin >> n >> m;
  cout << n * (n - 1) / 2 + m * (m - 1) / 2 << endl;

    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> p(n);
    for (int i = 0; i < n; i++)
    {
        cin >> p[i];
    }
    int ans = 0;
    for (int i = 1; i < n - 1; i++)
    {
        vector<int> check(3);
        check = {p[i - 1], p[i], p[i + 1]};
        sort(check.begin(), check.end());
        if (check[1] == p[i])
        {
            ans++;
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
import math
import copy
from copy import deepcopy
import sys
import fractions
# import numpy as np
from functools import reduce
# import statistics
import heapq
import collections
import itertools
sys.setrecursionlimit(100001)

# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

a, b, c = map(int, input().split())

if a<b and b<c:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 6876
#define _CRT_SECURE_NO_WARNINGS

#include<fstream>
#include<iostream>
#include<string>
#include<iomanip>
#include<list>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

bool isprime[1000000];

int main(int argc, char **argv){
	int n;
	int cnt;
	int checkcnt = 0;
	for (int i = 0; i < 1000000; i++) {
		isprime[i] = true;
	}
	while (cin >> n && checkcnt < 30) {
		cnt = 0;
		int i;
		for (i = 2; i <= sqrt(n); i++) {
			if (isprime[i]) {
				for (int j = 2; j <= n / i; j++) {
					isprime[i * j] = false;
				}
			}
		}
		for (int k = 2; k <= n; k++) {
			if (isprime[k]) {
				cnt++;
			}
		}
		cout << cnt << endl;
		checkcnt++;
	}
	return 0;
}

Measured memory_bytes: 2132
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = 0; i < (n); i++)
 
int main(){
    int N;
    cin >> N;
    int  m = N/2-1;
    
    vector<pair<int,int>> X(N);
    int R[N];
    for(int i=0;i<N;i++){
        int x;
        cin >> x;
        X[i].first = x;
        X[i].second = i;
    }
    sort(X.begin(),X.end());
    for(int i=0;i<N;i++){
        R[X[i].second] = i;
    }
    for(int i=0;i<N;i++){
        if(R[i] <= m){
            cout << X[m+1].first << endl;
        }else{
            cout << X[m].first << endl;
        }
    }
    return 0;
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    string s;
    cin >> s;
    string s1 = s.substr(0, 2), s2 = s.substr(2, 2);
    bool m1 = false, m2 = false;
    if (stoi(s1)>0&&stoi(s1)<=12) m1 = true;
    if (stoi(s2)>0&&stoi(s2)<=12) m2 = true;
    string ans;
    if (!m1&&m2) ans = "YYMM";
    else if (m1&&!m2) ans = "MMYY";
    else if (m1&&m2) ans = "AMBIGUOUS";
    else ans = "NA";
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long W = sc.nextLong();
        long H = sc.nextLong();
        int X = sc.nextInt();
        int Y = sc.nextInt();
        String split = "0";
        if (W/2.0 == X && H/2.0 == Y) {
            split = "1";
        }
        System.out.println((W*H/2.0) + " " + split);
    }    
}


Measured memory_bytes: 39124
package main

import (
	"fmt"
	"sort"
)

func main() {
	var N, M, answer, jumpLimit int
	fmt.Scan(&N, &M)
	numList := make([]int, M)
	for i := 0; i < M; i++ {
		fmt.Scan(&numList[i])
	}
	sort.Sort(sort.IntSlice(numList))

	if M <= N {
		fmt.Println(0)
	} else {
		dList := make([]int, M-1)
		for i := 0; i < M-1; i++ {
			dList[i] = numList[i+1] - numList[i]
		}
		sort.Sort(sort.IntSlice(dList))

		jumpLimit = N - 1
		if jumpLimit != 0 {
			for i := 0; i < jumpLimit; i++ {
				dList[M-2-i] = 0
			}
		}
		answer = Sum(dList)
		fmt.Println(answer)
	}

}

func Sum(a []int) int {
	s := 0
	for _, n := range a {
		s = s + n
	}
	return s
}


Measured memory_bytes: 5504
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <queue>
#include <ctime>
#include <cassert>
#include <cstdio>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <bitset>

using namespace std;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define epr(...) fprintf(stderr, __VA_ARGS__)
#define db(x) cerr << #x << " = " << x << endl
#define db2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n"; 
#define db3(x, y, z) cerr << "(" << #x << ", " << #y << ", " << #z << ") = (" << x << ", " << y << ", " << z << ")\n"
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

#define equal equalll
#define less lesss
typedef long long ll;
const int N = 333;
const long long INF = 1e9 + 19;

int n, m;
char s[N][N];
int dp[N][N];
int cost[N + N][N];


void read() {
    scanf("%d%d", &n, &m);
    for (int i = 0; i < n; i++)
        scanf("%s", s[i]);
}


int calc(string a, string b) {
    memset(cost, 0, sizeof(cost));
    for (int shift = -n; shift <= n; shift++) {
        for (int i = 0; i < n; i++) {
            int j = i + shift;
            if (0 <= j && j < n && a[i] == b[j])
                cost[shift + n][i + 1] = 1;
        }    
        for (int i = 0; i <= n; i++)
            cost[shift + n][i + 1] += cost[shift + n][i];
    } 
    memset(dp, 63, sizeof(dp));
    dp[n][n] = 0;
    /*for (int i = 0; i <= n; i++, cerr << endl)
        for (int j = 0; j <= n; j++)
            cerr << cost[i][j] << " ";*/

    for (int i = n; i >= 0; i--)
        for (int j = n; j >= 0; j--) {
            int ss = i - j;
            int gg = cost[ss + n][n - i];
            int res = INF;
            if (i + 1 <= n) {
                res = min(res, dp[i + 1][j] + gg);
            }
            if (j + 1 <= n) 
                res = min(res, dp[i][j + 1] + gg);
            dp[i][j] = min(res, dp[i][j]);
        } 
    /*cerr << endl;
    for (int i = 0; i <= n; i++, cerr << endl)
        for (int j = 0; j <= n; j++)
            cerr << dp[i][j] << " ";*/
    return dp[0][0];
}

void solve() {
    int answer = 0;
    for (int i = 0; i < m - 1; i++) {
        string a;
        string b;
        for (int j = 0; j < n; j++) {
            a += s[j][i];
            b += s[j][i + 1];
        }
        int tmp = calc(a, b);
        //db(tmp);
        answer += tmp;
    }
    cout << answer << endl;

}

void stress() {

}


int main(){
#ifdef MY_DEBUG
    freopen("in", "r", stdin);
    //freopen("out", "w", stdout);
#endif
    if (1) {
        int k = 1;
        for (int tt = 0; tt < k; tt++) {
            read();
            solve();
        }
    }
    else {
        stress();
    }

    return 0;
}








Measured memory_bytes: 1792
#define _CRT_SECURE_NO_WARNINGS

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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

ll X;

int main() {

	cin >> X;

	vector<ll> A, B;

	for (ll i = -200; i < 200; ++i) {
		A.push_back(i * i * i * i * i);
		B.push_back(i * i * i * i * i);
	}

	rep(a, 400) {
		rep(b, 400) {
			if (A[a] - B[b] == X) {
				cout << a - 200 << " " << b - 200 << endl;
				return 0;
			}
		}
	}

	return 0;
}


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

using namespace std;

#define PI 3.14159265358979323846
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define mp make_pair
#define pb push_back
#define fi first
#define se second

#define N 52

typedef long long ll;
typedef unsigned long long ull;

ll dp[N + 1][2];
string s[2];
int n;

ll solve(int y, bool dbl){
	if (y >= n){
		return 1;
	}

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

	if (y == 0){
		if (s[0][0] == s[1][0]){
			return dp[y][dbl] = (3 * solve(y + 1, false)) % MOD;
		}
		else{
			return dp[y][dbl] = (6 * solve(y + 2, true)) % MOD;
		}
	}

	if (s[0][y] == s[1][y]){
		if (dbl){
			return dp[y][dbl] = (solve(y + 1, false)) % MOD;
		}
		else{
			return dp[y][dbl] = (2 * solve(y + 1, false)) % MOD;
		}
	}
	else{
		if (dbl){
			return dp[y][dbl] = (3 * solve(y + 2, true)) % MOD;
		}
		else{
			return dp[y][dbl] = (2 * solve(y + 2, true)) % MOD;
		}
	}
}

int main(){
	ios::sync_with_stdio(false);

	cin >> n;
	cin >> s[0];
	cin >> s[1];

	memset(dp, -1, sizeof(dp));

	cout << solve(0, false) << endl;

	return 0;
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i < b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = INT_MAX / 2;
const ll  inf = LLONG_MAX / 2;
const int mod = 1000000007;
const int MAX_N = 101010;
const long double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/

	int h, w;
	cin >> h >> w;

	vector<vector<char>> a(h, vector<char>(w));
	int hash = 0;
	rep(i, h) {
		rep(j, w) {
			cin >> a[i][j];
			if (a[i][j] == '#') {
				hash++;
			}
		}
	}

	if (hash > h + w - 1) {
		out("Impossible");
	}
	else {
		out("Possible");
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>
#include<set>

int main() {
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	ll ac = a * c;
	ll ad = a * d;
	ll bc = b * c;
	ll bd = b * d;
	ll ans;
	ans = max(max(ac, ad), max(bc, bd));
	//cout << max(ac, ad);
	cout << ans;
	return 0;
}

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

int main(){
int N,M;
int A,C=0;
cin >> N>>M;
for(int i=0;i<M;i++){
	cin >> A; 
	C += A;
}

if(C<=N)cout << N-C << endl;
else cout << -1 << endl;
}

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

int main()
{
    int n,m;
    cin>>n>>m;
  
  int sum =n;

   for(int i=0;i<m;i++)
   {
       int a;
       cin>>a;
   
      sum-=a;
   }

    if(sum>=0)
    cout<<sum<<endl;
  
    else
      cout<<"-1"<<endl;

}


Measured memory_bytes: 3616
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define MAX 100
#define MOD 1000000007
#define pb push_back

/* add vars here */

ll n,k;

/* add your algorithm here */

int main() {
  cin >> n >> k;
  ll ans = 0;

  ll cnt = 0;
  for (int i = 1; i <= n; ++i) {
    if (i % k == 0) ++cnt;
  }
  ans = cnt * cnt * cnt;
  cnt = 0;
  if (k % 2 == 0) {
    for (int i = 1; i <= n; ++i) {
      if (i % k == (k/2)) {
        cnt++;
      }
    }
  }
  ans += cnt * cnt * cnt;

  cout << ans << endl;
}


Measured memory_bytes: 256
/* monkukui 競技プログラミング用のテンプレート  (ここから) */
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
using ll = long long int;
using lnt = long long int;
using Graph = vector<vector<int>>;
using Wgraph = vector<vector<pair<int, long long int>>>;
constexpr long long int INF = 1001001001001001LL;
constexpr long long int MOD = 1000000007LL;
constexpr double PI = 3.1415926535897932;
constexpr long long int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
constexpr long long int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
inline void yes(){ cout << "yes" << endl; }
inline void Yes(){ cout << "Yes" << endl; }
inline void YES(){ cout << "YES" << endl; }
inline void no(){ cout << "no" << endl; }
inline void No(){ cout << "No" << endl; }
inline void NO(){ cout << "NO" << endl; }
inline void possible(){ cout << "possible" << endl; }
inline void Possible(){ cout << "Possible" << endl; }
inline void POSSIBLE(){ cout << "POSSIBLE" << endl; }
inline void impossible(){ cout << "impossible" << endl; }
inline void Impossible(){ cout << "Impossible" << endl; }
inline void IMPOSSIBLE(){ cout << "IMPOSSIBLE" << endl; }

#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = 1; i <= (n); i++)
#define DREP(i,n) for(int i = (n)-1; i >= 0; i--)
#define SREP(i,s,t) for(int i = s; i < t; i++)
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define PB push_back

/* monkukui 競技プログラミング用のテンプレート (ここまで)*/

int main(){
  
  int h, w; cin >> h >> w;
  vector<vector<char>> a(h, vector<char> (w));

  vector<bool> col(h, true);
  vector<bool> row(w, true);
  for(int i = 0; i < h; i++)
    for(int j = 0; j < w; j++)
      cin >> a[i][j];
  
  for(int i = 0; i < h; i++) {
    for(int j = 0; j < w; j++) {
      if(a[i][j] == '#') {
        col[i] = false;
        row[j] = false;
      }
    }
  }

  for(int i = 0; i < h; i++) {
    for(int j = 0; j < w; j++) {
      if(!col[i] and !row[j]) cout << a[i][j];
    }
    if(!col[i]) cout << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cctype>
#include <functional>
using namespace std;
using ll = long long;

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

int main(){
    int n,a;
    cin >> n >> a;
    if((n%500) <= a) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <tuple>
#include <cstdio>
#include <cmath>
using namespace std;
using ll = long long;
const int INF = 1e9;

int main() {
    int n, m;
    vector<int> a;

    cin >> n >> m;

    for(int i = 0; i < m; i++) {
        int inp; cin >> inp;
        a.push_back(inp);
    }

    int sum = 0;
    for (int i = 0; i < m; i++) {
        sum += a[i];
    }
    if ((n - sum) < 0) {
        cout << "-1\n";
    } else {
        cout << n - sum << endl;
    }
}

Measured memory_bytes: 3728
n = int(input())
f = [[int(i) for i in input().split()] for j in range(n)]
p = [[int(i) for i in input().split()] for j in range(n)]

num = 2 ** 10

act = [0] * 10

ans = -10**100

for i in range(1,num):
    cnt = i
    tmp = 0
    while cnt != 0:
        if cnt % 2 == 0:
            act[tmp] = 0
            cnt = cnt // 2
            tmp += 1
        else:
            act[tmp] = 1
            cnt = cnt // 2
            tmp += 1
    
    tmp_ans = 0   
    for j in range(n):
        open_num = 0
        for k in range(10):
            if act[k] + f[j][k] == 2:
                open_num += 1
        tmp_ans += p[j][open_num]
    ans = max(ans,tmp_ans)
    
print(ans)

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

int main() {
    int N,s=0,m=0,L;
    cin >> N;

    rep(i,N) {
        cin >> L;
        s += L;
        m = max(m,L);
    }

    if(m < s-m)
        cout << "Yes";
    else
        cout << "No";
    cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  ll a[3];
  rep(i,3) R a[i];
  sort(a,a+3);
  pr(a[0]+a[1]+a[2]*10);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


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

int main() {
  int N;
  cin >> N;
  vector<double> x(N);
  vector<string> u(N);
  for (int i = 0; i < N; i++) {
    cin >> x.at(i) >> u.at(i);
  }
  double ans = 0.0;
  for (int i = 0; i < N; i++) {
    if (u.at(i) == "JPY") {
      ans += x.at(i);
    }
    else {
      ans += (x.at(i) * 380000.0);
    }
  }
  cout << ans << endl;
}


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

#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#define rdfile(...) 42
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    // rdfile("test/sample-1.in");

    int N, K;
    cin >> N >> K;
    string s;
    cin >> s;

    int res = 0, l = 0, r = 0;
    for (int i=0; i<N; ++i) {
        if (i == 0 || s[i] != s[i-1]) {
            if (s[i] == 'L') l++;
            else r++;
        }
        if (i != 0 && s[i] == s[i-1]) res ++;
    }

    if (l+r == 1) {
        cout << res << endl;
        return 0;
    } else if (l+r == 2) {
        cout << res+1 << endl;
        return 0;
    }
    
    while (0 < K && l+r > 2) {
        l--;
        r--;
        res += 2;
        K --;
    }
    if (0 < K && l+r == 2) {
        res ++;
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int L,R;
	cin >> L >> R;
	int l,r,c;
	l=L%2019;
	r=R%2019;
	c=2018;
	if(l>=r || R-L>673){
		cout << 0 <<endl;
	}
	else {
		for(int i=l;i<r;i++){
			for(int j=i+1; j<=r;j++){
				if((i*j)%2019<=c){
					c=(i*j)%2019;
				}
			}
		}
		cout << c << endl;
	}
}

Measured memory_bytes: 256
n,m=map(int,input().split())
b_list=[]
INF=10**6
for i in range(n):
    b_list.append(INF)
for i in range(m):
    a,b=map(int,input().split())
    b_list[a-1]=min(b-1,b_list[a-1])
end=INF
count=0
for i in range(n):
    if b_list[i]==INF:
        pass
    else:
        if i>=end:
            count=count+1
            end=b_list[i]
        else:
            end=min(end,b_list[i])
print(count+1)


Measured memory_bytes: 47184
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>

using namespace std;

int main()
{
    char o[51], e[51];
    cin >> o >> e;
    int dist=strlen(o)-strlen(e);
    int i;
    for(i=0; i<strlen(e); i++){
        cout << o[i] << e[i];
    }
    if(dist==1){
        cout << o[i];
    }
    
    return 0;
}

Measured memory_bytes: 256