akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> i_i;

#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((ll)(x).size())

const double PI  = acos(-1.0);
//const ll INF = 1e18+3;
const ll mod = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define print(x) cerr << #x << " is " << x << endl;

#include <iostream>
#include <vector>
using namespace std;
using DD = int;
const int INF = 10000000;

////////////////////////////////////////
// grid dijkstra
// x = i/W, y = i%W;
// xy = j * W + i;

int D[1000001];
int main() {
    int H, W, K, S, G, x1, y1, x2, y2;
    cin >> H >> W >> K;
    cin >> x1 >> y1 >> x2 >> y2;
    //vector<string> A(H);
    //rep(i, H)cin >> A[i];
    char A[H][W]={};
    rep(i, H)rep(j,W)cin >> A[i][j];
    S = (x1 - 1) * W + (y1 - 1);
    G = (x2 - 1) * W + (y2 - 1);
    rep(i, H * W)D[i] = INF;
    D[S] = 0;
    queue<int> que;
    que.push(S);
    while(que.size() > 0){
        int now = que.front(); que.pop();
#if 0        
        const int dir[4][2]={{-1, 0}, {0, -1}, {1, 0}, {0, 1}};
        int x = now/W, y = now%W;
        for(int i=0;i<4;i++){
            int nx=x, ny=y;
            int nd=D[now]+1;
            for(int j=1; j<=K; j++)
            {
                nx+=dir[i][0];
                ny+=dir[i][1];
                if (nx<0||ny<0||nx>=H||ny>=W||A[nx][ny]=='@'||D[nx * W + ny]<nd)
                    break;
                if(D[nx * W + ny]>nd)
                {
                    D[nx * W + ny]=nd;
                    que.push(nx * W + ny);
                }
            }
        }
#else        
        int DD[4] = {-W, +1, +W, -1};
        for (int d = 0; d < 4; d++){
            for (int k = 0; k <= K; k++){
                int x = now + DD[d] * k;
                int i = x/W;
                int j = x%W;
                
                if (A[i][j] == '@'){
                    break;
                }
                if (k > 0 && D[x] < D[now] + 1)break;
                
                //fprintf(stderr, "hoge now = (%d, %d): %d\n", i, j, D[now]); 
                if (D[x] > D[now] + 1){
                    D[x] = D[now] + 1;
                    que.push(x);
                    //fprintf(stderr, "D(%d, %d) = %d\n", i, j, D[now] + 1);
                }
                if ((d == 0 && i == 0) || (d == 1 && j == W - 1) ||
                    (d == 2 && i == H - 1) || (d == 3 && j == 0)){
                    break;
                }
            }
        }
#endif
    }

    if (D[G] == INF){
       cout << -1;
    } else {
        cout << D[G];
    }
    return 0;
}


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

#define endl '\n'
#define ll long long
#define fast_io ios::sync_with_stdio(0); cin.tie(0)
#define inf (1000*1000*1000+9)
#define infl ((ll)inf*inf+9)
#define sz(a) ((int)a.size())
#define all(a) a.begin(),a.end()

const int mod=1e9+7; 
const int nax=2e5; 
int mx[nax<<2]; 
int mn[nax<<2]; 
int inv[nax]; 
int a[nax]; 
void build(int p, int l ,int r){
  if(l==r){
    mx[p]=a[l]; 
    mn[p]=a[l]; 
  }
  else {
    int m=(l+r)>>1; 
    build(p<<1, l,m); 
    build(p<<1|1,m+1,r); 
    mx[p]=max(mx[p<<1], mx[p<<1|1]); 
    mn[p]=min(mn[p<<1], mn[p<<1|1]); 
  }
}
pair<int,int> qq(int p, int l , int r, int i ,int j){
  if(r<i || l>j) return {inf, -inf}; 
  if(i<=l && r<=j){
    return {mn[p],mx[p]}; 
  }
  else {
    int m=(l+r)>>1, c1=p<<1, c2=p<<1|1; 
    auto p1=qq(c1,l,m,i,j); 
    auto p2=qq(c2,m+1,r,i,j); 
    return {min(p1.first, p2.first), max(p1.second,p2.second)}; 
  }
}

void solve(){
  int n,k; cin>>n>>k; 
  for(int i=0;i<n;i++) cin>>a[i]; 
  vector<int> pre(nax); 
  for(int i=1;i<n;i++){
    if(a[i]<a[i-1]){
      inv[i]=1; 
    }
    pre[i]=pre[i-1]; 
    pre[i]+=inv[i]; 
  }
  build(1,0,n-1); 
  int ans=0; 
  bool pos=0; 
  for(int i=0;i+1<k;i++){
    if(a[i]>a[i+1]){
      ans=1; 
      break; 
    }
  }
  if(ans==0) pos=1; 
  for(int i=1;i+k-1<n;i++){
    auto pp=qq(1,0,n-1,i-1,i+k-1);
    int f=pp.first, s=pp.second; 
    //cout<<f<<" " <<s<<endl; 
    if(a[i-1]==f && a[i+k-1]==s){
      continue; 
    }
    else {
      if(pre[i+k-1]-pre[i] > 0){
        ans++; 
      }
      else {
        pos=1; 
      }
    }
  }
  if(pos) ans++; 
  cout<<ans<<endl; 
}

int main()
{
	fast_io;
	clock_t beg=clock(); 
	solve(); 
	clock_t end=clock(); 
	fprintf(stderr,"%.2lf sec\n",(double)(end-beg)/CLOCKS_PER_SEC); 
	return 0;
}

Measured memory_bytes: 7808
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vv vector<ll>
#define pp pair<ll,ll>
#define ff first
#define ss second
#define vp vector<pp>
#define dd double
#define pb push_back
#define mp make_pair

int main() 
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    ll g=(s[0]-48)*10+(s[1]-48);
    ll h=(s[2]-48)*10+(s[3]-48);
    if((g>12 || g==0) && h<=12 && h>0)
    {
    	cout<<"YYMM";
	}
	else if((h>12 || h==0) && g<=12 && g>0)
	{
		cout<<"MMYY";
	}
	else if(h<=12 && g<=12 && h>0 && g>0)
	{
		cout<<"AMBIGUOUS";
	}
	else
	{
		cout<<"NA";
	}
    return 0;
}

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

#define fi first
#define se second
#define pb push_back
#define mod(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,a,b) for(int i = a; i < b; i++)
#define forr(i,a,b) for(int i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()

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

const int maxn = 2999+10;
ld memo[maxn][maxn],P[maxn];
int N;

ld dp(int pos,int cnt){
	if(pos >= N){
		int t = (N+1)/2;
		if(cnt >= t)return 1;
		return 0;
	}
	ld &res = memo[pos][cnt];
	if(res != -1.0)return res;
	res = P[pos]*dp(pos+1,cnt+1);
	res += (1-P[pos])*dp(pos+1,cnt);
	return res;
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	forn(i,0,maxn)forn(j,0,maxn)memo[i][j] = -1;
	cin >> N;
	forn(i,0,N)	cin >> P[i];
	ld res = dp(0,0);
	cout << fixed << setprecision(10) << res << '\n';

	return 0;
}
/*
__builtin_mul_overflow(x,y,&x)
-fsplit-stack
*/


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

using namespace std;

vector<int> ch[222222];
typedef deque<pair<pair<long long, long long>, long long>> D;
const int mod = 1000000007;

void f(int v, D &d)
{
	D t;
	for (auto i : ch[v])
		f(i, t);
	if (ch[v].size() > 1)
		for (auto &p : t) {
			p.first.first += p.second;
			p.first.first %= mod;
			p.second = 0;
		}
	t.push_front(make_pair(make_pair(1, 1), 0));
	if (d.size() < t.size())
		d.swap(t);
	auto it = d.begin();
	for (auto &p : t) {
		it->second += it->first.first + it->first.second;
		it->second *= p.first.first + p.first.second + p.second;
		it->second %= mod;
		it->first.second *= p.first.first;
		it->first.second += it->first.first * p.first.second;
		it->first.second %= mod;
		it->first.first *= p.first.first;
		it->first.first %= mod;
		it->second += mod + mod;
		it->second -= it->first.first + it->first.second;
		it->second %= mod;
		++it;
	}
}
int main()
{
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) {
		int p;
		scanf("%d", &p);
		ch[p].push_back(i + 1);
	}
	D d;
	f(0, d);
	long long a = 0, b = 1;
	for (auto &p : d) {
		a *= p.first.first + p.first.second;
		a += b * p.first.second;
		a %= mod;
		b *= p.first.first + p.first.second;
		b %= mod;
	}
	cout << a << endl;
	return 0;
}


Measured memory_bytes: 164864
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int M = scanner.nextInt();
        int[][] students = new int[N][2];
        int[][] checkpoints = new int[M][2];
        int[] ans = new int[N];

        for (int i = 0; i < N; i++) {
            students[i][0] = scanner.nextInt();
            students[i][1] = scanner.nextInt();
        }

        for (int i = 0; i < M; i++) {
            checkpoints[i][0] = scanner.nextInt();
            checkpoints[i][1] = scanner.nextInt();
        }


        for (int i = 0; i < N; i++) {
            int min = Integer.MAX_VALUE;
            for (int j = 0; j < M; j++) {
                int distance = Math.abs(students[i][0] - checkpoints[j][0]) + Math.abs(students[i][1] - checkpoints[j][1] );
                if (min > distance) {
                    min = distance;
                    ans[i] = j;
                }
            }
        }

        for (int i = 0; i < N; i++) {
            System.out.println(ans[i]+1);
        }
    }
}


Measured memory_bytes: 22996
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <iomanip>
#include <time.h>
using namespace std;

typedef long long ll;


int main()
{
    int N,K;
    cin >> N >> K;
    vector<ll> Pos,Neg;
    
    for(int i=0; i<N; i++){
        ll tmp;
        cin >> tmp;
        if(tmp>=0) Pos.push_back(tmp);
        else Neg.push_back(-tmp);
    }

    sort(Pos.begin(),Pos.end(),greater<ll>());
    sort(Neg.begin(),Neg.end(),greater<ll>());
    
    int ns=Neg.size(),ps=Pos.size();
    ll mod=1000000007;
    ll ans=1;

    if(ps==0 && K%2==1){
        reverse(Neg.begin(),Neg.end());
        for(int i=0; i<K; i++){
            ans*=Neg[i];
            ans%=mod;
        }
        ans=(mod-ans)%mod;
        cout << ans << endl;
        return 0;
    }else if(ps+ns==K){
        for(int i=0; i<ps; i++){
            ans*=Pos[i];
            ans%=mod;
        }
        for(int i=0; i<ns; i++){
            ans*=Neg[i];
            ans%=mod;
        }
        if(ns%2==1) ans=mod-ans;
        ans%=mod;
        cout << ans << endl;
        return 0;
    }

    int n=0,p=0;
    while(n+p<K){
        if(p==ps){
            if((K-p)%2==1){
                p--;
            }
            n=K-p;
        }else if(n==ns || n+1==ns) p=K-n;
        else if(p+1==ps || n+p+1==K) p++;
        else if(Neg[n]*Neg[n+1]>=Pos[p]*Pos[p+1]) n+=2;
        else p++;
    }
    for(int i=0; i<p; i++){
        ans*=Pos[i];
        ans%=mod;
    }
    for(int i=0; i<n; i++){
        ans*=Neg[i];
        ans%=mod;
    }

    cout << ans << endl;

    

    return 0;
}

Measured memory_bytes: 5516
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
using namespace std;

using ll = long long;

int main(void)
{
	ll x;
	cin >> x;
	--x;
	ll grnum = x / 11;
	x %= 11;
	ll ans = ((x <= 5) ? 1 : 2);
	ans += grnum * 2;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
a = [list(map(int, input().split())) for i in range(2)]

ans = 0
for i in range(n):
        cnt = flag = 0
        for j in range(n):
                if not flag: cnt += a[flag][j]
                if i==j: flag = 1
                if flag: cnt += a[flag][j]
        ans = max(ans, cnt)
print(ans)

Measured memory_bytes: 3064
/*
 * a.cc: 
 */

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

using namespace std;

/* constant */

const int MAX_N = 100;

/* typedef */

/* global variables */

int as[MAX_N];

/* subroutines */

/* main */

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

  for (int i = 0; i < n; i++) cin >> as[i];

  for (int i = 0; i < n; i++) {
    if (i) putchar(' ');
    printf("%d", as[n - 1 - i]);
  }
  putchar('\n');
  
  return 0;
}

Measured memory_bytes: 1144
import sys
x = input().split()
for n in range(int(x[0])+1):
    if 4*n <= int(x[1]):
        nihon = int(x[1]) - 4*n
        if nihon == 2*(int(x[0]) - n):
            print('Yes')
            sys.exit()
            
print('No')
         
    

Measured memory_bytes: 9172
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		while (true) {
			int H = sc.nextInt();
			int W = sc.nextInt();
			if (H == 0 && W == 0) {
				break;
			}
			for (int i = 0; i < H; i++) {
				if (i % 2 == 0) {
					for (int j = 0; j < W; j++) {
						if (j % 2 == 0) {
							System.out.print('#');
						} else {
							System.out.print('.');
						}
					}
					System.out.println();
				} else {
					for (int j = 0; j < W; j++) {
						if (j % 2 == 0) {
							System.out.print('.');
						} else {
							System.out.print('#');
						}
					}
					System.out.println();
				}
			}
			System.out.println();
		}
		sc.close();
	}

}



Measured memory_bytes: 38696
import java.io.*;
import java.util.*;

/*
n = 3 k = 4
[1,2,3]
dp[i][j] = how many ways we can distruibute j candies among i children. (all j candies must used is constraint)
dp[0][0] = 1
dp[0][1] = dp[0][2] = dp[0][3] = dp[0][4] = 0;
dp[1][0] = dp[2][0] = dp[3][0] = dp[4][0] = 1;
dp[1][1] = dp[0][1] + dp[0][0] // either 1st children get 0 candies or 1 candies.
dp[1][2] = 0 = dp[0][1] + dp[0][2] ( not + dp[0][0] because we can't give 2 candies to 1'st children it only take either 0 or 1)
dp[1][3] = 0 = dp[0][2] + dp[0][3] ( not + dp[0][0] + dp[0][1] here j=3 > (arr[1]==1))
dp[i][j] = if we give ith child upto k candies than we can give i-1th childes j-k candies;
dp[i][j] = if(j <= arr[i]) prefixsum[j]
           else prefixsum[j] - prefixsum[j-arr[i]-1];
prefixsum is prefix sum of dp[i-1][] row.
dp[2][1] = prefixsum[1];
dp[2][2] = prefixsum[2];
dp[2][3] = prefixsum[3] - prefixsum[0(3 - 2 - 1)]; // j == 3 > 2
dp[2][4] = prefixsum[4] - prefixsum[1(4 - 2 - 1)]; // j == 4 > 2 
*/
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        final int MOD = (int) 1e9 + 7;
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] arr = new int[n + 1];
        for (int i = 1; i <= n; i++) {
            arr[i] = sc.nextInt();
        }

        int[][] dp = new int[n + 1][k + 1];

        dp[0][0] = 1;

        for (int i = 1; i <= n; i++) {
            int[] prefixSum = new int[k + 1];
            prefixSum[0] = dp[i - 1][0];
            for (int j = 1; j <= k; j++) {
                prefixSum[j] = (prefixSum[j - 1] + dp[i - 1][j]) % MOD;
            }

            for (int j = 0; j <= k; j++) {
                if (j <= arr[i]) {
                    dp[i][j] = prefixSum[j];
                } else {
                    dp[i][j] = (prefixSum[j] - prefixSum[j - arr[i] - 1] + MOD) % MOD;
                }
            }
        }

        // System.out.println(Arrays.deepToString(dp));
        System.out.println(dp[n][k]);
    }
}


Measured memory_bytes: 107344
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
	int n, m;
	int a[110], sum = 0;
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];
	}
	sort(a, a + n);
	for (int j = n - 1; j >= n - m; j--) {
		if (sum > a[j] * 4 * m) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector as V
import qualified Data.ByteString.Char8 as C
import Debug.Trace
import Data.List
import Control.Monad
import Data.Ord


r :: Int -> IO (U.Vector Int)
r n = U.unfoldrN n (C.readInt . C.dropWhile (==' ')) <$> C.getLine

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine

rp :: IO (Int,Int)
rp  = toTup . unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine

toTup [a,b] = (a,b)



main :: IO ()
main = do
    [a,b] <- r'
    print $ max 0 (a - 2*b)



Measured memory_bytes: 380
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Blackjack
{
    class Program
    {
        static void Main(string[] args)
        {
            var A = Console.ReadLine().Split();
            var A1 = int.Parse(A[0]);
            var A2 = int.Parse(A[1]);
            var A3 = int.Parse(A[2]);

            //Console.WriteLine(A1);
            //Console.WriteLine(A2);
            //Console.WriteLine(A3);

            if (A1+A2+A3 >= 22) 
            {
                Console.WriteLine("bust");
            }
            else
            {
                Console.WriteLine("win");
            }
        }
    }
}


Measured memory_bytes: 13140
def q3():
    N = int(input())
    from collections import deque
    S = deque()
    for _ in range(N):
        S.append(''.join(sorted(list(input()))))

    ans = 0
    d = {}  # key:文字列 value:出現回数
    for s in S:
        if s in d:
            ans += d[s]
            d[s] += 1
        else:
            d[s] = 1

    print(ans)


if __name__ == '__main__':
    q3()


Measured memory_bytes: 19848
#include <bits/stdc++.h>
using namespace std;
//using ll = long long;
#define ll long long
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll tmp1,tmp2,tmp3,ans;
const ll mod = 998244353;
const int INF = 1e9;
const ll INFLONG = 1e18;
//void swap(ll *x,ll *y){
//  ll z = *x;
//  *x = *y;
//  *y = z;
//}
//ll gcd(ll x,ll y){
//  if(y == 0){
//    return x;
//  }
//  return gcd(y,x%y);
//}
int main(){
  ll a,b;
  cin >> a >> b;
  cout << max((ll)0,a-b*2) << endl;
}

Measured memory_bytes: 256
import java.util.*;

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

        for (int i = 3; i <= n; i++) {
            if (i % 3 == 0) {
                System.out.print(" " + i);
            } else {
                int x = i;
                while (x != 0) {
                    if (x % 10 == 3) {
                        System.out.print(" " + i);
                        break;
                    }
                    x /= 10;
                }
            }
        }
        System.out.println();
    }
}

Measured memory_bytes: 28864
#!/usr/bin/env python3
n = int(input())
a = [0] + list(map(int, input().split()))
p = sorted((-a[i], -i) for i in range(n + 1))
ans = [0] * (n + 1)
m = n
for i in range(n):
    k, v = -p[i][1], -p[i][0]
    nv = -p[i + 1][0]
    m = min(m, k)
    ans[m] += (i + 1) * (v - nv)
print(*ans[1:], sep='\n')


Measured memory_bytes: 27680
s = gets.split.map(&:to_i)
n = s[0]
x = s[1]
m = []
result = 0
min = 10**5
n.times{
    i = gets.chomp.to_i
    min = i if( i<min )
    x = x-i
    result = result+1
}
result += (x/min).to_i
puts result

Measured memory_bytes: 3836
#pragma once
#include <stdio.h>


long N;
long kyori[100]={};
long kakudo[100]={};
int type[100]={};//1???1???,2???2?????????,3 2?????§,4???4???
int point[4][100]={};

int main(){

	scanf("%d",&N);

	for(int i=0;i<N;i++){
		scanf("%d%d",&kyori[i],&kakudo[i]);
		if(kakudo[i]%30==0 && kyori[i]%100 ==0 ){
			type[i] =1;
		}
		else if(kakudo[i]%30==0 && kyori[i]%100!=0 ){
			type[i] =2;
		}
		else if(kakudo[i]%30!=0 && kyori[i]%100==0 ){
			type[i] =3;
		}
		else{
			type[i] =4;
		}
	}


	for(int i=0;i<N;i++){
		switch(type[i]){
			case 1:
				point[0][i]=kyori[i]/100 + kakudo[i]/30*5;		
			break;
			case 2:
				point[0][i] =kyori[i]/100 + kakudo[i]/30*5;
				point[1][i] =kyori[i]/100 + kakudo[i]/30*5+1;
			break;
			case 3:
				point[0][i] =kyori[i]/100 + kakudo[i]/30*5;
				point[1][i] =kyori[i]/100 + kakudo[i]/30*5+5;
			break;
			case 4:
				point[0][i] =kyori[i]/100 + kakudo[i]/30*5;
				point[1][i] =kyori[i]/100 + kakudo[i]/30*5 +1;
				point[2][i] =kyori[i]/100 + kakudo[i]/30*5+5;
				point[3][i] =kyori[i]/100 + kakudo[i]/30*5 +6;
			break;
	
		}
	}




	for(int i=0;i<N;i++){
		switch(type[i]){
			case 1:
				printf("%d\n",point[0][i]);
			break;
			case 2:
				printf("%d\ %d\n",point[0][i],point[1][i]);
			break;
			case 3:
				printf("%d\ %d\n",point[0][i],point[1][i]);
			break;
			case 4:
				printf("%d\ %d\ %d\ %d\n",point[0][i],point[1][i],point[2][i],point[3][i]);
			break;
	
		}
	}


return 0;
}

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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const int64 infll = (1LL << 61) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}


int main() {
  int N, K;
  int64 L, R;

  cin >> N >> K >> L >> R;
  vector< int64 > A(N);
  cin >> A;

  int M = N / 2;
  vector< int64 > X[41];
  for(int i = 0; i < 1 << M; i++) {
    int64 add = 0;
    for(int j = 0; j < M; j++) {
      if((i >> j) & 1) add += A[j];
    }
    X[__builtin_popcount(i)].push_back(add);
  }
  for(int i = 0; i <= M; i++) {
    sort(begin(X[i]), end(X[i]));
  }

  int64 ret = 0;

  for(int i = 0; i < 1 << (N - M); i++) {
    int64 add = 0;
    for(int j = 0; j < (N - M); j++) {
      if((i >> j) & 1) add += A[j + M];
    }
    int p = __builtin_popcount(i);
    if(p > K) continue;
    ret += upper_bound(begin(X[K - p]), end(X[K - p]), R - add) - lower_bound(begin(X[K - p]), end(X[K - p]), L - add);
  }
  cout << ret << endl;
}





Measured memory_bytes: 12328
from sys import stdin, stdout
def main():
    N = int(stdin.readline())
    A = [0] + list(map(int, stdin.readline().rstrip().split()))
    dp = [0] * (N+1)
    prefix = [0] * (N+1)
    dp[1], prefix[1] = 0, A[1]
    for i in range(3, N, 2):
        prefix[i] = prefix[i-2]+A[i]
    for i in range(2, N+1):
        if i & 1:
            dp[i] = max(dp[i-1], A[i] + dp[i-2])
        else:
            dp[i] = max(dp[i-2] + A[i], prefix[i-1])
    
    stdout.write(str(dp[N])+"\n")
main()


Measured memory_bytes: 34552
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
using namespace std ;

typedef long long ll ;
#define rep (i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	int N;
		
	cin >> N;

	int l[2*N];
	for (int i = 0; i < 2*N; i++)
	{
		cin >> l[i];
	}

	sort(l, l + 2*N);

	/*
	for (int i = 0; i < 2 * N; i++)
	{
		cout << l[i] << endl;
	}
	*/

	int sum = 0;
	for (int i = 0; i < N; i++)
	{
		sum += l[2*i];
	}
	
	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
from sys import exit
n, k = map(int, input().split())
s = list(input())
if n == 1:
    print(0)
    exit()

L_record = []
R_record = []

if s[0] == "L":
    flg = "R"
else:
    flg = "L"

for i, char in enumerate(s):
    if char == "L" and flg == "R":
        L_record.append([i, 1])
        flg = "L"
    elif char == "L" and flg == "L":
        L_record[-1][1] += 1
    elif char == "R" and flg == "L":
        R_record.append([i, 1])
        flg = "R"
    elif char == "R" and flg == "R":
        R_record[-1][1] += 1

L_record.sort(key=lambda x: x[0])
R_record.sort(key=lambda x: x[0])
#print(L_record, R_record)

if L_record != []:
    if L_record[-1][0] + L_record[-1][1] == n:
        record = L_record.pop()
        L_record = [record] + L_record
if R_record != []:
    if R_record[-1][0] + R_record[-1][1] == n:
        record = R_record.pop()
        R_record = [record] + R_record


point = 0
for i, char in enumerate(s):
    #print(i, char)
    if char == "L" and i-1 >= 0:
        if s[i-1] == "L":
            point += 1
            #print(point)
    if char == "R" and i+1 < n:
        if s[i+1] == "R":
            point += 1
            #print(point)
#print(point)

#L -> R
point_l = point
for i in range(k):
    if L_record != []:
        idx, num = L_record.pop()
        if idx == 0:
            point_l += 1
        elif idx + num == n:
            point_l += 1
        else:
            point_l += 2

point_r = point
for i in range(k):
    if R_record != []:
        idx, num = R_record.pop()
        if idx == 0:
            point_r += 1
        elif idx + num == n:
            point_r += 1
        else:
            point_r += 2
print(min(max(point_r, point_l), n-1))

Measured memory_bytes: 92252
/*
  author:   Ziel
  created:  13.09.2020 17:59:24
*/

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/rope>

#define fi first
#define se second
#define sz(x) int(x.size())
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define bpc __builtin_popcountl
#define fre(f) if(fopen(f".in", "r")) freopen(f".in", "r", stdin),freopen(f".out", "w", stdout)

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

using ll = long long;
using ull = unsigned long long;
// using big = __int128_t; // -10^38...10^38
using db = double;
using ld = long double;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

template<class T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<class T>
using p_queue = priority_queue<T, vector<T>, greater<T>>;
struct chash {
  static uint64_t splitmix64(uint64_t x) {
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + RANDOM);
  }
};

const ll N = 1e5 + 123, MOD = 1e9 + 7, oo = 1e9 + 9, INF = 1e18 + 9;
const db EPS = 1e-9, PI = acos(-1); // 3.14159265358979323846
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1}, dy[] = {0, 0, 1, -1, 1, -1, -1, 1};

int32_t main() {
  fre("");
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  
  int x;
  cin >> x;
  if (x == 1)
    cout << 0;
  else
    cout << 1;
  
  return 0;
}

// uniform_int_distribution<int>(l, r)(rng) -> random in range [l, r]
// assert(condition) -> if (condition == false) Runtime Error
// order_of_key(x) -> number of elements smaller than x
// *find_by_order(k) -> k-th element in 0-based indexation
// gp_hash_table<T, U, chash> -> fast unordered_map
// m.count(x) <-> (m.find(x) != m.end())


Measured memory_bytes: 3668
#include <iostream>

using namespace std;

int findSumOfDigits(int n){
    int sum = 0;
    while(n > 0){
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

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

    if(N % findSumOfDigits(N) == 0) cout << "Yes" << endl;
    else cout << "No" << endl;

}

Measured memory_bytes: 256
s=list(map(int,input()))
#print(s)
bc=0
gc=0
if s[0]==s[1]:
    bc+=1
else:
    gc+=1
if s[1]==s[2]:
    bc+=1
else:
    gc+=1
if s[2]==s[3]:
    bc+=1
else:
    gc+=1

if 0<bc:
    print("Bad")
else:
    print("Good")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T & a, U & ... b) { cin >> a; IN_(b ...); };
template<typename T> void OUT(T && a) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }

// ---- ----

int main() {
	IN(int, n);
	set<string> se;
	inc(i, n) { IN(string, s); se.insert(s); }
	OUT(SI(se));
}


Measured memory_bytes: 19260
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

const long MOD = 1000000007;
typedef pair<int, int> P;
const int INF = 1001001001;

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

    vector<int> g[N];
    for(int i=0;i <M; i++){
        int u, v;
        cin >> u >> v;
        u--; v--;
        g[u].push_back(v);
    }
    int S, T;
    cin >> S >> T;
    S--; T--;

    int d[N][3];
    for(int i=0; i<N; i++){
        d[i][0] = INF;
        d[i][1] = INF;
        d[i][2] = INF;
    }
    d[S][0] = 0;

    priority_queue<pair<int, P>, vector<pair<int, P>>, greater<pair<int, P>>> q;
    q.push(make_pair(0, P(S, 0)));
    while(!q.empty()){
        int now = q.top().second.first;
        int mod = q.top().second.second;
        int l = q.top().first;
        q.pop();
        if(l != d[now][mod]) continue;
        for(auto next : g[now]){
            if(d[next][(mod+1)%3] > d[now][mod] + 1){
                d[next][(mod+1)%3] = d[now][mod] + 1;
                q.push(make_pair(d[next][(mod+1)%3], P(next, (mod+1)%3)));
            }
        }
    }

    int ans;
    if(d[T][0] == INF) ans = -1;
    else ans = d[T][0]/3;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 6912
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<int, int> pi;
const int mod = 1e9 + 7;

int n, a[100005];
int cnt1[100005], cnt2[100005];

lint fact(int x){
	if(x == 0) return 1;
	return fact(x-1) * x % mod;
}
int main(){
	scanf("%d",&n);
	for(int i=0; i<n; i++){
		int t;
		cnt1[abs(n-1-2*i)]++;
		scanf("%d",&t);
		cnt2[t]++;
	}
	lint ret = 1;
	for(int i=0; i<n; i++){
		if(cnt1[i] != cnt2[i]){
			puts("0");
			return 0;
		}
		ret *= fact(cnt1[i]);
		ret %= mod;
	}
	cout << ret << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};


  
int main(){
  int n,a,b;
  cin>>n>>a>>b;
  if(n<a+b-1 || (long long)n>(long long)a*(long long)b){
    cout<<-1<<endl;
    return 0;
  }
  vector<int> ans[b];
  REP(i,a){
    ans[0].push_back(n-a+1+i);
  }
  int rest = n-a;
  bool flag = false;
  bool corner=false;
  int current=1;
  int now;
  for(int i=b-1;i>=1;i--){
    if(rest==i){
      now = i;
      break;
    }else{
      REP(j,a){
        ans[i].push_back(current);
        rest--;
        current++;
        if(rest==i){
          flag = true;
          break;
        }
      }
      if(flag){
        if((int)ans[i].size()==a){
          now = i-1;
          corner = true;
        }else{
          now = i;
        }
        break;
      }
    }
  }
  for(int i=now;i>=1;i--){
    ans[i].push_back(current);
    current++;
    if(i==now && corner){
      ans[i].push_back(current);
      current++;
    }
  }
  
  int s;
  REP(i,b){
    s = ans[i].size();
    REP(j,s){
      cout<<ans[i][j]<<' ';
    }
  }
  cout<<endl;
  return 0;
}

Measured memory_bytes: 13056
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 6;
int child[maxn][26];
bool is_end[maxn];
int nxt = 1;

int main() {
    int n;
    cin >> n;
    vector<string> in(n);
    vector<vector<int>> paths(n);
    for (int who = 0; who < n; ++who) {
        string& s = in[who];
        cin >> s;
        reverse(s.begin(), s.end());
        int node = 0;
        for (char ch : s) {
            paths[who].push_back(node);
            if (child[node][ch - 'a'] == 0) {
                child[node][ch - 'a'] = nxt++;
            }
            node = child[node][ch - 'a'];
        }
        is_end[node] = true;
    }

    long long ans = 0;
    for (int who = 0; who < n; ++who) {
        string& s = in[who];
        set<char> suffix;
        for (int i = (int)s.size() - 1; i >= 0; --i) {
            suffix.insert(s[i]);
            int node = paths[who][i];
            for (char ch : suffix) {
                ans += is_end[child[node][ch - 'a']];
            }
        }
    }
    printf("%lld\n", ans - n);
    return 0;
}

Measured memory_bytes: 112892
/* I have already deleted My old account because somebody stole my code
and i have no idea how. If you are copying this code atleast make it look different 
Yours Faithfully
Shobhit Yadav */

#include<bits/stdc++.h>
using namespace std;
#define ll long long 
ll A;
double B;
/*ll freq[200005];*/
void solve(){
	 /*memset(freq,0,sizeof(freq));*/
	cin>>A>>B;

	ll bb=round(B*100);
    cout<<A*bb/100<<"\n";


}



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

	return 0;
}

Measured memory_bytes: 3708
#include<stdio.h>
#include<stdbool.h>

char s[10], c;
int l, i, cnt;
bool ok = true;

int main(void){
        while((c=getchar())!='\n') s[l++] = c;
        for(i=0; i<l; i++){
                if('a'<=s[i] && s[i]<='z') cnt++;
                else if(s[i]=='C'){
                        if(i<2 || l-2<i) ok = false;
                }
                else if(s[i]=='A'){
                        if(i!=0) ok = false;
                }
                else ok = false;
        }
        if(ok && cnt==l-2) puts("AC");
        else puts("WA");
        return 0;
}

Measured memory_bytes: 128
#include <stdlib.h>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <iostream>
#include <set>
#include <string>

using namespace std;


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

    if(n%1000==0) {
        cout<<0<<endl;
    }
    else {
        int d = n/1000;
        int left = d*1000;
        if(left<n) {
            left = (d+1)*1000;
            if(left>n) {
                cout<<left-n<<endl;
            }
        }
    }
    
    
    return 0;
}


Measured memory_bytes: 3636
object Main extends App {
  val read = scala.io.StdIn.readLine()
  val array =  read.split(" ").map(_.toInt).toVector
  val sum = array(0) + array(1)
  if (sum % 2 == 0) {
    println(sum / 2)
  } else {
    println("IMPOSSIBLE")
  }
}

Measured memory_bytes: 25524
///#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
const long double PI=3.14159265358979323846264338327950;
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n,q;
  cin>>n>>q;
  vector<stack<int> > vs(n);

  rep(i,q){
    int tmp,t,x;
    cin>>tmp;
    if(tmp==0){
      cin>>t>>x;
      vs[t].push(x);
    }
    else if(tmp==1){
      cin>>t;
      if(vs[t].empty()){
        continue;
      }
      cout<<vs[t].top()<<'\n';
    }
    else{
      cin>>t;
      if(vs[t].empty()){
        continue;
      }
      vs[t].pop();
    }
  }
  
  return(0);
}


Measured memory_bytes: 4268
#include <cstdio>
#include <cstring>
#include <cassert>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
typedef long long int64;
 
int cmp(int64 a, int64 b)
{
  string x = to_string(a);
  string y = to_string(b);
  return a <= b && x <= y || a > b && x > y;
}

int64 dest;
int main()
{
  //cin >> dest;
  const int l = 9;
  int64 a = 1, b = 9;
  for (int i = 1; i < l; ++i) a *= 10, b = b * 10 + 9;
  const int64 maxv = b;
  while (a <= b)
  {
    int64 mid = a + b >> 1;
    printf("? %lld0\n", mid); /*puts(cmp(mid, 123) ? "Y" : "N");*/ fflush(stdout);
    char buff[32];
    scanf("%s", buff);
    //buff[0] = cmp(mid, dest) ? 'Y' : 'N';
    if (buff[0] == 'Y') b = mid - 1; else a = mid + 1;
  }
  vector<int64> tester;
  int64 aa = a;
  while (aa%10==0) aa /= 10;
  for (int64 x = aa*10; x <= maxv; x = x * 10) tester.push_back(x+9);
  if (aa%10>1)
  {
    tester.push_back(aa-1);
    for (int64 x = (aa-1)*10; x <= maxv; x = x * 10) tester.push_back(x+9);
  }
  if (aa%10<9)
  {
    tester.push_back(aa+1);
    for (int64 x = (aa+1)*10; x <= maxv; x = x * 10) tester.push_back(x+9);
  }
  string s;
  for (auto& iter: tester)
  {
    printf("? %lld\n", iter); /*puts(cmp(iter, 123) ? "Y" : "N");*/ fflush(stdout);
    char buff[32];
    scanf("%s", buff);
    //buff[0] = cmp(iter, dest) ? 'Y' : 'N';
    s += buff[0] == 'Y' ? '1' : '0';
  }
  for (;;)
  {
    string me;
    for (auto& iter: tester)
      me += cmp(iter, aa) ? '1' : '0';
    if (me == s) {printf("! %lld\n", aa); break;}
    aa *= 10;
  }
  return 0;
}

Measured memory_bytes: 596
n, k = map(int, input().split())
d = [ int(x) for x in input().split() ]

def is_ok(x):
    while x != 0:
        if x % 10 in d:
            return False
        x //= 10
    return True

money = n
while True:
    if is_ok(n):
        print(n)
        break
    n += 1


Measured memory_bytes: 3060
s = input()
t = input()

ans = len(t)
n_1 = len(s) - len(t)
n_2 = len(t)

tmp = 0
for i in range(n_1 + 1):
  tmp = 0
  for j in range(n_2):
    if s[i + j] != t[j]:
      tmp += 1
  ans = min(ans, tmp)

print(ans)

Measured memory_bytes: 9056
#include <bits/stdc++.h>
using namespace std;
#define _overload3(_1,_2,_3,_4,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,n) (int i=a;i<n;i++)
#define per(i,a,n,s) (int i=n-1;i>=a;i--)
#define range(...) _overload3(__VA_ARGS__,per,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define vecin(x) for(auto&youso_: (x) ) cin >>  youso_
#define vecout(x) for(auto&youso_: (x) ) cout << youso_ << " " ; cout << endl
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; }
const int inf = 1e9+10;
const int mod = 1e9+7;
const long long llinf = 1e18;
#define _GLIBCXX_DEBUG
// head

int main(){
    int  n,m;
    cin >> n >> m;
    cout << (n-1)*(m-1) << endl;

}


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

int main() {

	ll h, n; cin >> h >> n;
	string ans = "No";
	for (ll i = 0; i < n; i++) {
		ll a; cin >> a;
		h -= a;
		if (h <= 0) {
			ans = "Yes";
			break;
		}
	}
	cout << ans << endl;
    return 0;
}

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

using namespace std;

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout .tie(0);
  long long n;
  cin >> n;
  string k;
  while (n) {
    n -= 1;
    k.push_back('a' + n % 26LL);
    n /= 26LL;
  }

  for (int i = k.size(); i > 0; i--) cout << k[i - 1]; 
  return 0;
}


Measured memory_bytes: 3644
#[macro_export]
// #[snippet(name = "input")]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[doc(hidden)]
#[macro_export]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

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

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

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

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

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

fn main() {
    input!{
        n: i32,
        k: i32,
    }

    println!("{}", if n % k == 0 { 0 } else { 1 });
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <cmath>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int N, K, A;
    cin >> N >> K;
    REP(i, N) cin >> A;
    cout << (int)(ceil((double)(N - 1) / (K - 1))) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
ll n, k;
int main(void){
    // Your code here!
    cin >> n >> k;
    if (k % 2 || n < k / 2){
        ll a = n / k;
        cout << a * a * a << endl;
    } else {
        ll a = n / k;
        ll ans = a * a * a;
        ll b = (n - k / 2) / k + 1;
        cout << ans + b * b * b << endl;
    }
}


Measured memory_bytes: 256
import sys


n = int(input())

if n == 0:
    print('0')
    sys.exit()

l1 = []
t = 0
s = 0
a = 0
while a < 10 ** 9:
    a = 2 ** t
    s += a
    l1.append(s)
    t += 2

l2 = []
t = 1
s = 0
a = 0
while a < 10 ** 9:
    a = 2 ** t
    s += a
    l2.append(s)
    t += 2


result = []
while n != 0:
    if n > 0:
        N = abs(n)
        for i in range(len(l1)):
            if N <= l1[i]:
                x = 2 * i
                break
        n -= (-2) ** x
        result.append(x)
    else:
        N = abs(n)
        for i in range(len(l2)):
            if N <= l2[i]:
                x = 2 * i + 1
                break
        n -= (-2) ** x
        result.append(x)

ans = []
for i in range(result[0], -1, -1):
    if i in result:
        ans.append('1')
    else:
        ans.append('0')

answer = ''.join(ans)
print(answer)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define vi vector<int>
#define vll vector<ll>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pb  push_back
#define mp  make_pair
int main(){
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// #endif
	ll a;
	string s;
	cin>>a>>s;
	if(a>=3200)
		cout<<s<<endl;
	else 
		cout<<"red"<<endl;
}

Measured memory_bytes: 256
/**
*
* Author: Mouhanad
* Lang: GNU C++14
*
**/
#include<bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define ii pair < int , int >
#define LS pair < ll , string >
typedef long long ll;
const int inf = 1<<30;
const int N =100100 , mod = 1000000007;
int n , a[N] , q ;
char al[N];
int dp[32];
int frq[N];
int main ( ){
  scanf("%d",&n);
  scanf("%s",al);
  for  (int i = 0 ; i< n ;i++ ) frq[al[i]-'a']++;
  dp[26] = 1 ;

  for ( int i = 25 ; i>= 0 ; i-- ){
        dp[i] += dp[i+1]%mod;
        dp[i] %= mod;
        dp[i] += ( 1LL*(frq[i]%mod) * (dp[i+1]%mod ) )%mod;
        dp[i] %= mod;
  }
  dp[0] -= 1;
  dp[0] += mod ;
  dp[0] %= mod ;
 printf("%d\n",dp[0]);
return 0 ;
}


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

int main()
{
    long long int h, w;
    cin>>h>>w;
    if((h % 2 == 0 && w % 2 == 0) || (h % 2 == 0 && w % 2 != 0) && (h != 1 || w != 1))
    {
        cout<< w * (h/2)<<endl;
    }
    else if(h == 1 || w == 1)
    {
        cout<<"1"<<endl;
    }
    else
    {
        if(h % 2 != 0 && w % 2 == 0 && (h != 1 || w != 1))
        {
            cout<<((w/2) * ((h/2) +1)) + ((w/2)*(h/2))<<endl;
        }
        else if(h % 2 != 0 && w % 2 != 0 && (h != 1 || w != 1))
        {
            cout<< (((w/2) + 1) * ((h/2) + 1)) + ((w/2)*(h/2))<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256