akhauriyash/Code-Regression huggingface dataset:
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
using namespace std;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<pii,int> ppiii ;
typedef unsigned long long ull ;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
vi p;
int main(){
	int n;
	cin>>n;
	vi a(n);
	int res=0;
	rep(i,n){
				cin>>a[i];
		if(a[i]%2==1)res++;
	}
	if(res%2==0)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	
}

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

int count(int n, int x){
    int cnt = 0;
    for ( int i = 1; i <= n-2; i++ ){
        for ( int j = i+1; j <= n-1; j++ ){
            for ( int k = j+1; k <= n; k++ ){
                if ( i + j + k == x ) cnt++;
            }
        }
    }
    return cnt;
}

int main(){
    int n, x;
    
    while(1){
        cin >> n >> x;
        if ( n == 0 && x == 0 ) break;
        cout << count(n, x) << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3092
/*input
31
4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4 6 2 6 4 3 3 8 3 2 7 9 5 0
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define int long long 
#define double long double
#define f first
#define s second
#define mp make_pair
#define pb push_back

#define RE(i,n) for (int i = 1; i <= n; i++)
#define RED(i,n) for (int i = n; i > 0; i--)
#define REPS(i,n) for(int i = 1; (i*i) <= n; i++)
#define REP(i,n) for (int i = 0; i < (int)n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)

#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define print(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout << *it << " "; cout << endl;
#define debug(x) cout << x << endl;
#define debug2(x,y) cout << x << " " << y << endl;
#define debug3(x,y,z) cout << x << " " << y << " " << z << endl;

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

const int INF = 1e18+1;
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;

int raise(int a,int n,int m = MOD){
  if(n == 0)return 1;
  if(n == 1)return a;
  int x = 1;
    x *= raise(a,n/2,m);
    x %= m;
    x *= x;
    x %= m;
    if(n%2)x*= a;
    x %= m;
    return x;
}

int floor1(int n,int k){
    if(n%k == 0 || n >= 0)return n/k;
    return (n/k)-1;
}

int ceil1(int n,int k){
    return floor1(n+k-1,k);
}

void solve(){
  	double ans = 1;
  	int n;
  	cin >> n;
  	bool leaveit = 0;
  	bool zero = 0;
  	RE(i,n){
  		double x;
  		cin >> x;
  		ans *= x;
  		zero |= (x==0);
  		if(ans > (double)1e18){
  			leaveit = 1;
  		}
  	}
  	if(zero)cout << 0;
  	else if(leaveit)cout << -1;
  	else cout << (int)ans;
}

signed main(){
  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  //freopen(".in","r",stdin);freopen(".out","w",stdout);
  int t = 1;
  //cin >> t;
  while(t--){
    solve();
  }
  return 0;
}

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

int main() {
	vector<int> M(2), D(2);
	rep(i, 2) cin >> M[i] >> D[i];
	if (D[1] == 1) cout << 1 <<endl;
	else cout << 0 << endl;
	return 0;
}


Measured memory_bytes: 380
#include <stdio.h>

int main(void)
{
	int w,h,x,y,r;
	
	scanf("%d %d %d %d %d",&w,&h,&x,&y,&r);
	
	if(x-r>=0&&x+r<=w&&y-r>=0&&y+r<=h) puts("Yes");
	else puts("No");
	return 0;
}

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

int main() {
    string S;
    ll K;
    cin >> S >> K;
    K--;
    for(int i = 0; i < S.length(); ++i) {
        if(S[i]!='1'){
            if(K>=i)
                cout << S[i] << endl;
            else
                cout << 1 << endl;
            break;
        }
        if(i>=K){
            cout << 1 << endl;
            break;
        }
    }
    return 0;
}


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

int main(void){
    int a, b;
    int result;
    
    cin >> a >> b;
    
    if(a >= 13){
        result = b;
    } else if(a <= 12 && a >= 6){
        result = b / 2;
    } else {
        result = 0;
    }
    
    cout << result << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int n,num=0,c_num=0,ans=0,tmp;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>tmp;
		if(tmp==c_num)num++;
		else {
			ans+=num/2;
			c_num=tmp;
			num=1;
		}
	}
	ans+=num/2;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner (System.in);
		
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int [] d = new int [n];
		int i, j;
		int temp;
		int calorie;
		int max = 0;

		for (i = 0; i < n; i++) {
			d[i] = sc.nextInt();
		}

		for (i = 0; i < n - 1; i++) {
			for (j = i + 1; j < n; j++) {
				if (d[i] < d[j]) {
					temp = d[i];
					d[i] = d[j];
					d[j] = temp;
				}
			}
		}

		if (n == 0) {
			System.out.println(a);
		} else {
			for (i = 0; i < n; i++) {
				int sum = c;
				for (j = 0; j < i; j++) {
					sum += d[j];
					calorie = sum / (a + i * b);
					if (max < calorie) {
						max = calorie;
					}
				}
			}
			System.out.println(max);
		}
		

	}

}

Measured memory_bytes: 18224
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define all(in) in.begin(), in.end()
#define FIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef pair<int, int> PII;

int main(){
    FIO;
    ll n, m;
    cin >> n >> m;
    vector<ll> adj[m+1];
    for(ll i = 0 ; i < n ; i++){
        ll x, y;
        cin >> x >> y;
        if(x <= m){
            adj[x].push_back(y);
        }
    }
    priority_queue<ll> pq;
    ll ans = 0;
    for(ll i = 1 ; i <= m ; i++){
        for(ll j = 0 ; j < adj[i].size() ; j++){
            pq.push(adj[i][j]);
        }
        if(pq.size()){
            ans += pq.top();
            pq.pop();
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5632
# -*- coding: utf-8 -*-
import collections
n,q = map(int,input().split())
a_b_list = [list(map(int,input().split())) for i in range(n-1)]
p_x_list = [list(map(int,input().split())) for i in range(q)]

graph_direct_list = [[] for _ in range(n+1)]
for i in range(n-1):
    a_i = a_b_list[i][0]
    b_i = a_b_list[i][1]
    graph_direct_list[a_i].append(b_i)
    graph_direct_list[b_i].append(a_i)

counter_init_list = [0 for _ in range(n+1)]


for j in range(q):
    p_j = p_x_list[j][0]
    x_j = p_x_list[j][1]
    counter_init_list[p_j] += x_j

counter_list = [0 for _ in range(n+1)]
graph_vertex_checked_list = [0 for _ in range(n+1)]


graph_vertex_stack_que=collections.deque()
graph_vertex_stack_que.append(1) # start
while graph_vertex_stack_que:
    v = graph_vertex_stack_que.pop()
    graph_vertex_checked_list[v] = 1
    counter_list[v] += counter_init_list[v]
    for u in graph_direct_list[v]:
        if graph_vertex_checked_list[u] == 1:
            continue
        counter_list[u] += counter_list[v]
        graph_vertex_stack_que.append(u)
print(*counter_list[1:])


Measured memory_bytes: 122508
#include <stdio.h>

int main(void) {
	int did=0;
	int price;
	int n10,n50,n100,n500;
	int t10,t50,t100,t500;
	int pay,back;
	int b10,b50,b100,b500;
	int now,min;
	int r10,r50,r100,r500;
	while(1) {
		scanf("%d",&price);
		if(price==0)break;
		if(did)putchar('\n');
		scanf("%d%d%d%d",&n10,&n50,&n100,&n500);
		min=10000;
		r10=r50=r100=r500=0;
		for(t10=0;t10<=n10;t10++) {
			for(t50=0;t50<=n50;t50++) {
				for(t100=0;t100<=n100;t100++) {
					for(t500=0;t500<=n500;t500++) {
						pay=t10*10+t50*50+t100*100+t500*500;
						if(pay<price)continue;
						back=pay-price;
						b500=back/500;
						b100=(back%500)/100;
						b50=(back%100)/50;
						b10=(back%50)/10;
						if(t10*b10 || t50*b50 || t100*b100 || t500*b500)continue;
						now=n10-t10+b10;
						now+=n50-t50+b50;
						now+=n100-t100+b100;
						now+=n500-t500+b500;
						if(now<min) {
							min=now;
							r10=t10;
							r50=t50;
							r100=t100;
							r500=t500;
						}
					}
				}
			}
		}
		if(r10>0)printf("10 %d\n",r10);
		if(r50>0)printf("50 %d\n",r50);
		if(r100>0)printf("100 %d\n",r100);
		if(r500>0)printf("500 %d\n",r500);
		did=1;
	}
	return 0;
}

Measured memory_bytes: 420
class Heap
  def initialize
    @heap = [nil] # 1-origin
  end

  def push(n)
    @heap << n
    i = @heap.size - 1
    while i > 1 && value(@heap[parent(i)]) < value(@heap[i])
      @heap[parent(i)], @heap[i] = @heap[i], @heap[parent(i)]
      i = parent(i)
    end
  end

  def pop
    return nil if @heap.size <= 1
    max = @heap[1]
    tmp = @heap.pop
    return max if @heap.size == 1
    @heap[1] = tmp
    max_heapify(1)
    max
  end

  def empty?
    @heap.size == 1
  end

  def inspect
    @heap
  end

  private

  def left(i)
    2 * i
  end

  def right(i)
    2 * i + 1
  end

  def parent(i)
    i / 2
  end

  def max_heapify(i)
    l = left(i)
    r = right(i)
    largest = i
    largest = l if l < @heap.size && value(@heap[l]) > value(@heap[i])
    largest = r if r < @heap.size && value(@heap[r]) > value(@heap[largest])
    if largest != i
      @heap[i], @heap[largest] = @heap[largest], @heap[i]
      max_heapify(largest)
    end
  end

  def value(element)
    element.value
  end
end

class ABC
  attr_reader :value, :a_i, :b_i, :c_i

  def initialize(value, a_i, b_i, c_i)
    @value = value
    @a_i = a_i
    @b_i = b_i
    @c_i = c_i
  end

  def to_key
    "#{@a_i}:#{@b_i}:#{@c_i}"
  end
end

def cake123(k, a, b, c)
  a.sort_by! { |x| -1 * x }
  b.sort_by! { |x| -1 * x }
  c.sort_by! { |x| -1 * x }

  heap = Heap.new
  used = {}
  max = ABC.new(a[0] + b[0] + c[0], 0, 0, 0)
  used[max.to_key] = true
  heap.push(max)

  k.times do
    abc = heap.pop
    puts abc.value

    [
      [abc.a_i + 1, abc.b_i, abc.c_i],
      [abc.a_i, abc.b_i + 1, abc.c_i],
      [abc.a_i, abc.b_i, abc.c_i + 1],
    ].each do |a_i, b_i, c_i|
      next if a_i >= a.size || b_i >= b.size || c_i >= c.size
      abc = ABC.new(a[a_i] + b[b_i] + c[c_i], a_i, b_i, c_i)
      next if used[abc.to_key]
      used[abc.to_key] = true
      heap.push(abc)
    end
  end
end

x, y, z, k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)
c = gets.split.map(&:to_i)
cake123(k, a, b, c)

Measured memory_bytes: 3448
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <math.h>
#include <stdio.h>
#define INF 1000000000
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
typedef long long int ll;
using namespace std;

int main() {

	int n, ans = 0; cin >> n;
	for (int i = 1; i <= n; i++) {
		string s = to_string(i);
		if (s.size() % 2 == 1) ans++;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define loop(i,a,b) for(int i=(a); i<int(b); i++)
#define rep(i,b) loop(i,0,b)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;

int const N=1299709+10;
vb isp;
vi ps;
void eratos(){
    isp.assign(N,true);
    ps.reserve(100000);
    isp[0]=isp[1]=false;
    ps.push_back(2);
    for(int i=4;i<N;i+=2){
        isp[i]=false;
    }
    for(int i=3;i<N;i++){
        if(!isp[i]) continue;
        ps.push_back(i);
        for(int j=i+i;j<N;j+=i){
            isp[j]=false;
        }
    }
}

int main(){
    eratos();
    int k;
    while(cin>>k&&k){
        auto lb=lower_bound(all(ps),k);
        auto i=lb-1;
        // cout << *lb << " " << *i << endl;
        if(k==*lb){
            cout << 0 << endl;
        } else {
            cout << *lb - *i  << endl;
        }
    }
}

Measured memory_bytes: 1528
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseFloat(x::SubString{String}) = parse(Float64, x)
parseFloat(x::Char) = parse(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n,z,w=parseMap(split(readline()))
    a=parseMap(split(readline()))
    if n==1
        println(abs(a[1]-w))
    else
        println(max(abs(a[end]-w),abs(a[end]-a[end-1])))
    end
end
main()

Measured memory_bytes: 168980
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

constexpr int INF = 1 << 30;

int main() {
    int n, ma, mb;
    cin >> n >> ma >> mb;

    int dp[401][401];
    fill(dp[0], dp[401], INF);
    dp[0][0] = 0;

    for (int h = 0; h < n; h++) {
        int a, b, c;
        cin >> a >> b >> c;

        for (int i = 400; i >= a; i--) {
            for (int j = 400; j >= b; j--) {
                dp[i][j] = min(dp[i][j], dp[i - a][j - b] + c);
            }
        }
    }

    int r = INF;
    for (int i = 1;; i++) {
        if (ma * i > 400 || mb * i > 400) break;
        r = min(r, dp[ma * i][mb * i]);
    }

    if (r == INF) r = -1;

    cout << r << endl;

    return 0;
}

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

#define rep(i, n) for (int i=0; i<(n); ++i)
using ll = long long;
using P = pair<int, int>;

int main() {
  string s;
  cin >> s;
  string front = s.substr(0, s.size()/2);
  string back = s.substr(s.size()/2 + 1, s.size());

  string tmp = s;
  reverse(s.begin(), s.end());

  string rfront = front;
  string rback = back;
  reverse(front.begin(), front.end());
  reverse(back.begin(), back.end());
  if (tmp == s && front == rfront && back == rback) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


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

int a[100010];

int main(){
    int N;
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>a[i];
    }
    long long sum=0;
    //+-+-
    long long ans1=0;
    for(int i=0;i<N;i++){
        sum+=a[i];
        if(i%2==0){
            if(sum<=0){
                ans1+=(1-sum);
                sum=1;
            }
        }else{
            if(sum>=0){
                ans1+=(sum+1);
                sum=-1;
            }
        }
    }
    //-+-+
    sum=0;
    long long ans2=0;
    for(int i=0;i<N;i++){
        sum+=a[i];
        if(i%2==0){
            if(sum>=0){
                ans2+=(sum+1);
                sum=-1;
            }
        }else{
            if(sum<=0){
                ans2+=(1-sum);
                sum=1;
            }
        }
    }
    cout<<min(ans1,ans2)<<endl;
    return 0;
}

Measured memory_bytes: 640
N, K = list(map(int, input().split()))
height = list(map(int, input().split()))
height2=height.copy()
ans = 10 ** 10
# if N==K:
#     cost=0
#     for i in range(1,N):
#         tarou=max(height2[:i])
#         if tarou>=height2[i]:
#             cost+=tarou-height2[i]+1
#             height2[i]=tarou+1
#     print(cost)
#     exit()
for i in range(2 ** N):
    cost = 0
    height2 = height.copy()
    if bin(i).count("1")==K:
        for j in range(1,N):
            if i >> j & 1:
                    tarou=max(height2[:j])
                    if height2[j]<=tarou:
                        cost+=tarou-height2[j]+1
                        height2[j]=tarou+1
        if N==K:
            print(cost)
            exit()
        if ans > cost:
            ans = cost

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int A, B;
int main()
{
	cin >> A >> B;
	if (B == 1) {
		cout << 0 << endl;
		return 0;
	}
	for (int i = 1; i <= 40; i++)
	{
		if (A + (A - 1) * (i - 1) >= B)
		{
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
w , h , n = map(int,input().split())
p = []
lef = 0
rig = w
up = h
dow = 0
for i in range(n):
    x , y , a = map(int,input().split())
    if a == 1:
        lef = max(lef,x)
    elif a == 2:
        rig = min(rig,x)
    elif a == 3:
        dow = max(dow,y)
    elif a == 4:
        up = min(up,y)
        
print(max(0,rig-lef)*max(0,up-dow))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int V,E;
int m[9][9];
int cnt,b;
void f(int x){
    b+=(1<<x);
    if(b==(1<<V)-1){
        cnt++;
    }
    else{
        for(int i=0;i<V;i++){
            if(m[x][i]&&(b&(1<<i))==0){
                f(i);
            }
        }
    }
    b-=(1<<x);
}
int main(){
    cin>>V>>E;
    for(int i=0;i<E;i++){
        int x,y;
        cin>>x>>y;
        x--;y--;
        m[x][y]=m[y][x]=1;
    }
    f(0);
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 256
use proconio::input;
use proconio::fastout;


#[fastout]
fn main() {
    input! {
        n: usize,
        a: [usize; n],
    }

    let mut xor_sum: usize = 0;
    for v in &a {
        xor_sum ^= v;
    }

    for v in a {
        print!("{} ", xor_sum ^ v);
    }
    println!();

}


Measured memory_bytes: 6304
#include<stdio.h>
int main(void){
  
  int n,i,count = 0;
  char str[105];
  
  scanf("%d",&n);
  scanf("%s",str);
  
  while(1){
   if(str[count] == '\0') break;
    count++;
  }
  
  for(i=0;i<n;i++){
    if(i<count) printf("%c",str[i]);
  }
  
  if(count > n) printf("...");
  
  return 0;
}

Measured memory_bytes: 1732
#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <random>
#include <string>
#include <bitset>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <cstring>
#include <cstdlib>
#include <cctype>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define FORR(i, m, n) for(int i = m; i >= n; --i)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define INF 999999999

using namespace std;

typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

llong pow(int x, int n) {
    llong ans = x;
    if (n == 0) return 1;

    for(int i = 0; i < n - 1; i++) {
        ans *= x;
    }

    return ans;
}

void swap(int *X, int *Y){
    int t = *X; *X = *Y; *Y = t;
}

const static int MAX = 500;

int h, w;
char field[MAX][MAX];
bool flag = false, visited[MAX][MAX] = {false};

void dfs(int i, int j) {
    if (field[i][j] == 'g') {
        flag = true;
        return;
    }
    if (visited[i][j]) return;
    visited[i][j] = true;

    rep(k, 4) {
        if (0 <= i + dx[k] && i + dx[k] <= h - 1 && 0 <= j + dy[k] && j + dy[k] <= w - 1 && field[i + dx[k]][j + dy[k]] != '#') {
            dfs(i + dx[k], j + dy[k]);
        }
    }
}

int main() {
    string a, b, c;
    cin >> a >> b >> c;
    cout << a[0] << b[1] << c[2] << endl;

    return 0;
}

Measured memory_bytes: 256
from collections import Counter
n, *lst = map(int, open(0).read().split())
c1, c2 = [(0, 0)] + sorted(Counter(lst[::2]).items(), key=lambda x: x[1]), [(0, 0)] + sorted(Counter(lst[1::2]).items(), key=lambda x: x[1])
if c1[-1][0] != c2[-1][0]:
  print(n - c1[-1][1] - c2[-1][1])
else:
  print(n - max(c1[-2][1] + c2[-1][1], c1[-1][1] + c2[-2][1]))

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

struct Dice{
	int num[6];
	void roll(char c){
		char tmp;
		if(c == 'N'){
			tmp = num[4];
			num[4] = num[0];
			num[0] = num[1];
			num[1] = num[5];
			num[5] = tmp;
		}
		else if(c == 'E'){
			tmp = num[2];
			num[2] = num[0];
			num[0] = num[3];
			num[3] = num[5];
			num[5] = tmp;
		}
		else if(c == 'S'){
			tmp = num[1];
			num[1] = num[0];
			num[0] = num[4];
			num[4] = num[5];
			num[5] = tmp;
		}
		else if(c == 'W'){
			tmp = num[3];
			num[3] = num[0];
			num[0] = num[2];
			num[2] = num[5];
			num[5] = tmp;
		}
	}
	void match1(int n){
		int i = 0;
		while(num[i] != n){
			i++;
		}
		switch(i){
			case 0: break;
			case 1: roll('N'); break;
			case 2: roll('W'); break;
			case 3: roll('E'); break;
			case 4: roll('S'); break;
			case 5: roll('S'); roll('S'); break;
		}
	}
	void match2(int n){
		int i = 0;
		while(num[i] != n){
			i++;
		}
		switch(i){
			case 1: break;
			case 2: roll('W'); roll('S'); roll('E'); break;
			case 3: roll('E'); roll('S'); roll('W'); break;
			case 4: roll('W'); roll('S'); roll('E'); roll('W'); roll('S'); roll('E'); break;
		}
	}
};

int main(){
	Dice d;
	string s;
	for(int i = 0; i < 6; i++){
		cin >> d.num[i];
	}
	int t;
	cin >> t;
	for(int i = 0; i < t; i++){
		int a, b;
		cin >> a >> b;
		d.match1(a);
		d.match2(b);
		cout << d.num[2] << endl;
	}
	return 0;
}


Measured memory_bytes: 3080
#include<iostream>
#include<cstdio>

using namespace std;

const int maxn=2e6+5;
const int maxv=1e4+5;

int n,s[maxn],b[maxn],c[maxv];

int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&s[i]);
        c[s[i]]++;
    }
    for(int i=1;i<=maxv;i++){
        c[i]=c[i]+c[i-1];
    }
    for(int j=n;j>=0;j--){
        b[c[s[j]]]=s[j];
        c[s[j]]--;
    }
    for(int i=1;i<=n;i++){
        if(i>1){
            printf(" ");
        }
        printf("%d",b[i]);
    }
    printf("\n");
    return 0;
}
/*
7
2 5 1 3 2 3 0
8
4 5 0 3 1 5 0 5
*/


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


int mod;
struct mint {
  ll x;
  mint(ll x):x(x%mod){}
  mint& operator+=(const mint a) {
    (x += a.x) %= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    (x += mod - a.x) %= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) {
    mint res(*this);
    return res*=a;
  }
 
  mint pow(ll n) const {
    if(!n)return 1;
    mint tmp = pow(n/2);
    tmp*=tmp;
    if(n%2==1)tmp*=x;
    return tmp;
  }

  mint inv() const {
    return pow(mod-2);
  }
  
  mint& operator/=(const mint a){
    return (*this) *= a.inv();
  }
  mint operator/(const mint a){
    mint res(*this);
    return res/=a;
  }
};


mint choose(ll n,ll a){
  mint nu=1,de=1;
  rep(i,a){
    nu*=(n-i);
    de*=(i+1);
  }
  return nu/de;
}

int main(){
  mod =1'000'000'000+7;
  ll n;
  int a,b;
  cin >> n >> a >> b;
  mint ans = 2;
  ans = ans.pow(n);
  ans -= 1;
  ans -= choose(n,a) + choose(n,b);
  cout << ans.x << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){

    string odd = "";

    string s;
    cin >> s;

    for (int i = 0; i < s.size(); i++){
        if (i % 2 == 0){
            odd += s[i];
        }
    }

    cout << odd << endl;



    return 0;
}

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'
#define rep(i,n) for(int_fast32_t i = 0; i < ((int_fast32_t)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int_fast32_t i = 1; i <= ((int_fast32_t)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int_fast32_t i = ((int_fast32_t)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int_fast32_t i = ((int_fast32_t)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

using namespace std;

template<typename T>
using vec = vector<T>;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using ll = long long;
using ld = long double;
using vi = vec<int_fast32_t>;
using vl = vec<int_fast64_t>;
using vld = vec<ld>;
using vii = vec<vi>;  // 2次元配列
using PII = pair<int_fast32_t, int_fast32_t>;

template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

const ld Pi = std::acos(-1.0L);
constexpr ll infll = (1LL<<62)-1;
constexpr int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
//    cout << fixed << setprecision(15);

    string s,t;
    i32 n,m;
    vec<int> p;
    char tmp;
    cin >> s;
    for(auto tmp : s) {
        p.push_back(int(tmp-'0'));
    }
    i32 x = *--p.end();
    if(x == 2 || x == 4 ||x == 5 ||x == 7 ||x == 9) cout << "hon";
    else if(x == 0 ||x == 1 ||x == 6 ||x == 8) cout << "pon";
    else cout << "bon";
    cout << '\n';

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-START_TIME)/CLOCKS_PER_SEC));
}


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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

template<typename T1,typename T2>ostream& operator<<(ostream& os,const pair<T1,T2>& a) {os << "(" << a.first << ", " << a.second << ")";return os;}

const char newl = '\n';

int main() {
    int n,k,c;
    cin >> n >> k >> c;
    string s;
    cin >> s;
    vector<int> ans;
    set<P> st;
    st.insert(P(-1e9,0));
    for (int i = 0;i < n;++i) if (s[i] == 'o') {
        auto it = st.lower_bound(P(i-c,0));
        st.insert(P(i,(--it)->second+1));
    }
    auto it = prev(st.end());
    if (it->second > k) return 0;
    while (it != st.begin()) {
        if (it->second > prev(it)->second) ans.push_back(it->first);
        it = prev(st.lower_bound(P(it->first-c,0)));
    }
    int m = ans.size();
    reverse(ans.begin(),ans.end());
    for (int i = 0;i < m;++i) cout << ans[i]+1 << newl;
}

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

int main(){
  const int inf = 1000000;
  int N, M;
  cin >> N >> M;
  
  int a[1000], b[1000], c[1000], dist[100][100];
  
  for(int i = 0; i < M; i++){
    cin >> a[i] >> b[i] >> c[i];
    a[i]--, b[i]--;
  }
  
  for(int i = 0; i < N; i++){
    for(int j = 0; j < N; j++){
      if(i==j)
        dist[i][j] = 0;
      else
        dist[i][j] = inf;
  	}
  }
  
  for(int i = 0; i < M; i++){
    dist[a[i]][b[i]] = min(dist[a[i]][b[i]], c[i]);
    dist[b[i]][a[i]] = min(dist[b[i]][a[i]], c[i]);
  }
  
  for(int k = 0; k < N; k++){
    for(int i = 0; i < N; i++){
      for(int j = 0; j < N; j++){
        dist[i][j] = min(dist[i][j], dist[i][k]+dist[k][j]);
      }
    }
  }
  
  int ans = M;
  for(int i = 0; i < M; i++){
    bool flag = false;
    for(int j = 0; j < N; j++){
      if(dist[j][a[i]]+c[i] == dist[j][b[i]])
        flag = true;
    }
    if(flag)
      ans--;
  }
  
  cout << ans << endl;
  
  return 0;
}

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

int main() {
    int n, idx = 0;
    string s;
    cin >> n >> s;
    while ((unsigned int) idx + 1 < s.size()) {
        if (s.at(idx) == s.at(idx + 1)) {
            s.erase(idx, 1);
        } else {
            idx++;
        }
    }
    cout << s.size() << endl;
}


Measured memory_bytes: 3720
from sys import stdin
import itertools
N = int(stdin.readline())
L = [int(i) for i in stdin.readline().split()]
counter = 0
for i in itertools.combinations(L,  3):
    if i[0] != i[1]:
        if i[1] != i[2]:
            if i[2] != i[0]:
                if i[0] + i[1] > i[2]:
                    if i[1] + i[2] > i[0]:
                        if i[2] + i[0] > i[1]:
                            counter += 1
print(counter)

Measured memory_bytes: 9196
#pragma GCC optimize("Ofast")

#include <algorithm>      //sort,二分探索,など
#include <bitset>         //固定長bit集合
#include <cmath>          //pow,logなど
#include <complex>        //複素数
#include <deque>          //両端アクセスのキュー
#include <functional>     //sortのgreater
#include <iomanip>        //setprecision(浮動小数点の出力の誤差)
#include <iostream>       //入出力
#include <iterator>       //集合演算(積集合,和集合,差集合など)
#include <map>            //map(辞書)
#include <numeric>        //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>          //キュー
#include <set>            //集合
#include <stack>          //スタック
#include <string>         //文字列
#include <unordered_map>  //イテレータあるけど順序保持しないmap
#include <unordered_set>  //イテレータあるけど順序保持しないset
#include <utility>        //pair
#include <vector>         //可変長配列

using namespace std;


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

	string tmp;
    int a, b;
	stack<int> s;
	while(cin >> tmp){
		if(tmp == "+"){
			a = s.top();
			s.pop();
			b = s.top();
			s.pop();
			s.push(b + a);
		}else if(tmp == "-"){
			a = s.top();
			s.pop();
			b = s.top();
			s.pop();
			s.push(b - a);
		}else if(tmp == "*"){
			a = s.top();
			s.pop();
			b = s.top();
			s.pop();
			s.push(b * a);
		}else{
			s.push(stoi(tmp));
		}
	}
	cout << s.top() << "\n";
    
	return 0;
}


Measured memory_bytes: 3236
#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
using namespace std;
#define ll long long
#define r(i,n) for(int i=0;i<n;i++)
#define rn(i,n) for(int i=1;i<=n;i++)

int main(){
  int d,g,p[11],c[11];
  cin>>d>>g;
  for(int i=0;i<d;i++){
    cin>>p[i]>>c[i];
  }

  int ans=1e9;
  for(int mask=0;mask<(1<<d);mask++){
    int s=0,num=0,rest_max=-1;
    for(int i=0;i<d;i++){
      if(mask>>i&1){
        s+=100*(i+1)*p[i]+c[i];
        num+=p[i];
      }else{
        rest_max=i;
      }
    }
    if(s<g){
      int s1=100*(rest_max+1);
      int need=(g-s+s1-1)/s1;
      if(need>=p[rest_max]){
        continue;
      }
      num+=need;
    }
    ans=min(ans,num);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define len(x) (int) (x.size())
using namespace std;
typedef long long ll;

bool check_palindrome(string s) {
    for(int i = 0; i <= len(s)/2; i++) {
        if(s[i] != s[len(s)-i-1]) {
            return false;
        }
    }
    return true;
}

int main(){
    string s, ans;
    cin >> s;
    
    string a(s), b(s, 0, (len(s)-1)/2), c(s, (len(s)-1+3)/2);

    bool cka, ckb, ckc;
    cka = check_palindrome(a);
    ckb = check_palindrome(b);
    ckc = check_palindrome(c);

    if(cka && ckb && ckc) {
        cout << "Yes" << '\n';
    }
    else {
        cout << "No" << '\n';
    }

    return 0;
}

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

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

	int ans = 1;
	bool end = false;

	for (int i = 0; ; ) {
		if (i == n - 1) break;
		for (int j = 1; ; ) {

			if (i + j <= n - 1) {
				if (s.at(i) == s.at(i + j)) {
					j++;
					continue;
				}
				else { // (s.at(i) != s.at(i + j)) 
					ans++;
					i += j;
					break;
				}
			}
			else { // n - 1 < i + j
				end = true;
				break;
			}

		}
		if (end) break;
	}
	
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <cassert>
using namespace std;



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

	int N;
	cin >> N;
	vector<int> a(N);
	for(int i = 0; i < N; i++) {
		cin >> a[i];
		a[i]--;
	}
	int ans = 0;
	for(int i = 0; i < N; i++) {
		if(a[a[i]] == i) ans++;
	}

	cout << ans / 2 << endl;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
typedef long long LL;

int a[100005];

int main(){
	int n,sum = 0;
	cin >> n;
	for(int i = 1;i <= n;i++) cin >> a[i];
	a[n + 1] = n + 1;
	for(int i = 1;i <= n;i++){
		if(a[i] == i){
			sum ++;
			if(a[i + 1] == i + 1){
				i += 1;
			}
		}
	}
	printf("%d",sum);
}

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

int main() {
  int n;
  cin >> n;
  pair<pair<string, int>, int> V[n];
  rep(i,n){
    string s;
    int k;
    cin >> s >> k;
    V[i] = make_pair(make_pair(s, -k), i);
  }
  sort(V, V + n);
  rep(i,n){
    cout << V[i].second + 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
N = int(input())

def find_divisor_num(n):
    count = 0
    i = 1
    while i**2 < n:
        if n % i == 0:
            count += 2
        i += 1
    if n == i**2:
        count += 1
    return count

count = 0
for i in range(1, N+1, 2):
    divisor_num = find_divisor_num(i)
    if divisor_num == 8:
        count += 1

print(count)

Measured memory_bytes: 3060
#54
n=int(input())
*l,=list(map(int,input().split()))

for i in range(n):
    temp=l[i]
    j=i-1
    while j>=0 and l[j]>temp:
        l[j+1] = l[j]
        j-=1
    l[j+1] = temp
    print(*l)


Measured memory_bytes: 5984
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        for(int i=0; i<n; i++) {
            int a = sc.nextInt();
            if(a % 2 == 0) {
                if(a % 3 != 0 && a % 5 != 0) {
                    System.out.println("DENIED");
                    return;
                }
            }
        }
        System.out.println("APPROVED");
    }
}

Measured memory_bytes: 21844
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getInt()
	}
	return ret
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)
	a := getInt()

	out(a + a*a + a*a*a)
}


Measured memory_bytes: 1772
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner scanner=new Scanner(System.in);
    int number=scanner.nextInt();
    long answer=0;
    for(int i=1;i<=number;i++){
      if(!(i%3==0||i%5==0)){
        answer=answer+i;
      }else{
        continue;
      }
     }
     System.out.println(answer);
  }
}

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

int main(){
    int N, M;
    cin >> N >> M;

    vector<int> c(M, 0);
    int K;
    for(int i = 0; i < N; ++i){
        cin >> K;
        int a;
        for(int j = 0; j < K; ++j){
            cin >> a;
            ++c[a-1];
        }
    }

    cout << count(begin(c), end(c), N) << endl;
}

Measured memory_bytes: 256
z[4000],*a=z,*b=z+2000,m,i,j,k;main(n){for(;scanf("%d",&n)*n++;m=!printf("%d\n",m))for(i=n;i--;j=a,a=b,b=j)for(j=n;j--;k>m?m=k:0)k=b[j]=n+~i&&getchar()>45?1+fmin(fmin(b[j+1],a[j+1]),a[j]):0;}

Measured memory_bytes: 0
#include <stdio.h>
#include <string.h>
#include <vector>
#include <numeric>
#include <algorithm>
#include <set>
#include <functional>
#include <math.h>

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pii;

int main() {
  int n,k;
  scanf("%d %d", &n, &k);
  set<int> s;
  int d, x;
  while (k--) {
    scanf("%d", &d);
    while (d--) {
      scanf("%d", &x);
      s.insert(x);
    }
  }

  printf("%d", n - s.size());

  return 0;
}


Measured memory_bytes: 3276
N = int(input())
W = [input() for _ in range(N)]
V = set()
prev = -1
for S in W:
    if S in V:
        print('No')
        exit()
    V.add(S)
    if prev == -1 or S[0] == prev:
        prev = S[-1]
    else:
        print('No')
        exit()
print('Yes')

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

int main() {
    int n,rmin,drmax=-1000000000,i,r;
    cin>>n>>rmin;
    for(i=1;i<n;i++){
        cin>>r;
        if(drmax<r-rmin)drmax=r-rmin;
        if(r<rmin)rmin=r;
    }
    cout<<drmax<<endl;
    return 0;
}


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

using namespace std;

int a[3] = {-1, -1, -1}; // 目的の数
int c[5] = {0};
int s[5] = {0};
int main(){

    int n, m;
    cin >> n >> m;
    cin.ignore();
    int tmp_s, tmp_c;

    if(m == 0){
        if(n == 1){
            cout << 0 << endl;
            return 0;
        } else {
            cout << 1 << flush;
            for(int i = 0; i < n - 1; i++){
                cout << 0 << flush;
            }
            cout << endl;
            return 0;
        }
    }
    for(int i = 0; i < m; i++){
        cin >> tmp_s >> tmp_c;
        cin.ignore();
        --tmp_s;

        // 左から0桁目が0の場合 ただし1桁の場合は除く
        if((tmp_s == 0) && (tmp_c == 0) && (n > 1)){
            cout << -1 << endl;
            return 0;
        }
        // 既にあるものと食い違った
        if((a[tmp_s] != tmp_c) && (a[tmp_s] != -1)){
            cout << -1 << endl;
            return 0;
        }
        a[tmp_s] = tmp_c;
    }

    for(int i = 0; i < n; i++){
        if(a[i] == -1){
            if(i == 0) cout << 1 << flush;
            else cout << 0 << flush;
        } else {
            cout << a[i] << flush;
        }
    }
    cout << endl;
    return 0;
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define LOOP(i) while(i--)
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	int N=in(),M=in();
	vector<string> A(N),B(M);
	REP(i,N){
		A[i]=in<string>();
	}
	REP(i,M){
		B[i]=in<string>();
	}
	for(int i=0;i<N-M+1;i++){
		for(int j=0;j<N-M+1;j++){
			int num=0;
			for(int v=0;v<M;v++){
				for(int u=0;u<M;u++){
					if(A[i+v][j+u]==B[v][u]) num++;
				}
			}
			if(num==M*M){
				out("Yes");
				return 0;
			}
		}
	}
	out("No");
	return 0;
}


Measured memory_bytes: 256
def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a

tmp = input().split()
A = int(tmp[0])
B = int(tmp[1])

mo = 0
if A >= B:
    mo = gcd(A, B)
else:
    mo = gcd(B, A)
ans = (A * B) // mo

print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define first F
#define second S

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n,m;
  cin>>n>>m;
  vi cost(n);
  rep(i,n)
    cin>>cost[i];
  vector<vi> ans(n,vi(2,0));
  rep(i,n)
    ans[i][1]=i+1;
  rep(i,m){
    int a;
    cin>>a;
    rep(j,n)
      if(cost[j]<=a){
        ans[j][0]++;
        break;
      }
  }
  sort(all(ans));
  cout<<ans[n-1][1]<<endl;
}

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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;
const ll MAX = 26;

ll C[30];
ll S[400][30];
ll T[400];
set<ll> Last[30];

ll calc(ll t, ll d, ll score) {
    score += S[d][t];
    REP(i, MAX) {
        //cout << *Last[i].rbegin() << " ";
        if (t == i)
            continue;
        score -= C[i] * (d - *Last[i].rbegin());
    }
    //    cout << endl;
    return score;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll D;
    cin >> D;
    REP(i, MAX) {
        cin >> C[i];
    }
    REP(i, D) {
        REP(j, MAX) {
            cin >> S[i][j];
        }
    }
    REP(i, D) {
        cin >> T[i];
        T[i]--;
    }
    ll score = 0;
    REP(i, MAX) {
        Last[i].insert(-1);
    }
    REP(i, D) {
        score = calc(T[i], i, score);
        cout << score << endl;
        Last[T[i]].insert(i);
    }

    return 0;
}

Measured memory_bytes: 3752
package main

import (
	"bufio"
	"fmt"
	"math"
	"math/big"
	"os"
	"strconv"
)

func powmod(x int64, y int64, m int64) int64 {
	res := new(big.Int).Exp(big.NewInt(x), big.NewInt(y), big.NewInt(m))
	return res.Int64()
}

var (
	scanner = bufio.NewScanner(os.Stdin)
)

func readInt() (read int) {
	scanner.Scan()
	read, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	return
}

const (
	initialBufSize = 2e8
	maxBufSize     = 2e8
)

func main() {

	buf := make([]byte, initialBufSize)
	scanner.Buffer(buf, maxBufSize)
	scanner.Split(bufio.ScanWords)

	n := int64(readInt())

	m := int64(math.Pow10(9)) + 7

	ans := powmod(10, n, m)
	ans -= powmod(9, n, m) * 2
	ans += powmod(8, n, m)
	ans %= m

	if ans < 0 {
		ans += m
	}

	fmt.Println(ans)
}

Measured memory_bytes: 8328
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  vector<bool> a(100000);
  int n;
  cin >> n;
  rep(i,n){
    int l,r;
    cin >> l >> r;
    l--; r--;
    for(int i = l; i<=r; i++){
      a.at(i)=true;
    }
  }
  int ans = 0;
  rep(i,100000){
    if(a.at(i)){
      ans++;
    }
  }
  cout << ans << endl;
}


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

ll dp[1000010], mod=1000000007;

int main(void){
    int N, H, D;
    cin >> N >> H >> D;
    ll mult=0;
    dp[0]=1;
    for(int i=1; i<=N; ++i){
        (dp[0] *= i) %= mod;
        (mult += dp[0]) %= mod;
    }
    ll sum=dp[0];
    for(int i=1; i<H; ++i){
        dp[i]=(sum*mult)%mod;
        if(i>=D) (sum += mod-dp[i-D]) %= mod;
        (sum += dp[i]) %= mod;
    }
    cout << sum << endl;
}


Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(), (a).end()
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define rep(i, n) FOR(i, 0, n)
#define repi(i, n) FOR(i, 1, n + 1)
#define pp(v) cout << #v "=" << (v) << endl;
#define ppa(v) cout << "----\n"; rep(i,v.size()) cout << #v << "[" << i << "] = " << v[i] << endl;
#define div_ceil(a,b) ((a) + ((b) - 1)) / (b)

int main() {
  int n;cin>>n;
  rep(i,1000) {
    if (n<=i && (i%111)==0) {
      cout << i << endl;
      exit(0);
    }
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#include<functional>
#include<stack>
#include<list>
#include<set>
#include<deque>
#include<climits>
using namespace std;

int main(){
	double X,H;
	while(cin>>X>>H,X||H){
		printf("%lf\n",X*X+X*sqrt(X*X/4+H*H)*2);
	}
	return 0;
}

Measured memory_bytes: 1232
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int MAXN=105;
int n;
int map[MAXN][MAXN];
int main()
{
	scanf("%d",&n);
	int z=n*(n-1)/2;
	z-=n/2;
	if(n&1)
	{
		for(int i=1;i<=n;i++)
			map[i][n-i]=1;
	}
	else
	{
		for(int i=1;i<=n;i++)
			map[i][n+1-i]=1;
	}
	printf("%d\n",z);
	for(int i=1;i<=n;i++)
	{
		for(int j=i+1;j<=n;j++)
			if(map[i][j]==0)
				printf("%d %d\n",i,j);
	}
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>

int main (int argc, char const *argv[])
{
    char b[2];

    gets(b);

    switch (b[0])
    {
        case 'A':
            puts("T");
            break;
        case 'C':
            puts("G");
            break;
        case 'G':
            puts("C");
            break;
        case 'T':
            puts("A");
            break;
        default:
            break;
    }

    return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<algorithm>
const int M=207,mod=998244353;
int read(){
	int ans=0,f=1,c=getchar();
	while(c<'0'||c>'9'){if(c=='-') f=-1; c=getchar();}
	while(c>='0'&&c<='9'){ans=ans*10+(c-'0'); c=getchar();}
	return ans*f; 
}
int n,f[M],sz[M];
int find(int x){while(f[x]!=x) x=f[x]=f[f[x]]; return x;}
int gcd(int x,int y){return y?gcd(y,x%y):x;} 
struct pos{int x,y;}q[M];
int cnt;
struct node{
	int u,v,w;
	bool operator <(const node &x)const{return w<x.w;}
	void calc(){
		int p=find(u),q=find(v);
		if(p!=q) f[q]=p,sz[p]+=sz[q];
	}
}e[M*M];
int pw[M],ans;
void prepare(){
	pw[0]=1; 
	for(int i=1;i<=n;i++) pw[i]=(pw[i-1]<<1)%mod;
}
int main(){
	n=read(); 
	prepare(); ans=(pw[n]-n-1)%mod;
	for(int i=1;i<=n;i++) q[i].x=read(),q[i].y=read();
	for(int i=1;i<=n;i++)
		for(int j=1;j<i;j++){
			int x=q[i].x-q[j].x,y=q[i].y-q[j].y,g=gcd(x,y);
			x/=g; y/=g;
			if(!x) y=1;
			if(!y) x=1;
			if(x<0) x=-x,y=-y;
			e[++cnt]=(node){i,j,x*30000+y};
		}
	std::sort(e+1,e+1+cnt);
	for(int i=1,j=1;i<=cnt;i=j){
		for(int k=1;k<=n;k++) sz[f[k]=k]=1;
		while(j<=cnt&&e[j].w==e[i].w) e[j++].calc();
		for(int k=1;k<=n;k++) if(f[k]==k&&sz[k]>=2) ans=(ans-pw[sz[k]]+sz[k]+1)%mod;
	}printf("%d\n",(ans+mod)%mod);
	return 0;
}

Measured memory_bytes: 384