akhauriyash/Code-Regression huggingface dataset:
import java.io.*;

class Main {
	public static void main(String[] args) {
		BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) );
		try {
			String str = kb.readLine();
			int n = Integer.parseInt( str );
			
			int[][][] oHouse= new int[5][4][11];
			int[] tnum= new int[5];
			String[] tmpArray;
			for( int i=0; i<n; i++ ) {
				str = kb.readLine();
				tmpArray = str.split( " " );
				for( int j=0; j<4; j++ ) {
					tnum[j]=Integer.parseInt( tmpArray[j] );
				}
				oHouse[ tnum[0]-1 ][ tnum[1]-1 ][ tnum[2]-1 ] += tnum[3];
			}
			for( int i=0; i<4; i++ ) {
				for( int j=0; j<3; j++ ) {
					for( int k=0; k<10; k++ ) {
						System.out.print( " " + oHouse[i][j][k] );	
					}
					System.out.print( "\n" );	
				}
				if( 3 != i ) {
					System.out.println( "####################" );	
				}
			}
		} catch( IOException e ) {
			System.err.println( e );
		}
	}
}

Measured memory_bytes: 19332
#include <stdio.h>
#define MAX 500000

void swap(int, int);
int parent(int);
int left(int);
int right(int);
void maxHeapify(int);
void buildMaxHeap();

int n;
int A[MAX];

int main()
{
  int i;

  scanf("%d", &n);
  for(i = 1; i <= n; i++)
    {
      scanf("%d", &A[i]);
    }

  buildMaxHeap();

  for(i = 1; i <= n; i++)
    {
      printf(" %d", A[i]);
    }
  printf("\n");

  return 0;
}

void swap(int i1, int i2)
{
  int tmp;

  tmp = A[i1];
  A[i1] = A[i2];
  A[i2] = tmp;
}

int parent(int i)
{
  return i / 2;
}

int left(int i)
{
  return 2 * i;
}

int right(int i)
{
  return 2 * i + 1;
}

void maxHeapify(int i)
{
  int l, r;
  int largest;

  l = left(i);
  r = right(i);

  largest = i;
  if(l <= n && A[l] > A[largest])
    largest = l;
  if(r <= n && A[r] > A[largest])
    largest = r;

  if(largest != i)
    {
      swap(i, largest);
      maxHeapify(largest);
    }
}

void buildMaxHeap()
{
  int i;

  for(i = n/2; i >= 1; i--)
    {
      maxHeapify(i);
    }
}

Measured memory_bytes: 2552
N,M = map(int, input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]
for i in range(N-M+1):
    for j in range(N-M+1):
        ok = True
        for k in range(M):
            if A[i+k][j:j+M] != B[k]:
                ok = False
                break
        if ok:
            print("Yes")
            exit()
print("No")

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<queue>
#include<functional>
#include<iso646.h>
#include<bitset>

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;

const ll INF = 1e15;
const ll MOD = 1e9 + 7;

int main() {
	ll i, j;
	ll N;
	cin >> N;
	vll d(N);
	for (auto &e : d)cin >> e;
	ll ans = 0;
	for (i = 0; i < N - 1; i++) {
		for (j = i + 1; j < N; j++) {
			ans += d[i] * d[j];
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define input(x) istream_iterator<x>(cin)
#define output(x, s) ostream_iterator<x>(cout, s)

const ll N = 50;
const char nl = '\n';

ll n, m, q;
ll a[N], b[N], c[N], d[N];

vector<ll> aseq;

ll score() {
    // cout << "i hav sekvens: ";
    // copy_n(aseq.begin(), aseq.size(), output(ll, " "));
    // cout << nl;
    ll sc = 0;
    for (ll i = 0; i < q; i++) {
        if (aseq[b[i]] - aseq[a[i]] == c[i]) sc += d[i];
    }
    // cout << "\tscore " << sc << nl;
    return sc;
}

ll haku(ll i = 0) {
    if (i == n) {
        return score();
    }
    ll top = aseq.empty() ? 1 : aseq.back();
    ll ans = 0;
    for (ll num = top; num <= m; num++) {
        aseq.push_back(num);
        ans = max(ans, haku(i + 1));
        aseq.pop_back();
    }
    return ans;
}

int main() {
    cin >> n >> m >> q;
    for (ll i = 0; i < q; i++) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        b[i]--; a[i]--;
    }
    cout << haku() << nl;
    return 0;
}



Measured memory_bytes: 3636
#include <algorithm>
#include <cstdio>

using namespace std;

typedef unsigned long long ll;

ll gcd(ll a, ll b) {
	if(a < b) {
		ll tmp = a;
		a = b;
		b = tmp;
	}

	ll r = a % b;
	while(r != 0) {
		a = b;
		b = r;
		r = a % b;
	}

	return b;
}

ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

int main(void) {
	ll a, b;
	ll c, d;
	scanf("%llu %llu %llu %llu", &a, &b, &c, &d);

	ll began = a - 1;
	ll end = b;

	ll dc = end / c - began / c;
	ll dd = end / d - began / d;
	ll dlcm = end / lcm(c, d) - began / lcm(c, d);

	// printf("dc:%lld dd:%lld dlcm:%lld\n", dc, dd, dlcm);

	printf("%llu\n", (end - began) - (dc + dd - dlcm));

	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int main(){
  char moji;
  
  while(1){
    scanf("%c",&moji);
    
    if(moji>=65 && moji<=90) moji+=32;
    else if(moji>=97 && moji<=122) moji-=32;
    printf("%c",moji);
    if(moji==10) break;
  }
  
  return 0;
}



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

#define ALL(obj) (obj).begin(), (obj).end()
#define rep(i,n) for(int i=0; i<n; i++)
#define rep2(i,a,b) for(int i=a; i<=b; i++)
using ll = long long;
#define pb push_back

typedef vector<int> VI;
typedef vector<ll> VL;
const double pi = acos(-1.0);
typedef complex<double> Comp;

int main()
{
  int N;
  cin >> N;
  int dp[100001];
  dp[1] = 1;
  for (int i=2; i<=100000; i++) {

    dp[i] = dp[i-1] + 1;

    int j=1;
    while ((i-j)>=0) {
      dp[i] = min(dp[i], 
          dp[i-j]+1);
      j *= 6;
    }

                    
  }
  for (int i=2; i<=100000; i++) {

    int j=1;
    while ((i-j)>=0) {
      dp[i] = min(dp[i], 
          dp[i-j]+1);
      j *= 9;
    }

                    
  }
  cout << dp[N] << endl;
}

Measured memory_bytes: 640
import math
N,H = map(int,input().split())

aList = []
bList = []
for count in range(0,N):
    a,b = map(int, input().split())
    aList.append(a)
    bList.append(b)

bList.sort()
bList.reverse()

maxA = max(aList)

count = 0
damage = 0
for b in bList:
    if maxA < b:
        damage+=b
        count+=1
    if damage >= H:
        break

if damage < H:
    remainingHP = H - damage
    count = count + math.ceil(remainingHP / maxA)

print(count)

Measured memory_bytes: 11264
#include<bits/stdc++.h>
#define tmp(x) std::cout<<"& "<<(x)<<" &\n"
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
typedef long long ll;
using namespace std;
const int maxn=1e3+10;
const int maxm=1e6+100;
int h,w;
char a[maxn][maxn];
int d[maxn][maxn];
bool vis[maxn][maxn];

int cx,cy,dx,dy,ans;
int xx[20]={-2,-2,-2,-2,-2,-1,-1,-1,-1,0,0,1,1,1,1,2,2,2,2,2},yy[20]={-2,-1,0,1,2,-2,-1,1,2,-2,2,-2,-1,1,2,-2,-1,0,1,2};
inline bool check(int x,int y){
    return x>=1&&x<=h&&y>=1&&y<=w&&a[x][y]=='.';
}
void work(){
    deque<pair<int,int> > q;
    q.push_back(make_pair(cx,cy));
    d[cx][cy]=0;
    while(!q.empty()){
        int x=q.front().first,y=q.front().second;q.pop_front();
        if(d[x-1][y]>d[x][y]&&check(x-1,y))q.push_front({x-1,y}),d[x-1][y]=d[x][y];
        if(d[x+1][y]>d[x][y]&&check(x+1,y))q.push_front({x+1,y}),d[x+1][y]=d[x][y];
        if(d[x][y-1]>d[x][y]&&check(x,y-1))q.push_front({x,y-1}),d[x][y-1]=d[x][y];
        if(d[x][y+1]>d[x][y]&&check(x,y+1))q.push_front({x,y+1}),d[x][y+1]=d[x][y];
        for(int i=0;i<20;++i){
            int nx=x+xx[i],ny=y+yy[i];
            if(check(nx,ny)){
                if(d[nx][ny]>d[x][y]+1)d[nx][ny]=d[x][y]+1,q.push_back({nx,ny});
            }
        }
    }
}
int main(){
    scanf("%d%d",&h,&w);
    scanf("%d%d",&cx,&cy);
    scanf("%d%d",&dx,&dy);
    rep(i,1,h){
        scanf("%s",a[i]+1);
    }
    rep(i,1,h)rep(j,1,w)d[i][j]=maxm;
    work();
    if(d[dx][dy]==maxm)cout<<-1;
    else cout<<d[dx][dy];

    return 0;
}


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

using namespace std;
#define ll long long
#define ld long double
#define rep(i,h) for(int i = 0; i < h; ++i)
#define rep1(i,h) for(int i = 0; i <= h; ++i)
#define rep2(i,k,h) for(int i = k; i < h; ++i)
#define rep3(i,k,h) for(int i = k; i <= h; ++i)
#define INF LONG_LONG_MAX // long long INF
#define inf INT_MAX // int inf

typedef pair<int,int> int_pair;
typedef pair<string,string> string_pair;


int main() {
    int n;
    cin >> n;
    vector<int> x(n);
    int res;
    int mi = INT_MAX;
    rep(i,n) cin >> x.at(i);
    rep3(i,1,100) {
        res = 0;
       rep(j,n) {
           int k = x.at(j) - i;
           res += pow(k,2);
       }
       mi = min(res, mi);
    }
    cout << mi << endl;

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
// debug & operator << (debug & dd, P p) { dd << "(" << p.x << ", " << p.y << ")"; return dd; }



int main() {
	int n, q;
	scanf("%d%d", &n, &q);
	n -= 2;
	int H = n, W = n;
	vector<int> height(n, n);
	vector<int> width(n, n);
	long long answer = 0;
	while(q--) {
		int type, x;
		scanf("%d%d", &type, &x);
		x -= 2;
		assert(0 <= x && x <= n - 1);
		if(type == 1) {
			if(x < W) {
				answer += min(H, height[x]);
				height[x] = -1; // will not use this again
				// debug() << imie(x) imie(height[x]);
				for(int i = x + 1; i < W; ++i) {
					height[i] = H;
				}
				W = x;
			}
			else {
				answer += height[x];
				height[x] = -1;
			}
		}
		else {
			swap(H, W);
			// swap(height, width);
			if(x < W) {
				answer += min(H, width[x]);
				width[x] = -1; // will not use this again
				for(int i = x + 1; i < W; ++i) {
					width[i] = H;
				}
				W = x;
			}
			else {
				answer += width[x];
				width[x] = -1;
			}
			swap(H, W);
			// swap(height, width);
		}
		debug() << imie(answer) imie(H) imie(W) imie(height) imie(width);
	}
	printf("%lld\n", (long long) n * n - answer);
}


Measured memory_bytes: 4824
import math
import itertools
import heapq
from sys import stdin, stdout, setrecursionlimit
from bisect import bisect, bisect_left, bisect_right
from collections import defaultdict, deque


# d = defaultdict(lambda: 0)
# setrecursionlimit(10**7)
# inf = float("inf")


##### stdin ####
def LM(t, r): return list(map(t, r))
def R(): return stdin.readline()
def RS(): return R().split()
def I(): return int(R())
def F(): return float(R())
def LI(): return LM(int,RS())
def LF(): return LM(float,RS())
def ONE_SL(): return list(input())
def ONE_IL(): return LM(int, ONE_SL())
def ALL_IL(): return LM(int,stdin)

##### tools #####
def ap(f): return f.append
def pll(li): print('\n'.join(LM(str,li)))
def pljoin(li, s): print(s.join(li))



##### main #####

def main():
	N=I()
	A=ALL_IL()
	B=sorted(A.copy())

	a = set([A[i] for i in range(0,N,2)])
	b = set([B[i] for i in range(0,N,2)])

	print(len(a-b))


if __name__ == '__main__':
	main()

Measured memory_bytes: 15324
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int N;
  cin >> N;

  vector<int> A(N);
  REP(i, N) cin >> A[i];

  int ans = 0;
  int now = A[0];
  FOR(i, 1, N){
    if(now < A[i]){
      now = A[i];
    }else{
      ans += now-A[i];
    }
  }

  cout << ans << "\n";

  return 0;
}


Measured memory_bytes: 4776
#include <cstdio>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <climits>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <set>
#include <map>
#include <list>
#include <deque>
#include <vector>
#include <string>
#include <bitset>
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define INF 1000000007
#define PI acos(-1.0)
#define endl "\n"
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP_R(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define FOR(i,m,n) for(int i=((int)(m));i<(int)(n);++i)
#define FOR_R(i,m,n) for(int i=((int)(m)-1);i>=(int)(n);--i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define SIZ(x) ((int)(x).size())
typedef long long int lli;
using namespace std;

int neq( int a, int b)
{
  if( a != b )
    {
      return 1;
      
    }
  else
    {
      return 0;
      
    }
}

int main()
{
  int N,K;
  string S;

  scanf("%d %d\n",&N,&K);
  cin >> S;

  int ifi,ise;
  
  vector<pair<int,int>> l;

  int i = 0;
  int j;
  

  int mx = 0;
  
  while( i < N )
    {
      if( S[i] == '1' )
	{
	  ifi = i;
	  
	  while( S[i] == '1' and i < N )
	    {
	      ++ i;
	      
	    }

	  
	  ise = i;
	  l.push_back(make_pair(ifi,ise));
	  
	    
	}
      else
	{
	  ++ i;
	  
	}
      
      
    }

  if( SIZ(l) == 0 or ( SIZ(l) + neq( l[0].first , 0  ) + neq( l[SIZ(l)-1].second , N ) <= K + 1 ) )
    {
      cout << N << endl;
    }
  else
    {
      for( j = 0 ; j < SIZ(l) - K ; ++ j )
	{
	  if( l[j+K].second - l[j].first > mx  )
	    {
	      mx = l[j+K].second - l[j].first;
	    }
	  
	}

      if( l[0].first > 0 )
	{
	  if( l[K-1].second > mx )
	    {
	      mx = l[K-1].second;
	      
	    }
	}

      if( l[SIZ(l)-1].second < N )
	{
	  if( N - l[SIZ(l)-K].first > mx )
	    {
	      mx = N - l[SIZ(l)-1-K+1].first ;
	      
	    }
	}

      cout << mx << endl;
      
      
    }
  

  
  
  

}


Measured memory_bytes: 1020
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };




signed main() {
	string s;
	vector<int>list(1000, 0);

	cin >> s;

	for (int i = 0; i < s.length(); i++) {
		list[s[i]]++;
	}

	int cnt = 0;

	for (int i = 0; i < 1000; i++) {
		if (list[i] == 2) {
			cnt++;
		}
	}

	if (cnt == 2) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}





	return 0;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define ANS(ans) cout<<(ans)<<endl;


//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)


int main() {

	int n, m;
	cin >> n >> m;
	char a[60][60];
	char b[60][60];
	REP(i, n) {
		REP(j, n) {
			cin >> a[i][j];
		}
	}
	REP(i, m) {
		REP(j, m) {
			cin >> b[i][j];
		}
	}


	bool exist = false;
	REP(i1, n - m + 1) {
		REP(i2, n - m + 1) {
			bool match = true;
			REP(j, m) {
				REP(k, m) {
					if (a[j + i1][k + i2] != b[j][k]) {
						match = false;
					}
				}
			}
			if (match == true) {
				exist = true;
			}
		}
	}

	if (exist) {
		ANS("Yes");
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<pair<int, int>, int> PP;
const ll INFL = 1LL << 60;
const ll MOD = 1000000007;
const int INF = 1000000000;
const int MAX = 300000;
int GCD(int a, int b) { return b ? GCD(b, a % b) : a; }

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

vector<vector<int>> G;
vector<int> ans;
bool visit[10000];
void dfs(int v) {
    visit[v] = 1;
    for (auto nv : G[v]) {
        if (visit[nv]) {
            continue;
        }
        dfs(nv);
    }
    ans.push_back(v);
}

int main(void) {
    int V, E;
    cin >> V >> E;
    G.resize(V);
    for (int i = 0; i < E; i++) {
        int s, t;
        cin >> s >> t;
        G[s].push_back(t);
    }
    for (int i = 0; i < V; i++) {
        if (!visit[i]) {
            dfs(i);
        }
    }
    reverse(ans.begin(), ans.end());
    for (int i = 0; i < ans.size(); i++) {
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 3680
#include <iostream>
#include <string>
#include <cstring>

int main(void){
    using namespace std;
    
    int i,j,k,l;
    int data_set;
    string data;
    int out;
    int field[4];
    int point;
    
    cin>>data_set;
    for(i=0;i<data_set;i++){
        out=0;
        memset(field,0,sizeof(field));
        
        while(out<3){
            cin>>data;
            if(data=="HIT"){
                field[3]+=field[2];
                field[2]=field[1];
                field[1]=field[0];
                field[0]=1;
            }
            else if(data=="HOMERUN"){
                for(j=0;j<3;j++){
                    field[3]+=field[j];
                    field[j]=0;
                }
                field[3]++;
            }
            else if(data=="OUT"){
                out++;
            }
        }
        point=field[3];
        cout<<point<<endl;
    }
    return(0);
}

Measured memory_bytes: 1208
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

const int mod = 1000000007;
//const int mod = 998244353;

struct mint {
    int64_t x;
    mint(int64_t 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(int64_t 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) {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() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, k;
    cin >> n >> k;

    vector<mint> jj(k);
    jj[k-1] = 1;
    for(int i = k-2; i >= 0; --i) {
        mint num = k/(i+1);
        jj[i] = num.pow(n);
        rep(j, num.x-1) {
            jj[i] -= jj[(i+1)*(j+2)-1];
        }
    }

    mint ans = 0;
    rep(i, k) {
        ans += jj[i] * (i+1);
    }

    cout << ans << endl;
}

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

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

typedef long long ll;

const int mod = 1e9 + 7;

using namespace std;

const int MAXA = 1000005;

int main(void) {
	ll N; cin >> N;
	vector<ll> A(N);
	rep(i, N)cin >> A[i];

	vector<int> sieve(MAXA+1, 0);
	for (auto x : A) {
		if (sieve[x] > 0) {
			sieve[x]++;
			continue;
		}

		for (ll i = x; i <= MAXA; i += x) {
			sieve[i]++;
		}
	}

	int ans = 0;
	for (auto x : A) {
		if (sieve[x] == 1)ans++;
	}
	cout << ans << endl;

	return 0;
}

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

int main(int, char**) {
    ios_base::sync_with_stdio(0); cin.tie(NULL);
    
    int n;
    cin >> n;
    map<string, int> cnt;
    int maxVote = 0;
    for (int i = 0; i < n; ++i) {
        string s;
        cin >> s;
        ++cnt[s];
        maxVote = max(maxVote, cnt[s]);
    }
    
    vector<string> res;
    for (auto& kv : cnt)
        if (kv.second == maxVote)
            res.emplace_back(kv.first);
    
    sort(res.begin(), res.end());
    for (auto& v : res)
        cout << v << endl;
   
    
    return 0;
}

Measured memory_bytes: 25584
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef long long int llint;
#define MM 1000000000
#define MOD MM+7
#define pi pair<int,int>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
const long double PI = acos(-1);
const long long INF = 1e15;
const ll DEP = (1LL << 50);
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
template<typename T>
T GCD(T x,T y){
    return y ? GCD(y,x%y) : x;
}
bool Isprime[300003];
void cnt(int s){
    fill(Isprime,Isprime+300000, true);
    Isprime[0] = false;
    Isprime[1] = false;
    for(int i = 2; i*i <= s; i++){
        if (Isprime[i]){
            for(int j = 2; i*j <= s; j++){
                Isprime[i*j] = false;
            }
        }
    }
}
int main(){
    for(;;){
        int n; cin >> n;
        if (!n) break;
        cnt(2*n);
        int ans = 0;
        for(int i = n+1; i <= 2*n; i++){
            if (Isprime[i]){
                ans++;
                //cout << "i=" << i << ",";
            }
        }
        //cout << endl;
        //cout << "ans=";
        cout << ans << endl;
    }
}



Measured memory_bytes: 3384
N,M = map(int,input().split())
ab_s = [list(map(int,input().split())) for _ in range(M)]
ONES = set()
NS = set()
for ab in ab_s:
    a = ab[0]
    b = ab[1]
    if a==1 or b==1:
        if a in NS or b in NS:
            print('POSSIBLE')
            break
        ONES.add(a)
        ONES.add(b)
    if a==N or b==N:
        if a in ONES or b in ONES:
            print('POSSIBLE')
            break
        NS.add(a)
        NS.add(b)
else:
    print('IMPOSSIBLE')


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

ll r(ll x, ll y) {
  if (y == 0) return 1;
  else if (y % 2 == 0) return r(x, y/2) * r(x, y/2) % mod;
  else return x * r(x, (y-1)/2) % mod * r(x, (y-1)/2) % mod;
}
  
int main() {
  int n;
  string s;
  cin >> n >> s;
  int count = 0;
  for (int i = 0; i < n - 2; i++) {
    if (s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') {
      count++;
    }
  }
  cout << count <<endl;
} 


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int main(){
  int h,w,n,ans;
  scanf("%d",&h);
  scanf("%d",&w);
  scanf("%d",&n);
  
  if(h>w){
    if(n%h>0){
    ans=n/h+1;
    }
    else{
      ans=n/h;
    }
  }
  else{
    if(n%w>0){
    ans=n/w+1;
    }
    
    else{
      ans=n/w;
    }
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 128
//  main.cpp
//  CppTest

#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;

int main(int argc, const char * argv[]) {
    
    // cinを高速にするためのおまじない
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    /////////////////////
    // Write code below /
    /////////////////////
    int P;  // A-B
    int Q;  // B-C
    int R;  // C-A
    cin >> P >> Q >> R;
    
    int min_time = P + Q;
    min_time = min(min_time, P + R);
    min_time = min(min_time, Q + R);
    
    cout << min_time << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
long double const pi = std::acos(-1.0L);
typedef pair<int,int> P;
const int INF = 1001001001;


int main() {
  int n; cin >> n;
  vector<int> h(n);
  cin >> h[0];
  bool ok = true;
  for(int i = 1; i < n; ++i) {
    cin >> h[i];
    if(h[i]==h[i-1]) continue;
    h[i]--;
    if(h[i]<h[i-1]){
      ok = false;
      break;
    }
  }
  if(ok) cout <<"Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3780
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
int main()
{
  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
  char c;
  cin>>c;
  if(c>='A'&&c<='Z')printf("A");
  else printf("a");
  return 0;
}

Measured memory_bytes: 3656
fun main (args: Array<String>) {
  val (N, L) = readLine()!!.split(" ").map(String::toInt)
  val strings = mutableListOf<String>()
  for (i in 0 until N) {
    strings.add(readLine()!!)
  }
  strings.sort()
  println(strings.joinToString(""))
}

Measured memory_bytes: 37816
import sys
readline = sys.stdin.readline

N = int(readline())
e = [0] * (N+1)

for i in range(2, N+1):
    cur = i
    for j in range(2, i+1):
        while cur % j == 0:
            e[j] += 1
            cur //= j

def num(m):
    # e の要素のうち、m-1 以上のものの個数
    return len([1 for x in e if x >= m-1])
    # return len(list(filter(lambda x: x >= m-1, e)))

def main():
    print(num(75) + num(25) * (num(3) - 1) + num(15) * (num(5) - 1) 
    + num(5) * (num(5) - 1) * (num(3) - 2) // 2)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <iostream>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<iomanip>
#include <limits>
 
using namespace std;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
 
int retl(int K,int L){
    int tmp=0;
    while(pow(2,tmp) * L < K){
        tmp++;
    }
    return tmp;
}
int gcd(int a,int b)
{
	if (a%b==0)
	{
		return(b);
    }
	else
	{
		return(gcd(b,a%b));
    }
}
struct A{
    string s;
    int p;
    int order;
};
long long c(long long N,long long mod1,long long mod2){
     long long tmp=(N/mod1)+(N/mod2)-(N/((mod1*mod2)/gcd(mod1,mod2)));
 
 
     return N-tmp;
}
bool compare_by_b(pair<long, long> a, pair<long, long> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}
 
int main(){
    int N,K;
 
    cin >>N>>K;
    if(K>((N-1)*(N-2))/2){
        cout<<-1<<endl;
        return 0;
    }else{
        cout<<(N-1)*(N-2)/2 -K+(N-1)<<endl;
        for(int i=2;i<=N;i++){
            cout<<1 <<" "<<i<<endl;
        }
        int res=(N-1)*(N-2)/2 - K;
        int from=2;
        int to=3;
        for(int i=0;res>i;i++){
            if(to<=N){
                cout<<from<<" "<< to <<endl;
                to++;
            }else{
                from++;
                to=from+1;
                i--;
            }
             
          
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int n, cnt = 1, ans = 0, a;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a;
        if(a == cnt) cnt++;
        else ans++;
    }
    if(ans == n) cout << -1;
    else cout << ans;
    return 0;
}

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

#define pfin(a) printf("%d\n",a);
#define pfln(a) printf("%lld\n",a);
#define pfis(a) printf("%d ",a);
#define pfls(a) printf("%lld ",a);
#define sfi(a) scanf("%d",&a);
#define sfl(a) scanf("%lld",&a);
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define f(i,a,b) for(int i=a;i<b;i++)
#define pb(a) push_back(a);
#define mp(a,b) make_pair(a,b)
#define ll long long

const ll mod=1e9+7;

ll M[51][51];

ll K[51][51];

int n;

void util()
{
	memset(M,0,sizeof(M));
	memset(K,0,sizeof(K));
}

void mul(int arg)
{
	ll R[51][51];

	f(i,1,n+1)
	{
		f(j,1,n+1)
		{
			ll temp=0;
			f(k,1,n+1)
			{
				if(arg)
				{
					temp=(temp+(M[i][k]*K[k][j])%mod)%mod;
				}
				else
				{
					temp=(temp+(M[i][k]*M[k][j])%mod)%mod;
				}
			}
			R[i][j]=temp;
		}
	}

	f(i,1,n+1)
	{
		f(j,1,n+1)
			M[i][j]=R[i][j];
	}
}

void matexp(ll k)
{
	if(k==0||k==1)
		return;

	matexp(k/2);
	mul(0);
	
	if(k%2==1)
	{
		mul(1);
	}
}

int main()
{
    util();

    ll k;
    sfi(n)
    sfl(k)

    f(i,1,n+1)
    {
    	f(j,1,n+1)
    	{
    		sfl(M[i][j])
    		K[i][j]=M[i][j];
    	}
    }

    matexp(k);

    ll ans=0;

    f(i,1,n+1)
    {
    	f(j,1,n+1)
    	{
    		ans=(ans+M[i][j])%mod;
    	}
    }

    pfln(ans)

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int a,b;
  // スペース区切りの整数の入力
  scanf("%d %d",&a,&b);

  switch((a*b)%2)
  {
    case 0:
        printf("Even");
        break;
    case 1:
        printf("Odd");
        break;
  }
  return 0;
}

Measured memory_bytes: 128
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
A = A1 + A2 + A3

N = int(input())

# 印をつける
for i in range(N):
    b = int(input())
    
    for index in range(len(A)):
        a = A[index]
        if a == b:
            A[index] = 0     # 0を印とする

def isExistTatePair():
    for i in range(3):
        sum = 0
        for j in range(3):
            sum += A[3 * j + i]
        if sum == 0:
            return True
    return False

def isExistYokoPair():
    for i in range(3):
        sum = 0
        for j in range(3):
            sum += A[3 * i + j]
        if sum == 0:
            return True
    return False

def isExistNanamePair():
    sum = 0
    for i in range(3):
        sum += A[3 * i + i]
    if sum == 0:
        return True
    
    sum = 0
    for i in range(3):
        sum += A[3 * (i + 1) - (i + 1)]
    if sum == 0:
        return True
    return False

isExistPair = isExistTatePair() or isExistYokoPair() or isExistNanamePair()
print('Yes' if isExistPair else 'No')

Measured memory_bytes: 3064
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		int N = S.Length;
		String S2 = S + S;
		int N2 = N * 2;
		int[][] min = new int[26][];
		int Inf = (int) 1e9;
		for(int i=0;i<26;i++){
			min[i] = new int[N2];
			for(int j=0;j<N2;j++){
				min[i][j] = Inf;
			}
		}
		for(int j=0;j<26;j++){
			int last = Inf;
			for(int i=N2-1;i>=0;i--){
				if(last != Inf){
					min[j][i] = last - i;
				}
				if(S2[i] == (char) ('a' + j)){
					last = i;
				}
			}
		}
		
//Console.WriteLine(String.Join(" ",min['s' - 'a']));
//Console.WriteLine(String.Join(" ",min['o' - 'a']));
//Console.WriteLine(String.Join(" ",min['n' - 'a']));
		
		
		int strt = -1;
		for(int i=0;i<N;i++){
			if(S[i] == T[0]){
				strt = i;
				break;
			}
		}
		if(strt == -1){
			Console.WriteLine(-1);
			return;
		}
		
		int pos = strt;
		long len = strt + 1;
		for(int j=1;j<T.Length;j++){
			int nstep = min[T[j] - 'a'][pos];
			if(nstep == Inf){
				Console.WriteLine(-1);
				return;
			}
			len += nstep;
			pos += nstep;
//Console.WriteLine("len:{0}, pos:{1}",len, pos);
			if(pos >= N) pos -= N;
		}
		
		Console.WriteLine(len);
		
	}
	String S,T;
	public Sol(){
		S = rs();
		T = rs();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 32728
s = [input() for i in range(2)]

K = int(s[0])
A = int(s[1].split()[0])
B = int(s[1].split()[1])

result = True
for i in range(A, B+1):
  if i % K == 0:
    print("OK")
    result = False
    break
if(result):
  print("NG")

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

const int INF = 1 << 30;

int main()
{
  int n, rm, ans;

  ans = -INF;
  cin >> n >> rm;
  for (int j = 1; j < n; j++) {
    int rj; cin >> rj;
    ans = max(ans, rj-rm);
    rm = min(rm, rj);
  }
  cout << ans << endl;
  return EXIT_SUCCESS;
}



Measured memory_bytes: 3108
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
//#include<bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1000000000000000000;
const int mod = 1000000007;
int test[1234][1234], cost[1234][1234];
signed main() {
	vector<int> v; map<string, int> mn;
	int n, m, q, a, b, c, x, cnt = 0, ans = 0; string s, t;
	cin >> a >> b >> n;
	cout << (a * min(n, b - 1) / b) - a * (min(n, b - 1) / b) << endl;
	return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
using namespace std;
using ll = long long;
int main(){
  int a, b;
  cin >> a >> b;
  
  if(a < 0 && b < 0){
    if(abs(b - a) % 2 == 0){
      cout << "Negative\n";
    }else{
      cout << "Positive\n";
    }
  }else if(a <= 0 && b >= 0){
    cout << "Zero\n";
  }else{
    cout << "Positive\n";
  }
  return 0;
}

Measured memory_bytes: 256
#-------------------------------------------------------------------------------
# coding: utf-8
# Created:     16/12/2015

import sys
io = sys.stdin

n = io.readline()

a0, a1 = [1, 1]
a2 = 1
for i in xrange(int(n)-1):
    a2 = a0 + a1
    a0, a1 = a1, a2

print a2

Measured memory_bytes: 6432
// Problem : A - Calc
// Contest : AtCoder - AtCoder Beginner Contest 172
// URL : https://atcoder.jp/contests/abc172/tasks/abc172_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
#define int long long
#define db double
#define mod 1000000007
#define pb push_back
#define pp pair<int,int>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repe(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=b;i>=a;i--)
#define maxn 100005
#define ss second
#define ff first
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub uppper_bound
using namespace std;
int inv(int a, int b){
 return 1<a ? b - inv(b%a,a)*b/a : 1;
}
void solve()
{
	int a;
	cin >> a;
	cout << a+(a*a)+(a*a*a);	
}
signed main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin >> t;
    while(t--)
    solve();
    return 0;
}


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

using namespace std;
//FILE *fi=freopen("1.txt","r",stdin);
int a,b;
int main()
{
    cin>>a>>b;
    if(a>b)
        swap(a,b);
    if(a==1&&b==2)
    {
        cout<<3;
        return 0;
    }
    else if(a==2&&b==3)
    {
        cout<<1;
        return 0;
    }
    if(a==1&&b==3)
    {
        cout<<2;
    }
    return 0;
}


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

using namespace std;

char rot_char(char c, int n) {
    return (char) ((c + n - 'A') % 26 + 'A');
}

string rot(string s, int n) {
    string t = "";
    for (char c : s) {
        t += rot_char(c, n);
    }
    return t;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    int n;
    cin >> n >> s;
    cout << rot(s, n) << endl;
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
#include<cmath>
#include<functional>
typedef long long ll;

using namespace std;
const ll MAX = 510000;
const ll MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main(){
    int N,K;
    cin >> N >> K;
    vector<ll> A(N, 0);
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    sort(A.begin(), A.end());
    ll maxSum=0;
    ll minSum=0;
    COMinit();
    for(int i=0;i<N;i++){
        if(i >= K-1){
            maxSum += (COM(i, K-1) % MOD) * (A[i] % MOD);
            maxSum %= MOD;
        }
        if(N-i >= K){
            minSum += (COM(N-i-1, K-1) % MOD) * (A[i] % MOD);
            minSum %= MOD;
        }
    }
    ll res = maxSum-minSum + 2*MOD;
    res %= MOD;
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 12928
import math
import queue
from collections import defaultdict
 
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def printQueue(q):
	r=qb
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
def dq():
	return queue.deque()
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		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 = 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]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): # much time
		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 self.roots()} # 1~n
def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1


def money(arr):
	ans = 0
	for i in range(len(arr)):
		if arr[i]==1:
			ans+=c[i][0]
	return ans

n,m,x = readInts()
c = []
for i in range(n):
	c.append(readInts())

ans = 1000000000000

for arr in bitArr(n):
	tmp = [0]*m
	for i in range(n):
		if arr[i]==1:
			arrsSum(tmp,c[i][1:])
	if min(tmp)>=x:

		kari = money(arr)
		if kari<ans:
			ans = kari

if ans==1000000000000:
	ans = -1

print(ans)

Measured memory_bytes: 10116
#include <iostream>
#include <fstream>
#include <random>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <map>
#include <algorithm>

using namespace std;



int main() {

    //freopen("../input.txt", "r", stdin);

    ios::sync_with_stdio(false);
    cin.tie();
    cout.tie();

    long long n, a, b;
    cin >> n >> a >> b;

    long long total = (n / (a + b)) * a;
    total += min(n % (a + b), a);

    cout << total;

    return 0;
}

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

using namespace std;

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

  int n;
  string s;
  cin >> n >> s;

  int res = 0;
  for (int i = 0; i < n; ++i) {
    int cnt = 0;
    set<char> s1, s2;
    for (auto & c: s.substr(0,i))
      s1.insert(c);
    for (auto & c: s.substr(i,n-i))
      s2.insert(c);
    for (auto &c : s1) 
      if (s2.find(c) != s2.end())
        cnt++;
    if (cnt > res) res = cnt;
  }
  cout << res << endl;

  return 0;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    static int mod = 1000000007;
    static int n, k;
    static boolean[] visited;
    static Map<Integer, Set<Integer>> edge;
    public static void main(String[]$) {
        n = scanner.nextInt();
        k = scanner.nextInt();
        edge = new HashMap<>();
        visited = new boolean[n];
        for (int i = 0; i < n; i++) {
            edge.put(i, new HashSet<>());
        }

        for (int i = 1; i < n; i++) {
            int a = scanner.nextInt() - 1;
            int b = scanner.nextInt() - 1;
            edge.get(a).add(b);
            edge.get(b).add(a);
        }

        System.out.println(bfs(0, 0, 0));
    }

    static long bfs(int v, int c2, int c1) {
        visited[v] = true;
        int d = 0;
        long r = k - c2 - c1;
        for (int i : edge.get(v)) {
            if (!visited[i]) {
                r = r * bfs(i, c1 + d, 1) % mod;
                d++;
            }
        }
        return r;
    }
}

Measured memory_bytes: 134732
#include <queue>
#include <cstdio>
#include <iostream>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <time.h>
#include <functional>
using namespace std;
typedef long long int ll;

#define EPS (1e-9)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i,n) for(int i=0;i<n;i++)

int gcd(int a, int b) {
    if (a < b) swap(a, b);
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll beki(ll a, ll b) {
    ll tmp = 1;
    REP(i, b) tmp *= a;
    return tmp;
}

int N, K;
bool S[110] = {};

int main() {
    cin >> N >> K;
    REP(i, K) {
        int d;
        cin >> d;
        REP(j, d) {
            int A;
            cin >> A;
            S[A - 1] = true;
        }
    }

    int ans = 0;
    REP(i, N) {
        if (!S[i]) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<endl;
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;
const ll inf=1e15;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  if(n%2==0) cout<<1.0/2.0<<endl;
  else{
    double now=(n+1)/2.0;
    cout<<setprecision(10)<<now/n<<endl;
  }
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;



int main()
{
	int n;
	cin >> n;
	vector<long long int> a(n);
	int ans = 0;
	for (int i = 0; i < n; i++) {
		long long int x;
		cin >> x;
		if (x % 2 == 0) {
			while (x % 2 == 0) {
				ans++;
				x /= 2;
			}
		}
	}

	cout << ans << endl;


	return 0;
}

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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

const int ST_MAX = (1 << 20);

template <class T , class U> class ST{
	T x[ST_MAX * 2];
	U lazy[ST_MAX * 2];
	
	T eval(T a , T b){
		return max(a,b);
	}
	
	U syn(U a , U b){
		return a+b;
	}
	
	void work(int a){
		if(a < ST_MAX){
			lazy[a * 2] = syn(lazy[a] , lazy[a * 2]);
			lazy[a * 2 + 1] = syn(lazy[a] , lazy[a * 2 + 1]);
		}
		x[a] += lazy[a];
		lazy[a] = 0;
	}
	
	void ren(int a , int b , int e , int s , int f , U z){
		if(e <= s || f <= b){
			work(a);
			return;
		}
		if(s <= b && e <= f){
			lazy[a] = syn(lazy[a] , z);
			work(a);
			return;
		}
		work(a);
		ren(2 * a , b , (b + e) / 2 , s , f , z);
		ren(2 * a + 1 , (b + e) / 2 , e , s , f , z);
		x[a] = eval(x[a * 2] , x[a * 2 + 1]);
	}
	
	T read_ST(int a , int b , int e , int s , int f){
		work(a);
		if(e <= s || f <= b) return 0;
		if(s <= b && e <= f) return x[a];
		return eval(read_ST(2 * a , b , (b + e) / 2 , s , f) , read_ST(2 * a + 1 , (b + e) / 2 , e , s , f));
	}
	
public:
	
	ST(){
		fill(x,x+ST_MAX*2,0);
		fill(lazy,lazy+ST_MAX*2,0);
	}
	
	void put(int s , int f , U b){
		ren(1 , 0 , ST_MAX , s , f , b);
	}
	
	T get(int s , int f){
		return read_ST(1 , 0 , ST_MAX , s , f);
	}
};

ST<LL,LL> solve;

int main(){
	int N,M; cin >> N >> M;
	vector<int> l(M),r(M),s(M);
	vector<LL> a(M);
	repp(i,0,M){
		cin >> l[i] >> r[i] >> a[i];
		s[i] = i;
	}
	sort(s.begin(),s.end(),[&](const int &x, const int &y){return r[x] < r[y];});
	int k = 0;
	repp(i,1,N+1){
		while(k < M && r[s[k]] == i){
			solve.put(l[s[k]],r[s[k]]+1,a[s[k]]);
			++k;
		}
		solve.put(i+1,i+2,solve.get(0,i+1));
	}
	cout << solve.get(0,N+1) << endl;
	return 0;
}


Measured memory_bytes: 36992