akhauriyash/Code-Regression huggingface dataset:
#include <cassert>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <limits>
#include <numeric>

using namespace std;

/* returns minimum #trucks to deliver all parcels given capacity
 */
inline bool sim(const vector<int>& parcels, const int capacity, const int K){
  int t = 0;
  int cumulative_weight = capacity;
  for(const int p : parcels){
    //if(p > capacity) return numeric_limits<int>::max();
    if(p > capacity) return false;
    
    const int room = capacity - cumulative_weight;
    if (p <= room){
      cumulative_weight  += p;
    }
    else{
      ++t;
      cumulative_weight = p;
    }
    
    //if(t > K) return numeric_limits<int>::max();
    if(t > K) return false;
  }

  assert(t <= K);
  return true;
}

int main(){
  ios::sync_with_stdio(false);
  int N, K; 
  cin >> N; // #parcels
  cin >> K; // #trucks

  vector<int> parcels;

  for(int i=0; i<N; ++i){
    int w;
    cin >> w;
    parcels.push_back(w);
  }

  //binary search
  int lb = 1;
  int ub = accumulate(parcels.begin(), parcels.end(), 0);
  while(lb<ub){
    const int mid = (lb + ub)/2;
    const bool feas_mid = sim(parcels, mid, K);
    if(feas_mid){
      ub = mid;
    }
    else{
      lb = mid + 1;
    }
  }

  cout << ub << endl;

  return 0;
}

Measured memory_bytes: 1684
#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5+4;
int h[MAX],dp[MAX];
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>h[i];
	}
	dp[1] = 0,dp[0] = 0;
	for(int i=2;i<=n;i++)
	{
		if(i > 2)
		{
			dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]),dp[i-2] + abs(h[i] - h[i-2]));
		}
		
		else if(i == 2)
		{
			dp[i] = dp[i-1] + abs(h[i] - h[i-1]);
		}
	}
	
	cout<<dp[n];
}

Measured memory_bytes: 1024
#include<stdio.h>

int dq[50];

int fib(int n) {
	if (n == 0 || n == 1)return dq[n] = 1;
	if (dq[n] != -1)return dq[n];
	return dq[n] = fib(n - 1) + fib(n - 2);
}

int main() {
	int n, i;
	for (i = 0; i < 50; i++) {
		dq[i] = -1;
	}

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

	return 0;
}


Measured memory_bytes: 2716
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

class Graph{
	private:
	int n;
	vvp g;
	public:
	int DIJ(int s,int t){
		priority_queue<P> q;
		vi d(n,inf);
		d[s]=0;
		q.push({0,s});
		while(!q.empty()){
			P p=q.top();
			q.pop();
			int v=p.second;
			if(d[v]<-p.first) continue;
			for(auto i:g[v]){
				int u=i.first,D=d[v]+i.second;
				if(d[u]>D){
					d[u]=D;
					q.push({-D,u});
				}
			}
		}
		return d[t];
	}
	Graph(int v){
		n=v;
		g=vvp(v);
	}
	void add_edge(int s,int t,int c){
		g[s].push_back({t,c});
	}
};

int n,m,s,t;

int main(){
	cin>>n>>m;
	Graph g(4*n);
	for(int i=0;i<m;i++){
		int u,v;
		cin>>u>>v;
		u--;v--;
		g.add_edge(u,v+n,0);
		g.add_edge(u+n,v+2*n,0);
		g.add_edge(u+2*n,v+3*n,0);
		g.add_edge(v+3*n,v,1);
	}
	cin>>s>>t;
	int d=g.DIJ(s-1,t-1);
	cout<<(d==inf?-1:d)<<endl;
}

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

using namespace std;

#define F first
#define S second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define endl '\n'

typedef long long int ll;
typedef pair<ll,ll> ii;
typedef pair<string,ll> si;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<si> vsi;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<vsi> vvsi;

const int INF = 2000000000;
const ll INFLL = 1LL * INF * INF;
ll mod = (int)pow(10,9)+7;
//**************************************************************
//int findSet(int i)
// {
// 	return (p[i]==i)? i:(p[i]=findSet(p[i]));
// }
// bool isSame(int i, int j)
// {
// 	return findSet(i)==findSet(j);
// }
// void unionSet(int i, int j)
// {
// 	if(!isSame(i,j))
// 	{
// 		int x = findSet(i);
// 		int y = findSet(j);
// 		if(ra[x]>ra[y])
// 			p[y] = i;
			
// 		else
// 		{
// 			p[x] = y;
// 			if(ra[x]==ra[y])
// 				ra[y]++;		
// 		}
// 	}
// }

// ***************************************************************************
// ll mulmod(ll a, ll b, ll mod) 
// { 
//     ll res = 0; // Initialize result 
//     a = a % mod; 
//     while (b > 0) 
//     { 
//         // If b is odd, add 'a' to result 
//         if (b % 2 == 1) 
//             res = (res + a) % mod; 
  
//         // Multiply 'a' with 2 
//         a = (a * 2) % mod; 
  
//         // Divide b by 2 
//         b /= 2; 
//     } 
  
//     // Return result 
//     return res % mod; 
// } 
// *****************************************************************************
// bool sieve[100005];

// void sieveoferat()
// {
// 	for(ll p = 2; p*p<100005 ; p++)
// 	{
// 		if(sieve[p])
// 		{
// 			for(int j = p*p; j<100005; j+=p)
// 				sieve[j] = false;
// 		}
// 	}
// }
//********************************************************************************
// void dp(sp_1, sp_2.....)
// {
// 	if()//exit statement
// 	if()//using the memoization 
// 	ll ans = //default/dummy answer
// 	//recursions
// 			//max/min
// 	return memo[][].. = ans;

// }
//*************************************************************************************
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
 	cout.tie(NULL);
 	//memset(memo, -1, sizeof memo);
 	// memset(sieve, true, sizeof sieve);
 	// sieveoferat();
 	// for(int i = 1; i<100005 ;i++) UFDS
		// p[i] = i;
 	int n;cin>>n;
 	int p[n];
 	for(int i = 0;  i<n ; i++)
 		cin>>p[i];
 	int count= 0 ;
 	for(int i = 1; i<n-1 ;i++)
 		if(p[i]!=min(p[i], min(p[i-1], p[i+1]))&&p[i]!=max(p[i], max(p[i-1], p[i+1])))
 			count++;
 	cout<<count<<endl;
 	
	return 0;
}

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

int ans[100002];

int main(void) {
	string S;
	cin >> S;
	int N = S.length();
	for (int i = 0; i <=N; i++) ans[i] = 0;

	int Rst = 0, Lst = -1;
	int pos = 0;
	while (pos < N) {
		char posch = S[pos];
		switch (posch) {
		case 'R':
			if (Rst < 0) {
				// start R
				Rst = pos;
				if (Lst > 0) { // 最初だけ除外するための条件
					// L -> R
					int Len = pos-1;
					// Lの処理
					int Lcount = Len-Lst+1;
					ans[Lst-1] += Lcount/2;
					ans[Lst]   += (Lcount - Lcount/2); // 端数はこちらに入る
				} else {
					// 一番最初だけ除外
				}
				Lst = -1;
			}
			break;
		case 'L':
			if (Lst < 0) {
				// start L
				Lst = pos;
				// RからLに切り換わる時
				int Ren = pos-1;
				int Rcount = Ren-Rst+1;
				ans[Ren+1] += Rcount/2;
				ans[Ren]   += (Rcount - Rcount/2); // 端数はこちらに入る
				Rst = -1;
			}
			break;
		}
		pos++;
	}
	// 最後のLを処理
	int Len = N-1;
	int Lcount = Len-Lst+1;
	ans[Lst-1] += Lcount/2;
	ans[Lst]   += (Lcount - Lcount/2); // 端数はこちらに入る

	for (int i = 0; i < N; i++) cout << ans[i] << " ";
	cout << endl;

	return 0;
}


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

int main(){
    using namespace std;
    size_t n;
    cin >> n;
    vector<unsigned int> a(n);
    copy_n(istream_iterator<unsigned int>(cin), n, a.begin());
    sort(a.begin(), a.end());
    cout << a[n / 2] - a[n / 2 - 1] << endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int N,K; cin>>N>>K;
  vi A(N);
  rep(i,0,N) cin>>A[i];
  vector<bool> F(K+1);
  REP(i,0,K){
    rep(j,0,N){
      if(i-A[j]>=0&&!F[i-A[j]]) F[i]=1;
    }
  }
  string ans="Second";
  if(F[K]) ans="First";
  cout<<ans<<endl;
  }


Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(){
    int a,b,c,x;
    cin >> a >> b >> c >> x;
    int ans = 0;
    for(int i = 0; i <= a; i++)
    {
        for(int j = 0; j <= b; j++)
        {
            for(int k = 0; k <= c; k++)
            {
                if (500*i+100*j+50*k == x) {
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
}

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

int x,y;
int main(){
    cin>>x>>y;
    if((x>y)&&(y>1)){
    cout<<"Alice"<<endl;
    }
    else if((x<y)&&(x>1)){
    cout<<"Bob"<<endl;
    }
    else if(x==y){
    cout<<"Draw"<<endl;
    }
    else if((x<y)&&(x<2)){
    cout<<"Alice"<<endl;
    }
    else{
    cout<<"Bob"<<endl;    
    }
}

Measured memory_bytes: 256
import java.util.*;

public class Main{

  public static void main (String[] args){
    
    Scanner scanner = new Scanner (System.in);
    
    int A = scanner.nextInt();
    String op = scanner.next();
    int B = scanner.nextInt();
    
    if(op.equals("+")){
      System.out.println(A+B);
    } else {
      System.out.println(A-B);
    }
  }
}

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

using namespace std;

typedef long long ll;

int main() {
  ll N, red=0;
  string s;
  cin >> N >> s;
  for (ll j=0; j < N; ++j) {
    if (s[j] == 'R') {
      red += 1;
    }
  }
  cout << (red > N-red ? "Yes" : "No") << endl;
}


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

typedef long long ll;
using namespace std;

int main() {
  ll N, Y;
  cin >> N >> Y;
  for(int i = 0; i <= N; i++) {
    for (int j = 0; j <= N - i; j++) {
      int k = N - i - j;
      if (1000 * k == Y - 10000 * i - 5000 * j) {
        cout << i << " " << j << " " << k << endl;
        return 0;
      }
    }
  }
  cout << "-1 -1 -1" << endl;
  return 0;
}

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

int main() {
  string S;
  cin >> S;
  string ans = "None";
  char c='a', cc;
  int ff=0;
  for (int i=0; i<26; i++) {
    ff=0;
    cc=(char)(c+i);
    for (int j=0; j<S.size(); j++) {
      if (S[j]==cc) {
        ff=1;
        break;
      }
    }
    if (ff==0) {
      ans = cc;
      break;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3736
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
#include <numeric>
#include <random>
#include <climits>  // A/Bを計算するときA==LLONG_MIN && B==-1のみ(1ull<<63)で代用
using namespace std;

typedef long long LL;
typedef pair<LL, LL> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef vector<VL> VVL;				// VVL v(100,VL(100,0));
typedef vector<pair<LL, LL> > VP;
typedef vector<string> VS;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<LL, pair<P, P> > PP;

#define INF 999999999999999997		// 少し加算したらオーバーフローする
#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORL(i,a,b) for(LL i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
#define O(s) cout<<s<<endl;

#define DUMP_VVI(b) if(dbgF){FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}

template<class T>T IN() { T d; cin >> d; return d; }

LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a%b) : a; } // 最大公約数（Greatest Common Divisor）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; } // 最小公倍数（Least Common Multiple）
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); } // うるう年判定
string Replace(string S, string from, string to) { auto p = S.find(from); while (p != string::npos) { S.replace(p, from.size(), to); p = S.find(from, p + to.size()); }return S; }

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int dxx[8] = { 0,1,1,1,0,-1,-1,-1 };
int dyy[8] = { 1,1,0,-1,-1,-1,0,1 };

// -------------------------------------------------------------------------------

int main() {
	FAST_IO;
	bool dbgF = true; // for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;

	string s;
	cin >> s;
	LL a = 0, b = 0, c = 0;
	FOR(i, 0, s.length()) {
		if (s[i] == 'a')a++;
			if (s[i] == 'b')b++;
			if (s[i] == 'c')c++;
	}
	if (a&&b&&c) {
		O("Yes");
	}
	else {
		O("No");
	}

	return 0;
}

Measured memory_bytes: 764
n = gets.to_i
a = n/100
b = n%100
if a>0 && a<13
  if b>0 && b<13
    puts "AMBIGUOUS"
  else
    puts "MMYY"
  end
else
  if b>0 && b<13
    puts "YYMM"
  else
    puts "NA"
  end
end


Measured memory_bytes: 1788
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn solve() {
    input! {
        n: usize, m: usize,
        abv: [(usize, usize); n]
    };

    let mut works = vec![Vec::new(); m + 1];
    for (a, b) in abv {
        if a <= m {
            works[a].push(b);
        }
    }
    let mut heap = BinaryHeap::new();
    let mut res = 0_usize;
    for i in 1..=m {
        for &b in &works[i] {
            heap.push(b);
        }
        if let Some(b) = heap.pop() {
            res += b;
        }
    }
    println!("{}", res);
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


Measured memory_bytes: 8716
from heapq import heappush, heappop
from collections import deque
import itertools
from itertools import permutations
import sys

import bisect
sys.setrecursionlimit(10**6)
def SI():
    return input().split()
def MI():
    return map(int,input().split())
def I():
    return int(input())
def LI():
    return [int(i) for i in input().split()]
YN=['Yes','No']
YNeos='YNeos'
GYN=['Yes','trumpet']
mo=10**9+7
imp='IMPOSSIBLE'

n,k=MI()
a=LI()
A=[0]
for i in a:
    A+=[A[-1]+i]
b=[]
for i in range(n+1):
    for j in range(i+1,n+1):
        b+=[A[j]-A[i]]
        
c=sorted(b)#[-k:]
ans=0
i=0
i2=2**40
while i2>0:
#    print(i2,sum([(j&(ans+i2))==(ans+i2) for j in c]))
    ans+=i2 if sum([(j&(ans+i2))==(ans+i2) for j in c])>=k else 0
    i2//=2
    i+=1
    
print(ans)#,A,c)
#print()


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

using namespace std;

void solve()
{
	int N;
	string S;
	cin >> N >> S;
	vector<int> ws(N+1), es(N+1);
	for (int i = 0; i < N; i++)
	{
		ws[i+1] = ws[i] + (S[i] == 'W');
	}
	for (int i = N-2; i >= 0; i--)
	{
		es[i] = es[i+1] + (S[i+1] == 'E');
	}
	int ans = N;
	for (int i = 0; i < N; i++)
	{
		ans = min(ans, es[i]+ws[i]);
	}
	cout << ans << endl;
}

int main(void)
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 3076
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <algorithm>
#include <string>

#define MAX 10000

using namespace std;

int n;
int LCS[MAX][MAX];

void solve(string a, string b){
    int m = a.size();
    int n = b.size();
    int maxl = 0;
    for(int i=0; i<m; i++){
        for(int j=0; j<n; j++){
            LCS[i][j] = 0;
        }
    }
    bool tmp_ok = false;
    for(int i=0; i<n; i++){
        if(a[0] == b[i] || tmp_ok){
            LCS[i][0] = 1;
            maxl = 1;
            tmp_ok = true;
        }
    }
    tmp_ok = false;
    for(int i=0; i<m; i++){
        if(a[i] == b[0] || tmp_ok){
            LCS[0][i] = 1;
            maxl = 1;
            tmp_ok = true;
        }
    }
    for(int i=1; i<n; i++){
        for(int j=1; j<m; j++){
            if(a[j] == b[i]){
                LCS[i][j] = LCS[i-1][j-1]+1;
            }
            else if(LCS[i-1][j]>=LCS[i][j-1]){
                LCS[i][j] = LCS[i-1][j];
            }
            else LCS[i][j] = LCS[i][j-1];
            maxl = max(maxl, LCS[i][j]);
        }
    }
    
    cout << maxl << endl;
}

int main(int argc, const char * argv[]) {
    // input from txt
    
    /////////
    //write//
    /////////
    
    cin >> n;
    for(int i=0; i<n; i++){
        string str_a;
        string str_b;
        cin >> str_a >> str_b;
        solve(str_a, str_b);
    }
    
    return 0;
}



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

typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
typedef map<ll, ll> mii;
const int MOD = 1e9 + 7;

#define fastIO() \
ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define endl "\n"
#define pb push_back
#define ff first
#define ss second
#define mp make_pair 

int H, W;
ll dp[1002][1002];
char a[1002][1002];

int main() {
    memset(dp, 0, sizeof(dp));
    cin >> H >> W;
    for (int i = 1; i <= H; ++i) {
        for (int j = 1; j <= W; ++j) {
            cin >> a[i][j];
            if (i == 1 && j == 1)   dp[i][j] = 1;
            else if (a[i][j] == '#')
                dp[i][j] = 0;
            else
                dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % MOD;
        }
    }
    cout << dp[H][W] << endl;
    return 0;
}


Measured memory_bytes: 9088
# -*- coding: utf-8 -*-
 
import numpy as np
 
N, K = map(int, input().split())
 
h = np.array(list(map(int, input().split())))
 
dp = np.zeros(N, dtype=np.int)
 
for n in range(1, N):
    k = min(K, n)
    temp = np.min(dp[n-k:n] + np.abs(h[n]-h[n-k:n]))
    dp[n] = temp
print(dp[-1])

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


int main() {
 long long n;
 cin >> n;
 
 long long ans = n -1;
 
 for(long long i = 2; i <= sqrt(n); i++) {
  if(n % i == 0) {
   ans = i + n / i - 2;
   }
   }
   
   cout << ans;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x[ohara],y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
map<ll,ll> mp;
map<ll,ll> cou;
map<ll,ll> herasu;
bool vi[ohara];
ll kosuu;
P p[ohara];
ll p_cou;
ll dat[ohara];

//-------------------------↓↓↓↓↓↓------------------------

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

    //[{%m,m}]=個数
    cin>>n>>m;
    rep(i,n)cin>>x[i];
    rep(i,n){
        cou[x[i]]++;
        mp[x[i]%m]++;
    }
    rep(i,n){
        if((x[i]%m)!=m-(x[i]%m)&&x[i]%m!=0){
            //cerr<<i<<" "<<mp[i]<<" ";
            ans+=min(mp[x[i]%m],mp[m-(x[i]%m)]);
            herasu[x[i]%m]+=min(mp[x[i]%m],mp[m-(x[i]%m)]);
            herasu[m-(x[i]%m)]+=min(mp[x[i]%m],mp[m-(x[i]%m)]);
            pos=mp[x[i]%m];
            mp[x[i]%m]-=min(mp[x[i]%m],mp[m-(x[i]%m)]);
            mp[m-(x[i]%m)]-=min(pos,mp[m-(x[i]%m)]);
        }
        else{
            ans+=mp[x[i]%m]/2;
            herasu[x[i]%m]+=(mp[x[i]%m]/2)*2;
            mp[x[i]%m]%=2;
        }
    }
    rep(i,n){
        if(vi[x[i]])continue;
        vi[x[i]]=true;
        p[p_cou++]=m_p(cou[x[i]],x[i]%m);
    }
    sort(p,p+p_cou);
    reverse(p,p+p_cou);
    rep(i,p_cou){
        if(p[i].fi%2==1){
            dat[p[i].se]++;
            p[i].fi--;
        }
        //p[i].fi/=2;
    }
    rep(i,m){
        herasu[i]-=dat[i];
        if(herasu[i]<0)herasu[i]=0;
    }
    rep(i,p_cou){
        if(p[i].fi>=herasu[p[i].se]){
        p[i].fi-=herasu[p[i].se];
        herasu[p[i].se]=0;
        }
        else{
            herasu[p[i].se]-=p[i].fi;
            p[i].fi=0;
        }
    }
    rep(i,p_cou){
        cnt+=p[i].fi/2;
        //cout<<p[i].fi<<"\n";
    }
    //Cerr(cnt);
    //rep(i,m)cnt-=herasu[i],cerr<<herasu[i]<<"\n";
    //rep(i,m)cnt-=herasu[i],cout<<i<<" "<<herasu[i]<<"\n";
    Cout(ans+cnt);
    return 0;
}


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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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 n;
string s;
int u[26];
i64 mod_pow(i64 x, i64 y, i64 mod){
	i64 res = 1;
	while(y > 0){
		if(y & 1) res = res * x % mod;
		x = x*x %mod;
		y >>= 1;
	}
	return res;
}
void solve(){
	cin >> n >> s;
	
	i64 a = 0;
	for(int i = 0; i < n; i++){
		i64 c = 1;
		for(int j = 0; j < 26 ;j++){
			if(s[i]-'a' == j) continue;
			if(!u[j]) continue;
			c += c*u[j];
			c %= INF;
		}
		a+=c;
		a%=INF;
		u[s[i]-'a']++;
	}
	cout << a << endl;
}

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


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

int main()
{
	string s;
	cin>>s;
	string str=s.substr(0,4);
	stringstream g(str);
	int year=0;
	g>>year;
	if(year>2019)cout<<"TBD\n";
	else{
		str=s.substr(5,2);
		stringstream g(str);
		int	month=0;
		g>>month;
		if(month>4)cout<<"TBD\n";
		else{
			str=s.substr(8,2);
			stringstream g(str);
			int day=0;
			g>>day;
			if(day>30)cout<<"TBD\n";
			else cout<<"Heisei\n";
		}
	}
	return 0;
}


Measured memory_bytes: 256
package main

import (
  "bufio"
  "os"
  "strconv"
  "strings"
  "fmt"
)

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt(A ...*int) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.Atoi(L[i])
  }
}
func NextIntVec(A *[]int) {
  L := strings.Split(NextLine(), " ")
  (*A) = make([]int, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.Atoi(l)
  }
}
func NextFloat(A ...*float64) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.ParseFloat(L[i], 64)
  }
}
func NextFloatVec(A *[]float64) {
  L := strings.Split(NextLine(), " ")
  (*A) = make([]float64, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.ParseFloat(l, 64)
  }
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func WriteIntVec(A []int) {
  S := make([]string, len(A))
  for i, a := range A {
    S[i] = strconv.Itoa(a)
  }
  Write(strings.Join(S, " "))
}
func Output() {
  _ = writer.Flush()
}

func MaxInt(A ...int) int {
  max := A[0]
  for _, a := range A {
    if max < a { max = a }
  }
  return max
}
func MinInt(A ...int) int {
  min := A[0]
  for _, a := range A {
    if a < min { min = a }
  }
  return min
}
func SumInt(A ...int) int {
  sum := 0
  for _, a := range A {
    sum += a
  }
  return sum
}

func Factorial(N int) (F, Finv, Inv []int) {
  F = make([]int, N + 1)
  Finv = make([]int, N + 1)
  Inv = make([]int, N + 1)
  F[0] = 1
  F[1] = 1
  Finv[0] = 1
  Finv[1] = 1
  Inv[0] = 1
  Inv[1] = 1
  for i := 2; i < N + 1; i++ {
    F[i] = F[i - 1] * i % p
    Inv[i] = p - Inv[p % i] * (p / i) % p
    Finv[i] = Finv[i - 1] * Inv[i] % p
  }
  return
}

const p = 1000000007

func Solve() {
  var N int
  NextInt(&N)
  var A []int
  NextIntVec(&A)
  F, _, Inv := Factorial(N)
  P := make([]int, N)
  for i := 1; i < N; i++ {
    P[i] = (P[i - 1] + Inv[i + 1]) % p
  }
  cnt := 0
  for i, a := range A {
    cnt += a * (P[i] + P[N - 1 - i] + 1) % p
    cnt %= p
  }
  cnt = cnt * F[N] % p
  Write(cnt)
  return
}

func main() {
  Solve()
  Output()
}

Measured memory_bytes: 7680
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        var sc = new Scanner(System.in);
    
        double a = Double.parseDouble(sc.next());
        double b = Double.parseDouble(sc.next());
        double h = Double.parseDouble(sc.next());
        double m = Double.parseDouble(sc.next());
        
        double x = Math.toRadians(Math.abs(h*30 + m*0.5 - m*6));
        double ans = Math.sqrt(a*a+b*b-(2*a*b*Math.cos(x)));
        System.out.println(ans);
    }
}

Measured memory_bytes: 35900
from collections import defaultdict
def main():
    N = int( input())
    A = list( map( int, input().split()))
    d = defaultdict( int)
    for a in A:
        if d[a] == 1:
            print("NO")
            return
        d[a] = 1
    print("YES")
if __name__ == '__main__':
    main()

Measured memory_bytes: 33996
#include<stdio.h>
int main(void){
	int k, a, b, i;
	scanf("%d", &k);
	scanf("%d %d", &a, &b);
	
	for(i=k; i<=b; i+=k){
		if(i>=a){
			i=-1;
			break;
		}
	}

	if(i==-1)printf("OK\n");
	else	printf("NG\n");
	
	return 0;
}

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

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

using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */
int main(){
  int N,num=0;
  cin>>N;

  for (int i=1;i<=N;i++){
    if (to_string(i).length()%2==1) {
      num++;
      
    }
  }
  cout<<num<<endl;
  return 0;
  
}

Measured memory_bytes: 3740
/* 
*  入力された二つの文字列から最長共通部分列を求める。
*  二次元配列使用、動的計画法を利用する 
*/

#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

static const int N = 1000;

int lcs(string X, string Y) {
	int c[N + 1][N + 1]; // 二次元配列
	int m = X.size(); // 文字列１の長さ
	int n = Y.size(); // 文字列２の長さ
	int maxl = 0; // 文字列の最長の長さ
	X = ' ' + X; // X[0]に空白を挿入
	Y = ' ' + Y; // Y[0]に空白を挿入

	c[0][0] = 0;
	for (int i = 1; i <= m; i++) c[i][0] = 0;
	for (int j = 1; j <= n; j++) c[0][j] = 0;

	for (int i = 1; i <= m; i++) {
		for (int j = 1; j <= n; j++) {
			if (X[i] == Y[j]) {
				c[i][j] = c[i - 1][j - 1] + 1;
			}
			else {
				c[i][j] = max(c[i - 1][j], c[i][j - 1]);
			}
			maxl = max(maxl, c[i][j]);
		}
	}

	// 配列c[][]の中身確認
	/*for (int i = 0; i <= m; i++) {
		for (int j = 0; j <= n; j++) {
			cout << c[i][j] << ", ";
		}
		cout << endl;
	}*/

	return maxl;

}

int main() {
	string s1, s2;
	int n; cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> s1 >> s2;
		cout << lcs(s1, s2) << endl;
	}

	return 0;
}


Measured memory_bytes: 7068
import sys
import os
import math
import string

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    A, B = il()
    ret = max(A, B)
    if ret == A:
        ret += max(A - 1, B)
    else:
        ret += max(A, B - 1)
    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3832
/*
  mail: mleautomaton@foxmail.com
  author: MLEAutoMaton
  This Code is made by MLEAutoMaton
*/
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define ll long long
#define REP(a,b,c) for(int a=b;a<=c;a++)
#define re register
#define file(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
inline int gi(){
	int f=1,sum=0;char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return f*sum;
}
const int N=200010;
int f[N],n,m;
int dis[N],vis[N],front[N],cnt;
struct node{int to,nxt,w;}e[N<<1];
set<int>se[N];
queue<int>Q;
void Add(int u,int v,int w){e[++cnt]=(node){v,front[u],w};front[u]=cnt;}
int find(int x){if(f[x]!=x)f[x]=find(f[x]);return f[x];}
void SPFA(){
	Q.push(1);memset(dis,63,sizeof(dis));dis[1]=0;
	while(!Q.empty()){
		int u=Q.front();Q.pop();vis[u]=0;
		for(int i=front[u];i;i=e[i].nxt){
			int v=e[i].to,W;
			if(se[u].find(e[i].w)!=se[u].end())W=0;
			else W=1;
			if(dis[v]>dis[u]+W){
				dis[v]=dis[u]+W;se[v].clear();se[v].insert(e[i].w);
				if(!vis[v]){vis[v]=1;Q.push(v);}
			}
			else if(dis[v]==dis[u]+W){if(se[v].find(e[i].w)==se[v].end()){if(!vis[v]){vis[v]=1;Q.push(v);}}se[v].insert(e[i].w);}
		}
	}
}
int main(){
	n=gi();m=gi();
	for(int i=1;i<=n;i++)f[i]=i;
	for(int i=1;i<=m;i++){
		int u=gi(),v=gi(),w=gi();
		f[find(u)]=find(v);Add(u,v,w);Add(v,u,w);
	}
	if(find(1)!=find(n))return puts("-1"),0;
	SPFA();printf("%d\n",dis[n]==dis[n+1]?-1:dis[n]);
	return 0;
}
//%HYJ,Not Good!!!
//% M _ s e a, G o o d ! ! !


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

class Program
{
    static void Main()
    {
        
        long[] A = Console.ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();

        Array.Sort(A, (x, y) => Comparer<long>.Default.Compare(y, x));

        Console.WriteLine(A[0] - A[2]);


    }
    
}



static class MathUtil
{
    public static IEnumerable<IEnumerable<int>> GetPermutation(int n)
    {
        if (n == 0)
        {
            yield return Single(0);
            yield break;
        }

        for (int i = 0; i <= n; i++)
        {
            foreach (var x in GetPermutation(n - 1))
            {
                yield return Single(i).Concat(x.Select(itm => itm < i ? itm : itm + 1));
            }
        }
    }

    private static IEnumerable<int> Single(int x)
    {
        yield return x;
    }

    public static IEnumerable<int> EnumeratePrimeNumbers()
    {
        List<int> primes = new List<int>() { 2 };
        yield return 2;

        for (int i = 3; i < int.MaxValue; i++)
        {
            bool isPrime = true;
            int Sqrt = (int)Math.Sqrt(i) + 1;

            foreach (var prime in primes)
            {
                if (prime > Sqrt)
                {
                    break;
                }
                if (i % prime == 0)
                {
                    isPrime = false;
                    break;
                }
            }

            if (isPrime)
            {
                primes.Add(i);
                yield return i;
            }
        }
    }
}



Measured memory_bytes: 13280
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort(reverse=True)
    return divisors
A,B,K = map(int,input().split())
nums1=make_divisors(A)
nums2=make_divisors(B)
ans=0
count=0
for a in nums1:
    if a in nums2:
        count+=1
    if count==K:
        ans=a
        break
print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define double long double
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 2147483647
#include <math.h> /* M_PI */
int main()
{
    ll x;
    ll y;
    cin >> x >> y;
    int flag = 0;
    for (int i = 0; i <= x; i++)
    {
        ll ans = 0;
        ans = (i)*4 + (x - i) * 2;
        if (ans == y)
        {
            cout << "Yes";
            flag = 1;
            break;
        }
    }
    if (flag == 0)
    {
        cout << "No";
    }
}


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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N,M=MAP()
S=LIST()
T=LIST()

# dp1[i][j], dp2[i][j] := Sをi文字目、Tをj文字目まで考えた時、dp1はi方向、dp2はj方向に遷移させる
dp1=list2d(N+2, M+2, 0)
dp2=list2d(N+2, M+2, 0)
dp1[0][0]=1
for i in range(N+1):
    for j in range(M+1):
        dp1[i][j]%=MOD
        # 数え上げをi方向とj方向で重複がないように遷移させる
        dp1[i+1][j]+=dp1[i][j]
        dp2[i][j]+=dp1[i][j]
        dp2[i][j+1]+=dp2[i][j]
        # 今回増やす数値が一致するなら
        if i<N and j<M and S[i]==T[j]:
            # 斜めに遷移させる(1→0)
            dp1[i+1][j+1]+=dp2[i][j]
print((dp2[N][M])%MOD)


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

int main() {
    // input
    int n, m, a, b, c;
    cin >> n >> m;
    vector<pair<ll, int> > cb;
    rep(i, n) {
        cin >> a;
        cb.push_back(make_pair(a, 1));
    }
    rep(i, m) {
        cin >> b >> c;
        cb.push_back(make_pair(c, b));
    }    
    sort(cb.begin(), cb.end(), greater<pair<ll, int> >());
    
    // solve
    ll ans = 0;
    rep(i, cb.size()) {
        if (n > cb[i].second) {
            ans += cb[i].first * cb[i].second;
            n -= cb[i].second;
            if (n == 0) break;
        } else {
            ans += cb[i].first * n;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 6512
#include <bits/stdc++.h>
typedef long long ll;
#define pb push_back
using namespace std;
typedef pair<ll, ll> pll;


ll n;
ll b[100005], X, l[200005], r[200005];
vector< pair<pll , ll> > a;
ll S;
bool check(ll h)
{
        ll s = S;
        ll tt = h / X;
        ll rms = h - tt*X;
        a.clear();
        if(h == n*X) return true;
        for(ll i=1;i<=n;i++){
                ll mup = l[i];
                if(rms > b[i]) mup = r[i];
                a.pb(make_pair(make_pair(r[i]*X - r[i]*b[i] + l[i]*b[i], l[i]*b[i] + mup*(rms - b[i])), i));
        }
        sort(a.rbegin(), a.rend());
        ll psum = 0;
        for(ll i=0;i<tt;i++) {
                ll id = a[i].second;
                psum += l[id] * b[id];
                psum += r[id] * (X - b[id]);
        }

        ll org = s;
        for(ll i=0;i<a.size();i++) {
                s += psum;
                ll id = a[i].second;
                if(i < tt){
                        //s -= l[id]*b[id];
                        s -= r[id] * (X - b[id]);
                        ll id2 = a[tt].second;
                        s += l[id2]*b[id2] + r[id2]*(X - b[id2]);
                }else {
                        s += l[id] * b[id];
                }
                ll mup = l[id];
                if(rms > b[id]) mup = r[id];
                s += mup * (rms - b[id]);
                if(s >=0 ) return true;
                s = org;
        }
        return false;
}
int main()
{
        cin >> n >> X;
        for(ll i=1;i<=n;i++) {
                cin >> b[i] >> l[i] >> r[i];
                //a.pb(make_pair(r[i]*X - r[i]*b[i] + l[i]*b[i] , i));
                S -= l[i] * b[i];
        }
        //sort(a.rbegin(), a.rend());
        ll lo = 0;
        ll hi = n*X;
        while(hi > lo) {

                ll mid = lo + (hi - lo) / 2;
                if(check(mid)) {
                        hi = mid;
                }else lo = mid + 1;
        }
        cout << lo << endl;
        return 0;
}


Measured memory_bytes: 7284
require "set"

n, m = gets.split.map(&:to_i)
hash = {}
m.times do
  a, b = gets.split.map(&:to_i)
  hash[a] ||= []
  hash[a] << b
  hash[b] ||= []
  hash[b] << a
end

queue = [1]
marked_set = Set.new([1])
mark_hash = {}
(1..n).each do
  break if queue.length == 0

  num = queue.shift
  arr = hash[num]
  arr.each do |j|
    next if marked_set.include?(j)
    
    queue << j
    marked_set << j
    mark_hash[j] = num
  end
end

if mark_hash.keys.length < n - 1
  puts "No"
  return
end

puts "Yes"
mark_hash.sort_by{|num, _mark| num}.each do |_n, mark|
  puts mark
end

Measured memory_bytes: 48992
#include<bits/stdc++.h>
using namespace std;
long long i,n,a[405];
int main()
{
    cin>>n;
    a[0]=2;
    for(i=0;i<=n;i++) a[i]=a[i-1]*2+2;
    cout<<a[n]<<endl;
    return 0;
}

Measured memory_bytes: 256
import numpy as np
import copy
from itertools import product
h, w, k = map(int, input().split())
C = [list(input()) for _ in range(h)]
C = np.array(C)

cnt = 0
for i in product([True, False], repeat=h):
    c = copy.deepcopy(C)
    c = np.array(c)
    for p, q in enumerate(i):
        if q:
            c[p, :] = "$"
    for j in product([True, False], repeat=w):
        d = copy.deepcopy(c)
        d = np.array(d)
        for s,t in enumerate(j):
            if t:
                d[:, s] = "$"
        if np.count_nonzero(d == "#") == k:
            cnt += 1

print(cnt)

Measured memory_bytes: 26956
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
using namespace std;


int main(){
	/*input*/
	int n;
	cin >> n ;
//	vector<int> p(n,0);
//	for(int i = 0; i < n; i++){
//		cin >> p[i];
//	}

	/*calc*/
	int ans = 0;
	ans = n/2;
	if(n%2 == 1)ans++;

    /*output*/
	cout<< ans <<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string A,B,C;
    cin >> A >> B >> C;
    char a = toupper(A[0]);
    char b = toupper(B[0]);
    char c = toupper(C[0]);
    cout << a << b << c<< "\n";
}

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

const int N = 5010;

char s[N * 2]; int n;

inline void FUCK(char t) {
    for (int i = 1; i <= n; i++) putchar(t);
    exit(0);
}

int tmp[N * 2]; char res[N];

int main() {
    int k; scanf("%d%d%s", &n, &k, s + 1); char t = 127;
    for (int i = 1; i <= n; i++) t = min(t, s[i]);
    for (int i = n + 1; i <= n * 2; i++) s[i] = s[n * 2 - i + 1];
    for (int i = 1; i <= n; i++) res[i] = 127;
    if (k == 1) {
        for (int i = 1; i <= n + 1; i++) {
            bool flag = false;
            for (int j = 1; j <= n; j++) if (s[i + j - 1] != res[j]) {
                if (s[i + j - 1] < res[j]) flag = true;
                break; 
            } 
            if (flag) for (int j = 1; j <= n; j++) res[j] = s[i + j - 1];
        }
        for (int i = 1; i <= n; i++) putchar(res[i]); 
        return 0;
    }
    if (k >= 20) FUCK(t);
    int mx = 0;
    for (int i = 1; i <= n * 2; i++) if (s[i] == t) 
        tmp[i] = tmp[i - 1] + 1, mx = max(mx, tmp[i]);
    if ((mx << (k - 1)) >= n) FUCK(t);
    int all = mx << k - 1, len = n - mx;
    for (int i = 1; i <= all; i++) putchar(t);
    
    for (int i = 1; i <= n * 2; i++) if (tmp[i] == mx && i - mx - len + 1 >= 1) {
        int st = i - mx + 1; bool flag = false;
        for (int j = 1; j <= len; j++) if (s[st - j] != res[j]) {
            if (s[st - j] < res[j]) flag = true;
            break; 
        } 
        if (flag) for (int j = 1; j <= len; j++) res[j] = s[st - j];
    }
    for (int i = 1; i <= n - all; i++) putchar(res[i]);
}//

Measured memory_bytes: 256
import numpy as np
n = int(input())
L1 = np.array(list(map(int, input().split())))
L2 = np.arange(1, n + 1)

L3 = L1-L2
ans = 0
for i in range(n-1):
    if L3[i] == 0:
        ans +=1
        L3[i],L3[i+1] = -1,-1
if L3[n-1] == 0:
    ans +=1
print(ans)


Measured memory_bytes: 23372
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;

int64_t mod = 998244353 ;

vector<int> getprime(int n){
    vector<int> p(0) ;
    vector<bool> table(n+1,0) ;
    for (int i = 2; i <= n; i++)
    {
        if (table.at(i) == 0)
        {
            p.push_back(i) ;
            for (size_t j = 2; j < n/i ; j++)
            {
                table.at(i*j) = 1 ;
            }
            
        }
        
    }
    return p ;
}

int main(){
    int64_t n ;
    cin >> n ;
    vector<char> x(n) ;
    for (int i = 0; i < n; i++)
    {
        cin >> x.at(i) ;
    }
    
    vector<int> ans(n+1,0) ;
    int poc = 0 ;
    for (int i = 0; i < n; i++)
    {
        if (x.at(i) == '1')
        {
            poc ++ ;
        }
        
    }

    int64_t modl = poc + 1 ;
    int64_t mods = poc - 1 ;
    int64_t powl = 1 ;
    int64_t pows = 1 ;
    int64_t xl = 0 ;
    int64_t xs = 0 ;

    for (int i = 0; i < n; i++)
    {
        if (x.at(n-1-i) == '1')
        {
            xl += powl ;
            xl %= modl ;
            if (mods != 0)
            {
                xs += pows ;
                xs %= mods ;
            }
            
            
        }
        powl *= 2 ;
        powl %= modl ;
        if (mods != 0)
        {
            pows *= 2 ;
            pows %= mods ;
        }
        
    }
    powl = 1 ;
    pows = 1 ;

    int temp = 0 ;
    for (int i = 0; i < n; i++)
    {
        temp = 1 ;
        int mod = 0 ;
        int pow = 0 ;
        int xx = 0 ;
        if (x.at(n-1-i) == '0')
        {
            mod = modl ;
            pow = powl ;
            xx = xl + powl ;
            xx %= mod ;
            
        }else
        {
            mod = mods ;
            pow = pows ;
            xx = xs - pows ;
            if (xx < 0)
            {
                xx += mod ;
            }
            
            
        }
        powl *= 2 ;
        powl %= modl ;
        if (mods != 0)
        {
            pows *= 2 ;
            pows %= mods ;
        }
        
        if (mod == 0)
        {
            ans.at(n-1-i) = 0 ;
            continue ;
        }
        
        
        while(xx > 0){
            int copy = xx ;
            int cop = 0 ;
            while (copy > 0)
            {
                cop += (copy % 2) ;
                copy /= 2 ;
            }
            xx %= cop ;
            temp ++ ;
        }
        ans.at(n-1-i) = temp ;
    }
    for (int i = 0; i < n; i++)
    {
        cout << ans.at(i) << endl ;
    }
    
    
}

Measured memory_bytes: 4300
#include<bits/stdc++.h>
using namespace std ;
int main()
{
    string s ;
    cin >> s ;

    //sort(s.begin(), s.end()) ;

    if(s[0] == s[1] && s[0] == s[2])
        cout << "Yes" << endl ;
    else  if(s[3] == s[1] && s[3] == s[2])
        cout << "Yes" << endl ;
        else
            cout << "No" << endl ;

}


Measured memory_bytes: 256
#include<iostream>
#include<vector>

int main(){
    int N, K;
    std::cin >> N >> K;
    std::vector<int> p(N);
    std::vector<double> expectation(N);
    for(int i = 0; i < N; i++){
        std::cin >> p[i];
        expectation[i] = (p[i] + 1.0) / 2.0; // 各サイコロの期待値
    }

    // 初期化
    double maxE = 0;
    for(int i = 0; i < K; i++){
        maxE += expectation[i];
    }

    // 最大値を求める
    double comparedE = maxE;
    for(int i = K; i < N; i++){
        comparedE += expectation[i] - expectation[i - K];
        if(maxE < comparedE) maxE = comparedE;
    }

    printf("%.6lf\n", maxE);

    return 0;
}

Measured memory_bytes: 2560
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <vector>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;

int main()
{
    string s;
    cin >> s;
    string t = "";
    int cnt = 0;
    for (int i = s.size()-1; i >= 0; i--)
    {
        if (s[i] == 'B')
        {
            cnt++;
        }else if (cnt != 0)
        {
            cnt--;
        }else if (s[i] != 'B' && cnt == 0)
        {
            t = s[i]+t;
        }
        
        
    }
    cout << t << endl;
}
    

Measured memory_bytes: 3636
/*input
7
zenkoku
touitsu
program
*/
/*

**************************
*						 *
* AUTHOR :: knight_coder *
*						 *
**************************

*/
#include<bits/stdc++.h>
#define lld          long long int
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<lld,lld>
#define msi         map<string,lld>
#define mis         map<lld, string>
#define mpi         map<pair<lld ,lld >,lld >
#define pii         pair<lld,lld>
#define vi          vector<lld>
#define vpi 		vector<pii>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (lld)x.size()
#define hell        1000000007
#define rep(i,m,n)	for(lld i=m;i<n;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define what_is(x)  cerr << #x << " is " << x << endl;
#define pr(x) 		cout<< x << " ";
#define pre(x)		cout<< x << endl ;
using namespace std;
#define N  100005
void solve()
{
	lld n;
	string a,b,c;
	cin >> n >> a >> b >> c;
	set <char> s[n+1];
	rep(i,0,n)
	{
		s[i].insert(a[i]);
		s[i].insert(b[i]);
		s[i].insert(c[i]);
	} 
	lld ans=0;
	rep(i,0,n)
	{
		ans+=(s[i].size()-1);
	}
	cout << ans << endl;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int tests=1;
	//cin>>tests;
	while(tests--)
	{
		solve();
	}
}

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

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

	int n, k;
	cin >> n >> k;
	int a[n];
	for (int i = 0; i < n; i++)
		cin >> a[i];
	int dp[k + 1];
	memset(dp, 0 , sizeof(dp));
	for (int i = 1; i <= k; i++)
		for (auto x : a)
			if (x <= i)
				if (dp[i - x] == 0)
					dp[i] = 1;
	cout << (dp[k] == 1 ? "First" : "Second");


	return 0;
}

Measured memory_bytes: 4040
using System;
using System.Linq;
using System.Collections.Generic;
public class Hello{
    public static void Main(){
        var wthr = new List<string>(){
            "Sunny","Cloudy","Rainy"
        };
        var s = Console.ReadLine();
        Console.WriteLine(wthr[(wthr.IndexOf(s) + 1) % 3]);
    }
}


Measured memory_bytes: 13024