akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <vector>
#include <ctype.h>

const int MAX_SIZE = 1000;
char field[MAX_SIZE + 1][MAX_SIZE + 1];

const int STEP_NUM = 4;
const int STEP[STEP_NUM][STEP_NUM] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};

using Position = std::pair<int,int>;

const int MAXN = 10;
Position locations[MAXN];
 
int H, W, N;

int get_shortest_distance(int current_HP)
{
	int sx = locations[current_HP-1].first;
	int sy = locations[current_HP-1].second;
	int ex = locations[current_HP].first;
	int ey = locations[current_HP].second;

	bool is_visit[MAX_SIZE + 1][MAX_SIZE + 1]={};
	is_visit[sx][sy]=true;

	std::vector<Position> frontier(1,Position{sx,sy});
	for(int step=0;step<W*H;step++)
	{
		std::vector<Position> next_frontier;
		for(auto p:frontier)
			for(int i=0;i<STEP_NUM;i++)
			{
				int nx = p.first+STEP[i][0];
				int ny = p.second+STEP[i][1];
				if(nx==ex && ny==ey)	return step+1;
				if(nx<0 || H<=nx) 		continue;
				if(ny<0 || W<=ny) 		continue;
				if(field[nx][ny]=='X') 	continue;
				if(is_visit[nx][ny]) 	continue;
				next_frontier.push_back(std::make_pair(nx,ny));
				is_visit[nx][ny] = true;
			}
		frontier = next_frontier;
	}
	return -1;
}

int solve()
{
	int total_step = 0;
	for(int i=1;i<N+1;i++)
		total_step += get_shortest_distance(i);
	return total_step;
}

int main()
{
	scanf("%d %d %d", &H, &W, &N);
	for(int i=0; i<H; i++)
		scanf("%s", field[i]);
	for(int i=0; i<H; i++)
		for(int j=0; j<W; j++)
		{
			if(field[i][j]=='S')
				locations[0] = std::make_pair(i,j);
			if(isdigit(field[i][j]))
				locations[field[i][j]-'0'] = std::make_pair(i,j);
		}
	printf("%d\n", solve());
	return 0;
}

Measured memory_bytes: 4520
#include<iostream>
#include<string>
using namespace std;
string s1="CODEFESTIVAL2016",s2;
int main()
{
    cin>>s2;
    int ans=16;
    for(int i=0;i<16;++i)
        ans-=(s1[i]==s2[i]);
    cout<<ans<<endl;
    return 0;
}

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

int main(){
   string s,t; cin>>s>>t; int cnt=0;

   for(int i=0,j=0;i<s.length(),j<t.length();i++,j++)
   {
       if(s[i]!=t[j])
        cnt++;
   }

   cout<<cnt;
}




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

bool is_goo(string s){
    int n = s.size()/2;
    for (int i = 0; i != n; ++i){
        if (s[i] != s[i + n]) return false;
    }
    return true;
}

int main() {
    string s;
    cin >> s;
    while (true){
        s.pop_back();
        s.pop_back();
        if (is_goo(s)){
            cout << s.size() << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
void main()
{
  char s[4];
  int i;
  for(i=0;i<3;i++)
  {
    scanf("%c",&s[i]);
  }
if(s[0]=='M')
  printf("6");
  else if(s[0]=='W')
    printf("4");
  else if(s[0]=='F')
     printf("2");
  else if(s[0]=='S')
  {
     if(s[1]=='U')
       printf("7");
    else
      printf("1");
  }
  else if(s[0]=='T')
     {
     if(s[1]=='U')
       printf("5");
    else
      printf("3");
  }
}
    
  
  

Measured memory_bytes: 1596
n, d = list(map(int, input().split()))
xl = [0] * n
yl = [0] * n
for i in range(n):
    xl[i], yl[i] = map(int, input().split())
ans = 0
for i in range(n):
    if xl[i]**2 + yl[i]**2 <= d**2:
        ans += 1
print(ans)


Measured memory_bytes: 73052
#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int inf = 0x3f3f3f3f;
const double pi = acos(-1.0);
const ll mod =  1e9+7;
#define ios std::ios::sync_with_stdio(false);cin.tie(0), cout.tie(0);
const int maxn = 1e5 + 5;

int main() {
  ios;
  ll a, b, c, d;
	cin >> a >> b >> c >> d;
	ll ans = max(a * c, a * d);
	ans = max(ans, b * c);
	ans = max(ans, b * d);
	cout << ans << endl;


  return 0;
}

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

int main()
{
  int h, n;
  cin >> h >> n;
  
  int temp, sum = 0;
  
  for(int i = 0; i < n; i++){
    cin >> temp;
    sum += temp;
  }
  
  if(sum >= h)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
typedef long long ll;

ll calc(vector<ll> A, ll b) {
	ll res = 0;
	for(ll t: A) {
		res += abs(t - b);
	}
	return res;
}

signed main(){
	int N;
	cin >> N;
	vector<ll> A(N);
	for(int i = 0; i < N; ++i) {
		cin >> A[i];
		A[i] -= i + 1;
	}
	sort(ALL(A));

	ll res;
	if (N % 2 == 0) {
		ll t = (A[N/2] + A[N/2-1]) / 2;
		res = min(min(calc(A, t), calc(A, t+1)), calc(A, t-1));
	} else {
		res = calc(A, A[N/2]);
	}
	cout << res << endl;

	return 0;
}


Measured memory_bytes: 6528
/*
２つの整数 a, b を読み込んで、a と b の大小関係を出力するプログラムを作成して下さい。
 */

#include <stdio.h>

int main(void)
{
    int a, b;

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

    if (a < b)
    {
        printf("a < b\n");
    }
    else if (a > b)
    {
        printf("a > b\n");
    }
    else
    {
        printf("a == b\n");
    }
    return (0);
}


Measured memory_bytes: 2120
#include <stdio.h>
#include <stdlib.h>
#define N 50
int x[N];
int fib(int);
int main(){
  int n,i;
  for(i = 0; i < N; i++)
    x[i] = -1;

  scanf("%d",&n);
  if(n < 0 || n > 44){
    printf("制約: 0 ≤ n ≤ 44\n");
    exit(1);
  }

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

  return 0;
}

int fib(int n){
  if(n == 0 || n == 1)
    return x[n] = 1;
  if(x[n] != -1)
    return x[n];

  x[n] = fib(n-1) + fib(n-2);

  return x[n];
}



Measured memory_bytes: 2104
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
 
using namespace std;

int main(){
	
	string str;
	cin >> str;
	
	for(int i = 0; i < str.size() - 1; i++){
		if(str[i] == 'A' && str[i + 1] == 'C'){
			cout << "Yes" << endl;
			return 0;
		}
	}
	
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int i,a[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

    int k,val;
    scanf("%d",&k);

   for(i=1;i<=32;i++)
  {
      if(k==i)
      {
          val = a[i-1];
           break;

      }

  }

    printf("%d",val);



    return 0;
}

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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author kessido
 */
public 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);
        DEquals solver = new DEquals();
        solver.solve(1, in, out);
        out.close();
    }

    static class DEquals {
        int[] a;
        int[] dsu;
        int n;

        void merge(int index1, int index2) {
            index1 = findParentIndex(index1);
            index2 = findParentIndex(index2);
            if (index1 != index2) {
                dsu[index1] = index2;
            }
        }

        int findParentIndex(int i) {
            if (dsu[i] != -1)
                return dsu[i] = findParentIndex(dsu[i]);
            return i;
        }

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            n = in.NextInt();
            int m = in.NextInt();
            a = in.NextIntArray(n);
            dsu = new int[n];
            Arrays.fill(dsu, -1);
            for (int i = 0; i < m; i++) {
                merge(in.NextInt() - 1, in.NextInt() - 1);
            }
            int[] realIndex = new int[n];
            for (int i = 0; i < n; i++) {
                realIndex[a[i] - 1] = i;
            }
            int res = 0;
            for (int i = 0; i < n; i++) {
                if (findParentIndex(i) == findParentIndex(realIndex[i])) {
                    res++;
                }
            }
            out.println(res);
        }

    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

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

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine(), " \t\n\r\f,");
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int NextInt() {
            return Integer.parseInt(next());
        }

        public int[] NextIntArray(int n) {
            return NextIntArray(n, 0);
        }

        public int[] NextIntArray(int n, int offset) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = NextInt() - offset;
            }
            return a;
        }

    }
}



Measured memory_bytes: 46088
#include <bits/stdc++.h>
 
using namespace std;
 
#define LL long long 
#define ULL unsigned long long 
#define LD long double 
 
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int a, b, c;
	cin>>a>>b>>c;
	int w = max(0, (c-(a-b)));
	cout<<w;
}


Measured memory_bytes: 256
#include <time.h>

#include <stdlib.h>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <bitset>
#include <cctype>
using namespace std;
const int64_t INF=10000000000000000;

int main(){
    int n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++){
        char t;
        cin>>t;
        if(i==k-1){
            t=tolower(t);
        }
        cout<<t;
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include<bits/stdc++.h>
#include <utility>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<29)

using namespace std;
using ll = long long;
map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int N,M;
  vector<pair<int,int>> City[100010];
  cin >> N >> M;
  int P,Y;
  for(int i=1;i<=M;i++){
    cin >> P >> Y;
    City[P].push_back({Y,i});
  }
  pair<int,int> ans[100010];
  for(int i=1;i<=N;i++){
    sort(City[i].begin(),City[i].end());
    for(int j=0;j<City[i].size();j++){
      ans[City[i][j].second]={i,j+1};
    }
  }
  for(int i=1;i<=M;i++){
    printf("%06d%06d\n", ans[i].first,ans[i].second);
  }
  return 0;
}

Measured memory_bytes: 7808
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int a[9][9][4],x,y,dir=1;
int dx[]={0,1,0,-1};
int dy[]={-1,0,1,0};
string s="URDL";
int main(){
  r(i,9){
    if(i%2){
      r(j,5){
        scanf("%1d",&x);
        if(x)a[i/2][j][2]=a[i/2+1][j][0]=1;
      }
    }else{
      r(j,4){
        scanf("%1d",&x);
        if(x)a[i/2][j][1]=a[i/2][j+1][3]=1;
      }
    }
  }x=1;
  cout<<s[dir];
  while(!(!x&&!y)){
    if(a[y][x][(dir+3)%4])dir=(dir+3)%4;
    else if(a[y][x][dir]);
    else if(a[y][x][(dir+1)%4])dir=(dir+1)%4;
    else dir=(dir+2)%4;
    x+=dx[dir];
    y+=dy[dir];
    cout<<s[dir];
  }
  cout<<endl;
}

Measured memory_bytes: 3112
import numpy as np
from functools import reduce

def dist(array,xyh):
    return (abs(array.real-xyh[0])+abs(array.imag-xyh[1])+xyh[2])

def dist2(array,xyh,dxyh):
    if xyh[2]>0:
        return dist(array,xyh) == dxyh
    else:
        return dist(array,xyh) >= dxyh

N=int(input())
xyh=sorted([list(map(int,input().split())) for _ in range(N)],key=lambda x:x[2],reverse=True)

a=np.arange(101)+np.arange(101).reshape(101,1)*1j
dxyh=dist(a,xyh[0])

ans=np.where(reduce(lambda a,b:a&b,[dist2(a,xyh[i],dxyh) for i in range(1,N)]) == True)
print(ans[1][0],ans[0][0],int(dxyh[ans[0][0],ans[1][0]]))

Measured memory_bytes: 13816
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
typedef long long   ll;
#define pb                push_back
#define mp                make_pair
#define all(a)            (a).begin(), (a).end()
#define clr(a,h)          memset(a, (h), sizeof(a))
#define mem(a,h)          memset(a, (h), sizeof(a))
#define fi first
#define se second
#define por(a,b) (((a%MOD) * (b%MOD))%MOD)
#define forg(i, b, e, c)    for (ll i = (ll)b; i < (ll)e; i+=c)
#define forr(i, b, e)    for (ll i = b; i < e; i++)
 
 
using namespace std;
//using namespace __gnu_pbds;
typedef double lldb;
typedef pair<ll, ll>  ii;
typedef pair<ii, ll>  iii;
typedef vector<ll>     vi;
typedef vector<vi>     vvi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const ll INF = 1e9;
const double PI = acos(-1);
#define tam 320000
#define offset 
const ll MOD= 1e9+7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int  main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    int n,t;
    cin>>n>>t;
    ll tot=0;
    int ant=-1,valor;
    forr(i,0,n)
    {
        cin>>valor;
        if (ant==-1)
            ant=valor;
        else
        {
            tot+=min(t,valor-ant);
        }
        ant=valor;
    }
    tot+=t;
    cout<<tot<<endl;

}
// PLUS ULTRA!


Measured memory_bytes: 256
"""
sum{j} - sum(i) >= K(j - i)
sum{j} - Ki >= sum(i) - Ki
"""

n,k = map(int,input().split())

al = []

for _ in range(n):
    a = int(input())
    al.append(a)

import itertools
al_ac = [0] + list(itertools.accumulate(al))

for i in range(n+1):
    al_ac[i] -= i * k

# 入力: 座標の配列
# 出力 MP[e] = i: 座標eはi番目に該当
def compress(arr):
    *XS, = set(arr)
    XS.sort()
    return {e: i for i, e in enumerate(XS)}

dic = compress(al_ac)
bl = [dic[b] for b in al_ac]
k = max(bl)

# Binary Indexed Tree (Fenwick Tree)
class BIT:
    def __init__(self, n):
        self.n = n
        self.data = [0]*(n+1)
        self.el = [0]*(n+1)
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.data[i]
            i -= i & -i
        return s
    def add(self, i, x):
        # assert i > 0
        self.el[i] += x
        while i <= self.n:
            self.data[i] += x
            i += i & -i
    def get(self, i, j=None):
        if j is None:
            return self.el[i]
        return self.sum(j) - self.sum(i)


ans = 0
bit = BIT(k+2)
for b in bl:
    ans += bit.sum(b+1)
    bit.add(b+1, 1)

print(ans)

Measured memory_bytes: 114336
N = int(input())
s =  int(0.5 * (N) * (1 + N))
f = int(0.5 * (N//3) * (1 + N // 3) * 3)
b = int(0.5 * (N//5) * (1 + N // 5) * 5)
fb = int(0.5 * (N//15) * (1 + N // 15) * 15)

print(s-f-b+fb)

Measured memory_bytes: 9188
#include<stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main( void )
{
    int K, N;
	cin >> N;
    string S;
	cin >> S;

	cin >> K;

    int l = S.size();
    for(int i=0;i<l;i++){
        if(S[i] != S[K-1]){
            S[i] = '*';
        }
    }

    cout << S << "\n";
	return 0;
}

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

const int MOD = 1000 * 1000 * 1000 + 7, N = 107, M = 10 * 1000 + 7;
int size, d;
string s;

int dp[M][2][N];

int place(int at, bool restrict, int md) {
	md %= d;
	if (at == size + 1)
		return md == 0;
	if (dp[at][restrict][md] != -1)
		 return dp[at][restrict][md];
	int ans = 0;
	for (int here = 0; here < 10; here++) {
		if (!restrict) 
			ans += place(at + 1, false, (md + here) % d);
		else {
			if (here < (s[at - 1] - '0'))
				ans += place(at + 1, false, (md + here) % d);
			else if (here == (s[at - 1] - '0'))
				ans += place(at + 1, true, (md + here) % d);
			else 
				continue;
		}
		ans %= MOD;
	}
	return dp[at][restrict][md] = ans % MOD;
}

int main() {
	for (int i=0; i < 10001; i++) 
		for (int j = 0; j < 2; j++) 
			for (int k = 0; k < 101; k++) 
				dp[i][j][k] = -1;
	cin >> s >> d;
	size = s.size();
	cout << (place(1, true, 0) - 1 + MOD) % MOD << endl;
}



Measured memory_bytes: 9600
/*Hey, What's up?*/

#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
vector<long long>v,vc;
int graph [ 250 ][ 250 ], dist [ 250 ][ 250 ];
void floydWarshall ( int V )
{
    int i, j, k ;
    for ( i = 0 ; i < V ; i ++)
        for ( j = 0 ; j < V ; j ++)
            dist [ i ][ j ]= graph [ i ][ j ];
    for ( k = 0 ; k < V ; k ++)
    {
        for ( i = 0 ; i < V ; i ++)
        {
            for ( j = 0 ; j < V ; j ++)
            {
                if ( dist [ i ][ k ]+ dist [ k ][ j ]< dist [ i ][ j ])
                    dist [ i ][ j ]= dist [ i ][ k ]+ dist [ k ][ j ];
            }
        }
    }
//    for ( i = 0 ; i < V ; i ++)
//    {
//        for ( j = 0 ; j < V ; j ++)
//        {
//            cout << dist [ i ][ j ]<< " " ;
//        }
//        cout << endl ;
//    }
}
int main()
{
    //fastio;
    long long a=0,b=0,c,d,e,f=999999999999999,l,g,m,n,r,k,i,j,t,p,q;
    cin>>n>>m>>r;
    memset ( graph, 0x3f3f3f3f, sizeof ( graph ));
    for(i=0; i<r; i++)
    {
        cin>>a;
        a--;
        v.push_back(a);
        vc.push_back(a);
    }
    for(i=0; i<n; i++)
    {
        graph[i][i]=0;
    }
    for(i=0; i<m; i++)
    {
        cin>>a>>b>>c;
        a--;
        b--;
        graph[a][b]=c;
        graph[b][a]=c;
    }
    floydWarshall(n);
    g=1;
    while(g)
    {
        //cout<<g;
        g=0;
        for(i=0; i<r-1; i++)
        {
            g+=dist[v[i]][v[i+1]];
        }
        f=min(g,f);
        next_permutation(v.begin(),v.end());
        for(i=0; i<r; i++)
        {
            if(v[i]!=vc[i])
                break;
        }
        if(i==r)
            g=0;
    }

    cout<<f<<'\n';
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
typedef long long ll; 
#define pb push_back
#define mp make_pair
#define mod 998244353
#define vi vector <ll>
using namespace std ; 
ll power(ll x,ll y,ll m)
{            //power(x,y)=x^y  %m;
	ll res=1%m;
	while(y)
	{
	    if(y&1)
	    res=(res*x)%m;
	    x=(x*x)%m;
	    y=(y>>1)%m;
	}
	return res;
}
ll mod_inverse(ll x,ll m)
{
	return power(x,m-2,m);
}
vector<vector<ll> >g;
   vector<ll>v;
   ll vis[2005];
   vector<ll>v1;
void dfs(ll i)
{
    vis[i]=1;
    v1.pb(i);
    for(ll j=0;j<g[i].size();j++)
    {
        if(!vis[g[i][j]])
        dfs(g[i][j]);
        
    }
}
int main ()
{
    ios_base :: sync_with_stdio ( false );
    cin.tie( NULL );
    cout.tie( NULL );
ll t = 1 ;
//cin>>t;
while ( t--)  
{
  ll n;
  cin>>n;
  ll arr[n+1];
  memset(arr,0,sizeof arr);
  for(ll i=1;i<=100;i++)
  {
      for(ll j=1;j<=100;j++)
      {
          for(ll k=1;k<=100;k++)
          {
              ll tt;
              tt=i*i+j*j+k*k+i*j+i*k+k*j;
              if(tt<=n)
              {
                  arr[tt]++;
              }
          }
      }
  }
  for(ll i=1;i<=n;i++)
  cout<<arr[i]<<"\n";
  //cout<<cnt<<"\n";
  
}
 

 return 0;
}

Measured memory_bytes: 3624
import sys
from collections import defaultdict

N, W = map(int, input().split())

inf = 10**14

dp = defaultdict(lambda : inf)
dp[0] = 0

for _ in range(N):
    w, v = map(int, input().split())
    for dv, dw in dp.copy().items():
        if w + dw <= W:
            dp[dv + v] = min(dp[dv + v], w + dw)
print(max(dp.keys()))

Measured memory_bytes: 96912
#include<stdio.h>
#include<math.h>
#include<string.h>
int main()
{
  int N,K,i;
  int a[200000];
  scanf("%d %d\n",&N,&K);
  for(i=0;i<N;i++){
    scanf("%d",&a[i]);
  }
  for(i=K;i<N;i++){
  	if(a[i]>a[i-K]){
	 printf("Yes\n");
	}else{
	 printf("No\n");
	}
  }
  return 0;
}


Measured memory_bytes: 2440
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(), (a).end()
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define rep(i, n) FOR(i, 0, n)
#define repi(i, n) FOR(i, 1, n + 1)
#define pp(v) cerr << #v "=" << (v) << endl;
#define ppa(v) cerr << "----\n"; rep(i,v.size()) cout << #v << "[" << i << "] = " << v[i] << endl;
#define div_ceil(a,b) ((a) + ((b) - 1)) / (b)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using Graph = vector<vector<int>>;
using ll = long long;

int main() {
  int n;cin>>n;
  int ans = n*(n+1)/2;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 1e5 + 5;

int32_t main()
{
	IOS;
	int n;
	cin >> n;
	int cur = 26;
	int len = 1;
	while(n > cur)
	{
		n -= cur;
		cur *= 26;
		len++;
	}
	n--;
	string ans = "";
	while(len > 0)
	{
		len--;
		int cur = n % 26;
		n /= 26;
		ans += (char)(cur + 'a'); 
	}
	reverse(ans.begin(), ans.end());
	cout << ans;
	return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end()) // ユニークなvectorにする。連続した値を除去して切り出す。
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  int max = A * (B + 1);
  int sum = A;

  while (sum <= max) {
    if (sum % B == C) {
      cout << "YES" << endl;
      return 0;
    }
    sum += A;
  }
  cout << "NO" << endl;
}


Measured memory_bytes: 256
n, m, k = map(int, input().split())
a = [0] + list(map(int, input().split()))
b = [0] + list(map(int, input().split()))
for i in range(1, n + 1):
    a[i] += a[i - 1]
for i in range(1, m + 1):
    b[i] += b[i - 1]


def search(arr, x):
    l, r = -1, len(arr)
    while abs(r - l) > 1:
        mid = (l + r) // 2
        if arr[mid] <= x:
            l = mid
        else:
            r = mid
    return l


ans = 0
for i in range(len(a)):
    rest = k - a[i]
    if rest < 0:
        break
    bidx = search(b, rest)
    if bidx == -1 or bidx == len(b):
        continue
    ans = max(ans, i + bidx)
print(ans)

Measured memory_bytes: 42252
import java.io.*;

public class Main{
    public static void main(String[]args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
        for (char c: str.toCharArray()){
            if(Character.isLowerCase(c)){
                System.out.print(Character.toUpperCase(c));
            }else{
                System.out.print(Character.toLowerCase(c));
            }
        }
         System.out.println();
        
        
        
    }

        
}

Measured memory_bytes: 16984
K = int(input())
N = 50
a = [i+K//N for i in range(N)]
for i in range(K%N):
    for j in range(N):
        if i%N==j:
            a[j]+=N
        else:
            a[j]-=1
print(N)
print(str(a)[1:][:-1].replace(", ", " "))


Measured memory_bytes: 3064
numbers=list(map(int,list(input())))
ansLst=[]
def count(i,opes,sum):
    if i == 4:
        if sum == 7:
            ansLst.append(str(numbers[0])+opes[0]+str(numbers[1])+opes[1]+str(numbers[2])+opes[2]+str(numbers[3])+"=7")
    else:
        count(i+1,opes+["+"],sum+numbers[i])
        count(i+1,opes+["-"],sum-numbers[i])
count(1,[],numbers[0])
print(ansLst[0])

Measured memory_bytes: 3064
using System;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(solver() ? "APPROVED" : "DENIED");
        }
        static bool solver()
        {
            var N = int.Parse(Console.ReadLine());
            var A = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            foreach (int a in A)
            {
                if ((a % 2) == 0)
                {
                    if (((a % 3) != 0) && ((a % 5) != 0)) return false;
                }

            }
            return true;
        }
    }
}


Measured memory_bytes: 11092
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

constexpr int number = 753;

int main(){
    
    std::string str;

    std::cin >> str;

    std::vector<int> v;

    for(size_t i = 0; i < str.size() - 2; i++){
        int tmp = ((str[i] - '0') * 100) + ((str[i + 1] - '0') * 10) + ((str[i + 2] - '0'));
        v.emplace_back(std::abs(number - tmp));
    }

    std::cout << *std::min_element(v.begin(), v.end()) << std::endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define F first
#define S second
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>
#define pb push_back
#define eb emplace_back
#define ischar(x)  (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
#define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
#define bug cout<<"BUG"<<endl;
const int Max = 1e5 + 10;
const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;


ll n,m;

vector<ll>adj[Max+10];

ll indeg[Max+10];

ll dis[Max+10];



void input()
{
      ll i,a,b;


       for(i=1; i<=m; i++)
       {
           cin>>a>>b;

           adj[a].eb(b);

           indeg[b]++;
       }
}

ll topsort()
{
    ll u,mx=0;

       queue<ll>q;

       for(ll i=1; i<=n; i++)
       {
           if(!indeg[i])q.push(i);
       }

         while(!q.empty())
         {
              u=q.front();

              q.pop();

                for(auto v  : adj[u])
                {
                   dis[v]=max(dis[v],dis[u]+1);

                   mx=max(dis[v],mx);

                   indeg[v]--;

                   if(!indeg[v])
                    q.push(v);
                }
         }

         return mx;
}
int main()
{

   fastread();

   ll i,j,p,a,sum=0,k,t,b,c,d,cnt=0,q,l,r;


     string str;

   bool flag=true;

     cin>>n>>m;

     input();


      cout<<topsort()<<endl;







}



Measured memory_bytes: 10592
#include<bits/stdc++.h>
#define ll long long int
#define st string
#define con continue
#define br break
#define rt return 0
#define fr first
#define sec second
using namespace std;
int main(){
//ll tc; cin>>tc; while(tc--){
ll n,m,i,x,j,mx=0,t,k,b=0,a=0,ans=0,c=0; 
ll mn;    
 st s,str; char strn;
cin>>n; //a=n; n-=1; 
    mn=n-1;
ll ara[n+1],bra[n+1],taj[n+1];
//memset(ara,0,sizeof(ara));
//for(i=1;i<=n;i++) cin>>ara[i]; 
      // cout<<k<<endl;  
  for(i=1;i<=sqrt(n);i++)
   {
     if(n%i==0)
     {
        b++;
      //ara[++a]=i;
     // bra[++b]=n/i;  
      ans=((n/i)+i)-2;
      mn=min(mn,ans);                   
     }
   }      
// t=ara[a]-1;
// k=bra[b]-1; 
  if(!b)cout<<n-1;     
 else cout<<mn<<endl;
    
 
    rt;
}

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

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

const ll linf = 1LL << 62;
const int inf = 99999999;
const int dx[4] = { 1,0,-1,0 };
const int dy[4] = { 0,1,0,-1 };
const ll atcoder = 1e9 + 7;

#define Endl endl
#define mp make_pair
#define all(v) v.begin(),v.end()
#define pb push_back
#define pr(x) cout << x << endl
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
#define rep(i,n) for(int i= 0;i<n;i++)

ll gcd(ll a, ll b) {//最大公約数
	if (a%b == 0)return b;
	else gcd(b, a%b);
}

ll lcm(ll a, ll b) {//最小公倍数
	return (a / gcd(a, b))*b;
}

int main() {

	int n, l;
	cin >> n >> l;
	string s[110];
	rep(i, n)cin >> s[i];
	sort(s,s+n);

	rep(i, n)cout << s[i];
	cout << endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ld long double
#define dd double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
typedef long long ll;
typedef unsigned long long ull;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;
typedef vector<pll> vplll;
ll mod = 1e9+7;
const ld PI = 2 * acos(0.0);
const vector<ll> dx = {1, -1, 0, 0};
const vector<ll> dy = {0, 0, 1, -1};
#define round(x, y) ((x + y - 1) / y)
#define ce(x, y) ((x + y - 1) / y)
#define amax(x, y) \
    if (y > x)     \
        x = y;
#define amin(x, y) \
    if (y < x)     \
        x = y;
#define lcm(x, y) ((x) * (y) / __gcd(x, y))
#define len(x) (ll) x.length()
#define sq(x) ((x) * (x))
#define cb(x) ((x) * (x) * (x))
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,c,t,n,m,k,q; 
    t = 1;
    // cin>>t;
    while(t--)
    {
    	cin>>a;
    	ld ans = 2 * PI * a ;
    	printf("%6Lf \n",ans);
    }
    return 0;
}

Measured memory_bytes: 3804
#include <bits/stdc++.h>
 
using namespace std;
 
struct Panel {
    string name;
    int x1, y1, x2, y2;
    vector<Panel> child;
     
    Panel(){}    
    Panel(string name, int x1, int y1, int x2, int y2) :
        name(name), x1(x1), y1(y1), x2(x2), y2(y2) {}
};
 
string s;
int idx;
 
string get_name()
{
    string name;
    ++idx;
    while (s[idx] != '>') {
        name += s[idx];
        ++idx;
    }
    ++idx;
    return name;
}
 
int s2i(string &str)
{
    stringstream ss(str);
    int num;
    ss >> num;
    return num;
}
 
int get_val()
{
    string val;
    while (isdigit(s[idx])) {
        val += s[idx];
        ++idx;
    }
    return s2i(val);
}
 
void parse(Panel &p)
{
    while (s[idx] == '<' && s[idx+1] != '/') {
        string name = get_name();
        int x1 = get_val(); ++idx;
        int y1 = get_val(); ++idx;
        int x2 = get_val(); ++idx;
        int y2 = get_val();
        Panel panel(name, x1, y1, x2, y2);
        parse(panel);
        p.child.push_back(panel);
        while (s[idx] != '>') {
            idx++;
        }
        idx++;
    }    
}
 
bool get_panel(int x, int y, const Panel &p)
{
    for (int i = 0; i < (int)p.child.size(); i++) {
        Panel np = p.child[i];
        if (np.x1 <= x && x <= np.x2 && np.y1 <= y && y <= np.y2) {
            if (!get_panel(x, y, np)) {
                cout << np.name << " " << np.child.size() << endl;
            }
            return 1;
        }
    }
    return 0;
}
 
int main()
{
    int n, x, y;
    while (cin >> n >> s, n) {
        Panel p;
        idx = 0;
        parse(p);
        for (int i = 0; i < n; i++) {
            cin >> x >> y;
            if (!get_panel(x, y, p)) {
                cout << "OUT OF MAIN PANEL 1" << endl;
            }
        }
    }
    return 0;
}

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

ll mod = 1000000007;


int main() {
int n;cin >>n;
vector<int> a(n);
rep(i,n) cin >> a[i];
sort(a.begin(),a.end());
cout << a[n-1] - a[0] << endl; 

}

Measured memory_bytes: 384
n = int(input())
xs = []
for i in range(n): xs.append(input())
m = int(input())
flag = 1
for i in range(m):
    s = input()
    if s in xs:
        print("Opened" if flag == 1 else "Closed", "by", s)
        flag ^= 1
    else:
        print("Unknown", s)

Measured memory_bytes: 7668
#include <iostream>

using namespace std;

int main()
{
    int n;
    int a = 64;
    cin >> n;
    if(n == 1)a = 1;
    while(a != 1){
        if(n / a >= 1){
            break;
        }
        a = a / 2;
    }
    cout << a << endl;
    return 0;
}

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

int main() {
  string N;
  cin >> N;
  if (N.at(0) == N.at(1) && N.at(1) == N.at(2)) {
    cout << "Yes" << endl;
  }
  else if (N.at(1) == N.at(2) && N.at(2) == N.at(3)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MAX 1000
using namespace std;
typedef long long ll;
ll N,X,ans;
int main () {
    ios_base::sync_with_stdio(false);
    cin>>X;
    N = 100;
    ans = 0;
    while(N < X) {
        N=(N*1.01);
        ans++;
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 3652
/* [Template].cpp 
Example code to use when starting new code. This particular problem was problem 
977A_Wrong_Subtraction from CodeForces

Compile: g++  -o B_Trick_or_Treat.exe B_Trick_or_Treat.cpp 
Execute: ./B_Trick_or_Treat
*/ 

#include <cstdio>
#include <iostream>
#include <cmath> 
#include <limits> 
#include <iomanip>
#include <cstring> 
#include <bits/stdc++.h>
#include <string>  
using namespace std;

int main() { 	
	int N, K; 
	int d, A; 
	bool does_snuke_have_snack[100] = {false}; 
	
	cin >> N >> K; 
	for(int i = 0; i < K; i++) {
		cin >> d; 
		for(int j = 0; j < d; j++) {
			cin >> A; 
			does_snuke_have_snack[A-1] = true; 
		}
	}
	
	int num_snukes_no_snacks = 0; 
	for(int i = 0; i < N; i++) {
		if(!does_snuke_have_snack[i]) {
			num_snukes_no_snacks++; 
		}
	}
	
	cout << num_snukes_no_snacks << endl; 
	
	return 0; 
} 


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

cnt = {}
for i in range(n):
    if a[i] not in cnt:
        cnt[a[i]] = 1
    else:
        cnt[a[i]] += 1
ans = 0
for i in cnt:
    if i <= cnt[i]:
        ans += cnt[i] - i
    else:
        ans += cnt[i]
print(ans)

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

const int INF = 1001001001;
vector<int> load[100005];

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

  long long A, B;
  for (int i = 0; i < M; ++i) {
    cin >> A >> B;
    A--;
    B--;
    load[A].push_back(B);
    load[B].push_back(A);
  }

  queue<int> q;
  vector<int> dist(N, INF);
  vector<int> pre(N, -1);
  dist[0] = 0;
  q.push(0);
  while (q.size()) {
    int v = q.front();
    q.pop();
    for (int u : load[v]) {
      if (dist[u] != INF) continue;
      dist[u] = dist[v] + 1;
      pre[u] = v;
      q.push(u);
    }
  }

  cout << "Yes" << endl;
  for (int i = 0; i < N; ++i) {
    if (i == 0) continue;
    int ans = pre[i];
    ++ans;
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 10648
#include<iostream>
#include<cstdio>
#include <cstring>
#include<map>
#include<string>
#include<stack>
#include <sstream>
using namespace std;


string IntToString(int number)
{
stringstream ss;
ss << number;
return ss.str();
}

string print(int *a){
	string kari;
	if(*a<10) kari+="0"+IntToString(*a);
	else kari+=IntToString(*a);
	return kari;
}

void ans1(int *a, int *b, int *c){
	double kari;
	kari = 2*3600-((*a)*3600+(*b)*60+(*c));
	*a = kari/3600;
	*b = ( kari-( (*a)*3600 ) )/60;
	*c = kari-( (*a)*3600 + (*b)*60);
}

void ans2(int *a, int *b, int *c){
	double kari;
	kari = 3*(((*a)*3600+(*b)*60+(*c)));
	*a = kari/3600;
	*b = ( kari-( (*a)*3600 ) )/60;
	*c = kari-( (*a)*3600 + (*b)*60);
}

int main(){
	int h,m,s;
	while(scanf("%d %d %d",&h ,&m ,&s))
	{
		int *a,*b,*c; 
		if(h==-1)break;
		a=&h;b=&m;c=&s;
		ans1(a, b, c);
		cout<<print(a)<<":"<<print(b)<<":"<<print(c)<<endl;
		ans2(a, b, c);
		cout<<print(a)<<":"<<print(b)<<":"<<print(c)<<endl;
	}
	return 0;
}

Measured memory_bytes: 1240
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define MODB 998244353
#define INF 9223372036854775807
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}
signed main()
{
  int x=0,y=0,z=1,w=0,n=2,m=1;
std::cin >> x;
y=sqrt(x);
if(x==1){
  std::cout << 1 << '\n';
  return 0;
}
repo(i,2,y+1){
  while(z<=x){
    z*=i;
  }
  z/=i;
  if(w<z)w=z;
  z=1;
}
std::cout << w << '\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <math.h>
#include <ctype.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
const int inf{ int(1e9) };

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

	vector<int>vec(3);
	vec[0] = a + b;
	vec[1] = a - b;
	vec[2] = a * b;
	sort(vec.begin(), vec.end());

	cout << vec[2] << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

const int dx[4] = {-1, 0, 0, 1};
const int dy[4] = {0, -1, 1, 0};

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 31;
// clang-format on

int W, H;
char canvas[50][50];

bool check(int i, int j)
{
  bool f = false;
  for (int k = 0; k < 4; k++) {
    int x = i + dx[k], y = j + dy[k];
    if (x < 0 || x >= W) continue;
    if (y < 0 || y >= H) continue;
    if (canvas[x][y] == '#') {
      f = true;
      break;
    }
  }
  return f;
}

int main(void)
{
  cin >> W >> H;
  REP(i, W) REP(j, H) cin >> canvas[i][j];

  bool f = true;
  for (int i = 0; i < W; i++) {
    for (int j = 0; j < H; j++) {
      if (canvas[i][j] == '#') {
        if (!check(i, j)) {
          cout << "No" << endl;
          return 0;
        }
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#C
N, K = [int(x) for x in input().split()]
H = [int(input()) for i in range(N)]
#print(N,K,H) #
H.sort()
dif = 10**9
for i in range(N-K+1):
    if H[i+K-1] - H[i]<dif: dif = H[i+K-1] - H[i]
        
print(dif)



Measured memory_bytes: 7436
N, A, B, C = [int(i) for i in input().split()]
L = [int(input()) for _ in range(N)]

INF = 1e10

def solve(cur, a, b, c):
    if cur >= N:
        if min(a, b, c) == 0:
            return INF
        return -30 + sum(map(abs, [a - A, b - B, c - C]))
    return min(
        10 + solve(cur + 1, a + L[cur], b, c),
        10 + solve(cur + 1, a, b + L[cur], c),
        10 + solve(cur + 1, a, b, c + L[cur]),
        solve(cur + 1, a, b, c),
    )

print(solve(0, 0, 0, 0))


Measured memory_bytes: 3064
//template---{{{
#include <bits/stdc++.h>

using namespace std;

//DEFINE---{{{
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b); i > (a); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
//end.DEFINE---}}}

//end.template ---}}}

int main()
{
    int a, b;

    cin >> a >> b;

    if (a > b) {
        cout << a - 1 << endl;
        return (0);
    }
    else {
        cout << a << endl;
        return (0);
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<deque>
#include<unordered_map>
#include<unordered_set>
#include<queue>
#include<algorithm>
#include<cmath>
#include<numeric>
using namespace std;

typedef long long LL;
const int MOD = 1e9+7;

void solve(){
	int n,k;
	cin>>n>>k;
	vector<bool> vis(n,1);
	for(int i=0;i<k;i++){
		int dk;
		cin>>dk;
		for(int j=0;j<dk;j++){
			int x;
			cin>>x;
			vis[x-1] = 0;
		}
	}
	int res = 0;
	for(int i=0;i<n;i++){
		res+=vis[i];
	}
	cout<<res<<endl;
}


int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int T = 1;
	// cin>>T;
	while(T--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 3648
#include <stdio.h>



#ifndef DEBUG 
#define fprintf (void)
#endif 

int main(void){

	char str[1001],cstr[1000];
	char memory;
	char trash;
	char order;
	int q,a,b;
	int i,j,k;
	i=0;
	
	while(1){
		scanf("%c",&str[i]);
		if(str[i]=='\n'){
			break;
		}
		cstr[i]=str[i];
		i++;
	}
	
	scanf("%d",&q);

	for(i=0;i<q;i++){
		for(j=0;j<3;j++){
			scanf("%c",&trash);
		}
		scanf("%c",&order);
		while(1){
			scanf("%c",&trash);
			if(trash==' '){
				break;
			}
		}
		if(order=='p'){
			fprintf(stdout,"route rep\n");
			scanf("%d",&a);
			scanf("%d",&b);
			scanf("%c",&trash);
			for(j=a;j<=b;j++){
				scanf("%c",&memory);
				str[j]=memory;
				cstr[j]=memory;
				fprintf(stdout,"%c",str[j]);
			}
			fprintf(stdout,"\n");
			fprintf(stdout,"route rep end\n");
		}else if(order=='v'){
			fprintf(stdout,"route rev\n");
			scanf("%d",&a);
			scanf("%d",&b);
			fprintf(stdout,"%d-%d\n",a,b);
			for(j=a;j<=b;j++){
				str[j]=cstr[b-j+a];
				fprintf(stdout,"%c",str[j]);
			}
			fprintf(stdout,"\n");
			for(j=a;j<=b;j++){
				cstr[j]=str[j];
			}
			fprintf(stdout,"route rev end\n");
		}else{
			fprintf(stdout,"route print\n");
			scanf("%d",&a);
			scanf("%d",&b);
			for(j=a;j<=b;j++){
				printf("%c",str[j]);
			}
			printf("\n");
			fprintf(stdout,"route print\n");
		}
	}
	
	return 0;
}

Measured memory_bytes: 2600
(defvar N (read))
(defvar M (read))

(defvar A (loop repeat N collect (read)))

(defvar discount 
  (loop for x in A with lst = nil do
        (loop if (zerop x) return nil do
              (push (ceiling x 2) lst)
              (setf x (floor x 2)))
        finally (return (sort lst #'>))))

(princ (- (reduce #'+ A)
          (loop for x in discount
                for i below M
                sum x)))

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

using namespace std;
const int MOD=2019;
#define ll long long

int main()
{
   int a;
   cin>>a;
   if (a%10==7 || (a%100)/10==7 || a/100==7)
    cout<<"Yes";
   else
    cout<<"No";
    return 0;
}


Measured memory_bytes: 3616
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
d = LIST()
mod = 998244353

if d[0] != 0:
    print(0)
    exit()

c = Counter(d)
counts = [0]*(max(d)+1)
for k, v in c.items():
    counts[k] = v
if counts[0] > 1:
    print(0)
    exit()
ans = 1
for i in range(1, len(counts)):
    ans *= pow(counts[i-1], counts[i])
    ans %= mod

print(ans)

Measured memory_bytes: 22924
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=200005,INF=1<<30;

int prime[MAX];//i番目の素数
bool is_prime[MAX+1];

void sieve(int n){
    int p=0;
    for(int i=0;i<=n;i++){
        is_prime[i]=true;
    }
    
    is_prime[0]=is_prime[1]=false;
    
    for(int i=2;i<=n;i++){
        if(is_prime[i]){
            prime[p++] = i;
            for(int j=2*i;j<=n;j+=i){
                is_prime[j] = false;
            }
        }
    }
}

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    sieve(MAX-3);
    
    while(1){
        int N,P;cin>>N>>P;
        if(N==-1&&P==-1) break;
        vector<int> A;
        
        for(int i=N+1;;i++){
            if(is_prime[i]){
                A.push_back(i);
            }
            if(A.size()==P) break;
        }
        
        multiset<int> SE;
        for(int i=0;i<P;i++){
            for(int j=i;j<P;j++){
                SE.insert(A[i]+A[j]);
            }
        }
        
        for(auto it=SE.begin();P;it++){
            if(P==1) cout<<*it<<endl;
            P--;
        }
    }
    
}



Measured memory_bytes: 3656
#include<bits/stdc++.h>
#include<cmath>
#define pb push_back
#define ld long double
#define mp make_pair
#define vl vector<ll> 
#define vd vector<double>
#define vld vector<long double>
#define ll long long int
#define pl pair<ll, ll>
#define all(a) a.begin(), a.end()
#define forr(i, n) for(ll i=0; i<n; i++) 
#define forr1(i, n) for(ll i=1; i<=n; i++)
using namespace std;
const ld PI =3.1415926535897923846;
const ll MOD = 1e9+7;
void solve()
{
    ll x, n;
    cin>>x>>n;
    map<ll, ll> mp1;
    forr(i, n) 
    {
        ll a;
        cin>>a;
        mp1[a]++;
    }
    ll cur=3432;
    ll ans=0;
    for(ll i=-1; i<=101; i++)
    {
        if(mp1.find(i)!=mp1.end())
        continue;
        if(cur>abs(x-i))
        {
            cur=abs(x-i);
            ans=i;
        }
    }
    cout<<ans;
}
int main()
{
    ll test=1;
    //cin>>test;
    while(test--)
        solve();
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
const int N = 1<<18;
typedef long long ll;
const ll MOD = 1e9 + 12345;
const int H = 1074;
typedef pair<ll, ll> pll;
char s[N];
map<pll, int> mp;
int main() {
    int n;
    cin >> n >> s;
    for(int i = 0; i < (1 << n); i++) {
        ll x=0, y=0;
        for(int j = n - 1; j >= 0; j--) {
            if((i >> j) & 1) {
                x = x * H + s[j];
                x %= MOD;
            } else {
                y = y * H + s[j];
                y %= MOD;
            }
        }
        mp[{x,y}]++;
    }
    ll res = 0;
    for(int i = 0; i < (1 << n); i++) {
        ll x=0, y = 0;
        for(int j = 0; j < n; j++) {
            if((i >> j) & 1) {
                x = x * H + s[n+j];
                x %= MOD;
            } else {
                y = y * H + s[n+j];
                y %= MOD;
            }
        }
        res += mp[{x,y}];
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 33024