akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> d(n);
  for(int i = 0; i < n; i++) cin >> d[i];
  
  set<int> quantity;
  for(int i = 0; i < n; i++){
    quantity.insert(d[i]);
  }
  cout << quantity.size() << endl;
  return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll mod=1000000007;
 
ll powmod(ll x, ll y){
    ll res = 1;
    for(ll i = 0; i < y; i++){
        res = res * x % mod;
    }
    return res;
}
int main(){
    ll n;
    cin >> n;
    ll ans = powmod(10,n) - powmod(9,n) - powmod(9,n) + powmod(8,n);
    ans %= mod;
    ans = (ans + mod) % mod;
    cout << ans << endl;
}

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

using namespace std;

int main()
{
  int r,g,b,k;
  cin>>r>>g>>b;
  cin>>k;
    while(g<=r && k>0)
    {
      g*=2;
      k--;
    }
    while(b<=g && k>0)
    {
      b*=2;
      k--;
    }
  if(r<g && g<b)
    cout<<"Yes";
  else 
    cout<<"No";
  return 0;
}

Measured memory_bytes: 3632
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;

#define rep(i,N) for(int i=0;i<(int)N;++i)

ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}


#include <iostream>

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

    int B = N % 500;

    if (B <= A) { cout << "Yes" << endl; }
    else { cout << "No" << endl; }

}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
#include<map>
using namespace std;
int main() {
    int n,cnt=0; 
    string s;
    cin >> n >> s;
    for(int i=0;i<n-2;i++){
        if(s.substr(i,3) == "ABC") cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;


int main(){
 ll t;
 for(ll i=0;i<5;i++){
  cin>>t;
  if(t==0)cout<<i+1<<endl;
 }
    return 0;
}


Measured memory_bytes: 3636
abcd = list(str(input()))
for k in range(4):
    abcd[k] = int(abcd[k])
#print(abcd)

for i in range(1 << 3):
    info = [abcd[0]]
    for j in range(3):
        if (i >> j) & 1:
            info.append(-1*(abcd[j + 1]))
        else:
            info.append((abcd[j + 1]))
    if sum(info) == 7:
        p = str(abcd[0])
        for m in range(1, 4):
            if info[m] >= 0:
                p += ("+"+str(info[m]))
            else:
                p += (str(info[m]))
        print(p+"=7")
        exit()

Measured memory_bytes: 3064
N = int(input())
D, X = [int(i) for i in input().split()]
A = [int(input()) for i in range(N)]

choco = 0

for i in range(N):
    cnt = 0
    a = 0
    while a * A[i] + 1 <= D:
        cnt = cnt + 1
        a = a + 1
    choco = choco + cnt
print(choco + X)

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

vector<pair<ll,ll>> prime_factor(ll n){
    vector<pair<ll,ll>> p;
    for(ll i=2;i*i<=n;i++){
        if(n % i != 0) {
            //cout << i << endl;
            continue;
        }

        ll ex=0;
        while(n % i == 0){
            ex++;
            n /= i;
        }
        p.push_back(make_pair(i,ex));
    }

    if(n != 1){
        p.push_back(make_pair(n,1));
    }

    return p;
}

ll pow(ll a, ll x){
  	ll tmp=1;
  	while(x>0){
    	if(x%2 == 1){
          	tmp = (a*tmp);
        }
      	a = (a*a);
      	x /= 2;
    }
  	return(tmp);
}

int main(){
    ll n,prime;
    cin >> n >> prime;
    const auto &factor = prime_factor(prime);
  	ll res=1;
    for(auto p : factor){
        if(p.second != 0){
          	ll index = p.second/n;
          	res *= pow(p.first, index);
            //cout << p.first << " " << p.second << endl;
        }
    }
  	
  	cout << res << endl;

    return(0);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <numeric>
#include <list> 
#include <cmath>
#include <stdio.h>

using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(),x.end()
#define INF (1e9)

typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> P;

#define CAPITAL
void Yes(bool ex=true){
	#ifdef CAPITAL
	cout<<"YES"<<endl;
	#else
	cout<<"Yes"<<endl;
	#endif
	if(ex)exit(0);
}
void No(bool ex=true){
	#ifdef CAPITAL
	cout<<"NO"<<endl;
	#else
	cout<<"No"<<endl;
	#endif
	if(ex)exit(0);
}

int main() {
    ll N, P;
    cin >> N >> P;
    ll ans = 1;
    ll i = 2;
    if (N == 1) {
        printf("%lld", P);
        return 0;
    }
    while (true) {
        if (pow(i, N) > P) {
            break;
        }
        if (P % ll(pow(i, N)) == 0) {
            ans = i;
        }
        i++;
    }
    printf("%lld", ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
                    
                    
using ll = long long;
using ull = unsigned long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const ll mod = 1e9+7;
void chmod(ll &M){
  if(M >= mod) M %= mod;
  else if(M < 0){
     M += (abs(M)/mod + 1)*mod;
    M %= mod;
}
}
ll modpow(ll x, ll n){
   if(n==0) return 1;
  ll res=modpow(x, n/2);
 if(n%2==0) return res*res%mod;
else return res*res%mod*x%mod;
}
int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };
long long GCD(long long a, long long b) {
  if (b == 0) return a;
  else return GCD(b, a % b);
}

using namespace std;
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
int main() 
{
    double  D, T, S;
    cin >> D >> T >> S; 
    if (T >= D/S) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3684
#include "iostream"
#include "algorithm"
#include "cstring"
#include "cstdio"
using namespace std;
#define MAXN 21
int n , k , dp[1 << 21][21];
char ch[1 << 21];
int main() {
    cin >> n >> k;
    for( int i = 0 ; i <= n ; ++ i ) {
        scanf("%s",ch);
        for( int j = 0 ; j < ( 1 << i ) ; ++ j )
            dp[( 1 << i ) | j][i] = ( ch[j] == '1' );
    }
    int re1 = 0 , re2 = 0;
    for( int i = n ; i >= 0 ; -- i ) {
        for( int j = 0 ; j < ( 1 << i ) ; ++ j ) // sta : ( 1 << i ) | j
            for( int k = i ; k > 0 ; -- k ) if( dp[( 1 << i ) | j][k] ) {
                int S = ( j >> k ) , T = ( j & ( 1 << k ) - 1 ) , f = dp[( 1 << i ) | j][k];
                dp[( 1 << i - k ) | S][0] += f;
                int ls = T & ( 1 << k ) - 1 , re = (~T) & ( 1 << k ) - 1;
                if( T ) {
                    int u = 31 - __builtin_clz( ls );
//                    cout << ls << ' ' << u << endl;
                    dp[( 1 << i - k + u + 1 ) | ( S << u + 1 ) | ( 1 << u ) | ( T & ( 1 << u ) - 1 )][u] += f;
                }
                if( re ) {
                    int u = 31 - __builtin_clz( re );
//                    cout << T << ' ' << u << ' ' << k << endl;
                    dp[( 1 << i - k + u + 1 ) | ( S << u + 1 ) | ( T & ( 1 << u ) - 1)][u] += f;
                }
            }
    }
    for( int i = n ; i >= 0 ; -- i )
        for( int j = 0 ; j < ( 1 << i ) ; ++ j ) if( dp[( 1 << i ) | j][0] >= k ) {
            for( int k = i - 1 ; k >= 0 ; -- k ) printf("%d",( j >> k ) & 1);
            return 0;
        }
}

Measured memory_bytes: 173440
#include <iostream>
#include <numeric>
#include <cstdio>

using namespace std;

#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)

int dp[1001][8] = {};
int must[1001], f[256];

int main(){
    int n;cin>>n;
    f['J']=0;
    f['O']=1;
    f['I']=2;
    getchar();
    rep(i,n)must[i]=f[getchar()];
    rep(c,8)if(c>>0&1 && c>>must[0]&1) dp[0][c]=1;
    rep(i,n-1){
        rep(tdy,8)rep(tmr,8){
            if(tmr>>must[i+1]&1 && tmr&tdy){
                dp[i+1][tmr]+=dp[i][tdy];
            }
            dp[i+1][tmr]%=10007;
        }
    }
    cout<<accumulate(dp[n-1],dp[n-1]+8,0)%10007
        <<endl;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

string T;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>T;
	FORR(c,T) if(c=='?') c='D';
	cout<<T<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 3776
#include <cstdio>

int main()
{
	int d, t = 1, n;
	scanf("%d%d", &d, &n);
	while (d--) t *= 100;
	for (int i = 1; i <= n; ++i)
		if (i % 100 == 0) ++n;
	printf("%d", t*n);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n-1); i >= 0; i--)
#define all(v) (v).begin(),(v).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a/gcd(a,b)*b; }
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;


int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, k;
	cin >> n >> k;
    vector<int> p(n), c(n);
    rep(i,n) {
        cin >> p[i]; 
        p[i]--;
    }
    rep(i,n) cin >> c[i];

    ll ans = -LINF;
    rep(si,n) {
        vector<int> dists;
        int now = si;
        ll cycle = 0;
        while (true) {
            now = p[now];
            dists.push_back(c[now]);
            cycle += c[now];
            if (now == si) break;
        }
        int sz = dists.size();
        ll tot = 0;
        rep(i,sz) {
            tot += dists[i];
            if(i+1>k) break;
            ll total = tot; 
            if(cycle>0)  total += ((k-(i+1))/sz)*cycle;
            ans = max(ans, total);
        }
    }
    cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 3672
import math
import string


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//math.factorial(n-r)*math.factorial(r)


n, m, c = map(int, input().split())
b = list(map(int, input().split()))
a = [list(map(int, input().split())) for i in range(n)]
# print(a)
cnt = 0
for i in range(n):
    x = c
    for j in range(m):
        x += a[i][j]*b[j]
    if x > 0:
        cnt += 1
print(cnt)


Measured memory_bytes: 3828
#include<cstdio>
#include<cstdlib>
#define MAX 100

int S[MAX];
int top;

void initialize(){
	top = 0;
}

bool isEmpty(){
	return top == 0;
}

bool isFull(){
	return top >= MAX - 1;
}

void push(int x){
	top++;
	S[top] = x;
}

int pop(){
	top--;
	return S[top+1];
}

int main(void){
	int op1, op2;
	char input[10];
	initialize();
	while(scanf("%s", input) != EOF){
		if(input[0] == '+'){
			op2 = pop();
			op1 = pop();
			push(op1 + op2);
		}
		else if(input[0] == '-'){
			op2 = pop();
			op1 = pop();
			push(op1 - op2);
		}
		else if(input[0] == '*'){
			op2 = pop();
			op1 = pop();
			push(op1 * op2);
		}
		else{
			push(atoi(input));
		}
	}

	printf("%d\n", pop());
	return 0;
}

Measured memory_bytes: 2712
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h> 
using namespace std;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define INF 1e18L+5
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
typedef vector<int> vi;
typedef pair<int,int>ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef long long ll;
typedef vector<long long > vl;
template<typename T>
void show(vector<T> v){
    bool ok=true;
for(auto it:v){

    
   cout<<it<<" ";
    //cout<<it;
}
cout<<"\n";
}
const int N=101;
int A[N],B[N];
 int main() { ios_base::sync_with_stdio(false); cin.tie(0);
 int n;cin>>n;
 rep(i,0,n)cin>>A[i]>>B[i];bool ok=false;
 for(int i=0;i<n;i++){
     if(A[i]==B[i]){
         int compt=1;
         rep(j,1,3){
             if(i+j>=n)continue;
             if(A[i+j]==B[i+j])++compt;
         }
         if(compt==3){
             cout<<"Yes";
             return 0;
         }
     }
 }
 puts("No");
return 0;
}

Measured memory_bytes: 3656
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main() {
	bool ans = false;
	vector<char> vec;
	for (int i = 0; i < 3; i++) {
		char c;
		cin >> c;
		vec.push_back(c);
	}
	for (int i = 1; i < 3; i++) {
		if (vec.at(i) != vec.at(i - 1)) {
			ans = true;
		}
	}
	if (ans) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int n,a,b,min=1000000000000000;
  cin>>n;
  for(int i=1;i<=sqrt(n);i++)
  {
   	if(n%i==0)
    {
     	a=n/i;
      	b=n/a;
      	if(min>a+b)
        {
         	min=a+b; 
        }
          
    }
  }
  
  cout<<min-2<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()

bool check(VL &x1, VL &x2) {
    ll n=x1.size();
    ll s = 0;
    rep(i,0,n) s += (x1[i]-x2[i]) * (x1[i]-x2[i]);
    ll sq = (ll)sqrt(s);
    return (sq*sq) == s;
}

int main() {
	ll N; cin>>N;
    ll D; cin>>D;
    VVL X(N,VL(D,0));
	rep(i,0,N) rep(j,0,D) cin>>X[i][j];
    ll ans = 0;
    rep(i,0,N) rep(j,i+1,N) {
    ans += (ll)check(X[i], X[j]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
def main():
    s = [-1 if c == '?' else int(c) for c in list(input())]
    MOD = 10 ** 9 + 7
    n = len(s)
    dp = [[0] * 13 for _ in range(n)]

    if s[n-1] == -1:
        for j in range(10):
            dp[0][j] = 1
    else:
        dp[0][s[n-1]] = 1
    i10 = 1
    for i in range(1, n):
        i10 = (10 * i10) % 13
        c = s[n-i-1]
        for k in range(13):
            if c == -1:
                for j in range(10):
                    m = (i10 * j + k) % 13
                    dp[i][m] += dp[i-1][k]
                    dp[i][m] %= MOD
            else:
                m = (i10 * c + k) % 13
                dp[i][m] += dp[i-1][k]
                dp[i][m] %= MOD
    print(dp[n-1][5])


main()


Measured memory_bytes: 68216
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll n,k;
    cin>>n>>k;
    ll x1=n%k;
    n=n%k;
    ll x2=abs(n-k);
    //cout<<x1<<" "<<x2<<endl;
    ll mn=min(x1,x2);
    cout<<mn<<endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Double.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static final int MOD = 1000000007;
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		double a = parseDouble(sc.next());
		double b = parseDouble(sc.next());
		double h = parseDouble(sc.next());
		double m = parseDouble(sc.next());
		sc.close();
		double dx = cos(PI*(h/6+m/360)) * a - cos(PI*m/30) * b;
		double dy = sin(PI*(h/6+m/360)) * a - sin(PI*m/30) * b;
		double ans=sqrt(dx*dx+dy*dy);
		out.println(ans);
	}
}


Measured memory_bytes: 26932
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<ll>;
using vvi = vector<vector< ll > >;
using st = set<ll>;
using kiwi = queue<ll>;
using mp = map<ll,ll>;
using ump = unordered_map<ll,ll>;
#define MOD 1000000007
const ll mx = 1e5+123;
#define REP(i,n) for (ll i=1;i<=n;++i)

#define fastio  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int main(){
    fastio;
    ///freopen("input.txt","r",stdin);
    ///freopen("output.txt","w",stdout);
    ll tc; cin>>tc;
    ll ac=0, wa=0, tle=0,re=0;
    while(tc--){
        string str;
        cin>>str;
        if(str=="AC") ac++;
        else if(str=="WA") wa++;
        else if(str=="TLE") tle++;
        else re++;
    }
    cout<<"AC x "<<ac<<endl;    cout<<"WA x "<<wa<<endl;    cout<<"TLE x "<<tle<<endl;    cout<<"RE x "<<re<<endl;
return 0;
}


Measured memory_bytes: 3656
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}
#define trace1(x)                  cout <<#x<<": "<<x<<endl
#define trace2(x, y)               cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)            cout <<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)         cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)      cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f)   cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}


int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s,t;
    cin >> s >> t;
    ll n=s.size(),m=t.size();
    ll dp[n+1][m+1]={0};
    string ans;
    set<pair<ll,ll>> z;
    for(ll i=0; i<=n; i++){
        for(ll j=0; j<=m; j++){
            if(i==0 || j==0) dp[i][j]=0;
            else{
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
                if(s[i-1]==t[j-1]) dp[i][j]=max(dp[i][j],dp[i-1][j-1]+1);
            }
        }
    }

    //trace1(dp[n][m]);
    ll spos=n,tpos=m;
    while(spos>=1 && tpos>=1){
        if(s[spos-1]==t[tpos-1] && dp[spos][tpos]==dp[spos-1][tpos-1]+1){
			//trace1(1);
            ans+=s[spos-1];
            --spos;--tpos;
        }
        else if(dp[spos][tpos]==dp[spos-1][tpos]){
            --spos;
        }
        else{
            --tpos;
        }
    }
    reverse(all(ans));
    cout << ans;
    return 0;
}


Measured memory_bytes: 70656
import math
import numpy as np
 
def f(x,y,z):
  return x**2+y**2+z**2+x*y+y*z+z*x
 
N = int(input())
f_list = np.zeros((N,1), dtype=int)
 
for x in range(1,math.floor((N//6)**0.5)+1):
  for z in range(1,math.floor(N**0.5)+1):
    for y in range(x,z+1):
      if f(x,y,z)<=N:
        if((x-y)*(y-z)*(z-x)==0): # 少なくとも2つが等しい
          if(x==y and y==z):
            f_list[f(x,y,z)-1] = f_list[f(x,y,z)-1] + 1
          else:
            f_list[f(x,y,z)-1] = f_list[f(x,y,z)-1] + 3
        else:
          f_list[f(x,y,z)-1] = f_list[f(x,y,z)-1] + 6
 
for i in range(N):
  print(f_list[i][0])

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

class Main{
    public static void main(String[] args)throws IOException{
      try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))){
        String input = br.readLine();
        boolean flag = false;

        if(input.isEmpty()){
          flag = true;
        }

        if(input.contains("hi")){
          input = input.replace("hi", "");
        }

        if(input.isEmpty()){
          if(flag){
            System.out.println("No");
          }else{
            System.out.println("Yes");
          }
          
        }else{
          System.out.println("No");
        }

        }
      }
}

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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n, 0)
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const int mod = 1e9+7;
const ll INF = 1e18;
const int inf = 1e9;

void solve()
{
  int a,b; cin>>a>>b;
  if (a%3==0||b%3==0||(a+b)%3==0) cout << "Possible" << endl;
  else cout << "Impossible" << endl;
}

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


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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;

int dx4[] = {0, 1, 0, -1}, dy4[] = {1, 0, -1, 0};

// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, m, x, y, q, k;
string s, t;

// <------------- Implement Functions Here ----------> //

vll cnt(12,0);

// <------------- Start of main() -------------------> //

void MAIN() {
	cin>>n>>k;
	vll a(n);
	ll ans = 0;
	for(ll i=0;i<n;i++) {
		cin>>x;
		ans += 2*min(x, (k-x));
	}
	cout<<ans;
}

int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}


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

#define Fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO freopen("in.txt", "r", stdin)
#define FC freopen("out.txt", "w", stdout)
#define aise cout<<"aise"<<endl
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define ll long long
#define all(x) x.begin(), x.end()
#define mset(v, a) memset(v, a, sizeof(v))
#define pll pair< ll, ll >
#define pdd pair< double, double >
#define ff first
#define ss second
#define pi acos(-1.0)
#define mxN 2010
#define inf 1e14
#define MOD 1000000007

int main()
{

    ll x, s = 0;
    cin >> x;
    ll n = x;
    while(1)
    {

        if(x==0) break;
        s+=(x%10);
        x/=10;
    }
    if(n%s) cout << "No";
    else cout << "Yes";
}


Measured memory_bytes: 256
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<cstring>
#include<iomanip>
using namespace std;
typedef long long lng;
typedef unsigned long long ulng;

#define pb push_back
#define SZ(a) int((a).size())
#define ALL(a) (a).begin(), (a).end()
#define FOR(i,a,b) for(int i=(a); i<=(b); ++i)
#define FORD(i,b,a) for(int i=(b); i>=(a); --i)
#define REP(i,n) FOR(i,0,n-1)
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end()) // <a> must be sorted in advance

lng power(lng b, lng e) {lng sol=1; while(e>0) {if(e&1) {sol=sol*b;} e>>=1; b*= b;} return sol;}


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

    string n;
    cin >> n;
    if(n[0]=='9' || n[1]=='9') cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

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

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

    ll S,W; cin >> S >> W;

    if(W >= S) cout << "unsafe" << endl;
    else cout << "safe" << endl; 

    return 0;

}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}

bool end(v(bool) &visited) {
  bool ok = true;
  rep(i,sz(visited)){
    if(!visited[i]) {
      ok = false;
    }
  }
  return ok;
}

int dfs(vvi &G,v(bool) &visited,int p) {
  if(end(visited)) {
    return 1;
  }
  int cnt = 0;
  rep(i,sz(G[p])) {
    int k = G[p][i];
    if(!visited[k]) {
      visited[k] = true;
      cnt += dfs(G,visited,k);
      visited[k] = false;
    }
  }
  return cnt;
}
  
int main() {
  int N,M;
  cin >> N >> M;
  vvi G(N);
  rep(i,M) {
    int a,b;
    cin >> a >> b;
    a--;
    b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  v(bool) visited(N,false);
  visited[0] = true;
  cout << dfs(G,visited,0) <<endl;
  return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.xise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
//#define int long long

//cerrはコメントアウトしなくても通る//ただしTLEを引き起こすことがある

ll a[2005];

int main(){
    ll n,z,w;
    cin >> n>>z>>w;
    rep(i,n){
        cin >> a[i];
    }
    cerr<<abs(a[n-1]-w)<<' '<<abs(a[n-2]-a[n-1]);
    ll ans=max(abs(a[n-1]-w),abs(a[n-2]-a[n-1]));
    if(n==1){
        ans=abs(a[0]-w);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>

#define P 1000000007

int comp(const void *a, const void *b){return *(int*)a-*(int*)b;}

int main(void){
	int n, i;
	char s[101];
	scanf("%d%s", &n, s);
	int a=0, b=0, c=0;
	for(i=0; i<n; i++){
		if(s[i]=='('){
			a++;
		}else{
			b++;
			if(a<b){c++; a++;}
		}
	}
	while(c--) putchar('(');
	fputs(s, stdout);
	c=a-b;
	while(c--) putchar(')');
	putchar(10);
}


Measured memory_bytes: 128
//shahil_005
//Some basic pre-written functions might have been copied from www.geeksforgeeks.org or cp-algorithms.com//

#include <bits/stdc++.h>

using namespace std;

#define endl '\n'
#define int long long
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

const int N = 1e5 + 5;
//const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

int32_t main()
{
    string s;
    cin >> s;
    sort(s.begin(),s.end());
    if(s[0] != s[2]){
        cout << "Yes";
    }
    else
        cout << "No";
        
    return 0;
}



Measured memory_bytes: 256
var i,j,k : longint ;
     cc : array ['0'..'9'] of longint ;
     so : ansistring ;
   g: char ;
begin
 readln(so);
for i:=2 to 3 do
 if so[i]=so[i-1] then
 k:=k+1;
for i:=3 to 4 do
 if so[i]=so[i-1] then
 inc(j);
if (k=2)or(j=2) then
 writeln('Yes')
else
 writeln('No');


end.

Measured memory_bytes: 128
using System;

    class Program
    {
        static void Main()
        {
            string line;
            int[] num = new int[26];
            while (true)
            {
                if ((line = Console.ReadLine()) == null)
                    break;

                char[] charArray = line.ToLower().ToCharArray();
                foreach (char chara in charArray)
                {
                    if (char.IsLower(chara))
                        num[chara - 'a']++;
                }
            }

            for (int i = 0; i < num.Length; i++)
            {
                Console.WriteLine(((char)('a' + i)).ToString() + " : " + num[i].ToString());
            }
        }
    }

Measured memory_bytes: 19896
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <queue>
#include <utility>

using namespace std;

int main(void){
    int N, tmp;
    scanf("%d", &N);
    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> A;
    for(int i = 0; i < N; i++){
        scanf("%d", &tmp);
        A.push(make_pair(tmp, i+1));
    }
    while(!A.empty()){
        pair<int, int> p = A.top();
        cout << p.second;
        A.pop();
        if(!A.empty()){
            cout << " ";
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1780
#include <iostream>
#include <vector>
#include <cmath>
#include <sstream>
#include <cstring>
#include <fstream>
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

const int MAX_N = 12+1;
const double INF = 1e+100;
double dist[10+1][10+1]; // åå¾ a ã®ã±ã¼ã­ã®ä¸­å¿ã¨åå¾ b ã®ã±ã¼ã­ã®ä¸­å¿ã¨ã®è·é¢ã
double d[MAX_N][MAX_N];
double dp[1<<MAX_N][MAX_N];
int n, w;
int a[MAX_N];

// ã±ã¼ã­éã®è·é¢ãæ±ãã
int calc (void )
{
	for (int i = 3; i <= 10; i++ )
		for (int j = 3; j <= 10; j++ )
			dist[i][j] = 2.0*sqrt ((double)i*j );
}

// çµè·¯ã®æ¥ç¶ãæ±ãã
void make (void )
{
	// åæå
	rep (i, n+1 )
		rep (j, n+1 )
				d[i][j] = INF;

	rep (i, n )
		rep (j, n )
			d[i][j] = dist[a[i]][a[j]];

	rep (i, n ){
		d[n][i] = a[i]; d[i][n] = a[i];
	} // end rep
	n++;
}

// bitDP
double solve (){

	// åæå
	rep (S, 1<<n ){
		fill (dp[S], dp[S]+n, INF );
	} // end rep

	dp[(1<<n)-1][0] = 0;
	for (int S = (1 << n ) - 2; S >= 0; S-- )
		rep (v, n ) rep (u, n )
			if (!(S >> u & 1 ) )
				dp[S][v] = min (dp[S][v], dp[S | 1 << u][u] + d[v][u] );

	return dp[0][0];
}

int main()
{
	calc ();
	string str = "";

	while (getline (cin, str ) ){
		vector <int> cake; 
		stringstream ss (str );
		ss >> w;
		int i = 0, m;
		while (ss >> m ){
			 a[i++] = m;
		} // end while
		n = i;
		make ();
		if ((double)w >= solve () ){
			printf ( "OK\n" );
		}else{
			printf ( "NA\n" );
		} // end if
	} // end loop
		
	return 0;
}

Measured memory_bytes: 0
import java.util.*;
import java.io.*;
 
class Main{
    public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String s;
        int num = 0;
        while((s=br.readLine())!=null){
            String[] str = s.split(" ");
            if(Integer.parseInt(str[0])<0 || Integer.parseInt(str[0])>1000000 ||
               Integer.parseInt(str[1])<0 || Integer.parseInt(str[1])>1000000){
                
                    continue;
            }
            num = Integer.parseInt(str[0]) + Integer.parseInt(str[1]);
            //System.out.println(str[0]+"\t"+str[1] + "\t"+num);
            int a = String.valueOf(num).length();
            System.out.println(a);
        }
         
         
    }
}

Measured memory_bytes: 15164
#include <stdio.h>
#include <stdlib.h>
int compare(const void *a,const void *b){
    return *(int*)a-*(int*)b;
}
int main()
{   int n,c,k;
    scanf("%d%d%d",&n,&c,&k);
    int t[n];
    for(int i=0;i<n;i++){
        scanf("%d",&t[i]);
    }
    qsort(t,n,sizeof(int),compare);
    //printf("sorted\n");
    int ans=0,flag=0,first,cnt=0;
    for(int i=0;i<n;i++){
        if(flag==0){
            first=i;
            flag++;
            //printf("first=%d\n",first);
        }
        if((cnt+1)<=c&&t[i]-t[first]<=k){
            cnt++;
            //printf("cnt=%d\n",cnt);
        }else{
            //printf("last=%d\n",i-1);
            ans++;
            first=i;
            cnt=1;
        }
    }
    if(cnt!=0){ans++;
    //printf("added\n");
    }
    printf("%d",ans);
    
    return 0;
}


Measured memory_bytes: 892
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 1000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
using namespace std;

int n,m,ans;

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


Measured memory_bytes: 256
A,B = map(int,input().split())
ans = 0
  
if A>B:
	ans += A
	A -= 1
else:
  ans += B
  B -= 1
  
if A>B:
	ans += A
	A -= 1
else:
  ans += B
  B -= 1
  
print(ans)
 

Measured memory_bytes: 2940
# Bはすべて右に詰まるので各Bの右からの距離の総和
# （逆でもいい Wの左）
s = input()
n = len(s)
w = 0
pack_w = 0
for i in range(n):
    if s[i] == "W":
        w += i - pack_w
        pack_w += 1

print(w)


Measured memory_bytes: 3500
def solve():
    from sys import stdin
    f_i = stdin
    
    H, N = map(int, f_i.readline().split())
    
    dp = [10 ** 8] * (H + 10 ** 4)
    dp[0] = 0
    
    for i in range(N):
        A, B = map(int, f_i.readline().split())
        for j, t in enumerate(zip(dp, dp[A:H+A]), start=A):
            dp_i, dp_j = t
            if dp_i + B < dp_j:
                dp[j] = dp_i + B
    
    print(min(dp[H:]))

solve()

Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

int main(){
    int D; cin >> D;
    vector<int> c(27);
    for (int i = 1; i < 27; i++) {
        cin >> c[i];
    }

    vector<vector<int>> s(D+1, vector<int> (27));
    for (int i = 1; i < D+1; i++) {
        for (int j = 1; j < 27; j++) {
            cin >> s[i][j];
        }
    }

    vector<int> t(D+1);

    ll score = 0;
    vector<int> last(27, 0);
    int M;
    int MJ;
    for (int i = 1; i < D+1; i++) {
        M = 0;
        for (int j = 1; j < 27; j++) {
            if(s[i][j] + c[j] * (i-last[j]) > M){
                M = s[i][j] + c[j] * (i-last[j]);    
                MJ = j;
            }
        }
        t[i] = MJ;
        score += s[i][MJ];
        last[MJ] = i;
        for (int j = 1; j < 27; j++) {
            score -= c[j] * (i - last[j]);
        }
    }
    
    //ここまでが貪欲解の導出
    //ここから微調整

    // そのコンテストが開催された日の集合
    vector<set<int>> day(27, set<int> ());
    for (int i = 1; i < D+1; i++) {
        day[t[i]].insert(i);
    }
    for (int i = 1; i < 27; i++) {
        day[i].insert(0);
        day[i].insert(D+1);
    }

    //更新作業
    //i回目の更新では、i%D日目の開催をt[i%D]+7i%26に変更し、差分が正だったら更新
    int CNT = 4000000;
    int dd, qq;
    int tq;
    int d1, d2;
    auto itr1 = day[1].lower_bound(0);
    dd = 1; tq = 1;
    ll diff;
    for (int i = 0; i < CNT; i++) {
        diff = 0;
        
        day[t[dd]].erase(dd);

        qq = (t[dd] + tq) % 26;
        if(qq == 0) qq = 26;

        diff += s[dd][qq];
        diff -= s[dd][t[dd]];
        
        itr1 = day[qq].lower_bound(dd);
        d2 = *itr1;
        itr1--;
        d1 = *itr1;
        diff += c[qq] * (dd - d1) * (d2 - dd);

        itr1 = day[t[dd]].lower_bound(dd);
        d2 = *itr1;
        itr1--;
        d1 = *itr1;
        diff -= c[t[dd]] * (dd - d1) * (d2 - dd);

        //差分が正なら更新
        if(diff > 0){
            // tとsetを更新
            t[dd] = qq;
            day[qq].insert(dd);
        }
        else{
            day[t[dd]].insert(dd);
        }

        //ddとqqを更新
        dd++; tq = tq * 7;
        if(dd == D+1) dd = 1;
        if(tq >= 27) tq = tq % 26;

    }
    for (int i = 1; i < D+1; i++) {
        printf("%d\n", t[i]);
    }

}

Measured memory_bytes: 3732
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    N, M = map(int, readline().split())
    res = [0] * (N + 1)

    for _ in range(M):
        a, b = map(int, readline().split())
        res[a] += 1
        res[b] += 1

    for i in range(1, N + 1):
        print(res[i])


if __name__ == '__main__':
    main()


Measured memory_bytes: 62156
[<AutoOpen>]
module Program

open System

let read f = stdin.ReadLine() |> f
let reada f = stdin.ReadLine().Split() |> Array.map f
let reads f = stdin.ReadLine().Split() |> Array.toList |> List.map f

let inline gcd x y =
    let zero = LanguagePrimitives.GenericZero
    let rec loop x y = if y = zero then x else loop y (x % y)
    loop (abs x) (abs y)

[<EntryPoint>]
let main _ =
    let N = read int64
    let n = min N 1000000L
    let bs =
        [1L..n]
        |> List.map (fun x -> (x, N / x, N % x))
    let (c, d, _) =
        bs
        |> List.filter (fun (_, _, x) -> x = 0L)
        |> List.minBy (fun (x, y, _) -> abs (x - y))
    // eprintfn "*%A" (c, d)
    printfn "%i" (c - 1L + d - 1L)
    0

Measured memory_bytes: 123892
#include <cstdint>
#include <functional>
#include <iostream>
#include <limits>
#include <vector>

using namespace std;

int main()
{
    int n;
    vector<int> v;

    cin >> n;
    for (int i = 0; i < n; ++i) {
        int s;
        cin >> s;
        v.push_back(s);
    }

    auto merge = [&v](int left, int mid, int right) {
        uint64_t count = 0;
        int n1 = mid - left;
        int n2 = right - mid;
        vector<int> l(n1 + 1);
        vector<int> r(n2 + 1);
        for (int i = 0; i < n1; ++i) {
            l[i] = v[left + i];
        }
        for (int i = 0; i < n2; ++i) {
            r[i] = v[mid + i];
        }
        l[n1] = numeric_limits<int>::max();
        r[n2] = numeric_limits<int>::max();

        int i = 0;
        int j = 0;
        for (int k = left; k < right; ++k) {
            if (l[i] <= r[j]) {
                v[k] = l[i];
                i += 1;
            }
            else {
                v[k] = r[j];
                j += 1;
                count += n1 - i;
            }
        }
        return count;
    };

    function<uint64_t(int, int)> mergeSort = [&merge, &mergeSort](int left,
                                                                  int right) {
        uint64_t count = 0;
        if (left + 1 < right) {
            int mid = (left + right) / 2;
            count += mergeSort(left, mid);
            count += mergeSort(mid, right);
            count += merge(left, mid, right);
        }
        return count;
    };

    auto r = mergeSort(0, n);
    cout << r << endl;
}


Measured memory_bytes: 4376
#include <bits/stdc++.h>
using namespace std;
#define mod 2019
int main() {
  string s; 
  cin >> s;
  int n = s.length();
  int suf = 0;
  int power_of_ten = 1;
  unordered_map<int, int> mp;
  mp[0] = 1;
  int ans = 0;
  for(int i=n-1; i>=0; i--) {
    int digit = s[i] - '0';
    suf = (suf + digit*power_of_ten)%mod;
    power_of_ten = (10*power_of_ten)%mod;
    ans += mp[suf];
    mp[suf]++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3708
q = int(input())
l, r = [0] * q, [0] * q
for i in range(q):
    l[i], r[i] = map(int, input().split())
 
mini = min(min(l), min(r))
maxi = max(max(l), max(r))
ans = [0] * (maxi + 1)
prime = [0] * (maxi + 1)
def judge_prime(n):
    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            return False
    
    return True if n != 1 else False
 
for i in range((mini + 1) // 2, maxi + 1):
    prime[i] = judge_prime(i)
 
for i in range(mini, maxi + 1, 2):
    ans[i] = ans[i - 2] + 1 if prime[i] and prime[(i + 1) // 2] else ans[i - 2]
for i in range(q):
    print(ans[r[i]] - ans[max(0, l[i] - 2)])

Measured memory_bytes: 19172
#include<iostream>
#include<cmath>
#include<stdio.h>
#define PI 3.141592653589793
using namespace std;

int main(){
	double x = 0, y = 0;

	int angle = 90;

	int l, a;

	while(scanf("%d,%d",&l,&a) + 1){
		if(l == 0 && a == 0)break;

		x -= l * cos(angle * PI / 180);
		y += l * sin(angle * PI / 180);

		angle += a;
	}

	cout << (int)x << endl << (int)y << endl;

	return 0;
}

Measured memory_bytes: 1212
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.nextLine());
		for(int i = 0; i < n; i++) {
			String S = sc.nextLine();
			String s = S.replaceAll("Hoshino", "Hoshina");
			System.out.println(s);
		}
		sc.close();
	}
}


Measured memory_bytes: 26256
#include<stdio.h>

int main(void)
{
	int a[200],b[200],c[200],sum[200];
	int fa[200],fb[200],fc[200];
	int n,i,j;
	
	scanf("%d",&n);
	for(i=0;i<n;i++)	{
		scanf("%d %d %d",&a[i],&b[i],&c[i]);
		fa[i]=0;	fb[i]=0;	fc[i]=0;
	}
	for(i=0;i<n-1;i++)	{
		for(j=i+1;j<n;j++)	{
			if(a[i]==a[j] )	{
				fa[i]=1;
				fa[j]=1;
			}
			if(b[i]==b[j])	{
				fb[i]=1;
				fb[j]=1;
			}
			if(c[i]==c[j])	{
				fc[i]=1;
				fc[j]=1;
			}
		}
	}
	for(i=0;i<n;i++)	{
		if(fa[i]==1)	a[i]=0;
		if(fb[i]==1)	b[i]=0;
		if(fc[i]==1)	c[i]=0;
		sum[i]=a[i]+b[i]+c[i];
		printf("%d\n",sum[i]);
	}
	return 0;
}


Measured memory_bytes: 600
import string

S = list(map(str, input()))
s = sorted(set(S))
count = 0

alphabet = string.ascii_lowercase

if len(s) == len(alphabet):
    print("None")

else:
    for i in range(len(s)):
        if s[i] != alphabet[i]:
            print(alphabet[i])
            break
        else:
            count += 1

if count == len(s):
    print(alphabet[len(s)])


Measured memory_bytes: 4600
#include <bits/stdc++.h>
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
#define invrep(i,n) for(int64_t i=n-1;i >= 0L;i--)
#define positiverep(i,n) for(int64_t i=1;i <= (int64_t)(n);i++)
using namespace std;

//////全探索したいときに開けよ////////
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  int64_t array_num = 1;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}

//////nCrのmodを求めたいときに開けよ/////////
//int64_t univMod = 1000000007;
//int64_t factnum = 100000
//vector<int64_t> modfact(factnum);
//vector<int64_t> modinvfact(factnum);

/*void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t calcmodpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t calcinverse(int64_t n){
	return calcmodpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = calcmodpower(modfact.at(i),univMod-2);
    }
  }
}

int64_t calcmodcomb(int64_t n,int64_t r){
  return (((modfact.at(n)*modinvfact.at(r))%univMod)*modinvfact.at(n-r))%univMod;
}

int64_t calcmodpositive(int64_t n){
  return (n + ((abs(n)+univMod-1)/univMod)*univMod)%univMod;
}
  
    */


/*
int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}
*/
struct playerinfo{
  int64_t eattime;
  int64_t id;
};

int main(){
  int64_t n,m;
  cin >> n >> m;
  int64_t beki = 1;
  rep(i,m){
    beki *= 2;
  }
  cout << beki*(1900*m+100*(n-m)) << endl;
}

Measured memory_bytes: 256