akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <algorithm>
#include <vector>
#include <cstring>
#include <stack>
#include <cctype>
#include <utility>
#include <map>
#include <string>
#include <climits>
#include <set>
#include <sstream>
#include <utility>
#include <ctime>
#include <cassert>
#include <fstream>
using namespace std;
typedef long long LL;
#define MS(A) memset(A, 0, sizeof(A))
#define MSV(A,a) memset(A, a, sizeof(A))
#define MP make_pair
#define PB push_back
#define getcx getchar_unlocked
#define INF (int(1e9))
#define INFL (LL(1e18))
#define EPS 1e-12
#define chkbit(s, b) (s & (1<<b))
#define setbit(s, b) (s |= (1<<b))
#define chk(a) cerr << endl << #a << " : " << a << endl
#define chk2(a,b) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << endl
#define chk3(a,b,c) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << endl
#define chk4(a,b,c,d) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << "\t" << #d << " : " << d << endl
#define rep(i, a, n) for(i=a;i<n;i++)
#define rev(i, a, n) for(i=a;i>=n;i--)
#define rep_itr(itr, c) for(itr = (c).begin(); itr != (c).end(); itr++)
#define MOD 1000000007
#define MAX 1000000


int main() {

	char s[50];
	scanf("%s",s);
	printf("%c%c%c\n", s[0], s[1],s[2]);
	return 0;
}

Measured memory_bytes: 3748
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
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; }

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

    int res = 0;
    while(!s.empty()){
        char a = s[0], b = s.back();
        if(a == b){
            s.pop_back();
            if(!s.empty())s.erase(s.begin());
        }else if(a == 'x'){
            s.erase(s.begin());
            res++;
        }else if(b == 'x'){
            s.pop_back();
            res++;
        }else{
            res = -1; break;
        }
    }
    cout << res << ln;
}

Measured memory_bytes: 512
#include <iostream>

using namespace std;

unsigned long long n, k = 1, result = 0;

int main(int argc, char** argv)
{
    scanf("%lld", &n);
    while (n > 0)
    {
        result += k;
        n /= 2;
        k *= 2;
    }
    printf("%lld", result);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0;i<(n);i++)
using namespace std;
#define vecout(V) for(int i=0;i<V.size();i++) {cout<<V[i]<<endl;}
typedef long long ll;


int main(void){
    int n;
    cin>>n;
    vector<char> alp={'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'};
    queue <pair<string, int> > ans;
    ans.push(make_pair("a", 1));
    rep(i, n-1){
        int qsize=ans.size();
        rep(k, qsize){
            auto p=ans.front();
            ans.pop();
            int num=p.second;//種類数
            rep(j, num+1){
                pair<string, int> tmp;
                tmp=p;
                tmp.first.push_back(alp[j]);
                if(j==num) tmp.second=p.second+1;
                ans.push(tmp);
            }
        }
    }
    while(!ans.empty()) {
        pair<string, int> p=ans.front();
        ans.pop();
        cout<<p.first<<endl;
    }


}

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

struct Shop {
    int A;
    int B;
};

bool cmp(const Shop &a, const Shop &b)
{
    return a.A < b.A;
}

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

    long long ans = 0;
    vector<Shop> shop(N);

    for(int i=0; i<N; i++){
        cin >> shop[i].A >> shop[i].B;
    }

    sort(shop.begin(), shop.end(), cmp);

    while(M > 0){
        ans += shop[0].A;

        if(shop[0].B == 1)
            shop.erase(shop.begin());
        else
            shop[0].B -= 1;

        M--;
    }

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


Measured memory_bytes: 1024
N,K = map(int,input().split())
x = list(map(int,input().split()))

min_time = float("inf")

for i in range(N-K+1):
    if x[i] >= 0:
        time = x[i+K-1]
    if x[i] < 0:
        if x[i+K-1] >= 0:
            time = min(x[i+K-1], -x[i]) + (x[i+K-1] - x[i])
        else:
            time = -x[i]
    min_time = min(min_time,time)
print(min_time)


Measured memory_bytes: 14536
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    A = [0] + il() + [0]
    M = 0
    for n in range(N + 1):
        M += abs(A[n] - A[n + 1])

    for i in range(0, N):
        print(M - abs(A[i] - A[i + 1]) - abs(A[i + 1] - A[i + 2]) + abs(A[i] - A[i + 2]))


if __name__ == '__main__':
    main()


Measured memory_bytes: 20348
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)


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

    ll ans = 1000;
    ll stock = 0;
    ll pastA = 0;
    ll A = 0;
    cin >> pastA;
    rep(i, N - 1){
        cin >> A;
        if(stock == 0){
            if(A > pastA){
                stock = ans / pastA;
                ans -= pastA * stock;
            }
        }else{
            if(A < pastA){
                ans += pastA * stock;
                stock = 0;
            }
        }
        pastA = A;
    }
    if(stock > 0){
        ans += A * stock;
    }

    cout << ans << endl;

    return 0;
}


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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n;
    cin >> n;
    map<int32,int32> a;
    REP(i,n){
        int32 ai;
        cin >> ai;
        a[ai]++;
    }
    int32 ans = 0;
    for(auto it = a.rbegin(); it != a.rend(); it++){
        int32 x = it->first;
        int32 y = it->second;
        if(y > 0){
            int64 sum = 2;
            while(sum <= x){
                sum <<= 1;
            }
            int32 mn;
            if(x + x == sum){
                mn = a[x] / 2;
            }else{
                mn = min(y, a[sum-x]);
            }
            it->second -= mn;
            a[sum-x] -= mn;
            ans += mn;
        }
    }
    ANS(ans);
    return 0;
}

Measured memory_bytes: 25216
#include<bits/stdc++.h>
#define f(i,a,b) for(long long i=a;i<b;i++)
#define F first
#define S second
#define pb(i) push_back(i)
#define mp(x,y) make_pair(x,y)
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
using namespace std;

int main(){
	ll n;cin>>n;
	n=n*n;
	cout<<n<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define M_PI 3.14159265358979323846
#define MOD 1000000007
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> ipair;
typedef pair<ll, ll> llpair;

template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }

#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
    
/*
    Author: Koushik Sahu
    Created: 19 Sep 2020 17:35:55
*/

int n;
array<int, 1000001> dp;

int numberOfDivisor(int x){
    if(dp[x]!=-1) return dp[x];
    int ans = 0;
    for(int i=1; i<=sqrt(x); i++){
        if(x%i==0){
            ans += (x/i == i ? 1 : 2);
        }
    }
    return dp[x] = ans;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    cin>>n;
    int ans = 0;
    dp.fill(-1);
    for(int c=1; c<n; c++){
        ans += numberOfDivisor(n-c);
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 7600
import sys
def input():
	return sys.stdin.readline().strip()

N, M = list(map(int, input().split()))

AB = []

for i in range(N):
	AB.append(list(map(int, input().split())))

AB.sort()

total = 0
yen = 0
i = 0
while True:
	A = AB[i][0]
	B = AB[i][1]
	if total + B < M:
		yen += A*B
		total += B
		i += 1
	else:
		yen += (M - total)*A
		break
print(yen)

Measured memory_bytes: 56540
#include <iostream>
#include <fstream>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <iterator>
#include <ext/pb_ds/assoc_container.hpp>

#define x first
#define y second
#define mp make_pair
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)x.size()
#define bit __builtin_popcount
#define all(x) x.begin(),x.end()

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

const ll INF=1e18+123;
const ld EPS=1e-9;
const int inf=1e9+123;
const int MOD=1e9+7;
const int N=1e5+123;
const int dx[]={0,0,1,-1};
const int dy[]={1,-1,0,0};

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin>>n;
    int cnt=0;
    for(int i=1;i<=n;i+=2){
        int q=0;
        for(int j=1;j<=i;j++){
            if(i%j==0){
                q++;
            }
        }
        if(q==8)cnt++;
    }
    cout<<cnt;
    return 0;
}


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

int main(){
	int N;
	cin >> N;
	bool odd=false;
	for(int i=0;i<N;i++){
		int A;
		cin >> A;
		if(A%2==1)odd=(!odd);
	}
	if(odd)cout << "NO" << endl;
	else cout << "YES" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>

using namespace std;
int main()
{
  vector<int> vec;
    vec ={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
};
    int K;

    cin >> K;

    cout << vec.at(K-1) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#include<vector>
#define int long long int
#define mod 1000000007
int function(int arr[],int initial,int final,int curr,int memo[][3])
{
	if(initial>final)
	  return 0;
	if(memo[initial][curr]!=-1)
	{
		return memo[initial][curr];
	}
	else
	{
		if(curr==0)
		{
			int val=arr[initial]+function(arr,initial+2,final,curr,memo);
			memo[initial][curr]=val;
			return val;
		}
		else
		{
			int val1=arr[initial]+function(arr,initial+2,final,curr,memo);
			int val2=arr[initial]+function(arr,initial+3,final,curr-1,memo);
			memo[initial][curr]=max(val1,val2);
			return max(val1,val2);
		}
	}
}
int32_t main()
{
		int n;
		cin>>n;
		int arr[n+1];
		int j;
		for(j=1;j<=n;j++)
		{
			cin>>arr[j];
		}
		int memo[n+1][3];
		int i;
		for(i=0;i<=n;i++)
		{
			for(j=0;j<3;j++)
			{
				memo[i][j]=-1;
			}
		}
		if(n%2==0)
		{
			int val1=function(arr,1,n,1,memo);
			int val2=function(arr,2,n,0,memo);
			cout<<max(val1,val2)<<endl;
		}
		else
		{
			int val1=function(arr,1,n,2,memo);
			int val2=function(arr,2,n,1,memo);
			int val3=function(arr,3,n,0,memo);
			int answer2=max(val1,max(val2,val3));
			cout<<answer2<<endl;
		}
}


Measured memory_bytes: 17616
import java.util.Scanner;
class Main{
	public static void main(String[] args){
		Scanner input = new Scanner(System.in);
		int n, seq, tmp;
		int i, j, res;
		int num[] = new int[10];
		
		n = input.nextInt();
		for (; n > 0; n--){
			seq = input.nextInt();
			for (i = 0; i < 8; i++){
				num[i] = seq % 10;
				seq /= 10;
			}
			for (i = 0; i < 7; i++){
				for (j = i + 1; j < 8; j++){
					if (num[i] > num[j]){
						tmp = num[i];
						num[i] = num[j];
						num[j] = tmp;
					}
				}
			}
			res = 0;
			for (i = 0; i < 8; i++){
				res *= 10;
				res += (num[7 - i] - num[i]);
			}
			System.out.println(res);
		}
	}
}

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

using std::min;

const int N=1010,Inf=1e9+7;

struct Edge{ int to,next; }way[N];

int n,p[N],X[N],dp[N],g[N*10],tot,num[N];

void Build(int a,int b) { way[++tot]=(Edge){b,num[a]}; num[a]=tot; }

void Init() {
	scanf("%d",&n);
	int f;
	for (int i=2;i<=n;++i) scanf("%d",&f),Build(f,i);
	for (int i=1;i<=n;++i) scanf("%d",&X[i]);
}

bool Dfs(int x) {
	if (!num[x]) { dp[x]=0; return 1; }
	for (int i=num[x];i;i=way[i].next) {
		int v=way[i].to;
		if (!Dfs(v)) return 0;
	}
	for (int i=0;i<=X[x];++i) g[i]=Inf; bool fl=1;
	for (int i=num[x];i;i=way[i].next) {
		int v=way[i].to;
		if (fl) {
			fl=0;
			if (dp[v]<=X[x]) g[dp[v]]=min(g[dp[v]],X[v]);
			if (X[v]<=X[x]) g[X[v]]=min(g[X[v]],dp[v]);
		}else for (int j=X[x];j>=0;--j) if (g[j]!=Inf) {
			int val=g[j]; g[j]=Inf;
			if (j+dp[v]<=X[x]) g[j+dp[v]]=min(g[j+dp[v]],val+X[v]);
			if (j+X[v]<=X[x]) g[j+X[v]]=min(g[j+X[v]],val+dp[v]);
		}
	}
	int ans=Inf;
	for (int i=0;i<=X[x];++i) if (g[i]!=Inf) ans=min(ans,g[i]);
	if (ans==Inf) return 0;
	dp[x]=ans;
	return 1;
}

void Solve() {
	if (Dfs(1)) printf("POSSIBLE\n");
	else printf("IMPOSSIBLE\n");
}

int main() {
	Init();
	Solve();
	return 0;
}

Measured memory_bytes: 256
// In the name of God

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>

using namespace std;

const int N = (int) 2005, mod = (int) 1e9 + 7;

int dp[N], odp[N];
void sadd(int &x, int y) { x += y; x %= mod; }
int32_t main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n, m, k, res = 0;
    cin >> n >> m >> k;
    dp[1] = 1;
    for (int h = 1; h <= (n + m + 2200) / (k - 1); ++h) {
        int val = h * (k - 1) + 1;
        memcpy(odp, dp, sizeof dp);
        memset(dp, 0, sizeof dp);
        for (int last = 0; last <= n; ++last) for (int j = 0; j < k && last + j <= n; ++j) {
            sadd(dp[last + j], odp[last]);
        }
        if (val % (k - 1) == (n + m) % (k - 1)) {
            for (int j = 1; j <= n; ++j)
                if (val - j <= m && j % (k - 1) == n % (k - 1)) {
                    //cout << h << ' ' << j << ' ' << dp[j] << ' ' << val << ' ' << val - j << endl;
                    sadd(res, (dp[j] - (j - k + 1 >= 0? odp[j - k + 1]: 0) + mod) % mod);
                }
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(I, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
using ll = long long;

int main() {
  int n,m;
  cin >> n >> m;
  int ans = 0;
  
  int an[n];
  REP(i,n) an[i] = -1;
  
  REP(i,m){
    int s,c;
    cin >> s >> c;
    s--;
    
    if(n != 1 && s == 0 && c == 0){
      cout << -1 << endl;
      return 0;
    }
    
    if(an[s] < 0 || an[s] == c){
      an[s] = c;
    }
    else{
      cout << -1 << endl;
      return 0;
    }
  }
  
  if(n != 1){
    REP(i,n){
      if(i != 0 && an[i] == -1){
        an[i] = 0;
      }
      else if(an[i] == -1){
        an[i] = 1;
      }
    }
  }
  else{
    if(an[0] == -1){
      an[0] = 0;
    }
  }
  
  REP(i,n){
    ans += an[i];
    if(i != n-1){
      ans *= 10;
    }
  }
  
  
  
  cout << ans << endl;
}

Measured memory_bytes: 3612
#include<iostream>
using namespace std;
int main () {
  int N, L;
  cin >> N >> L;
  int ans = 0;
  bool did = false;
  for (int i = 0; i < N; i ++) {
    if (L + i == 0) did = true;
    ans += L + i;
  }
  if (!did) {
    if (L > 0) ans -= L;
    else ans = ans - L - N + 1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
n, t = map(int, input().split())
a = list(map(int, input().split()))

a_max = [a[-1]] * n
for i in reversed(range(n-1)):
    a_max[i] = max(a[i], a_max[i+1])

a_min = [a[0]] * n
a_diff_max = 0
for i in range(1, n):
    a_min[i] = min(a[i], a_min[i-1])
    a_diff_max = max(a_diff_max, a_max[i] - a_min[i-1])

a_min_max = set()
for i in range(n-1):
    if a_max[i+1] - a_min[i] == a_diff_max:
        a_min_max.add((a_max[i+1], a_min[i]))

ans = len(a_min_max)
print(ans)


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

using namespace std;

int n;
int a[200010];

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i) scanf("%d",&a[i]),a[i]-=i;
	sort(a+1,a+n+1);
	long long ans=0;
	int mi=a[(n+1)/2];
	for(int i=1;i<=n;++i) ans+=abs(mi-a[i]);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;

int main() {
    int N;
    cin >> N;
    vector<int> a(3*N);
    for(int i=0; i<3*N; ++i) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    ll res = 0;
    for(int i=0; i<N; ++i) {
        res += a[3*N-2-i*2];
    }
    cout << res << endl;
    // 1 2 5 5 5 8
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int mod=1000000007;
#define pb  push_back
#define FOR(i,n) for(int i=0;i<(n);i++)
#define FORA(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define count_1(n)  __builtin_popcountll(n)
#define parity(n)   __builtin_parityll(n)   //Even parity 0 as output
void show    (int a[], int arraysize) { for (int i = 0; i < arraysize; ++i)  {cout << a[i] << " ";}	cout<<endl;}
int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b);}
void sieve(int n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p])
          cout << p << " ";
}
int main()
{FAST
ll a,b;
cin>>a>>b;
if((a*b)%2==0&&a!=1&&b!=1)
{
	cout<<(a*b)/2<<endl;
}
else if(a==1||b==1)
{
	cout<<1<<endl;
	
}
else
{
		cout<<(a*b)/2+1<<endl;
}
return  0;
}




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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll n;
  cin >> n;

  ll ng = 0;
  ll ok = 1e7;
  while(ok-ng>1){
    ll mid = (ok+ng)/2;
    if(mid*(mid+1)/2>=n)
      ok = mid;
    else
      ng = mid;
  }

  ll k = ok;
  for(ll i = k; i>0 && n>0; i--){
    if(i<=n){
      cout << i << endl;
      n -= i;
    }
  }


}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<vector>
#include<deque>
#include<queue>
#include<string>
#include<iostream>
#include<tuple>
#include<utility>
#include<set>
#include<queue>
#include<iomanip>
#include<iterator>
//#include<chrono>
//#include<mt19937>
using namespace std;
typedef long long int llint;
const int big=1e9+100000;
const int mod=1e9+7;
const long double pai=3.141592653589793238462643;
#define mt make_tuple
#define mp make_pair
#define fir first
#define sec second
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define res resize
#define ins insert
#define era erase
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
//各シフト数につき反転数を求めておく
//左右シフト数につき、可能かどうか求める
//例、左2,右3=不可
//左2,右4=可
//左の数を固定,右を探索
//.....10..の場所を持っておく
//左->右->はてな
//左右逆転
vector<int> han(const deque<bool>&a,/*実はconst*/ deque<bool>&b){
	int i,j,n=a.size();
	vector<int> ret(n);
	for(i=0;i<n;i++){
		int kr=0;
		for(j=0;j<n;j++){if(a[j]!=b[j]){kr++;}}
		ret[i]=kr;
		auto z=b.back();b.pob();b.puf(z);
	}
	return ret;
}//ret[i]= bをi回みっぎシフトしたもの
int solve(deque<bool> a,deque<bool> b){
	int ans=big,n=a.size();
	deque<bool> c=b;//c=change
	//bを左シフト->うまく合わせる
	auto kaz=han(a,b);
	int ikaz=0;
	for(int j=0;j<n;j++){if(a[j]==1){ikaz++;}}
	int bk=0;
	for(int j=0;j<n;j++){if(b[j]==1){bk++;break;}}
	if(bk==0&&ikaz==0){return 0;}
	if(bk==0){return -1;}
	for(int i=0;i<n+1;i++){
		//bを左しふと iはシフト回数
		
		vector<int>iopot;
		deque<bool>d=c;//途中
		int nok=ikaz;
		for(int j=0;j<n;j++){if(a[j]==1&&c[j]==1){nok--;}}
		for(int j=0;j<n-1;j++){
			if(d[j]==1&&d[j+1]==0){iopot.pub(j+1);}
		}if(d[n-1]==1&&d[0]==0){iopot.pub(0);}
		
		int j;
		for(j=0;j<n;j++){//jは右シフトの回数
			if(nok==0){break;}
			vector<int>iti;
			for(int k=0;k<iopot.size();k++){
				if(a[iopot[k]]==1){nok--;}
				d[iopot[k]]=1;
				if(d[(iopot[k]+1)%n]==0){iti.pub((iopot[k]+1)%n);}
			}
			swap(iti,iopot);
		}
		//jを使用
		//2*i+j
		for(int k=0;k<n;k++){
			int it=i+i+j+kaz[k]+min(min(abs(j-k),abs(j-n-k)),abs(n+j-k));
			mineq(ans,it);
			//cout<<"i="<<i<<"j="<<j<<"kaz[k]=="<<kaz[k]<<"de it[i]="<<it<<endl;
		}
		bool z=c[0];
		for(int j=0;j<n-1;j++){c[j]|=c[j+1];}
		c[n-1]|=z;
	}
	return ans;
}
int main(void){
	int ans=big;
	string a,b;
	cin>>a>>b;
	int n=a.size();
	deque<bool> A(n),B(n);
	
	for(int i=0;i<n;i++){
		if(a[i]=='1'){A[i]=1;}else{A[i]=0;}
		if(b[i]=='1'){B[i]=1;}else{B[i]=0;}
	}
	mineq(ans,solve(A,B));
	reverse(A.begin(),A.end());
	reverse(B.begin(),B.end());
	mineq(ans,solve(A,B));
	cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;

public class Main {
	static Integer A = 0;
	static Integer B = 0;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
	    int N = sc.nextInt();
	    int K = sc.nextInt();
	    
	    int V [] = new int [N];

	    for (int i=0;i<N;i++) {
	    	V[i]=sc.nextInt();
	    }
	    sc.close(); 
	    
		int[] L = new int[N+1];
		int[] R = new int[N+1];

		int l = 0;
		for (int i=0;i<N;i++) {
			l += V[i];
			L[i+1]=l;
		}
		
		int r = 0;

		for (int i=0;i<N;i++) {
			r += V[N-i-1];
			R[i+1]=r;
		}
	    
		
		int X = Math.min(N, K);
		int max = 0;
		int temp = 0;
		Queue <Integer> min = new PriorityQueue<Integer>();

		while (A+B<=X){
			A++;
			
			while (A+B<=X){
				temp = L[A]+R[B];
				
				
				for (int i=0; i<A;i++) {
					if (V[i]<0)
						min.add(V[i]);	
				}
				
				for (int i=0;i<B;i++) {
					//System.out.print(V[N-i-1]+" ");
					if (V[N-i-1]<0)
						min.add(V[N-i-1]);
					//System.out.println(min.peek());
				}
				//System.out.println(" ");
				
				/*for (int i=0; i<min.size()+1; i++){
					System.out.print(min.poll()+ " ");
						
				}
				System.out.println(" ");
				*/
				
				
				int cur = Math.min(min.size(), K-(A+B));
				for (int i=0; i<cur; i++){
					//System.out.println(min.peek());
					temp=temp-min.poll();
				}
				
				max = Math.max(temp,max);
				//System.out.println(A+" "+B+ " "+ max);
				B++;
				min.clear();
				
				
			}
			B=0;
		}
		System.out.println(max);
	}

}


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

unsigned long long abso(unsigned long long a,unsigned long long b){
  if(a>b/2){
    a = llabs(a-b);
  return abso(a,b);
}else return a;
}


int main(void){
  unsigned long long n;
  unsigned long long k;
  scanf("%lld %lld",&n,&k);
  n %=k;
  printf("%lld\n",abso(n,k));
  return 0;
}


Measured memory_bytes: 1684
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
string s,t;
int sl,tl;
int main(){
    cin>>s>>t;
    sl=s.size();
    tl=t.size();
    vector<int> v;
    for(int i=0;i<=sl-tl;i++){
        for(int j=0;j<tl;j++){
            if(s[i+j]!='?'&&s[i+j]!=t[j])break;
            if(j==tl-1) v.push_back(i);
        }
    }
    if(v.empty()){
        cout<<"UNRESTORABLE";
        return 0;
    }
    string ans="ANS";
    for(int i=0;i<v.size();i++){
        string a=s;
        for(int j=0;j<sl;j++){
            if(v[i]<=j&&j<v[i]+tl) a[j]=t[j-v[i]];
            if(a[j]=='?') a[j]='a';
        }
        if(ans=="ANS") ans=a;
        else{
            for(int j=0;j<sl;j++){
                if(ans[j]>a[j]) ans=a;
                if(ans[j]<a[j]) break;
            }
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(v) v.begin(),v.end()
#define mem(arr) memset(arr, 0, sizeof(arr))
#define ff first
#define ss second
#define int long long int
const int MOD = 1e9 + 7;
const int INF = 1e18;
const int N = 1e6 + 20;
vector<int> g[N];
vector<int> vis(N);
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tc = 1;
    while(tc--){
        int a, b;
        cin >> a >> b;
        cout << (a * b) << '\n';
    }
}

Measured memory_bytes: 34200
#include<iostream>

using namespace std;
int main()
{
	// 整数の入力
	long long n,k;
	cin >> n >> k ;
	
	long long a = n / k;
	long long b = (n + k / 2) / k;
	long long kotae=0;

	if (k % 2) {
		kotae = a * a * a;
	}
	else {
		kotae = a * a*a + b * b*b;
	}
	cout << kotae << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue> 
using namespace std;
long long b,a=1; 
int main() 
{int n;
 cin>>n;
 for (int i=1;i<=n;i++)
 a=(i*a)%1000000007; 
 cout<<a;
 system("pause");
 return 0;
}        

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

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vpint> vvpint;
typedef vector<vpll> vvpll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<string>> vvstring;
typedef vector<vector<bool>> vvbool;

typedef vector<vector<vector<ll>>> vvvll;

const int c_YET = -1;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const ll MAX = 1e9;
const double PI = 3.14159265358979323846264338327950288;
//========================================================================





int main() {

	////==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	////==================================

	string S;
	cin >> S;


	int first_C = -1;
	int last_F = -1;
	for (int i = 0; i < S.length(); i++)
	{
		if (S[i] == 'C')
		{
			first_C = i;
			break;
		}
	}

	for (int i = 0; i < S.length(); i++)
	{
		if (S[i] == 'F')
		{
			last_F = i;
		}
	}

	if (first_C != -1 && last_F != -1 && first_C < last_F)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

}





Measured memory_bytes: 256
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
#define INF (1ll<<60)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;

#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)

template<class T>bool umax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool umin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using namespace std;

// gcd
int gcd(int a, int b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}
// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);

    return result;
}

// sort big to small
// sort(A,A+N, greater<int>());

// v.front() = -BOUND;
// v.back() = BOUND;

// Iterator
// v.begin
// v.end

int main() {
    unsigned int N,D;
    int answer=0;

    cin >> D >> N;
    answer = 1;
    rep(i,D){
        answer*=100;
    }

    answer = (N==100) ? (N+1)*answer : N*answer;
    cout << answer << endl;
    return 0;
}



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

using namespace std;

typedef long long int ll;

const int MAXN = 1e5 + 5;

vector < ll > t(4 * MAXN), cst;

void build(int v, int tl, int tr){
  if(tl == tr){
    t[v] = cst[tl];
  }else{
    int tm = (tr - tl) / 2 + tl;
    build(2 * v, tl, tm);
    build(2 * v + 1, tm + 1, tr);
    t[v] = min(t[2 * v], t[2 * v + 1]);
  }
}

ll query(int v, int tl, int tr, int l, int r){
  if(r < l) return 1e17;
  if(tl == l && tr == r){
    return t[v];
  }else{
    int tm = (tr - tl) / 2 + tl;
    return min(query(2 * v, tl, tm, l, min(r, tm)), query(2 * v + 1, tm + 1, tr, max(tm + 1, l), r));
  }
}

void update(int v, int tl, int tr, int idx, ll val){
  if(tl == tr){
    t[v] = val;
  }else{
    int tm = (tr - tl) / 2 + tl;
    if(idx <= tm) update(2 * v, tl, tm, idx, val);
    else update(2 * v + 1, tm + 1, tr, idx, val);
    t[v] = min(t[2 * v], t[2 * v + 1]);
  }
}

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

  int n, m;
  cin >> n >> m;
  vector < pair < pair < ll, ll >, ll > > edges;
  for(int i = 0; i < m; i++){
    ll u, v, wt;
    cin >> u >> v >> wt;
    edges.push_back({{u, v}, wt});
  }
  sort(edges.begin(), edges.end());

  cst.assign(n + 1, 1e17);
  cst[1] = 0;
  build(1, 1, n);
  for(int i = 0; i < m; i++){
    ll l = edges[i].first.first;
    ll cst_l = query(1, 1, n, l, n);
    ll r = edges[i].first.second;
    cst[r] = min(cst[r], cst_l + edges[i].second);
    update(1, 1, n, r, cst[r]);
  }

  if(cst[n] == 1e17) cout << -1 << '\n';
  else cout << cst[n] << '\n';
}


Measured memory_bytes: 8052
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;

typedef long long ll;
#define READ(a) int a; cin >> a;
#define READARR(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define READMAT(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}
#define print(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;} cout << endl;
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll mod = 1e9 + 7;

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	READ(n);
	int a[10][10] = {};
	FOR (i, 1, n)
	{
	    string s = std::to_string(i);
	    a[s[0] - 48][s[s.size() - 1] - 48]++;
	}
	
	int sum = 0;
	FOR (i, 1, n)
	{
	    string s = std::to_string(i);
	    sum += a[s[s.size() - 1] - 48][s[0] - 48];
	}
	
	cout << sum;
}

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

#define vd vector<double>
 
typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
// #define mp make_pair
//#define endl '\n'
 
int main() {
    string s;
    cin >> s;
    string sunny = "Sunny";
    string cloudy = "Cloudy";
    string rainy = "Rainy";

    if(s == sunny){
        cout << cloudy << endl;
    }
    else if(s == cloudy){
        cout << rainy << endl;
    }
    else{
        cout << sunny << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

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

	int k, i;
	cin >> k;
	queue<string> q;
	for (i = 1; i < 10; i++) {
		if (i == k) {
			cout << i << endl;
			return 0;
		}
		q.push(to_string(i));
	}
	while (true) {
		string front = q.front();
		q.pop();
		for (int x = -1; x <= 1; x ++) {
			char back = front.back() + x;
			if (!isdigit(back))
				continue;
			string lunlun = front + back;
			if (i == k) {
				cout << lunlun << endl;
				return 0;
			}
			q.push(lunlun);
			i++;
		}
	}
}


Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,k;cin>>n>>k;
    double ans=0;
    for(int i=1;i<n+1;i++){
        int k2=i;
        double p=1;
        while(k2<k){
            p/=2;
            k2*=2;
        }
        ans+=p;
    }
    ans/=n;
    cout<<fixed<<setprecision(12)<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
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)

using ll = long long;
#define INF 1e9


int main(){
  int N, A;
  cin >> N >> A;
  vector<int> x(N+1);
  REP(i, N){
    cin >> x[i+1];
  }

  vector<vector<vector<ll>>> dp(51, vector<vector<ll>>(51, vector<ll>(52*51, 0)));
  // REP(i, N+1){
  //   dp[i][0] = 1;
  // }
  REP(i, N+1)  dp[i][0][0] = 1;
  // FOR(i, 1, N+1){
  //   FOR(j, 1, i+1){
  //     FOR(k, 0, A*(N+1)+1){
  //       FOR(l, 1, j+1){
  //         if(i > l){
  //           dp[i][l][k] +=dp[i-1][l][k];
  //         }
  //         dp[i][l][k+x[i]] += dp[i-1][l-1][k];
  //         cout << "i:" << i << " l:" << l << " k:" << k << " " << dp[i][l][k] << endl;
  //       }
  //     }
  //   }
  // }
  FOR(i, 1, N+1){
    FOR(j, 1, i+1){
      FOR(k, 0, A*(N+1)+1){
        if(i > j){
          dp[i][j][k]+= dp[i-1][j][k];
        }
        if(k-x[i] >= 0){
          dp[i][j][k] += dp[i-1][j-1][k-x[i]];
        }
      }
    }
  }

  ll ans = 0;
  FOR(i, 1, N+1){
      ans += dp[N][i][A*i];
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 55296
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define mod 1000000007
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
void yes() { cout << "Yay!" << endl; }
void no() { cout << ":(" << endl; }
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}
const int MAX = 330000;
int 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 COMB(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;
}
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug_out(T...);
}

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
struct edge { int to, cost; };
class UnionFind {
protected:
	int* par, * rank, * size;
public:
	UnionFind(unsigned int size) {
		par = new int[size];
		rank = new int[size];
		this->size = new int[size];
		rep(i, size) {
			par[i] = i;
			rank[i] = 0;
			this->size[i] = 1;
		}
	}
	int find(int n) {
		if (par[n] == n)return n;
		return par[n] = find(par[n]);
	}
	void unite(int n, int m) {
		n = find(n);
		m = find(m);
		if (n == m)return;
		if (rank[n] < rank[m]) {
			par[n] = m;
			size[m] += size[n];
		}
		else {
			par[m] = n;
			size[n] += size[m];
			if (rank[n] == rank[m])rank[n]++;
		}
	}
	bool same(int n, int m) {
		return find(n) == find(m);
	}
	int getsize(int n) {
		return size[find(n)];
	}
};
int n;
int a[114];
signed main() {
	cin >> n;
	rep(i, n)cin >> a[i];
	rep(i, n) {
		if (a[i] % 2 == 0) {
			if (a[i] % 3 != 0 && a[i] % 5 != 0) {
				puts("DENIED");
				ggr
			}
		}
	}
	puts("APPROVED");
	ggr
}


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

#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;

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

    vector<int64_t> a(n);
    for (auto&& aa : a) {
        cin >> aa;
    }

    int64_t ans = 0;
    while (true) {
        int64_t k = 0;

        for (auto&& aa : a) {
            if (aa > n - 1) {
                auto t = (aa - (n - 1) - 1) / n + 1;
                k += t;
                aa -= (n + 1) * t;
                assert(aa <= n - 1);
            }
        }
        bool ok = true;
        for (auto&& aa : a) {
            aa += k;
            if (aa > n - 1) {
                ok = false;
            }
        }

        ans += k;
        if (ok) {
            cout << ans << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
// Author: HarshKumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e6 + 6, M = 1e9 + 7;
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    ll n, m, k, ans = 0;
    cin >> n >> m >> k;
    vector<string> s(n);
    for (auto &e : s)
        cin >> e;
    for (ll i = 0; i < (1 << n); i++)
    {
        for (ll j = 0; j < (1 << m); j++)
        {
            auto t = s;
            ll c = 0;
            for (ll x = 0; x < n; x++)
                for (ll y = 0; y < m; y++)
                    if ((i & (1 << x)) || (j & (1 << y)))
                        t[x][y] = '.';
            for (ll x = 0; x < n; x++)
                for (ll y = 0; y < m; y++)
                    c += t[x][y] == '#';
            if (c == k)
                ans++;
        }
    }
    cout << ans;
}

Measured memory_bytes: 3660
def smaller(x, y):
	if x < y: return x
	return y
N = int(input())
A = list(map(int, input().split()))
colorlist = [[1, 399]]
for i in range(1, 8):
	colorlist.append([400*i, 400*(i+1)-1])
ratelist = [False, False, False, False, False, False, False, False]
overcount = 0
for i in range(0, N):
	for j in range(0, 8):
		if colorlist[j][0] <= A[i] and A[i] <= colorlist[j][1]:
			ratelist[j] = True
			break
		if j == 7: overcount += 1
min = 0
for i in range(0, 8):
	if ratelist[i]: min += 1
if min == 0:
	min = 1
	overcount -= 1
max = min + overcount
print(str(min)+' '+str(max))


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

int main() {
  char b;
  cin >> b;
  if (b == 'A')
    cout << 'T' << endl;
  else if (b == 'T') 
    cout << 'A' << endl;
  else if (b == 'G') 
    cout << 'C' << endl;
  else if (b == 'C') 
    cout << 'G' << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define dl double
using namespace std;

//***********************************************************************
int MAXNUM = 5e3+5;
vector <int>vis(MAXNUM);
vector<int> pr;
void sieve() {
	pr.push_back(2);
	for(ll i=3;i<MAXNUM;i+=2) if(!vis[i]) {
		pr.push_back(i);
		for(ll j=i*i;j<MAXNUM;j+=2*i) vis[j]=true;
	}
}
//************************************************************************
ll mod=1000000007;
ll n,k;
struct M
{
   vector<vector<ll>> t;
   M(){
       t.resize(n,vector<ll>(n));
   }
   M operator*(const M &b) const{
       M c=M();
       for(int i=0;i<n;i++)
       {
           for(int j=0;j<n;j++)
           {
               for(int k=0;k<n;k++)
               {
                   c.t[i][j]+=(t[i][k]*b.t[k][j])%mod;
                   c.t[i][j]%=mod;
               }
           }
       }
       return c;
   }
};

M matrixexpo(M m,ll k)
{
    if(k==1)
    return m;
   M u=matrixexpo(m,k/2);
   u=u*u;
   if(k%2)
   u=u*m;
   return u;
}

void solve()
{
   
    cin >> n >> k;
    vector<vector<ll>> v(n);
    //vector<vector<ll>> dp(n);
    for(ll i=0;i<n;i++)
    {
       // dp[i].resize(n+1);
        v[i].resize(n);
        for(ll j=0;j<n;j++)
        {
            cin >> v[i][j];
        }
    }
    M ans=M();
    M m=M();
    m.t=v;
    ans.t=matrixexpo(m,k).t;
    ll fans=0;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            fans+=ans.t[i][j]%mod;
            fans%=mod;
        }
    }
    cout << fans << endl;


}


int main()
{ 
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
	ll t;
	//cin >> t;
	t=1;
	while(t--)
	{
		solve();
	}

	return 0;
}

Measured memory_bytes: 1664
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

  
    public static void main(String[] args)  {

    	try{
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            String line;
            while((line=br.readLine())!=null){if(line.isEmpty())break;
	        	String[] spl = line.split(" ");
	            int n = Integer.parseInt(spl[0]);
	            if(n==0){break;}
                    while(n>0){
                        int out =0, ten=0;
                        boolean rui[] =new boolean[4];
                        while(out<3){
                            line=br.readLine();
                            if(line.equals("OUT")){out++;continue;}
                            if(line.equals("HIT")){
                                if(rui[3]==true){ten++; rui[3]=false;}
                                if(rui[2]==true){rui[3]=true; rui[2] = false;}
                                if(rui[1]==true){rui[2]=true; rui[1] = false;}
                                rui[1]=true;
                            
                            }
                            if(line.equals("HOMERUN")){
                                ten++;for(int i=1;i<=3;i++){
                                    if(rui[i]==true){rui[i]=false;ten++;}
                                }
                            }
                        }
n--;
                        System.out.println(ten);
                    }//n round pass.
                    break;
            }//End WHILE


        }catch(Exception e){e.printStackTrace();}

    }


}

Measured memory_bytes: 16900
#include<bits/stdc++.h>
constexpr long long INFL = 1LL << 60;
constexpr int INF = 1e9;

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main()
{
    int x,y;
    cin >> x >> y;
    set<int> g1 {1,3,5,7,8,10,12};
    set<int> g2 {4,6,9,11};
    set<int> g3 {2};

    if(g1.count(x) && g1.count(y)){
        cout << "Yes" << endl;
        return 0;
    }

    if(g2.count(x) && g2.count(y)){
        cout << "Yes" << endl;
        return 0;
    }
    if(g3.count(x) && g3.count(y)){
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256