akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <algorithm>
#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; }
using ll = long long;
using namespace std;

int main() {
    int n;
    cin >> n;
    
    vector<long long> h(100010);
    rep(i,n) {
     cin >> h[i];
    }
    
    
   const long long INF = 1LL << 60;
   long long dp[100010];
   
    
    for(int i = 0;i < 100010;i++) {
     dp[i] = INF;
    }
    dp[0] = 0;
    
    for(int i = 1;i<n;i++) {
     chmin(dp[i], dp[i-1]+abs(h[i] - h[i-1]));
        if(i > 1) chmin(dp[i], dp[i-2]+abs(h[i] - h[i-2]));
     }
    
    cout << dp[n-1];
}

Measured memory_bytes: 4796
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M;
  cin >> N >> M;
  vector<vector<int>> AB(N,vector<int>(2));
  for (int i=0;i<N;i++){
    cin >> AB[i][0] >> AB[i][1];
  }
  sort(AB.begin(),AB.end());
  long long ans=0;
  for (int i=0;i<N;i++){
    if (AB[i][1]<M){
      ans+=(long long)AB[i][0]*AB[i][1];
      M-=AB[i][1];
    }
    else {
      ans+=(long long)AB[i][0]*M;
      break;
    }
  }
  cout << ans << endl;
}

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

int main(){
    int N; cin >> N;
    vector<int> nums(N);
    for (int i=0; i<N; i++){
        cin >> nums.at(i);
    }
    sort(nums.begin(), nums.end());
    bool judge=true;
    if (nums.size()%2==0){//要素数が偶数だった場合
        for (int i=0; i<N-2; i+=2){
            if (nums.at(0)!=1 || nums.at(i)!=nums.at(i+1) || nums.at(i)+2!=nums.at(i+2)){
                judge=false;
                break;
            }
        }
    } else {//要素数が奇数だったとき
        for (int i=2; i<N; i+=2){
            if (nums.at(0)!=0 || nums.at(i)!=nums.at(i-1) || nums.at(i)-2!=nums.at(i-2)){
                judge=false;
                break;
            }
        }
    }
    //cout << "judge is " << judge << endl;
    if (judge){
        //long long answer=(long long)pow(2, nums.size()/2)%1000000007;
        //cout << (long long)pow(2, nums.size()/2)%1000000007 << endl;
        long long answer=1;
        for (int i=0; i<N/2; i++){
            answer*=2;
            answer%=1000000007;
        }
        cout << answer << endl;
    } else {
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 640
//https://atcoder.jp/contests/abc179/tasks/abc179_e
#include <iostream>
#include <algorithm>

using namespace std;

typedef unsigned long long ULL;

const int MAXN=1e5+4;
const int MAXM=1e5+4;
int idx[MAXM];//和位置索引
ULL sum[MAXN];//和

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

    //打表
    ULL l, r;
    for (ULL i=1, num=x; ; num=num*num%m, i++) {
        if (!idx[num]) {
            //没有计算过，标注已经计算
            idx[num]=i;
        } else {
            //数据存在
            l=idx[num];
            r=i-1;
            break;
        }
        //更新数据表
        sum[i]=sum[i-1]+num;
    }

    ULL len=r-l+1;
    ULL ans=0;
    ans+=sum[min(n, l-1)];
    
    n=max(0ULL, n-l+1);
    if (n) {
        ans+=(sum[r]-sum[l-1])*(n/len)+(sum[n%len+l-1]-sum[l-1]);
    }

    cout<<ans<<"\n";

    return 0;
}

Measured memory_bytes: 4304
#include "bits/stdc++.h"
using namespace std;

// Inserted snippets: io, opt, root
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }
#pragma GCC optimize("O3")
#pragma GCC target("avx2")
// End snippets

const ll inf = 0x3f3f3f3f3f3f3f3fll;

int n;
ll x[15], y[15], p[15];

ll _rev_x[20010], _rev_y[20010];
ll dp_x[1 << 15][15], dp_y[1 << 15][15];
ll ans[16];
int opt[15];

void dfs(int d) {
  if (d == n) {
    int cnt = 0, mask_x = 0, mask_y = 0;
    rep(i, 0, n) {
      if (opt[i]) cnt++;
      if (opt[i] == 1) mask_x |= 1 << i;
      if (opt[i] == 2) mask_y |= 1 << i;
    }
    ll val = 0;
    rep(i, 0, n) val += p[i] * min(dp_x[mask_x][i], dp_y[mask_y][i]);
    chmin(ans[cnt], val);
    return;
  }

  rep(i, 0, 3) {
    opt[d] = i;
    dfs(d + 1);
  }
}

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

  read(n);
  rep(i, 0, n + 1) ans[i] = inf;
  rep(i, 0, n) read(x[i], y[i], p[i]);

  rep(i, 0, 1 << n) {
    vector<int> vx;
    vx.push_back(0);
    rep(j, 0, n) if (i >> j & 1) {
      vx.push_back(x[j]);
    }
    sort(all(vx));

    int p = 0;
    rep(j, 0, n) {
      dp_x[i][j] = inf;
      auto it = lower_bound(all(vx), x[j]);
      if (it != vx.end()) chmin(dp_x[i][j], *it - x[j]);
      if (it != vx.begin()) { --it; chmin(dp_x[i][j], x[j] - *it); }
    }
  }

  rep(i, 0, 1 << n) {
    vector<int> vy;
    vy.push_back(0);
    rep(j, 0, n) if (i >> j & 1) {
      vy.push_back(y[j]);
    }
    sort(all(vy));

    int p = 0;
    rep(j, 0, n) {
      dp_y[i][j] = inf;
      auto it = lower_bound(all(vy), y[j]);
      if (it != vy.end()) chmin(dp_y[i][j], *it - y[j]);
      if (it != vy.begin()) { --it; chmin(dp_y[i][j], y[j] - *it); }
    }
  }

  dfs(0);

  rep(i, 0, n + 1)
    write(ans[i]);
}


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

#define ll long long int
void insertionSort(int arr[], int n)
{
   int i, key, j;
   for (i = 1; i < n; i++)
   {
       key = arr[i];
       j = i-1;

       while (j >= 0 && arr[j] > key)
       {
           arr[j+1] = arr[j];
           j = j-1;
       }
       arr[j+1] = key;
   }
}
int binarySearch(int arr[], int l, int r, int x)
{
   if (r >= l)
   {
        int mid = l + (r - l)/2;

        // If the element is present at the middle
        // itself
        if (arr[mid] == x)
            return mid;

        // If element is smaller than mid, then
        // it can only be present in left subarray
        if (arr[mid] > x)
            return binarySearch(arr, l, mid-1, x);

        // Else the element can only be present
        // in right subarray
        return binarySearch(arr, mid+1, r, x);
   }

   // We reach here when element is not
   // present in array
   return -1;
}

int gcd(int u, int v)
{
    return (v != 0) ? gcd(v, u % v) : u;
}

int cdig(int b)
{
    int a=b;
    int count=0;
    while(a)
    {
        a=a/10;
        count++;
    }
    return count;
}

int dig_sum(int a)
{
    int b,sum=0;
    while(a)
    {
        sum=sum+a%10;
        a=a/10;
    }
    return sum;
}

int abs(int a)
{
    if(a<0)
    {
        a=a*(-1);
        return a;
    }
    return a;
}

int ar_to_num(int ar[],int n)
{
    int sum=0;
    for(int i=0,j=n-1;i<n;i++,j--)
    {
        sum=sum+(ar[i]*pow(10,j));
    }
    return sum;
}

int pow(int a,int n)
{
    if(n==0)
        return 1;
    int b=1;
    for(int i=0;i<n;i++)
        b*=a;
    return b;
}
void get_ar(int a,int ar[])
{
    for(int i=0;i<a;i++)
        cin>>ar[i];
}


int main()
{
    int n;
    cin>>n;
    string s[n];
    for(int i=0;i<n;i++)
    {
        cin>>s[i];
    }
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            if(s[i]==s[j])
            {
                cout<<"No";
                return 0;
            }
        }
    }
    for(int i=0;i<n-1;i++)
    {
        if(s[i].at(s[i].size()-1)!=s[i+1].at(0))
        {
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double r = sc.nextDouble();
        double pi = Math.PI;
        double area = r*r*pi;
        double length = 2*r*pi;
        System.out.printf("%f %f", area, length);
    }
}


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

int main() {
string ans;
vector<int> A(3);
  for(int i=0; i<3;i++){
    cin>>A.at(i);}
  
  sort(A.begin(),A.end());
  A.at(0)==5 && A.at(1)==5 && A.at(2)? ans="YES":ans="NO";
	
	cout<<ans<<endl;
}


Measured memory_bytes: 256
import sys
X, N = map(int, input().split())
P = list(map(int, input().split()))

abs_list = []

if N == 0:
    print(X)
    sys.exit()

for i in range(0,150):
    j,k = abs(X - i), X +i
    if j not in P:
        print(j)
        break
    if k not in P:
        print(k)
        break

Measured memory_bytes: 9128
n=int(input())
t=list(map(int,input().split()))
m=int(input())
px=[map(int, input().split()) for _ in range(m)]
p,x=[list(i) for i in zip(*px)]
total=sum(t)

for i in range(m):
    print(total-t[p[i]-1]+x[i])

Measured memory_bytes: 3064
// C - Good Sequence
#include <bits/stdc++.h>
using namespace std;
int C[100001];

int main(){
	int N; cin>>N;
	int n = N, ans = 0;
	while(n--){
		int a; scanf("%d",&a);
		ans++;
		if(a <= N)
			if(++C[a] == a) ans -= a;
	}
	cout<< ans <<endl;
}

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

using namespace std;
typedef long long ll;

int main() {
    ll a;
    string b;
    cin >> a >> b;
    ll c = 0;
    for (int i = 0; i < 4; i++) {
        if (i == 1)continue;
        c = c * 10 + b[i] - '0';
    }
    cout << a * c / 100 << endl;
    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define int long long

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

  int N,A,B,C; cin >> N >> A >> B >> C;
  vector<int> L(N);
  for(int i = 0; i < N; i++){
    cin >> L[i];
  }

  function<int(int,int,int,int)> dfs =
  [&](int i,int a,int b,int c){
    if(i == N){
      if(!a || !b || !c) return 1LL << 60;
      return abs(a-A) + abs(b-B) + abs(c-C);
    }
    int res = 1LL << 60;
    res = min(res,dfs(i+1,a,b,c));
    res = min(res,dfs(i+1,a + L[i],b,c) + (a ? 10 : 0));
    res = min(res,dfs(i+1,a,b + L[i],c) + (b ? 10 : 0));
    res = min(res,dfs(i+1,a,b,c + L[i]) + (c ? 10 : 0));
    return res;
  };
  cout << dfs(0,0,0,0) << endl;

  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cerr << #x << " = " << (x) << endl;
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = (int)1e9;
const double pi = acos(-1.0);
template <class A>ostream & operator<<(ostream & o, const vector<A> & p) { o << "{"; for (int i = 0; i < (int)p.size(); ++i)o << (i > 0 ? ", " : "") << p[i]; o << "}"; return o; }
template <class A, class B>ostream & operator<<(ostream & o, const pair<A, B> & p) { o << "{" << p.first << ", " << p.second << "}"; return o; }
template <class A, class B>ostream& operator<<(ostream & o, const map<A, B> & p) { o << "{"; for (auto it = p.begin(); it != p.end(); ++it) o << (it != p.begin() ? ", " : "") << *it; o << "}"; return o; }
template <class A>ostream & operator<<(ostream & o, const set<A> & p) { o << "{"; for (auto it = p.begin(); it != p.end(); ++it) o << (it != p.begin() ? ", " : "") << *it; o << "}"; return o; }
void print() { cerr << endl; }
template <class H> void print(H && h) { cerr << h << endl; }
template <class H, class... T> void print(H && h, T && ... t) { cerr << h << " "; print(forward<T>(t)...); }

//最大公約数
long long gcd(long long n, long long m) {
	return m == 0 ? n : gcd(m, n % m);
}
//最小公倍数
long long lcm(long long n, long long m) {
	return n / gcd(n, m) * m;
}

int main() {
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	int a = abs(A - C), b = abs(B - D);

	cout << ((a / gcd(a, b) + b / gcd(a, b) - 1) * gcd(a, b)) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;

int n;
int l[25], r[25], parent[25];

int sib(int i){
	if(parent[i] == -1) return -1;
	int j = parent[i];
	if(l[j] == i) return r[j];
	else return l[j];
}

int deg(int i){ //子の個数
	return (int)(l[i] != -1) + (int)(r[i] != -1);
}

int dep(int i){
	if(parent[i] == -1) return 0;
	return dep(parent[i]) + 1;
}

int hei(int i){
	if(i == -1) return -1;
	return max(hei(l[i]), hei(r[i])) + 1;
}

int main(){
	cin >> n;
	for(int i=0; i<n; i++) parent[i] = -1;
	for(int i=0; i<n; i++){
		int id;
		cin >> id;
		cin >> l[id] >> r[id];
		parent[l[id]] = id;
		parent[r[id]] = id;
	}
	for(int i=0; i<n; i++){
		cout << "node " << i;
		cout << ": parent = " << parent[i];
		cout << ", sibling = " << sib(i);
		cout << ", degree = " << deg(i);
		cout << ", depth = " << dep(i);
		cout << ", height = " << hei(i);
		if(parent[i] == -1) cout << ", root" << endl;
		else if(l[i] == -1 && r[i] == -1) cout << ", leaf" << endl;
		else cout << ", internal node" << endl;
	}
	
	return 0;
}

/*

int n;
int parent[100000];
vector<int> child[100000];
int dp[100000] = {};

int depth(int i){
	//if(dp[i] != 0) return dp[i];
	if(parent[i] == -1) return 0;
	return dp[i] = depth(parent[i]) + 1;
}

int main(){
	cin >> n;
	for(int i=0; i<n; i++) parent[i] = -1;
	for(int i=0; i<n; i++){
		int id,k;
		cin >> id >> k;
		for(int j=0; j<k; j++){
			int c;
			cin >> c;
			child[id].push_back(c);
			parent[c] = id;
		}
	}

	for(int i=0; i<n; i++){
		cout << "node " << i << ": ";
		cout << "parent = " << parent[i] << ", ";
		cout << "depth = " << depth(i) << ", ";
		if(parent[i] == -1) cout << "root, ";
		else if(child[i].size() > 0) cout << "internal node, ";
		else cout << "leaf, ";
		cout << "[";
		for(int j=0; j<child[i].size(); j++){
			if(j != 0) cout << ", ";
			cout << child[i][j];
		}
		cout << "]" << endl;
	}
}

*/


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second
const int INF = 987654321;
const int MOD = (int)1e9+7;
//const long double PI = (acos(-1));
//const long double EPS = 0.0000000001;

ll n,k;
vl a;

bool can(int cand) {
	//cout << cand << endl;
	vl na = a;
	ll nk = 0;

	rep(i,0,n) {
		na[i] %= cand;
	}

	sort(all(na));

	/*rep(i,0,n) {
		cout << na[i] << ' ';
	}
	cout << endl;*/

	int i = 0;
	int j = n-1;
	while(i < j) {
		if(na[i]%cand == 0) {
			i++;
			continue;
		} else if(na[j] % cand == 0) {
			j--;
			continue;
		}

		int x = na[i];
		int y = abs(cand-na[j]);
		if(x == y) {
			nk += x;
			na[i] -= x;
			na[j] += y;
			i++;
			j--;
		} else if (x < y) {
			nk += x;
			na[i] -= x;
			na[j] += x;
			i++;
		} else {
			nk += y;
			na[i] -= y;
			na[j] += y;
			j--;
		}
	}

	/*rep(i,0,n) {
		cout << na[i] << ' ';
	}
	cout << endl;
	cout << nk << endl;*/
	if(na[i] % cand > 0 || na[j] % cand > 0) {
		return false;
	}
	if (nk <= k) {
		return true;
	} else {
		return false;
	}
}

int main(void) {
	ios_base::sync_with_stdio(false); 
	cin.tie(0); 
	cout.tie(0);
	//freopen("in.txt", "r", stdin);
	cin >> n >> k;
	a.resize(n);
	ll A = 0;
	rep(i,0,n) {
		cin >> a[i];
		A += a[i];
	}
	ll limit = sqrt(A);

	ll ret = 0;
	for(int i=1; i<=limit; ++i) {
		if(A%i) {
			continue;
		}
		if(can(A/i)) {
			ret = A/i;
			break;
		}
		if(can(i)) {
			ret = i;
		}
	}
	cout << ret << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long x,ans=0,now=0;
	cin>>x;
	while(pow(2,now)<=x)
		now++;
	for(int i=0;i<now;i++)
		ans+=pow(2,i);
	cout<<ans; 
	return 0;
}

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

yen9=[9**i for i in range(6)]
yen6=[6**i for i in range(7)]
memo = {}

def withdraw_times(n):
  if n in memo:
    return memo[n]
  if n ==0:
    return 0

  maxmoney9 = 0
  maxmoney6 =0
  for i in range(6):
    if yen9[i] <= n:
      maxmoney9 = max(yen9[i],maxmoney9)
      
  for i in range(7):
    if yen6[i] <= n:
      maxmoney6 = max(yen6[i],maxmoney6)
      
  memo[n] =  min(withdraw_times(n-maxmoney6),withdraw_times(n-maxmoney9))+1
  return memo[n]

print(withdraw_times(n))



Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define sz(x) ((int) (x).size())
#define forn(i,n) for (int i = 0; i < int(n); ++i)
typedef long long ll;
typedef long long i64;
typedef long double ld;
const int inf = int(1e9) + int(1e5);
const ll infl = ll(2e18) + ll(1e10);

int main() {
    #ifdef LOCAL
    assert(freopen("g.in", "r", stdin));
    #else
    #endif
    int n, q;
    cin >> n >> q;
    vector<int> p(n);
    vector<bool> can(n, false);
    can[0] = true;
    can[1] = true;
    iota(p.begin(), p.end(), 0);

    int x = 0;
    forn (i, q) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        if (a == x || b == x)
            x ^= a ^ b;
        swap(p[a], p[b]);
        assert(p[x] == 0);

        if (x > 0)
            can[p[x - 1]] = true;
        if (x + 1 < n)
            can[p[x + 1]] = true;
    }
    int res = accumulate(can.begin(), can.end(), 0);
    cout << res << '\n';
}


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

const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

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

  vector<int>p(N);
  rep(i,N) cin >> p[i];

  sort(p.begin(), p.end());

  ll ans = 0;
  rep(i,K){
    ans += p[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <vector>

using namespace std;

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

    if (k % 2 == 0 || k % 5 == 0)
    {
        cout << -1 << endl;
        return 0;
    }

    int cnt = 1;
    int a = 7;
    while (k > 0)
    {
        int x = a % k;

        if (x == 0)
        {
            break;
        }
        else
        {
            cnt++;
            a = x * 10 + 7;
        }
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
#define MAX 1000000000
int main()
{
    int n,k,s,i,m,a,b;
    cin>>n>>k>>s;
    for(i=1;i<=k;i++)
        cout<<s<<" ";
    for(i=k+1;i<=n;i++)
    {
        if(MAX==s)
            cout<<MAX-1<<" ";
        else
        cout<<MAX<<" ";
    }
    cout<<endl;
}


Measured memory_bytes: 1280
def check(x,j=1):
    if sum(x)==0: return True
    for i in range(j,10):
        y = x[:]
        if y[i]>=3:
            y[i] -= 3
            if check(y,i): return True
        y = x[:]
        if i<8 and y[i]>0 and y[i+1]>0 and y[i+2]>0:
            y[i] -= 1
            y[i+1] -= 1
            y[i+2] -= 1
            if check(y,i): return True
    return False

while True:
    c = [0]*10
    try:
        for e in map(int,raw_input()):
            c[e] += 1
    except:
        break

    f = False
    for i in range(1,10):
        c1=c[:]
        if c1[i]>=4: continue
        else: c1[i]+=1
        atama = [j for j,e in enumerate(c1) if e>=2]
        for e in atama:
            c1[e]-=2
            if check(c1):
                f = True
                print i,
                break
            c1[e]+=2
    if f: print
    else: print 0

Measured memory_bytes: 4276
#include<bits/stdc++.h>
using namespace std;
const int MN=260000;
int x[520][520];
int cnt[MN][4];
int main(){
	int n,m;
	cin>>n>>m;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			cin>>x[i][j];
		}
	}
	int res=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<m-1;j++){
			if(x[i][j]%2==1){
				x[i][j]--;
				x[i][j+1]++;
				cnt[res][0]=i;
				cnt[res][1]=j;
				cnt[res][2]=i;
				cnt[res][3]=j+1;
				res++;
			}
		}
	}
	int ax=m-1;
	for(int i=0;i<n-1;i++){
		if(x[i][ax]%2==1){
			x[i][ax]--;
			x[i+1][ax]++;
			cnt[res][0]=i;
			cnt[res][1]=ax;
			cnt[res][2]=i+1;
			cnt[res][3]=ax;
			res++;
		}
	}
	cout<<res<<endl;
	for(int i=0;i<res;i++){
		cout<<cnt[i][0]+1<<" "<<cnt[i][1]+1<<" "<<cnt[i][2]+1<<" "<<cnt[i][3]+1<<endl;
	}
	return 0;
}

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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define for_each(e, v) for (auto &e : v)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
const int MOD = 1e9 + 7;
const int INF = __INT_MAX__;               // 2^31 - 1
const long long INFLL = __LONG_LONG_MAX__; // 2^61 - 1
const int MAX_N = 1e5 + 5;
const double PI = acos(-1);

int main() {
    int n;
    cin >> n;
    vi x(n), y(n), h(n);
    rep(i, n) cin >> x[i] >> y[i] >> h[i];
    int ax, ay, ah;
    auto f = [](int x1, int x2, int y1, int y2) {
        return abs(x1 - x2) + abs(y1 - y2);
    };
    rep(xn, 101) {
        rep(yn, 101) {
            bool ok = true;
            int idx = 0;
            while (h[idx] == 0)
                idx++;
            int h_condidate = f(xn, x[idx], yn, y[idx]) + h[idx];
            rep(i, n) {
                int dist = f(xn, x[i], yn, y[i]);
                if (max(0, h_condidate - dist) != h[i])
                    ok = false;
            }
            if (ok)
                ax = xn, ay = yn, ah = h_condidate;
        }
    }
    cout << ax << ' ' << ay << ' ' << ah << endl;
    return 0;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/diverta2019/tasks/diverta2019_b

#include "algorithm"
#include "functional"
#include "iostream"
#include "numeric"
#include "queue"
#include "set"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define fi first
#define se second
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

void solve() {
  ll R, G, B, N;
  cin >> R >> G >> B >> N;

  ll res = 0;

  rep(r, (N / R) + 1) {
    ll rest = N - r * R;

    rep(g, (rest / G) + 1) {
      ll b_ct = N - r * R - g * G;
      if (b_ct % B == 0) res++;
    }
  }

  cout << res << endl;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define ff first
#define ss second
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
int main()
{
    ll n,k;
    cin>>n>>k;
    vector<ll> arr(n);
    for(ll i=0;i<n;i++)
        cin>>arr[i];
    sort(arr.begin(),arr.end());
    ll ans=0;
    for(ll i=0;i<k;i++)
        ans+=arr[i];
    cout << ans << endl;
}

Measured memory_bytes: 3632
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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;}

const ll INF=1e9+7;

int main(){
    ll n;
    cin >> n;
    vector<ll> t(n);
    ll ans=0;
    rep(i,n){
        cin >> t[i];
        ans+=t[i];
    }
    ll m;
    cin >> m;
    rep(i,m){
        ll p,x;
        cin >> p >> x;
        p--;
        cout << ans-t[p]+x << endl;
    }
    return 0;
}


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

namespace _1179
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            for (int i = 0; i < n; i++)
            {
                int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
                int ret = 0;
                while (x[0] < 1000)
                {
                    if (x[0] % 3 != 0 && x[1] % 2 == 0 && x[2] > 19)
                    {
                        x[1]++;
                        x[2] = 1;
                    }
                    else if ((!(x[0] % 3 != 0 && x[1] % 2 == 0)) && x[2] > 20)
                    {
                        x[1]++;
                        x[2] = 1;
                    }
                    if (x[1] > 10)
                    {
                        x[0]++;
                        x[1] = 1;
                    }
                    x[2]++;
                    ret++;
                }
                Console.WriteLine(ret - 1);
            }
        }
    }
}


Measured memory_bytes: 9592
#include <stdio.h>
int gcd(int,int);
int gcd(int x,int y){
  int d;
    
    d=x%y;
    while(d!=0){
        x=y;
        y=d;
        d=x%y;
      
    }
    return y;
}
int main(){
    int x,y,z;
    scanf("%d%d",&x,&y);
    if(x>y){
    z=gcd(x,y);
    }else{
      z=gcd(y,x);
    }
    printf("%d\n",z);
    return 0;
}


Measured memory_bytes: 2044
#include<stdio.h>
#include<string.h>
#include<math.h>
int main(void)
{
  int a,s[1001],d,f,g,h,i,j;
  char z[1001][1001],x[1001];
  d=0;
  scanf("%d",&a);
  for(i=0;i<a;i++){
    scanf("%s %d",z[i],&s[i]);
    d+=s[i];
  }
  scanf("%s",x);
  for(i=0;i<a;i++){
    d-=s[i];
    if(strcmp(z[i],x)==0) break;
  }
  printf("%d\n",d);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 998244353;
const ld PI = acosl(-1);

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

    int N, Q;
    cin >> N >> Q;

    set<pii> st1, st2;
    st1.insert({N - 1, N - 1});
    st2.insert({N - 1, N - 1});
    ll now = (ll)(N - 2) * (N - 2);
    int r = N - 1, b = N - 1;
    for (int i = 0; i < Q; ++i) {
        int a, x;
        cin >> a >> x;
        x--;
        if (a == 1) {
            now -= st1.upper_bound({x, 0})->second - 1;
            if (x < r) {
                r = x;
                st2.insert({b, x});
            }
        } else {
            now -= st2.upper_bound({x, 0})->second - 1;
            if (x < b) {
                b = x;
                st1.insert({r, x});
            }
        }
    }

    cout << now << endl;

    return 0;
}


Measured memory_bytes: 12980
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using i64 = int64_t;
using f80 = __float80;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

void Main()
{
  i64 N, M;
  cin >> N >> M;
  vvi B;
  i64 a,b;
  rep(i,M){
    cin >> a >> b;
    a--;
    b--;
    vi x;
    x.emplace_back(a);
    x.emplace_back(b);
    B.emplace_back(x);
  }
  sort(rng(B));
  sort(rng(B),[](const vi &a, const vi &b){return a[1]<b[1];});
  i64 x = -1;
  i64 ans = 0;
  for(auto &p:B){
    if(p[0]>x){
      x = p[1]-1;
      ans++;
    }
  }
  cout << ans << "\n";

}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}

Measured memory_bytes: 6708
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define INF 100000000000000

int main() {
    int N, M, P;
    cin >> N >> M >> P;
    vector<int>A(M);
    vector<int>B(M);
    vector<int>C(M);
    for (int i = 0; i < M; ++i) {
      cin >> A[i] >> B[i] >> C[i];
    }
    for (int i = 0; i < M; ++i) {
        C[i] = P - C[i]; // コスト
    }

    // 負閉路検出用に頂点Nに到達可能な点をdfsで求める
    vector<int> onTheWay(N+1, 0); //  1なら到達可能, 1-indexed
    stack<int> st;
    vector<vector<int>> revGraph(N+1, vector<int>()); // 逆向きグラフ
    for (int i = 0; i < M; ++i) {
        revGraph[B[i]].push_back(A[i]);
    }
    st.push(N);
    onTheWay[N] = 1;
    while (! st.empty()){
        int t = st.top();
        st.pop();
        for (int x : revGraph[t]) {
            if(onTheWay[x] == 0){
                onTheWay[x] = 1;
                st.push(x);
            }
        }
    }

    // Bellman–Ford
    vector<ll>dist(N+1, INF); // i-indexed
    dist[1] = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < M; ++j) {
            if(dist[A[j]] != INF && dist[B[j]] > dist[A[j]] + C[j]){
                dist[B[j]] = dist[A[j]] + C[j];
                if(i == N-1 && onTheWay[B[j]] == 1){
                    cout << -1;
                    return 0;
                }
            }
        }
    }
    dist[N] *= -1;
    if(dist[N] < 0) dist[N] = 0;
    cout << dist[N];
    return 0;
}

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

struct Edge {
    ll dst, weight;
};

const ll MAX_V = 1.0e5 + 10;
vector<Edge> G[MAX_V];
ll V, M;
ll L[MAX_V], R[MAX_V], C[MAX_V];

ll d[MAX_V];
const ll INF = 1.0e15;

void dijkstra(int s) {
    priority_queue<P, vector<P>, greater<P> > que;
    //priority_queue<P> que;
    fill(d, d+V, INF);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;

        for (int i = 0; i < G[v].size(); i++) {
            Edge e = G[v][i];
            if (d[e.dst] > d[v] + e.weight) {
                d[e.dst] = d[v] + e.weight;
                que.push(P(d[e.dst], e.dst));
            }
        }
    }
}



int main() {
    cin >> V >> M;

    for (int i = 0; i < V-1; i++) {
        Edge e = {i, 0};
        G[i+1].push_back(e);
    }

    for (int i = 0; i < M; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        Edge e_a = {b-1, c};
        G[a-1].push_back(e_a);
    }

    dijkstra(0);

    if (d[V-1] >= INF) cout << -1 << endl;
    else cout << d[V-1] << endl;

    return 0;
}


Measured memory_bytes: 11256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <array>
#include <algorithm>
#include <utility>
#include <numeric>


using namespace std;


template <class ...Args>
void Input(Args &...args)
{
	(cin >> ... >> args);
}

template <class T>
void InputArray(std::size_t size, T &t)
{
	t.resize(size);
	for (auto &e : t) {
		cin >> e;
	}
}

template <class ...Args>
void InputArray(std::size_t size, Args &...args)
{
	(InputArray(size, args), ...);
}

template <class ...Args>
void InputVerticalArray(std::size_t size, Args &...args)
{
	(args.resize(size), ...);
	for (int i = 0; i < size; i++) {
		((cin >> args[i]), ...);
	}
}

template <class ...Args>
void Output(const Args &...args)
{
	((cout << args << ' '), ...) << endl;
}

template <class ...Args>
void OutputVertical(const Args &...args)
{
	((cout << args << endl), ...);
}

template <class T>
void OutputArray(const T &t)
{
	for (const auto &e : t) {
		cout << e << ' ';
	}
	cout << endl;
}

template <class ...Args>
void OutputArray(const Args &...args)
{
	(OutputArray(args), ...);
}

template <class ...Args>
void OutputVerticalArray(const Args &...args)
{
	for (int i = 0; i < min({ args.size()... }); i++) {
		((cout << args[i] << ' '), ...) << endl;
	}
}


#define inp(type, ...) \
	type __VA_ARGS__; \
	Input(__VA_ARGS__)

#define inpa(type, size, ...) \
	type __VA_ARGS__; \
	InputArray((size), __VA_ARGS__)

#define inpva(type, size, ...) \
	type __VA_ARGS__; \
	InputVerticalArray((size), __VA_ARGS__)

#define otp(...) \
	Output(__VA_ARGS__)

#define otpv(...) \
	OutputVertical(__VA_ARGS__)

#define otpa(...) \
	OutputArray(__VA_ARGS__)

#define otpva(...) \
	OutputVerticalArray(__VA_ARGS__)

#define rep(counter, range) \
	for (int (counter) = 0; (counter) < (range); (counter)++)

#define repi(range) \
	rep(i, range)

#define rrep(counter, range) \
	for (int (counter) = (range) - 1; (counter) >= 0; (counter)--)

#define rrepi(range) \
	rrep(i, range)

#define repc(element, container) \
	for (auto &(element) : (container))

#define repe(container) \
	repc(e, container)

#define all(container) \
	(container).begin(), (container).end()

#ifdef __CCR__
#	define dlog(x) clog << #x " = " << x << endl
#else
#	define dlog(x)
#endif



int main()
{
	inp(int, n);
	inpva(vector<int>, n, d1, d2);
	
	int count = 0;
	repi(n) {
		if (d1[i] == d2[i]) {
			if (++count >= 3) {
				otp("Yes");
				return 0;
			}
		}
		else {
			count = 0;
		}
	}
	
	otp("No");
	
	return 0;
}


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

using namespace std;
using ll = long long;

int main() {
    int l,r,d = 0;
    cin >> l >> r >> d;
    int sum = 0;
    for(int i = l;i <= r;i++){
        if(i % d == 0){
            sum++;
        }
    }

    cout << sum <<endl;
    return 0;
}

Measured memory_bytes: 3600
n = int(input())
a = list(map(int,input().split()))
MOD = 10**9+7

arr = []
if n%2==0:
    for i in range(1,n,2):
        arr += [i,i]
else:
    arr += [0]
    for i in range(2,n,2):
        arr += [i,i]

if sorted(a)!=sorted(arr):
    print(0)
    exit()

print(pow(2,n//2,MOD))


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

long long mod = 1000000007;

int main() {
	int n;  cin >> n;
	long long ans = 1;
	for(int i = 1; i <= n; i++) {
		ans = i * ans;
		ans %= mod;
	}
	cout << ans << "\n";
}

Measured memory_bytes: 3636
n = int(input())
a = list(map(int,input().split()))
mod = 10**9 + 7
nisi = [0 for i in range(60)]
for i in range(n):
    for j in range(60):
        if (a[i] >> j) & 1 == 1:
            nisi[j] += 1
ans = 0
for i in range(60):
    ans += pow(2,i,mod)*nisi[i]*(n-nisi[i])%mod
ans %= mod
print(ans)

Measured memory_bytes: 122808
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>

//#include<bits/stdc++.h>


using namespace std;



int main() {
	
	int n, k;
	cin >> n >> k;
	
	long long int ans = 0;
	priority_queue<pair<int, int>>t;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		t.push(make_pair(a,1));
	}
	for (int i = 0; i < k; i++) {
		int b, c;
		cin >> b >> c;
		t.push(make_pair(c,b));
	}
	for (int i = 0; i < n; i++) {
		int x, y;
		x = t.top().first;
		y = t.top().second;
		ans += x;
		t.pop();
	//	cout << x << endl;
		y--;
		if (y) {
			t.push(make_pair(x, y));
		}
	}
	cout << ans << endl;
	return 0;


}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define INF 1e9
typedef long long ll;
typedef pair<int, int> P;

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

int gcd(vector<int>a) {
  int ans = a[0];
  for (int i=1; i<a.size(); i++) {
    ans = gcd(ans, a[i]);
  }
  return ans;
}

int main() {
    int n, X;
    cin >> n >> X;
    vector<int> x(n), y(n);
    rep(i, n) cin >> x[i];
    rep(i, n) y[i] = abs(x[i]-X);

    if (n == 1) {
        cout << abs(x[0]-X) << endl;
        return 0;
    }

    int ans;
    ans = gcd(y);
    cout << ans << endl;

}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
 
using namespace std;
 
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define forab(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ford(i, n) for (int i = int(n) - 1; i >= 0; --i)
#define sz(c) int((c).size())
#define all(c) (c).begin(), (c).end()
#define mp(x, y) make_pair(x, y)
#define pb push_back
#define fst first
#define snd second
 
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;
using vvi = vector<vi>;
 
#define FILE_NAME "a"
 
ll n;

bool read() {
    if (!(cin >> n)) {
        return 0;
    }
    return 1;
}
 
void solve() {
    int ans = 1;
   
    int cnt = 0;

    vll s(9);
    iota(all(s), 1);
    vi sum(9);
    iota(all(sum), 1);

    while (*min_element(all(s)) <= n)
    {
        forn (i, 9) if (s[i] <= n)
            ans = max(ans, sum[i]);

        for (ll &x : s)
            x = 10 * x + 9;
        for (int &x : sum)
            x += 9;
    }

    cout << ans << endl;
}
 
int main() {
#ifdef LOCAL
    freopen(FILE_NAME ".in", "r", stdin);
//    freopen(FILE_NAME ".out", "w", stdout);
#endif
 
    while (read()) {
        solve();
    }
 
    return 0;
}


Measured memory_bytes: 764
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>
#include <cstring>
#include <iomanip>
#include<queue>
#include<set>
#include<stack>

using namespace std;
#define REP(i,k,n) for(int i=k;i<n;i++)
 
#define INF 1000000000
typedef unsigned long long  ll;

#define MOD 1000000007



int main()
{
	int H,W,N;
	cin>>H>>W>>N;

	if(H>W){
		if(N%H==0){
			cout<<N/H<<endl;
		}else{
			cout<<N/H+1<<endl;
		}
	}else{
		if(N%W==0){
			cout<<N/W<<endl;
		}else{
			cout<<N/W+1<<endl;
		}
	}
	return 0;
	
}

Measured memory_bytes: 256
import java.util.*;
import java.awt.*;

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

    int N = sc.nextInt();
    int[] A = new int[N];
    for (int i = 0; i < N; i++) {
      A[i] = sc.nextInt();
    }

    long ans = 0;
    int prev_a = -1;

    for (int i = N-1; i >= 0; i--) {
      if (A[i] >= prev_a - 1 && A[i] <= i) {
        if (A[i] > prev_a - 1) {
          ans += A[i];
        }
        prev_a = A[i];
      } else {
        ans = -1;
        break;
      }
    }

    System.out.println(ans);
  }
}


Measured memory_bytes: 85692
object Main extends App{
  import scala.io.StdIn.readLine
  
  val x = readLine.split(" ")(2).toInt
  val gates = readLine.split(" ").map(_.toInt)
  val tozero = gates.filter(_ < x).length
  
  println(List((gates.length - tozero),tozero).min.toString)
}


Measured memory_bytes: 54880
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll INF=mod*mod;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 ll gcd(ll m,ll n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
ll lcm(ll a,ll b){
  ll g=gcd(a,b);
  return a/gcd(a,b)*b;
		

}
int main(){
  
  ll N,M;
  cin>>N>>M;
  
  ll m=M/2;
  
  cout<<min(N,m)+((m-min(N,m)+2)/2)-1<<endl;
}
    

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

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

    pair<pair<string, long>, long> rest[110];
    for (long i = 0; i < n; i++) {
        string name;
        long point;
        cin >> name >> point;
        rest[i] = make_pair(make_pair(name, -point), i + 1);
    }

    sort(rest, rest + n);
    for (long i = 0; i < n; i++) {
        cout << rest[i].second << endl;
    }

}


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

int dp[501][501];
bool field[501][501];

int main() {
    for(int N; cin >> N, N; ) {
        fill(dp[0], dp[501], 0);
        fill(field[0], field[501], 0);
        int W, H; cin >> W >> H;
        while(N--) {
            int X, Y; cin >> X >> Y;
            field[Y][X] = true;
        }
        for(int x = 1; x <= W; x++) {
            for(int y = 1; y <= H; y++) {
                dp[y][x] = dp[y - 1][x] + dp[y][x - 1] - dp[y - 1][x - 1] + field[y][x];
            }
        }
        int S, T; cin >> S >> T;
        int res = 0;
        for(int x = S; x <= W; x++) {
            for(int y = T; y <= H; y++) {
                res = max(res, dp[y][x] - dp[y - T][x] - dp[y][x - S] + dp[y - T][x - S]);
            }
        }
        cout << res << endl;
    }
}

Measured memory_bytes: 2384
#include <stdio.h>
#include <utility>
#include <set>
typedef long long ll;
using namespace std;

int main(void) {
  ll i, j, k, h, w, n, a, b, sum = 0;
  scanf("%lld%lld%lld", &h, &w, &n);
  set< pair<ll, ll> > s[9];
  for(i = 0; i < n; ++i) {
    scanf("%lld%lld", &a, &b);
    pair<ll, ll> p;
    for(j = 0; j < 9; ++j) if(a - j / 3 > 0 && b - j % 3 > 0 && a - j / 3 + 2 <= h && b - j % 3 + 2 <= w) {
      p = {a - j / 3, b - j % 3};
      bool b = true;
      for(k = 0; k < 8; ++k) if(s[k].find(p) != s[k].end()) {
        b = false;
        s[k].erase(s[k].find(p)), s[k + 1].insert(p);
        break;
      }
      if(b) s[0].insert(p);
    }
  }
  for(i = 0; i < 9; ++i) sum += s[i].size();
  printf("%lld\n", (h - 2) * (w - 2) - sum);
  for(i = 0; i < 9; ++i) printf("%lld\n", s[i].size());
  return 0;
}

Measured memory_bytes: 56448
#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++)
#define fo(i,j,n) for (int i=(j); 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; }

using edge = pll; //first: 移動先 second: コスト

int main() {
    int n; cin >> n;
    vector<vector<edge>> G(n);
    vector<ll> dist(n, -1);
    rep(i, n-1){
        ll a, b, c; cin >> a >> b >> c; a--, b--;
        G[a].emplace_back(b, c);
        G[b].emplace_back(a, c);
    }
    int Q, k; cin >> Q >> k; k--;
    queue<int> que;
    que.push(k);
    dist[k] = 0;
    while(!que.empty()){
        int pos = que.front(); que.pop();
        for(pll e: G[pos]){
            ll to = e.first, cost = e.second;
            if(dist[to] != -1) continue;
            dist[to] = dist[pos] + cost;
            que.push(to);
        }
    }
    rep(i, Q){
        ll from, to; cin >> from >> to; from--, to--;
        ll res = dist[from] + dist[to];
        cout << res << ln;
    }
}

Measured memory_bytes: 9984
n = int(input())
# A = {i for i in map(int, input().split())}
A = [i for i in map(int, input().split())]
# print(A)
# B = set()
B = []

for e in A:
    cnt = bin(e)[::-1].find('1')
    # print(cnt)
    # B.add(cnt)
    B.append(cnt)
# print(B)
print(min(B))


Measured memory_bytes: 2940