akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder.ABC095.B
{
    class Program
    {
        static void Main ()
        {
            var sc = new Scanner ();
            int n = sc.NextInt ();
            int x = sc.NextInt ();
            var m = sc.ArrayInt (n);
            var x2 = x - m.Sum ();
            Console.WriteLine (n + x2 / m.Min ());
        }

    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner ()
        {
            s = new string[0];
            i = 0;
        }

        public string Next ()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine ();
            while (st == "") st = Console.ReadLine ();
            s = st.Split (cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return Next ();
            i = 0;
            return s[i++];
        }

        public int NextInt ()
        {
            return int.Parse (Next ());
        }
        public int[] ArrayInt (int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextInt () + add;
            }
            return Array;
        }

        public long NextLong ()
        {
            return long.Parse (Next ());
        }

        public long[] ArrayLong (int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextLong () + add;
            }
            return Array;
        }

        public double NextDouble ()
        {
            return double.Parse (Next ());
        }

        public double[] ArrayDouble (int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextDouble () + add;
            }
            return Array;
        }

        public decimal NextDecimal ()
        {
            return decimal.Parse (Next ());
        }

        public decimal[] ArrayDecimal (int N, decimal add = 0)
        {
            decimal[] Array = new decimal[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextDecimal ();
            }
            return Array;
        }
    }
}

Measured memory_bytes: 13268
import java.util.Scanner;

public class Main {

	public static int a,b,c,d,e,f;

	public static int water(int i, int j) {
		return 100*i*a + 100*j*b;
	}
	public static int sugar(int i, int j) {
		return i*c + j*d;
	}
	public static double noudo(int w, int s) {
		if(w == 0) return 0;
		else return (double)s/ ((double)w+(double)s);
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		a = sc.nextInt();
		b = sc.nextInt();
		c = sc.nextInt();
		d = sc.nextInt();
		e = sc.nextInt();
		f = sc.nextInt();

		int max_w = 0;
		int max_s = 0;
		//i,j,k,lは操作の回数
		for(int i =0; i<=30; i++) {
			for(int j=0; j<=30; j++) {
				for(int k=0; k<=100; k++) {
					for(int l=0; l<=100; l++) {
						if(water(i,j)+sugar(k,l)<=f && noudo(water(i,j),sugar(k,l))<=noudo(100,e)) {
							if(noudo(water(i,j),sugar(k,l)) >= noudo(max_w, max_s)) {
								max_w = water(i, j);
								max_s = sugar(k,l);
							}
						}
					}
				}
			}
		}
		int ans = max_w+max_s;
		System.out.println(ans+" "+max_s);

	}
}


Measured memory_bytes: 22740
N, K = map(int, input().split())
a = list(map(int, input().split()))

dp = [0] * (K + 1)

for i in range(1, K + 1):
    for j in a:
        if i - j >= 0 and dp[i - j] == 0:
            dp[i] = 1

print('First' if dp[K] else 'Second')


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

#define REP(i, n) for (int i=0; i<n; i++)
#define print(x) cout << x << endl

typedef long long ll;

using namespace std;

void solve() {
    
    int N;
    cin >> N;
    vector<int> L(N);
    REP(i, N) cin >> L[i];
    sort(L.begin(), L.end());
    int ans = 0;
    for (int i = 0; i < N; i++) {
        for (int j = i+1; j < N; j++) {
            int d = L[i] + L[j];
            int k = distance(L.begin(), lower_bound(L.begin()+j, L.end(), d));
            ans += k - 1 - j;
        }
    }
    print(ans);
}

signed main() {
    solve();
}


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

int A(int x,int y){
  return x+y;
}

int B(int x,int y){
  return x-y;
}

int C(int x,int y){
  return x*y;
}

int D(int x,int y){
  return x/y;
}


int main() {
  int a,b;
  char op;
  while(1){
    
    cin >> a >> op >> b;
    
    if(op == '?')
      break;
    
    if(op == '+')
      cout << A(a,b) << endl;
    
    if(op == '-')
      cout << B(a,b) << endl;
    
    if(op == '*')
      cout << C(a,b) << endl;
    
    if(op == '/')
      cout << D(a,b) << endl;
   
  }
}



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

int main() {
	int n,i,j,cur;
	cin >> n;
	vector<int> d(2*n);
	for(i=0; i<n; i++){
		cin >> d[2*i] >> d[2*i+1];
	}
	
	cur=0;
	for(i=0; i<n; i++){
		if(d[2*i]==d[2*i+1]){
			cur++;
			if(cur==3){
				cout << "Yes" << endl; return 0;
			}
		}else{
			cur=0;
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3628
N = int(input())
S=[]
for i in range(N):
  s=input()
  S.append(s)
  
print("AC x "+str(S.count("AC")))
print("WA x "+str(S.count("WA")))
print("TLE x "+str(S.count("TLE")))
print("RE x "+str(S.count("RE")))

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

#define REP(i, s, n) for(int i = s; i < n; ++i)
#define rep(i, n)		 REP(i, 0, n)
#define SORT(c)			 sort((c).begin(), (c).end())
#define IINF					INT_MAX
#define LLINF					LLONG_MAX
#define DEBUG					false

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

int main() {

	int n, k, x, y;
	cin >> n >> k >> x >> y;
	
	cout << min(n, k) * x + max(0, n - k) * y <<endl;
	
	return 0;
}

Measured memory_bytes: 384
#!/usr/bin/python3
# -*- coding: utf-8 -*-



H,W = map(int, input().split())
Sn = [[None for _ in range(W)] for _ in range(H)]
for h in range(H):
  s = str(input())
  for w in range(W):
    if s[w] == ".":
      Sn[h][w] = True
    else:
      Sn[h][w] = False

H_cnt = [[1 for _ in range(W)] for _ in range(H)]
for h in range(H):
  for w in range(W):
    if Sn[h][w] and w>0:
      H_cnt[h][w] = H_cnt[h][w-1]+1
    elif not Sn[h][w]:
      H_cnt[h][w] = 0
  for w in range(W-2,-1,-1):
    if H_cnt[h][w+1] > 0 and H_cnt[h][w] > 0:
      H_cnt[h][w] = H_cnt[h][w+1]

W_cnt = [[1 for _ in range(W)] for _ in range(H)]
for w in range(W):
  for h in range(H):
    if Sn[h][w] and h>0:
      W_cnt[h][w] = W_cnt[h-1][w]+1
    elif not Sn[h][w]:
      W_cnt[h][w] = 0
  for h in range(H-2,-1,-1):
    if W_cnt[h+1][w] > 0 and W_cnt[h][w] > 0:
      W_cnt[h][w] = W_cnt[h+1][w]


ans = 0
for h in range(H):
  for w in range(W):
    if H_cnt[h][w]*W_cnt[h][w] > 0:
      ans = max(ans, H_cnt[h][w]+W_cnt[h][w]-1)
print(ans)

Measured memory_bytes: 138376
H, W, A, B = map(int, input().split())

grid_1 = [0] * A + [1] * (W - A)
grid_2 = [1] * A + [0] * (W - A)

for i in range(B):
    print(*grid_1, sep='')
for i in range(H - B):
    print(*grid_2, sep='')

Measured memory_bytes: 76908
n = int(input())
p = list(map(int, input().split()))

cnt = 0
for i in range(n - 2):
    if p[i] < p[i + 1] < p[i + 2]:
        cnt += 1
    elif p[i] > p[i + 1] > p[i + 2]:
        cnt += 1
print(cnt)


Measured memory_bytes: 3064
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().solve();
	}
	
	int N;
	int A,B;
	
	void solve(){
		Scanner sc=new Scanner(System.in);
		N=sc.nextInt();
		A=sc.nextInt();
		B=sc.nextInt();
		
		//パスカルの三角形
		long [][]c=new long[51][51]; //c[n][k]=nCk
		for(int i=0;i<51;i++){
			for(int j=0;j<=i;j++){
				if(j==0 || j==i)c[i][j]=1;
				else{
					c[i][j]=c[i-1][j]+c[i-1][j-1];
				}
			}
		}
		
		Long[] v=new Long[N];
		
		for(int i=0;i<N;i++){
			v[i]=sc.nextLong();
		}

		Arrays.sort(v,Comparator.reverseOrder());
		
		double max_Ave=0;
		long max_sum=0;
		for(int i=0;i<A;i++){
			max_sum+=v[i];
		}
		max_Ave=(double)max_sum/(double)A;
		String ans=String.format("%.6f", max_Ave);
		
		System.out.println(ans);
		
		if(v[0].equals(v[A-1])){
			int X=0;
			
			for(int i=0;i<N;i++){
				if(v[i].equals(v[0])){
					X++;
				}
			}
			
			long sum=0;
			for(int i=A;i<=B;i++){
				sum+=c[X][i];
			}
			System.out.println(sum);
			
		}else{
			int X=0;
			int Y=0;
			for(int i=0;i<N;i++){
				if(v[i].equals(v[A-1]))X++;
			}
			for(int i=0;i<A;i++){
				if(v[i].equals(v[A-1]))Y++;
			}
			
			System.out.println(c[X][Y]);
		}
	}
}

Measured memory_bytes: 22100
from collections import Counter
n = int(input())
alphabet = Counter(input())
for _ in range(n-1):
    counter = Counter(input())
    for i in range(26):
        alphabet[chr(i+97)] = min(alphabet[chr(i+97)], counter[chr(i+97)])
print(''.join(a*num for a, num in sorted(alphabet.items())))


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

#define trace(...) __f( #__VA_ARGS__ , __VA_ARGS__ )
template <typename Arg1>
void __f( const char* name , Arg1&& arg1 ) {
        cerr << name << " : " << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void __f( const char* na , Arg1&& arg1 , Args&&... args ) {
        const char* c = strchr( na + 1 , ',' );
        cerr.write( na , c - na ) << " : " << arg1 << " , ";
        __f( c + 1 , args... );
}
#define endl "\n"
#define all(V) V.begin(),V.end()
#define Unique(V) sort(all(V)),V.erase(unique(all(V)),V.end())
#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long int LL;
typedef pair <int,int> pii;
const int MOD = 1e9 + 7;
const int inf = 1e9;
const double EPS = 1e-9;
const double PI = acos(-1.0);
const long long INF = 1e18;
const int N = 1e5 + 5;

int main( ) {
        IO;
        #ifdef LOCAL
            //freopen( "input.txt" , "r" , stdin );
        #endif // LOCAL
        LL n;
        cin >> n;
        cout << ( n * ( n - 1 ) / 2 ) << endl;
        return 0;
}










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

int main() {
    ll n, k;
    string s;
    cin >> n >> k >> s;
    k--;
    s[k] = s[k] - 'A' + 'a';
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3628
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')

#Pythonを用いる場合
#numpy 1.18.0, scipy 1.4.1, scikit-learn 0.22, numba 0.47.0, networkx 2.4

#import numpy as np
#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
#from scipy.sparse import csr_matrix

 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n=ii()

ans=0

for i in range(1,n+1):
    
    q=(n//i)*(2*i+i*(n//i -1))//2
    ans+=q
print(ans)



Measured memory_bytes: 77076
n = int(input())
v = [int(i) for i in input().split()]


def gcd(x, y):
    if y > x:
        x, y = y, x
    if y == 0:
        return x
    if x % y == 0:
        return y
    return gcd(y, x % y)


l = [0 for i in range(n)]
r = [0 for i in range(n)]

for i in range(1, n):
    l[i] = gcd(l[i - 1], v[i - 1])
for i in range(n - 1)[::-1]:
    r[i] = gcd(r[i+1], v[i+1])
m = [gcd(l[i], r[i]) for i in range(n)]
print(max(m))


Measured memory_bytes: 14432
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<set>
#include<vector>
using namespace std;
int main(){
long long int a,b,x;
cin>>a>>b>>x;
if(a%x==0)
cout<<b/x-a/x+1<<endl;
if(a%x!=0)
cout<<b/x-a/x<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define ll long long
#define MAX 1000000007
#define mod % MAX

using namespace std;

ll max(ll a,ll b){
  if(a > b){
    return a;
  }
  return b;
}
int main(void){
  ll num;
  cin >> num;
  vector<vector<ll>> maps(num,vector<ll>(2));
  for(int i = 0;i < num;i ++){
    cin >> maps[i][0];
    cin >> maps[i][1];
  }
  vector<ll> migiue(2);
  migiue = maps[0];
  vector<ll> migisita(2);
  migisita = maps[0];
  vector<ll> hidaue(2);
  hidaue = maps[0];
  vector<ll> hidasita(2);
  hidasita = maps[0];
  for(int i = 0;i < num;i ++){
    if(hidasita[0]+hidasita[1] < maps[i][0] + maps[i][1]){
      hidasita = maps[i];
    }
    if(hidaue[0]-hidaue[1] < maps[i][0] - maps[i][1]){
      hidaue = maps[i];
    }
    if(-migisita[0]+migisita[1] < -maps[i][0] + maps[i][1]){
      migisita = maps[i];
    }
    if(-migiue[0]-migiue[1] < -maps[i][0] - maps[i][1]){
      migiue = maps[i];
    }
  }
  ll ans = max(hidasita[0] - migiue[0] +hidasita[1] - migiue[1]  ,hidaue[0]-migisita[0]-hidaue[1]+migisita[1]);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 14340
#include<bits/stdc++.h>
using namespace std;
const int MAXN=100005;
int main(){
    int n;
    cin>>n;
    int ans;
    ans = n%1000;
    if(ans!=0)
        cout<<1000-ans<<endl;
    else
        cout<<0<<endl;
    return 0;
}

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

using namespace std;

#define fi first
#define se second
#define eb emplace_back
#define mt make_tuple
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

ll INF=LLONG_MAX;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	int x,y,a,b,c;
	cin >> x >> y >> a >> b >> c;
	vi p(a),q(b),r(c);
	for(auto &i:p)cin >> i;
	for(auto &i:q)cin >> i;
	for(auto &i:r)cin >> i;
	sort(p.rbegin(),p.rend());
	sort(q.rbegin(),q.rend());
	sort(r.rbegin(),r.rend());
	priority_queue<int,vi, greater<int>>pp,qq;
	for(int i=0; i<x; i++)pp.push(p[i]);
	for(int i=0; i<y; i++)qq.push(q[i]);
	while(!r.empty()){
		int cmpp = r[0]-pp.top();
		int cmpq = r[0]-qq.top();
		if(cmpp<0&&cmpq<0)break;
		if(cmpp>=cmpq){
			pp.pop();
			pp.push(r[0]);
		}else{
			qq.pop();
			qq.push(r[0]);
		}
		r.erase(r.begin());
	}
	ll ans = 0LL;
	for(int i=0; i<x; i++){
		ans += pp.top();
		pp.pop();
	}
	for(int i=0; i<y; i++){
		ans += qq.top();
		qq.pop();
	}
	cout << ans << endl;
}
	
// READ & UNDERSTAND
// ll, int overflow, array bounds, memset(0)
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN


Measured memory_bytes: 2552
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#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() {
  int a,b,c,k;
  cin >> a >> b >> c >> k;
  int ans = max({a,b,c});
  int n = a+b+c - ans;
  ans <<= k;
  ans += n;
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        long n = Long.parseLong(sc.next());
        long k = Long.parseLong(sc.next());
        long x = 0;
        x = Math.min(n % k, k - n % k);

        System.out.print(x);
    }
}


Measured memory_bytes: 23764
N, Y = map(int, input().split())

for x in range(N + 1):
    for y in range(N - x + 1):
        z = N - x - y
        price = 10000 * x + 5000 * y + 1000 * z
        if price == Y:
            print(x, y, z)
            exit()
print(-1, -1, -1)

Measured memory_bytes: 3060
n = gets.to_i
h = gets.chomp.split.map(&:to_i).reverse

h.each_with_index do |hh, i|
  next if i == h.size - 1
  diff = h[i] - h[i+1]
  if diff < -1
    puts 'No'
    exit
  end

  if diff == -1
    h[i+1] -= 1
  end
end
puts 'Yes'


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

int main() {
	int N, M, K[50], A[50][50];
	int ans = 0;
	int s[50] = { 0 };

	cin >> N >> M;

	for (int i = 1;i <= N; i++) {
		cin >> K[i];
		for (int j = 1; j <= K[i]; j++) {
			cin >> A[i][j];
			s[A[i][j] - 1]++;

		}
	}

	for (int i = 0; i <= M - 1; i++) {
		if (s[i] == N)ans++;
	}

	cout << ans;

	return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=1;i<=n;i++)
using namespace std;
using ll = long long;
using ld = long double;
int mod = 1000000007;
int main(){
    ll n,k;
    int i,j;
    cin >> n >> k;
    vector<ll> b(n);
    ll d;
    rep(i,k){
        d=0;
        cin >> d;
        rep(j,d){
            int a;
            cin >> a;
            b.at(a-1)++;
        }
    }
    ll ans=0;
    rep(i,n){
        if(b.at(i-1)==0)ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
import collections

n = int(input())
ls = [list(map(int, input().split())) for _ in range(n - 1)]
es = [[] for _ in range(n + 1)]
for u, v, w in ls:
    b = w % 2 == 0
    es[u].append([v, b])
    es[v].append([u, b])

cs = [-1 for _ in range(n + 1)]
cs[1] = 0
q = collections.deque([1])
while len(q) > 0:
    x = q.popleft()
    for y, b in es[x]:
        if cs[y] >= 0:
            continue
        cs[y] = cs[x] if b else 1 - cs[x]
        q.append(y)
print(*cs[1:], sep='\n')

Measured memory_bytes: 61176
//#pragma GCC optimize(3)
#define _CRT_SECURE_NO_WARNINGS

#include<bits/stdc++.h>

typedef long long LL;
using namespace std;

#define MAXN 200005

char t[MAXN];
char a[MAXN];
int tongt[4];//LRUD
int tonga[4];
bool a1[MAXN];

int main() {
	//ios::sync_with_stdio(false);
	//cin.tie(0);
	int groups;
	//scanf("%d", &groups);
	groups = 1;
	for (int i = 0; i < groups; i++) {
		int h, w, n, sr, sc;
		char tempt, tempa;
		bool flag = false;
		scanf("%d%d%d", &h, &w, &n);
		scanf("%d%d", &sc, &sr);
		scanf("%s", t);
		scanf("%s", a);
		for (int j = 0; j < n; j++) {
			if (t[j] == 'L') tongt[0]++;
			if (t[j] == 'R') tongt[1]++;
			if (t[j] == 'U') tongt[2]++;
			if (t[j] == 'D') tongt[3]++;
			if (a[j] == 'L') tonga[0]++;
			if (a[j] == 'R') tonga[1]++;
			if (a[j] == 'U') tonga[2]++;
			if (a[j] == 'D') tonga[3]++;
			if (tonga[0] - tongt[1] >= sr) {
				tonga[0]--;
				a1[j] = true;
			}
			if (tonga[1] - tongt[0] >= (w - sr + 1)) {
				tonga[1]--;
				a1[j] = true;
			}
			if (tonga[2] - tongt[3] >= sc) {
				tonga[2]--;
				a1[j] = true;
			}
			if (tonga[3] - tongt[2] >= (h - sc + 1)) {
				tonga[3]--;
				a1[j] = true;
			}
		}
		for (int j = n - 1; j >= 0; j--) {
			if (a[j] == 'L' && !a1[j]) tonga[0]--;
			if (a[j] == 'R' && !a1[j]) tonga[1]--;
			if (a[j] == 'U' && !a1[j]) tonga[2]--;
			if (a[j] == 'D' && !a1[j]) tonga[3]--;
			if (tongt[0] - tonga[1] >= sr) flag = true;
			if (tongt[1] - tonga[0] >= (w - sr + 1))flag = true;
			if (tongt[2] - tonga[3] >= sc) flag = true;
			if (tongt[3] - tonga[2] >= (h - sc + 1)) flag = true;
			if (flag) break;
			if (t[j] == 'L') tongt[0]--;
			if (t[j] == 'R') tongt[1]--;
			if (t[j] == 'U') tongt[2]--;
			if (t[j] == 'D') tongt[3]--;
		}
		if (flag) printf("NO");
		else printf("YES");
	}
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main()
{
	// 整数の入力
    string input;
    cin >> input;
 
    string first = input.substr(0,2);
    string second = input.substr(2,2); 
    
    int first_num = atoi(first.c_str());
    int second_num = atoi(second.c_str());
    
    bool first_MM = true;
    bool second_MM = true;
  
    if(first_num > 12 || first_num < 1)
    {
        first_MM = false;
    }
    if(second_num > 12 || second_num < 1)
    {
        second_MM = false;
    }
    
    if(first_MM && second_MM)
    {
        // どちらもOK
        cout << "AMBIGUOUS";
    }
    else if(first_MM)
    {
        // MMYY フォーマットのみ
        cout << "MMYY";
    }
    else if(second_MM)
    {
        // YYMM フォーマットのみ
        cout << "YYMM";
    }
    else
    {
        // どちらもだめ   
        cout << "NA";
    }
    
    return 0;
}

Measured memory_bytes: 3508
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
sum_a = sum(a)
count_a = Counter(a)
q = int(input())
for i in range(q):
    b, c = map(int, input().split())
    tmp = count_a[b]
    new = {c : tmp}
    count_a.update(new)
    del count_a[b]
    sum_a = sum_a - b * tmp + c * tmp
    print(sum_a)

    

 



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

int main() {
    int n, a[11000], cnt = 0;
    cin >> n;
    for (int i = 0; i < n; ++i) cin >> a[i];

    for (int i = 0; i < n; ++i) {
        bool sosu = true;
        for (int j = 2; j * j <= a[i]; ++j) {
            if (a[i] % j == 0) {
                sosu = false;
                break;
            }
        }
        if (sosu) ++cnt;
    }

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


Measured memory_bytes: 3076
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <random>
#include <typeinfo>
#include <type_traits>

using namespace std;

template <typename T>	constexpr T	rep_start(const T &end)			{ return 0; }
template <typename T>	constexpr T	rep_start(const T &start, const T &end)	{ return start; }
template <typename T>	constexpr T	rep_end(const T &end)				{ return end; }
template <typename T>	constexpr T	rep_end(const T &start, const T &end)		{ return end; }

#define rep(index, ...) for (auto index = rep_start(__VA_ARGS__); index < rep_end(__VA_ARGS__); ++index)
#define irep(index, ...) for (auto index = rep_end(__VA_ARGS__) - 1; index >= rep_start(__VA_ARGS__); --index)

using llong = long long;
using ullong = unsigned long long;

int main ()
{
	int N;
	cin >> N;
	vector<int> h(N+1);
	h[0] = 0;
	rep(i, 1, N+1) cin >> h[i];

	int count = 0;
	rep(i, 1, N+1)
	{
		count += max(0, h[i] - h[i-1]);
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 1e-5
#define LONG_INF 1000000000000000000LL
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL
#define MOD 998244353LL
#define seg_size 262144*4
#define REP(a,b) for(long long a = 0;a < b;++a)
long long dp[300][2];
int main() {
#define int long long
	string s;
	cin >> s;
	long long k;
	cin >> k;
	int ok = 1;
	for (int i = 1; i < s.length(); ++i) {
		if (s[i] != s[0]) ok = 0;
	}
	if (ok == 1) {
		k *= (long long)s.length();
		cout << k / 2 << endl;
		return 0;
	}
	long long pre_cost = 0;
	REP(q, 300) {
		REP(j, 2) {
			dp[q][j] = LONG_INF;
		}
	}
	dp[0][0] = 0;
	dp[0][1] = 1;
	for (int i = 1; i < s.length(); ++i) {
		if (s[i] == s[i - 1]) {
			dp[i][0] = dp[i - 1][1];
			dp[i][1] = min(dp[i - 1][1] + 1, dp[i - 1][0] + 1);
		}
		else {
			dp[i][0] = min(dp[i - 1][0], dp[i - 1][1]);
			dp[i][1] = min(dp[i - 1][1] + 1, dp[i - 1][0] + 1);
		}
	}
	pre_cost = min(dp[s.length() - 1][0], dp[s.length() - 1][1]);

	long long ans = LONG_INF;
	if (s[0] == s.back()) {
		REP(t, 2) {
			REP(q, 300) {
				REP(j, 2) {
					dp[q][j] = LONG_INF;
				}
			}
			dp[0][1] = 1;
			for (int i = 1; i < s.length(); ++i) {
				if (s[i] == s[i - 1]) {
					dp[i][0] = dp[i - 1][1];
					dp[i][1] = min(dp[i - 1][1] + 1, dp[i - 1][0] + 1);
				}
				else {
					dp[i][0] = min(dp[i - 1][0], dp[i - 1][1]);
					dp[i][1] = min(dp[i - 1][1] + 1, dp[i - 1][0] + 1);
				}
			}
			long long hoge = min(dp[s.length() - 1][0], dp[s.length() - 1][1]);
			long long pre_ans = hoge * (k - 1LL) + pre_cost;
			ans = min(ans, pre_ans);
			reverse(s.begin(), s.end());
		}
	}
	else {
		ans = pre_cost * k;
	}
	cout << ans << endl;
}

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

using namespace std;

int main(){
	int n,a,b;
	int rank=0;
	int kaigai=0;
	string s;
	cin >> n >> a >> b >> s;
	for(int i=0;i<n;i++){
		if(s[i]=='a'){
			rank+=1;
			if(rank<=(a+b))cout << "Yes" <<endl;
			else cout << "No" <<endl;
		}
		if(s[i]=='b'){
			kaigai+=1;
			if(kaigai<=b){
				if((rank+1)<=(a+b)){
					rank +=1;
					cout << "Yes" <<endl;
				}else{
					cout << "No" <<endl;
				}
			}else{
				cout << "No" <<endl;
			}
		}
		if(s[i]=='c'){
			cout << "No" <<endl;
		}
	}
	return 0;
}

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


using namespace std;

using ll   = long long;
using ii   = pair   < int , int >;
using i3   = pair   < int , ii  >;
using li   = pair   < ll  , int >;
using lii  = pair   < ll  , ii  >;
using pll  = pair   < ll  , ll  >;
using vi   = vector < int       >;
using vl   = vector < ll        >;
using vii  = vector < ii        >;
using vli  = vector < li        >;
using vpll = vector < pll       >;
using vi3  = vector < i3        >;
using vlii = vector < lii       >;


const int N = 2e5 + 5;
const ll INF = 1e17 + 7;
const double eps = 1e-9 , PI = acos(-1);



int n , m;

vi adj[N];
int h[N];


void solve(int testCase){

    scanf("%d %d" , &n , &m);

    for(int i = 1 ; i <= n ; i ++) scanf("%d" , &h[i]);

    for(int i = 0 ; i < m ; i ++) {
            int u , v;
            scanf("%d %d" , &u , &v);

            adj[u].push_back(v);
            adj[v].push_back(u);
    }

    int ans = 0;
    for(int i = 1 ; i <= n ; i ++) {
            bool ok = 1;

            for(int v : adj[i]) {
                    if(h[v] >= h[i]) ok = 0;
            }

            if(ok) ans ++;
    }

    printf("%d\n" , ans);

}

main(){

    int t = 1;
    // scanf("%d" , &t);

    for(int testCase = 1 ; testCase <= t ; testCase ++){
            solve(testCase);
    }

    return 0;
}


Measured memory_bytes: 11688
H=int(input())+1
A=[0]+list(map(int,input().split()))
def h(i):
 l=2*i;r=l+1
 g=i
 if l<H and A[i]<A[l]:g=l
 if r<H and A[g]<A[r]:g=r
 if g>i:A[i],A[g]=A[g],A[i];h(g)
for i in range(H//2,0,-1):h(i)
print(' '+' '.join(map(str,A[1:])))


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)

int main() {
    fastio
    int x;
    cin >> x;
    int mini = x/100;
    if(mini*105 <x  || x <100)
        cout<<0<<endl;
    else
        cout<<1<<endl;
    
	return 0;
}






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

using namespace std;

#define int long long
#define ll long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl



signed main() {

	int N, M;
	cin >> N >> M;
	vector<int> A(N);
	vector<P> BC(M);
	rep(i, N) cin >> A[i];
	rep(i, M) cin >> BC[i].first >> BC[i].second;

	rep(i, N) {
		BC.push_back(P(1, A[i]));
	}

	sort(BC.begin(), BC.end(), 
		[](P & a, P & b) {return a.second > b.second; });

	int ans = 0;
	int cur = 0;
	for(P p : BC){

		if (cur + p.first > N) {
			ans += p.second * (N-cur);
			break;
		}
		cur += p.first;
		ans += p.first * p.second;
	}

	cout << ans << endl;


	return 0;
}


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

//グローバル変数たち
const int limit=50;
int k, n;
int x[limit+1], y[limit+1];//点の集合
int xline[limit+1], yline[limit+1];//辺の集合

int main(){
  cin >> n >> k;
  for(int i=1; i<=n; i++) {
    cin >> x[i] >> y[i];
    xline[i] = x[i]; yline[i] = y[i];
  }

  sort(xline+1, xline+n+1);
  sort(yline+1, yline+n+1);

  long long int ans = 1LL * (xline[n]-xline[1]) * (yline[n]-yline[1]);

  //まず長方形を作成して条件を満たすものだけについて最小値更新
  for(int xi=1; xi<=n; xi++){
    for(int xj=xi+1; xj<=n; xj++){
      for(int yi=1; yi<=n; yi++){
        for(int yj=yi+1; yj<=n; yj++){

          //長方形確定
          long long int xl = xline[xi], xr = xline[xj];
          long long int yu = yline[yi], ya = yline[yj];

          int cnt=0;//長方形内に入っている点のカウント
          for(int i=1; i<=n; i++){
            if(xl<=x[i] && x[i]<=xr && yu<=y[i] && y[i]<=ya) cnt++;
          }
          //もしkこ以上の点を含むなら最小値更新
          if(cnt>=k){
            long long int nd = 1LL * (xr-xl) * (ya-yu);
            ans = min(ans, nd);
          }
        }
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 384
#include<cstdio>
class segment_tree
{
	private:
		int mx[1200005];
		inline int max(int a,int b)
		{
			return a>b?a:b;
		}
		inline void update(int k)
		{
			mx[k]=max(mx[k<<1],mx[k<<1|1]);
		}
	public:
		void change(int k,int l,int r,int pos,int x)
		{
			if(l==r&&r==pos)
			{
				mx[k]=x;
				return;
			}
			int mid=l+r>>1;
			if(mid>=pos)
				change(k<<1,l,mid,pos,x);
			else
				change(k<<1|1,mid+1,r,pos,x);
			update(k);
		}
		int query(int k,int l,int r,int x,int y)
		{
			if(x<0)
				x=0;
			if(y>300000)
				y=300000;
			if(l>=x&&r<=y)
				return mx[k];
			int mid=l+r>>1,res=0;
			if(mid>=x)
				res=max(res,query(k<<1,l,mid,x,y));
			if(mid<y)
				res=max(res,query(k<<1|1,mid+1,r,x,y));
			return res;
		}
}t;
int n,k,a[300005];
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;++i)
		scanf("%d",&a[i]);
	for(int i=1;i<=n;++i)
		t.change(1,0,300000,a[i],t.query(1,0,300000,a[i]-k,a[i]+k)+1);
	printf("%d",t.query(1,0,300000,0,300000));
}

Measured memory_bytes: 7004
#include<bits/stdc++.h>
#define ll long long
#define vll vector<ll>
using namespace std;
ll dp[504][504],a[504][504];
int main()
{
	string s;
	cin>>s;
	if(s.size()<4)cout<<"No";else
	if(s[0]=='Y'&&s[1]=='A'&&s[2]=='K'&&s[3]=='I')cout<<"Yes";else cout<<"No";
}

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

// 入力
int n, W;
int weight[110], value[110];

// DPテーブル
int dp[110][10010];

int main() {
    cin >> n >> W;
    for (int i = 0; i < n; ++i) cin >> value[i] >> weight[i];

    // DP初期条件
    for (int w = 0; w <= W; ++w) dp[0][w] = 0;

    // DP
    for (int i = 0; i < n; i++) {
        for (int w = 0; w <= W; w++) {
            //wの方がweight[i]より大きい=>dp[i][w](そのままのやつ)とdp[i][w-weight[i]](i行のw-weigth[i])の最大値比べる
            if (w >= weight[i]) dp[i+1][w] = max(dp[i][w-weight[i]] + value[i], dp[i][w]);
            else dp[i+1][w] = dp[i][w];
        }
    }

    cout << dp[n][W] << endl;
}


Measured memory_bytes: 7024
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
#define pvec(vec) {for (auto v: vec) cout << v << ' '; cout << endl;}
#define pivec(vec) {rep(i, 0, vec.size()) cout << i << ':' << vec[i] << ' '; cout << endl;}

using namespace std;
using ll = long long;
const int maxcnt = 20;

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

    ll cnt = 0;
    vector<vector<int>> dp(maxcnt, vector<int>(maxcnt, 0));
    rep(i, 0, N)
    {
        string s;
        cin >> s;

        ll now;
        if (s.find('.') == string::npos)
            now = stoll(s) * (ll)1e9;
        else
        {
            string s1, s2;
            s1 = s2 = "";
            int pos = s.find('.');
            s1 = s.substr(0, pos);
            s2 = s.substr(pos+1);

            s2 += string(9-s2.size(), '0');

            now = stoll(s1) * (ll) 1e9;
            now += stoll(s2);
            // printf("now: %lld, s1: %s, s2: %lld\n", now, s1.c_str(), stoll(s2));
        }

        int c2, c5;
        c2 = c5 = 0;
        while (now%2 == 0){ ++c2; now /= 2;}
        while (now%5 == 0){ ++c5; now /= 5;}

        c2 = min(c2, maxcnt-1);
        c5 = min(c5, maxcnt-1);

        rep(i, 0, maxcnt)
            rep(j, 0, maxcnt)
            if (i+c2>=18 and j+c5>=18)
                cnt += dp[i][j];

        ++dp[c2][c5];
        // printf("now: %lld\n", now);
        // printf("s: %s, c2: %d, c5: %d, cnt: %lld\n", s.c_str(), c2, c5, cnt);
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
bool f[100001];
int c[100002],n,l,r;
int main()
{
	int i,j;
    for (i=2;i<=100000;i++)
    {
        if (!f[i])
        {
	        for (j=i+i;j<=100000;j+=i)
	        {
	            f[j]=true;
	        }
	    }
    }
    for (i=3;i<=100000;i+=2)
    {
        if (!f[i] && !f[(i+1)/2])
        {
            c[i]++;
        }
    }
    for (i=3;i<=100000;i++)
    {
        c[i]+=c[i-1];
    }
    cin>>n;
    while (n--)
    {
        cin>>l>>r;
        cout<<c[r]-c[l-1]<<endl;
    }
}

Measured memory_bytes: 1152
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include <iomanip>
#include<cmath>
#include<stdio.h>
#include<map>
#define rep(i,n) for(int i=0;i<(n);i++)
#define ll long long
#define sort(s) sort(s.begin(),s.end())
#define r(s) reverse(s.begin(),s.end())
#define please return
constexpr auto AC = 0;
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> h(n),dp(n,0);
	rep(i, n)cin >> h[i];
	rep(i, n) {
		if (i == 0)dp[i] = 0;
		else {
			if (i == 1)dp[i] = abs(h[0] - h[1]);
			else {
				dp[i] = min(dp[i - 2] + abs(h[i] - h[i - 2]), dp[i - 1] + abs(h[i] - h[i - 1]));
			}
		}
	}
	cout << dp[n - 1] << endl;
	please AC;
}

Measured memory_bytes: 1024
#include <vector>
#include <algorithm>
#include <iostream>
#include <set>
using namespace std;

struct edge{
	int to,cap,rev;
    int rIdx;
};

const int MAX_V = 500;
const int INF = 100000000;

vector<edge> G[MAX_V];
bool used[MAX_V];
// ¹ª·ÅÉè³êÄ¢é©Ç¤©
bool decided[10001];
bool isRevEdge[10001];

void add_edge(int from,int to,int cap,int idx){
	edge e;
	e.to = to;
	e.cap = cap;
	e.rev = G[to].size();
    e.rIdx=idx;
	G[from].push_back(e);

	e.to = from;
	e.cap = 0;
	e.rev = G[from].size()-1;
	G[to].push_back(e);
}
// ÁpXðTõ
int dfs(int v,int t,int f){
    if(v==t)
		return f;
	used[v]=true;
	for(int i=0; i<G[v].size(); i++){
		edge &e = G[v][i];
        // Vµ¢¹©Ç¤©
        bool ok=false;
        bool change=false;
        if(!decided[e.rIdx]){
            ok=true;
            decided[e.rIdx]=true;
            // tü«É¬µÄ¨­
            if(e.cap==0){
                change=true;
                isRevEdge[e.rIdx]=true;
                G[e.to][e.rev].cap=0;
                e.cap=1;
            }
        }
        if(!used[e.to]&&e.cap>0){
			int d=dfs(e.to,t,min(f,e.cap));
			if(d>0){
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
            else{
                // ¡ñÏXÅ«È¢êÅAtü«É¬µÄ¢éÌÅ êÎAC³·é
                if(ok){
                    decided[e.rIdx]=false;
                    if(isRevEdge[e.rIdx]&&change){
                        isRevEdge[e.rIdx]=false;
                        G[e.to][e.rev].cap=1;
                        e.cap=0;
                    }
                }
            }
		}
        else{
            if(ok){
                decided[e.rIdx]=false;
                if(isRevEdge[e.rIdx]&&change){
                    isRevEdge[e.rIdx]=false;
                    G[e.to][e.rev].cap=1;
                    e.cap=0;
                }
            }
        }
	}
	return 0;
}

int max_flow(int s,int t){
	int flow = 0;
    fill(isRevEdge,isRevEdge+10001,false);
    fill(decided,decided+10001,false);
	while(1){
		fill(used,used+MAX_V,false);
		int f = dfs(s,t,INF);
		if(f==0)
			return flow;
		else
			flow+=f;
	}
}

int main(){
    int n,m;
    cin>>n>>m;
    for(int i = 0; i < m; i++){
        int from,to;
        cin>>from>>to;
        add_edge(from,to,1,i);
    }
    int s,t;
    cin>>s>>t;
    int res=max_flow(s,t);
    cout<<res<<endl;
    set<int> ss;
    for(int i = 0; i < m; i++)
        if(isRevEdge[i])
            ss.insert(i);
    cout<<ss.size()<<endl;
    for(set<int>::iterator it = ss.begin();it!=ss.end();it++)
        cout<<(*it+1)<<endl;
    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 2*1e5+10;
const int MOD = 1e9 + 7;
const int INF = 1e18 + 10;



void printVector(vector<int> s){
    for(int &x:s){
        cout<<x<<" ";
    }
    cout<<endl;
}



void solve(){
    int n ;
    cin>>n;
    vector<vector<int>> arr(n+1 , vector<int>(3));
    vector<vector<int>> dp(n+1 , vector<int>(3));
    for(int i = 0 ; i < n ; i++){
        for(int j = 0 ; j < 3 ; j++){
            cin>>arr[i][j];
        }
    }
    dp[0][0] = arr[0][0];
    dp[0][1] = arr[0][1];
    dp[0][2] = arr[0][2];
    if(n==1){
        cout<<max({dp[0][0] , dp[0][1] , dp[0][2]})<<endl;
        return;
    }
    for(int i = 1; i < n ; i++){
        for(int j = 0 ; j < 3 ; j++){
            dp[i][j] = arr[i][j];
            if(j==0){
                dp[i][j] += max(dp[i-1][1] , dp [i-1][2]);
            }
            else if(j==1){
                dp[i][j] += max(dp[i-1][0] , dp [i-1][2]);
            }
            else{
                dp[i][j] += max(dp[i-1][0] , dp [i-1][1]);
            }
        }
    }
    for(int i = 0 ; i < n ; i++){
//        printVector(dp[i]);
    }
    cout<<max({dp[n-1][0] , dp[n-1][1] , dp[n-1][2]})<<endl;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
//    cin>>t;
    t = 1;
    for(int i = 0 ; i < t ; i++){
        solve();
    }
    return 0;
}

Measured memory_bytes: 14220
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)

	nums := make([]int, n)
	for i := range nums {
		fmt.Scan(&nums[i])
	}

	cp := make([]int, n)
	copy(cp, nums)
	sort.Sort(sort.IntSlice(cp))

	var cnt int
	for i := 0; i < n; i++ {
		if nums[i] != cp[i] {
			cnt++
		}
	}

	if cnt < 3 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }

    static class Task {
        void solve(InputReader in, PrintWriter out) {
            int N = in.nextInt();
            int A = in.nextInt();
            int change = N % 500;
            out.println(change <= A ? "Yes" : "No");
        }
    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }
    }
}

Measured memory_bytes: 23380
#include <stdio.h>

int main(void){ 

int a,b,c,i=0,Count=0;  

scanf("%d %d %d",&a,&b,&c);  

for(i=a;i<=b;i++){ 

if(c%i==0){ 

Count++; 

} 

} 

printf("%d\n",Count);   

return 0;

}

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

#define ll long long int
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define sep(i,b,a) for(ll i=b-1;i>=a;i--)
#define hell (ll)(1e9+7)
#define pii pair <ll,ll>
#define vi vector <ll>
#define pb push_back
#define inf 1000000000000000

using namespace std;

void solve()
{
    ll n,ans;
    cin>>n;
    ans=inf;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            ans=min(ans,abs(i-1)+abs(n/i-1));
        }
    }
    cout<<ans;
}

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


Measured memory_bytes: 256
n, k = map(int, input().split())
A = list(map(int, input().split()))

ans = float("inf")
for i in range(2 ** n):
    can_see_list = list(bin(i)[2:].zfill(n))
    cost = 0
    now_hieght = A[0]
    if can_see_list[0] == '1':
        if can_see_list.count('1') < k:
            continue
    else:
        if can_see_list.count('1') < k - 1:
            continue
    for num, can_see in enumerate(can_see_list):
        if can_see == "1":
            if now_hieght >= A[num]:
                cost += (now_hieght - A[num]) + 1
                now_hieght = now_hieght + 1
            else:
                now_hieght = A[num]
        else:
            now_hieght = max(now_hieght, A[num])
    ans = min(ans, cost)
print(ans)

Measured memory_bytes: 74040
import sys
from fractions import gcd
import bisect
 
stdin = sys.stdin
 
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
s = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

n = ni()
k = ni()
x = ni()
y = ni()

if n <= k:
        print(n * x)
else:
        print(k * x + (n - k) * y)

Measured memory_bytes: 5076
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <typeinfo>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T>
using Tree =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i = a; i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i, a, b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i, a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;  // check the limits, dummy

typedef long long ll;
const int inf = INT_MAX / 2;
const ll infl = 1LL << 60;
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 (b < a) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T>
void print(const vector<T> v) {
  cout << "[ ";
  F0R(i, v.size()) { cout << v[i] << ' '; }
  cout << "]" << '\n';
}

int mod(int i, int j) {
  return (i % j) < 0 ? (i % j) + 0 + (j < 0 ? -j : j) : (i % j + 0);
}

// --------------------------------------------------------
// This is tool
// --------------------------------------------------------
void Main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int N, a, b, bb, c;
  cin >> N;
  a = N / 100;
  b = N % 100;
  bb = b / 10;
  c = b % 10;

  if (a == 7 || bb == 7 || c == 7)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

Measured memory_bytes: 3652
import sys
import math
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":
    n ,y = I2()
    for i in range(n+1):
        for j in range(n+1-i):
            k = n - i - j
            if y//1000 == 10*i + 5*j + k:
                print(i,j,k)
                exit()
    print(-1,-1,-1)

Measured memory_bytes: 9228
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val t = arrayOf(1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51)
    println(t[sc.nextInt() - 1])
}

Measured memory_bytes: 31128
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
a_s=sum(a)
b_s=sum(b)
if a_s>b_s:
    print("No")
    exit()
count=b_s-a_s
temp1=0
temp2=0
for i in range(n):
    if a[i]>=b[i]:
        temp1+=a[i]-b[i]
    else:
        if a[i]%2==b[i]%2:
            temp2+=(b[i]-a[i])//2
        else:
            temp1+=1
            temp2+=(b[i]+1-a[i])//2

if temp1>count or temp2>count:
    print("No")
    exit()
if (count-temp1)==(count-temp2)*2:
    print("Yes")
else:
    print("No")

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

int main(){
	int a, b;
	char op[1];
	bool end = false;
	
	for(;;){
		cin >> a >> op[0] >> b;
	
		switch(op[0]){
		case '+':
			cout << a + b << endl;
			break;
		case '-':
			cout << a - b << endl;
			break;
		case '*':
			cout << a * b << endl;
			break;
		case '/':
			cout << a / b << endl;
			break;
		case '?':
			end = true;
			break;
		}
		if(end == true) break;
	}
	return 0;
}

Measured memory_bytes: 1160
rooms = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
n = int(input())
for i in range(n):
    b, f, r, v= map(int, input().split())
    rooms[b-1][f-1][r-1] += v
for i in range(4):
    for j in range(3):
        for k in range(10):
            print('', rooms[i][j][k], end='')
        print()
    if i < 3:
        print('####################')

Measured memory_bytes: 7720
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
#define INF 1000000000 // 1 billion, safer than 2B for Floyd Warshall’s
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pcont(x) for(auto i: x){cout << i << " ";} cout << "\n";

void put(int a){
    cout << a << "\n";
}

int main(){
    IOS;
    int x;
    cin >> x;
    if(x >= 400 && x<600)put(8);
    else if(x >= 600 && x<800)put(7);
    else if(x >= 800 && x<1000)put(6);
    else if(x >= 1000 && x<1200)put(5);
    else if(x >= 1200 && x<1400)put(4);
    else if(x >= 1400 && x<1600)put(3);
    else if(x >= 1600 && x<1800)put(2);
    else if(x >= 1800 && x<2000)put(1);
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include<vector>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
int main() {
  int a,b,c,d=3;cin>>a>>b>>c;
  if(a==b)d--;
  if(b==c)d--;
  if(a==c)d--;
  if(a==b&&a==c)d++;
  cout<<d;
}


Measured memory_bytes: 256