akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <numeric>
#include <climits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <utility>
#include <cctype>
#include <iterator>
////////////////////////////////////////////////
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define FOR(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define REPe(e, mp) for (auto& e : mp)
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
using ll = long long int;
using vecint = vector<int>;
using vecll = vector<ll>;
using vec2int = vector<vector<int>>;
using P = pair<int, int>;
////////////////////////////////////////////////
int main() {
  ////////////////////////////////////////////////
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ////////////////////////////////////////////////
  int n;
  cin >> n;
  vector<ll> a(n, 0);
  ll ans = 1LL;
  REP(i, n) {
    cin >> a[i];
    if (a[i] == 0) {
      ans = 0;
    }
  }
  if (ans == 0) {
    cout << 0 << endl;
    return 0;
  }
  REP(i, n) {
    if (ans < (ll)2e18 / a[i]) {
      ans *= a[i];
    } else {
      ans = -1;
      break;
    }
    if (ans > 1000000000000000000) {
      ans = -1;
      break;
    }
  }
  cout << ans << endl;
}
//////////////////////////////////////////////


Measured memory_bytes: 3988
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

//HEADER FILES AND NAMESPACES
 
#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;
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
template <typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>; 
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
#define uid(a, b) uniform_int_distribution<int>(a, b)(rng)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);  

#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r+", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w+", stdout);
#endif  
	
    ll A,B,C,D;
    cin>>A>>B>>C>>D;
    cout << max({A*C,A*D,B*C,B*D}) << '\n';
}
 
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long llong;
typedef unsigned long long ullong;

using namespace std;

int main() {
	llong n;//200000
	llong a[200005];
	map<llong, llong> m;// 何の数字が 何個あるか
	llong c[200005];
	cin >> n;
	llong _a;
	rep(i, n)
	{
		cin >> a[i];
		m[a[i]]++;
	}
	long t = 0;
	for (auto& it : c)
		it = -1;

	for (auto& it : m)
	{
		if (c[it.second] == -1)
		{
			c[it.second] = it.second * (it.second - 1) / 2;
		}
		t += c[it.second];
	}

	rep(i, n)
	{
		llong aa = t;
		aa -= m[a[i]] * (m[a[i]] - 1) / 2;
		aa += (m[a[i]] - 2) * (m[a[i]] - 1) / 2;
		cout << aa << endl;
	}
}

Measured memory_bytes: 14236
#include<bits/stdc++.h>
#define ST first
#define ND second
#define ll long long
#define ld long double
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using namespace std;

const ll  INF = 1e9 + 9;
const ll  MOD = 1e9 + 7;
const long long LINF = (ll)1e18 + 3;
 
// secik.insert({x, t++});
// secik.erase(secik.lower_bound({x,-1}));
// *secik.find_by_order(x)).first << "\n";
// secik.order_of_key(x)
 
//random_device device;
//mt19937 gener(device());
//uniform_int_distribution<ll > gen(0,n-1);
//gen(gener); // generate random number

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

	int n; cin >> n;
	vector<ll> tab(n);
	for(int i = 0; i < n; i++) cin >> tab[i];
	
	sort(tab.begin(),tab.end());
	
	n--;
	ll res = 0;
	int ind = n;
	if(n > 0){
		res += tab[ind];
		n--;
		ind--;
	}
	
	while(n){
		if(ind < 0) assert(false);
		if(n >= 2){
			res += 2*tab[ind];
			n-=2;
			ind--;
		} else {
			res += tab[ind];
			n = 0;
		}	
	}
	
	cout << res;
	
	
	
	
	
	
	
	
	
	
	

}

Measured memory_bytes: 4744
n=int(input())
if n==1:print(0);exit()
s=list(map(int,input().split()))
a=0
l,r=0,1
while 1:
    if s[r-1]>=s[r]:
        a=max(a,r-l)
        r+=1
    else:
        l=r
        r=l+1
    if r==n:break
print(a)

Measured memory_bytes: 14224
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <utility>
#include <cstring>
using namespace std;
typedef long long ll;

const int SIZE = 1E6;
vector<int> primes;
vector<bool> bits(SIZE);

void sieve() {
	for (int i = 3; i < SIZE; i+=2) {
		if (!bits[i]) {
			primes.push_back(i);
			for (ll j = (ll)i*i; j < SIZE; j += i) {
				bits[(int)j] = true;
			}
		}
	}
}

int main() {
	sieve();
	int N;
	scanf("%d", &N);
	ll S;
	int ans = 0;
	for (int i = 0; i < N; ++i) {
		scanf("%lld", &S);
		S = S * 2 + 1;
		bool res = false;
		if (S < SIZE) {
			res = bits[(int)S];
		} else {
			for (int j = 0; ;++j) {
				ll p = primes[j];
				if (p * p > S) break;
				if (S % p == 0) {
					res = true;
					break;
				}
			}
		}
		if (!res) ++ans;
	}
	printf("%d\n", ans);
}

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

using namespace std;

int dp[10001];
int n,h,a[1000],b[1000];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int h,n;
	cin >> h >> n;
	
	for(int i=0;i<n;i++){
		cin >> a[i] >> b[i];
	}
	memset(dp,0x3f,sizeof(dp)); 
	dp[0]=0;	
	for(int i=0;i<n;i++){
		int c=a[i];
		int p=b[i];
		for(int j=1;j<=h;j++){
			if(j < c)
				dp[j]=min(dp[j],p);
			else 
				dp[j]=min(dp[j],dp[j-c]+p);
		}
	}
	cout<<dp[h];
}

Measured memory_bytes: 3660
import heapq as h;I=lambda:list(map(int,input().split()));n,k=I();z=[i*2+1for i in range(n)];s=sorted([I()for _ in[0]*n],key=lambda x:-x[1]);q=[];v=A=0;l=[0]*-~n
for a,b in s[:k]:
 if l[a]:h.heappush(q,b)
 else:A+=z[v];v+=1
 l[a]=1;A+=b
T=A
for a,b in s[k:]:
 if l[a]^1and q:l[a]=1;T+=b+z[v]-h.heappop(q);v+=1;A=max(A,T)
print(A)

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

int main() {
    string s, t, u;
    int a, b;
    cin >> s >> t >> a >> b >> u;
    if (u == s)
        a--;
    else if (u == t)
        b--;
    cout << a << " " << b << endl;
}


Measured memory_bytes: 3512
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define INF 10000000
using ll = long long ;
ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}
template< int id > struct CompTupleBy
{
  template<class T> 
  bool operator()( const T& a, const T& b ) const {
    return std::get<id>(a) < std::get<id>(b);
  }
};

using namespace std;

int main(){
    int a,b;
    cin >> a >> b;
    int out = 1;
    int ans = 0;
    while(out<b){
        out--;
        out += a;
        ans++;
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
def main ():
    antennas= []
    max     = 0
    for i in range(6):
        if i < 5:
            antennas.append(int(input()))
        else:
            max = int(input())
    print (distance_comparison(max,antennas))

def distance_comparison(max,antennas):
    memo = []
    for i in range(len(antennas)):
        compnum = i+1
        for j in range(len(antennas[compnum:])):
            append_data = abs(antennas[i] - antennas[compnum])
            if append_data <= max:
                memo.append(append_data)
            else:
                return ":("
            compnum+=1
    return "Yay!"


main()

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

int main(){
	int N,a[250];
	int ans=0;
	cin>>N;
	for(int i=0;i<2*N;i++)cin>>a[i];
	sort(a,a+2*N);
	for(int i=0;i<2*N;i+=2)ans+=a[i];
	cout<<ans<<endl;
}

Measured memory_bytes: 256
n = int(input())
ai = [int(i) for i in input().split()]

ans = 0
s = 0
x = 0

r = 0
            
for l in range(n):
    while r <= n-1 and s+ai[r] == x^ai[r]:
        s += ai[r]
        x ^= ai[r]
        r += 1
    ans += (r-l)
    
    if l == r:
        r += 1
    else:
        s -= ai[l]
        x ^= ai[l]
        
print(ans)

Measured memory_bytes: 77900
class UnionFind():
    def __init__(self,n):
        self.n=n
        self.parents=[-1]*n

    def find(self,x): #要素xが属するグループの根を返す
        #根ならその番号を返す
        if self.parents[x]<0: 
            return x 
        # 根でないなら、親の要素で再検索
        else:
            # 走査していく過程で親を書き換える
            self.parents[x]=self.find(self.parents[x])
            return self.parents[x]
    
    def union(self,x,y): #要素xが属するグループと要素yが属するグループとを併合する
        #根を探す
        x=self.find(x)
        y=self.find(y)

        if x==y:
            return
        if self.parents[x]>self.parents[y]: #グループの大きい方に合わせる
            x,y=y,x

        self.parents[x]+=self.parents[y] #x(根)の要素にｙ(根)のグループの要素数をプラスする(要素の値は負の数で表される)
        self.parents[y]=x

    def size(self,x): #要素xが属するグループのサイズ（要素数）を返す
        return -self.parents[self.find(x)]
    
    def same(self,x,y): #要素x, yが同じグループに属するかどうかを返す
        return self.find(x)==self.find(y)

    def members(self,x): #要素xが属するグループに属する要素をリストで返す
        root=self.find(x)
        return [i for i in range(self.n) if self.find(i)==root]
    
    def roots(self): #すべての根の要素をリストで返す
        return [i for i ,x in enumerate(self.parents) if x<0]

    def group_count(self): #グループの数を返す
        return len(self.roots())

    def all_group_members(self): #{ルート要素: [そのグループに含まれる要素のリスト], ...}の辞書を返す
        return {r:self.members(r) for r in relf.roots()}

    def __str__(self): #ルート要素: [そのグループに含まれる要素のリスト]を文字列で返す (print()での表示用)
        return '\n'.join('{}:{}'.format(r,self.members(r)) for r in self.roots())

N,M=map(int,input().split())
uf=UnionFind(N)

#友達関係
for i in range(M):
    a,b=map(int,input().split())
    uf.union(a-1,b-1)

ans=0
roots=uf.roots()

for i in roots:
    ans=max(ans,uf.size(i))

print(ans)

Measured memory_bytes: 18280
using System;
using System.Linq;

namespace B_ChooseIntegers
{
    class Program
    {
        static void Main(string[] args)
        {
            
            var intputs = System.Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var A = intputs[0];
            var B = intputs[1];
            var C = intputs[2];

            var result = false;

            for (var i = B; i >= 1; i--)
            {
                if((A * i) % B == C)
                {
                    result = true;
                    break;
                }
            }
            Console.WriteLine(result ? "YES" : "NO");
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define rep(i,n) FOR(i,0,n)
 
int main(){
	
	string s;cin >> s;
	string an = "CODEFESTIVAL2016";
	int ans=0;
	rep(i,16)if(s[i]!=an[i])ans++;
	cout << ans << endl;
		
	
}

//cout << ans << endl;

Measured memory_bytes: 256
<?php

class Calculate {

    public function getAnswer()
    {
        $n = trim(fgets(STDIN));
        $count = 0;

        for ($i = 0; $i < $n; $i++) {
            $num = (int) fgets(STDIN);

            if ($this->isPrime($num)) {
                $count++;
            }
        }

        echo $count . PHP_EOL;
    }
}

class CheckPrimeNumbers extends Calculate {

    public function isPrime($num)
    {
        if ($num == 2) {
            return true;
        } elseif ( $num < 2 or $num % 2 == 0) {
            return false;
        } else {
            $start = 3;
            while ($start <= sqrt($num)) {
                if ($num % $start == 0) {
                    return false;
                }
                $start += 2;
            }
            return true;
        }
    }
}

$rate = new CheckPrimeNumbers();
$rate->getAnswer();



Measured memory_bytes: 9316
from itertools import accumulate
n = int(input())
a = list(map(int, input().split()))
a.sort()
a_acc = list(accumulate(a))[:-1]
ans = 1
for i in reversed(range(n-1)):
    if a_acc[i] * 2 >= a[i+1]:
        ans += 1
    else: break
print(ans)

Measured memory_bytes: 14428
N,M = map(int, input().split())
 
sets = []
for i in range(M):
  s,c = input().split()
  sets.append((s,c))
 
start = 0
if N != 1:
  start = 10**(N-1)
 
for n in range(start,10**N):
  for s,c in sets:
    if str(n)[int(s)-1] == c:
      continue
    else:
      break
  else:
    print(n)
    break
else:
  print(-1)

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#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>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define EPS 1e-9
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}


signed main(void) {
    int n;
    cin >> n;
    vi a(n);
    rep(i,n)cin >> a[i];
    int ans = 0;
    rep(i,n){
        int cnt = 0;
        loop(j,i,n-1){
            if(a[j] < a[j+1])break;
            else cnt++;
        }
        ans = max(ans, cnt);
        i += cnt;
    }
    cout << ans << endl;

}


Measured memory_bytes: 1024
import sys
import os
import itertools
from collections import deque

def main():
    if os.getenv("ENV")=='LOCAL':
        sys.stdin = open(os.path.dirname(__file__)+'/input.txt', 'r')

    X,N=map(int, input().split())
    if N==0:
        print(X)
    else:
        p=list(map(int, input().split()))

        i=1
        if not X in p:
            print(X)
        else:
            while True:
                if not X-i in p:
                    print(X-i)
                    break
                if not X+i in p:
                    print(X+i)
                    break
                i+=1

if __name__ == '__main__':
    main()


Measured memory_bytes: 9404
def water(l,x,c):
    if l==1:
        return x[0]
    if l==0:
        return 0
    k=j=0
    for i in x:
        if i==0:
            k=j
            break
        j+=1
    if j<l:
        #print(k)
        #print(x[:k])
        c += water(k, x[:k], 0)
        #print(l - (k+1))
        #print(x[k+1:])
        c += water(l - (k+1) , x[k+1:], 0)
    else:
        c+=1
        for i in range(l):
            x[i]-=1
        i=0
        while x[i]==0 and i < l-1:
            i+=1
        c+=water(l-i,x[i:],0)
    return c

a=int(input())
b=[int(i) for i in input().split()]
c=water(a,b,0)
#print("A")
print(c)

Measured memory_bytes: 3188
#include<iostream>
#include<string.h>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#define ll long long int
#define ld long double
#define INF 1000000000
#define EPS 0.0000000001
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;

typedef complex<double> P;

struct L : public vector<P>{//??´???
  L(const P &a, const P &b){
    push_back(a);push_back(b);
  }
};

struct C{//???
  P c; double r;
  C(const P &c,double r): c(c),r(r){}
};

namespace std{//??????????????????
  bool operator < (const P& a,const P& b){
    return real(a)!= real(b) ? real(a) < real(b) : imag(a) < imag(b);
    //return imag(a) != imag(b) ? imag(a) < imag(b) : real(a) < real(b)
  }
  bool operator == (const P& a,const P& b){
    return a.real()==b.real()&&a.imag()==b.imag();
  }
}

double dot(P a,P b){
  return real(conj(a)*b);
}

double cross(P a,P b){
  return imag(conj(a)*b);
}

int ccw(P a, P b, P c){
  b-=a;c-=a;
  if(cross(b,c)>0)   return +1;// counter clockwise 
  if(cross(b,c)<0)   return -1;// clockwise 
  if(dot(b,c)<0)     return +2;// c-a-b on line
  if(norm(b)<norm(c))return -2;// a-b-c on line
  return 0;                    // a-c-b on lone
}

P intersection(P a,P b,P c,P d){//2??´????????????
  return a+(b-a)*(cross(d-c,c-a)/cross(d-c,b-a));
}

int main()
{
  int i;
  int q;

  cin>>q;

  rep(i,q){
    double xp,yp;

    cin>>xp>>yp;  P p1(xp,yp);
    cin>>xp>>yp;  P p2(xp,yp);
    cin>>xp>>yp;  P p3(xp,yp);
    cin>>xp>>yp;  P p4(xp,yp);

    P p=intersection(p1,p2,p3,p4);
    printf("%.9f %.9f\n",p.real(),p.imag());

  }

}

Measured memory_bytes: 3204
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    string s; cin >> s;
    ATYN(s[0] == s[2])

    return 0;
}

Measured memory_bytes: 256
N= int(input())
H= list(map(int, input().split()))
flag=0
before=0
bad=0
for i in H:
    if bad==1:
        break
    if before<i:
        flag=0
    elif before==i:
        pass
    elif before==i+1:
        if flag==1:
            bad=1
            break
        else:
            flag=1
    else:
        bad=1
        break
    before=i
if bad==0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 14252
MOD = 10 ** 9 + 7
INF = 10 ** 11
import sys
sys.setrecursionlimit(100000000)

N = int(input())
ans = []
def dfs(i,standard):
    if i == N:
        ans.append(standard)
        return
    before_M = max(ord(s) for s in standard)
    for j in range(97,before_M + 2):
        dfs(i + 1,standard + chr(j))
dfs(1,'a')
print('\n'.join(ans))


Measured memory_bytes: 15128
/* * * * * * * * * * * **
*                      *
*	   saurabh8522	   *
*	  I will handle	   *
*		   it.		   *
*                      *
* * * * * * * * * * * **/
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define ld long double
#define zero(a) memset((a),0,sizeof((a)))
#define one(a) memset((a),1,sizeof((a)))
#define minus(a) memset((a),-1,sizeof((a)))
#define all(g) g.begin(),g.end()
#define ppb pop_back
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> //indexed_set;
typedef long long int ll;
#define MOD 1000000007
ll extgcd(ll a,ll b,ll& x,ll& y){if(b==0){x=1;y=0;return a;}else{int g=extgcd(b,a%b,y,x);y-=a/b*x;return g;}}
ll modpow(ll a,ll b,ll m) {ll res=1;a%=m;for(;b;b>>=1){if(b&1)res=res*a%m;a=a*a%m;}return res;}
ll numdigit(ll n){return floor(log10(n)) + 1;}
bool isPowerTwo (ll x) { return x && (!(x&(x-1))); } 
int  main(){
	FastRead;
	ll t=1;
	// cin>>t;
	while(t--){
		ll n;
		cin>>n;
		map<string,ll>mp;
		for(int i=0;i<n;i++){
			string s;
			cin>>s;
			mp[s]++;
		}
		cout<<mp.size()<<endl;
	}
}

Measured memory_bytes: 19268
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <stack>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

struct Rectangle
{
	int height;
	int pos;
};

string st[501];
int w[501][501];

int getLargestRectangle(int size,int buffer[])
{
	stack<Rectangle> S;
	int maxv = 0;
	buffer[size] = 0;

	rep(i,size+1)
	{
		Rectangle rect;
		rect.height = buffer[i];
		rect.pos = i;
		if(S.empty())
		{
			S.push(rect);
		}
		else
		{
			if(S.top().height < rect.height)
			{
				S.push(rect);
			}
			else if(S.top().height > rect.height)
			{
				int target = i;
				while(!S.empty() && S.top().height >= rect.height)
				{
					Rectangle pre = S.top();
					S.pop();
					int area = pre.height * (i - pre.pos);
					maxv = max(maxv,area);
					target = pre.pos;
				}

				rect.pos = target;
				S.push(rect);

			}
		}
	}
	return maxv;
}

int getLargestRectangle(int n,int m)
{
	rep(i,n)
	{
		rep(j,m)
		{
			w[i][j] = 0;
		}
	}

	rep(j,m)
	{
		int sequence = 0;
		rep(i,n)
		{
			if(st[i][j] == '*')
			{
				sequence = w[i][j] = 0;
			}
			else
			{
				w[i][j] = ++sequence;
			}
		}
	}

	int maxv = 0;
	rep(i,n)
	{
		maxv = max(maxv,getLargestRectangle(m,w[i]));
	}
	return maxv;
}

int main()
{
	int n,m;
	while(cin >> n >> m && n && m)
	{
		memset(w,0,sizeof(w));
		rep(i,n)
		{
			cin >> st[i];
		}

		rep(i,n)
		{
			rep(j,m)
			{
				if(st[i][j] == '*') w[i][j] = 0;
				else w[i][j] = 1;
			}
		}

		cout << getLargestRectangle(n,m) << endl;
	}
	return 0;
}

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

using namespace std;

#define forn(i0, n0) for (int i0 = 0; i0 < n0; i0++)
#define printvi(arr) for (int x0 : arr) cout << x0 << ' '; cout << '\n';
#define printvl (v) for (ll x : v) cout << x << ' '; cout << '\n'
#define ff first
#define ss second
#define all(a) (a).begin(), (a).end()
#define Sort(a) sort(all(a))
#define Reverse reverse (all(a))

typedef long long ll;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    ll n, k;
    cin >> n >> k;
    n %= k;
    cout << min(n, abs(n - k));
    return 0;
}

Measured memory_bytes: 256
import itertools
n, m = map(int, input().split())
index=0
switchL=[]
while index < m:
    listSw = list(map(int, input().split()))
    switchL.append(listSw)
    index+=1
listP = list(map(int, input().split()))

counter=0
for combi in itertools.product([0, 1], repeat=n):
    listR = list(combi)
    index=0
    while index < len(switchL):
        sumA=0
        index2=1
        while index2 < len(switchL[index]):
            target = switchL[index][index2]-1
            sumA+=listR[target]
            index2+=1
        if sumA%2 == listP[index]:
            index+=1
        else:
            break
    if index == len(switchL):
        counter+=1
print(counter)

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

int main(){
	int n;
	while( cin>>n ,n){  // nが0ならwhileを抜けます。

		int dp[50]={};  // 階段のかわり　（　余裕を持って50段用意しています　）

		dp[0]=1;        // 今０段目にいる。（　階段を登っていない通り数は１つ　）    （　まだ階段を登っていない　＝　0段目にいる　）

		for(int i=0;i<n;i++){  // i段目で３通りの飛び方を試す

			dp[i+1] += dp[i];   // 1段先に飛ぶ  (1段先にi段目までの通り数を足す)
			dp[i+2] += dp[i];   // 2段先に飛ぶ　(2段先にi段目までの通り数を足す)
			dp[i+3] += dp[i];   // 3段先に飛ぶ　(3段先にi段目までの通り数を足す)

		}

        /*   dp[n] に　n段目に飛んでいく通り数が入ってます　*/

		cout<< ( (dp[n]/10)/365 + 1 )<<endl;  //  1日に10回飛ぶ　＝　割る10。  １年間あたり　＝　割る365。　いい感じにしたいので１を足す
	}
}


Measured memory_bytes: 3088
#include <iostream> 
#include <string>
#include <string.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <stdlib.h>
#include <deque>  
#include <iomanip>

using namespace std;

using ll = long long;
const ll INF  = 1e9;
const ll MOD =  1e9 + 7;
#define rep(i, n) for(int i = 0; i < n; i++)
#define loop(i, a, n) for(int i = a; i < n; i++)
#define all(in) in.begin(), in.end()
int main(){
    int N, K;
    cin >> N >> K;
    cout << N - K + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	a, b, k := nextInt(), nextInt(), nextInt()
	aValue := a - k
	bValue := b + min(aValue, 0)
	fmt.Println(max(aValue, 0), max(bValue, 0))
}

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

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

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

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


Measured memory_bytes: 640
// IOI 2021
#include <bits/stdc++.h>
using namespace std;
 
#define endl '\n'
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << ends << H; debug_out(T...); }
#define debug(...) cerr << "{" << #__VA_ARGS__ << "}:", debug_out(__VA_ARGS__)
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll MOD = 924844033;
 
////////////////////////////////////////////////////////////////////
 
const int N = 1e5 + 5;

int A[N], H[N];

void DFS(int v, int h = 1) {
	H[v] = h;
	if (!H[A[v]]) DFS(A[v], h + 1);
}

int main() {
 
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	mt19937 Rnd(time(0));

	int n; cin >> n;
	for (int i = 0; i < n; i++) cin >> A[i], A[i]--;
	DFS(0);
	cout << H[1] - 1 << endl;

	return 0;
}


Measured memory_bytes: 4376
<?php

const ROW_NUM = 3;
const COL_NUM = 3;

$input = [];
for ($i = 0; $i < ROW_NUM; $i++)
{
    $input[$i] = explode(' ', trim(fgets(STDIN)));
}

$result = true;

$a00 = (int)$input[0][0];
$a01 = (int)$input[0][1];
$a02 = (int)$input[0][2];

$a10 = (int)$input[1][0];
$diff = $a00 - $a10;

$a11 = (int)$input[1][1];
$result = $result && ($a01 - $a11 === $diff);
$a12 = (int)$input[1][2];
$result = $result && ($a02 - $a12 === $diff);

$a20 = (int)$input[2][0];
$diff = $a00 - $a20;
$a21 = (int)$input[2][1];
$result = $result && ($a01 - $a21 === $diff);
$a22 = (int)$input[2][2];
$result = $result && ($a02 - $a22 === $diff);

$diff = $a00 - $a01;
$result = $result && ($a10 - $a11 === $diff);
$result = $result && ($a20 - $a21 === $diff);

$diff = $a00 - $a02;
$result = $result && ($a10 - $a12 === $diff);
$result = $result && ($a20 - $a22 === $diff);

echo ($result)? 'Yes' : 'No';


Measured memory_bytes: 4856
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
#define int      long long int
#define MOD      1000000007
#define pb       push_back
#define pf		 push_front
#define vi       vector<int>
#define mi  	 map<int,int>
#define umi		 unordered_map<int,int>
#define pii      pair<int,int>
#define ff 		 first
#define ss 		 second
#define inf		 1e18
#define case	int t;cin>>t;while(t--)
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
void pre()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}
int dp[100003][102];
int32_t main()
{	pre();
	//case
	{	int n , k;
		cin >> n >> k;
		int a[n + 2], sm[n] = {0};
		for (int i = 1; i <= n; i++)
			cin >> a[i];

		for (int i = 0; i <= k; i++)
		{	for (int j = 0; j <= n; j++)
			{	if (i == 0)
				{	dp[i][j] = 1;
					continue;
				}
				if (j == 0)
				{dp[i][j] = 0; continue;}

				dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
				dp[i][j] %= MOD;
				if (i > a[j])
					dp[i][j] = (dp[i][j] - dp[i - a[j] - 1][j - 1] + MOD) % MOD;
			}
		}
		//	for (int i = 0; i <= k; i++)
		//	{	for (int j = 0; j < n; j++)
		//			cout << dp[i][j] << " ";
		//		cout << endl;
		//	}
		cout << dp[k][n];
	}
	return 0;
}


Measured memory_bytes: 80000
#include<bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false)
#define ll long long
ll a[600000], vs[600000], dp[3000][3000], fs[500][500];
map<int,int>mp;
string s , s1;
ll f(ll l, ll r)
{
    ll i, j, n, mn=LLONG_MAX, k;
    if(l==r) return a[l];
    if(dp[l][r]) return fs[l][r];
    for(i=l ; i<r ; i++){
        k = f(l,i)+f(i+1,r);
        j = dp[l][i]+dp[i+1][r]+k;
        if(j<mn){
            mn = j ; fs[l][r] = k;
        }
    }
    dp[l][r]=mn; return fs[l][r];
}
int main()
{
    IO;
    ll j=0, n, m, k, m1, m2, a1=0, a2=0, l  = 1, t=3, mn, cnt=0, mx=0, h=0, mod=1e8+7, i; int tc=0;
    //cin>>t;
    //while(t--){
        cin>>n;

        for(i = 1; i<=n; i++)
              cin>>a[i];

        j = f(1, n); cout<<dp[1][n]<<endl;

    //}
    return 0;
}



Measured memory_bytes: 14208
#include <algorithm>
#include <bitset>
#include <boost/multiprecision/cpp_int.hpp>
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <set>
#include <numeric>
#include <sstream>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
#include<iomanip>
namespace mp = boost::multiprecision;
using namespace std;
using ull = unsigned long long;
using ld = long double;
using lll = boost::multiprecision::cpp_int;
using ll = long long;
#define FOR(i, N) for(ll i = 0; i < N; ++i)

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
// using int = ll;
template <typename T>
T gcd(T m, T n) {
    if(n == 0)
        return abs(m);
    return (gcd(n, m % n));
}
void putYN(bool b) {
    if(b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}
ll combi(ll n, ll k) {
    ll r = 1, rr = 1;
    for(ll i = 0; i < k; ++i) {
        r *= (n - i);
        rr *= (i + 1);
        // r %= 1000000007;
        // rr %= 1000000007;
    }
    r /= rr;
    // r %= 1000000007;
    return r;
}
int main(){
  ll N,K;
  cin>>N>>K;
  ll ans=0;
  while(N!=0){
    ans++;
    N/=K;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>

using namespace std;

char a[10],b[10];

int main(){
	scanf("%s",a+1);
	scanf("%s",b+1);
	if(a[1] == b[3] && a[2] == b[2] && a[3] == b[1])printf("YES\n");
	else printf("NO\n");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> L(N);
  for (int i = 0; i < N; i++){
    cin >> L[i];
  }
  sort(L.begin(), L.end());
  int ans = 0;
  for (int i = 0; i < N; i++){
    for (int j = i + 1; j < N; j++){
      for (int k = j + 1; k < N; k++){
        if (L[k] < L[i] + L[j] && L[i] != L[j] && L[j] != L[k] && L[k] != L[i]){
          ans++;
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3576
n=int(input())
ab=[list(map(int,input().split())) for _ in range(n)]
ab.sort(key=lambda x:x[0])
# print(ab)
if n%2==0:
    min=ab[n//2-1][0]+ab[n//2][0]
else:
    min=ab[n//2][0]
ab.sort(key=lambda x:-x[1])
if n%2==0:
    max=ab[n//2-1][1]+ab[n//2][1]
else:
    max=ab[n//2][1]
print(max-min+1)


Measured memory_bytes: 120592
#include <cstdio>
#include <algorithm>
using namespace std;
int main(){
    int N, C, c, sum = 0, res;
    scanf("%d %d", &N, &C);
    for (int i = 0; i < C; i++) {
        scanf("%d", &c);
        sum+=c;
    }
    res = sum / (N+1), sum%=N+1;
    (sum > 0) ? printf("%d\n", res+1) : printf("%d\n", res);
    return 0;
}




Measured memory_bytes: 2760
#include <stdio.h>
long long int mem[200][40] = {0};
int num[200] = {0};
int n;
long long int ex(int a,int sum)
{
    if(sum > 20||sum < 0)return 0;
    if(a == n - 1&&sum == num[n - 1])return 1;
    if(a == n - 1)return 0;
    if(mem[a][sum] != 0)return mem[a][sum];
    mem[a][sum] = ex(a + 1,sum + num[a]) + ex(a + 1,sum - num [a]);
    return mem[a][sum];
}
int main()
{
    scanf("%d",&n);
    for(int i = 0; i < n; i++)
    {
        scanf("%d",&num[i]);
    }
    printf("%lld\n",ex(1,num[0]));
    return 0;
}

Measured memory_bytes: 1060
<?php
list($n,$k) = explode(" ", trim(fgets(STDIN)));
$ans = $n;
$check_array = array_fill(0, $n, false);
for($i=0; $i<$k; $i++){
    $d =  trim(fgets(STDIN));
    $nums = explode(" ", trim(fgets(STDIN)));
    foreach ($nums as $num) {
        if($check_array[$num-1] === false){
            $ans -=1;
            $check_array[$num-1] = true;
        }
    }
}
echo $ans . "\n";

Measured memory_bytes: 16100
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define REP(i, n) for(int i = 0; i < n; ++i)
using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

LLONG Kanade(const int n, const vector<LLONG> &cs,
	int &out_start, int &out_end)
{
	vector<LLONG> dp(n);
	vector<int> starts(n);
	dp[0] = cs[0];
	starts[0] = 0;
	for (int i = 1; i < n; ++i)
	{
		if (dp[i - 1] + cs[i] > cs[i])
		{
			dp[i] = dp[i - 1] + cs[i];
			starts[i] = starts[i - 1];
		}
		else
		{
			dp[i] = cs[i];
			starts[i] = i;
		}
	}
	auto itr = max_element(dp.begin(), dp.end());
	out_end = distance(dp.begin(), itr);
	out_start = starts[out_end];
	return *itr;
}

// 与えられた数列の部分和のうち，個数がlimit以下の最大値を返す
LLONG LimitedKanade(const int n, const vector<LLONG> &dcs, const int limit)
{
	vector<LLONG> sums(n);
	sums[0] = dcs[0];
	LLONG sum = dcs[0];
	for (int i = 1; i < n; ++i)
	{
		sum += dcs[i];
		sums[i] = sum;
	}

	LLONG ret = -1e15;
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < limit; ++j)
		{
			int end = min(i + j + 1, n - 1);
			ret = max(ret, sums[end] - sums[i]);
		}
	}
	return ret;
}

int main()
{
	int N, K; cin >> N >> K;
	vector<int> ps(N);
	vector<LLONG> cs(N);
	REP(i, N) { cin >> ps[i]; --ps[i]; }
	REP(i, N) cin >> cs[i];

	LLONG ans = -1e15;
	REP(i, N)
	{
		// iから始まるループを探索
		int size = 0;
		LLONG sum = 0;
		int v = i;
		do
		{
			++size;
			sum += cs[v];
			v = ps[v];
		} while (v != i);

		// ループの余り部分がiから始まる場合を探索
		LLONG rem = 0;
		int count = 0;
		do
		{
			++count;
			rem += cs[v];

			// 個数がKを超えたらそれ以上取れない
			if (count > K) break;

			// 繰り返し部分は一度に計算
			int num = (K - count) / size;
			ans = max(ans, rem + max(0LL, sum) * num);

			v = ps[v];

		} while (v != i);
	}
	cout << ans << endl;
}


Measured memory_bytes: 3716
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <math.h>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
const long long int mod=1e9+7;
int N;
int main()
{
   // freopen("in.txt","r",stdin);
    while(scanf("%d",&N)==1)
    {
        int x;
        long long int ans=1;
        int bad=0;
        for(int i=0;i<N;i++)
        {
            scanf("%d",&x);
            ans=(ans*(i+1-bad))%mod;
            if(x<(i-bad)*2+1)
                bad++;
        }
        printf("%I64d\n",ans);
    }


    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)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

int main() {
  long n;
  cin >> n;
  long a,b,c;
  rep2(j,n/4+1,n/2+1){  
    long ren=n*j/(4*j-n)+1;
    bool ex=false;
    rep2(i,ren,2*ren+1){
      if(n*j*i%((4*j-n)*i-n*j)==0){
        a=j;
        b=i;
        c=n*j*i/((4*j-n)*i-n*j);
        ex=true;
        break;
      }
    }
    if(ex){
      break;
    }
  }
  cout<<a<<" "<<b<<" "<<c<<endl;  
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
#define int long long 
#define pb push_back
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int,int>
 
const int MOD = 1e9+7;
const int N = 2e5+10;
int fact[N];
int ifact[N];
 
int mod_add(int a,int b)
{
    int sum = a+b;
    return (sum >= MOD) ? sum - MOD : sum;
}
 
int mod_sub(int a,int b)
{
    int diff = a-b;
    return diff < 0 ? diff+MOD : diff;
}
 
int mod_mul(int a,int b)
{
    return ((long long)a*b)%MOD;
}
 
int mod_pow(int a,int b)
{
    int res = 1;
    
    while(b)
    {
        if(b&1) res=mod_mul(res,a);
        a=mod_mul(a,a);
        b>>=1;
    }
    
    return res;
}
 
void pre()
{
    fact[0] = 1;
    for(int i=1;i<N;i++) fact[i] = mod_mul(fact[i-1],i);
    ifact[N-1] = mod_pow(fact[N-1],MOD-2);
    for(int i=N-2;i>=0;i--) ifact[i] = mod_mul(ifact[i+1],i+1);
    
}
 
int ncr(int n,int r)
{ 
    if(r>n) return 0;
    return mod_mul(fact[n],mod_mul(ifact[r],ifact[n-r]));
}
 
int store[3003];
 
int way(pii a,pii b)
{
 if(a.F > b.F || a.S > b.S) return 0;
 return ncr(b.F+b.S-(a.F+a.S),b.S-a.S);
}
 
signed main()
{
    fast;
    pre();
 
    int n,m,k;
    cin >> n >> m >> k;
 
    pii start = {1,1}, end ={n,m};
 
    pii go[k];
    f(i,k) cin >> go[i].F >> go[i].S;
 
    sort(go,go+k);
 
    int res = way(start,end);
 
    f(i,k)
    {
          store[i] = way(start,go[i]);
     
          f(j,i) 
              store[i] = mod_sub(store[i],mod_mul(store[j],way(go[j],go[i])));
 
           res = mod_sub(res,mod_mul(store[i],way(go[i],end)));
    }
 
    cout << res;
}

Measured memory_bytes: 3456
/*
  テ、ツスツ愿」ツつ凝」ツ?禿」ツ?ィテ」ツ?ョテ」ツ?ァテ」ツ?催」ツつ凝ヲツ閉エテヲツ閉ーテ」ツ?ョテヲツ閉ーテ」ツ?ッテヲツ慊?・ツ、ツァ 10P4 = 10*9*8*7 = 5040 テゥツ?堙」ツつ?
  テ」ツ?セテ」ツ?堙」ツδ?」ツδ姪」ツつ甘」ツつ津ィツ?ε」ツ?暗」ツ?堙」ツ?ォテ・ツ?催・ツクツーテ」ツ?ァテ・ツ?ィテゥツ?堙」ツつ甘、ツスツ愿」ツ?」テ」ツ?ヲテ」ツ?ソテ」ツつ凝」ツ??
  テ」ツ?敕」ツ?ョテゥツ堋崚」ツ?ォ,テヲツ鳴?・ツュツ療・ツ按療」ツつ津ヲツ閉エテヲツ閉ーテ・ツ楪凝」ツ?ォテ・ツ、ツ嘉ヲツ渉崚」ツ?ァテ」ツ?催」ツつ蟻toiテゥツ鳴「テヲツ閉ー(stdlib.hテ」ツつ津」ツつ、テ」ツδウテ」ツつッテ」ツδォテ」ツδシテ」ツδ?テ」ツ?古、ツセツソテ・ツ按ゥテ」ツ??
  テ・ツ?コテヲツ敖・テ、ツクツ甘」ツ?古」ツ?」テ」ツ?淌ヲツ閉ーテ・ツュツ療」ツ?ョテゥツ?催・ツ按療」ツつ津」ツつステ」ツδシテ」ツδ暗」ツ?療」ツ??ゥツ?催ィツ、ツ?」ツ?療」ツ?ヲテ」ツ??」ツつ凝」ツつづ」ツ?ョテ」ツつ津ゥツ卍、テ・ツ、ツ姪」ツ?療」ツ?ヲテヲツ閉ーテ」ツ?暗、ツクツ甘」ツ?津」ツつ凝」ツ??
 */

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

#define MAXN 11
#define SIZE 6000

int N, K;
char A[MAXN][10];
int used[MAXN];
char num[100];
int size;
int arr[SIZE];

void rec(int k) {
  int i;
  int length = strlen(num);
  if(k == K) {
    arr[size++] = atoi(num);
    return;
  }
  for(i = 0; i < N; ++i) {
    if(!used[i]) {
      used[i] = 1;
      strcat(num, A[i]);
      rec(k+1);
      used[i] = 0;
      num[length] = '\0';
    }
  }
}

void bubbleSort() {
  int i, j, t;
  for(i = 0; i < size; ++i) {
    for(j = 1; j < size-i; ++j) {
      if(arr[j-1] > arr[j]) {
        t = arr[j-1];
        arr[j-1] = arr[j];
        arr[j] = t;
      }
    }
  }
}

int main() {
  int i, ans;
  while(1) {
    scanf("%d", &N);
    scanf("%d", &K);
    if(N == 0 && K == 0) break;
    for(i = 0; i < N; ++i) {
      scanf("%s", A[i]);
    }

    for(i = 0; i < N; ++i) {
      used[i] = 0;
    }
    strcpy(num, "");
    size = 0;
    rec(0);
    bubbleSort();

    ans = 0;
    for(i = 0; i < size; ++i) {
      if(i == 0 || arr[i-1] != arr[i]) {
        ++ans;
      }
    }

    printf("%d\n", ans);
  }
  return 0;
}

Measured memory_bytes: 624
#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;
  int a[110];
  int count=0;
  rep(i,n) cin >> a[i];
  //rep(i,n) cout << a[i] << '\t';
  rep(i,n){
    if((i+1)%2==1){
      //cout << a[i]%2 << '\t';
      if(a[i]%2==1)
        count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

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

    if(s[2] == s[3] && s[4] == s[5]) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LOOP(val, times)   for(val = 0; val < (times); val++)
using namespace std;

int main(){
    int n,m,k,l;
    cin>>n>>m;
    vector<vector<int> >vec(n,vector<int>(m));
    vector<int> vec2(m);
    vector<int> ans(n);
    
        for(int i=0;i<n;++i){
        for(int j=0;j<m;++j){
            cin >>vec.at(i).at(j);
        }
        }
        
        for(int o=0;o<m;++o){
            cin >>vec2.at(o);
        }
    LOOP(k,n){
        
    LOOP(l,m){
    ans.at(k)+=vec.at(k).at(l)*vec2.at(l);
    }
        
    cout<<ans.at(k)<<endl;
    }
}


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

int main()
{
    int S;
    cin >> S;

    int s = S % 60;
    S /= 60;
    int m = S % 60;
    S /= 60;
    int h = S % 60;

    cout << h << ":" << m << ":" << s << endl;
}



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

int main(){
  int N;
  cin>>N;
  
 bool flag=false;
  
  int sum=0;
  
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      if(4*j+7*i==N){
        cout<<"Yes"<<endl;
        
        sum++;
        
        flag=true;
        break;
        
      }
    }
    if(flag){
      break;
    }
    
  }
  
  if(sum==0){
    cout<<"No"<<endl;
  }
}

  
  
      

Measured memory_bytes: 256
fun main(args : Array<String>) {
    val (h, w) = readLine()!!.split(" ").map { it.toInt() }
    val ss = Array(h) { readLine()!! }

    for (i in 0 until h) {
        inner@for (j in 0 until w) {
            val s = ss[i][j]
            if (s == '.') {
                continue@inner
            }

            if (j > 0 && ss[i][j-1] == '#') {
                continue@inner
            } else if (j < w-1 && ss[i][j+1] == '#') {
                continue@inner
            } else if (i > 0 && ss[i-1][j] == '#') {
                continue@inner
            } else if (i < h-1 && ss[i+1][j] == '#') {
                continue@inner
            }

            println("No")
            return
        }
    }

    println("Yes")
}

Measured memory_bytes: 37876
#include<bits/stdc++.h>
using namespace std;
int main(){
    unsigned long long n;
    cin >> n;
    auto v = vector<unsigned long long>(istream_iterator<unsigned long long>(cin),istream_iterator<unsigned long long>());
    
    auto _min =  *std::min_element(v.begin(),v.end());
    unsigned long long minits = ceil((double)n/(double)_min) + 4;
    cout << minits;
}


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

typedef struct task{
  long cost;
  long dead;
}task;

int compare(const void *a,const void *b){
  task *X = (task *)a;
  task *Y = (task *)b;
  long x = X->dead;
  long y = Y->dead;
  if(x > y){
    return 1;
  }else if(x < y){
    return -1;
  }else{
    return 0;
  }  
}

int main(){
  int N;
  scanf("%d",&N);
  task *T = (task *)malloc(sizeof(task)*N);
  for(int i=0;i<N;i++){
    scanf("%ld %ld", &T[i].cost, &T[i].dead);
  }
  qsort(T,N,sizeof(task),compare);
  
  long time = 0;
  int flag = 0;
  for(int j=0;j<N;j++){
    time += T[j].cost;
    if(time > T[j].dead){
      flag = 1;
      break;
    }
  }
  if(flag == 1){
    printf("No\n");
  }else if(flag == 0){
    printf("Yes\n");
  }
  return 0;
}

Measured memory_bytes: 6396
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
typedef vector<vector<P>> vvP;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll n, m, x;
    cin >> n >> m >> x;

    ll cnt = 0;
    rep(i, m) {
        ll a;
        cin >> a;
        if(a < x) {
            cnt++;
        }
        else {
            break;
        }
    }

    out(min(cnt, m - cnt));
    re0;
}

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

#define M 25000

int dp[2][101][M];

int main(){
  int n;
  while(cin>>n,n){
    int p[100],pp[100];
    for(int i=0;i<n;i++)scanf("%d",&p[i]),pp[i]=(1000-p[i]%1000)%1000;

    for(int i=0;i<2;i++)
      for(int j=0;j<=n;j++)
	for(int k=0;k<M;k++)dp[i][j][k]=1e9;
    
    dp[0][0][0]=0;

    for(int i=0;i<n;i++){
      int ni=(i+1)%2,I=i%2,mm=min(M,500*i+1);

      for(int j=0;j<=i;j++)
	for(int k=0;k<mm;k++)dp[ni][j][k]=1e9;
      
      for(int j=0;j<=i;j++)
	for(int k=0;k<mm;k++){
	  int np=k+pp[i];
	  int nj=j;
	  if(np>=500)nj++,np-=500;
	  np=min(M-1,np);
	  dp[ni][nj][np]=min(dp[ni][nj][np],dp[I][j][k]+p[i]);
	  dp[ni][j][k]=min(dp[ni][j][k],dp[I][j][k]);
	}
    }
    
    int c=0,s=0;
    for(int i=1;i<=n;i++)
      for(int j=0;j<M;j++)
	if(dp[n%2][i][j]!=1e9&&i>=c){
	  if(c==i&&dp[n%2][i][j]<s)s=dp[n%2][i][j];
	  else if(c<i)c=i,s=dp[n%2][i][j];
	}
    printf("%d %d\n",c,s);
  }
  return 0;
}

Measured memory_bytes: 22924
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys


def get_parent(index):
    return index // 2


def get_left(index):
    return 2 * index


def get_right(index):
    return get_left(index) + 1


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    array_length = int(_input[0])
    array = list(map(int, _input[1].split()))
    array.insert(0, None)
    for i in range(1, array_length + 1):
        parent, left, right = get_parent(i), get_left(i), get_right(i)
        print('node ' + str(i) + ': ', end='')
        print('key = ' + str(array[i]) + ',', end='')
        if parent:
            print(' parent key = ' + str(array[parent]) + ',', end='')
        if left <= array_length:
            print(' left key = ' + str(array[left]) + ',', end='')
        if right <= array_length:
            print(' right key = ' + str(array[right]) + ',', end='')
        print(' ')

Measured memory_bytes: 7872
#include<bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#define int long long
#define pb push_back
#define inf 1e9
#define mod 1000000007

const int maxn = 100010;
int n, arr[maxn], dp[maxn];

void solve()
{
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> arr[i];

	fill(dp, dp + maxn, inf);
	dp[1] = 0;
	for (int i = 1; i <= n; i++)
	{
		for (int j = i + 1; j <= i + 2; j++)
		{
			dp[j] = min(dp[j], dp[i] + abs(arr[i] - arr[j]));
		}
	}
	cout << dp[n];
}

int32_t main()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	solve();
	return 0;
}


Measured memory_bytes: 5168
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,K;
  cin>>N>>K;
  vector<int>L(N);
  for(int i=0;i<N;i++){
    cin>>L.at(i);
  }
  sort(L.begin(),L.end());
  reverse(L.begin(),L.end());
  int sum=0;
  for(int i=0;i<K;i++){
    sum=sum+L.at(i);
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
*B, = map(int, input().split())
*P, = map(int, input().split())
def solve(v):
    C = B[:]
    D = []
    for i in range(M):
        D += [(i & 1) ^ v]*P[i]
    res = 0
    for i in range(N):
        if C[i] != D[i]:
            for j in range(i, N):
                if D[i] == C[j]:
                    C[i], C[j] = C[j], C[i]
                    res += j - i
                    break
            else:
                return 10**9
    return res
print(min(solve(0), solve(1)))

Measured memory_bytes: 5600