akhauriyash/Code-Regression huggingface dataset:
#include <functional>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <iomanip>
#include <vector>
#include <string>
#include <cstdio>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <set>
#if __cplusplus >= 201103L
#include <unordered_map>
#include <unordered_set>
#endif
#define ls x<<1
#define rs x<<1|1
#define fi first
#define se second
#define ll long long
#define pb push_back
#define mp make_pair
#define fun function
#define vi vector<int>
#define lowbit(x) x&(-x)
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define mem(a,b) memset(a,b,sizeof(a))
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);

using namespace std;

const int INF = 0x3f3f3f3f;



int main() {
	IOS;
#ifdef xiaofan
	freopen("1.in","r",stdin);
	freopen("1.out","w",stdout);
#endif

	ll a,b;
	cin>>a>>b;
	ll x1=a/2;
	ll x2=a-x1;
	ll y1=b/2;
	ll y2=b-y1;
	ll ans=x1*y1+x2*y2;
	if(a==1||b==1)ans=1;
	cout<<ans<<endl;





	return 0;
}



Measured memory_bytes: 256
package main

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

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt() int {
  n, _ := strconv.Atoi(NextLine())
  return n
}
func NextIntVec() []int {
  L := strings.Split(NextLine(), " ")
  N := make([]int, len(L))
  for i := range N {
    N[i], _ = strconv.Atoi(L[i])
  }
  return N
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func Output() {
  _ = writer.Flush()
}

const p = 1000000007

func main() {
  N := NextInt()
  A := NextIntVec()
  C := []int{0, 0, 0}
  pat := 1
  for i := 0; i < N; i++ {
    a := A[i]
    cnt := 0
    for i, c := range C {
      if c == a {
        if cnt < 1 { C[i]++ }
        cnt++
      }
    }
    pat = pat * cnt % p
  }
  Write(pat)
  Output()
}

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

using namespace std;

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

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 510;
int s[N], t[N];
ull u[N], v[N];
bool cu[N], vu[N];
ull ans[N][N];
int cur[N][N];
int n;

int ci[N], cj[N];

void setbit(int i, int j, int b){
  if(cur[i][j] == -1){
    cur[i][j]=b;
    if(s[i] == 0 && cu[i] && b == 1) ci[i]=0;
    if(s[i] == 0 && !cu[i] && b == 0) ci[i]=0;
    
    if(s[i] == 1 && !cu[i] && b == 0) ci[i]=0;
    if(s[i] == 1 && cu[i] && b == 1) ci[i]=0;
    
    if(t[j] == 0 && vu[j] && b == 1) cj[j]=0;
    if(t[j] == 0 && !vu[j] && b == 0) cj[j]=0;
      
    if(t[j] == 1 && !vu[j] && b == 0) cj[j]=0;
    if(t[j] == 1 && vu[j] && b == 1) cj[j]=0;
    
    ci[i]--;
    cj[j]--;
    return;
  }
  if(cur[i][j] != b){
    cout << "-1";
    exit(0);
  }
}

int ni[N], nj[N];

void solve(ull bit){
  for(int i = 1; i <= n; i ++ ){
    cu[i] = (u[i] & bit);
    vu[i] = (v[i] & bit);
  }
  for(int i = 1; i <= n; i ++ ) for(int j = 1; j <= n; j ++ ) cur[i][j]=-1, ci[i]=cj[j]=n;
  for(int i = 1; i <= n; i ++ ){
    if(s[i] == 0 && cu[i])
      for(int j = 1; j <= n; j ++ ){
        setbit(i, j, 1);
      }
    if(s[i] == 1 && !cu[i])
      for(int j = 1; j <= n; j ++ ){
        setbit(i, j, 0);
      }
    if(t[i] == 0 && vu[i])
      for(int j = 1; j <= n; j ++ )
        setbit(j, i, 1);
    if(t[i] == 1 && !vu[i])
      for(int j = 1; j <= n; j ++ ){
        setbit(j, i, 0);
      }
  }
  for(int i = 1; i <= n; i ++ ){
    ni[i]=-1,nj[i]=-1;
    if(ci[i] >= 0)
      ni[i]=cu[i];
    if(cj[i] >= 0)
      nj[i]=vu[i];
    //cout << ni[i] << " " << nj[i] << "\n";
  }
  for(int i = 1; i <= n; i ++ ){
    for(int j = 1; j <= n; j ++ ){
      if(cur[i][j] == -1){
        if(ci[i] < 0 && cj[j] < 0) setbit(i,j,0);
        if(ci[i] > 0 && cj[j] < 0) setbit(i,j,ni[i]);
        if(ci[i] < 0 && cj[j] > 0) setbit(i,j,nj[j]);
        if(ci[i] > 0 && cj[j] > 0){
          if(ci[i] <= cj[j]){
            setbit(i,j,ni[i]);
          }
          else{
            setbit(i,j,nj[j]);
          }
        }
      }
    }
  }
  for(int i = 1; i <= n; i ++ ){
    if(ci[i] >= 0 || cj[i] >= 0){
      cout << "-1\n";
      exit(0);
    }
  }
  for(int i = 1; i <= n; i ++ ){
    for(int j = 1; j <= n; j ++ ){
      if(cur[i][j]) ans[i][j] |= bit;
    }
  }
}

int main(){
  fastIO;
  cin >> n;
  for(int i = 1; i <= n; i ++ )
    cin >> s[i];
  for(int i = 1; i <= n; i ++ )
    cin >> t[i];
  for(int i = 1; i <= n; i ++ )
    cin >> u[i];
  for(int i = 1; i <= n; i ++ )
    cin >> v[i];
  for(int lg = 63; lg >= 0 ;lg -- ){
    solve((1ll << lg));
  }
  for(int i = 1; i <= n; i ++ ){
    for(int j = 1; j <= n ; j ++ ){
      cout << ans[i][j] << " ";
    }
    cout << "\n";
  }
  return 0;
}


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int a[3];

int main() {
	inc(i, 3) { cin >> a[i]; }
	sort(a, a + 3);
	
	cout << a[0] + a[1] << endl;
	
	return 0;
}


Measured memory_bytes: 256
from collections import deque
h,w=map(int,input().split())
maze=[input() for i in range(h)]

def bfs():
    global goal
    #0はstartとまだ通ってない場所
    d=[[float('inf')]*w for _ in range(h)]
    d[st[0]][st[1]]=0
    #進行方向
    x=[0,1,0,-1]
    y=[1,0,-1,0]

    p=deque([])
    p.append(st)#start座標を入れる

    while p:
        zahyo=p.popleft()
        for i in range(4):
            nx=zahyo[0]+x[i]
            ny=zahyo[1]+y[i]

            if 0<=nx<=h-1 and 0<=ny<=w-1 and d[nx][ny]==float('inf') and maze[nx][ny]=='.':
                d[nx][ny]=d[zahyo[0]][zahyo[1]]+1
                p.append([nx,ny])
                if goal<d[nx][ny]:
                    goal=d[nx][ny]

goal=0
ans=0
#starを決める
for i in range(h):
    for j in range(w):
        if maze[i][j]=='.':
            st=[i,j]
            bfs()
            if ans<goal:
                ans=goal
print(ans)


Measured memory_bytes: 3316
// Aizu 1179: Millennium
// 2017.9.13 bal4u@uu

#include <stdio.h>

#define M 196666

int main()
{
	int n, y, m, d, ans;
	
	scanf("%d", &n);
	while (n-- > 0) {
		scanf("%d%d%d", &y, &m, &d);
		ans = 195*y;
		if (y > 1) ans += 5*((y-1)/3);
		if (y % 3) ans += 19*(m-1) + m/2; else ans += (m-1)*20;
		ans += d;
		printf("%d\n", M-ans);
	}
	return 0;
}

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
#define SZ(v) ((int)(v).size())
#define zero(v) memset(v,0,sizeof(v))
#define rep(i,n) for(int i=0;i<(n);i++)
#define foreach(it,c) for(__typeof(c.begin()) it=c.begin();it!=c.end();it++)
#define all(v) (v).begin(),(v).end()
template<typename T>inline bool chkmin(T &a,const T &b){return a>b?a=b,1:0;}
template<typename T>inline bool chkmax(T &a,const T &b){return a<b?a=b,1:0;}
typedef long long ll;
typedef unsigned uint;
const int INF=0x3f3f3f3f;
const double EPS=1e-10;
typedef pair<int,int>P;
int inline in(){int x=0,c;for(;(uint)((c=getchar())-'0')>=10;)
{if(c=='-')return -in();if(!~c)throw ~0;}do{x=(x<<3)+(x<<1)+(c-'0');}
while((uint)((c=getchar())-'0')<10);return x;}
int n,k,c;
const int Maxn=2e5+5;
char s[Maxn];
bool B[Maxn];
vector<int>v;
int main(){
	scanf("%d%d%d%s",&n,&k,&c,s+1);
	int p=1;
	while(p<=n){
		while(s[p]=='x')p++;
		v.push_back(p);p+=c+1;
	}
	if(SZ(v)>k)return 0;
	zero(B);
	rep(i,SZ(v))B[v[i]]=true;
	v.clear();
	p=n;
	while(p>0){
		while(s[p]=='x')p--;
		v.push_back(p);p-=c+1;
	}
	reverse(all(v));
	rep(i,SZ(v)){
		if(B[v[i]]){
			printf("%d\n",v[i]);
		}
	}
	return 0;
}

Measured memory_bytes: 2804
#include <stdio.h>

int main(){
  int i,n,y,m,d, tmp;

  scanf("%d", &n);
  for(i=0;i<n;i++){
    scanf("%d %d %d", &y, &m, &d);
    printf("%d\n", 196471
	          -((y-1)*195 + (y-1)/3*5)
                  -((y%3==0) ? (m-1)*20 : (m-1)*20-(m-1)/2)
                  -d
      );
  }

  return 0;
}

Measured memory_bytes: 596
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        int i,j;
        Scanner sc = new Scanner(System.in);
        while(true) {
            int H = sc.nextInt();
            int W = sc.nextInt();
            if (H == 0 && W == 0) break;
            for(i=0;i<H;i++){
                for(j=0;j<W;j++){
                    if((i+j)%2 == 0){
                        System.out.printf("#");
                    }else{
                        System.out.printf(".");
                    }
                }
                System.out.printf("\n");
            }
            System.out.printf("\n");
        }
    }
}


Measured memory_bytes: 63844
#include <stdio.h>
#define true 1
#define false 0
#define MAX 2000

int A[MAX],n;

int solve(int i, int m) {
  int res;
  if(!m) return true;
  if(i >= n) return false;
  res = solve(i + 1, m) || solve(i + 1, m - A[i]);
  return res;
}

int main() {
  int q,m,i;
    
  scanf("%d", &n);
  
  for(i = 0; i < n; i++) {
    scanf("%d", &A[i]);
  }
  scanf("%d", &q);
  for(i = 0; i < q; i++) {
    scanf("%d", &m);
    if(solve(0, m)) printf("yes\n");
    else printf("no\n");
  }
  return 0;
}



Measured memory_bytes: 1976
/*  -*- coding: utf-8 -*-
 *
 * a.cc: C: Sentou
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 200000;
const int INF = 2147483647;

/* typedef */

typedef long long ll;

/* global variables */

int ts[MAX_N + 1];

/* subroutines */

/* main */

int main() {
  int n, t;
  scanf("%d%d", &n, &t);

  for (int i = 0; i < n; i++) scanf("%d", &ts[i]);
  ts[n] = INF;

  ll sum = 0;
  for (int i = 0; i < n; i++) sum += min(ts[i + 1] - ts[i], t);
  printf("%lld\n", sum);
  
  return 0;
}


Measured memory_bytes: 1024
"""マージソートを用いて安定かどうかを確認する。"""

from typing import List, Tuple
import math
import sys


class sort_object:
    """ソート対象のオブジェクト。必要に応じてプロパティやメソッドを増やす。"""

    def __init__(self, value: int, inf1='', inf2=''):
        self.value = value
        self.inf1 = inf1

    def set_value(self, value: int):
        self.set_value = value

    def get_value(self):
        return self.value

    def set_inf1(self, inf1):
        self.inf1 = inf1

    def get_inf1(self):
        return self.inf1

    def set_inf2(self, inf2):
        self.inf2 = inf2

    def get_inf2(self):
        return self.inf2


def merge(A: List[sort_object], left: int, mid: int, right: int) -> None:

    left_list = A[left:mid]
    right_list = A[mid:right]
    left_list.append(sort_object(sys.maxsize))
    right_list.append(sort_object(sys.maxsize))

    i = 0  # left_listのインデックス
    j = 0  # right_listのインデックス
    for k in range(left, right):
        if left_list[i].get_value() <= right_list[j].get_value():
            A[k] = left_list[i]
            i += 1
        else:
            A[k] = right_list[j]
            j += 1


def merge_sort(A: List[sort_object], left: int, right: int) -> int:
    if left + 1 < right:
        mid = math.floor((left + right) / 2)
        merge_sort(A, left, mid)
        merge_sort(A, mid, right)
        merge(A, left, mid, right)


def partition(A: List[sort_object], p: int, r: int) -> int:
    """パーティション

    A[p, ..., r]を、A[p, ..., q-1]とA[q+1, ..., r]二分割する。
    A[p, ..., q-1]の各要素は A[q]以下とする。
    A[q+1, ..., r]の各要素は A[q]より大きくする。

    Args:
        A (List[int]): 分割対象のリスト
        p (int): 分割対象のリストの先頭のインデックス
        r (int): 分割対象のリストの最後のインデックス

    Returns:
        int: q
    """
    tmp = A[r].get_value()
    i = p - 1
    for j in range(p, r):
        if A[j].get_value() <= tmp:
            i += 1
            A[i], A[j] = A[j], A[i]
    A[i + 1], A[r] = A[r], A[i + 1]
    return i + 1


def quick_sort(A: List[sort_object], p: int, r: int) -> None:
    if p < r:
        q = partition(A, p, r)
        quick_sort(A, p, q - 1)
        quick_sort(A, q + 1, r)
    return


n = int(input())
cards_1 = []
for _i in range(n):
    pic, num = map(str, input().split())
    num = int(num)
    cards_1.append(sort_object(num, pic))
cards_2 = [i for i in cards_1]

quick_sort(cards_1, 0, n - 1)
merge_sort(cards_2, 0, n)

if cards_1 == cards_2:
    print('Stable')
else:
    print('Not stable')
for c in cards_1:
    print(c.get_inf1(), c.get_value())



Measured memory_bytes: 29580
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;

#define FOR(i,f,t) for(int i=(int)f; i<(int)t; i++)
#define FORR(i,f,t) for(int i=(int)f; i>(int)t; i--)
#define ms(obj, val) memset(obj, val, sizeof(obj))
#define pb push_back
#define SYNC ios_base::sync_with_stdio(false)
#define inf 2248012
#define mp make_pair
#define F first
#define S second
#define ri(x) scanf("%d",&x)
#define rii(x,y) scanf("%d %d",&x,&y)
#define riii(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define lri(x) scanf("%lld",&x)
#define lrii(x,y) scanf("%lld %lld",&x,&y)
#define lriii(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)

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

const int MAXN = 1e6+3; //AREGLAAAAAAAAR!!!!
int m[100];
int main(){
    ll n;
    lri(n);
    ll y=n,d=0,ans=0;
    while(y/10){
        ans+=y%10;
        y/=10; 
        d++;
    }
    ans+=y;
    y=n;
    FOR(i,0,d+1){
        m[d-i]=y%10;
        y/=10;        
    }
    ll l=0;
    FOR(i,0,d){
        if(!i && m[i]>1){
            ans=max(ans,(d-i)*9+m[i]-1);
            break;
        }else if(i && m[i]>0){
            ans=max(ans,l+(d-i)*9+m[i]-1);
            break;
        }
        l+=m[i];
    }
    ans=max(ans,d*9);
    printf("%lld\n",ans);

}

Measured memory_bytes: 256
n=int(input())
bag=[]
ans="Yes"
total=0
for i in range(n):
    a,b=map(int,input().split())
    bag.append([a,b])
d=sorted(bag, key=lambda x:x[1])

for j in range(n):
    total=total+d[j][0]
    if total>d[j][1]:
        ans="No"
        

print(ans)

Measured memory_bytes: 41320
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }



int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(25);

  int a, b, c, d;
  cin >> a >> b >> c >> d;
  
  while (1) {
    c -= b;
    if (c <= 0) {
      cout << "Yes" << '\n';
      return 0;
    }
    a -= d;
    if (a <= 0) {
      cout << "No" << '\n';
      return 0;
    }
  }




  
  return 0;
}

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

int main() {
	int n, k;
	scanf("%d%d", &k, &n);
	if (k == 1) {
		for (int i = 0; i < (n + 1) / 2; i++)
			printf("1 ");
	} else if (k % 2) {
		int64_t num = 0, cur = 1;
		int i = 0;
		for (; i < n && num < 10000000LL; i++)
			num += cur *= k;
		if (i == n) {
			int64_t t = (num - 1) / 2;
			std::vector<int> res;
			for (int i = 0; i < n; i++) {
				if (i) {
					if (!t) break;
					t--, num--;
				}
			  num /= k;
				res.push_back(t / num);
				t %= num;
			}
			for (auto j : res) printf("%d ", j + 1);
		} else {
			int shift = 0;
			std::vector<int> res;
			for (int j = 0; j < n - i; j++) {
        if (j && (n - j) % 2) shift++;
				res.push_back((k + 1) / 2);
			}
			num++;
			int64_t t = (num - 1) / 2 - shift;
			assert(t >= 0);
      for (int j = n - i; j < n && t; j++) {
				t--, num--;
				num /= k;
				res.push_back(t / num + 1);
				t %= num;
			}
      for (auto j : res) printf("%d ", j);

		}
	} else {
		printf("%d", (k + 1) / 2);
		for (int i = 0; i + 1 < n; i++)
			printf(" %d", k);
	}
  return 0;
}


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

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

    string s;
    cin >> s;
    int ans = 1e9;
    rep(i,s.size()-2){
        int a = s[i] - '0', b = s[i + 1] - '0', c = s[i + 2] - '0';
        int x = 100 * a + 10 * b + c;
        ans = min(ans, abs(x - 753));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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 long long INF = 1LL << 60;

int main(){
  int a, b, c, x;
  cin >> a >> b >> c >> x;

  int cnt = 0;
  rep(i, a+1){
    rep(j, b+1){
      rep(k, c+1){
        if(500*i + 100*j + 50*k == x) cnt++;
      }
    }
  }

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const ll INF = 1e18;

int main(){
    int p;
    cin >> p;
    ll n = p-1, m = p, inv[n+1];
    rep2(i, 1, n+1){
        inv[i] = 1;
        ll e[31];
        e[0] = i;
        rep2(j, 1, 30) e[j] = (e[j-1]*e[j-1]) % m;
        ll k = m-2;
        int count = 0;
        while(k > 0){
            if(k % 2 == 1) inv[i] *= e[count], inv[i] %= m;
            k /= 2;
            count++;
        }
    }
    ll fac[p], invfac[p];
    fac[0] = 1, invfac[0] = 1;
    rep2(i, 1, p-1){
        fac[i] = (fac[i-1]*i)%p;
        invfac[i] = (invfac[i-1]*inv[i])%p;
    }
    ll a[p], b[p];
    fill_n(b, p, 0);
    rep(i, p){
        cin >> a[i];
        if(a[i] == 0) continue;
        b[0]++;
        ll ex[p];
        ex[0] = 1;
        rep2(j, 1, p-1) ex[j] = (ex[j-1]*(p-i))%p;
        rep(j, p){
            ll s = ex[p-1-j]*fac[p-1]*invfac[p-1-j]*invfac[j];
            s %= p;
            b[j] += p-s;
            b[j] %= p;
        }
    }
    rep(i, p) cout << b[i] << endl;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<string.h>

int main(void) {
	char s[101], t[101];
	
	scanf("%s", s);
	scanf("%s", t);

	int s_len = strlen(s);
	char s_res[101];
	for (int i=0; i<s_len; i++) {
		int min_idx = 0;
		for (int j=1; j<s_len; j++) {
			if (s[j] < s[min_idx]) {
				min_idx = j;
			}
		}

		s_res[i] = s[min_idx];
		s[min_idx] = 'z';
	}

	s_res[s_len] = '\0';

	int t_len = strlen(t);
	char t_res[101];
	for (int i=0; i<t_len; i++) {
		char max_idx = 0;
		for (int j=1; j<t_len; j++) {
			if (t[j] > t[max_idx]) {
				max_idx = j;
			}
		}

		t_res[i] = t[max_idx];
		t[max_idx] = 'a';
	}

	t_res[t_len] = '\0';

	//printf("%s\n", s_res);
	//printf("%s\n", t_res);
	if (strcmp(s_res, t_res) < 0) {
		printf("Yes\n");
	} else {
		printf("No\n");
	}

	return 0;
}


Measured memory_bytes: 128
S=str(input())
T=str(input())

ls=len(S)
lt=len(T)


DP=[[0]*(lt+1) for _ in range(ls+1)]


for i in range(1,ls+1):
    for j in range(1,lt+1):
        if S[i-1]==T[j-1]:
            DP[i][j]=max(DP[i-1][j-1]+1,DP[i][j-1],DP[i-1][j])
        else:
            DP[i][j]=max(DP[i][j-1],DP[i-1][j])

lf=DP[ls][lt]

res=''
u=ls
v=lt
while u>0 and v>0:
    if DP[u][v]==DP[u-1][v]:
        u-=1
    elif DP[u][v]==DP[u][v-1]:
        v-=1
    else:
        res=S[u-1]+res
        u-=1
        v-=1

print(res)

Measured memory_bytes: 112476
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#define all(v) v.begin(), v.end()
#define repi(i, n, init) for (ll i = init; i < (n); i++)
#define repd(i, n, init) for (ll i = (n); i >= init; i--)
#define repm(i, m) for (auto i = m.begin(); i != m.end(); i++)
#define repb(bit, n, init) for (ll bit = init; bit < (1 << n); ++bit)

template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val)
{
    std::fill((T *)array, (T *)(array + N), val);
}

int main()
{
    ll a, b, n;
    cin >> a >> b >> n;
    ll ans = a * min(b-1,n) / b - min(b-1,n) / b * a;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3604
from collections import deque
from collections import defaultdict
N, Q = map(int, input().split())
C = [0]* N
D = defaultdict(set)
for i in range(N-1):
  a, b = map(int, input().split())
  D[a-1].add(b-1)
  D[b-1].add(a-1)
for i in range(Q):
  p, x = map(int, input().split())
  C[p-1] += x

Q = deque([])
Q.append(0)
vstd = set()

while len(Q)>0:
  a = Q.popleft()
  vstd.add(a)
  for b in D[a]:
    if b in vstd:
      continue
    C[b] += C[a]
    Q.append(b)

print (" ".join(map(str, C)))


Measured memory_bytes: 118848
import copy
def solve():
    c = []
    for i in range(3):
        tmp = list(map(int,input().split()))
        c.append(tmp)
    
    for a1 in range(0, 100+1):
        b1 = c[0][0] - a1
        b2 = c[0][1] - a1
        b3 = c[0][2] - a1

        a2 = c[1][0] - b1
        if a2 != c[1][1] - b2 or a2 != c[1][2] - b3:
            continue


        a3 = c[2][0] - b1
        if a3 != c[2][1] - b2 or a3 != c[2][2] - b3:
            continue

        print('Yes')
        break
    else:
        print('No')

if __name__ == '__main__':
    solve()

Measured memory_bytes: 38384
#include <stdio.h>

int main(void)
{
	int a = 0;
	int b = 0;
	int c = 0;
	
	scanf("%d %d %d", &a, &b, &c);
	
	if (a < b) {
		if (b < c) {
			printf("Yes\n");
		}
		else {
			printf("No\n");
		}
	}
	else{
		printf ("No\n");
	}
	
	return (0);
}

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

void chmax(ll &a, ll b){
  if( a < b){ swap(a,b);} return ;}

int main(){
 ll N,K; scanf("%lld %lld", &N,&K);
 vector<ll> A(N);
  for(ll i = 0; i < N; i++){ scanf("%lld", &A[i]);}
  
  ll dp[50][2]; 
  for(ll i = 0; i  < 50; i++){
    for(ll j = 0; j < 2; j++){ dp[i][j] = -1;}} 
  // -1 は、当該のdp[i][j]が未更新であることを表す
  // j == 0 は、上から見ていってすでにK未満であることを、1は以下であることを表す
  
  dp[45][1] = 0;
  
  for(ll d = 44; d >= 0; d--){
    ll num = 0; ll mask = 1LL << d;
    // d桁目について、それを上げるか下げるかを考える
    for(ll i = 0; i < N; i++){ if( A[i] & mask){ num++;}}
    
    if( dp[d+1][0] >= 0){
      //これは、すでに X < Kなる場合が存在する時
      //この時、この桁については1でも0でも構わない
      chmax(dp[d][0], dp[d+1][0]+mask*max(num,N-num));
    }
    
    if( dp[d+1][1] >= 0){
      
     if( !(K & mask)){ //
      chmax( dp[d][1], dp[d+1][1]+mask*num);
     }
     else{
       chmax( dp[d][0], dp[d+1][1]+mask*num);
       chmax( dp[d][1], dp[d+1][1]+mask*(N-num));
     }
                         }
             
      
  }
             
    printf("%lld\n", max(dp[0][0], dp[0][1]));
    return 0;}
      
    
    
    
    

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

bool is_n(string s) { char ch = s[0]; return '0' <= ch and ch <= '9'; }
bool is_b(string s) { char ch = s[0]; return 'a' <= ch and ch <= 'z'; }
bool is_s(string s) { char ch = s[0]; return 'A' <= ch and ch <= 'Z'; }

vector<string> split(string s) {
    s += "!";
    vector<string> ret;
    string num = "";
    rep(i, s.size()) {
        char ch = s[i];
        if ('0' <= ch and ch <= '9') {
            num += ch;
        }
        else {
            if (num.size() > 0) {
                ret.push_back(num);
                num = "";
            }
            if (ch != '!') {
                string tmp = ""; tmp += ch;
                ret.push_back(tmp);
            }
        }
    }
    return ret;
}

int main() {
    int n;
    string base;
    cin >> n >> base;
    vector<string> b = split(base);
    b.emplace_back("!");

    rep(i, n) {
        string tmp;
        cin >> tmp;
        vector<string> a = split(tmp);
        a.emplace_back("!");
        bool pls = true;
        rep(j, min(a.size(), b.size())) {
            string a1 = a[j], b1 = b[j];
            if (a1 == b1 and a1 == "!") break;
            else if (a1 == "!") {
                pls = false; break;
            }
            else if (b1 == "!") {
                break;
            }
            if (is_n(a1) and is_n(b1)) {
                ll an = stoll(a1);
                ll bn = stoll(b1);
                if (an == bn) continue;
                else if (bn > an) { pls = false; break; }
                else break;
            }
            else if (is_n(a1)) {
                pls = false;
                break;
            }
            else if (is_n(b1)) {
                break;
            }
            else {
                if ( (is_b(a1) and is_b(b1)) or (is_s(a1) and is_s(b1)) ) {
                    if (a1 == b1) continue;
                    else if (b1 > a1) { pls = false; break; }
                    else break;
                }
                else if (is_b(a1) and is_s(b1)) {
                    break;
                }
                else if (is_s(a1) and is_b(b1)) {
                    pls = false; break;
                }
            }
        }
        cout << (pls ? "+" : "-") << endl;
    }
    return 0;
}



Measured memory_bytes: 3196
import math

n,d=map(int, input().split())
l=[]*n
for i in range(n):
  x=list(map(int, input().split()))
  l.append(x)

cnt=0
for i in range(n):
  for j in range(i+1,n):
    dis=0
    for k in range(d):
      dis += (l[i][k]-l[j][k])**2
    dis = math.sqrt(dis)

    if dis==math.floor(dis):
      cnt+=1
print(cnt)

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

int main(void)
{
  int H, W;
  char C[105][105];

  cin >> H >> W;
  for (int i = 1; i <= H; ++i)
  {
    for (int j = 1; j <= W; ++j)
    {
      cin >> C[i][j];
    }
  }

  for (int i = 1; i <= H * 2; ++i)
  {
    for (int j = 1; j <= W; ++j)
    {
      cout << C[(i + 1) / 2][j];
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
class item {
public:
	string name;
	int price;
	vector<int> recipe;
};
bool compare(item &a, item &b) {
	return a.name < b.name;
}
int find(vector<item> &, string);
int make(vector<item> &, int);
int main() {
	int buy;
	while (cin >> buy&&buy != 0) {
		vector<item> line(buy);
		for (int i = 0; i < buy; ++i) {
			cin >> line[i].name >> line[i].price;
		}
		sort(line.begin(), line.end(), compare);
		int time;
		cin >> time;
		for (int j = 0; j < time; ++j) {
			string d;
			int num;
			cin >> d >> num;
			int place = find(line, d);
			for (int i = 0; i < num; ++i) {
				cin >> d;
				line[place].recipe.push_back(find(line, d));
			}
		}
		string d;
		cin >> d;
		cout << make(line, find(line, d)) << endl;
	}
	return 0;
}

int find(vector<item> &line, string name) {
	int sp = 0;
	int up = line.size();
	while (true) {
		int tmp = (sp + up) / 2;
		if (line[tmp].name==name) {
			return tmp;
		}
		else if (line[tmp].name < name) {
			sp = tmp + 1;
		}
		else {
			up = tmp;
		}
	}
}

int make(vector<item> &line, int place) {
	int res = line[place].price;
	if (!line[place].recipe.empty()) {
		int res2 = 0;
		for (int i = 0, nmax = line[place].recipe.size(); i < nmax; ++i) {
			res2 += make(line, line[place].recipe[i]);
		}
		return min(res, res2);
	}
	return res;
}

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

int main(){
    char ch;
    int num;
    int counter[26]={};

    while(scanf("%c", &ch) != EOF){
        if(isalpha(ch)){
            if(isupper(ch)){
                ch=tolower(ch);
            }
            num=(ch-'a');
            for(int i=0;i<26;i++){
                if(num==i){
                    counter[i]+=1;
                }
            }
        }
    }
    for(int j=0;j<26;j++){
        printf("%c : %d\n",j+'a',counter[j]);
    }
    return 0;
}


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


int main() {
    ll A,B,K;
    cin >> A >> B >> K;
    rep2(i,A,B + 1) {
        if (i - A < K || B - i < K) {
            cout << i << endl;
        }
    }
}




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

typedef long long int ll;


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

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

    ll ans = 0;

    for(ll i=1;i+1<n;i++)
    {
        vector <ll> vec;
        vec.push_back(arr[i-1]);
        vec.push_back(arr[i]);
        vec.push_back(arr[i+1]);
        sort(vec.begin(),vec.end());
        if(arr[i]==vec[1]){
            ans++;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define For(i,x,y) for (register int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (register int i=(x);i<(y);i++)
#define Dow(i,x,y) for (register int i=(x);i>=(y);i--)
#define Debug(v) for (auto i:v) printf("%lld ",i);puts("")
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ep emplace_back
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define fil(a,b) memset((a),(b),sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef pair<ll,ll> PA;
typedef vector<int> poly;
inline ll read(){
    ll x=0,f=1;char c=getchar();
    while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
    if (c=='-') f=-1,c=getchar();
    while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*f;
}

const int N = 2e5+10;
int n,pre[N];
char s[N];

int main(){
	scanf("%d%s",&n,s+1);
	For(i,1,n) pre[i]=pre[i-1]+(s[i]=='.');
	int ans=n;
	For(i,0,n) ans=min(ans,(i-pre[i])+(pre[n]-pre[i]));
	printf("%d\n",ans);
}

Measured memory_bytes: 4736
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <functional>
#include <initializer_list>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, a, n) for (int i = (a); i < (int)(n); i++)
#define repc(i, a, n) for (int i = (a); i <= (int)(n); i++)
#define all(t) t.begin(), t.end()
#define rall(t) t.rbegin(), t.rend()
#define mat(type, row, col, init)                                              \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
#define DBG(str) cerr << (str) << endl;
int main() {
  vector<int> a(3);
  rep(i, 0, 3) cin >> a[i];
  sort(all(a));
  Yes(a[0] + a[1] == a[2]);
  return 0;
}


Measured memory_bytes: 256
n = gets.to_i
a = Array.new(n); b = Array.new(n);
a = gets.split(" ").map(&:to_i);
b = a.uniq.sort {|a, b| a <=> b}
if b.length == 1 && b[0] == 0
    puts "Yes"
elsif b.length != 3
    if b.length == 2
        if n % 3 == 0
            if b[0] == 0
                if a.count(b[1]) == n*2/3
                    puts "Yes"
                else
                    puts "No"
                end
            else
                puts "No"
            end
        else
            puts "No"
        end
    else
        puts "No"
    end
elsif b[0] ^ b[1] == b[2]
    if n == 3
        puts "Yes"
    elsif n % 3 == 0
        c = n / 3
        if a.count(b[0]) == c && a.count(b[1]) == c
            puts "Yes"
        else
            puts "No"
        end
    else
        puts "No"
    end
else
    puts "No"
end
            

Measured memory_bytes: 13836
x,k,d = map(int,input().split())

x = abs(x)

if x > k*d:
    print(x-k*d)
else:
    val = x // d
    if val % 2 == 0:
        if k % 2 == 0:
            print(x%d)
        else:
            print(abs(x%d-d))
    else:
        if k % 2 == 0:
            print(abs(x%d-d))
        else:
            print(x%d)

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

int gcd(int a, int b) {
	while (b) {
		int c = a % b;
		a = b;
		b = c;
	}
	return a;
}

int main()
{
	int n, m;
	string s, t;
	cin >> n >> m >> s >> t;
	
	int g = gcd(n, m);
	
	int dn = n / g;
	int dm = m / g;
	
	for (int i = 0, j = 0; i < n && j < m; i += dn, j += dm) {
		if (s[i] != t[j]) {
			cout << -1 << endl;
			return 0;
		}
	}
	
	cout << (n * 1LL * m) / g << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include<math.h>
using namespace std;
long long n;

int main()
{
	cin >> n;
	int x[50];
	n++;
	int i, flg = 0;
	for (i = 0; i < 50 && n>0; i++) {
		x[i] = n&1;
		n >>= 1;
		if ( n&& x[i])
			flg = 1;
	}
	if (!flg) {
		cout << i << endl;
		cout << "1";
		for (int j = 2; j <= i; j++)
			cout << " 1";
		return 0;
	}
	int y[101],z[101];
	int a=0,b = 0,c=100;
	for (int j = 0; j <i-1; j++) {
		if (x[j]) {
			z[++b] = c--;
			y[++a] = c--;
		}
		else {
			y[++a] = c--;
		}
	}
	cout << 200 - c*2<< endl;
	cout << z[1];
	for (int j = 2; j <= b; j++)
		cout << " "<<z[j];
	for (int j = a; j >=1; j--)
		cout << " "<<y[j] ;
	for (int j = c + 1; j <= 100; j++)
		cout << " " << j;
}



Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
// #include <C:\include\boost\multiprecision\cpp_int.hpp>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define divup(a,b) ( ( (a) + ( (b) - 1u) ) / (b) ) // a/b の余り切り上げ
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
// using namespace boost::multiprecision;
ll mod = 1000000007;

ll bubbleSort(vector<ll> &a,ll n){
    bool flag=true;
    ll ct=0;
    while(flag){
        flag=false;
        for(int j=n-1;j>0;j--){
            if(a[j]<a[j-1]){
                ll aa=a[j];
                a[j]=a[j-1];
                a[j-1]=aa;
                ct++;
                flag=true;
            }
        }
    }
    return ct;
}

int main(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    ll k =bubbleSort(a,n);
    rep(i,n){
        if(i==n-1) cout<<a[i]<<endl;
        else cout<<a[i]<<" ";
    }
    cout<<k<<endl;
}



Measured memory_bytes: 3100
#include <stdio.h>
#include <string.h>

int main() {
	char str[1000];
	char str1[] = "s";
	char str2[] = "es";
	int i = 0;
	scanf("%s", str);
	while (str[i] != '\0') {
		i++;
	}
	i--;
	if (str[i] != 's') {
		strcat(str, str1);
		printf("%s", str);

	}

	if (str[i] == 's') {
		strcat(str, str2);
		printf("%s", str);
	}
	return 0;
}

Measured memory_bytes: 2152
from math import floor

num = [int(_) for _ in input().split()]


col_num = num[1] + num[2]

line = floor(num[0] / col_num)

count = line * num[1]

temp = num[0] % col_num
if temp == 0:
    pass
else:
    count += min(temp,num[1])

print(count)

Measured memory_bytes: 38740
def solve():
    import numpy as np
    from sys import stdin
    f_i = stdin
    
    N, T = map(int, f_i.readline().split())
    AB = [tuple(map(int, f_i.readline().split())) for i in range(N)]
    AB.sort()
    max_Ai = AB[-1][0]
    
    dp = [[0] * T for i in range(N + 1)]
    dp = np.zeros(max_Ai + T, dtype=int)
    
    
    for A_i, B_i in AB:
        dp[A_i:A_i+T] = np.maximum(dp[A_i:A_i+T], dp[:T] + B_i)
    
    print(max(dp))

solve()

Measured memory_bytes: 83176
package main
import "fmt"
func main() {
  var n,a,b uint
  fmt.Scan(&n,&a,&b)
  if popcnt(a)%2 == popcnt(b)%2 { fmt.Println("NO");return }
  fmt.Println("YES")
  p := compose(n,a,b)
  fmt.Print(p[0])
  for i:=1;i<len(p);i++ { fmt.Print(" ");fmt.Print(p[i]) }
  fmt.Println()
}
func compose(n,a,b uint) []uint {
  if n == 1 { return []uint{a,b} }
  d := a^b
  var x,y,c,k uint
  for i:=uint(0);i<n;i++ {
    if (d>>i)&1 == 0 { continue }
    l := uint(0)
    for j:=uint(0);j<n;j++ {
      if j == i { l++;continue }
      if (a>>j)&1 == 1 { x |= 1<<(j-l) }
      if (b>>j)&1 == 1 { y |= 1<<(j-l) }
    }
    c = x|1
    if x&1 == 1 { c = x^1 }
    k = i
    break
  }
  q := compose(n-1,x,c)
  r := compose(n-1,c,y)
  m := len(q)
  p0 := make([]uint,m)
  p1 := make([]uint,m)
  for i:=0;i<m;i++ {
    l := uint(0)
    for j:=uint(0);j<n;j++ {
      if j == k {
        if (a>>j)&1 == 1 { p0[i] |= 1<<j }
        if (b>>j)&1 == 1 { p1[i] |= 1<<j }
        l++
        continue
      }
      if (q[i]>>(j-l))&1 == 1 { p0[i] |= 1<<j }
      if (r[i]>>(j-l))&1 == 1 { p1[i] |= 1<<j }
    }
  }
  return append(p0,p1...)
}
func popcnt(n uint) int {
  m := 0
  for i:=uint(0);i<32;i++ {
    if (n>>i)&1 == 1 { m++ }
  }
  return m
}

Measured memory_bytes: 8832
#include <bits/stdc++.h>
#include <string>
using namespace std;
#define INF (1e9)

int main(void){
  long long n,cnt = 0, ans = INF, t;
  scanf("%lld",&n);

  for (int i = 0; i <= n; i++) {
    t = i;
    cnt = 0;
    while (t>0) {
      cnt += t % 6;
      t /= 6;
    }
    t = n - i;
    while (t>0) {
      cnt += t % 9;
      t /= 9;
    }
    if (cnt < ans) {
      ans = cnt;
    }
  }

  printf("%d", ans);

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
bool sugar[3005], water[3005];
int main() {
  int a, b, c, d, e, f;
  scanf("%d %d %d %d %d %d", &a, &b, &c, &d, &e, &f);
  sugar[0] = true;
  water[0] = true;
  for (int i = 1; i <= 3000; i++) {
    if (i >= 100 * a) {
      water[i] |= water[i - 100 * a];
    }
    if (i >= 100 * b) {
      water[i] |= water[i - 100 * b];
    }
    if (i >= c) {
      sugar[i] |= sugar[i - c];
    }
    if (i >= d) {
      sugar[i] |= sugar[i - d];
    }
  }
  double maxx = -1, maxi = 0, maxj = 0;
  for (int i = 1; i <= 3000; i++) {
    for (int j = 0; j <= 3000; j++) {
      if (water[i] && sugar[j] && i + j <= f && i * e >= j * 100) {
        if (1.0 * j / (i + j) > maxx) {
          maxx = 1.0 * j / (i + j);
          maxi = i;
          maxj = j;
        }
      }
    }
  }
  printf("%.0f %.0f\n", maxi + maxj, maxj);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define data_type long long
#define endl "\n"
#define mod 1000000007

int main()
{
    ios_base::sync_with_stdio(false),cin.tie(nullptr);
    data_type c=0,ans=0;
    string str;
    cin>>str;
    for(auto i:str)
    {
       if(i=='R')
       c++;
       else
         c=0;
         ans=max(ans,c);
    }

    cout<<ans<<endl;

    return 0;
}


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

void solve(){

    // A * B + C = N
    int n; cin>>n;
    //int a,b,c;
    int count=0;
    
    for(int i=1;i<n;i++)
    {
        count+=(n-1)/i;
    }

    cout<<count;
}

int main()
{
    solve();
}

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

int main()
{
    int h, w; cin>>h>>w;
    vector<string> s(h); for(e: s) cin>>e;
    bool ok=true;
    for(int i=0; i+1<h; ++i)
        for(int j=0; j+1<w; ++j) {
            if (s[i][j]=='#' and s[i][j+1]=='#' and s[i+1][j]=='#') ok=false;
            if (s[i+1][j]=='#' and s[i][j+1]=='#' and s[i+1][j+1]=='#') ok=false;
        }
    cout<<(ok ? "Possible" : "Impossible")<<endl;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
B = list(map(int, input().split()))
cnt = 0
rest = 0
for i in range(N-1, -1, -1):
    b = B[i]
    a = A.pop(-1)
    if b <= a:
        cnt += b
    else:
        cnt += a
        b -= a
        if b <= A[-1]:
            cnt += b
            A[-1] -= b
        else:
            cnt += A[-1]
            A[-1] = 0
print(cnt)

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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pf push_front
#define iter(v, i) for (__typeof__((v).begin()) i = (v).begin(); i != (v).end(); i++)
#define fast_io_without_cstdio ios_base::sync_with_stdio(false), cin.tie(NULL)
#define all(v) (v).begin(), (v).end()
#define rep(i, s, e) for (int i = s; i < e; i++)

// START for segment tree
#define params int p, int L, int R
#define housekeep int mid = (L + R) >> 1, left = p << 1, right = left | 1
// END

#ifdef __linux__
#define gc getchar_unlocked
#define pc putchar_unlocked
#else
#define gc getchar
#define pc putchar
#endif

#if __cplusplus <= 199711L
template<class BidirIt>
BidirIt prev(BidirIt it, typename iterator_traits<BidirIt>::difference_type n = 1) {
    advance(it, -n);
    return it;
}

template<class ForwardIt>
ForwardIt next(ForwardIt it, typename iterator_traits<ForwardIt>::difference_type n = 1) {
    advance(it, n);
    return it;
}
#endif

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

const double EPS = 1e-9;
const double PI = 3.141592653589793238462;

template<typename T>
inline T sq(T a) { return a * a; }

//#ifdef LOCAL_MACHINE
//#endif

int ar[105];

int main() {
    //freopen("", "r", stdin);
    //freopen("", "w", stdout);
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &ar[i]);
    }
    vi vec;
    for (int i = 1; i <= 10000; i++) {
        bool found = false;
        for (int j = 1; j <= n; j++)
            if (ar[j] == i) found = true;
        if (!found) vec.pb(i);
    }
    int ptr = 0;
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (ar[i] == ar[i - 1]) {
            ans++;
            ar[i] = vec[ptr++];
        }
    }
    printf("%d\n", ans);
    return 0;
}



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

using namespace std;

int main(){
  int n,m;
  int check;

  cin >> n >> m;
  check = n;

  while(m--){
    cin >> n;
    check = __gcd(n,check);
  }

  cout << (check == 1 ? "Yes" : "No") << endl;

  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define fi first
#define se second
#define em emplace
#define eb emplace_back
#define mp make_pair
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int((v).size())
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i) 
#define rep2(i, n, m) for (ll i = n; i <= (ll)(m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (ll)(m); --i)

template<class T, class U> bool chmax(T &a, U b) { if (a < b) a = b; return true; }
template<class T, class U> bool chmin(T &a, U b) { if (a > b) a = b; return true; }

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007;

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

  int k, t; cin >> k >> t;
  vi a(t);

  rep(i, t) cin >> a[i];
  int mx = *max_element(all(a));

  cout << max(0, mx * 2 - k - 1) << endl;

  return (0);
}


Measured memory_bytes: 3572
#include <time.h>
#include <stdio.h>
#include <stdlib.h>

int main()
{
	int  i, sum = 0;
	char s[6];
	
	for (i = 0; i < 6; i++){
		scanf("%c", &s[i]);
		sum += s[i] - '0';
	}

	printf("%d", sum);

	
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstring>

using namespace std;

const int MAX = 21;
int data[MAX][MAX];

pair<int,int> p;
int sum;

void N(int in, int m){
  for(int i = 0; i < in; i++){
    p.first += m;
    if(data[p.first][p.second]){
      sum--;
      data[p.first][p.second] = 0;
    }
  }
}

void E(int in, int m){
  for(int i = 0; i < in; i++){
    p.second += m;
    if(data[p.first][p.second]){
      sum--;
      data[p.first][p.second] = 0;
    }
  }
}

void move(char c, int i){
  if(c == 'N') N(i,1);
  if(c == 'S') N(i,-1);
  if(c == 'E') E(i,1);
  if(c == 'W') E(i,-1);
}

int main(){

  int in;
  while(cin >> in && in){
    sum = in;
    p.first = p.second = 10;
    memset(data,0,sizeof(data));
    for(int i = 0; i < in; i++){
      int x,y;
      cin >> x >> y;
      data[y][x] = 1;
    }

    int num;
    cin >> num;
    for(int i = 0; i < num; i++){
      char c; int a;
      cin >> c >> a;
      move(c,a);
    }
    if(sum) cout << "No" << endl;
    else cout << "Yes" << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <list>
#include <algorithm>
#include <ctime>
#include <limits>
#include <cmath>


using namespace std;

//  ||
// \

int main(){
	int a = 0, b = 0, c = 0;
	cin >> a >> b >> c;
	int sum = a + b + c;
	if(sum == 17) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
 
    return 0;
}

Measured memory_bytes: 256