akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using Int = int64_t;

const Int N = 1123456;
bool is_prime[N];
const Int inf = 1LL << 50;

int main() {
   for(Int i = 0; i < N; ++i) {
      is_prime[i] = true;
   }
   is_prime[0] = is_prime[1] = false;
   for(Int i = 2; i * i < N; ++i) {
      if( is_prime[i] ) {
         for(Int k = 2*i; k < N; k+=i) {
            is_prime[k] = false;
         }
      }
   }
   for(;;) {
      Int n, m;
      std::cin >> m >> n;
      if( n == 0 and m == 0 ) break;
      auto field = std::vector<std::vector<Int>>(1024, std::vector<Int>(1024, -1));
      Int y = 512;
      Int x = 512;
      Int dx[] = {1, 0,-1, 0};
      Int dy[] = {0,-1, 0, 1};
      Int k = 3;
      Int i = 1;
      while( i <= m ) {
         field[y][x] = i;
         i += 1;
         {
            Int nx = x + dx[(k+1)%4], ny = y + dy[(k+1)%4];
            if( field[ny][nx] == -1 ) {
               k = (k+1) % 4;
            }
         }
         Int nx = x + dx[k], ny = y + dy[k];
         x = nx;
         y = ny;
      }
      auto dp = std::vector<std::vector<std::pair<Int,Int>>>(1024, std::vector<std::pair<Int,Int>>(1024, std::make_pair(-inf,-1)));
      for(Int y = 0; y < 1024; ++y) {
         for(Int x = 0; x < 1024; ++x) {
            if( field[y][x] == n ) {
               dp[y][x] = std::make_pair(0, field[y][x]);
            }
         }
      }
      for(Int y = 1; y < 1024; ++y) {
         for(Int x = 0; x < 1024; ++x) {
            if( x-1 >= 0 ) {
               if( dp[y][x].first < dp[y-1][x-1].first ) {
                  dp[y][x] = dp[y-1][x-1];
               }
            }
            if( dp[y][x].first < dp[y-1][x].first ) {
               dp[y][x] = dp[y-1][x];
            }
            if( x+1 < 1024 ) {
               if( dp[y][x].first < dp[y-1][x+1].first ) {
                  dp[y][x] = dp[y-1][x+1];
               }
            }
            if( is_prime[field[y][x]] ) {
               dp[y][x].first += 1;
               dp[y][x].second = field[y][x];
            }
         }
      }
      std::pair<Int,Int> res(-inf,-1);
      for(Int y = 0; y < 1024; ++y) {
         for(Int x = 0; x < 1024; ++x) {
            if( res < dp[y][x] ) {
               res = dp[y][x];
            }
         }
      }
      if( res.first == 0 ) {
         res.second = 0;
      }
      std::cout << res.first << ' ' << res.second << std::endl;
   }
}




Measured memory_bytes: 28708
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include <iomanip>
using namespace std;

int main(){
	long long int n,a,sum=0;
	cin>>n;
    	
    a=n;
    for(int i=0;a>0;i++){
    	sum+=a%10;
    	a=a/10;
    }
    if(n%sum==0){
    	cout<<"Yes"<<endl;
    }
    else{
    	cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define For(i,j,k) for(int i=j;i<=k;++i)
using namespace std;
int read(){
	int l=1,x=0; char ch=getchar();
	while(!isdigit(ch)) {if (ch=='-') l=-1; ch=getchar();}
	while(isdigit(ch)) x=x*10+(ch^48),ch=getchar();
	return x*l;
}
int a[100005],b[100005],c[100005],d[100005];
int main(){
	int n=read(),s,x,y,z; long long ans=0;
	For(i,1,n) a[i]=read();
	For(i,1,n) b[i]=read();
	For(i,1,n) c[i]=read();
	sort(a+1,a+1+n); sort(b+1,b+1+n); sort(c+1,c+1+n);
	For(i,1,n) d[i]=lower_bound(a+1,a+1+n,b[i])-a-1;
	For(i,1,n){
		x=upper_bound(c+1,c+1+n,b[i])-c; ans+=(long long)d[i]*(n-x+1);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1792
import numpy as np
H, N = (int(i) for i in input().split())  

a = np.empty(N, dtype='int')
b = np.empty(N, dtype='int')
dp = np.array([float('inf')]*(H+1))
dp[0] = 0

for i in range(N):
  a[i], b[i] = map(int, input().split())
  
for i in range(1, H+1):
  i_from = i - a
  i_from[i_from<0] = 0
  dp[i] = np.min(dp[i_from] + b)
print(int(dp[H]))
  

Measured memory_bytes: 14560
import numpy as np

D = int(input())
C = np.array(list(map(int, input().split())))
S = []
for i in range(D):
    s = list(map(int, input().split()))
    S.append(s)
S = np.array(S)
T = [int(input()) for _ in range(D)]

last = np.zeros(26, dtype=np.int64)


def decrease(d, last):
    res = np.sum(C * (d - last))
    # print(d, res, C * (d - last))
    return res


manzoku = 0
# kaisai = dict()

# print(S, T, C)
for day, t in enumerate(T):
    t -= 1
    manzoku += S[day, t]  # d 日目にタイプi のコンテストを開催した場合、満足度が S[d,i]増加することが予め分かっています。
    last[t] = day + 1
    manzoku -= decrease(day + 1, last)

    print(manzoku)



Measured memory_bytes: 27520
import java.util.*;
public class Main{
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int s = sc.nextInt();
        int cnt = 0;

        for(int a=0; a<=k; a++){
            for(int b=0; b<=k; b++){
                int c = s - a - b;
                if( 0<=c && c<=k){
                    cnt++;
                }        
            }
        }
        System.out.println(cnt);
    }
}

Measured memory_bytes: 22996
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right #func(リスト,値)
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from math import *

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x):
        self.setdefault(x,0)
        self[x] += 1

W,H,N = mint()
rec = [[1]*H for _ in range(W)]

for _ in range(N):
    X,Y,a = mint()
    if a==1:
        for x in range(X):
            for y in range(H):
                rec[x][y] = 0
    if a==2:
        for x in range(X,W):
            for y in range(H):
                rec[x][y] = 0
    if a==3:
        for x in range(W):
            for y in range(Y):
                rec[x][y] = 0
    if a==4:
        for x in range(W):
            for y in range(Y,H):
                rec[x][y] = 0
print(sum(map(sum,rec)))

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

struct P
{
    int x,y;

    bool operator<(const P &a)const{
              return x>a.x;
    }

};

vector<P> v[101103];
//bitset<4001000> b;
int a,c,i,b,k,n,d,m;//dy[15]={0,1,0,-1,-1,1,-1,1},dx[15]={1,0,-1,0,1,1,-1,-1};//
int o[100130];
int l[101103];
double j[1030];
int e[110];
int dx[10]={1,0,-1,0,1,1,-1,-1},dy[10]={0,1,0,-1,1,-1,1,-1},dz[10]={0,0,0,0,1,-1};
long long x,y,mod=998244353;
long long z;
double pi=3.14159265;
P u[10600];
stack<int> s;

//set<int> s;
queue<int> q;

//2147483647
//'1'==49;
//'A'==65;
//'a'==97;
//unordered_
//map<int,int> p,p1;
//list<int> l;

string r;
//char r[133];
//deque<int> de;
bool as(P a,P b)
{
    if(o[a.x]!=o[b.x])
    return o[a.x]<o[b.x];
    return a.y<b.y;
}


int main()
{

    scanf("%d %d %d",&a,&b,&c);
    double x=a*2-c*2;
    if(c==0) x=a;
    x*=(b-1);
    x/=a;
    x/=a;
    printf("%lf",x);
}


Measured memory_bytes: 2560
#include<iostream>
#define MAX 100
using namespace std;


int main(){
    int N, B[MAX], A[MAX], sumA = 0;
    cin >> N;
    for(int i=0; i<N-1; i++) cin >> B[i];
    
    for(int i=1; i<N-1; i++){
        A[i] = min(B[i-1], B[i]);
    }
    A[0] = B[0];
    A[N-1] = B[N-2];

    for(int i=0; i<N; i++){
        sumA += A[i];
    }
    cout << sumA << endl;
}

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

using namespace std;

#define INF 1000000007
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define vec vector
#define pb push_back
#define ll long long

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

	vec<int> prime;
	rep(i, n - 1) {
		int check = i + 2;
		int flag = 1;
		rep(j, prime.size()) {
			if (check % prime[j]) continue;
			flag = 0;
		}
		if (flag) prime.pb(check);
	}

	vec<ll> count(prime.size(), 0);

	rep(i, prime.size()) {
		rep(j, n) {
			int check = j + 1;
			while(check % prime[i] == 0) {
				check /= prime[i];
				count[i]++;
			}
		}
	}

	ll ans = 1;
	rep(i, count.size()) {
		ans *= count[i] + 1;
		ans %= INF;
	}
	cout << ans << endl;
	return 0;
}



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

int main(){
	double xa,ya,ra,xb,yb,rb;
	double d,dx,dy;
	int n,i;
	
	scanf("%d",&n);
	for(i=0;i<n;i++){
		
	scanf("%lf %lf %lf %lf %lf %lf",&xa,&ya,&ra,&xb,&yb,&rb);
	
	dx=sqrt((xa-xb)*(xa-xb));
	dy=sqrt((ya-yb)*(ya-yb));
	d=sqrt(dx*dx+dy*dy);
	
	if(d>ra+rb)printf("0\n");
	else if(ra>d+rb)printf("2\n");
	else if(rb>d+ra)printf("-2\n");
	else if(d<=ra+rb)printf("1\n");
	}
	return 0;
}

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

int n;
long long a[200500];

int main()
{
    int k,n,i;
    cin >> n >> k;

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

    long long ans=1e18+7;;

    for(i=1; i+k-1<=n; i++)
    {
        long long tmp = a[i+k-1]-a[i];
        // 头尾都是负数
        if ((a[i]<0) && (a[i+k-1]<0)) 
        {
        	tmp+=abs(a[i+k-1]);
        }
        // 头尾都是正数
        if ((a[i]>0) && (a[i+k-1]>0)) 
        {
        	tmp+=a[i];
        }
        // 头尾符号不一样
        if ((a[i]<0) && (a[i+k-1]>0)) 
        {
        	tmp+=min(-a[i],a[i+k-1]);
        }

        ans=min(ans,tmp);
    }

    cout << ans;
    return 0;
}


Measured memory_bytes: 1024
import sys
input = sys.stdin.readline
import collections

n, k, q = map(int, input().split(' '))
t = [int(input()) for i in range(q)] 
 
ans = [k - q] * n

t_cnt = collections.Counter(t)
for i, j in t_cnt.items():
  ans[i-1] += j

for i in ans:
  if i > 0:
    print('Yes')
  else:
    print('No')

Measured memory_bytes: 13936
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

int N, M, Q;
vector<vector<int>> v;
int ret;

void dfs(int i, int mn, vector<int>& w){
  if(i == N){
    int sum = 0;
    rep(j,Q){
      if(w[v[j][1]] - w[v[j][0]] == v[j][2]){
        sum += v[j][3];
      }
    }
    ret = max(ret, sum);
    return;
  }
  REP(ii,mn,M+1){
    w[i] = ii;
    dfs(i+1, ii, w);
  }
}


int main(){
  cin >> N >> M >> Q;
  rep(i,Q){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    a--; b--;
    v.push_back({a,b,c,d});
  }

  ret = 0;
  
  vector<int> w(N);
  dfs(0, 1, w);

  cout << ret << endl;
  
  return 0;
}



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

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  int max_a = *max_element(a.begin(), a.end());
  int g = a[0];
  rep(i, n) g = gcd(g, a[i]);
  // cerr << g << " " << max_a << endl;
  if (k % g == 0 && k <= max_a) {
    cout << "POSSIBLE" << endl;
  } else {
    cout << "IMPOSSIBLE" << endl;
  }
  return 0;
}


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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
using ll = long long;


int main() {
    int n; cin >> n;
    V<ll> c(n - 1), s(n - 1), f(n - 1);
    for(int i = 0; i < n - 1; i++) cin >> c[i] >> s[i] >> f[i];

    for(int i = 0; i < n - 1; i++){
        ll sum = c[i] + s[i];
        for(int j = i + 1; j < n - 1; j++){
            if(s[j] < sum){
                if(sum % f[j] != 0){
                    sum = (sum / f[j] + 1) * f[j];
                }
            }else{
                sum = s[j];
            }
            sum += c[j];
        }
        cout << sum << endl;
    }
    cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 3620
MOD = 10**9+7
fac = [1, 1]

def prepare(n, mod):
    for i in range(2, n+1):
        fac.append((fac[-1] * i) % mod)


def modcmb(n, r, mod):
    if n < 0 or r < 0 or r > n:
        return 0

    return fac[n] * pow(fac[r], mod-2, mod) * pow(fac[n-r], mod-2, mod) % mod


def f(r, c):
    return modcmb(r+c, r, MOD)


def g(x, y):
    return ((y+2) * modcmb(x+y+2, x, MOD) - (x+1)) * pow(x+1, MOD-2, MOD)


def main():
    prepare(2*10**6+10, MOD)
    r1,c1,r2,c2 = map(int, input().split())

    ans = g(r2, c2) - g(r1-1, c2) - g(r2, c1-1) + g(r1-1, c1-1)
    ans %= MOD

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 82220
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] num = new int[6];
		Dice dice = new Dice(num);
		for (int i = 0; i < 6; i++) {
			num[i] = sc.nextInt();
		}
		dice.setFace(num);
		String str = sc.next();
		dice.order(str);
		System.out.println(dice.getFace());
		sc.close();
	}
}

class Dice {
	private int face[] = new int[6];

	Dice(int[] num) {
		for (int i = 0; i < 6; i++) {
			this.face[i] = num[i];
		}
	}

	public void order(String str) {
		char[] order = str.toCharArray();
		for (int i = 0; i < order.length; i++) {
			switch (order[i]) {
			case 'N':
				rollToNorth();
				break;
			case 'S':
				rollToSouth();
				break;
			case 'E':
				rollToEast();
				break;
			case 'W':
				rollToWest();
				break;
			}
		}
	}

	public void rollToNorth() {
		int tmp;
		tmp = face[0];
		face[0] = face[1];
		face[1] = face[5];
		face[5] = face[4];
		face[4] = tmp;
	}

	public void rollToSouth() {
		int tmp;
		tmp = face[0];
		face[0] = face[4];
		face[4] = face[5];
		face[5] = face[1];
		face[1] = tmp;
	}

	public void rollToEast() {
		int tmp;
		tmp = face[0];
		face[0] = face[3];
		face[3] = face[5];
		face[5] = face[2];
		face[2] = tmp;
	}

	public void rollToWest() {
		int tmp;
		tmp = face[0];
		face[0] = face[2];
		face[2] = face[5];
		face[5] = face[3];
		face[3] = tmp;
	}

	public int getFace() {
		return face[0];
	}

	public void setFace(int[] face) {
		this.face = face;
	}
}


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

using namespace std;

#define pb push_back
#define F first
#define S second
#define ALL(v) v.begin(),v.end()
#define fast_cin() ios_base::sync_with_stdio(0)

typedef long long ll;
typedef long double ld;
typedef pair <ll,ll> pll;
typedef pair <int,int> pii;

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

int faltu;

const int mod = 1e9+7;
const ll MAX = 5e18;
const ll MIN = -MAX;
const int imax = 2e9 + 100;


int main()
{
	time_t t1, t2;
	t1 = clock();

	int n, k;
	cin >> n >> k;

	int a[n + 1];
	int done[n + 1];
	memset(done, 0, sizeof(done));
	for(int i = 1; i <= n; i++)
	{
		cin >> a[i];
		done[a[i]] ++;
	}
	sort(done + 1, done + n + 1, greater <int> ());
	int ans = 0;
	for(int i = k + 1; i <= n; i++)
		ans += done[i];
	cout << ans << endl;

	t2 = clock();
	cerr << "time taken: " << t2 - t1 << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <map>
#include <vector>

int main() {
    std::map<int, int> ntop;
    std::vector<bool> ban(9, false);
    for (int i = 0; i < 9; i++) {
        int a;
        std::cin >> a;
        ntop.insert(std::make_pair(a, i));
    }

    int n;
    std::cin >> n;

    for (int i = 0; i < n; i++) {
        int b;
        std::cin >> b;
        auto it = ntop.find(b);
        if (it != ntop.end()) {
            ban[it->second] = true;
        }
    }

    if ((ban[0] && ban[1] && ban[2]) ||
        (ban[3] && ban[4] && ban[5]) ||
        (ban[6] && ban[7] && ban[8]) ||
        (ban[0] && ban[3] && ban[6]) ||
        (ban[1] && ban[4] && ban[7]) ||
        (ban[2] && ban[5] && ban[8]) ||
        (ban[0] && ban[4] && ban[8]) ||
        (ban[2] && ban[4] && ban[6])    ) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<iostream>
using namespace std;
int main()
{
    int n,m,x,y;
    scanf("%d%d%d%d",&n,&m,&x,&y);
    int ma=-100,mi=100,k;
    while(n--)
    {
        scanf("%d",&k);
        ma=max(ma,k);
    }
    while(m--)
    {
        scanf("%d",&k);
        mi=min(mi,k);
    }
    if(ma<mi)
    {
        bool flag=false;
        for(int i=x+1;i<=y;i++)
            if(i>ma&&i<=mi) {flag=true;break;}
        if(flag)
            printf("No War\n");
        else printf("War\n");
    }
    else printf("War\n");
}


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

using namespace std;

typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define debug(a) cout << #a << ": " << a << endl;

int dp[101][4][4][4];

int main() {
  int N;
  cin >> N;
  int mod = int(1e9) + 7;

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

  rep(len, N) rep(c3, 4) rep(c2, 4) rep(c1, 4) {
    if (dp[len][c3][c2][c1] == 0)
      continue;
    rep(add, 4) {
      if (c2 == 0 && c1 == 1 && add == 2)
        continue;
      if (c2 == 1 && c1 == 0 && add == 2)
        continue;
      if (c2 == 0 && c1 == 2 && add == 1)
        continue;
      if (c3 == 0 && c1 == 1 && add == 2)
        continue;
      if (c3 == 0 && c2 == 1 && add == 2)
        continue;

      dp[len + 1][c2][c1][add] += dp[len][c3][c2][c1];
      dp[len + 1][c2][c1][add] %= mod;
    }
  }

  int ans = 0;
  rep(c3, 4) rep(c2, 4) rep(c1, 4) {
    ans += dp[N][c3][c2][c1];
    ans %= mod;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		try (Scanner sc = new Scanner(System.in)) {
			String S;
			int head, tail;
			S = sc.next();
			head = Integer.valueOf(S.substring(0, 2));
			tail = Integer.valueOf(S.substring(2, 4));
			
			boolean headMM = inMM(head);
			boolean tailMM = inMM(tail);
			
			if (headMM && tailMM) {
				System.out.println("AMBIGUOUS");
			} else if (headMM && !tailMM) {
				System.out.println("MMYY");
			} else if (!headMM && tailMM) {
				System.out.println("YYMM");
			} else {
				System.out.println("NA");
			}
			
		} catch (Exception e) {
			// TODO: handle exception
		}
	}
	
	private static boolean inMM (int value) {
		if (0 < value && value <= 12) {
			return true;
		} else {
			return false;
		}
	}

}

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

int main()
{
  int X;
  cin >> X;
  int a[100] = {0};
  for(int i=0; i<X; i++){
    cin >> a[i];
  }
  int min = 999999;
  int count = 0;
  for(int i=0; i<101; i++){
    count = 0;
    for(int j=0; j<X; j++){
      count += pow(abs(a[j]-i), 2);
    }
    if(min > count){
      min = count;
    }
  }
  cout << min;
  
  return 0;
}

Measured memory_bytes: 3604
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        final int s = in.nextInt();
        final int n = in.nextInt();
        in.nextLine();
        int total = 0;
        for (int i = 0; i < n; i++) {
            total += in.nextInt();
        }
        System.out.println(total > s ? -1 : s - total);
    }
}


Measured memory_bytes: 46400
#include <bits/stdc++.h>
// bitwise operations need to be revised
using namespace std;
int main()
{

    int h,w,k,ans=0;
    cin>>h>>w>>k;
    char c[h][w];
    for(int i=0; i<h; i++)
    {
        for(int j=0; j<w; j++)
        {
            cin>>c[i][j];
        }
    }
    for(int maskR=0; maskR<(1<<h); maskR++)
    {
        for(int maskC=0; maskC<(1<<w); maskC++)
        {
            int black=0;
            for(int i=0; i<h; i++)
            {
                for(int j=0; j<w; j++)
                {
                    if(((maskR >> i) & 1) == 0&& ((maskC >> j) & 1) == 0&& c[i][j] == '#')
                        black++;
                }
            }
            if(black==k)
                ans++;
        }
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
typedef pair<double,double> pdd;
#define MEM(a, b) memset(a, (b), sizeof(a))
#define SZ(i) ll(i.size())
#define FOR(i, j, k, in) for (ll i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (ll i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define REP1(i,j) FOR(i, 1, j+1, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(_a) _a.begin(),_a.end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define X first
#define Y second
#ifdef tmd
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
#endif

template<class T> inline bool cmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool cmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MOD=1000000007;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll MAXN=1e3+5;
const ll MAXLG=__lg(MAXN)+2;

ll dp[MAXN][MAXN],n,m;
/********** Good Luck :) **********/
int main()
{
    IOS();
    cin >> n >> m;
    REP (i,n) {
        REP (j,m) {
            char c;
            cin >> c;
            if (c == '.') {
                dp[i][j] = ((i?dp[i-1][j]:0) + (j?dp[i][j-1]:0)) % MOD;
                if (i == 0 && j == 0) {
                    dp[i][j] = 1;
                }
            }
        }
    }

    cout << dp[n-1][m-1] << endl;
    return 0;
}


Measured memory_bytes: 8064
a = input().split()
N = int(a[0])
Y = int(a[1])
shA = -1
shB = -1
shC = -1
for A in range(N+1):
  for B in range(N+1-A):
    C = N - A - B
    total = 10000 * A + 5000 * B + 1000 * C
    if total == Y:
      shA = A
      shB = B
      shC = C
print(str(shA) + " " + str(shB) + " " + str(shC))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#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 rrep(i,n) for(int i=((int)(n)-1);i>=0;(i)--)
#define rrep1(i,n) for(int i=((int)(n));i>0;(i)--)
#define sz(c) ((int)(c).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> P;
typedef pair<int, pair<int, int> > PP;
//const int MAX=;

int N,M;
priority_queue<int> pr;
void input(){
	cin>>N>>M;
	rep(_,N){
		int A;
		cin>>A;
		pr.push(A);
	}
}

void solve(){
	rep(_,M){
		int v=pr.top();
		pr.pop();
		v=v/2;
		pr.push(v);
	}
	ll ans=0;
	rep(_,N){
		int c=pr.top();
		pr.pop();
		ans=ans+(ll)c;
	}
	cout<<ans<<endl;
}

void output(){
  
}

int main(){
  input();
  solve();
  output();
}

Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
template<typename T>
inline void read(T &x)
{
	x=0;
	int f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9')
	{
		if(ch=='-') f=-1;
		ch=getchar();
}
	while(ch>='0'&&ch<='9') x=x*10+(ch^48),ch=getchar();
	x*=f;
	return;
}	
template<typename T>
void write(T x)
{
	if(x<0) putchar('-'),x=-x;
	if(x>=10) write(x/10);
	putchar(x%10+'0');
	return;
}
const int MAXN=10;
int h,w,k;
bool mp[MAXN][MAXN];
int ans=0;
bool check(int x)
{
    int tmp[MAXN][MAXN];
    for(int i=1;i<=h;++i)
    for(int j=1;j<=w;++j) tmp[i][j]=mp[i][j];
    for(int i=0;i<=(h-1);++i)
    if(x&(1<<i))
    for(int j=1;j<=w;++j) tmp[i+1][j]=0;
    for(int i=h;i<=h+w-1;++i)
    if(x&(1<<i))
    for(int j=1;j<=h;++j) tmp[j][i-h+1]=0;
    int sum=0;
    for(int i=1;i<=h;++i)
    for(int j=1;j<=w;++j) sum+=tmp[i][j];
    return sum==k;
}
int main()
{
    cin>>h>>w>>k;
    for(int i=1;i<=h;++i)
    {
        string s;
        cin>>s;
        for(int j=0;j<w;++j)
        if(s[j]=='.') mp[i][j+1]=0;
        else mp[i][j+1]=1;
    }
    for(int i=0;i<=(1<<(h+w))-1;++i)
    if(check(i)) ++ans;
    cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3596
A,B = list(map(int,input().split(' ')))

g = 0
p = ''

if (A >= B):
	p = 'A'
	g = g + A
	A = A - 1
else:
	p = 'B'
	g = g + B
	B = B - 1

if (A >= B):
	p = 'A'
	g = g + A
	A = A - 1
else:
	p = 'B'
	g = g + B
	B = B - 1

print(g)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;
  cin >>a >>b;
  
  int socket = 1;
  int ans = 0;
  while (socket < b) {
    ans++;
    socket += a-1;
  }
  
  cout << ans; 
}

Measured memory_bytes: 3616
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

fn main() {
  let n = read::<i32>();
  let mut p: Vec<i32> = vec![];

  for _ in 0..n {
    let p_i = read::<i32>();
    p.push(p_i);
  }

  let sum: i32 = p.iter().sum();
  let p_max = p.iter().max().unwrap();


  println!("{}", sum - (p_max / 2));

}



Measured memory_bytes: 4352
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Throwable {
		Scanner sc = new Scanner(System.in);
//		Scanner sc = new Scanner(new File("test_1.txt"));
		List<Integer> a = new ArrayList<Integer>();
		int N = sc.nextInt();
		for (int i = 0; i < N; i++)
			a.add(sc.nextInt());
		sc.close();
		
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < N; i++) {
			// 0..i-1??????????????????
			int a_i = a.get(i);
			int j = i - 1;
			while (j >= 0 && a.get(j) > a_i) {
				a.set(j + 1, a.get(j));
				j--;
			}
			a.set(j + 1, a_i);
			
			// ??????
			for (int k = 0; k < a.size(); k++) {
				sb.append(a.get(k));
				sb.append(' ');
			}
			sb.deleteCharAt(sb.length() - 1);
			sb.append('\n');
		}
		
		System.out.print(sb.toString());
	}
}

Measured memory_bytes: 23216
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

int solve(vector<int>& v) {
  if(v.empty()) return 0;
  int lhs = v[0];
  for(int i = 0; i < v.size(); i++) lhs = min(lhs, v[i]);
  for(int i = 0; i < v.size(); i++) v[i] -= lhs;
  int ret = lhs;
  for(int i = 0; i < v.size();) {
    if(v[i] == 0) {
      i++;
      continue;
    }
    vector<int> nv;
    while(i < v.size() && v[i]) nv.push_back(v[i++]);
    ret += solve(nv);
  }
  return ret;
}

void solve() {
  int n;
  cin >> n;
  vector<int> v;
  v.resize(n);
  for(int i = 0; i < n; i++) cin >> v[i];
  cout << solve(v) << "\n";
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  /*
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ": ";
    solve();
  }
  */
  solve();
}


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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, 0, n) cin >> a[i];
    int tmp = a[0];
    ll ans = 0;
    rep(i, 1, n){
        ans += max(0, tmp - a[i]);
        if(tmp < a[i]){
            tmp = a[i];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4044
/*
 * If you're not willing to make sacrifices yourself, you'll never be
 * able to change anything. In order to overcome monsters, you must
 * be willing to abandon your own humanity.
 * ~ Arlert
 */

#include <bits/stdc++.h>

using namespace std;

typedef pair<int, int> II;
typedef vector<II> VII;
typedef vector<int> VI;
typedef vector<VI> VVI;

typedef long long int LL;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(), a.end()
#define SET(a, b) memset(a, b, sizeof(a))
#define si(n) scanf("%d", &n)
#define dout(n) printf("%d\n", n)
#define sll(n) scanf("%lld", &n)
#define lldout(n) printf("%lld\n", n)

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
  const char *comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
#else
#define trace(...)
#endif

#define fast_io                     \
  ios_base::sync_with_stdio(false); \
  cin.tie(NULL)

#define endl '\n'

int main() {
  fast_io;
  string s;
  cin >> s;
  string ans = "No";
  for (auto c : s)
    if (c == '9') ans = "Yes";
  cout << ans << endl;
  return 0;
}


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

int main() {
  int H,W,K;
  cin >> H >> W >> K;
  vector<vector<char>> itigo(H,vector<char>(W));
  vector<bool> exist(H,false);
  int mini;
  for (int i=0;i<H;i++) {
    for (int j=0;j<W;j++) {
      cin >> itigo.at(i).at(j);
      if (itigo.at(i).at(j) == '#')  exist.at(i) = true;
    }
  }
  for (int i=0;i<H;i++) {
    int flg=0;
    for (int j=0;j<W;j++) {
      cin >> itigo.at(i).at(j);
      if (itigo.at(i).at(j) == '#') { mini = i; flg=1; break;}
    }
    if (flg) break;
  }
  vector<vector<int>> kiri(H,vector<int>(W));
  int idx=0;
  for (int i=0;i<H;i++) {
    if (exist.at(i)) {
      idx++;
      int cnt=0;
      for (int j=0;j<W;j++) {
        if (itigo.at(i).at(j) == '#') {
          cnt++;
          if (cnt<=1) { kiri.at(i).at(j) = idx;}
          else { idx++; kiri.at(i).at(j) = idx;}
        }
        else { kiri.at(i).at(j) = idx;}
      }
    }
    else {continue;}
  }
  if (mini != 0) {
    for (int i=0;i<mini;i++) {
      for (int j=0;j<W;j++) {
        kiri.at(i).at(j) = kiri.at(mini).at(j);
      }
    }
  }
  for (int i=0;i<H;i++) {
    if (i>mini && !exist.at(i)) {
      for (int j=0;j<W;j++) {
        kiri.at(i).at(j) = kiri.at(i-1).at(j);
      }
    }
  }
  for (int i=0;i<H;i++) {
    for (int j=0;j<W;j++) {
      cout << kiri.at(i).at(j) << " ";
      if (j == W-1)  cout << endl;
    }
  }
}

Measured memory_bytes: 1280
import sys


def input():
    return sys.stdin.readline()[:-1]


def main():
    A, B = map(int, input().split())
    if B == 1:
        print("0")
        exit()
    else:
        for i in range(1, 100):
            if (A-1)*(i-1) + A >= B:
                print(i)
                exit()


if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>
#include<cassert>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define rep(i,s,n) for(int i=(s); i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x)

using namespace std;

typedef unsigned int uint;
typedef long long ll;

const int _dx[] = {0,1,0,-1};
const int _dy[] = {-1,0,1,0};

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

int v1[1001];
int v2[1000000];

int main(){
  int n,m;
  while(n = getInt(), m = getInt(), n+m){
    int cnt = 0;
    REP(i,n) v1[i] = getInt();
    v1[n++] = 0;
    REP(i,n) rep(j,i,n) {
      if(v1[i] + v1[j] <= m)
        v2[cnt++] = v1[i] + v1[j];
    }
    sort(v2, v2+cnt);

    int ans = 0;
    REP(i,cnt){
      int a = v2[i];
      int b = m - a;
      int *it = lower_bound(v2, v2+cnt, b);
      if(it != v2) --it;
      ans = max(ans, a + *it);
    }

    print(ans);
  }
  return 0;
}

Measured memory_bytes: 2792
//submisssions/4054148を参考

#include <bits/stdc++.h>

using namespace std;
 
typedef long long ll;
 
 
int main()
{
    int n, k;
    cin >> n >> k;
    //二次元動的配列の使いかた
    vector<ll> a(n), b(n);
    vector<vector<ll>> v(n);

    for(int i = 0; i < n; ++i){
        cin >> a[i] >> b[i];
        v[--a[i]].push_back(b[i]);
    }
    //for(auto& x : v){
    //    sort(x.begin(), x.end(), greater<ll>());
    //}
    for(int i = 0; i < n; i++)
    {
        sort(v[i].begin(),v[i].end(), greater<ll>());
    }
    

    vector<ll> top;
    vector<ll> notop;

    for(int i = 0; i < n; i++)
    {
        if(v[i].empty())
            continue;
        top.push_back(v[i][0]);
        for(int j = 1; j < v[i].size(); j++)
        {
            notop.push_back(v[i][j]);            
        }
    }
    
    sort(top.begin(), top.end(), greater<ll>());
    sort(notop.begin(), notop.end(), greater<ll>());

    ll ans = 0;
    for(ll i = 0; i <= k; i++)
    {
        if (i > top.size() || (k - i) > notop.size()) continue;

        ll tmp = 0;
        for(ll j = 0; j < k; j++)
        {

            if (j < i){
                tmp += top[j];
            }else{
                tmp += notop[j - i];
            }
        }
        tmp += i*i;
        ans = max(ans, tmp);  
    }
    cout << ans << endl;
}

Measured memory_bytes: 8440
S = input()
n = len(S)
ans1, ans2 = 0, 0
for i, s in enumerate(S):
    m = int(s)
    if i % 2:
        ans1 += 1 - m
        ans2 += m
    else:
        ans1 += m
        ans2 += 1 - m
print(min(ans1, ans2))

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

int main(){
	int n,a,b; cin>>n>>a>>b;
	int c=min(a,b);
	int m=a+b-n;
	if(m>0) cout<<c<<" "<<m<<endl;
	else cout<<c<<" "<<0<<endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
using namespace std;
 
int main(){
  int N,K,l[60];
  cin >> N >> K;
  for(int i=0 ; i<N ; i++) cin >> l[i];
 
  sort(l,l+N,greater<int>()); // lを大きい順にソート
 
  int total=0;
  for(int i=0 ; i < K ; i++) total += l[i];
 
  cout << total;
}

Measured memory_bytes: 256
function main(input) {
  const args = input.split('\n');
  var int = [];
  for(let i=0;i<args.length;i++){
    int.push(args[i].split(' '));
  }
  var times = parseInt(int[0][0]);
  var points = [];
  for(let j=1;j<=times;j++){
    var point = [parseInt(int[j][0]),parseInt(int[j][1]),parseInt(int[j][2])];
    points.push(point);
  }
  points.unshift([0,0,0])
  for(let k=0;k<times;k++){
    var judge_time = points[k+1][0]-points[k][0];
    var judge_point = (points[k+1][1]-points[k][1])+(points[k+1][2]-points[k][2]);
    if(Math.abs(judge_point)<= judge_time && (judge_time-judge_point)%2 === 0){
      var result = 'Yes';
    }else{
      var result = 'No';
      break;
    }
  }
  console.log(result);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 71480
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const int MOD=998244353;
const ll INF=2e15;
const double PI=acos(-1);

int main() {
    ios_base::sync_with_stdio(false); 

    int n;
    cin >> n;
    bool flag=0;
    rep(i,n) {
        int a;
        cin >> a; 
        if (a%2==1) flag=1;
    }
    if (flag) cout << "first" << endl;
    else cout << "second" << endl;
    


    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
#define FOR(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define rep(i,n) FOR(i,0,n-1)
#define int long long
#define MOD 998244353
#define MAXN  100005
#define P pair<int,int>

signed main(){
	
	int n,p;cin>>n>>p;
	int gu = 0,ki = 0;
	rep(i,n)
	{
		int a;cin>>a;
		if(a%2)ki++;
		else gu++;
	}
	
	if(ki == 0)
	{
		if(p == 0 ) cout << (1LL<<n) << endl;
		else cout << 0 << endl;
	}
	else
	{
		cout <<(1LL<<(n-1)) << endl;
	}
		
	
}

//cout << 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 ll long long
const ll MOD = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1);



int main(void)
{
    ll n,k; cin>>n>>k;
    int p[n];
    rep(i,n) cin>>p[i];
    sort(p,p+n);
    ll sum=0;
    rep(i,k) sum+=p[i];
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>
#include <functional>
#include <vector>
#include <stack>
#include <set>
using namespace std;
typedef unsigned long long ll;
const int maxn=2e5+50;
const int inf=0x3f3f3f3f;
const int MOD=1e9+7;
const int HASH=131;



int main()
{
    char tmp;
    int ans=0;
    while(scanf("%c",&tmp)!=EOF&&tmp!='\n')
    {
        ans=(ans+tmp-'0')%9;
    }
    if(ans==0) printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 3684
#include<stdio.h>
#include<math.h>
#define N 10000

#include<stdio.h>
#define N 10000
 
int main(){
  int i=0,A[N],count=0,count2=0,n,k;
   
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&A[i]);
  for(i=0;i<n;i++){ 
    if(A[i]==2) count++;    
    if(A[i]%2!=0){
      for(k=3,count2=0;k<=sqrt(A[i]);k+=2){    
	if(A[i]%k==0){
	  count2++;
	  break;}}
      if(count2==0) count++;
    }}
  
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 632
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <memory>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll;
typedef vector<vector<long long> > vvll;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _rep(i,n) _rep2((i),0,(n))
#define _rep2(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) GET_MACRO(__VA_ARGS__, _rep2, _rep)(__VA_ARGS__)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define fi first
#define se second
#define mkp make_pair
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
	int K;
	cin>>K;
	int n;
	cin>>n;
	vint v(n);
	rep(i,n) cin>>v[i];
	sort(ALL(v));
	cout<<max(0, v.back()-(K-v.back()+1))<<endl;
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define zy -2147382637
#define bql 2147483647
#define ll long long
#define ull unsigned long long
#define ld long double
#define il inline
#define sz(x) x.size()
#define maxn 100010
#define rp(i, l, r) for (int i = l; i <= r; i++)
#define rb(i, r, l) for (int i = r; i >= l; i--)
#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;
ll max(ll a,ll b){if(a>b)return a;else return b;}
ll min(ll a,ll b){if(a<b)return a;else return b;}
ll lowbit(ll x){return x&(-x);}
ll prime(ll x){
   if(x<=1)return false;
   for(int i=2;i<=int(sqrt(x));i++){
	   if(x%i==0)return false;
   }return true;
}
bool cmp(ll a,ll b){return a>b;}
ll gcd(ll a,ll b){ll r;while(b>0){r=a%b;a=b;b=r;}return a;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
inline ll read() {
	char c = getchar(); ll w = 1; ll x = 0;
	while (!isdigit(c))
		(c == '-') && (w = -w), c = getchar();
	while (isdigit(c))
		x = (x << 1) + (x << 3) + (c ^ '0'), c = getchar();
	x *= w;
}
void fl(){
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
}
const int dx[8] = {-1, 1, 0, 0, -1, 1, -1, 1},
		  dy[8] = {0, 0, -1, 1, -1, -1, 1, 1};
int main(){
	fast;
	ll x,y;
	cin>>x>>y;
	if(x==1)x=300000;
	else if(x==2)x=200000;
	else if(x==3)x=100000;
	else x=0;
	if(y==1)y=300000;
	else if(y==2)y=200000;
	else if(y==3)y=100000;
	else y=0;
	if(x==300000&&y==300000)cout<<x+y+400000<<endl;
	else cout<<x+y<<endl;
	return 0;
}/*『你强归你强，我永不示弱』*/




Measured memory_bytes: 256
// Original: https://github.com/tanakh/competitive-rs
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

mod util {
    #[allow(dead_code)]
    pub fn chmin<T>(x: &mut T, y: T) -> bool
    where
        T: PartialOrd + Copy,
    {
        *x > y && {
            *x = y;
            true
        }
    }

    #[allow(dead_code)]
    pub fn chmax<T>(x: &mut T, y: T) -> bool
    where
        T: PartialOrd + Copy,
    {
        *x < y && {
            *x = y;
            true
        }
    }

    /// 整数除算切り上げ
    #[allow(dead_code)]
    pub fn roundup(a: i64, b: i64) -> i64 {
        (a + b - 1) / b
    }

    #[allow(dead_code)]
    pub fn ctoi(c: char) -> i64 {
        c as i64 - 48
    }
}

#[allow(unused_imports)]
use util::*;

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, VecDeque};

fn main() {
    input! {
        n:usize,
        mut ass:[i64;n+1],
        mut bs:[i64;n]
    }

    let mut total = 0;
    for i in 0..n {
        if ass[i] < bs[i] {
            total += ass[i];
            bs[i] -= ass[i];
            let damage = min(ass[i + 1], bs[i]);
            ass[i + 1] -= damage;
            total += damage;
        } else {
            total += bs[i];
        }
    }

    println!("{}", total);
}


Measured memory_bytes: 6396
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	for scanner.Scan() {
		num, _ := strconv.Atoi(scanner.Text())
		first := true
		beki := 1
		for num != 0 {
			if num % 2 == 1 {
				if !first {
					fmt.Print(" ")
				}
				fmt.Print(beki)
				first = false
			}
			num /= 2
			beki *= 2
		}
		fmt.Println()
	}
}


Measured memory_bytes: 1060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 998244353;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(int i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	ll n, s; cin >> n >> s;
	ll a[n+1]; rep(i, 1, n)cin >> a[i];
	
	ll dp[n+1][s+1]; memset(dp, 0, sizeof(dp));
	dp[0][0] = 1;
	
	rep(i, 1, n){
		rep(j, 0, s){
			dp[i][j] += 2*dp[i-1][j]%MOD;
			dp[i][j] %= MOD;
		}
		
		rep(j, 0, s-a[i]){
			dp[i][j+a[i]] += dp[i-1][j];
			dp[i][j+a[i]] %= MOD;
		}
		
		//printa(dp[i], 0, s)
	}
	
	print(dp[n][s])
	
	return 0;
}

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

int main()
{
    string s; cin>>s;
    int N=s.size();

    vector<int> idxL(N),idxR(N);
    idxL[N-1]=N-1;
    for(int i=N-2;i>=0;i--){
        idxL[i]=idxL[i+1];
        if(s[i]=='L') idxL[i]=i;
    }
    idxR[0]=0;
    for(int i=1;i<N;i++){
        idxR[i]=idxR[i-1];
        if(s[i]=='R') idxR[i]=i;
    }
    
    vector<int> cnt(N);
    for(int i=0;i<N;i++){
        if(s[i]=='R'){
            int dist=idxL[i]-i;
            if(dist%2==0) cnt[idxL[i]]++;
            else cnt[idxL[i]-1]++;
        }else{
            int dist=i-idxR[i];
            if(dist%2==0) cnt[idxR[i]]++;
            else cnt[idxR[i]+1]++;
        }
    }
    for(int i=0;i<N;i++) cout<<cnt[i]<<endl;

    return 0;
}

Measured memory_bytes: 1792