akhauriyash/Code-Regression huggingface dataset:
## ABC 054 b
import sys

n,m = (int(_) for _ in input().split())
a = [input() for i in range(n)]
b = [input() for i in range(m)]

#if(a[::1] == b[::1]):
#    print('Yes')
#    sys.exit(0)

for i in range(n-m+1):
    for j in range(n-m+1):
        if (b[::1] == [ai[j:j+m] for ai in a[i:i+m]]):
            print('Yes')
            sys.exit(0)

print('No')

Measured memory_bytes: 3064
<?php
fscanf(STDIN, "%d", $n);
fscanf(STDIN, "%[^\r\n]", $p);
$p_list = explode(' ', $p);

$a = array();
for($i = 1;$i <= $n; $i ++) {
	$a[] = $i * 30000;
}

$b = array();
for($i = 1;$i <= $n; $i ++) {
	$b[] = ($n - $i + 1) * 30000;
}


for($i = 0;$i < $n; $i ++) {
	$b[$p_list[$i] - 1] += $i;
}

print(implode(' ', $a)."\n");
print(implode(' ', $b)."\n");

?>

Measured memory_bytes: 6648
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <unordered_map>

using namespace std;

int cost(int n,vector <int> arr) {
    sort(arr.begin(),arr.end());
    int sum = 0;
    for(int i = 0; i < arr.size(); i = i + 2){
        sum = sum + arr[i];
    }
    // Complete this function
    return sum;
}

int main() {
    int n;
    cin >> n;
    vector <int> arr;
    for(int i = 0; i < 2 * n; i++){
        int temp;
        cin >> temp;
        arr.push_back(temp);
    }
    int result = cost(n,arr);
    cout << result << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;
  cin >> a >> b;
  if (a % 2 == 0 || b % 2 == 0)
    cout << "Even" << endl;
  else{
    cout << "Odd" << endl;
  }
}

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

//gcdやり直す

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

  temp = *x;
  *x = *y;
  *y = temp;
}




/***
* pivotを決め、
* 全データをpivotを境目に振り分け、
* pivotの添え字を返す
***/
int partition (int array[], int left, int right) {
  int i, j, pivot;
  i = left;
  j = right + 1;
  pivot = left;   // 先頭要素をpivotとする

  do {
    do { i++; } while (array[i] < array[pivot]);
    do { j--; } while (array[pivot] < array[j]);
    // pivotより小さいものを左へ、大きいものを右へ
    if (i < j) { swap(&array[i], &array[j]); }
  } while (i < j);

  swap(&array[pivot], &array[j]);   //pivotを更新

  return j;
}

/* クイックソート */
void quick_sort (int array[], int left, int right) {
  int pivot;

  if (left < right) {
    pivot = partition(array, left, right);
    quick_sort(array, left, pivot-1);   // pivotを境に再帰的にクイックソート
    quick_sort(array, pivot+1, right);
  }
}




/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/

int main(void){
  int l,r;
  scanf("%d%d",&l,&r);
  int ans=2020;
  int i,j;
  
  if(r-l+1>=2019){
    printf("0\n");
    return 0;
  }
  

  r%=2019;
  l%=2019;


  if(r<l){
    printf("0\n");
    return 0;
  }


  for(i=l;i<r;i++){
    for(j=i+1;j<=r;j++){
      int a=(i*j)%2019;
      if(a<ans){
        ans=a;
      }
    }
  }
  printf("%d\n",ans);



  return 0;
}

Measured memory_bytes: 1696
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

struct SCC {
    int n;
    vector<vector<int>> G, R, T;
    vector<bool> used;
    vector<int> vs, cmp;

    SCC(int n) : n(n), G(n), R(n), used(n), cmp(n) {}

    int operator[](int k) {
        return cmp[k];
    };

    void add_edge(int from, int to) {
        G[from].emplace_back(to);
        R[to].emplace_back(from);
    }

    void dfs(int v) {
        used[v] = true;
        for (int u : G[v]) {
            if (!used[u]) dfs(u);
        }
        vs.emplace_back(v);
    }

    void rdfs(int v, int k) {
        used[v] = true;
        cmp[v] = k;
        for (int u : R[v]) {
            if (!used[u]) rdfs(u, k);
        }
    }

    int build() {
        for (int v = 0; v < n; v++) {
            if (!used[v]) dfs(v);
        }
        fill(used.begin(), used.end(), false);
        int k = 0;
        for (int i = n - 1; i >= 0; i--) {
            if (!used[vs[i]]) {
                rdfs(vs[i], k);
                k++;
            }
        }
        T.resize(k, vector<int>());
        for (int v = 0; v < n; v++) {
            for (int u : G[v]) {
                if (cmp[v] != cmp[u]) T[cmp[v]].emplace_back(cmp[u]);
            }
        }
        for (int i = 0; i < k; i++) {
            sort(T[i].begin(), T[i].end());
            T[i].erase(unique(T[i].begin(), T[i].end()), T[i].end());
        }
        return k;
    }
};

/*
    To.size() == V
   であればトポロジカルソートができた、そうでなければできなかったと判定できる
*/
vector<int> Tsort(vector<vector<int>>& G) {
    vector<int> To;
    int V = G.size();
    stack<int> st;
    int indeg[V] = {};
    for (int i = 0; i < V; i++) {
        for (int j = 0; j < (int)G[i].size(); j++) {
            indeg[G[i][j]]++;
        }
    }
    for (int i = 0; i < V; i++) {
        if (indeg[i] == 0) {
            st.push(i);
        }
    }
    // vector<int> dp(V);
    while (!st.empty()) {
        int u = st.top();
        st.pop();
        To.push_back(u);
        for (int i = 0; i < (int)G[u].size(); i++) {
            indeg[G[u][i]]--;
            // dp[G[u][i]] = max(dp[G[u][i]], dp[u] + 1);
            // ans = max(ans, dp[G[u][i]]);
            if (indeg[G[u][i]] == 0) {
                st.push(G[u][i]);
            }
        }
    }
    return To;
}

signed main() {
    int n, m;
    cin >> n >> m;
    SCC scc(n);
    int a, b;
    rep(i, m) {
        cin >> a >> b;
        scc.add_edge(a, b);
    }
    int k = scc.build();
    cout << k << endl;
    vector<int> vec[k];
    rep(v, n) {
        vec[scc[v]].emplace_back(v);
    }
    auto G = scc.T;
    auto T = Tsort(G);
    for (auto v : T) {
        cout << vec[v].size();
        for (int u : vec[v]) {
            cout << " " << u;
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 127596
#include <iostream>

#include <vector>
#include<algorithm>
#include<iomanip>
#include<queue>
using namespace std;
#define rep(i,n) for(int i=0;i<=(int)(n-1);i++)

int main() {
	int c[3][3];
	rep(i,3) rep(j,3) cin>>c[i][j];
	int k = 0;
	rep(i,2){
		if(c[i][0]-c[i][1]!=c[i+1][0]-c[i+1][1] | c[i][0]-c[i][2] != c[i+1][0]-c[i+1][2]){
			k++;
		}
		if(c[0][i]-c[1][i]!=c[0][i+1]-c[1][i+1] | c[0][i]-c[2][i] != c[0][i+1]-c[2][i+1]){
					k++;
				}
	}
	if(k==0){
		cout<<"Yes"<<endl;
	}
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include<set>
using namespace std;
std::set<int> st;
int main(void){
    int N,ans=0;
    cin>>N;
    for(int i=0;i<N;i++){
        int a;
        cin>>a;
        if(st.count(a)!=0)st.erase(a);
        else st.insert(a);
    }
    for(auto x : st)ans++;
    cout<<ans<<endl;
}


Measured memory_bytes: 4864
#include <bits/stdc++.h>
#include <cmath>
#define _USE_MATH_DEFINES
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vii;
typedef pair<int, int> pi;
#define F first
#define S second
#define PB push_back
#define MP make_pair

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	vector<int> a(11, 0);
	for (int i = 0; i < 3; i++)
	{
		int tmp;
		cin >> tmp;
		a[tmp]++;
	}

	if(a[5] == 2 and a[7] == 1) cout << "YES" << endl;
	else 						cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 3604
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
from pprint import pprint
sys.setrecursionlimit(2147483647)


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007



from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


def gcd(x, y):
    while y:
        x, y = y, x % y
    return x



def prime_decomposition(n):
    table =[]
    i = 2
    while n >= i**2:
    # nのその数自身を除いた素因数は√n以下であることから。
        while n % i == 0:
            table.append(i)
            n /= i
        i += 1
    if n > 1:
        table.append(int(n))
# 最後に残った、最大の素因数をリストに入れる。
    return table


a, b = LI()
print(len(set(prime_decomposition(gcd(a, b)))) + 1)

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

using namespace std;
typedef long long ll;

ll fpow( ll a, ll b ) {
	ll c = 1;
	while( b-- ) c *= a;
	return c;
}

bool read() {
	char ch;
	scanf( " %c", &ch );
	return ch == 'Y';
}

ll solve1() {
	for( ll i = 1; i <= 10; ++i ) {
		printf( "? %lld\n", fpow(10, i) );
		fflush(stdout);
		bool st = read();
		if( !st ) return i;
	}
	return 0;
}

ll solve2() {
	for( ll i = 9; i >= 1; --i ) {
		printf( "? %lld\n", fpow(10, i) - 1 );
		fflush(stdout);
		bool st = read();
		if( !st ) return i+1;
	}
	return 1;
}

bool check( ll mid ) {
	printf( "? %lld9\n", mid );
	fflush(stdout);
	return read();
}
ll solve3( ll digit ) {
	ll low = fpow(10, digit-1);
	ll high = fpow(10, digit)-1;
	while( low < high ) {
		ll mid = (low + high)/2;
		if( check(mid) ) high = mid;
		else low = mid + 1;
	}
	return low;
}

int main() {
	ll digit = solve1();
	if( !digit ) digit = solve2();
	printf( "! %lld\n", solve3(digit) );
	return 0;
}


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

struct Card { char suit, value; };

void bubble(struct Card A[], int N){
    for ( int i=0; i<N;i++){
        for(int j=N-1;j>=i;j--){
            if(A[j].value<A[j-1].value){
                Card t = A[j];
                A[j] = A[j-1];
                A[j-1] = t;
            }
        }
    }
}

void selection(struct Card A[],int N){
    for(int i=0;i<N;i++){
        int minj = i;
        for(int j=i;j<N;j++){
            if(A[j].value < A[minj].value) minj = j;
        }
        Card t = A[i];
        A[i] = A[minj];
        A[minj] = t;
    }
}

void print(struct Card A[],int N){
    for(int i=0;i<N;i++){
        if(i) cout << " ";
        cout << A[i].suit << A[i].value;
    }
    cout << endl;
}

bool isStable(struct Card C1[],struct Card C2[],int N){
    for(int i=0;i<N;i++){
        if(C1[i].suit != C2[i].suit) return false;
    }
    return true;
}

int main(){
    Card C1[100],C2[100];
    int N;
    
    cin >> N;
    for(int i=0;i<N;i++){
        cin >> C1[i].suit >> C1[i].value;
        C2[i] = C1[i];
    }
    
    bubble(C1,N);
    selection(C2,N);
    
    print(C1,N);
    cout << "Stable" << endl;
    print(C2,N);
    if (isStable(C1,C2,N)){
        cout << "Stable" << endl;
    }
    else cout << "Not stable" << endl;
    
    return 0;
}

Measured memory_bytes: 1160
import java.util.Scanner;
public class Main{
		
    public void solve(){
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
			System.out.println(x * x * x);
	
    }
	public static void main(String[] args){
		Main obj = new Main();
		obj.solve();
	}
}
				
			
        

Measured memory_bytes: 17300
#include <iostream>
#include <stdio.h>

using namespace std;

int main() {
    int a, b;
    int d = 0, r = 0;
    double f = 0.0;
    
    cin >> a >> b;
    
    d = a / b;
    r = a % b;
    f = (double)a / (double)b;
    
    printf("%d %d %.8lf\n", d, r, f);
    
    return 0;
}


Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int a,b,temp;
  	cin >> a >> b;
  	temp = (a * b) % 2;
  
  	if(temp == 0){
    	cout << "Even" << endl; 
    }
  	else if (temp != 0) {
    	cout << "Odd" << endl;
    }
}

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

typedef long long ll;
const int maxn=1e5+7;
const int inf=1e9+7;
const int mod=1e9+7;
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define rep(i,n) for (int i=1;i<=(n);i++)
#define rep2(i,a,b) for (int i=(a);i<=(b);i++)

vector <int> G[maxn];
set <int> fennec,snuck;
vector<int> color;
bool v[maxn]={0};
int sub[maxn]={0};

bool dfs (int now,int target)
{ v[now]=1;
if (now==target) {
	color.pb(now);
	return 1;
}
	for (int i:G[now])
	{
		if (!v[i])
		{
			if (dfs(i,target)) 
			{
			color.pb(now);
			return 1;
			}
		}
	}
	return 0;
} 

int dfs2(int now)
{
	v[now]=1;
	int sum=0;
	for (int i:G[now])
	{
		if (!v[i])
		{
			if (fennec.find(i)==fennec.end()&&
			snuck.find(i)==snuck.end())
			{
			sum+=1;
			//cout<<now<<' '<<i<<endl;
			sum+=dfs2(i);
			}
			else dfs2(i);
		}
	}
	sub[now]=sum;
	return sum;
} 

int main()
{
 	ios::sync_with_stdio(0); cin.tie(0);
 	int n;
 	cin>>n;
 	for (int i=1;i<=n-1;i++)
 	{
 		int a,b;
 		cin>>a>>b;
 		G[a].pb(b);
 		G[b].pb(a);
	}
	//cout<<"---"<<endl;
	dfs(1,n);
	memset(v,0,sizeof(v));
	int size=color.size();
	for (int i=0;i<size;i++)
	{
		//cout<<color[i]<<' ';
		if ((i+1)<=size/2) snuck.insert(color[i]);
		else fennec.insert(color[i]);
	}
	dfs2(1);
	int sums=0,sumf=0;
	//for (int i=1;i<=n;i++) cout<<sub[i]<<' ';
	for (auto j=snuck.begin();j!=snuck.end();j++)
	{ /*cout<<sub[(*j)]<<'/'; */sums+=sub[(*j)];}
	 for (auto j=fennec.begin();j!=fennec.end();j++)
	{/*cout<<sub[(*j)]<<'*';*/sumf+=sub[(*j)];}
	if (sumf+size-size/2>sums+size/2) cout<<"Fennec"<<endl;
	else cout<<"Snuke"<<endl;
}

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

int main() {
    int h, w;

    while(true) {
        cin >> h >> w;
        if (h == 0 && w == 0) break;

        rep(i,h) {
            if (i == 0 || i == h-1) {
                rep(f,w) cout << '#';
            } else {
                cout << '#';
                rep(f,w-2) cout << '.';
                cout << '#';
            }
            cout << endl;
        }
        cout << endl;
    }
}


Measured memory_bytes: 3084
#include <stdio.h>
#include <algorithm>
 
using namespace std;
 
int main(){
    int H,W;
    while(true){
        scanf("%d %d",&H,&W);
        if(H == 0 && W == 0) break;
        for(int i = 0; i < W; i++) printf("#");
        printf("\n");
 
        for(int i = 1; i < H-1; i++){
            printf("#");
            for(int j = 1; j < W-1; j++) printf(".");
            printf("#\n");
        }
 
        if(H > 1){
            for(int i = 0; i < W; i++) printf("#");
            printf("\n");
        }
        printf("\n");
    }
}


Measured memory_bytes: 2628
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repd(i, n) for (int i = n; i >= 1; i--)
#define mod 1000000007
#define MOD 998244353
#define inf 1e20
typedef long long int ll;
typedef pair<ll, ll> p;


int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if ((a * 100 + b * 10 + c) % 4 == 0) {
		cout << "YES";
	}
	else {
		cout << "NO";
	}
	return 0;
}

//Ctrl+Aを使わない

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

int main(){
    ll l , r ;
    cin >> l >> r ;
    for(ll i = 1 ; 2019 * i <= 2 * 1e9 ; i++ ){
        if( l <= 2019*i && 2019*i <= r ){
            cout << 0 << endl ;
            return 0 ;
        }
    }
    ll ans = 2 * 1e10 ;
    for(ll i = l ; i < r ; i++ ){
        for(ll j = i+1 ; j <= r ; j++ ){
            ll tem = i*j ;
            tem %= 2019 ;
            ans = min(tem,ans) ;
        }
    }
    cout << ans <<endl ; 
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  string s;cin >> s;
  cout << count(all(s),'2') << endl;
  return 0;
}


Measured memory_bytes: 256
MOD = 998244353
k, n = map(int, input().split())

list_size = 5000

f_list = [1] * list_size
f_r_list = [1] * list_size

for i in range(list_size - 1):
	f_list[i + 1] = int((f_list[i] * (i + 2)) % MOD)

def power(n, x):
	if x == 1:
		return n
	elif x % 2 == 0:
		return power(int((n * n) % MOD), int(x / 2))
	else:
		return int((n * power(n, x - 1)) % MOD)

f_r_list[-1] = power(f_list[-1], MOD - 2)

for i in range(2, list_size + 1):
	f_r_list[-i] = int((f_r_list[-i + 1] * (list_size + 2 - i)) % MOD)

def comb(n, r):
	if n < r or r < 0:
		return 0
	elif n == 0 or r == 0 or n == r:
		return 1
	else:
		return (((f_list[n - 1] * f_r_list[n - r - 1]) % MOD) * f_r_list[r - 1]) % MOD 

ans = []
for i in range(2, k+2):
	num = 0
	if i%2 == 1:
		for j in range(0, i//2+1):
			#num += comb(i//2, j) * comb(n-1, j-1) * pow(2, j, MOD) * comb(n+k-i-j, k-i)
			num += comb(i//2, j) * pow(2, j, MOD) * comb(n+k-i, k-i+j)
			num %= MOD
	else:
		for j in range(0, i//2):
			#num += comb(i//2-1, j) * comb(n-1, j-1) * pow(2, j, MOD) * comb(n+k-i-j, k-i)
			num += comb(i//2-1, j) * pow(2, j, MOD) * comb(n+k-i, k-i+j)
			#num += comb(i//2-1, j) * comb(n-2, j-1) * pow(2, j, MOD) * comb(n+k-i-j-1, k-i)
			num += comb(i//2-1, j) * pow(2, j, MOD) * comb(n+k-i-1, k-i+j)
			num %= MOD
	ans.append(num)

print(*ans, sep="\n")
ans = reversed(ans[:k-1])
print(*ans, sep="\n")

Measured memory_bytes: 57836
#include <iostream>
#include <string>
#include <vector>
using namespace std;
 
int main() {
	int h;
	cin >> h;
	int w;
	cin >> w;
	vector<string> a(h);
	for (int i = 0; i < h; i++) {
		cin >> a[i];
	}
 
	vector<bool> row(h, false);
	vector<bool> col(w, false);
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (a[i][j] == '#') {
				row[i] = true;
				col[j] = true;
			}
		}
	}
 
	for (int i = 0; i < h; i++) {
		if (row[i]) {
			for (int j = 0; j < w; j++) {
				if (col[j]) {
					cout << a[i][j];
				}
			}
			cout << endl;
		}
	}
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define ll long long

using namespace std;

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

    ll r, D, x;
    cin>>r>>D>>x;

    for (int i=0;i<10;i++)
    {
        x = r*x-D;
        cout<<x<<endl;
    }
}


Measured memory_bytes: 256
a,b=gets.split.map(&:to_i)

ans1=Array.new(50){Array.new(100,"#")}
a-=1

25.times do |i|
  50.times do |j|
    if a>=1
      ans1[2*i][2*j]="."
      a-=1
    end
  end
end


ans2=Array.new(50){Array.new(100,".")}
b-=1
25.times do |i|
  50.times do |j|
    if b>=1
      ans2[2*i][2*j]="#"
      b-=1
    end
  end
end


puts "100 100"
50.times do |i|
  puts ans1[i].join("")
end

50.times do |i|
  puts ans2[50-i-1].join("")
end


Measured memory_bytes: 2044
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(998244353);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int t[100100],check[2][2]={{5,10},{9,6}};
ll dp[100100][2];
map<P, int> mp;

ll calc(int i, int d, int e){
	int x;
	x = mp[P(i,d)];
	if(!x){
		return 2ll;
	}else if((!(x&12)) || (x == check[e][0]) || (x == check[e][1])){
		return 1ll;
	}else{
		return 0ll;
	}
}

ll rwpw(ll p, ll a = 2ll){
	ll ret = 1ll;
	while(p){
		if(p%2){
			mul_mod(ret,a);
		}
		mul_mod(a,a);
		p /= 2;
	}
	return ret;
}

int main(void){
	int n,m,i,j,k,a,b,c;
	ll tmp,f,ans=0ll;
	bool o = false;
	cin >> n >> m;
	f = (1ll*n*n-5ll*n+6ll)/2;
	fill(t,t+n,3);
	for(i=0; i<m; ++i){
		cin >> a >> b >> c;
		--a; --b;
		if(a==b){
			t[a] &= (1<<c);
			continue;
		}
		if(a<b){
			swap(a,b);
		}
		b = a-b;
		k = mp[P(a,b)];
		k <<= 2;
		k |= (1<<c);
		mp[P(a,b)] = k;
		if(b<3){
			continue;
		}
		if(k && (!(k&12))){
			--f;
		}
		for(j=0; j<2; ++j){
			if(k == check[1][j]){
				o = true;
				break;
			}
		}
	}
	if(o){
		cout << 0 << endl;
		return 0;
	}
	for(i=0; i<2; ++i){
		dp[0][i] = (t[0]&(1<<i))?1:0;
	}
	for(i=1; i<n; ++i){
		for(j=0; j<2; ++j){
			if(!(t[i]&(1<<j))){
				continue;
			}
			for(k=0; k<2; ++k){
				tmp = dp[i-1][k];
				mul_mod(tmp,calc(i,1,(j+k)%2));
				if(i>1){
					mul_mod(tmp,calc(i,2,k));
				}
				add_mod(dp[i][j],tmp);
			}
		}
	}
	ans = (dp[n-1][0] + dp[n-1][1]) % MOD;
	mul_mod(ans,rwpw(f));
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 17792
#include <iostream>
using namespace std;
int main(){
  int count = 0;
  int a,b,c;
  int x,y,z;
  cin >> a >> b >> c;
  while(1){
    if(a%2==0 && b%2==0 && c%2==0){
      x = a;
      y = b;
      z = c;
      a = y/2 + z/2;
      b = z/2 + x/2;
      c = x/2 + y/2;
      count++;
      if(count == 10000){
        cout << -1 << "\n";
        return 0;
      }
    }
    else break;
  }
  cout << count << "\n";
  return 0;
}

Measured memory_bytes: 256
/*________________________Bismillahir Rahmanir Rahim___________________
|                                                                      |
|                    /\     |     | |\    |     /\     |-------        |
|                   /  \    |     | | \   |    /  \    |               |
|                  /----\   |-----| |  \  |   /----\   |-----          |
|                 /      \  |     | |   \ |  /      \  |               |
|                /        \ |     | |    \| /        \ |               |
|                     14th batch CSE , ID : 12008029                   |
|                     Comilla University                               |
|                     Email : sheikhahnafshifat@gmail.com              |
|______________________________________________________________________*/
#include<bits/stdc++.h>
#include<string>
#include<iostream>
using namespace std;
#define ll                      long long
#define MAX                     1000007
#define pb(x)                   push_back(x)
#define mp(x,y)                 make_pair(x,y)
#define vii                     vector<int>
#define vll                     vector<long long>
#define vp                      vector<pair<ll, ll> >
#define v_min(a)                *min_element(a.begin(),a.end())
#define v_max(a)                *max_element(a.begin(),a.end())
#define v_sum(a)                accumulate(a.begin(),a.end(),0)
#define un(a)                   a.erase(unique(a.begin(),a.end()),a.end())
#define SORT(a)                 sort(a.begin(),a.end())
#define AHNAF                   ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define gcd(a,b)                __gcd(a,b)
#define lcm(a,b)                ((a)*(b))/gcd(a,b)
#define YES                     cout<<"YES"<<endl
#define NO                      cout<<"NO"<<endl
#define testcase(t)             int t;cin>>t;while(t--)
#define reverse(a)              reverse(a.begin(),a.end())
#define ff                      first
#define ss                      second
#define print(a)                for(auto it: a) cout<<it<<" "
#define all(a)                  a.begin(),a.end()
///--------------Graph Moves--------------------------------------
///const int fx[] = {+1,-1,+0,+0};
///const int fy[] = {+0,+0,+1,-1};
///const int fx[] = {+0,+0,+1,-1,-1,+1,-1,+1}; ///King's move
///const int fy[] = {-1,+1,+0,+0,+1,+1,-1,-1}; ///king's Move
///const int fx[] = {-2,-2,-1,-1,+1,+1,+2,+2}; ///knight's move
///const int fy[] = {-1,+1,-2,+2,-2,+2,-1,+1}; ///knight's move
///---------------------------------------------------------------

int main()
{
    AHNAF;int ca=0;
    int n;cin>>n;
    string s="ACL";
    for(int i=0; i<n-1; i++) s+="ACL";
    cout<<s;
}



Measured memory_bytes: 3568
import sys
import math
from collections import deque
import copy
input = sys.stdin.readline
INF = 10**9+7
N, W = map(int, input().split())
weight = []
value = []
for i in range(N):
    tempW, tempV = map(int, input().split())
    weight.append(tempW)
    value.append(tempV)

dp = [[INF for _ in range(N * 1000 + 1)] for _ in range(N + 1)]
dp[0][0] = 0

for i in range(1, N + 1):
    for l in range(N * 1000 + 1):
        if l - value[i - 1] >= 0:
            dp[i][l] = min(dp[i - 1][l], dp[i - 1][l - value[i - 1]] + weight[i - 1])
        else:
            dp[i][l] = dp[i - 1][l]
for i in range(N * 1000 + 1):
    if dp[N][i] <= W:
        ans = i
print(ans)


Measured memory_bytes: 170760
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <stack>

#define rep(i, n) for(int i=0;i<n;i++)
#define IOS() ios_base::sync_with_stdio(false)
#define ll long long
#define ull unsigned long long
#define INT_MINI -987654321
#define INT_MAXI 987654321
#define ABS(X) ((X) < 0 ? -(X) : (X))


using namespace std;

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

long double a, b, c;


void input() {

    cin >> a >> b >> c;
}

void process() {

    long double aa, bb, cc;
    long double eps = 1.0E-14;
    aa = sqrt(a);
    bb = sqrt(b);
    cc = sqrt(c);

    /*
    printf("%.33Lf\n", sqrt(a) + sqrt(b) + eps);
    printf("%.33Lf\n", aa + bb + eps);
    printf("%.33Lf\n", cc);
    printf("%.33Lf\n", sqrt(c));
     */

    if(aa + bb + eps < cc) {
    //if(sqrt(a) + sqrt(b) + eps < sqrt(c)){
        cout << "Yes";
    }
    else {
        cout << "No";
    }
}

int main() {

    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    input();
    process();

    return 0;
}

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

int main(){
    
    int N;cin>>N;
    vector<double> p(N);
    vector<double> S(2*N+1);
    for(int i=0;i<N;i++){
        cin>>p[i];
    }
    S[N]=1.0;
    for(int i=0;i<N;i++){
        for(int j=N-i;j<N+1+i;j+=2){
            if(S[j]!=0){
                S[j-1]+=S[j]*p[i];
                S[j+1]+=S[j]*(1-p[i]);
                S[j]=0;
            }
        }
    }
    double ans=0;
    for(int i=0;i<N;i++){
        ans+=S[i];
    }
    cout<<setprecision(15)<<ans<<endl;
}


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

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

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main(){
    let s = read::<String>();
    let v = s.parse::<i64>().unwrap();
    let t:Vec<char> = s.clone().chars().collect();
    let first = t[0].to_digit(10).unwrap();
    let second = first+1;
    let near_v = first*100 + first*10 + first;
    // let another_v = second*100 + second*10 + second;
    let ans = if near_v < v as u32 {
        second*100 + second*10 + second
    } else {
        near_v
    };
    println!("{}",ans);

}

Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;

int main(void){
	int n, x;
	cin >> n >> x;
	vector<int> m(n);
	int sum = 0;
	for(int i=0;i<n;i++){
		cin >> m[i];
		sum += m[i];
	}
	sort(m.begin(),m.end());
	cout << (int)((x - sum)/m[0]) + n << endl;
	return 0;
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline


def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    K_d = [0] * (len(bin(10 ** 12)) - 2)
    L = len(K_d)
    for i, k in enumerate(bin(K)[2:][::-1], 1):
        k = int(k)
        K_d[L - i] = k

    cnt_d = [[0, 0] for _ in range(L)]
    for a in A:
        for i in range(L - 1, -1, -1):
            cnt_d[i][a & 1] += 1
            a >>= 1

    ans = 0
    lower_K = False
    for i, (d, (n_zero, n_one)) in enumerate(zip(K_d, cnt_d)):
        if n_zero <= n_one:
            n = 0
        else:
            n = 1
        
        if not lower_K:
            if d == 1 and n == 0:
                lower_K = True
            elif d == 0 and n == 1:
                n = 0

        num = cnt_d[i][n ^ 1]
        ans += num * 2 ** (L - 1 - i)

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 20532
#include <bits/stdc++.h>
using namespace std;
const int N = 300000;
int n;
int k;
int ai[N];
#define LL long long
LL ss[N], af[N], ans;

int tr[N];
void add(int t, int d) {for (; t <= n + 5; t += t & (-t)) tr[t] += d;}
int sum(int t) {int d = 0; for (; t; t -= t & (-t)) d += tr[t]; return d;}
int main()
{
    cin >> n >> k;
    for (int i = 1; i <= n; ++ i)
    {
        cin >> ai[i];
        ai[i] -= k;
        ss[i] = ss[i - 1] + ai[i];
        af[i] = ss[i];
    }
    sort(af, af + n + 1);
    int tot = unique(af, af + n + 1) - af;
    for (int i = 0; i <= n; ++ i)
        ss[i] = lower_bound(af, af + tot, ss[i]) - af + 1;
    add(ss[0], 1);
    for (int i = 1; i <= n; ++ i)
    {
        ans += sum(ss[i]);
        add(ss[i], 1);
    }
    cout << ans;
}


Measured memory_bytes: 6528
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<set>
#include<queue>

using namespace std;

#define INF 1000000007

int u(long long a, long long b){
  long long r, t;
  if(a < b){
    t = a;
    a = b;
    b = t;
  }
  r = a % b;
  while(r != 0){
    a = b;
    b = r;
    r = a %b;
  }
  return b;
}

int main(){
  long long a, b;
  cin >> a >> b;
  long long now = 1;
  int cnt = 0;
  for(int i = 1; i <= sqrt(double(a)); i++){
    if(a%i == 0){
      if(b % i == 0){
        if(u(i, now) == 1){
          now *= i;
          cnt++;
        }
      }
    }
  }
  for(int i = 1; i <= sqrt(double(a)) ; i++){
    if(a % i != 0 || a == 1) continue;
    if(b % (a/i) == 0){
      if(u((a/i), now) == 1){
        now *= a/i;
        cnt++;
      }
    }

  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;

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(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    int ok=1;
    for (int i=0;i<S.size();++i){
        if (S[i]!=S[0]) ok=0;
    }
    cout << (ok?"No":"Yes") << '\n';
}

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);  
	int n;
	cin >> n;
	vector<int> a(3 * n);
	for(int i = 0; i < 3 * n; i++) {
		cin >> a[i];
	}
	sort(a.rbegin(), a.rend());
	long long ans = 0;
	for(int i = 1; i < 2 * n; i += 2) {
		ans += a[i];
	}
	cout << ans << endl;
	return 0;	
}


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

int main()
{
    long long N;
    cin >> N;
    long long X[100], Y[100], H[100];
    for (long long i = 0; i < N; ++i) {
        cin >> X[i] >> Y[i] >> H[i];
    }

    for (int x = 0; x < 101; ++x) {
        for (int y = 0; y < 101; ++y) {
            bool found = true;
            long long h = -1;
            for (long long n = 0; n < N; ++n) {
                if (H[n] == 0) {
                    continue;
                }
                h = H[n] + abs(X[n] - x) + abs(Y[n] - y);
                break;
            }
            for (long long n = 0; n < N; ++n) {
                long long h_candidate = max(h - abs(X[n] - x) - abs(Y[n] - y), 0ll);
                if (H[n] != h_candidate) {
                    found = false;
                    break;
                }
            }
            if (found) {
                printf("%d %d %lld\n", x, y, h);
                return 0;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>

using namespace std;

using vlong = vector<long long>;
using vvint = vector< vector<int> >;

bool great(int a, int b){
  return a > b;
}

int main(){
  int n, k; cin >> n >> k;
  vlong a(n);
  int cnt = 0;
  for(int i = 0; i < n; i++){
    cin >> a[i];
    cnt += a[i];
  }
  vlong d;
  for(int i = 1; i <= sqrt(cnt); i++){
    if(cnt%i == 0){
      d.push_back(i);
      d.push_back(cnt/i);
    }
  }
  sort(d.begin(), d.end(), great);
  for(int i = 0; i < d.size(); i++){
    int t = d[i];
    vlong mini(n+1,0);
    vlong maxi(n+1,0);
    vlong rem(n, 0);
    for(int j = 0; j < n; j++){
      rem[j] = a[j]%t;
    }
    sort(rem.begin(), rem.end());
    for(int j = 1; j <= n; j++){
      mini[j] = mini[j-1] + rem[j-1];
      maxi[n-j] = maxi[n-j+1] + t-rem[n-j];
    }
    for(int j = 0; j <= n ; j++){
      if(abs(mini[j]-maxi[j])%t == 0){
        if(max(mini[j], maxi[j]) <= k){
          cout << t << endl;
          return 0;
        }
      }
    }
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;

double totheta(int k){
	double ret = k * M_PI / 180.0;
	return ret;
}

int main(){
	string input;
	int meter = 0, theta = 0;
	float x=0, y=0, c=0;
	while (true)
	{
		scanf("%d,%d", &meter, &theta);
		if (meter == 0 && theta == 0) { break; }
		x += meter * sin(c);
		y += meter * cos(c);
		c += totheta(theta);
	}
	int ansx, ansy;
	ansx = x;
	ansy = y;
	cout << ansx << endl << ansy << endl;
	return 0;
}

Measured memory_bytes: 3304
#include <iostream>

using namespace std;

int main(){
    int a[3];
    int tmp;
    
    cin >> a[0] >> a[1] >> a[2];
    
    if(a[0] > a[1]){
        tmp = a[0];
        a[0] = a[1];
        a[1] = tmp;
    }
    if(a[1] > a[2]){
        tmp = a[1];
        a[1] = a[2];
        a[2] = tmp;
    }
    if(a[0] > a[1]){
        tmp = a[0];
        a[0] = a[1];
        a[1] = tmp;
    }
    
    cout << a[0] << ' ' << a[1] << ' ' << a[2] << endl;
    
    return 0;
}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define inf 1e9+10
int main(){
    int n;
    ll W;
    int v[n+1];
    ll w[n+1];
    cin>>n>>W;
    ll max=n*1000+1;
    ll a[n+1][max];
    for(int i=1;i<=n;i++)
    cin>>w[i]>>v[i];
    for(int i=0;i<max;i++)
    a[1][i]=inf;
    a[1][v[1]]=w[1];
    a[1][0]=0;
    for(int i=2;i<=n;i++){
        for(int j=0;j<max;j++){
            if(v[i]>j)
            a[i][j]=a[i-1][j];
            else
            a[i][j]=min(a[i-1][j],w[i]+a[i-1][j-v[i]]);
        }
    }
    ll ans=0;
    for(int i=1;i<max;i++){
        if(a[n][i]<=W)
        ans=i;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 81728
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<iostream>
#include<iterator>
#include<math.h>
#include<cmath>
#include<sstream>
#include<vector>
#include<iomanip>
#include<string>
#include<fstream>
#include<algorithm>
#include<map>
#include<thread>
#include<stack>
#include<numeric>
#include<functional>
#include<queue>
#include<set>
#include<list>
#include<bitset>
#include <cassert>

typedef long long ll;

using namespace std;

const ll MOD = (ll)1000000007;
const ll inf = (ll)1e18;
const long double eps = 0.0000001;

struct th
{
	ll first = -1, second = -1;
	ll third = -1;
};


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

#ifdef _DEBUG
	/*freopen("sorting.in", "r", stdin);
	freopen("sorting.out", "w", stdout);*/

	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int n;
	cin >> n;

	vector<long double> a(n);
	for (auto &i : a)
	{
		cin >> i;
	}
	sort(a.begin(), a.end());

	long double ans = a[0] + a[1];
	ans /= 2.;

	for (int i = 2; i < n; ++i)
	{
		ans += a[i];
		ans /= 2.;
	}

	cout << ans;


	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int x = scanner.nextInt();
		scanner.close();

		if (x % 2 == 1) {
			System.out.println((x - 1) / 2);
		} else {
			System.out.println(x / 2 - 1);
		}
	}
}


Measured memory_bytes: 23636
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let mut vec: Vec<(usize, usize)> = Vec::with_capacity(n);
    for i in 1..(n+1) {
        vec.push((i, iterator.next().unwrap().parse().unwrap()));
    }

    vec.sort_by(|a, b| (a.1).cmp(&b.1));
    let ans: Vec<String> = vec.iter().map(|it| it.0.to_string()).collect();
    return ans.connect(" ");
}

#[test]
fn test() {
    assert_eq!(
        solve(
            r"3
2 3 1"
        ),
        "3 1 2"
    );
//    assert_eq!(
//        solve(
//            r""
//        ),
//        ""
//    );
//    assert_eq!(
//        solve(
//            r""
//        ),
//        ""
//    );
}


Measured memory_bytes: 12540
#include <bits/stdc++.h>
#define maxn 100086

using namespace std;

int l, r, d;
int ans;

int main(){
	scanf("%d%d%d", &l, &r, &d);
	for(int i = l;i <= r;i++) ans += i % d == 0;
	printf("%d", ans);
}

Measured memory_bytes: 3724
h, w = map(int, input().split())
s = [input() for i in range(h)]
way = ((1,1),(1,0),(1,-1),(0,1),(0,-1),(-1,0),(-1,1),(-1,-1))
ans = [[0 for j in range(w)] for i in range(h)]

for i in range(h):
    for j in range(w):
        if s[i][j] == "#":
            ans[i][j] = "#"
            continue
        for k in way:
            if not (0 <= i+k[0] < h and 0 <= j+k[1] < w):
                continue
            if s[i+k[0]][j+k[1]] == "#":
                ans[i][j] += 1

for i in range(h):
    print(''.join(map(str, ans[i])))

Measured memory_bytes: 3064
n, m = map(int, input().split())
mat = [list(map(int, input().split())) for _ in range(m)]

red = [False]*n
red[0] = True
balls = [1]*n

for x, y in mat:
    x -= 1
    y -= 1
    if red[x] is True:
        red[y] = True
    balls[x] -= 1
    balls[y] += 1
    if balls[x] == 0:
        red[x] = False

ans = 0
for r in red:
    if r is True:
        ans += 1
print(ans)

Measured memory_bytes: 28964
#include <iostream>
using namespace std;
int main(void){
  const int mod=1000000007;
  int h,w,i,j,g[1010][1010]={};
  char c;
  bool th[1010][1010]={false};
  cin >> h >> w;
  for (i=1;i<=h;i++){
    for (j=1;j<=w;j++){
      cin >> c;
      if (c=='#') th[i][j]=true;
    }
  }
  g[0][1]=1;
  for (i=1;i<=h;i++){
    for (j=1;j<=w;j++){
      if (th[i][j]) g[i][j]=0;
      else g[i][j]=(g[i-1][j]+g[i][j-1])%mod;
    }
  }
  cout << g[h][w] << '\n';
  return 0;
}

Measured memory_bytes: 5248
#include<bits/stdc++.h>
using namespace std;
const int N=3e5+12;
char s[N];
int l[N],r[N];
int main()
{
	int n;
	scanf("%d",&n);
	scanf("%s",&s[1]);
	for(int i=1;i<=n;i++) 
	{
		l[i]=l[i-1];
		if(s[i]=='W') l[i]++;
	}
	for(int i=n;i>=1;i--) 
	{
		r[i]=r[i+1];
		if(s[i]=='E') r[i]++;
	}
	int mini=0x3f3f3f3f;
	for(int i=1;i<=n;i++) 	
	{
		mini=min(mini,l[i-1]+r[i+1]);
	}
	printf("%d\n",mini);
	return 0;
}

Measured memory_bytes: 2944
#include<iostream>
using namespace std;
typedef long long ll;

const int MAX_N = 2 * 1e3 + 2;

ll A[MAX_N];

int main() {
    int N;
    ll Z, W;
    cin >> N >> Z >> W;
    for (int i = 0; i < N; i++) cin >> A[i];
    if (N == 1) {
        cout << abs(W - A[0]) << endl;
        return 0;
    }
    cout << max(abs(W - A[N - 1]), abs(A[N - 1] - A[N - 2])) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <string.h>

using namespace std;

int exist[100000];
int needed[100000];
int main(){
	int n,k;
	while(1)
	{
		cin >> n >> k;
		if (n==0)break;
		memset(exist,0,sizeof(exist));
		memset(needed,0,sizeof(needed));
		for (int i=0; i<k; i++)
		{
			cin >> exist[i];
		}
		int tmp;
		for (int i=0; i<n; i++)
		{
			for (int j=0; j<k; j++)
			{
				cin >> tmp;
				needed[j]+=tmp;
			}
		}
		int ok=1;
		for (int i=0; i<k; i++)
		{
			if (exist[i]<needed[i])
			{
				ok=0;
				break;
			}
		}
		(ok==1)?cout << "Yes" << endl:cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 1632
#include <iostream>
#include<bits/stdc++.h>
#include<unordered_set>
#define ll long long
using namespace std;
int main(){
  ll x,n;
  cin>>x>>n;
  unordered_set<ll>st;
  for(ll i=1;i<=n;i++)
    {
        int t;
        cin>>t;
        st.insert(t);
    }
    if(st.find(x)==st.end())
    {
        cout<<x<<endl;
        return 0;
    }
    bool p=true;
    ll x1=x-1;
    ll x2=x+1;
    while(1)
    {
        if(p)
        {
            if(st.find(x1)==st.end())
            {
                cout<<x1<<endl;
                return 0;
            }
            x1--;
            p=false;
        }
        else
        {
            if(st.find(x2)==st.end())
            {
                cout<<x2<<endl;
                return 0;
            }
            x2++;
            p=true;
        }
    }
    return 0;
}


Measured memory_bytes: 3628
n = int(input())
a = list(map(int,input().split()))

def gcd(x,y):
    while y != 0:
        x,y = y,x%y
    return x

l,r = [0],[0]
for i in range(n-1):
    l.append(gcd(l[-1],a[i]))
    r.append(gcd(r[-1],a[n-i-1]))

ans = 0
for i in range(n):
    ans = max(ans,gcd(l[i],r[n-i-1]))
print(ans)


Measured memory_bytes: 14076
<?php
while(true){
    $card = trim(fgets(STDIN));
    if($card == "-"){ 
        break; 
    }
     
    $count = intval(trim(fgets(STDIN)));
  
    for($i = 0; $i < $count; $i++){
        $shuffle = trim(fgets(STDIN));
        $divide1 = substr($card, 0, $shuffle);
        $divide2 = substr($card, $shuffle);      
        $card = $divide2.$divide1;
    }
    echo $card.PHP_EOL;
}
?>


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

using namespace std; 
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>; 

#define INF 10000000000
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

//#define DEBUG

int main_(){
  int N;
  string s;
  cin>>N>>s;
  int red=0,blue=0;
  for(int i=0;i<N;i++){
    if(s[i]=='R')red++;
    if(s[i]=='B')blue++;
  }
  if(red>blue)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
#ifdef DEBUG
  vector<string>test;
  /*
   * input for debug
   */
  for(int i=0;i<test.size();++i){
    stringbuf buf;
    streambuf*out=cout.rdbuf(&buf);
    cout<<test[i]<<flush;
    cout.rdbuf(out);
    streambuf*in=cin.rdbuf(&buf);
    main_();
    cin.rdbuf(in);
    cout<<endl;
  }
#else
  main_();
#endif

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    while(true){
      int n = sc.nextInt();
      if(n == 0) break;
      int sum = 0;
      for(int i=0;i<n*(n-1)/2;i++){
        sum += sc.nextInt();
      }
      System.out.println(sum/(n-1));
    }
  }
}

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


int main(){
	char ch,ch2;
	
	while(1){
		scanf("%c" ,&ch);
		
		if(islower(ch)){
			ch2 = toupper(ch);
			cout << ch2;
		}else{
			ch2 = tolower(ch);
			cout << ch2;
		}
		
		if(ch == '\n'){
			break;
		}
	}
	
			
	


    return 0;
}

Measured memory_bytes: 3112
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
	static final int MAX = 2_147_483_646; // intMax 
	static final int INF = 1_000_000_000; // 10^9  
	public static void main(String[] args) throws Exception{
		hayami saori = new hayami();
		int n = saori.saori_hayami();
		for(int i = 0;i <= 100;i++){
			if(n <= 1000*i){
				System.out.println(1000*i-n);
				return;
			}
		}
		
		saori.close();
	}
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}


Measured memory_bytes: 32392