akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>

int main()
{
    // input
    long A,B,N;
    scanf( "%ld %ld %ld", &A, &B, &N );

    long qa = A / B;
    long ra = A % B;
    long rx = std::min( B - 1, N );
    long ret = rx * qa + std::floor( ra * rx * 1.0 / B );

    // process

    // output
    printf( "%ld\n", ret );

    return 0;
}


Measured memory_bytes: 1736
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <queue>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;

#define MP make_pair
#define PB push_back
#define FF first
#define SS second

#define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }

// #define FL fflush(stdout)

#define MOD 1000000007
#define INF 2000000000

int GLL(LL& x) {
  return scanf("%lld", &x);
}

int GI(int& x) {
  return scanf("%d", &x);
}


LL n, a, b, c, d;

bool inInterval(PLL interval, LL query) {
  if (query >= interval.FF && query <= interval.SS) return true;
  else return false;
}

void check(PLL itv, LL query) {
  if (inInterval(itv, query)) 
    printf("YES\n");
  else
    printf("NO\n");
}

int main() {
  GLL(n);
  GLL(a);
  GLL(b);
  GLL(c);
  GLL(d);

  // at step n there are n+1 intervals
  // len(interval) = 1 + n * (d-c)
  // large: a + n*d
  // small: a - n*d
  // gap: (large - small - (n+1)*len) / n

  LL large = a + (n-1)*d;
  LL small = a - (n-1)*d;
  LL len = 1 + (n-1) * (d-c);
  LL gap = (large - small - n*(len - 1)) / (n-1);
//  printf("gap = (%lld - %lld - (%lld - 1) * %lld) / (%lld -2)", large, small, n, len, n);
  if (gap <= 0) {
    check(MP(small, large), b);
    return 0;
  }

//  printf("[%lld, %lld], len: %lld, gap: %lld, total: %lld\n", small, large, len, gap, len * (n-1) + gap*(n-1));
//  LL total = len * (n-1) + gap*(n-1);
//  assert(total == large - small);

  LL stop = large;
  LL start = large - len + 1;
  FORN(k, n) { // for each interval
//    printf("(%lld, %lld)\n", start, stop);
    if (inInterval(MP(start, stop), b)) {
      printf("YES\n");
//      printf("YES: (%lld, %lld)\n", start, stop);
      return 0;
    }
    
    start -= len + gap - 1;
    stop -= len + gap - 1;
  }
  printf("NO\n");
    
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n,k; cin >> n >> k;
	vector<ll> a(n);
	vector<ll> cnt(n+1,0);
	for(int i=0;i<n;i++){
		cin >> a[i];
		cnt[i+1]=cnt[i]+a[i];
	}
	vector<ll> v;
	for(int i=0;i<n;i++){
		for(int j=i;j<n;j++){
			v.push_back(cnt[j+1]-cnt[i]);
		}
	}
	ll ans=0;
	for(int i=50;i>=0;i--){
		ans+=1LL<<i;
		int num=0;
		for(ll j:v){
			if((ans&j)==ans)num++;
		}
		if(num<k){
			ans-=1LL<<i;
		}
	}
	cout << ans << endl;
}

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

word = ns()
print(word[0] + str(len(word)-2) + word[-1])

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

using namespace std;


int main () {


	ios_base::sync_with_stdio(false);  cin.tie(NULL); 

	string x;
	cin >> x;

	if (x == "Sunny")
		cout << "Cloudy";
	else if (x == "Rainy")
		cout << "Sunny";
	else cout << "Rainy";

	cout << '\n';



	return 0;
}





Measured memory_bytes: 256
r, c = map(int, input().split())
rows = [[0 for i in range(c+1)] for j in range(r+1)]

for i in range(r):
    rows[i] = list(map(int, input().split()))
    rows[i].append(0)

for i in range(r):
    for j in range(c):
        rows[i][c] += rows[i][j]

for i in range(c + 1):
    for j in range(r):
        rows[r][i] += rows[j][i]

for i in range(r+1):
    print(" ".join(map(str, rows[i])))



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

using namespace std;

int n, ans, a[(int)1e5];

int main(){
	cin >> n;
	for(int i = 0; i < n; ++i) cin >> a[i];
	for(int i = 0; i < n; ++i) ans = __gcd(ans, a[i]);
	cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define fr first
#define se second
#define r_0 return 0
#define ll long long
#define pb push_back
#define TIME ios_base::sync_with_stdio(0);
using namespace std;

const long long INF = 1e6;
const long long N = 1e3 + 7;
const long long mod = 1e9 + 7;
const long double eps = 1E-7;

ll T = 1, n, m, b, ans, y, x, c, a[N][N], used[INF], u[INF], cnt, mn = 1e18;
string s;
vector < ll > v, v1;
set< char > st;
int main(){
    TIME
    for ( int i=0; i<3; i++ ){
        for ( int j=0; j<3; j++ ){
            cin >> a[i][j];
            used[ a[i][j] ] = 1;
        }
    }
    cin >> n;
    for ( int i=0; i<n; i++ ){
        cin >> x;
        u[x] = 1;
    }
    if ( used[ a[0][0] ] == u[a[0][0] ] and used[ a[1][1] ] == u[a[1][1] ] and used[ a[2][2] ] == u[a[2][2] ] )
        return cout << "Yes", 0;
    if ( used[ a[0][2] ] == u[a[0][2] ] and used[ a[1][1] ] == u[a[1][1] ] and used[ a[2][0] ] == u[a[2][0] ] )
        return cout << "Yes", 0;
    if ( used[ a[1][0] ] == u[a[1][0] ] and used[ a[1][1] ] == u[a[1][1] ] and used[ a[1][2] ] == u[a[1][2] ] )
        return cout << "Yes", 0;
    if ( used[ a[0][1] ] == u[a[0][1] ] and used[ a[1][1] ] == u[a[1][1] ] and used[ a[2][1] ] == u[a[2][1] ] )
        return cout << "Yes", 0;
    if ( used[ a[0][0] ] == u[a[0][0] ] and used[ a[1][0] ] == u[a[1][0] ] and used[ a[2][0] ] == u[a[2][0] ] )
        return cout << "Yes", 0;
    if ( used[ a[0][2] ] == u[a[0][2] ] and used[ a[1][2] ] == u[a[1][2] ] and used[ a[2][2] ] == u[a[2][2] ] )
        return cout << "Yes", 0;
    if ( used[ a[0][0] ] == u[a[0][0] ] and used[ a[0][1] ] == u[a[0][1] ] and used[ a[0][2] ] == u[a[0][2] ] )
        return cout << "Yes", 0;
    if ( used[ a[2][0] ] == u[a[2][0] ] and used[ a[2][1] ] == u[a[2][1] ] and used[ a[2][2] ] == u[a[2][2] ] )
        return cout << "Yes", 0;
    return cout << "No", 0;

}

Measured memory_bytes: 4352
n = int(input())
if n <=599:
    print(8)
elif n <=799:
    print(7)
elif n <= 999:
    print(6)
elif n <= 1199:
    print(5)
elif n <= 1399:
    print(4)
elif n <= 1599:
    print(3)
elif n <= 1799:
    print(2)
else :
    print(1)

Measured memory_bytes: 9176
#include <bits/stdc++.h>
#define N 1000005
#define ll long long int 	
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define sp " "
#define endl "\n"
#define fi first
#define se second
#define ii pair<int,int>
#define lli pair<ll,ll>
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define fast2 freopen ("myfile.in","r",stdin);freopen ("myfile.out","w",stdout);
#define mod 1000000007
#define fs(x,y) for(int i=1;i<=y;i++) cin>>x[i];
#define fo(i,x,y) for(int i=x;i<=y;i++)
using namespace std;

ll n,m,ar[N],sum;


int main()
{
	fast;
	int a,b,c,d;
	cin>>a>>b;
	cin>>c>>d;
	// if(a==c)
	cout<<(a-c)*(b-d);

}

Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int a[100009]={0},b[100009]={0};
int main()
{
    int t,i;
    scanf("%d",&t);
    for(i=1;i<=t;i++){
        int n1;
        scanf("%d",&n1);
        a[n1]=i;
    }
    for(i=1;i<=t;i++){
        if(i>1)
            printf(" ");
        printf("%d",a[i]);
    }
    return 0;
}


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

int main()
{
    int A, B, C, K;
    cin >> A >> B >> C >> K;
    int sum = 0;

    while(A > 0) {
        sum++;
        A--;
        K--;
        if (K == 0) {
            cout << sum << endl;
            break;
        } else {
            continue;
        }
    }
    if (K > 0) {
        while(B > 0) {
            B--;
            K--;
            if (K == 0) {
                cout << sum << endl;
                break;
            } else {
                continue;
            }
        }
    }
    if (K > 0) {
        sum = sum - (1 * K);
        cout << sum << endl;
    }
}

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

int main(){
    string S;
    cin >> S;
    int len = S.size();
    int ans = 0;
    if (len == 1){
        ans = 1;
    }
    else if (len == 2){
        if (S[0] == S[1]) ans = 1;
        else ans = 2;
    }
    else{
        int count = 0;
        while(true){
            if (S.size() == 1){
                count++;
                break;
            }
            else if (S.size() == 2){
                if (S[0] == S[1]) count++;
                else count += 2;
                break;
            }
            else if (S.size() == 3){
                if (S[1] == S[2]) count += 2;
                else if (S[0] == S[1]) count += 2;
                else count += 3;
                break;
            }
            else{
                if (S[S.size() - 1] == S[S.size() - 2]){
                    S = S.substr(0, S.size() - 3);
                    count += 2;
                }
                else{
                    S = S.substr(0, S.size() - 1);
                    count++;
                }
            }
        }
        ans = count;
    }
    cout << ans << endl;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (ll i=(ll)from; i<(ll)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }

int main() {
  ll N; cin >> N;
  ll X[N], Y[N], P[N]; rep(i,N) cin >> X[i] >> Y[i] >> P[i];
  ll xmin[N][1<<N], ymin[N][1<<N];
  rep(i,1<<N) rep(j,N) {
    xmin[j][i] = abs(X[j]); rep(k,N) if (i&1<<k) xmin[j][i] = min(xmin[j][i], abs(X[k]-X[j]));
    ymin[j][i] = abs(Y[j]); rep(k,N) if (i&1<<k) ymin[j][i] = min(ymin[j][i], abs(Y[k]-Y[j]));
  }
  // rep(i,N) debug(xmin[i],xmin[i]+(1<<N));

  vector<ll> result(N+1,LLINF);
  rep(i,pow(3,N)) {
    ll ti = i, dx = 0, dy = 0, count = 0;
    rep(j,N) {
      if (ti%3==1) { dx += 1<<j; count++; }
      else if (ti%3==2) { dy += 1<<j; count++; }
      ti /= 3;
    }
    ll sum = 0; rep(j,N) sum += min(xmin[j][dx], ymin[j][dy]) * P[j];
    if (result[count]>sum) result[count] = sum;
  }
  rep(i,N+1) cout << result[i] << endl;
  return 0;
}

Measured memory_bytes: 11772
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
typedef long long LL;
typedef long double Lf;
#define Rep(i,a,n)for(int i=(int)(a);i<(int)(n);i++)
#define rep(i,n)Rep(i,0,n)
#define Ma(x,y) ((x)>(y)?(x):(y))
#define mi(x,y) ((x)<(y)?(x):(y))
#define N 11
#define MOD 1000000007
int acs(const void* a, const void* b) { return *(int*)a - *(int*)b; }//1,2,3,4
int des(const void* a, const void* b) { return *(int*)b - *(int*)a; }//8,7,6,5
int cmp_char(const void* a, const void* b) { return *(char*)a - *(char*)b; }//a,b,c,d
int cmp_str(const void* a, const void* b) { return strcmp(*(const char**)a, *(const char**)b); }//aaa,aab
//temmie_のsnippet

int main() {
	int n,a[2001];
	LL k,ansi=0,anse=0;
	scanf("%d%lld",&n,&k);
	rep(i,n)scanf("%d",a+i);
	//internal
	rep(i,n)Rep(j,i,n)if(a[i]>a[j])ansi++;
	ansi*=k;ansi%=MOD;
	//external
	rep(i,n)rep(j,n)if(a[i]>a[j])anse++;
	k=k*(k-1)/2;k%=MOD;
	anse*=k;anse%=MOD;

	printf("%lld",(ansi+anse)%MOD);
	return 0;
}

Measured memory_bytes: 128
using System;

class ABC075A
{
	static public void Main(string[] args)
	{
		int A,B,C;
		string[] vals = Console.ReadLine().Split(' ');
		A = int.Parse(vals[0]);
		B = int.Parse(vals[1]);
		C = int.Parse(vals[2]);

		if(A == B)
		{
			Console.WriteLine(C);
		}
		else if(A == C)
		{
			Console.WriteLine(B);
		}
		else if(B == C)
		{
			Console.WriteLine(A);
		}
	}
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
const int maxn = 55;
int gg[maxn][maxn];
int main(){
  int n, m; cin >> n >> m;
  for(int i = 0; i < m; i++){
    int x, y; cin >> x >> y;
    gg[x][y] = gg[y][x] = 1;
  }
  vector<int> o(n - 1);
  iota(o.begin(), o.end(), 2);
  int ans = 0;
  do{
  	int last = 1, good = 1;
    for(int v : o){
      good &= gg[last][v];
      last = v;
    }
    ans += good;
  } while(next_permutation(o.begin(), o.end()));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.awt.geom.Point2D;
import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	public static void main(String[] args){
		new Main();
	}
	public Main(){
		new A().doIt();
	}
	class A{
		void doIt(){
			int n = sc.nextInt();
			long a[] = new long[n];
			long b[] = new long[n];
			for(int i = 0;i < n;i++){
				a[i] = sc.nextLong();
				b[i] = sc.nextLong();
			}
			long num = 0;
			for(int i = n - 1;i >= 0;i--){
				if(b[i] > 1){
					long cc = (a[i] + num) % b[i];
					if(cc > 0)num = num +  b[i] - ((a[i] + num) % b[i]);
				}
			}
			System.out.println(num);
		}
	}
}


Measured memory_bytes: 64004
#include<iostream>
using namespace std;
int main()
{
	int n, ans = 0;
	cin >> n;
	for (int i = 0; n >= 0; i++)
	{
		if (n % 7 == 0 || n == 0)
		{
			ans = 1;
		}
		n -= 4;
	}
	if (ans == 1)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = 0
last_eat = -1
for a in A:
    ans += B[a - 1]
    if a == last_eat + 1:
        ans += C[last_eat - 1]
    last_eat = a

print(ans)


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

const int MAX = 1000000;
bool A[MAX];

int main() {
    int n, k, r, s, p;
    string t;
    cin >> n >> k >> r >> s >> p;
    cin >> t;
    int ans = 0;
    map<char, int> mp;
    mp['r'] = p;
    mp['s'] = r;
    mp['p'] = s;
    for (int i = 0; i < n; ++i) {
        ans += mp[t[i]];
        if (i >= k && t[i] == t[i-k]) {
            ans -= mp[t[i]];
            t[i] = 'a';
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define reg register
#pragma GCC optimize(3)
#pragma GCC optimize("02")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#define _inline __inline__ __attribute__((always_inline))
using namespace std;
class complex{
public:
    inline char gc(){
        static const signed IN_LEN=1<<18|1;
        static char buf[IN_LEN],*s,*t;
        return (s==t)&&(t=(s=buf)+fread(buf,1,IN_LEN,stdin)),s==t?-1:*s++;
    }
    template <typename _Tp> _inline complex & operator >> (_Tp &x){
        static char ch,sgn; ch=gc(),sgn=0;
        for(;!isdigit(ch);ch=gc()){if(ch==-1)return *this;sgn|=ch=='-';}
        for(x=0;isdigit(ch);ch=gc())x=x*10+(ch^'0');
        sgn&&(x=-x); return *this;
    }
}inc;
signed main(){
	//ios_base::sync_with_stdio(0);
	//cin.tie(0);
	//cout.tie(0);
	int a,b;
	scanf("%d%d",&a,&b);
	int cnt=0;
	while(a){
		a/=b;
		cnt++;
	}
	printf("%d\n",cnt);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const int mod = 1000000007;

struct mint {
  ll x;
  mint(ll x = 0): x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) { if ((x += a.x) >= mod) x -= mod; return *this; }
  mint& operator-=(const mint a) { if ((x += mod - a.x) >= mod) x -= mod; return *this; }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
  mint operator+(const mint a) const { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return *this *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
};
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

ll powmod(ll a, int b) {
  a %= mod;
  ll res = 1;
  while (b) {
    if (b % 2 == 1) res = res * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return res;
}

ll f[200005];
void cominit() {
  f[0] = 1;
  for (int i = 0; i < 200000; i++) f[i + 1] = f[i] * (i + 1) % mod;
}

ll nCr(int n, int r) {
  if (n < r or r < 0) return 0;
  return f[n] * powmod(f[r] * f[n - r], mod - 2) % mod;
}

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int &i : a) cin >> i;
  sort(a.begin(), a.end());
  cominit();
  mint ans = 0;
  for (int i = 0; i < n; i++) {
    mint res = nCr(i, k - 1);
    res *= a[i];
    ans += res;
  }
  reverse(a.begin(), a.end());
  for (int i = 0; i < n; i++) {
    mint res = nCr(i, k - 1);
    res *= a[i];
    ans -= res;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 64;
int n, a[N];
int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    cin >> n;
    for (int i = 0; i < 3 * n; ++i) {
        cin >> a[i];
    }
    sort(a, a + 3 * n);
    int64_t s = 0;
    int cnt = 0;
    for (int i = 3 * n - 2; cnt < n; i -= 2, ++cnt) {
        s += a[i];
    }
    cout << s << "\n";
    return 0;
}


Measured memory_bytes: 1408
#include<iostream>
#include<vector>
using namespace std;
int main(int argc, char *argv[])
{
    for(;;) {
        int n;
        cin >> n;
        if(n == 0) break;
        int cnt = 0;
        bool st = false;
        bool left = false;
        bool right = false;
        for(int i = 0; i < n; i++) {
            string s;
            cin >> s;
            if(s == "lu") {
                left = true;
            } else if(s == "ru") {
                right = true;
            } else if(s == "ld") {
                left = false;
            } else if(s == "rd") {
                right = false;
            }
            if(left == !st && right == !st) {
                st = !st;
                cnt++;
            }
        }
        cout << cnt << endl;
    }
    return 0;
}



Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++){
    cin >> a[i];
  }
  if (n % 2 == 0){
    for (int i = 0; i < n / 2; i++){
      cout << a[n - 1 - i * 2] << ' ';
    }
    for (int i = n / 2; i < n; i++){
      cout << a[(i - n / 2) * 2];
      if (i < n - 1){
        cout << ' ';
      }
    }
    cout << endl;
  } else {
    for (int i = 0; i < n / 2 + 1; i++){
      cout << a[n - 1 - i * 2] << ' ';
    }
    for (int i = n / 2 + 1; i < n; i++){
      cout << a[(i - (n / 2 + 1)) * 2 + 1];
      if (i < n - 1){
        cout << ' ';
      }
      cout << endl;
    }
  }
}

Measured memory_bytes: 3072
import heapq
N = int(input())
A = list(map(int, input().split()))
h = []
for i, num in enumerate(A):
  heapq.heappush(h,(num, i))
sorted_h = [heapq.heappop(h) for i in range(len(h))]
B = []
for i in range(N):
  if(i < (N // 2)):
    heapq.heappush(B, (sorted_h[i][1], sorted_h[((N//2))][0]))
  else:
    heapq.heappush(B,(sorted_h[i][1], sorted_h[((N//2) - 1)][0]))
for i in range(len(B)):
  print(heapq.heappop(B)[1])

Measured memory_bytes: 49476
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)

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

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

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

int main() {
  string s, t;
  cin >> s >> t;
  if (s == t.substr(0, s.length())) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3628
#include<stdio.h>
#include<string.h>
#include<map>
#include <iostream>
using namespace std;
map<string,int> mymap;

int main()
{
    int n;
    string s,word;
    scanf("%d",&n);

    for(int i=0;i<n;i++)
    {
    cin>>s>>word;
            if(s=="insert")
            {
                mymap[word]=1;
            }
            else if(s=="find")
            {
               if(mymap[word]==1)
                {
                    printf("yes\n");
                }
                if(mymap[word]!=1)
                {
                    printf("no\n");
                }
            }
    }
}

Measured memory_bytes: 52648
import java.util.Scanner;

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

        if (a < b){
            System.out.println("a < b");
        }
        else if (a > b){
            System.out.println("a > b");
        }
        else {
            System.out.println("a == b");
        }
    }
}

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;


int main() {
    string s;
    cin >> s;
    for (auto& c : s) {
        c = 'x';
    }
    cout << s << endl;

    return 0;
}

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

int A[1005][500005];
ll I[1005];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, Q;
    cin >> N >> Q;


    REP(_, Q) {
        ll q;
        cin >> q;
        if (q == 0) {
            ll t, x;
            cin >> t >> x;
            A[t][I[t]++] = x;
        }
        else if (q == 1) {
            ll t;
            cin >> t;
            REP(i, I[t]) {
                cout << A[t][i];
                if (i < I[t] - 1)
                    cout << " ";
            }
            cout << endl;
        }
        else {
            ll t;
            cin >> t;
            I[t] = 0;
        }
    }
    return 0;
}


Measured memory_bytes: 9060
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define ll              long long
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)      __builtin_ctzll(x)
#define mod             998244353
#define Mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define vpii            vector<pair<int,int> >
#define all(x)          x.begin(),x.end()
#define matrixprint(arr,a,b,c,d) for(int i=a;i<=c;i++){for(int j=b;j<=d;j++){cout<<arr[i][j]<<" ";}cout<<"\n";}
#define show(arr,x,y)   for(int i=x;i<=y;i++){cout<<arr[i]<<" ";}cout<<"\n"
#define sz               size()
#define inc(i,x,y)      for(int i=x;i<y;i++)
#define dec(i,x,y)      for(int i=x;i>=y;i--)

const int N = 2e5 + 5;

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

void fast()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//#ifndef ONLINE_JUDGE
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
//#endif
}

//////////////////////////////code//////////////////////////////
int arr[15][15];
 int n,m,x;
 int ans;

 void cal(vi s)
 {
     int curr=0;
     map<int,int>mp;
     for(int i=0;i<n;i++)
     {
         if(s[i])
         {
             for(int j=1;j<=m;j++)
                mp[j]+=arr[i][j];

             curr+=arr[i][0];
         }
     }
     int f=0;
     for(int i=1;i<=m;i++)
        if(mp[i]<x)
         f=1;

     if(f==0)
     ans=min(ans,curr);

 }

 void seq(int j,vi &s)
 {
     if(j==n)
     {
         cal(s);
         return ;
     }

     for(int i=0;i<=1;i++)
     {
         s.pb(i);
         seq(j+1,s);
         s.pop_back();
     }

 }
int32_t main()
{
  fast();


  cin>>n>>m>>x;

  for(int i=0;i<n;i++)
    for(int j=0;j<=m;j++)
     cin>>arr[i][j];

  ans=inf;

  vi s;
  seq(0,s);
  
  if(ans!=inf)
  cout<<ans;
  else
    cout<<-1;



}


Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define  all(x) (x).begin(),(x).end()
typedef long long ll;
typedef struct Card
{
    char mark;
    int value;
} Card;

vector<Card> c, b, s;

void printCard(vector<Card> cc){
    for(int i = 0; i < cc.size(); i++){
        cout << cc[i].mark << cc[i].value;
        if (i != cc.size()-1) cout << " ";
    }
    cout << endl;
}

void bubbleSort(){
    for(int i = 0; i < b.size(); i++){
        for(int j = b.size()-1; i < j; j--){
            if (b[j-1].value > b[j].value){
                swap(b[j-1], b[j]);
            }
        }
    }
}

void selectionSort(){
    for(int i = 0; i < s.size(); i++){
        int min_idx = i;
        for(int j = i+1; j < s.size(); j++){
            if (s[j].value < s[min_idx].value){
                min_idx = j;
            }
        }
        swap(s[i], s[min_idx]);
    }
}

int main(){
    int n;
    cin >> n;
    c = b = s = vector<Card>(n);
    rep(i,n){
        string x;
        cin >> x;
        Card ci = {x[0], x[1]-'0'};
        c[i] = ci;
    }
    b = s = c;
    bubbleSort();
    selectionSort();

    printCard(b);
    cout << "Stable" << endl;    
    printCard(s);
    bool ok = true;
    rep(i,n){
        if (b[i].mark != s[i].mark) ok = false;
    }
    if (ok) cout << "Stable" << endl;
    else cout << "Not stable" << endl;
}


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

int main(){
  int N, Q;
  cin >> N >> Q;
  string S;
  cin >> S;
  int count[N+1] = {0};
  for(int i = 2; i <= N; i++){
    if(S[i-1] == 'C' && S[i-2] == 'A') count[i] = count[i-1] + 1;
    else count[i] = count[i-1]; 
  }
  int ans[Q];
  for(int i = 0; i < Q; i++){
    int l, r;
    cin >> l >> r;
    ans[i] = count[r] - count[l];
  }
  for(int i = 0; i < Q; i++){
    cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 1792
import math

time = [int(input()) for _ in range(5)]
ans = 0
min_ones = 10

for t in time:
    ans += math.ceil(t / 10) * 10
    ones = int(str(t)[-1])
    if ones < min_ones and ones > 0:
        min_ones = ones

if min_ones != 10:
    ans = ans - (10 - min_ones)

print(ans)

Measured memory_bytes: 3060
P,M = map(int,input().split())
dac = {}
dwa = {}
for _ in range(M):
  p,s = input().split()
  p = int(p)
  if s == "AC":
    if p not in dac:
      dac[p] = 1
  else:
    if p not in dac:
      if p not in dwa:
        dwa[p] = 1
      else:
        dwa[p] += 1

score = len(dac)
penalty = sum([val for k,val in dwa.items() if (k in dac)])
print(score,penalty)

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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
#define mins(x, y) (x = min(x, y))
#define maxs(x, y) (x = max(x, y))
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using P = pair<int, int>;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

struct mint {
  ll v;
  mint() : v(0) {}
  mint(ll v) : v((v % MOD + MOD) % MOD) {}
  operator ll() const { return v; }
  mint pow(ll t) const;
  mint inv() const;
};
mint& operator+=(mint& a, mint b) { return a = a.v + b.v; }
mint& operator-=(mint& a, mint b) { return a = a.v - b.v; }
mint& operator*=(mint& a, mint b) { return a = a.v * b.v; }
mint operator+(mint a, mint b) { return a += b; }
mint operator-(mint a, mint b) { return a -= b; }
mint operator*(mint a, mint b) { return a *= b; }
mint operator-(mint a) { return (mint)0 - a; }
mint& operator/=(mint& a, mint b) { return a *= b.inv(); }
mint operator/(mint a, mint b) { return a /= b; }
mint mint::pow(ll t) const {
  if (!t) return 1;
  mint a = pow(t >> 1);
  a *= a;
  if (t & 1) a *= *this;
  return a;
}
mint mint::inv() const { return pow(MOD - 2); }
bool operator==(mint a, mint b) { return a.v == b.v; }
bool operator!=(mint a, mint b) { return a.v != b.v; }
istream& operator>>(istream& os, mint& a) { return (os >> a.v); }
ostream& operator<<(ostream& os, const mint& a) { return (os << a.v); }

mint mfact(int n) { // n! (mod MOD)
  static vector<mint> fact(1, 1);
  int pn = fact.size();
  if (pn < n + 1) {
    fact.resize(n + 1);
    for (int i = pn; i <= n; i++) fact[i] = fact[i - 1] * (mint)i;
  }
  return fact[n];
}
mint mifact(int n) { // n! (mod MOD)
  static vector<mint> ifact(1, 1);
  int pn = ifact.size();
  if (pn < n + 1) {
    ifact.resize(n + 1);
    ifact[n] = mfact(n).inv();
    for (int i = n; i >= pn; --i) ifact[i - 1] = ifact[i] * (mint)i;
  }
  return ifact[n];
}
mint nPk(int n, int k) {
  if (n < 0 || k < 0 || n < k) return 0;
  if (k == 0) return 1;
  return mfact(n) * mfact(n - k).inv();
}
mint nCk(int n, int k) {
  if (n < 0 || k < 0 || n < k) return 0;
  if (k == 0) return 1;
  // return mfact(n) * mfact(k).inv() * mfact(n - k).inv();
  return mfact(n) * mifact(k) * mifact(n - k);
}

void solve() {
  int n, k;
  cin >> n >> k;
  k = min(k, n - 1);
  mint ans = 0;
  for (int i = 0; i <= k; i++) {
    ans += nCk(n, i) * nCk(n - i - 1 + i, i);
  }
  cout << ans << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 6372
#include <bits/stdc++.h>
 
#define int long long
 
// loop
#define FOR(i, a, b) for (int i = (a); i < (b); i++) 	// a ~ b-1	(ascending)
#define REP(i, n) FOR(i, 0, n)							// 0 ~ n-1
#define NREP(i, n) FOR(i, 1, n + 1)						// 1 ~ n
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)	// a ~ b	(descending)
#define RREP(i, n) RFOR(i, n, 0)						// n ~ 0
#define RNREP(i, n) RFOR(i, n, 1)						// n ~ 1
 
// container operation
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define ASORT(c) std::sort((c).begin(), (c).end())
#define DSORT(c) std::sort((c).begin(), (c).end(), std::greater<typeof((c).front())>())
#define SIZE(x) ((int)(x).size())
 
// debug
#define check(x) std::cout << #x << " = " << x << '\n'
 
// print
#define cout(x) std::cout << x << '\n'
 
// typedef
typedef std::vector<int> VI;
typedef std::vector<VI> VII;
typedef std::vector<std::string> VS;

std::string yes = "Yes\n";
std::string no = "No\n";

void solve();

signed main() {
  solve();
  return 0;
}

void solve() {
  int a, b, c;
  std::cin >> a >> b >> c;
  cout(std::min(c, b / a));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,M; cin>>N>>M;
  vector<int>s(M);
  vector<int>c(M);
  vector<vector<bool>>A(N,vector<bool>(10,false));
  for(int i=0;i<M;i++){
    cin>>s[i]>>c[i];
    A[s[i]-1][c[i]]=true;
  }
  if(N==1){
    int B=0;
    for(int i=0;i<10;i++)if(A[0][i]==true)B++;
    if(B>1){cout<<-1<<endl;return 0;}
  }
  else{
    for(int i=0;i<N;i++){
      if(i==0){
        if(A[0][0]==true){cout<<-1<<endl;return 0;}
        int B=0;
        for(int j=1;j<10;j++)if(A[i][j]==true)B++;
        if(B>1){cout<<-1<<endl;return 0;}
      }
      else{
        int B=0;
        for(int j=0;j<10;j++)if(A[i][j]==true)B++;
        if(B>1){cout<<-1<<endl;return 0;}
      }
    }
  }
  int answer=0;
  for(int i=0;i<N;i++)for(int j=0;j<10;j++){int d=pow(10,N-i-1);if(A[i][j]==true)answer+=j*d;}
  if(N==1){cout<<answer<<endl;return 0;}
  cout<<(answer<pow(10,N-1)? answer+pow(10,N-1):answer)<<endl;
}

Measured memory_bytes: 3876
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    int n;
    ll a, b;
    cin >> n >> a >> b;
    if (b < a) {
        cout << 0 << endl;
        return 0;
    }
    if (n == 1) {
        if (a == b) {
            cout << 1 << endl;
        }
        else {
            cout << 0 << endl;
        }
        return 0;
    }
    if (n == 2) {
        cout << b - a + 1 << endl;
        return 0;
    }
    cout << (b * (n - 1) + a) - (b + a * (n - 1)) + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
def distance(str1, str2)
  str1, str2 = str1.split(//).unshift(0), str2.split(//).unshift(0)
  arr = Array.new(str1.size){Array.new(str2.size)}
  for i in 0...str2.size
    arr[0][i] = i
  end
  for i in 1...str1.size
    arr[i][0] = i
    for j in 1...str2.size
      if str1[i] == str2[j]
        arr[i][j] = [arr[i - 1][j - 1], arr[i - 1][j] + 1, arr[i][j - 1] + 1].min
      else
        arr[i][j] = [arr[i - 1][j - 1] + 1, arr[i - 1][j] + 1, arr[i][j - 1] + 1].min
      end
    end
  end
  puts arr.last.last
end
def main(input = $stdin)
  distance(input.gets.chomp, input.gets.chomp)
end
main

Measured memory_bytes: 13816
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<int,int>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
int a,b,c;
cin>>a>>b>>c;
int now=0;
for(int i=0;i<10000;i++){
    now+=a;
    if(now%b==c){
        cout<<"YES"<<endl;
        return 0;
    }
    else now%=b;
}
cout<<"NO"<<endl;
}

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

int main() {
  int n,m;	cin >> n >> m;
  
  int h[100005], Mi[100005];
  for (int i=1; i<=n; i++) {
    cin >> h[i];
    Mi[i] = 0;
  }
  
  int a,b,ans=0;
  for (int i=0; i<m; i++) {
    cin >>a>>b;
    Mi[a] = max(Mi[a],h[b]);
    Mi[b] = max(Mi[b],h[a]);
  }
  
  for (int i=1; i<=n; i++) {
    if (h[i] > Mi[i]) { 
     // cout << h[i] << endl;
     // cout << Mi[i] << endl;
      ans++;
    }
  }
  cout << ans << endl;
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repr(i,x,n) for(int i=(x);i<(n);i++)
#define sortn(a) sort((a).begin(),(a).end())
#define sortr(a) sort((a).begin(),(a).end(),greater<int>())
#define MOD 1000000007

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

int main(){
    
    string s;
    cin >> s;

    string ans;
    if(s == "Sunny")ans = "Cloudy";
    else  if(s == "Cloudy")ans = "Rainy";
    else ans ="Sunny";
    cout << ans << endl;
    
    return 0;
}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main
{
  static int[] array1 = new int[2001];

  static int[] array2 = new int[4001];

  final static int BIGIN_NUM = 1000;

  final static int END_NUM = 0;

  public static void main(String[] args) throws NumberFormatException, IOException
  {
    init();
    BufferedReader input = new BufferedReader(new InputStreamReader(System.in));

    while (input.ready())
    {
      int num = Integer.valueOf(input.readLine());

      System.out.println(array2[num]);
    }

  }

  private static int solver(int num)
  {
    int ans = 0;
    int current = 0;

    int start_i = 0;
    if (num > END_NUM)
    {
      start_i = BIGIN_NUM;
    }
    else
    {
      start_i = num;
    }
    for (int i = start_i; i >= END_NUM; i--)
    {
      current = i;
      int start_j = num - i;
      if (start_j > BIGIN_NUM)
      {
        start_j = BIGIN_NUM;
      }
      for (int j = start_j; j >= END_NUM; j--)
      {
        current = i + j;
        int start_k = num - current;
        if (start_k > BIGIN_NUM)
        {
          start_k = BIGIN_NUM;
        }
        for (int k = start_k; k >= END_NUM; k--)
        {
          current = i + j + k;
          int start_l = num - current;
          if (start_l > BIGIN_NUM)
          {
            start_l = BIGIN_NUM;
          }
          for (int l = start_l; l >= END_NUM; l--)
          {
            // ?????????????????????????§°??§???????????????????????§????????????????????§?¨??????????????????£??????????????????
            System.out.println(i + " " + j + " " + k + " " + l);
            current = i + j + k + l;
            if (current == num)
            {
              ans += 1;
              break;
            }
          }
        }
      }
    }
    return ans;
  }

  private static void init()
  {

    for (int i = 0; i <= 1000; i++)
    {
      for (int j = 0; j <= 1000; j++)
      {
        array1[i + j]++;
      }
    }

    array1[0] = 1;

    for (int i = 0; i <= 2000; i++)
    {
      for (int j = 0; j <= 2000; j++)
      {
        array2[i + j] += array1[i] * array1[j];
      }
    }
    array2[0] = 1;
  }
}

Measured memory_bytes: 25060
N = int(input())

list = []

for _ in range(N):
  list.append(input())

if len(set(list)) != len(list):
  print('No')
  exit()
  
w_old = list[0]

for w in list[1:]:
  if w_old[-1] != w[0]:
    print('No')
    exit()
  w_old = w
    
print('Yes')

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

const long long MOD = 998244353;

int main()
{
    ll N, S;
    cin >> N >> S;
    vector<ll> A(N);
    for (ll i = 0; i < N; i++) {
        cin >> A[i];
    }
    vector<vector<ll>> dp(N + 1, vector<ll>(S + 1));

    dp[0][0] = 1;
    for (ll i = 0; i < N; i++) {
        for (ll j = 0; j <= S; j++) {
            dp[i + 1][j] = dp[i][j] * 2 % MOD;
            if (j - A[i] >= 0) {
                dp[i + 1][j] += dp[i][j - A[i]];
                dp[i + 1][j] %= MOD;
            }
        }
    }

    cout << dp[N][S] << endl;
    return 0;
}


Measured memory_bytes: 73660
from functools import reduce

def main():
    # 一文字のみを読み込み
    # s = input().rstrip().split(' ')
    
    # スペース区切りで標準入力を配列として読み込み
    # s = input().rstrip().split(' ')

    # 位置文字ずつ標準入力を配列として読み込み
    # s = list(input().rstrip())
    slist = input().rstrip().split(' ')
    N = int(slist[0])
    K = int(slist[1])
    D = input().rstrip().split(' ')

    for n in range(N,100000):
        # 各桁にDの配列にある数値がいるか
        d_flag = False
        tmp_n = list(str(n))
        # print(tmp_n)
        for tmp_char in tmp_n:
            if (str(tmp_char) in D):
                d_flag = True
                break
        if(d_flag == False):
            print(n)
            break
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 3572
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.second < b.second; }

const int MOD = 1000000007;

//繰り返し二乗
ll RepeatSquaring(ll N, ll P, ll M){
    if(P==0) return 1;
    if(P%2==0){
        ll t = RepeatSquaring(N, P/2, M);
        return t*t % M;
    }
    // return N * RepeatSquaring(N, P-1, M);        // Before
    return N * RepeatSquaring(N, P-1, M) % M;       // After
}

int main() {
    ll n,a,b; cin>>n>>a>>b;
    ll ans=RepeatSquaring(2,n,MOD)-1;
    ll B=1;
    if(b>n/2)b=n-b;
    if(a>n/2)a=n-a;
    rep(i,b){
        // B*=(n-i)/(i+1);                          // Before
        B*=(n-i)*RepeatSquaring(i+1,MOD-2,MOD)%MOD; // After
        B%=MOD;
        if (B==0)break;
    }
    ll A=1;
    rep(i,a){
        // A*=(n-i)/(i+1);                          // Before
        A*=(n-i)*RepeatSquaring(i+1,MOD-2,MOD)%MOD; // After
        A%=MOD;
    }
    debug(A);


    debug(B)
    // cout<<(ans-A-B)%MOD<<endl;                   // Before
    cout<<((ans-A-B)%MOD+MOD)%MOD<<endl;            // After  
}


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

int main() {

  vector<int> A(9);
  for(int i=0;i<9;i++){
    cin >> A.at(i);
  }

  int N;
  cin >> N;

  vector<int> b(N);
  for(int i=0;i<N;i++){
    cin >> b.at(i);
  }

  //一致するセルにtrueを代入
  vector<bool> BingoCell(9,false);
  for(int i=0;i<9;i++){
    for(int j=0;j<N;j++){
      if(A.at(i)==b.at(j)){
        BingoCell.at(i)=true;
        break;
      }
    }
  }

  //横方向
  for(int k=0;k<3;k++){
    int cnt =0;
    for(int i=0;i<3;i++){
      if(BingoCell.at(3*k+i) == false){
        break;
      }
      cnt++;
    }
    if(cnt == 3){
      cout << "Yes" << endl;
      return 0;
    }
  }

  //縦方向
  for(int i=0;i<3;i++){
    int cnt =0;
    for(int k=0;k<3;k++){
      if(BingoCell.at(3*k+i) == false){
        break;
      }
      cnt++;
    }
    if(cnt == 3){
      cout << "Yes" << endl;
      return 0;
    }
  }

  //斜方向
  if(BingoCell.at(0)==true && BingoCell.at(4)==true &&BingoCell.at(8)==true){
    cout << "Yes" << endl;
      return 0;
  }
  if(BingoCell.at(2)==true && BingoCell.at(4)==true &&BingoCell.at(6)==true){
    cout << "Yes" << endl;
      return 0;
  }

  cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define ALL(v) v.begin(), v.end()
#define PRINT(V) for (auto v : (V)) cout << v << " "
const long long INF = 1LL << 60;
using namespace std;
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}
#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

int main() {

int n,k;
cin >> n >> k;
vector <int>x(n);
rep(i, n){
  x[i]=0;
}
 rep(i, k){
  int d;
  cin >> d;
  vector <int> a(d);
  rep(i, d){
    cin >> a[i];
    x[a[i]-1]=1;
  }
 }
  int cnt = 0;
  rep(i, n){
    if(x[i] == 0){
      cnt++;
    }
  }
  cout << cnt;
return 0;
}

Measured memory_bytes: 3604
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>

using namespace std;
using ll = long long;

#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
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;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
/*----------------------------------------------------------------------------------*/

int main() {
    int a, b; cin >> a >> b;
    vector<vector<char>> ans(100, vector<char>(100));
    rep(i,100) rep(j,100) {
        if (i < 50) ans[i][j] = '#';
        else ans[i][j] = '.';
    }

    a--; b--;
    for (int i = 0; i < 50; i+=2) {
        for (int j = 0; j < 100; j+=2) {
            if (a) {
                ans[i][j] = '.';
                a--;
            }
        }
    }
    for (int i = 51; i < 100; i+=2) {
        for (int j = 0; j < 100; j+=2) {
            if (b) {
                ans[i][j] = '#';
                b--;
            }
        }
    }

    printf("100 100\n");
    rep(i,100) {
        rep(j,100) {
            printf("%c", ans[i][j]);
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 256