akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>

#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;
typedef long long ll;

int main() {
    int n,k,m;
    while(cin >> n >> k >> m) {
        if(n == 0 && k == 0 && m == 0) break;

        bool used[10005];
        memset(used,0,sizeof(used));


        vector<int> v;
        rep(i,n) {
            v.push_back(i);
        }
        
        int id = m-1;
        v.erase(v.begin()+id);
        used[id] = true;

        while(v.size() != 1) {
            id += k-1;
            id %= v.size();

            used[v[id]] = true;
            v.erase(v.begin() + id);
        }

        cout << v[0]+1 << endl;
    }
    return 0;
}

Measured memory_bytes: 1340
#include<iostream>
int main()
{
	int h1 = -1, h2 = -1, h3 = -1;
	for(int i = 0; i < 10; i++)
	{
		int h;
		std::cin >> h;
		if(h > h1)
		{
			h3 = h2;
			h2 = h1;
			h1 = h;
		}
		else if(h > h2)
		{
			h3 = h2;
			h2 = h;
		}
		else if(h > h3)
		{
			h3 = h;
		}
	}
	std::cout << h1 << std::endl;
	std::cout << h2 << std::endl;
	std::cout << h3 << std::endl;
	return 0;
}


Measured memory_bytes: 3096
#include <iostream>

using namespace std;

int main() {
  int N, Y;

  cin >> N >> Y;

  for (int x = 0; x <= N; ++x) {
    for (int y = 0; y <= N - x; ++y) {
      const int z = N - x - y;
      if (10000 * x + 5000 * y + 1000 * z == Y) {
        printf("%d %d %d\n", x, y, z);
        return 0;
      }
    }
  }
  printf("-1 -1 -1\n");
  return 0;
}


Measured memory_bytes: 256
/*
  Vivek Rathi
  CSE 2nd Year
  MNNIT
*/
#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
#define ll long long int
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define present(c,x) ((c).find(x) != (c).end())
#define null NULL
#define mp make_pair
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define inf 1e17
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
ll n,h[100001],k;
ll dp[100001];
ll solve(ll i)
{
	if(i==n-1)
	{
		return 0;
	}
	if(dp[i]!=-1) return dp[i];
	vector<ll> v;
	for(ll j=i+1;j<n&&j<i+k+1;j++)
	{
		v.pb(abs(h[j]-h[i])+solve(j));
	}
	sort(v.begin(),v.end());
	return dp[i]=v[0];
}
int main()
{
	boost
	cin>>n>>k;
	memset(dp,-1,sizeof(dp));
	for(ll i=0;i<n;i++) cin>>h[i];
	cout<<solve(0)<<endl;
	return 0;
}

Measured memory_bytes: 12800
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RegularTriangle
{
    class Program
    {
        static void Main(string[] args)
        {
            var nums = Console.ReadLine().Split(' ').Select(item => int.Parse(item)).ToArray();
            Console.WriteLine((nums[0] == nums[1] && nums[1] == nums[2]) ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 11220
import math
def A():
    temp = [int(i) for i in input().split()]
    print(int(math.ceil(temp[0]/temp[1])))

def B():
    temp = [int(i) for i in input().split()]
    H = temp[0]
    N = temp[1]
    A = [int(i) for i in input().split()]
    if H <= sum(A):
        print('Yes')
    else:
        print('No')

def C():
    temp = [int(i) for i in input().split()]
    N = temp[0]
    K = temp[1]
    H = [int(i) for i in input().split()]
    if N <= K:
        print(0)
        return
    H.sort(reverse=True)
    print(sum(H[K:]))
    
C()

Measured memory_bytes: 27300
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>

using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(a) (a).begin(),(a).end()
#define PI 3.141592653589793238
#define INF 1050000000

using vi = vector<int>;


int main() {

	string S;

	cin >> S;

	REP(i, 3) {
		if (S[i] == S[i + 1]) {
			cout << "Bad" << endl;
			return 0;
		}
	}

	cout << "Good" << endl;

	

	return 0;
}

Measured memory_bytes: 256
package main

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

func solve() {
	x := getInt()

	ans := 0
	if x >= 2100 {
		ans = 1
	} else {
		a := x / 100
		b := x % 100
		if b <= 5*a {
			ans = 1
		}
	}
	fmt.Fprintln(wr, ans)
}

// -----------------------------------------

const (
	inf = 1 << 60
	// mod = 1000000007
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	// buf := 200001
	// sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

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

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

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

func getRunes() []rune {
	return []rune(getString())
}


Measured memory_bytes: 640
s = input()

cnt = 0
cnt_array = []
for i in s:
    if i == "A" or i == "G" or i == "C" or i == "T":
        cnt += 1
    else:
        cnt_array.append(cnt)
        cnt = 0
else:
    cnt_array.append(cnt)
    print(max(cnt_array))


Measured memory_bytes: 2940
import bisect
import copy
import heapq
import math
import sys
from collections import *
from itertools import accumulate, combinations, permutations, product
from math import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n=int(input())
s=[input() for i in range(n)]
# print(s)
lst=list(Counter(s))
print(len(lst))

Measured memory_bytes: 134416
//wawando's template

#include <iostream>
#include <string>
#include <fstream>
#include <functional>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <list>
#include <set>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>  //clock_t , clock() , CLOCKS_PER_SEC
#include <cstring>
#include <cctype>
#include <climits> // LLONG_MAX , LLONG_MIN , INT_MAX , INT_MIN

//MACROS
#define pb              push_back
#define mp              make_pair
#define INF             1000000000     //1 billion safer for floyd warshall, avoid overflow

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

int main() {
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	ios::sync_with_stdio(false); cin.tie(0);

  int W,H,x,y;
  scanf("%d %d %d %d", &W, &H, &x, &y);

  double area = ((double)W/2.0) * (double)H;
  printf("%.9lf ", area);
  if(W % 2 == 0 && x == (W/2) && H % 2 == 0 && y == (H/2))
    printf("1\n");
  else
    printf("0\n");
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    char s[100];
    char t[101];
    int i,j,count=0;
    scanf("%s",&s);
    scanf("%s",&t);
    int len = strlen(s);
    for(i=0,j=0; i<len; i++,j++)
    {
        if(s[i]==t[j])
            count++;
    }
    if(count==len)
        printf("Yes");
    else
        printf("No");
    return 0;
}


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

int main(){
    int N;
	cin >> N;
    vector<long long> A(N);
    for(int i=0; i<N; i++){
        cin >> A.at(i);
    }
    sort( A.begin(), A.end(), greater<int>() );

    long long comf=0;
    comf=A.at(0); 
    
    int i;
    for(i=1; i<N/2; i++){
        comf += 2*A.at(i);
    }
    if( N%2 == 1 ){
        comf += A.at(i);
    }
    cout << comf << endl;

}


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

int main(){
    string s;
    cin >> s;
    int ans = 0;
    if (s[0]  == 'o') ans++;
    if (s[1]  == 'o') ans++;
    if (s[2]  == 'o') ans++;
    cout << 700+ ans*100 << endl;
}

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

const int INF = 1001001001;

/*struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }*/

int main() {
    int n;
    cin >> n;
    vector<int> l(n);
    int maxn = 0;
    int ind = -1;
    rep(i, n) {
        cin >> l[i];
        if (maxn < l[i]) {
            ind = i;
            maxn = l[i];
        }
    }

    int sum = 0;
    for (int i = 0; i < n; i++) {
        if (i == ind) continue;
        sum += l[i];
    }

    if (sum > maxn)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#define rep(i,n) for (int i=0; i<n;++i)
#define rep_down(i,n) for (int i=n-1; i>=0;--i)
typedef long long ll;
using namespace std;

int main() {
  cin.sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  double x1,y1,x2,y2,x3,y3;
  cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
  double a = hypot(x1-x2,y1-y2);
  double b = hypot(x2-x3,y2-y3);
  double c = hypot(x3-x1,y3-y1);

  // ヘロンの公式
  double s = (a+b+c)/2;
  double area = sqrt(s*(s-a)*(s-b)*(s-c));

  //　内接円の半径
  double r = area/s;
  double mx = max(a, max(b,c));

  // 二分探索
  bool flag=true;
  double ans=0.0, ng = mx; 
  while(flag){
    double x = (ans+ng)/2.0;
    if (ng-ans<1e-10) flag=false;
    if (mx*(r-x) >= 2*x*r) ans=x;
    else ng=x;
  }
  cout << fixed << setprecision(10) << ans << "\n";
  return 0;
}

Measured memory_bytes: 256
/*
    問題をよく読もう！
    論理的に考えよう！
    サンプルを確認しよう!
    絶対に諦めるな！
    工夫をしろ！
    配列は少し多めにとっておく

    Twitterは終わるまでログアウト！
    （間違えて解法をツイートしてはいけないから）

*/
//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include<cstring>
//namespace
using namespace std;
//繰り返し
#define REP(i, m, n) for(int i=(int)m; i<(int)n; ++i)
#define rep(i, n) REP(i, 0, n)
//イテレータ
#define all_range(C) begin(C), end(C)
//簡略化
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
typedef pair<string,int> pst;

const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
//最大最小
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) {if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) {if(a<b) a=b;}

//関数

//最大公約数を求める
ll my_gcd(ll x, ll y) {
  ll r;

  while(y!=0) {
    r = x%y;
    x = y;
    y = r;
  }

  return x;
}

//最小公約数を求める
ll my_lcm(ll x, ll y) {

  return (x*y)/my_gcd(x,y);
}

//xのy乗を求める ※参考：10^18乗まで
ll my_pow(ll x, ll y) {
  ll sum = 1;

  while(y>0) {
    sum *= x;
    --y;
  }

  return sum;
}

/*考えを書くスペース


*/

//main.cpp----------------------------
#define MAX 100000

ll n, q;
string s;
ll l[MAX+1];
ll r[MAX+1];
ll a[MAX+1];

int main() {
  cin >> n >> q >> s;
  rep(i, q) cin >> l[i] >> r[i];

  ll num = 0;
  a[0] = 0;
  rep(i, n-1) {
    if(s[i]=='A'&&s[i+1]=='C') {
      ++num;
      a[i+1] = num;
    }
    else a[i+1] = num;
  }

  rep(i, q) {
    cout << a[r[i]-1]-a[l[i]-1] << endl;
  }

  return 0;
}


Measured memory_bytes: 3456
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#include <algorithm>
#include <functional>
#include <iterator>
#include <locale>
#include <memory>
#include <stdexcept>
#include <utility>
#include <string>
#include <fstream>
#include <ios>
#include <iostream>
#include <iosfwd>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <streambuf>
#include <complex>
#include <numeric>
#include <valarray>
#include <exception>
#include <limits>
#include <new>
#include <typeinfo>
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <climits>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdlib>
#include <cstddef>
#include <cstdarg>
#include <ctime>
#include <cstdio>
#include <cstring>
#include <cwchar>
#include <cwctype>
using namespace std;
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);
using ll = long long;
using ull = unsigned long long;

#define ALL(c) (c).begin(), (c).end()
#define CLEAR(v) memset(v,0,sizeof(v))
#define MP(a,b) make_pair((a),(b))
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ABS(a) ((a)>0?(a):-(a))
template<class T> T MIN(const T& a, const T& b) { return a < b ? a : b; }
template<class T> T MAX(const T& a, const T& b) { return a > b ? a : b; }
template<class T> void MIN_UPDATE(T& a, const T& b) { if (a > b) a = b; }
template<class T> void MAX_UPDATE(T& a, const T& b) { if (a < b) a = b; }

constexpr int mo = 1000000007;
int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

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

	int N, M;
	cin >> N >> M;
	vector<int> num_was(N + 1);
	vector<bool> aceds(N + 1);
	int num_acs = 0;
	int num_penalties = 0;
	REP(m, M) {
		int p;
		string S;
		cin >> p >> S;
		if (aceds[p]) {
			continue;
		}

		if (S == "AC") {
			++num_acs;
			num_penalties += num_was[p];
			aceds[p] = true;
		}
		else {
			++num_was[p];
		}
	}
	cout << num_acs << " " << num_penalties << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
 
using namespace std;
 
const int mod = 1e9 + 7;
 
int N;
vector< int > tree[100000];
int hashed[100000];
map< int, int > val;
long long ret;
 
int dfs(int idx, int par = -1)
{
  int hashed = 1;
  for(int to : tree[idx]) {
    if(to != par) (hashed += 1LL * dfs(to, idx) * 1003 % mod) %= mod;
  }
  ret += val[hashed]++;
  return(hashed);
}
 
int main()
{
  cin >> N;
  for(int i = 0; i < N - 1; i++) {
    int A, B;
    cin >> A >> B;
    --A, --B;
    tree[A].push_back(B);
    tree[B].push_back(A);
  }
  dfs(0, -1);
  cout << ret << endl;
}

Measured memory_bytes: 21052
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T iabs(const T& x) { return max(x, -x); }
// #define abs gabs

int main() {
    i64 h, n;
    cin >> h >> n;
    i64 sum = 0;
    for (int i = 0; i < n; ++i) {
        i64 a;
        cin >> a;
        sum += a;
    }
    cout << (sum >= h ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
#define Next( i, x ) for( register int i = head[x]; i; i = e[i].next )
#define rep( i, s, t ) for( register int i = (s); i <= (t); ++ i )
#define drep( i, s, t ) for( register int i = (t); i >= (s); -- i )
#define re register
#define int long long
int gi() {
	char cc = getchar() ; int cn = 0, flus = 1 ;
	while( cc < '0' || cc > '9' ) {  if( cc == '-' ) flus = - flus ; cc = getchar() ; }
	while( cc >= '0' && cc <= '9' )  cn = cn * 10 + cc - '0', cc = getchar() ;
	return cn * flus ;
}
const int N = 100 + 5 ; 
const int P = 1e9 + 7 ; 
int n, a[N], dp[N][N][N] ; 
signed main()
{
    n = gi() ; int m = 2 * n ; 
    for( re int i = 1; i < m; ++ i ) a[i] = gi() ; 
    sort( a + 1, a + m ) ;
    dp[n][0][0] = 1 ; 
    for( re int i = n - 1; i >= 1; -- i ) {
        int dl = ( a[i] != a[i + 1] ), dr = ( a[m - i] != a[m - i - 1] ) ;
        rep( l, 0, m ) {
            rep( r, 0, m ) {
                dp[i][l + dl][r + dr] = ( dp[i][l + dl][r + dr] + dp[i + 1][l][r] ) % P ; 
                for( re int k = 0; k < l + dl; ++ k )
                    dp[i][k][r + 1 + dr] = ( dp[i][k][r + 1 + dr] + dp[i + 1][l][r] ) % P ; 
                for( re int k = 0; k < r + dr; ++ k )
                    dp[i][l + 1 + dl][k] = ( dp[i][l + dl + 1][k] + dp[i + 1][l][r] ) % P ; 
            }
        }
    }
    int Ans = 0 ; 
    rep( l, 0, m ) rep( r, 0, m ) Ans = ( Ans + dp[1][l][r] ) % P ;
    cout << Ans << endl ; 
	return 0 ;
}

Measured memory_bytes: 6272
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner scan = new Scanner(System.in);

	int A = scan.nextInt();
	int B = scan.nextInt();
	int C = scan.nextInt();
	int D = scan.nextInt();

	int count = 0;
	if(A >= B){
	    count += B;
	}else{
	    count += A;
	}
	if(C >= D){
	    count += D;
	}else{
	    count += C;
	}

	System.out.println(count);
    }
}


Measured memory_bytes: 21716
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

using namespace std;

typedef long long ll;

const int INF = 1100000000;

int main(){
  int n, m; cin >> n >> m;
  vector<pair<int, int> > adj[n+1];
  for(int i=0;i<m;i++){
    int l, r, d; cin >> l >> r >> d;
    adj[l].push_back(make_pair(r, d));
    adj[r].push_back(make_pair(l, -d));
  }
  int d[n+1];
  for(int i=1;i<=n;i++) d[i]=INF;
  for(int s=1;s<=n;s++){
    if(d[s] != INF) continue;
    queue<int> Q;
    d[s]=0;
    Q.push(s);
    while(Q.empty()==false){
        int v=Q.front();
        Q.pop();
        for(int i=0;i<adj[v].size();i++){
          if(d[adj[v][i].first]!=INF){
            if(d[adj[v][i].first] != d[v]+adj[v][i].second){
              cout << "No" << endl;
              return 0;
            }
          }else{
            d[adj[v][i].first]=d[v]+adj[v][i].second;
            Q.push(adj[v][i].first);
          }
        }
        //cout << v << endl;
    }
  }
  cout << "Yes" << endl;
}

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

int main()
{
    ll H, W, K; cin >> H >> W >> K;
    vector<vector<ll>> c(H, vector<ll>(W, 0));
    rep(i,H) {
        string s; cin >> s;
        rep(j,W) {
            if (s[j] == '#') {
                c[i][j] = 1;
            }
        }
    }
    ll ans = 0;
    for (int i = 0; i < (1<<H); ++i) {
        vector<vector<ll>> tmp(H, vector<ll>(W, 0));
        tmp = c;
#if 0
        cout << "[1]" << endl;
        rep(ii,H) {
            rep(iii, W) {
                if (tmp[ii][iii] == 1) cout << 1;
                else cout << 0;
            }
            cout << endl;
        }
#endif
        for (int j = 0; j < H; ++j) {
            if ((i >> j) & 0x01) {
                for (int k = 0; k < W; ++k) tmp[j][k] = 0;
            }
        }
        for (int k = 0; k < (1<<W); ++k) {
            vector<vector<ll>> tmp2(H, vector<ll>(W, 0));
            tmp2 = tmp;
            for (int kk = 0; kk < W; ++kk) {
                if ((k >> kk) & 0x01) {
                    for (int kkk = 0; kkk < H; ++kkk) tmp2[kkk][kk] = 0;
                }
            }
#if 0
            cout << "[2]" << endl;
            rep(ii,H) {
                rep(iii, W) {
                    if (tmp2[ii][iii] == 1) cout << 1;
                    else cout << 0;
                }
                cout << endl;
            }
#endif
            ll cnt = 0;
            rep(ii,H) {
                rep(iii, W) {
                    if (tmp2[ii][iii] == 1) cnt++;
                }
            }
            if (cnt == K) ans++;
        }
    }
    cout << ans << endl;

    




}


Measured memory_bytes: 3616
n,w=map(int,input().split())
d={}
p=0
for i in range(n):
    a,b=map(int,input().split())
    if a in d: d[a].append(b)
    else: d[a]=[b]
    p=max(p,a)

for i in range(4):
    if p-i in d:d[p-i].sort(reverse=True)
    else: d[p-i]=[0]

l={}
for i in d:
    t=0
    l[i]=[0]
    for j in d[i]:
        t+=j
        l[i].append(t)
ans=0
for ai,i in enumerate(l[p]):
    for bj,j in enumerate(l[p-1]):
        for ck,k in enumerate(l[p-2]):
            for em,m in enumerate(l[p-3]):
                x=ai*p+bj*(p-1)+ck*(p-2)+em*(p-3)
                if x<=w:
                    ans=max(ans,i+j+k+m)
print(ans)


Measured memory_bytes: 43628
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,c=1,i=0;
    cin>>a;
    int b[a];
    for(int i=0;i<a;i++) cin>>b[i];
    while(1){
        c=b[c-1];
        i++;
        if(c==1){
            cout<<-1<<endl;
            return 0;
        }
        else if(c==2){
            cout<<i<<endl;
            return 0;
        }
        if(i>a){
            cout<<-1<<endl;
            return 0;
        }
    }
}


Measured memory_bytes: 640
//In the name of God
//SMani24
#include<bits/stdc++.h>
using namespace std;

long long a, b, k;

int main() {
	cin >> a >> b >> k;
	if (k <= a) 
		cout << a - k << " " << b << endl;
	else
		cout << 0 << " " << max(b - k + a, 0ll) << endl;
	return 0;
}


Measured memory_bytes: 256
s = list(input())
q = int(input())
Q = [list(input().split()) for i in range(q)]

A = [[], []] # 先頭、末尾
a = 0
for i in range(q):
    b = int(Q[i][0])
    if b == 1:
        a = (a+1) % 2
    else:
        f = int(Q[i][1])
        c = Q[i][2]
        A[(f-1+a)%2].append(c)
# print(A)

ANS = [A[0][i] for i in range(len(A[0])-1,-1,-1)] + s + [A[1][i] for i in range(len(A[1]))]
if a == 0:
    print("".join(ANS))
else:
    print("".join(ANS[::-1]))

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

int main() {
	string s;
	cin >> s;
	int sum = 0;
	for (int i = 0; i < s.size(); i++) {
		sum = (sum + (s[i] - '0')) % 9;
	}
	if (sum == 0) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3368
#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define gc getchar_unlocked
#define cases int t;  cin>>t;   while(t--)
ll mod =1e9+7;
//template<typename T> 
inline ll pwr(ll base,ll n){ll ans=1;while(n>0){ if(n%2==1)ans=ans*base;  base=base*base; n/=2;} return ans;}
struct range{int l,h;};
using namespace std;
int main()
{
ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    int n;
    cin>>n;

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

    int ans=a[0];

    for(int i=0;i<n-2;i++)
    {
      if(a[i]<=a[i+1])
        ans+=a[i];
      else 
        ans+=a[i+1];
    }

    ans+=a[n-2];
    
    cout<<ans;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijoMOD(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=yakusu[i];
  }
  return num;
}

int H,W;
vs s(50);
vi dv ={-1,0,1,0};vi du={0,-1,0,1};
int cnt=1;
int dfs(int u,int v){
  s[u][v]='.';
  
  rep(i,4){
   
      int nu =u +du[i],nv=v+dv[i];
      if(nu<0||nu>=H||nv<0||nv>=W)continue;
      if(s[nu][nv]=='.')continue;
      cnt ++;
      dfs(nu,nv);
    
  }
  return cnt;

}
int keta_wa(int x){
  int tot=0;
  while(x>0){
    tot +=x%10;
    x/=10;
  }
  return tot;
}

//vc alp ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//cout<<""<<endl;
int main(){
  string A,B;cin>>A>>B;
  vc a(A.size()),b(B.size());
  rep(i,A.size())a[i]=A[i];
  rep(i,B.size())b[i]=B[i];
  if(A.size()>B.size()){
    cout<<"GREATER"<<endl;    
  }
  else if(A.size()<B.size()){
    cout<<"LESS"<<endl;
  }
  else{
    if(A==B)cout<<"EQUAL"<<endl;
    else{
      rep(i,A.size()){
       if(a[i]-'0'==b[i]-'0' ){
        continue;
       }
       if(a[i]-'0'>b[i]-'0' ){
        
         cout<<"GREATER"<<endl;
         break;
        
       }
       else if(a[i]-'0'<b[i]-'0' ){
         
         cout<<"LESS"<<endl;
         break;
       }
      }
    }
  }
    
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s,t;
    cin>>s>>t;
    int ans=0;
    for(int i=0;i<s.size();i++)
    {
        ans+=(s[i]!=t[i]);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3884
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int n;
    cin>>n;
    vector<int> a(n);
    int cnt=0;
    rep(i,n) cin>>a[i];
    rep(i,n){
        if(a[i]==i+1){
            swap(a[i],a[i+1]);
            cnt++;
        }
    }
    cout<<cnt;
}

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

int main(void)
{
	int i, k = 0, t = 0, len;
	char s[100000];

	s[0] = '\0';

	scanf("%s", s);
	//printf("%s", s);

	len = strlen(s);

	for(i=0; i < len; i+=2){
		if(s[i] != '0') k++;
		
		if(s[i+1] != '1' && s[i+1] != '\0') k++;
		//printf("%d", k);
	}
	
	for(i=0; i < len; i+=2){
		if(s[i] != '1') t++;
		if(s[i+1] != '0' && s[i+1] != '\0') t++;
	}

	if(k <= t){
		printf("%d", k);
	} else{
		printf("%d", t);
	}
	



	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main (){
    int P,Q,R,AB,BC,CA;
    scanf("%d%d%d",&P,&Q,&R);
 
    AB=P+Q;
    BC=Q+R;
    CA=R+P;
 
    if (AB<=BC && AB<=CA){
        printf("%d\n",AB);
    }else if (BC<=AB && BC<= CA){
        printf("%d\n",BC);
    }else if (CA<=BC && CA<= AB){
        printf("%d\n",CA);
    }
}

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

int main() {
    int n;
    cin >> n;
    n %= 10;
    if(n == 2||n == 4||n==5||n==7||n==9){
        cout << "hon" << endl;
    } else if(n==0||n==1||n==6||n==8){
        cout << "pon" << endl;
    } else {
        cout << "bon" << endl;
    }
    return 0;
}


Measured memory_bytes: 3624
import java.util.Scanner;
public class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int n,m;
        StringBuilder sb = new StringBuilder();
        String s;
        StringBuilder temp = new StringBuilder();
        while(true)
        {
            s= sc.next();
            if(s.compareTo("-")==0) break;
            else
            {
              m = sc.nextInt();
              for(int i = 0; i<m;i++)
              {
                  temp = temp.delete(0, temp.length());
                  n = sc.nextInt();
                  temp = temp.append(s);
                   s = s.substring(n);
                  if(n!=temp.length()) temp.delete(n,temp.length()+1);
                  s = s.concat(temp.toString());
              }
              System.out.println(s);
            }
        }
    }
}


Measured memory_bytes: 26156
#![allow(non_snake_case, unused_imports)]

// Input
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($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) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $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, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,BTreeMap,VecDeque};

// Functions

// Main
fn main(){
    input!{
        S: chars,
    }
    let len = S.len();
    println!("{}", if (S[0]==S[len-1]) ^ (len%2==0){"Second"}else{"First"});
}

Measured memory_bytes: 4352
#include <stdio.h>

int main()
{
	int A, B, C, X;
	scanf("%d", &A);
	scanf("%d", &B);
	scanf("%d", &C);
	scanf("%d", &X);
	X /= 50;

	int i, j, k, count = 0;
	for (i = 0; i <= A; i++) {
		for (j = 0; j <= B; j++) {
			for (k = 0; k <= C; k++) {
				if (10 * i + 2 * j + k == X) count++;
			}
		}
	}
	
	printf("%d\n", count);
	fflush(stdout);
	return 0;
}

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

int main(){
  int n,m; cin >> n >> m;
  int u=1; int l=n;
  rep(i,m){
    int U,L; cin >> U >> L;
    u=(u<U) ? U : u; l=(l>L) ? L : l;
  }
  int ans=l-u+1;
  if(ans<1) ans=0;
  cout << ans << endl;
 return 0;
}


Measured memory_bytes: 256
h = int(input())
w = int(input())
n = int(input())

if h > w:
    if n % h == 0:
        print(n // h)
    else:
        print(n // h + 1)
else:
    if n % w == 0:
        print(n // w)
    else:
        print(n // w + 1)

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

#define rep(i, N) for (ll i = 0; i < N; i++)

#define INF 1000000000
#define MOD 1000000007

using ll = long long;
using namespace std;

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

int main() {
    int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
    int H, W;
    cin >> H >> W;
    int sx = 0, sy = 0, gy = H-1, gx = W-1, ans = 0;

    //cin >> sy >> sx;
    //cin >> gy >> gx;
    vector<vi> a(H,vi(W,INF));  //スタート位置からの距離
    vector<string> c(H); //迷路の形状
    queue<P> que;   //探索予定の座標

    rep(i, H){
        cin >> c[i];

        //スタート位置の移動距離距離を0に設定
        rep(j,W){
            if(c[i][j] == '#') {
                a[i][j] = 0;
                que.push(P(i,j));
            }
        }
    }
        
    while(!que.empty()) {
        //現在地の取得
        P cgr = que.front(); que.pop();
        int cx = cgr.second;
        int cy = cgr.first;

         rep(i, 4){
            //チェックする座標の取得
            int chx = cx + dx[i];
            int chy = cy + dy[i];

            //チェックする座標が範囲内
            if(chx >= 0 && chx < W && chy >= 0 && chy < H){
                //チェックする座標が通れる かつ　未探索
                if(a[chy][chx] > a[cy][cx] + 1) {
                    a[chy][chx] = a[cy][cx] + 1;
                    que.push(P(chy, chx));
                }
            }
        }
    }

    rep(i,H)
        rep(j,W)
            ans = max(ans,a[i][j]);

    cout << ans << "\n";
    return 0;
    
}


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

using namespace std;

const int N = 2010;

int n, k;
int dist[N][N];
vector<int> g[N];
int x[N], y[N];

void dfs(int v, int p, int st, int d) {
  dist[st][v] = d;
  for (auto& u : g[v]) {
    if (u == p) {
      continue;
    }
    dfs(u, v, st, d + 1);
  }
}

int main() {
  scanf("%d %d", &n, &k);
  for (int i = 0; i < n - 1; i++) {
    int xx, yy;
    scanf("%d %d", &xx, &yy);
    xx--; yy--;
    g[xx].push_back(yy);
    g[yy].push_back(xx);
    x[i] = xx;
    y[i] = yy;
  }
  for (int st = 0; st < n; st++) {
    dfs(st, -1, st, 0);
  }
  int best = n;
  {
    for (int st = 0; st < n; st++) {
      int cnt = 0;
      for (int i = 0; i < n; i++) {
        cnt += (2 * dist[st][i] > k);
      }
      best = min(best, cnt);
    }
  }
  {
    for (int i = 0; i < n - 1; i++) {
      int xi = x[i];
      int yi = y[i];
      int cnt = 0;
      for (int j = 0; j < n; j++) {
        cnt += (2 * min(dist[xi][j], dist[yi][j]) + 1 > k); 
      }
      best = min(best, cnt);
    }
  }
  printf("%d\n", best);
  return 0;
}


Measured memory_bytes: 16256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P  = pair <int, int>;

#define rep(i, n)     for (int i = 0; i < (int) (n); i++)
#define repr(i, a, b) for (int i = a; i < b; i++)
#define each(i, mp)   for (auto &i : mp)

const int INF = 1001001001;

int main()
{
  int n;
  cin >> n;
  vector <int> a(n + 2);
  rep(i, n) cin >> a[i];

  ll ans = 0;
  ll max = a[0];
  rep(i, n - 1) {
    if (max > a[i + 1]) {
      ans += max - a[i + 1];
    }
    else {
      max = a[i + 1];
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3980
import java.util.Scanner;

class Main{
  public static void main(String[] args) {
    
	  Scanner sc = new Scanner(System.in);
	  
	  int hourS = sc.nextInt();
	  
	  int h = hourS / 3600;
	  int m = hourS % 3600 / 60;
	  int s = hourS % 60;
	  
	 
	  
	  System.out.println(h+":"+m+":"+s);
	 
	  
  }
}

Measured memory_bytes: 26324
#include <vector> 
#include <iostream>
using namespace std;
int main() {
	vector<int> vc;
    int l, r, d, num;
	cin >> l >> r >> d;
  	num = 1;
    for(int i = 1; i < 101; i++){
       num =  d * i;
       if(num >= l && num <= r)vc.push_back(num);  
       if(num > r) break;
    }
    cout << vc.size() << endl;
    return 0;
}

Measured memory_bytes: 3588
A = int(input())
B = int(input())
C = int(input())
X = int(input())
dp = [0 for i in range(1010)]
dp[0] = 1
for i in range(1000, -1, -1):
    if(dp[i] > 0):
        for j in range(1, C + 1):
            dp[i + 1 * j] += dp[i]
for i in range(1000, -1, -1):
    if(dp[i] > 0):
        for j in range(1, B + 1):
            dp[i + 2 * j] += dp[i]
for i in range(1000, -1, -1):
    if(dp[i] > 0):
        for j in range(1, A + 1):
            dp[i + 10 * j] += dp[i]
print(dp[X // 50])

Measured memory_bytes: 3064
"use strict";

const main = arg => {
  const input = arg.trim().split("\n");
  const num = parseInt(input[0]);
  const resFunc = x => (x === 0) ? console.log(1) : console.log(0);
  resFunc(num);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));  

Measured memory_bytes: 29668
import java.lang.StringBuilder

fun main(arr:Array<String>) {
    val (a,b,k) = readLine()!!.split(" ").map { it.toLong() }
    val list = (a..Math.min(a+k-1,b)).union((Math.max(b-k+1, a)..b))
    val ans = StringBuilder()
    list.forEach{ans.appendln(it)}
    print(ans.toString())

}


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

const int INF = 1e9+7;

int main() {
    int N,K,i,m=INF;
    cin >> N >> K;
    vector<int> h(N);

    for(i=0; i<N; i++)
        cin >> h.at(i);
    sort(h.begin(), h.end());

    for(i=0; i<=N-K; i++)
        m = min(m, h.at(i+K-1)-h.at(i));

    cout << m << endl;
}

Measured memory_bytes: 640
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a = II()
    ans = 0
    for i in range(a + 1):
        ans += i
    print(ans)
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    A()


Measured memory_bytes: 38512
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

int n;

int main() {
#ifndef ONLINE_JUDGE
    freopen("D:/MYCODE/vsCode-c/test.in", "r", stdin);
    freopen("D:/MYCODE/vsCode-c/test.out", "w", stdout);
#endif
    scanf("%d", &n);
    int ans = 0;
    for (int i = 1; i < n; i++) {
        ans += (n / i);
        if (n % i == 0) ans--;
    }
    printf("%d", ans);
    return 0;
}

Measured memory_bytes: 3232
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <cmath>
#include <set>

#define lowbit(x) (x&(-x))
#define MAX(a,b) (a<b?b:a)
#define MIN(a,b) (a<b?a:b)
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
const int N = 1e7;
const int maxn = 2e3 + 5;
ll mod = 1e9 + 7;

struct Edge
{
	int u, v, nxt;
	ll w;

	Edge(int _u = 0, int _v = 0, ll _w = 0, int _nxt = -1)
	{
		u = _u;
		v = _v;
		w = _w;
		nxt = _nxt;
	}
};

int cmp(const Edge &a, const Edge &b)
{
	return a.w < b.w;
}

int n, m;
ll x;
Edge edg[maxn];
int vis[maxn];

Edge tree[maxn];
int g[maxn], ecnt;
int dep[maxn], fa[maxn];
ll val[maxn], d[maxn];

int p[maxn];
int find(int u)
{
	return u == p[u] ? u : p[u] = find(p[u]);
}
void merge(int u, int v)
{
	u = find(u); v = find(v);
	if (u^v) p[u] = v;
}
ll kruskal(int n)
{
	for (int i = 1; i <= n; i++) p[i] = i;

	int cnt = 0; ll sum = 0;
	for (int i = 0; i < m; i++)
	{
		int u = edg[i].u, v = edg[i].v;
		if (find(u) ^ find(v))
		{
			vis[i] = 1;
			merge(u, v);
			++cnt;
			sum += edg[i].w;
			tree[++ecnt] = edg[i]; tree[ecnt].nxt = g[u]; g[u] = ecnt;
			tree[++ecnt] = edg[i]; tree[ecnt].nxt = g[v]; g[v] = ecnt; swap(tree[ecnt].u, tree[ecnt].v);
		}
	}

	return cnt == n - 1 ? sum : 0;
}

ll ss(ll a, ll b)
{
	ll ans = 1;
	while (b)
	{
		if (b & 1) (ans *= a) %= mod;
		(a *= a) %= mod;
		b >>= 1;
	}
	return ans;
}

void dfs(int u)
{
	for (int i = g[u]; ~i; i = tree[i].nxt)
	{
		int &v = tree[i].v;
		if (v != fa[u])
		{
			dep[v] = dep[u] + 1;
			fa[v] = u;
			val[v] = tree[i].w;
			dfs(v);
		}
	}
}

ll query(int u, int v)
{
	ll maxv = 0;
	while (u != v)
	{
		if (dep[u] < dep[v]) swap(u, v);
		maxv = MAX(maxv, val[u]);
		u = fa[u];
	}
	return maxv;
}

int main()
{
	scanf("%d%d%lld", &n, &m, &x);
	memset(g, ecnt = -1, sizeof(g));
	for (int i = 0; i < m; i++)
	{
		scanf("%d%d%lld", &edg[i].u, &edg[i].v, &edg[i].w);
	}
	sort(edg, edg + m, cmp);
	
	ll sum = 0;
	if (sum=kruskal(n))
	{
		sum = x - sum;
		if (sum < 0) printf("0");
		else
		{
			dep[1] = 1; dfs(1);

			int cnt1 = 0, cnt2 = 0;
			for (int i = 0; i < m; i++) if(!vis[i])
			{
				d[i] = edg[i].w - query(edg[i].u, edg[i].v);
				if (d[i]==sum) ++cnt1;
				else if (d[i] > sum) ++cnt2;
			}

			ll ans1 = (ss(2, n - 1) - 2 + mod)*ss(2, m - n + 1) % mod,
				ans2 = 2 * (ss(2, cnt1) - 1)*ss(2, cnt2) % mod;
			if (sum == 0) printf("%lld", (ans1 + ans2) % mod);
			else printf("%lld", ans2);
		}
	}
	else printf("0");
}

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

const int N = 505;

int n;
char a[N][N];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> (a[i] + 1);
	}
	int full_col = 0;
	vector<bool> can (n + 1, false);
	for (int i = 1; i <= n; i++) {
		bool isfull = true;
		for (int j = 1; j <= n; j++) {
			isfull = isfull && a[j][i] == '#';
			if (a[i][j] == '#') {
				can[j] = true;
			}
		}
		full_col += 1 - isfull;
	}
	int ans = 142857;
	for (int i = 1; i <= n; i++) {
		int cnt = 0;
		for (int j = 1; j <= n; j++) {
			cnt += a[i][j] == '.';
		}
		if (can[i] || !cnt) {
			ans = min(ans, cnt);
		} else if (cnt < n) {
			ans = min(ans, cnt + 1);
		}
	}
	if (ans == 142857) {
		cout << "-1" << '\n';
	} else {
		cout << ans + full_col << '\n';
	}
	return 0;
}


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

int n,m;
int dp[2000][20];
vector<int> pv;

int main(){
  for(int i=2;i<=1120;i++){
    bool f = true;
    for(int j=2;j*j<=i;j++){
      if(i%j==0){
	f = false;
	break;
      }
    }
    if(f)pv.push_back(i);
  }

  for(int i=0;i<=1120;i++)
    for(int j=0;j<=14;j++)dp[i][j] = 0;
  dp[0][0] = 1;

  for(int k=0;k<pv.size();k++){
    for(int i=1120;i>=0;i--){
      for(int j=13;j>=0;j--){
	if(i+pv[k]<=1120)dp[i+pv[k]][j+1] += dp[i][j];
      }
    }
  }

  while(cin >> n >> m,n||m){
    cout << dp[n][m] << endl;
  }
}

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

int A, B;

int main() {
    cin >> A >> B;
    if ((A + B) % 2 == 0) {
        printf("%d\n", (A + B) / 2);
    } else {
        printf("IMPOSSIBLE\n");
    }
}

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

#define int long long

int n, a, x[51], dp[51][51][2501]; // i番目までで、カードをj枚選んで合計をkにできる組み合わせの数
int ans;

signed main() {
    cin >> n >> a;
    for (int i = 0; i < n; ++i) cin >> x[i];

    dp[0][0][0] = 1;

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j <= i; ++j) {
            for (int k = 0; k <= n * a; ++k) {
                dp[i + 1][j + 1][k + x[i]] += dp[i][j][k];
                dp[i + 1][j][k] += dp[i][j][k];
            }
        }
    }

    for (int i = 1; i <= n; ++i) {
        ans += dp[n][i][i * a];
    }

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

Measured memory_bytes: 49152
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

	int a, b;
	cin >> a >> b;
	cout << (a-1)*(b-1) << endl;
	
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

#define mem(a, b) memset(a, b, sizeof(a))
#define MOD 1000000007
#define MAX (int) 1e9
#define PI 3.141592653589793238462643383279502884

template <typename T, typename U>
T max(T x, U y) {
    return x > y ? x : y;
}

template <typename T, typename U>
T min(T x, U y) {
    return x < y ? x : y;
}

template<typename T>
void debug(string msg, T t) {
	cout << msg << ": " << t << "\n";
}

template<typename T>
T abs(T a, T b) {
	return a > b ? a - b : b - a;
}


int toDigit(char c) { return c - '0'; }

int n, m, bookA, bookB, ans;
ll a[200000], b[200000], k, sumA, sumB;

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0); 

	cin >> n >> m >> k;

	for(int i = 0; i < n; i++) { cin >> a[i]; }
	for(int i = 0; i < m; i++) { cin >> b[i]; }
	
	for(int i = 0; i < n && sumA + a[i] <= k; i++) {
		sumA += a[i];
		bookA++;
	}

	for(int i = bookA; i >= 0; i--) { // num books from stack A
		// fit as many books from b as possible
		while(sumA + sumB + b[bookB] <= k && bookB < m) {
			sumB += b[bookB];
			bookB++;
		}

		ans = max(ans, i + bookB);
		sumA -= a[i - 1];

	}

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 6700
package main

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

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

var sc = bufio.NewScanner(os.Stdin)

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

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

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

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

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

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

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

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

func main() {
	sc.Split(bufio.ScanWords)
	A, B, H, M := float64(getInt()),
		float64(getInt()),
		float64(getInt()),
		float64(getInt())

	H = H + M/60
	// out(math.Pi * H / 6)
	H = (H * math.Pi) / 6
	x0 := A * math.Cos(H)
	y0 := A * math.Sin(H)

	M = M * math.Pi / 30
	x1 := B * math.Cos(M)
	y1 := B * math.Sin(M)
	// out(math.Sqrt(x0*x0 + y0*y0))
	// out(math.Sqrt(x1*x1 + y1*y1))

	dx := x0 - x1
	dy := y0 - y1
	l := math.Sqrt(dx*dx + dy*dy)
	// out(x0, y0, x1, y1)
	out(l)
}


Measured memory_bytes: 1756
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10**9)

N,H = I()
A = []
B = []
for i in range(N):
    a,b = I()
    A.append(a)
    B.append(b)
B.sort(reverse=True)
huru = max(A)
cnt = 0
for i in range(N):
    if B[i] < huru:
        break
    H -= B[i]
    cnt += 1
    if H <= 0:
        print(cnt)
        exit()
print(cnt+math.ceil(H/huru))

Measured memory_bytes: 88636