akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef set<int> :: iterator setit;

int f(int a,char ch,int b){
  if(ch=='+')return a+b;
  else if(ch=='-')return a-b;
  else if(ch=='*')return a*b;
  else return a/b;
}

bool visited[20][20];
set<int> dp[20][20];
set<int> rec( int l,int r,  vector< set<int> > &t,  vector< char > &u ){
  if(visited[l][r])return dp[l][r];
  visited[l][r]=true;
  set<int> res;
  for(int i=l;i+1<=r;i++){
    set<int> A,B;
    A=rec(l,i,t,u);
    B=rec(i+1,r,t,u);
    for(setit j=A.begin();j!=A.end();j++){
      for(setit k=B.begin();k!=B.end();k++){
        int J=*j,K=*k;
        if(u[i]=='/'&&K==0)continue;
        res.insert( f(J,u[i],K) );
      }
    }
  }
  return dp[l][r]=res;
}

set<int> solve(   vector< set<int> > &t,  vector< char > &u ){
  for(int i=0;i<20;i++)
    for(int j=0;j<20;j++)
      dp[i][j].clear(),visited[i][j]=false;
  for(int i=0;i<(int)t.size();i++){
    dp[i][i]=t[i];
    visited[i][i]=true;
  }
  return rec(0,t.size()-1,t,u);
}



string s;
int p;

set<int> calc();

set<int> getNum(){
  if(s[p]=='('){
    p++;
    return calc();
  }
  int a=0;
  while('0'<=s[p]&&s[p]<='9'){
    a=a*10+s[p]-'0';
    p++;
  }
  set<int> res;
  res.insert(a);
  return res;
}

set<int> calc(){
  vector< set<int> > t;
  vector< char > u;
  t.push_back(getNum());
  while(1){
    if(s[p]=='='||s[p]==')'){
      p++;
      break;
    }
    u.push_back(s[p]);
    p++;
    t.push_back(getNum());
  }
  if(u.size()==0)return t[0];
  else return solve(t,u);
}

int main(){
  while(1){
    cin>>s;
    if(s=="#")break;
    s.push_back('=');
    p=0;
    set<int> ans=calc();
    cout<<ans.size()<<endl;
  }
  return 0;
}

Measured memory_bytes: 1396
import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy, functools, random
import sys
from collections import deque, defaultdict, Counter; from heapq import heappush, heappop
from itertools import permutations, combinations, product, accumulate, groupby
from bisect import bisect_left, bisect_right, insort_left, insort_right
from operator import itemgetter as ig
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20; INF = float("INF"); ans = 0; tmp = 0; ansli = []; tmpli = []; candili = []
eps = 1.0 / 10 ** 10; mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]; ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]; ddn9 = ddn + [(0, 0)]
"""for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:"""
def wi(): return list(map(int, sys.stdin.readline().split()))
def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]#WideIntPoint
def ws(): return sys.stdin.readline().split()
def i(): return int(sys.stdin.readline())
def s(): return input()
def hi(n): return [i() for _ in range(n)]
def hs(n): return [s() for _ in range(n)]#HeightString
def mi(n): return [wi() for _ in range(n)]#MatrixInt
def mip(n): return [wip() for _ in range(n)]
def ms(n): return [ws() for _ in range(n)]

a, b = wi()
if a <= 5:
    print(0)
elif 6 <= a <= 12:
    print(b // 2)
if a >= 13:
    print(b)

Measured memory_bytes: 7872
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define FIT(it,v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << endl
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(ALL(c), (e)) != (c).end())



void init() {

}

void input() {

}

void solve() {
  int n, a, b;
  cin >> n >> a >> b;
  cout << min(a,b) << " ";
  cout << max(0, a+b-n) << endl;

}

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


Measured memory_bytes: 256
import queue

_in = input()
Nlen = len(_in)
N = int(_in)
glen = 1
ans = 0

findq = queue.Queue()
checkq = queue.Queue()

findq.put('3')
findq.put('5')
findq.put('7')

while glen <= Nlen and not findq.empty():
  head = findq.get()
  checkq.put(head)
  if len(head)+1 <= Nlen:
    glen = min(glen, len(head))
    findq.put(head+'3')
    findq.put(head+'5')
    findq.put(head+'7')

while not checkq.empty():
  head = checkq.get()
  if int(head) > N:
    continue
  if ''.join(sorted(set(head))) == '357':
    ans += 1

print(ans)


Measured memory_bytes: 6000
#include <stdio.h>
#include <string.h>
int main()
{   char s[200001];
    scanf("%s",s);
    int l=strlen(s);
    int arr[200001]={0},k=0;
    for(int i=0;i<l-1;i++){
        if(s[i]=='B'&&s[i+1]=='C'){
            arr[k]=4;
            i++;
        }else if(s[i]=='A'){
            arr[k]=1;
        }
        k++;
    }
 /*for(int i=0;i<k;i++){
   printf("arr[%d]=%d\n",i,arr[i]);
 }*/
    long sub=0,ans=0;
    for(int i=0;i<k;i++){
        if(arr[i]==1){
            sub++;
        }
        if(arr[i]==4){
            ans+=sub;
        }
        if(arr[i]==0){
            sub=0;
        }
    }
    printf("%ld",ans);

    return 0;
}


Measured memory_bytes: 1152
<?php
	list( $n, $m, $l ) = explode( ' ', trim( fgets( STDIN ) ) );
	$A = array();
	$B = array();
	$C = array_fill( 0, $n, array_fill( 0, $l, 0 ) );
	for( $i=0; $i<$n; $i++ ) {
		array_push( $A, explode( ' ', trim( fgets( STDIN ) ) ) );
	}
	for( $i=0; $i<$m; $i++ ) {
		array_push( $B, explode( ' ', trim( fgets( STDIN ) ) ) );
	}
	for( $i=0; $i<$n; $i++ ) {
		for( $j=0; $j<$l; $j++ ) {
			$res = 0;
			for( $k=0; $k<$m; $k++ ) {
				$res += $A[$i][$k]*$B[$k][$j];
			}
			$C[$i][$j] = $res;
		}
	}
	for( $i=0; $i<$n; $i++ ) {
		print implode( " ", $C[$i] ).PHP_EOL;
	}
	return;
?>

Measured memory_bytes: 11616
base = gets.split(' ').map {|i| i.to_i}
l = base[0]
r = base[1]

min = nil

def over?(current_r, r)
  current_r > r
end

current_l = l
current_r = current_l + 1

if over?(current_r, r)
  puts min
  exit
end

while true do
  #puts "#{current_l}, #{current_r}"
  _m = current_l * current_r
  if _m < 2019
    m = _m
  else
    m = _m % 2019
  end

  if m == 0
    puts 0
    exit
  end
  if min == nil
    min = m
  elsif m < min
    min = m
  end

  current_r = current_r + 1

  if over?(current_r, r)
    if current_l == r - 1
      puts min
      exit
    end
    current_l += 1
    current_r = current_l + 1
  end
end


Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <algorithm>
#include <ctime>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <bitset>
#include <list>
#include <cstdio>
#include <stdio.h>
#include <complex>
#include <math.h>

typedef long long ll;

using namespace std;

double pi=2*acos(0);
const int INF = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};


int main()
{
    double n;
    cin >> n;
    double sum =0;
    for(int i=0; i<n; i++)
    {
        double a;
        cin >> a;
        sum += 1/a;
    }
    cout << 1/sum;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;
#define inf 1000000007

int main(void){
    int k, x;
    cin >> k >> x;
    int a = x-k+1;
    int b = x+k-1;
    for(int i = a; i <= b ; i++)
        cout << i << ' ';
    cout << endl;
    
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	static int gcd(int x, int y) {
		if(x < y) {
			int tmp = x;
			x = y;
			y = tmp;
		}
		while(y > 0) {
			int r = x % y;
			x = y;
			y = r;
		}
		return x;
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		System.out.println(gcd(a, b));
	}
}



Measured memory_bytes: 26244
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
vector<int> v[200010];
vector<int> ans(200010);

void solve(int x,int p){
    for(auto u : v[x]){
        if(u==p) continue;
        ans[u]+=ans[x];
        solve(u,x);
    }
}

int main(){
    int n,q;
    cin>>n>>q;
    rep(i,n-1){
        int x,y;
        cin>>x>>y;
        x--;y--;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    rep(i,q){
        int p,x;
        cin>>p>>x;
        p--;
        ans[p]+=x;
    }
    solve(0,-1);
    rep(i,n) cout<<ans[i]<<endl;
    return 0;
}

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

int main() {
    int W,H,x,y,r;
    cin >> W >> H >> x >> y >> r;
    if(x-r >= 0 && x+r <= W && y-r >= 0 && y+r <= H) {
    	cout << "Yes" << endl;
    }
    else {
    	cout << "No" << endl;  
    }  
    return 0;
}


Measured memory_bytes: 3116
#include "bits/stdc++.h"
using namespace std;
#pragma region define/typedef
//auto
#define var auto
//a..b-1
#define FOR(i, a, b) for(var (i) = (a); (i) < (b); (i)++)
//b..a
#define FORR(i, a, b) for(var (i) = (b); (i) >= (a); (i)--)
//0..n-1
#define rep(i, n) for(var (i) = 0; (i) < (n); (i)++) 
//1..n
#define rep1(i, n) for(var (i) = 1; (i) <= (n); (i)++)
//n-1..0
#define repr(i, n) for(var (i) = (n) - 1; (i) >= 0; (i)--)
//n-1..1
#define repr1(i, n) for(var (i) = (n); (i) > 0; (i)--)
#define out(a) cout<<(a)<<endl;
#define pb(a) push_back((a))
#define mp make_pair
#define mt make_tuple
#define endl "\n";
#define outif(b, t, f) cout << ((b) ? (t) : (f)) << endl;
#define sort(vec) sort((vec).begin(), (vec).end())
typedef long long ll;
typedef unsigned int uint;
typedef vector<int> vint;
typedef vector<ll> vlong;
typedef vector<pair<int, int>> vpair;
const int MAX = 2147483647;
const int MIN = 0 - 2147483648;
const ll MAXL = 922337203685775807;
const ll MINL = 0 - 922337203685775808;
#pragma endregion
#pragma region methods/operators
ll parse(const string num) { stringstream ss; ss << num << flush; ll n; ss >> n; return n; }
string tostring(const ll n) { stringstream ss; ss << n << flush; return ss.str(); }

vector<string> split(string s, string delim) {
	vector<string> res;
	auto pos = 0;
	while (true) {
		const int found = s.find(delim, pos);
		if (found >= 0) {
			res.push_back(s.substr(pos, found - pos));
		}
		else {
			res.push_back(s.substr(pos));
			break;
		}
		pos = found + delim.size();
	}
	return res;
}

template<typename T>
string join(vector<T>& vec, string sep = " ")
{
	var size = vec.size();
	if (size == 0) return "";
	stringstream ss;
	for (int i = 0; i < size - 1; i++) {
		ss << vec[i] << sep;
	}
	ss << vec[size - 1];
	return ss.str();
}

template<typename T>
istream& operator >> (istream& is, vector<T>& vec)
{
	for (T& x : vec) is >> x;
	return is;
}

template<typename T>
void print(T t) {
	cout << t << endl;
}

ll gcd(ll a, ll b)
{
	if (a < b) gcd(b, a);
  ll r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
#pragma endregion

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

  int N;
  while (cin >> N) {
    vint a(N);
    cin >> a;

    int cnt4 = 0, cntEven = 0, cntOdd = 0;

    rep(i, N)
    {
      if (a[i] % 4 == 0) cnt4++;
      else if (a[i] % 2 == 0)cntEven++;
      else cntOdd++;
    }

    var ans = false;
    if (cntEven == 0) ans =cntOdd -cnt4 <= 1;
    else ans = cnt4 >= cntOdd;
    
    print(ans ? "Yes" : "No");
  }
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printa(x, n) for(ll i = 0; i < n; i++) {cout << (x[i]) << " ";} cout << endl;
#define printd(x) printf("%.12f\n", ans);
#define print(x) cout << (x) << endl;
#define Yes() cout << "Yes" << endl;
#define No() cout << "No" << endl;
#define YES() cout << "YES" << endl;
#define NO() cout << "NO" << endl;
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;

int f(int n) {
    int ans = 1;
    rrep(i, n) ans *= i;
    return ans;
}

int main(void) {
    int n;
    cin >> n;
    int x[n], y[n];
    rep(i, n) cin >> x[i] >> y[i];

    vi num(n);
    rep (i, n) num[i] = i;

    double ans = 0;

    do {
        double sum = 0;
        rep (i, n - 1) {
            sum += pow((pow((x[num[i]] - x[num[i + 1]]), 2) + pow((y[num[i]] - y[num[i + 1]]), 2)), 0.5);
        }
        ans += sum;
    } while(next_permutation(rng(num)));

  
    ans /= f(n);
    
    printd(ans)
    return 0;
}

Measured memory_bytes: 384
while(1):
    try:
        [v,d]=map(int,raw_input().split())
    except:
        break
    fib=[1 for x in range(v+2)]
    for i in range (2,v+2):
        fib[i]=fib[i-1]+fib[i-2]
    fib.pop(0)
    fib.pop(0)
    fibm=sorted([x%1001 for x in fib])
    ans=1
    for i in range(v-1):
        if fibm[i+1]-fibm[i]>=d:    ans+=1
    print ans
        

Measured memory_bytes: 6336
from collections import defaultdict
import math


def f(n, k):
    base = 2 ** k
    syou = n // base
    amari = n % base
    q = max(0, amari - (base // 2) + 1)
    res1 = syou * (base // 2) + q
    return res1 % 2


def g(n):  # nを累計xorで表現
    if n <= 0:
        return "0"
    keta = int(math.log2(n) + 1)
    s = ""
    for i in range(keta):
        s = str(f(n, i + 1)) + s
    return s


def xor(a, b):
    max_len = max(len(a), len(b))
    a = (("0" * max_len) + a)[-max_len:]
    b = (("0" * max_len) + b)[-max_len:]

    s = ""
    for i in range(max_len):
        if a[i] != b[i]:
            s += "1"
        else:
            s += "0"
    return s


def to10(s):
    res = 0
    for c in s:
        res *= 2
        if c == "1":
            res += 1
    return res


def main():
    n, m = [int(q) for q in input().split()]
    A = g(n - 1)
    B = g(m)
    res = xor(A, B)
    print(to10(res))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3572
#[macro_use]
mod utils {
    macro_rules! input {
        ($($r:tt)*) => {
            let stdin = std::io::stdin();
            let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
            let mut next = move || -> String{
                bytes
                    .by_ref()
                    .map(|r|r.unwrap() as char)
                    .skip_while(|c|c.is_whitespace())
                    .take_while(|c|!c.is_whitespace())
                    .collect()
            };
            input_inner!{next, $($r)*}
        };
    }
    macro_rules! input_inner {
        ($next:expr) => {};
        ($iter:expr, ) => {};

        ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
            let $var = read_value!($next, $t);
            input_inner!{$next $($r)*}
        };
        ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
            let mut $var = read_value!($next, $t);
            input_inner!{$next $($r)*}
        };
    }
    macro_rules! read_value {
        ($next:expr, ( $($t:tt),* )) => {
            ( $(read_value!($next, $t)),* )
        };
        ($next:expr, [ $t:tt ; $len:expr ]) => {
            (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        };
        ($next:expr, chars) => {
            read_value!($next, String).chars().collect::<Vec<char>>()
        };
        ($next:expr, usize1) => {
            read_value!($next, usize) - 1
        };
        ($next:expr, $t:ty) => {
            $next().parse::<$t>().expect("Parse error")
        };
    }
}

fn main() {
    input! {
        n: usize,
        a: [usize1; n],
    }
    let mut m = vec![0i64; n];
    for i in 0..n {
        m[a[i]] += 1;
    }
    let mut s = 0;
    for i in 0..n {
        s += m[i] * (m[i] - 1) / 2;
    }

    for i in 0..n {
        println!("{}", s - (m[a[i]] - 1));
    }
}


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

vector<int>v[2000];
int main(){
	int w,h;cin>>w>>h;
	rep(i,h)rep(j,w){
		int c;scanf("%d",&c);
		v[j].push_back(c);
	}
	map<vector<int>,int>mp;
	rep(i,w){
		mp[v[i]]++;
	}
	if(mp.size()!=2){
		puts("no");return 0;
	}
	if(abs(mp.begin()->second-mp.rbegin()->second)>1){
		puts("no");return 0;
	}
	vector<int>a=mp.begin()->first,b=mp.rbegin()->first;
	int c1=0,c2=0;
	rep(i,h){
		if(a[i]==b[i]){
			puts("no");return 0;
		}
		if(a[i]==0)c1++;
		else c2++;
	}
	if(abs(c1-c2)>1){
		puts("no");return 0;
	}
	puts("yes");
}



Measured memory_bytes: 10996
# -*- coding: utf-8 -*-
 
import math
import itertools
import re
 
# 入力
N = int(input())
S = str(input())
#M1, D1 = map(int, input().split())
 
si = ""
cnt = 0
for i in range(1000) :
  
  si = str(i).zfill(3)
  
  c = 0
  for x in range(N) :
    if S[x] == si[c] :
      c += 1
      if c == 3 :
        cnt += 1
        break    

print (cnt)


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

int main() {
  int K;
  cin >> K;
  
  int ans = -1;
  int p=0;
  int q=0;
  //qは足す数
  
  for(int i=0;i<K;i++){
    q = q*10 + 7;
    q = q % K;
    if (q % K == 0){
      ans = i+1;
      break;
    }
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 3628
import math
import sys

def is_prime(n):
  if n==1:
    return False
  for i in range(2,int(math.sqrt(n)+1)):
    if n%i==0:
      return False
  return True

x=int(input())

while(1):
  if is_prime(x):
    print(x)
    sys.exit()
  x=x+1


Measured memory_bytes: 2940
N = gets.to_i
$v_list = gets.split.map(&:to_i)
$c_list = gets.split.map(&:to_i)

def dfs(i, x, y)
  if i == N
    return x - y
  end
  v = $v_list[i]
  c = $c_list[i]
  [
    dfs(i + 1, x + v, y + c),
    dfs(i + 1, x, y)
  ].max
end
ans = dfs(0, 0, 0)
puts ans


Measured memory_bytes: 1788
/*ANKON GHOSH
  KUET,ECE 2K16*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define MAX 3100
#define mod 1000000007
#define Case(i) cout<<"Case "<<i<<": "
#define sf(a) scanf("%lld",&a)
#define sff(a,b) scanf("%lld %lld",&a,&b)
#define sfff(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define sffff(a,b,c,d) scanf("%lld %lld %lld %lld",&a,&b,&c,&d)
#define pfn printf("NO\n")
#define pfs  printf("YES\n")
#define pf(a) printf("%lld\n",a)
#define pff(a,b) printf("%lld %lld\n",a,b)
#define pfff(a,b,c) printf("%lld %lld %lld\n",a,b,c)
#define pffff(a,b,c,d) printf("%lld %lld %lld %lld\n",a,b,c,d)
#define FOR(i,n) for(ll i=0;i<n;i++)
#define FOR1(i,n) for(ll i=1;i<=n;i++)
#define RFOR(i,n) for(ll i=n-1;i>=0;i--)
#define RFOR1(i,n) for(ll i=n;i>0;i--)
#define m_p(a,b) make_pair(a,b)
#define p_b(a) push_back(a)
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
map<ll,ll>mp1,mp;
vector<pair<ll,pair<ll,ll> > >vpp,vpp1;
vector<pair<ll,ll> >vp,vp1;
vector<ll>v,v1,v2,fin;
map<pair<ll,ll>,bool>mbb;
map<ll,bool>mb;
ll n,k,a,b,c,d,ta,sum=0,cnt=0,m,l,req,sz,maxi;
bool sortbysec(const pair<pair<ll,ll>,ll> &a,const pair<pair<ll,ll>,ll> &b)
{
    return (a.second < b.second);
}
///vector<pair<ll,ll> >adj[MAX+10];
int main()
{
    cin>>n;
    map<string,bool>ms;
    ms.clear();
    ll cnt=0;
    FOR(i,n)
    {
        string s;
        cin>>s;
        if(ms[s]==false)
        {
            ms[s]=true;
            cnt++;
        }
        ///st.insert(s);
    }
    cout<<cnt<<endl;
    return 0;
}


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

int main(){
	int a, b;
	cin >> a >> b;

	if (a < b){
		printf("a < b\n");
	}
	else if (a > b)
	{
		printf("a > b\n");
	}
	else
	{
		printf("a == b\n");
	}
	
}


Measured memory_bytes: 3084
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

C = [0] * (N + 1)

B.append(0)
kill = 0

for i in range(0, N):
    kill += min(A[i], B[i]) + min(A[i + 1], B[i] - min(A[i], B[i]))
    A[i + 1] -= min(A[i + 1], B[i] - min(A[i], B[i]))

print(kill)

Measured memory_bytes: 19156
while 1:
  t,d,l=map(int,input().split())
  if t==d==l==0:break
  x=[0]*(t+1)
  for i in range(t):
    s=int(input())
    if s<l:continue
    x[i]+=1
    x[min(i+d,t)]-=1
  y=[0]*t
  y[0]=x[0]
  for i in range(t-1):y[i+1]=y[i]+x[i+1]
  s=0
  for i in y[:-1]:
    if i>0:s+=1
  print(s)


Measured memory_bytes: 11668
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int x;
  cin>>x;
  int p=0,q=0,h;
  p=x/500;
  x=x%500;
  q=x/5;
  h=p*1000 + q*5;
  cout<<h;
  
}

Measured memory_bytes: 256
def solve(string):
    x, k, d = map(int, string.split())
    if k % 2:
        x = min(x - d, x + d, key=abs)
        k -= 1
    x, k, d = abs(x), k // 2, d * 2
    return str(min(x % d, abs((x % d) - d))) if x < k * d else str(x - k * d)


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


Measured memory_bytes: 9196
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#define ll long long
using namespace std;
const int N=305,P=998244353;
int n,a[N],f[N][N*N],sum[N],g[N][N*N];

inline void read(int &i){
	i=0;char c=getchar();bool j=0;
	for(;!isdigit(c);c=getchar())if(c=='-')j=1;
	for(;isdigit(c);c=getchar())i=(i<<1)+(i<<3)+c-'0';i=j?-i:i;
}
inline void add(int &x,int y){(x+=y)>=P?x-=P:0;x<0?x+=P:0;}
inline ll Pow(ll a,int b){ll c=1;for(;b;a=a*a%P,b>>=1)if(b&1)c=c*a%P;return c;}

int main(){
	read(n);
	for(int i=1;i<=n;++i)read(a[i]),sum[i]=sum[i-1]+a[i];
	f[0][0]=1;
	for(int i=0;i<n;++i)
		for(int j=0;j<=sum[n];++j)if(f[i][j]){
			add(f[i+1][j],f[i][j]);
			add(f[i+1][j+a[i+1]],2*f[i][j]%P);
		}
	g[0][0]=1;
	for(int i=0;i<n;++i)
		for(int j=0;j<=sum[n];++j)if(g[i][j])
			add(g[i+1][j+a[i+1]],g[i][j]),
			add(g[i+1][j],g[i][j]);
	int ans=Pow(3,n);
	add(ans,-3ll*f[n][0]%P);
	for(int i=1;i<=sum[n];++i)if(i<=sum[n]-i)add(ans,-3ll*f[n][i]%P);
	if(sum[n]%2==0)add(ans,3ll*g[n][sum[n]/2]%P);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 219392
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1e9 + 7;
#define pival 3.14159265358979323846264338327950L
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pqq priority_queue
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl '\n'
#define DEBUG
#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1)
    {
        cerr << name << " = " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args)
    {
        const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " = " << arg1 << " || ";
        __f(comma+1, args...);
    }
#else
#define debug(...)
#endif
template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ; ";
    return os << "}";
}
template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
    return os << "[ " << p.first << ", " << p.second << "]" ;
}
ll power(ll x, ll y, ll p)
{ 
    ll res = 1;  
    x = x % p;
    while (y > 0) { 
        if (y & 1) res = (res * x) % p; 
        y = y >> 1;
        x = (x * x) % p;   
    } 
    return res; 
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
 	ll n, k, s;
    cin >> n >> k >> s;
    ll a = n - k;
    ll b = k;
    ll n1 = s - 1;
    if (n1 == 0) n1 = 1e9;
    for (ll i = 0; i < a; i++) {
        cout << n1 << ' ';
    }  
    for (ll i = 0; i < b; i++) {
        cout << s << ' ';
    }
    cout << endl;
	return 0;
}

Measured memory_bytes: 3624
t = input()

before_and_max = [[0, 0, 0] for i in range(len(t))]

for i in range(len(t)):
    if i == 0:
        if t[0] == "0":
            before_and_max[0][0] = 0
            before_and_max[0][1] = 0
            before_and_max[0][2] = 0
        else:
            before_and_max[0][0] = 1
            before_and_max[0][1] = 1
            before_and_max[0][2] = 0
    else:
        if t[i] == "0":
            before_and_max[i][0] = before_and_max[i - 1][0] + max(before_and_max[i-1][1], before_and_max[i-1][2])
            before_and_max[i][1] = max(before_and_max[i-1][1], before_and_max[i-1][2])
            before_and_max[i][2] = max(before_and_max[i-1][1], before_and_max[i-1][2])
        else:
            before_and_max[i][0] = before_and_max[i - 1][0] + ((i + 1) // 2 + (i + 1) % 2)
            before_and_max[i][1] = before_and_max[i - 1][2] + 1
            before_and_max[i][2] = before_and_max[i - 1][1]

print(before_and_max[len(t) - 1][0])


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

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

int n,m;
bool flag[5005][5005];
vector<int> G[5005];
vector<int> G_rev[5005];

vector<int> L;
queue<int> S;
int cnt[5005];

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

    cin >> n >> m;

    for (int i = 0;i < m;i++){
        int a,b; cin >> a >> b;
        flag[a][b] = true;
        G[a].push_back(b);
        cnt[b]++;
    }

    for (int i = 1;i <= n;i++){
        if(cnt[i] == 0) S.push(i);
    }

    while(S.size()){
        int now = S.front(); S.pop();
        L.push_back(now);
        for (int i = 0;i < G[now].size();i++){
            int to = G[now][i];
            cnt[to]--;
            if(cnt[to] == 0){
                S.push(to);
            }
        }
    }

    for (int i = 0;i < n;i++){
        cout << L[i] << endl;
    }

    for (int i = 0;i < n-1;i++){
        if(flag[L[i]][L[i+1]] || flag[L[i+1]][L[i]]) continue;
        cout << "1" << endl;
        return 0;
    }

    cout << "0" << endl;

    return 0;

}



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

const long double PI = acos(-1);
 
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

 bool IsPrime(ll num){
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2){
        if (num % i == 0){
            return false;
        }
    }
    return true;
}

int main(){
    ll n;
    cin >> n;
    ll x[n], y[n];
    for(int i = 0; i < n; i++){
        cin >> x[i];
        y[i] = x[i];
    }

    sort(y, y+n);
    
    ll keyu = y[n/2];
    ll keyd = y[n/2-1];
    for(int i = 0; i < n; i++){
        if(x[i] < keyu) cout << keyu << endl;
        else cout << keyd << endl;
    }
    return 0;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005
const ll MOD = 1000000007;

/*
    Number of Amidakuji
*/

int fib(int x){
    if(x<=0)return 1;
    if(x==1)return 2;
    if(x==2)return 3;
    if(x==3)return 5;
    if(x==4)return 8;
    if(x==5)return 13;
    if(x==6)return 21;
}

int main() {
    ll h,w,k;
    cin >> h >> w >> k;
    k--;

    ll dp[h+1][w];
    rep(i,h+1){
        rep(j,w){
            dp[i][j] = 0;
        }
    }
    dp[0][0] = 1;
    srep(i,1,h+1){
        rep(j,w){
            dp[i][j] = dp[i-1][j  ] * fib(j-1) * fib(w-1-(j+1)); 
            if(1<=j)dp[i][j] += dp[i-1][j-1] * fib(j-2) * fib(w-1-(j+1));
            if(j<=w-2)dp[i][j] += dp[i-1][j+1] * fib(j-1) * fib(w-1-(j+2));
            dp[i][j] %= MOD;
        }
    }

    cout << dp[h][k] << endl;

    return 0;
}
 
 


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

int main(){
                                                                     

    int n, i, j, t;

    string a = "abcdefghijklmnopqrstuvwxyz";

    vector<int> an(26);

    string k;


    cin >> n;

    vector<string> s(n);

    for( i = 0 ; i < n ; i = i + 1 ){

         cin >> s.at(i);

         }


    for( i = 0 ; i < n ; i = i + 1 ){

         for( j = 0 ; j < 26 ; j = j + 1 ){

              if( i == 0 ) an.at(j) = count(s[i].begin(), s[i].end(), a.at(j) );

              else{ 

                     t = count(s[i].begin(), s[i].end(), a.at(j) );

                     if( t < an.at(j) ) an.at(j) = t;

                     }

              }

         }

    
    for( i = 0 ; i < 26 ; i = i + 1 ){

         for( j = 0 ; j < an.at(i) ; j = j + 1 ){

              k.push_back( a.at(i) );

              }

         }


    cout << k << endl;

    return 0;

    }

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

typedef long long ll;

int main()
{
    ll i,j;
    ll h;
    cin >> h;
    ll ans = 0;
    ll tmp = 1;
    while(h){
        ans += tmp;
        tmp *= 2LL;
        h /= 2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ll long long
#define li long
#define pb push_back
#define mem(arr,x) memset(arr,x,sizeof(arr))
ll n,W;
ll w[101],v[101];
ll dp[101][100010];

// ll maxValue(ll end, ll totalW)
// {
//   if(end==0||W==0)
//   return 0;
//   if(dp[end][totalW]!=-1)
//   return dp[end][totalW];
//   if(w[end-1]>totalW)
//   return dp[end][totalW]=maxValue(end-1,totalW);
//   return dp[end][totalW]=max(v[end-1]+maxValue(end-1,totalW-w[end-1]), maxValue(end-1,totalW));
// }

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll i,j;
    cin>>n>>W;
    for(i=0;i<n;i++)
    cin>>w[i]>>v[i];
    for(i=0;i<=n;i++)
    {
      for(j=0;j<=W;j++)
      {
        if(i==0||j==0)
        dp[i][j]=0;
        else if(j>=w[i-1])
        dp[i][j]=max(v[i-1]+dp[i-1][j-w[i-1]], dp[i-1][j]);
        else 
        dp[i][j]=dp[i-1][j];
      }
    }
    // cout<<maxValue(n,W);
    cout<<dp[n][W];
    return 0;
}

Measured memory_bytes: 82552
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;


int cost[305][305];
int nxt[305][305];
int path[305][305];

int n, m;
void warshall_floyd(){
    rep(k, n){
        rep(i, n){
            rep(j, n) {
                if (cost[i][j] > cost[i][k] + cost[k][j]){
                    cost[i][j] = cost[i][k] + cost[k][j];
                    nxt[i][j] = nxt[i][k];
                }
            }
        }
    }
}

int sta[305], sp;


void checkShortestPath(int start, int goal) {
    vector<int> v;
    for (int cur = start; cur != goal; cur = nxt[cur][goal])
        v.push_back(cur);
    v.push_back(goal);
    rep(i, v.size()-1) path[v[i]][v[i+1]] = 0, path[v[i+1]][v[i]] = 0;
}

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

    rep(i, 305) rep(j, 305) if (i != j) cost[i][j] = INF;
    rep(i, 305) rep(j, 305) nxt[i][j] = j;

    rep(i, m){
        int a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        cost[a][b] = c;
        cost[b][a] = c;
        path[a][b] = 1;
        path[b][a] = 1;
    }

    warshall_floyd();

    int ans = 0;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            if (i != j) checkShortestPath(i, j);
        }
    }

    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            if (i != j && path[i][j] == 1) ans++;
        }
    }

    cout << ans / 2 << endl;

    return 0;
}


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

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}






int gcd(int a,int b)
{
 
  int r, tmp;
 
  
 
  /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
 
 
  return b;
}







int fac(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}

int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}
///////////////////////////
int main() {
  ios::sync_with_stdio(false);
  int n,count=0;
  cin>>n;
  vector<int> v(n);
  rep(i,n) cin>>v[i];
  sort(v.begin(),v.end());
  for(int i=0;i<n-2;i++){
    for(int j=i+1;j<n-1;j++){
      for(int k=j+1;k<n;k++){
        if(v[i]<v[j]+v[k] && v[j]<v[i]+v[k] && v[k]<v[j]+v[i]) count++;
      }
    }
  }
  cout<<count<<endl;
  
  
}
///////////////////////////


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16
#define mod 1000000007

ll sum(ll a){
  return a*(a+1)/2;
}

ll sqsum(ll a){
  return a*(a+1)*(2*a+1)/6;
}

ll qsum(ll a){
  return sum(a)*sum(a);
}

ll n,m;
vector<P> qs;
ll cnt[3][50001],cntjust[3][50001];

int main(){
  cin>>n>>m;
  rep(i,m){
    ll q,k;
    cin>>q>>k;
    if(q==0){
      ll lb=0,ub=n+1;
      while(ub-lb>1){
        ll mid=(ub+lb)/2;
        if(sum(mid)<k)lb=mid;
        else ub=mid;
      }
      k=ub;
    }
    if(k>n)continue;
    qs.push_back(P(q,k));
    cnt[q][k]++;
    cntjust[q][k]++;
  }
  rep(i,3)rep(j,n)cnt[i][j+1]+=cnt[i][j];
  m=qs.size();
  ll add=0,sub=0;
  rep(i,m){
    ll q=qs[i].fi,k=qs[i].se;
    if(q==0){
      sub+=k*k;
    }else{
      sub+=sqsum(n)-sqsum(k-1);
    }
  }

  rep(i,m){
    ll q=qs[i].fi,k=qs[i].se;
    if(q==0){
      add+=k*(cnt[1][k]+cnt[2][k]);
    }else if(q==1){
      add+=(sum(n)-sum(k-1))*cnt[2][k-1];
      add+=(sum(n)-sum(k-1))*cntjust[2][k];
    }else if(q==2){
      add+=(sum(n)-sum(k-1))*cnt[1][k-1];
    }
  }

  rep(i,m){
    ll q=qs[i].fi,k=qs[i].se;
    if(q==0){
      sub+=cnt[1][k]*cnt[2][k];
    }
  }

  cout<<qsum(n)+add-sub<<endl;
  return 0;
}



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

int main()
{
    long long int n,m;
    long long int a,b,sum=0;
    long long int ans =0; 
    cin  >> n >> m;
    sum = m;
    vector<pair<long long int,long long int>>pairs(n);
    for(int i=0;i<n;i++){
        cin >> a >> b;
pairs[i] = make_pair(a,b);
    }
    sort(pairs.begin(),pairs.end());
    for(int i=0;i<n;i++){
        if(pairs[i].second < sum){
            ans += pairs[i].second * pairs[i].first;
            sum -= pairs[i].second;
           // cout << sum <<endl;
            //cout <<  i << " " <<  pairs[i].first << " "<< pairs[i].second << " "<<ans << endl;
        }else{
ans += sum * pairs[i].first;
//cout << sum <<endl;
   //cout <<  i << " " <<  pairs[i].first << " "<< pairs[i].second << " "<<ans << endl;
break;
        }
    }
   // for(int i=0;i<n;i++)cout << pairs[i].first << " " <<pairs[i].second << endl;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll power(ll a,ll b)
{ll result=1;
while(b>0)
{if(b%2==1)
 result*=a;
 a*=a;
 b/=2;
}
return result;
}

int main()
{ios_base::sync_with_stdio(false);
    cin.tie(NULL);
ll n;
cin>>n;
if(n<=1000)
cout<<1000-n;
else
{if(n%1000==0)
 cout<<0;
 else
 {ll temp=n/1000;
  cout<<abs(n-((temp+1)*1000));
 }
}
}

Measured memory_bytes: 3620
N = int(input())
A = [int(x) for x in input().split()]

dp = [[[0,0] for _ in range(2)] for _ in range(N+1)]
dp[0][0] = [1000,0]

for i in range(N):
    for j in range(i+1):
        if(dp[j][0][0] > dp[i+1][0][0]):
            dp[i+1][0][0] = dp[j][0][0]
        x = dp[j][1][0] + dp[j][1][1] * A[i]
        if(x > dp[i+1][0][0]):
            dp[i+1][0][0] = x
        
        y = dp[j][0][0] // A[i]
        x = dp[j][0][0] % A[i]
        if((y > dp[i+1][1][1] ) or (y == dp[i+1][1][1] and x > dp[i+1][1][0])):
            dp[i+1][1][1] = y
            dp[i+1][1][0] = x
        
        y = dp[j][1][1] + dp[j][1][0] // A[i]
        x = dp[j][1][0] % A[i]
        if((y > dp[i+1][1][1] ) or (y == dp[i+1][1][1] and x > dp[i+1][1][0])):
            dp[i+1][1][1] = y
            dp[i+1][1][0] = x

print(dp[N][0][0])

Measured memory_bytes: 9308
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

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

	private static void mt_Diff() {
		ArrayList<Double> mts = new ArrayList<Double>();

		while (sc.hasNext()) {
			double h = sc.nextDouble();
/*
			if (h == 0.0) {
				break;
			}
*/
			mts.add(h);
		}

		Collections.sort(mts);

		System.out.printf("%f\n", Math.abs(mts.get(0) - mts.get(mts.size() - 1)) );

	}

}


Measured memory_bytes: 27880
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char N[200000];
  cin >> N;
  
  int num;
  long long count,len;
  count = 0;

  len = strlen(N);

  for (long i = 0; i < len; i++) {
      num = N[i] - '0';
      count += num; 
  }
  
  if (count % 9 == 0){
     cout << "Yes" <<endl;    
  }else{
      cout << "No" <<endl;
  } 
 
  
      
}

Measured memory_bytes: 3780
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

int main() {
  int h, w;
  cin >> h >> w;
  vector<vector<char>> v(h, vector<char> (w));
  
  for (int i=0; i<h; i++){
    for (int j=0; j<w; j++){
      cin >> v[i][j];
    }
  }
  
 
  set<int> sh, sw;
  for (int i=0; i<h; i++){
     bool hsh = true;
    for (int j=0; j<w; j++){
      if (v[i][j] == '#'){
        hsh = false;
        break;
      }
    }
    if (hsh){
      sh.insert(i);
    }
  }
  
  
  for (int i=0; i<w; i++){
    bool wsh = true;
    for (int j=0; j<h; j++){
      if (v[j][i] == '#'){
        wsh = false;
        break;
      }
    }
    if (wsh){
      sw.insert(i);
    }
  }
  
  
  for (int i=0; i<h; i++){
    bool kaigyou = false;
    if(sh.count(i) != 0){
      continue;
    }
    for (int j=0; j<w; j++){
      if (sw.count(j) == 0){
        cout << v[i][j];
        kaigyou = true;
      }  
    }
    if(kaigyou){
      cout << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 256
/*
 * main.c
 *
 *  Created on: 2020/03/28
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MAX(a,b) (a > b ? a : b)
#define MIN(a,b) (a > b ? b : a)
typedef long long int ll;
typedef unsigned long long int ull;

int sort_inc(const void *a, const void *b) { return (*(int*)a - *(int*)b);}
int sort_dec(const void* a, const void* b) { return (*(int*)b - *(int*)a);}
int sort_dec_ll(const void *a, const void *b) {
    ll da = *(ll*)a, db = *(ll*)b;    int val = 0;
    if(da > db) { val = -1; }
    else if (da == db) { val = 0; }
    else { val = 1; }
    return val;
}
int sort_inc_ll(const void *a, const void *b) {
    ll da = *(ll*)a, db = *(ll*)b;    int val = 0;
    if(da > db) { val = 1; }
    else if (da == db) { val = 0; }
    else { val = -1; }
    return val;
}
int sort_dic(const void *a, const void *b) {
    char *pa = (char *)a;    char *pb = (char *)b;    int i = 0, val = 0, N = 10;
    for (i = 0; i < N; i++) {
    	char da = pa[i], db = pb[i];
    	if (da == db) continue;
  		if (da > db) val = 1; else val = -1;
        break;
    }
    return val;
}


int main()
{
	int N = 0, ans = 0;
	scanf("%d", &N);
	if ((N/100) == 7) {
		ans = 1;
	} else if (((N%100)/10) == 7) {
		ans = 1;
	} else if (((N%100)%10) == 7) {
		ans = 1;
	} else {
		ans = 0;
	}
	if (ans == 1) {
		printf("Yes\n");
	} else {
		printf("No\n");
	}
    return 0;
}


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

int top,S[100];

void push(int a){
  S[++top] = a;
}

int pop(){
  int ans;
  top--;
  ans = S[top+1];
  return ans;

}

int main(){

  int s,t,u,i;
  top = 0;
  char array[1000000];

  while(1)
    {

      if( scanf("%s", &array[0]) == EOF ) break;

      if ( array[0] == '+' ){
        s = pop();
        t = pop();
        push(s + t);
      }
      else if ( array[0] == '-' ){
        t = pop();
        s = pop();
        push(s - t);
      }
      else if ( array[0] == '*' ){
        s = pop();
        t = pop();
        push(s * t);
      }
 else {
        u = atoi(array);
        push(u);
      }
    }
  printf("%d\n", pop());

  return 0;
}

Measured memory_bytes: 556
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

constexpr static int MAXN = 1e6;

int N, C, K;
int t[MAXN];

int main() {
    cin >> N >> C >> K;
    for (int i = 0; i < N; i++)
        cin >> t[i];
    sort(t, t + N);

    int buses = 0;
    int i = 0;
    while (i < N) {
        int j = i;
        while (j < N && j < i + C && t[j] <= t[i] + K)
            j++;
        buses++;
        i = j;
    }
    cout << buses << endl;
}


Measured memory_bytes: 640
// AOJ 2592: Flowers
// 2017.11.30 bal4u@uu

#include <stdio.h>

int vw[100002], pf[100002], vf[100002], th[100002];
int n, pw;

double calc(double x)
{
	int i;
	double t, ans = pw * x;
	
	for (i = 0; i < n; i++) {
		t = th[i] - x * vw[i];
		if (t > 0) ans += t / (double)vf[i] * pf[i];
	}
	return ans;
}

int main()
{
	int i;
	double l, r, lm, rm, x, y, t, ans;

	while (scanf("%d", &n) && n > 0) {
		scanf("%d", &pw);
		for (i = 0; i < n; i++) scanf("%d%d%d%d", vw+i, pf+i, vf+i, th+i);

		l = 0, r = 1000;
		ans = 1e10;
		for (i = 0; i < 75; i++) {
			lm = (l * 2 + r) / 3;
			rm = (l + r * 2) / 3;
			x = calc(lm);
			y = calc(rm);
			if (x < y) r = rm;
			else       l = lm;
			t = x; if (y < t) t = y;
			if (ans > t) ans = t;
		}
		printf("%.8lf\n", ans);
	}
	return 0;
}

Measured memory_bytes: 3240
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<n; i++)
#define REP(i,x,n) for (int i=x; i<n; i++)
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
const int mod =1'000'000'007;

ll factor(ll n, ll k){
    ll x = abs(n - k);
    if (x > n){
        return n;
    }
    return factor(x, k);
}

int main(){
    ll n, k;
    cin >> n >> k;
    if (n % k == 0){
        cout << 0 << endl;
        return 0;
    }
    ll x = n % k;
    ll y = abs(x - k);
    ll z = min(x, y);
    cout << z << endl;
    return 0;
}


Measured memory_bytes: 3532
#include <stdio.h>
#define N 100
int main()
{
  int mini,i,j,k[N],kin,gensui,cnt;
  scanf("%d",&kin);

for(i=0;i<kin;i++)
{
    scanf("%d",&k[i]);
}

for(i=0;i<kin-1;i++)
{
  mini=i;
  for(j=i;j<kin;j++)
  {
  if(k[j]<k[mini])
  mini=j;
  }

gensui=k[i];
k[i]=k[mini];
k[mini]=gensui;

if(i!=mini)
cnt++;
}

for(i=0;i<kin;i++)
{
  if(i>0)
  printf(" ");

  printf("%d",k[i]);
}

printf("\n");
printf("%d\n",cnt);

return 0;
}



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

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

	int n, m, k;
	cin >> n >> m >> k;

	for (int i=0; i<=n; i++) {
		for (int j=0; j<=m; j++) {
			if (i*(m-j) + j*(n-i) == k) {
				cout << "Yes\n";
				return 0;
			}
		}
	}
	cout << "No";
}

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

int main(){
  long long int a,b,c;
  cin >> a >> b >> c;
  if(c<=a+b)
    cout << "No" << endl;
  else if(2*(a*b+b*c+c*a) < a*a+b*b+c*c)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
class PotentializedUnionFind():
    "Either 0-indexed or 1-indexed"

    __slots__ = ["parent", "potential_diff"]

    def __init__(self, size):
        self.parent = [-1] * (size + 1)
        self.potential_diff = [0] * (size + 1) # potential_diff[node] = potential[parent[node]] - potential[node]
    
    def find(self, a):
        path = []
        while self.parent[a] > 0:
            path.append(a)
            a = self.parent[a]
        for child in reversed(path):
            self.potential_diff[child] += self.potential_diff[self.parent[child]]
            self.parent[child] = a
        return a

    def union(self, a, b, diff):
        """
        connect a and b, where potential of these satisfy `potential[b] - potential[a] == diff`,
        Returning `not same(a, b)`. 
        
        If a and b are already in the same tree, then this does nothing.
        """

        a_root = self.find(a)
        b_root = self.find(b)
        diff += self.potential_diff[b] - self.potential_diff[a] # find で経路圧縮しているのでこれでよい。
        a = a_root
        b = b_root

        if a == b:
            return False 
        else:
            if self.parent[a] == self.parent[b]:
                self.parent[a] = b
                self.parent[b] -= 1
                self.potential_diff[a] = diff
            elif self.parent[a] < self.parent[b]: #aのほうが大きい
                self.parent[b] = a
                self.potential_diff[b] = -diff
            else:
                self.parent[a] = b #bのほうが大きい
                self.potential_diff[a] = diff
            return True
        
    def same(self, a, b):
        return self.find(a) == self.find(b)

    def diff(self, a, b):
        assert self.find(a) == self.find(b) # find(a) と find(b) 内での経路圧縮が本質なので、コメントアウトしない。
        return self.potential_diff[a] - self.potential_diff[b]


def main():
    import sys
    input = sys.stdin.buffer.readline
    
    N, M = map(int, input().split())
    lrds = list(map(int, sys.stdin.buffer.read().split()))
    puf = PotentializedUnionFind(N)
    ls = lrds[::3]
    rs = lrds[1::3]
    ds = lrds[2::3]
    for l, r, d in zip(ls, rs, ds):
        if not puf.union(l, r, d):
            if not puf.diff(l, r) == d:
                print("No")
                exit()
    
    print("Yes")
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 129672