akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;
int n,a,b,c;
vector<int>l;
int ans=1001001001;
void dfs(vector<int>A){
  if(A.size()==n){
    int now=1001001000;
    int w=0;
    int wc=0;
    int x=0;
    int xc=0;
    int y=0;
    int yc=0;
    
    rep(i,n){     
      if(A[i]==1){
        w+=l.at(i);
        wc++;
      }
      else if(A[i]==2){
        x+=l.at(i);
        xc++;
      }
      else if(A[i]==3){
        y+=l.at(i);
        yc++;
      }
    }
    if(wc>0&&xc>0&&yc>0){
      now=10*(wc+xc+yc-3)+abs(w-a)+abs(x-b)+abs(y-c);
    }
    
    ans=min(ans,now);
    
    return;
  }
  
  rep(v,4){
    A.push_back(v);
    dfs(A);
    A.pop_back();
  }
}
int main() {
  
  cin>>n>>a>>b>>c;
  l=vector<int>(n);
  rep(i,n){
    cin>>l.at(i);
  }
  dfs(vector<int>());   
  cout<<ans<<endl;
}



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

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) reps(i,0,((n)+1))
#define repst(i,s,n) reps(i,s,((n)+1))
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (i==n-1?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ');}}

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<bool> vb;
typedef vector<ld> vld;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

ll n, m;

signed main() {
	cin >> n >> m;
	if (n==1 && m==1) cout << 1 << ln;
	else if (n==1) cout << m-2 << ln;
	else if (m==1) cout << n-2 << ln;
	else if (n==2 || m==2) cout << 0 << ln;
	else cout << (n-2)*(m-2) << ln;
}

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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

void solve() {
    string s;
    cin >> s;
    
    if (s == "ABC") {
        cout << "ARC" << endl;
    } else if (s == "ARC") {
        cout << "ABC" << endl;
    }
}

int main() {
    solve();

    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vpii = vector<pair<int,int>>;
using vpll = vector<pair<ll,ll>>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int) n;i++)
#define rep1(i,m,n) for(int i=(int) m;i<(int) n;i++)
#define fix(n) cout << fixed << setprecision((int)n)

void absll(ll &x) {
    if(x>=0) return ;
    else x=-x; return;
}

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

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

const ll INF = 1LL << 60;

int N;

//DPテーブル
vector<ll> dp(100010);

int main() {
    rep(i,5){
        int a;
        cin>>a;
        if(a==0){
            cout<<i+1<<endl;
        }
    }

}

Measured memory_bytes: 3836
#include <map>
#include <string>
#include <iostream>
using namespace std;
int main(){
    map<char,string>m;
    m['T']="a";
    m['L']="i";
    m['U']="u";
    m['R']="e";
    m['D']="o";
    m['1']="";
    m['2']="k";
    m['3']="s";
    m['4']="t";
    m['5']="n";
    m['6']="h";
    m['7']="m";
    m['8']="y";
    m['9']="r";
    m['0']="w";
    string s,t;
    cin >> s;
    for(int i=0; i<s.length(); i+=2){
        t=s.substr(i,2);
        if(t=="0U"){
          cout << "nn";
        }else
           cout << m[t[0]] << m[t[1]];
    }
    cout << endl;
}


Measured memory_bytes: 3212
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>

using namespace std;

#define INF 2147483647


int main(){

	int N,M;
	scanf("%d %d",&N,&M);

	int** dp = new int*[M+1];
	for(int i = 0; i <= M; i++){
		dp[i] = new int[N+1];
		for(int k = 0; k < N+1; k++)dp[i][k] = INF;
	}

	int distance[N+1],value[M+1];

	for(int i = 1; i <= N; i++){
		scanf("%d",&distance[i]);
	}

	for(int i = 1; i <= M; i++){
		scanf("%d",&value[i]);
	}

	for(int i = 0; i <= M; i++)dp[i][0] = 0;

	for(int day = 1; day <= M; day++){
		for(int city = 1; city <= N; city++){
			if(dp[day-1][city-1] == INF)continue;
			dp[day][city] = min(dp[day][city],min(dp[day-1][city],dp[day-1][city-1]+distance[city]*value[day]));
		}
	}

	printf("%d\n",dp[M][N]);

	return 0;
}

Measured memory_bytes: 5864
#include "bits//stdc++.h"
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
typedef pair<int, int> P;

#define rep(i,n) for (int i = 0; i < (n); i++)
#define ALL(v) v.begin(), v.end()

struct edge {
	int to, cap, rev;
	edge(int to, int cap, int rev) :to(to), cap(cap), rev(rev) {}
};

vector<vector<edge>> G;
vector<bool> used;

void add_edge(int from, int to, int cap) {
	G[from].emplace_back(to, cap, G[to].size());
	G[to].emplace_back(from, 0, G[from].size() - 1);
}

int dfs(int v, int t, int f) {
	if (v == t) return f;
	used[v] = 1;
	for (edge &e : G[v]) {
		if (!used[e.to] && e.cap > 0) {
			int d = dfs(e.to, t, min(f, e.cap));
			if (d > 0) {
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}

int max_flow(int s, int t) {
	int flow = 0;
	used.resize(G.size());
	for (;;) {
		fill(ALL(used), 0);
		int f = dfs(s, t, 1 << 30);
		if (f == 0) return  flow;
		flow += f;
	}
}
bool a[10000010];
bool is_prime[10000010];
int main() {
	memset(is_prime, -1, sizeof(is_prime));
	is_prime[0] = is_prime[1] = 0;
	for (int i = 2; i <= 10000000; i++) {
		if (!is_prime[i]) continue;
		for (int j = i * 2; j <= 10000000; j += i) is_prime[j] = 0;
	}
	int N;
	cin >> N;
	rep(i, N) {
		int x;
		cin >> x;
		a[x] = 1;
	}
	vector<int> even, odd;
	rep(i, 10000001) {
		if (a[i] ^ a[i + 1]) {
			if (i % 2 == 0) even.push_back(i);
			else odd.push_back(i);
		}
	}
	int X = even.size(), Y = odd.size();
	G.resize(X + Y + 2);
	rep(i, X) add_edge(0, i + 1, 1);
	rep(i, Y) add_edge(i + X + 1, X + Y + 1, 1);
	rep(i, X) {
		rep(j, Y) {
			if (is_prime[abs(even[i] - odd[j])]) add_edge(i + 1, j + X + 1, 1);
		}
	}
	int k = max_flow(0, X + Y + 1);
	int ans = k + (X - k) / 2 * 2 + (Y - k) / 2 * 2 + ((X - k) % 2) * 3;
	cout << ans << endl;
}


Measured memory_bytes: 18944
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

int main(){
  double time, N;
  double need, speed,high;

  while(scanf("%lf",&need) != EOF){
    time = need / 9.8;
    high = 4.9 * (time * time);
    N = ceil(high/5 + 1);
    printf("%.lf\n", N);
  }

  return 0;
}

Measured memory_bytes: 0
//AUTHOR - NAVEEN KUMAR(@naveen19991124)
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#inlcude<boost/multiprecision/cpp_dec_float.hpp>
#define ll long long
#define pb push_back
#define f(a) for(ll i = 0;i<a;i++)
#define rep(i,a,b) for(ll i = a;i<b;i++)
#define rrep(i,a,b) for(ll i = a;i>b;i--)
#define v vector<ll>
#define mp make_pair
#define fir first
#define sec second
#define _fast_ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
//using boost :: multiprecision :: cpp_int;
//using boost :: multiprecision :: cpp_dec_float_50;
//using boost :: multiprecision :: cpp_dec_float_100;
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}

ll power(ll a, ll n, ll mod) {ll p = 1;while (n > 0) {if(n%2) {p = p * a; p %= mod;} n >>= 1;
a *= a; a %= mod;} return p % mod;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
int main()
{
    _fast_
    ll t = 1;
   // cin>>t;
    while(t--){
    ll n;
    cin>>n;
    map<ll,ll>mm;
    ll arr[n];
    f(n)
    {
        cin>>arr[i];
        mm[arr[i]]++;
    }
    ll ans = 0;
    for(ll i= 1;i<=n;i++)
    {
        ll val = mm[i];
        if(val>=2)
        {
            ans += (val*(val-1))/2;
        }
    }
 //   cout<<ans<<"\n";
    f(n)
    {
        ll val = mm[arr[i]];
        ll val1 = mm[arr[i]]-1;
        ll x = ans;
        if(val>=2)
        {
            x -= (val*(val-1))/2;
        }
        if(val1>=2)
        {
            x += (val1*(val1-1))/2;
        }
        cout<<x<<"\n";
    }

    }
    return 0;
}

Measured memory_bytes: 16640
#include <stdio.h>
#include <ctype.h>

int main() {

  char ch[1200];
  int i,n;
  n=0;
  char a[1200];

  while(1) {
    scanf("%c",&a[n]);
    if(a[n] == '\n') {
      break;
    }
    ch[n] = a[n];
    if('A' <= a[n] && a[n] <= 'Z') {
      ch[n] = a[n] + 32;
    } else if(a[n] >= 'a' && a[n] <= 'z') {
      ch[n] = a[n] - 32;

    }
    
    
    n = n +1;
    
  }
  
  for(i=0; i<n ; i++) {
    printf("%c" ,ch[i]);
  }
  printf("\n"); 
  return 0;
  
} 



Measured memory_bytes: 2072
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>

using namespace std;

const int MOD = 1000000007;

struct Edge {
    int to;
    int weight;

    Edge(int t, int w) : to(t), weight(w) {}
};

int main() {
    long long N, P;
    cin >> N >> P;
    long long ans = 1;
    // Pを素因数分解する
    for (long long i = 2; i*i <= P; ++i) {
        if (P % i != 0) continue;
        long long cnt = 0;
        while (P % i == 0) {
            P /= i;
            cnt++;
        }
        long long t = cnt / N;
        while (t--) ans = ans * (long long) i;
    }
    if (N == 1) ans = ans * P;
    cout << ans << endl;
    return 0;
}

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

#define for0(i, n) for (int i = 0; i < (int)(n); ++i) 
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define forc(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i) 
#define forr0(i, n) for (int i = (int)(n) - 1; i >= 0; --i) 
#define forr1(i, n) for (int i = (int)(n); i >= 1; --i) 
#define forrc(i,l,r) for (int i= (int)(r); i>= (int)(l); --i)

#define pb push_back
#define fi first
#define se second
#define mp make_pair

#define all(x) (x).begin(), (x).end() 
#define rall(x) (x).rbegin, (x).rend() 


#define tr(c,i) for(__typeof__((c)).begin() i = (c).begin(); i != (c).end(); i++)


#define present(c,x) ((c).find(x) != (c).end())


#define cpresent(c,x) (find(all(c),x) != (c).end())

#define sz(a) int((a).size())

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

using namespace std;


typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef double ld;
typedef long long ll;
typedef unsigned long long int ull;

int MOD=1000000007;

int main(){
  fastio; 
  
  int n;
  cin >> n;
  vector<double> dp(n+1);
  double p_head;
  dp[0]=1;
  for0(coin,n){
    cin >> p_head;
    forrc(i,0,coin+1){
      dp[i]= (i==0?0:dp[i-1]*p_head) + dp[i]*(1-p_head);
    }
  }
  double ans=0;
  for0(i,n+1){
    int tails=n-i;
    if(i>tails){
      ans+=dp[i];
    }
  }
  printf("%0.10lf",ans);
}

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

const long long MOD = 1000000007;
const long long INF = 1LL << 60;

int main()
{
  string S;
  cin >> S;
  for (int i = 0; i < S.size(); i++)
  {
    if (S[i] != 'x')
      S[i] = 'x';
  }
  cout << S << endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1000000007; 
const int INF = 1000000000; //1e9
const int NIL = -1;
const long long LINF = 1000000000000000000; // 1e18
const long double EPS = 1E-10;

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






int main(){
    int A, B, C, K; std::cin >> A >> B >> C >> K;
    int ans(0);
    ans += std::min(A, K);
    K -= ans;
    K -= std::min(B, K);
    ans -= std::min(C, K);
    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 3636
def lcs(s1, s2):
    dp = []
    for s2_k in s2:
        bgn_idx = 0
        for i, cur_idx in enumerate(dp):
            chr_idx = s1.find(s2_k, bgn_idx) + 1
            if not chr_idx:
                break
            dp[i] = min(cur_idx, chr_idx)
            bgn_idx = cur_idx
        else:
            chr_idx = s1.find(s2_k, bgn_idx) + 1
            if chr_idx:
                dp.append(chr_idx)
    return len(dp)


n = int(input())
for _ in range(n):
    x = input()
    y = input()
    print(lcs(x, y))




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

typedef long long ll;

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

    for(int i=0;;i++){
        int x; cin >> x;
        if(x==0) break;
        cout << "Case " << i+1 << ": " << x << endl;
    }
    return 0;
}


Measured memory_bytes: 3180
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {

    public static void main(String[] args) {

        InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
        PrintWriter out = new PrintWriter(System.out);

        try {
    		String strData = br.readLine();
    		String strDat[] = strData.split(" ", -1);

    		int intCard = Integer.parseInt(strDat[0]);
    		int intGate = Integer.parseInt(strDat[1]);

    		int intL[] = new int [intGate];
    		int intR[] = new int [intGate];

    		int intSt;
    		int intEd;

    		intSt = 0;
    		intEd = intCard;

    		for (int i=0 ; i<intGate ; i++) {
        		strData = br.readLine();
        		strDat = strData.split(" ", -1);

        		intL[i] = Integer.parseInt(strDat[0]);
        		intR[i] = Integer.parseInt(strDat[1]);

        		if (intL[i] > intSt) intSt = intL[i];
        		if (intR[i] < intEd) intEd = intR[i];

    		}
    		int ans = 0;

//    		for (int i=0 ; i<intCard ; i++) {
//    		for (int i = intSt-1 ; i <= intEd-1 ; i++) {
//    			int j;
//	    		for (j=0 ; j<intGate ; j++) {
//	    			if (!(intL[j] <= i+1 && i+1 <= intR[j])) break;
//	    		}
//
//	    		if (j == intGate) ans ++;
//    		}

    		ans = intEd - intSt+ 1;
    		if (ans < 0) ans = 0;

    		System.out.println(ans );

    		out.flush();


        } catch (IOException e) {

        }


    }


}

Measured memory_bytes: 47620
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int k = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();

		int ans = 0;

		if (n > k) {
			ans += k * x + (n - k) * y;
		} else {
			ans += n * x;
		}

		System.out.println(ans);
		sc.close();
	}

}


Measured memory_bytes: 23764
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W;
    cin >> H >> W;
    if (H == 1 || W == 1) {
        cout << 1 << endl;
        return 0;
    }
    cout << ((H + 1) / 2) * ((W + 1) / 2) + (H / 2) * (W / 2) << endl;

    return 0;
}


Measured memory_bytes: 256
N,K=map(int,input().split())
Sinput=input()
S=[]
for i in range(len(Sinput)):
    S.append(int(Sinput[i]))
Smax=0
human=[]
humansum=[0]
counter=1
if S[0]==0:
    human.append(0)
for i in range(1,len(S)):
    if S[i-1]!=S[i]:
        human.append(counter)
        counter=1
    else:
        counter+=1
human.append(counter)
if len(human)%2==0:
    human.append(0)

#奇数番目が０の個数、偶数番目が１の個数
for i in range(len(human)):
    humansum.append(human[i]+humansum[i])

if K>=len(human)//2:
    ans=len(S)
else:
    for i in range(len(human)//2-K+1):
        Smax = max(Smax,humansum[(i+K)*2+1]-humansum[i*2])
    ans=Smax
print(ans)

Measured memory_bytes: 50908
N, X, D = map(int, input().split())
if D == 0:
    r = N*(X!=0)+1
else:
    if D < 0:
        X,D=-X,-D
    d=dict()
    for k in range(N+1):
        M = (k*X)%D
        F = (k*X)//D + ((k-1)*k)//2 #(1..k-1)
        L = (k*X)//D + (2*N-k-1)*k//2# (N-k..N-1)
        if M not in d:
            d[M] = list()
        d[M].append((F,-1))
        d[M].append((L,1))
    r = 0
    for m in d:
        fc=f=0
        for x in sorted(d[m]):
            r+=(x[0]-f+1)*(fc<2)*(x[1]>0)
            fc-=x[1]
            f=(fc==1)*x[0]*(x[1]<0)+f*(x[1]>0 or fc!=1)
print(r)

Measured memory_bytes: 91480
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repA(i,a,b) for(int i=a;i<=b;i++)
#define repD(i,b,a) for(int i=b;i>=a;i--)
#define fill(a) memset(a,0,sizeof(a))
#define f first
#define s second
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
int main()
{
    int s,w;
    cin>>s>>w;
    if(w>=s)
        cout<<"unsafe"<<endl;
    else
        cout<<"safe"<<endl;
}



Measured memory_bytes: 3624
// SeeAlso: 

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define MAX 100000
#define NIL -1
#define MOD 1000000007

typedef int _loop_int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define debug(x) cout<<#x<<": "<<x<<endl
#define debig_vec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) rep(i, h) { rep(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }

int main() {
    int m1,m2,d1,d2;
    cin >> m1 >> d1;
    cin >> m2 >> d2;
    print(m1!=m2?"1":"0");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef pair<int, int> P;

signed main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, 0, n){
        cin >> a[i];
    }
    int ans = 1;
    int f = 0;
    rep(i, 1, n){
        if(a[i - 1] < a[i]){
            if(f == 0) f = 1;
            else if(f == -1){
                ans++;
                f = 0;
            }
        }
        if(a[i - 1] > a[i]){
            if(f == 0) f = -1;
            else if(f == 1){
                ans++;
                f = 0;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
//#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e9 + 7;
constexpr ll MOD = 1e9 + 7;

int main()
{
    ciosup;
    string s;
    cin >> s;
    int sz = s.size();
    int ans = 0, pos = 0, prevlen = 0;
    string prev = s;
    while (pos < sz)
    {
        if (pos == 0)
        {
            ++ans;
            ++pos;
            prevlen = 1;
        }
        else if (pos == sz - 2)
        {
            if (prevlen == 1)
            {
                if (s[sz - 2] == s[sz - 1])
                {
                    ++ans;
                    break;
                }
                else
                {
                    if (s[sz - 2] == s[sz - 3])
                    {
                        ans++;
                        break;
                    }
                    else
                    {
                        ans += 2;
                        break;
                    }
                }
            }
            else if (prevlen == 2)
            {
                if (s[sz - 2] == s[sz - 1])
                {
                    ++ans;
                    break;
                }
                else
                {
                    ans += 2;
                    break;
                }
            }
        }
        else if (pos == sz - 1)
        {
            if (prevlen == 2)
            {
                ans++;
                break;
            }
            else if (prevlen == 1)
            {
                if (s[pos] != s[pos - 1])
                {
                    ++ans;
                }
                break;
            }
        }
        else
        {
            if (prevlen > 1)
            {
                prevlen = 1;
                ++ans;
                ++pos;
            }
            else
            {
                if (s[pos - 1] == s[pos])
                {
                    ++ans;
                    pos += 2;
                    prevlen = 2;
                }
                else
                {
                    ++ans;
                    pos++;
                    prevlen = 1;
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 788
require 'set'

def main(str)
  n = str.to_i
  return 0 if n == 1
  factors = Hash.new(0)
  (2..(n**0.5).to_i).each do |p|
    loop do
      break unless n % p == 0
      n /= p
      factors[p] += 1
    end
  end
  factors[n] += 1 if n > 1
  # puts "#{str} #{factors}"
  ans = 0
  factors.each do |_, x|
    i = 1
    loop do
      break if x < i
      x -= i
      i += 1
      ans += 1
    end
  end
  ans
end

unless ENV["TEST"]
  puts(main($stdin.read.chomp))
  exit(0)
end

require 'minitest/autorun'

class TestA < Minitest::Test
  def test_main
    assert_equal(3, main("24"))
    assert_equal(0, main("1"))
    assert_equal(3, main("64"))
    assert_equal(1, main("1000000007"))
    assert_equal(7, main("997764507000"))
    assert_equal(1, main("2"))
    assert_equal(1, main("3"))
    assert_equal(1, main("4"))
    assert_equal(1, main("5"))
    assert_equal(2, main("6"))
  end
end




Measured memory_bytes: 14820
#include <bits/stdc++.h>
using namespace std;
void Main();

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;
template <class T> using Vec = vector<T>;
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define ALL(v) v.begin(), v.end()
#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) a / __gcd(a, b) * b /* 最小公倍数 */

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

void Main() {
    u32 A, B, C, K;
    cin >> A >> B >> C >> K;
    i32 res = 0;
    if (A >= K) {
        res = K;
    } else {
        res = A;
        if (A + B < K) {
            res -= K - (A + B);
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 3652
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


int main(){
    ll A, B, K;
    cin >> A >> B >> K;

    for(ll i = A; i <= B; i++){
        if(i <= A + K - 1 || i >= B - K + 1){
            cout << i << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3572
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let r = read::<i32>(&mut stdin_lock, &mut buf, b' ');
    let d = read::<i32>(&mut stdin_lock, &mut buf, b' ');
    let x = read::<i32>(&mut stdin_lock, &mut buf, b'\n');
    let mut ans: i32 = x;
    for _ in 0..10 {
        ans = r * ans - d;
        println!("{}", ans);
    }
}


Measured memory_bytes: 4352
import math
 
N = 1000001
 
spf = [*range(N)]
i = 2
while i * i < N:
  if spf[i] == i:
    for j in range(i * i, N, i):
      if spf[j] == j:
        spf[j] = i
  i += 1
  
r = 'pairwise'
 
input()
d = None
u = set()
for x in map(int, input().split()):
  d = math.gcd(d or x, x);
  s = set()
  while x > 1:
    p = spf[x]
    if p in u:
      r = 'setwise'
    s.add(p)
    x //= p
  u |= s
print('not' if d > 1 else r, 'coprime')


Measured memory_bytes: 179380
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
  string a, b;
  int count = 0;
  cin >> a >> b;
  for (int i = 0; i<a.length(); i++){
    if (a[i] != b[i]){
      count++;
    }
    
  }
  cout << count;
  return 0;
}

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

using namespace std;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
int n;
cin>>n;
vector<int> a(1e5+100);
int i,j,k;
for(i=0;i<=100011;i++) a[i]=0;
k=0;
for(i=0;i<n;i++){
    cin>>j;
    j=j+5;
    a[j-1]++;
    a[j]++;
    a[j+1]++;
    k=max(k,a[j-1]);
    k=max(k,a[j]);
    k=max(k,a[j+1]);
}
cout<<k;

}


Measured memory_bytes: 640
"use strict"

let N = require('fs').readFileSync('/dev/stdin', 'UTF-8')

let value_1 = 0
for(let i=9;i>0;i--){
    if(N % i == 0){
        value_1 = i
        break
    }
}

if(value_1 > 0 && N % value_1 == 0 && N / value_1 < 10){
    console.log("Yes")
}else{
    console.log("No")
}


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

// chmin, chmax関数
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

// Yes-Noを出力する問題で楽をする
void Ans(bool f){
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main(){
    string s; cin >> s;
    s[3] = '8';
    cout << s << endl;
    return 0;
}

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

typedef long long ll;

ll gcd(ll a, ll b){
return a != 0 ? gcd(b % a, a) : b;
}

int main() {
ll a, b;
while(cin >> a >> b)
cout << gcd(a, b) << " " << a / gcd(a, b) * b << endl;}

Measured memory_bytes: 3076
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll inf=1e9+7;
ll a[2000];
ll b[2000];
int main()
{
    //freopen("input.txt","r",stdin);
    ios::sync_with_stdio(false);
    ll n;cin>>n;
    for(int i=0;i<n;i++) cin>>a[i]>>b[i];

    for(int i=1;i<n;i++)
    {
        if(a[i]<a[i-1]||b[i]<b[i-1])
        {
            ll t=max(ceil((long double)a[i-1]/a[i]),ceil((long double)b[i-1]/b[i]));
            a[i]*=t;
            b[i]*=t;
        }
    }
    cout<<a[n-1]+b[n-1]<<endl;
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define pb push_back
#define endl '\n'
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 2222222222222222222LL;
const ll mod = 1000000007LL;

ll n = 0, m = 0, ans = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok;
ll dx[9] = { 0,1,-1,0,0,1,1,-1,-1 }, dy[9] = { 0,0,0,1,-1,1,-1,1,-1 };
#pragma endregion
#define MAX 222222


ll a[MAX];

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


  cin >> n;
  rep(i, n) cin >> a[i];
  ll up = inf, low = 0;
  while (up - low > 1) {
    ll mid = (up + low) / 2;
    bool ok = true;
    vpll vec;
    vec.pb(make_pair(1, 1));
    ll cur = 1;
    FOR(i, 1, n) {
      //cout << i << " " << cur - 1 << " " << vec[cur - 1].first << " " << vec[cur - 1].second << endl;
      if (a[i - 1] < a[i]) continue;
      while (cur != 1 && vec[cur - 1].first > a[i]) {
        vec.pop_back();
        cur--;
      }
      if (vec[cur - 1].first < a[i]) {
        if (mid == 1) {
          ok = false; break;
        }
        vec.pb(make_pair(a[i], 2));
        cur++;
        continue;
      }

      vec[cur - 1].second++;
      ll pos;
      while (vec[cur - 1].second > mid) {
        if (cur == 1) {
          ok = false;
          break;
        }
        pos = vec[cur - 1].first;
        vec.pop_back();
        cur--;
        if (vec[cur - 1].first == pos - 1) {
          vec[cur - 1].second++;
        }
        else {
          if (mid == 1) {
            ok = false; break;
          }
          vec.pb(make_pair(pos - 1, 2));
          cur++;
          break;
        }
      }
      if (!ok) break;
    }
    if (ok) up = mid;
    else low = mid;
  }
  cout << up << endl;

  return 0;
}

Measured memory_bytes: 1792
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)

	l := make([]int, n)
	sum := 0
	for i := 0; i < n; i++ {
		fmt.Scan(&l[i])
		sum += l[i]
	}

	sort.Ints(l)

	max := l[len(l)-1]
	if sum - max > max {
		fmt.Println("Yes")
		return
	}
	fmt.Println("No")
}

Measured memory_bytes: 512
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    template<typename T>
    vector<T> read_vec(size_t n){
        vector<T> tmp(n);
        for(size_t i = 0; i < n; i++){
            cin >> tmp[i];
        }
        return tmp;
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
};

constexpr int MOD = 1000000007;

int main(){
    Stream io;

    int N;
    string S;
    io.read(N, S);
    int ans = 0;
    int x = 0;
    for(int i = 0; i < N; i++){
        if(S[i] == 'I') x++;
        else x--;
        ans = max(ans, x);
    }
    cout << ans;
    return 0;
}

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<tuple<string, int, int>> as;
    for (int i = 0; i < n; i++) {
        string a;
        int b;
        cin >> a >> b;
        as.emplace_back(a, -b, i + 1);
    }
    sort(as.begin(), as.end());
    for (int i = 0; i < n; i++) {
        cout << get<2>(as[i]) << '\n';
    }
}


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

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

    long long a[n+1];
    long long b[n+1];
    for(long long i = 1; i <= n; i++){
        cin >> a[i];
        b[i] = 0;
    }

    
    long long count = 0;

    for(long long i = n; i >= 1; i--){
        long long j = i;
        long long sum = 0;
        while(j <= n){
            sum = sum + b[j];
            j = j + i;
        }
        
        if((sum%2) != (a[i]%2)){
            b[i] = 1;
            count++;
        }
    
    }

    printf("%lld\n", count);

    if(count >= 1){
        for(long long i = n; i >= 1; i--){
            if(b[i] == 1){
                printf("%lld ", i);
            }
        }
        printf("\n");
    }

    return 0;
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long int ll;
using namespace std;
int main()
{
  int n;
  cin >> n;
  if(n*100%108 == 0){
    cout << n*100/108 << endl;
  }else{
    double x1 = (double)n/1.08;
    double x2 = (double)(n + 1)/1.08 - 0.00000000001;
    if((int)x1 != (int)x2){
      cout << (int)x2 << endl;
    }else{
      cout << ":(" << endl;
    }
  }
}


Measured memory_bytes: 384
/* abc_170_c */

#include<stdio.h>
#include<stdlib.h>
 
int main()
{
  int X,N;
  int p[100];
  int i,j,k;
  int t,u;
  int q,r,s;
  scanf("%d",&X);
  scanf("%d",&N);
  for (i=0;i<N;i++){
    scanf("%d",&p[i]);
  }
  /*for (i=0;i<N;i++){
    for (j=i+1;j<N;j++){
      if(p[i]>p[j]){
        t=p[i];
        p[i]=p[j];
        p[j]=t;
      }
    }
  }*/
  /*for(j=0;;j++){
    for(i=0;i<N;i++){
      u=0;
      if( ((X+j)==p[i]) ) u=1;
      if( (X+j)<p[i] ) {
        q=X+j;
        goto loopend1;
      }
      if(u==1) break;
    }
  }
  loopend1:
  for(j=0;;j++){
    for(i=0;i<N;i++){
      u=0;
      if( ((X-j)==p[i]) ) u=1;
      if( (X-j)<p[i] ){
        r=X-j;
        goto loopend2;
      }
    if(u==1) break;
    }
  }
  loopend2:*/
  q=X;
  r=X;
  for(j=0;;j++){
    u=0;
    for(i=0;i<N;i++){
      if(X+j==p[i]){
        u=1;
        break;
      }
    }
    if(u==0){
      q=X+j;
      break;
    }
  }
  for(j=0;;j++){
    u=0;
    for(i=0;i<N;i++){
      if(X-j==p[i]){
        u=1;
        break;
      }
    }
    if(u==0){
      r=X-j;
      break;
    }
  }
  if( (q-X) < (X-r) ){
    s=q;
  } else if( (q-X) > (X-r) ){
    s=r;
  } else if( (q-X) == (X-r) ){
    s=r;
  }
  printf("%d\n",s);
  return 0;
}


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

string s;
int n;

int main() {
	if (fopen("input.txt", "r")) 
		freopen("input.txt", "r", stdin);

	cin >> s;
	n = s.length(); s = " " + s;

	long long res = 0, Count = 0;
	for (int i = 1; i <= n; ++i) {
		if (s[i] == 'W') res += Count;
		else Count++;
	}
	cout << res << '\n';

	return 0;
}

Measured memory_bytes: 772
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<string>
#include<sstream>
#include<cmath>
#include<climits>
#include<algorithm>
#include<bitset>
#include<set>
#include<stack>
#include<queue>
#include<iomanip>
#include<memory.h>
#include<complex>
using namespace std;  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef tuple<int,int> tii;
#define rep(i,n) for(ll i=0;i<(n);i++)  
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second  
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
const double PI = M_PI;  
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define SHOWARRAY(ar,i,j) REP(a,i)REP(b,j)cerr<<ar[a][b]<<((b==j-1)?((a==i-1)?("\n\n"):("\n")):(" "))
#define DIV int(1e9+7)
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}

 /* Coding Space*/
ll f(ll b,ll n){
  //SHOW(b,n);
  if(n < b)
    return n;
  else
    return f(b,n/b)+(n%b);
}

int main(){
  ll n,s; cin >> n >> s;
  if(s == n){cout << n+1 << endl; return 0;}
  if(n < s){cout << -1 << endl; return 0;}
  for(ll i = 2; i*i <= n; i++)
    if(f(i,n) == s){
      cout << i << endl; return 0;
    }
  ll ans = LLINF;
  for(ll s1 = 1; s1*s1 <= n; s1++){
    ll s2 = s - s1;
    if(s2 < 0) continue;
    if(n-s2 >= 0 && (n-s2)%s1 == 0){
      ll b = (n-s2)/s1;
      if(b > s1 && b > s2)
        ans = min(ans,b);
    }
  }
  cout <<(ans==LLINF?-1:ans) << endl;
}

Measured memory_bytes: 256
#pragma region head
    #include <bits/stdc++.h>
    using namespace std;
    using ll = long long;
    using vi = vector<int>;
    using vll = vector<ll>;
    using pi = pair<int, int>;
    using pll = pair<ll,ll>;
    template <class T> using vv = vector<vector<T>>;
    #define rep(i,n) for(int i = 0; i < (int)(n); i++)
    #define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
    #define rrep(i,n) for(int i = (int)(n)-1; i >= 0; i--)
    #define rrepi(i,a,b) for(int i = (int)(b)-1; i >= (int)(a); i--)
    #define all(x) (x).begin(), (x).end()
    #define rall(x) (x).rbegin(), (x).rend()    
    #define bit(n) (1LL<<(n))
    template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
    template<class T> inline bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
    const int INF = 1002003004;
    const ll LINF = 1002003004005006007ll;
    struct preprocess{preprocess()
    {cin.tie(nullptr);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}}____;
#pragma endregion head

#pragma region library
const int MOD = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  // for prime MOD
  mint inv() const {
    return pow(MOD-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
ostream& operator<< (ostream& os, const mint& value) {
  os << value.x;
  return os;
}
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < MOD);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
}; 

#pragma endregion library

int main(){
    int s; cin >> s;
    mint ans = 0;
    combination cb(10000);
    repi(len,1,2000){
        int tot = s - len*3;
        if(tot<0) continue;
        ans += cb(tot+len-1, tot);
    }
    cout << ans << '\n';
    

}


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

#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
string s;
int main()
{
    fastio;
    long long a=0,b=0,c,d,e,f=9999999,l,g,m,n,k,i,j,t,p,q;
    cin>>a>>b;
    for(i=a;i<=a+2019&&i<=b;i++){
        for(j=i+1;j<=i+2019&&j<=b;j++){
            if(i!=j){
                d=i*j;
                d%=2019;
                if(d<f)f=d;
            }
        }
    }
    cout<<f<<'\n';
    return 0;
}


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

using namespace std;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)((x).size()))

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef long long int64;
typedef unsigned int uint;
typedef unsigned long long uint64;

#define gi(x) ((x) = F())
#define gii(x, y) (gi(x), gi(y))
#define giii(x, y, z) (gii(x, y), gi(z))

int F()
{
	char ch;
	int x, a;
	while (ch = getchar(), (ch < '0' || ch > '9') && ch != '-');
	if (ch == '-') ch = getchar(), a = -1;
	else a = 1;
	x = ch - '0';
	while (ch = getchar(), ch >= '0' && ch <= '9')
		x = (x << 1) + (x << 3) + ch - '0';
	return a * x;
}

int w[100010];

int n, m;

int main()
{
	gii(n, m);
	for (int i = 1; i <= m; ++i)
	{
		int u, v;
		gii(u, v);
		w[u] ^= 1;
		w[v] ^= 1;
	}
	for (int i = 1; i <= n; ++i)
	{
		if (w[i])
		{
			puts("NO");
			return 0;
		}
	}
	puts("YES");
	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
  
int main(void)
{
    char num[1000];
    int count,tmp,sum;
    while(1){
        scanf("%s", num);
        if(num[0]=='0') break;
        count=0;
        sum=0;
        while(1){
            if(num[count]=='\0') break;
            sum+=(int)num[count++]-48;
        }
        printf("%d\n",sum);
    }
    return 0;   
}   

Measured memory_bytes: 536
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ALL(a) a.begin(),a.end()

const double EPS = 1e-6;

int main(){
    string S, T; cin >> S >>T;
    ll nt = T.size();
    ll ns = S.size();
    unordered_map<char,int> mps, mpt;
    for(int i = 0; i < S.size(); i++) mps[S[i]]++;
    for(int i = 0; i < T.size(); i++) mpt[T[i]]++;
    double max = 0;
    //vector<char> ans;
    for(auto e: mpt){
        if(mps[e.first] == 0){
            cout << -1 << endl;
            return 0;
        }
        /* if(max + EPS < (double)e.second / (double)mps[e.first]){
            max = (double)e.second / (double)mps[e.first];
            ans.clear;
            ans.push_back(e.first);
        }else if(max + EPS > (double)e.second / (double)mps[e.first] && max - EPS < (double)e.second / (double)mps[e.first]){
            ans.push_back(e.first);
        } */
    }
    vector<int> tmp[26];
    for(int i = 0 ; i < S.size(); i++){
        int x = S[i] - 'a';
        tmp[x].push_back(i);
    }
    ll ans = 0;
    ll pre = 0;
    for(int i = 0; i < T.size(); i++){
        int x = T[i] - 'a';
        auto it = lower_bound(tmp[x].begin(), tmp[x].end(), pre);
        if(it == tmp[x].end()){
            ans += ns - pre + 1;
            ans += tmp[x][0];
            pre = tmp[x][0];
        }else{
            ans += *it -pre + 1;
            pre = *it;
        }
        pre++;
        //cout << " pre " <<  pre << "ans " << ans <<endl;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1216
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<queue>
#include<functional>
#include<cmath>
#include<algorithm>
typedef  long long ll;

int main() {
	int n;
	bool ok = false;
	ll ans = 0;
	std::cin >> n;
	ll ar[10000] = {};
	for (int i = 0; i < n; i++) {
		std::cin >> ar[i];
	}
	for (int i = 0; i < n; i++) {
		while (ok==false) {
			if (ar[i] % 2 != 0) {
				ok = true;
			}
			if (ok == false) {
				ar[i] = ar[i] / 2;
				ans++;
			}
		}
		ok = false;
	}
	std::cout << ans << std::endl;
}


Measured memory_bytes: 384
#include <limits>
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <unordered_map>

using namespace std;

int main()
{
    int A,B;
    cin >> A >> B;
    int c = 0;
    for(int i = A; i <= B; ++i)
    {
        if(i/10000 == i%10 && i/1000%10 == i/10%10) c++;
    }
    cout << c << '\n';
    return 0;
}


Measured memory_bytes: 256
###さらに綺麗に！！！
def y_solver(tmp):
    l=len(tmp)
    rev=[int(i) for i in tmp[::-1]+"0"]
    ans=0
    for i in range(l):
        num=rev[i]
        next_num=rev[i+1]
        if (num>5) or (num==5 and next_num>=5):
            rev[i+1]+=1
        ans+=min(num,10-num)  
    last=rev[l]
    ans+=min(last,10-last)
    return ans
  
s=input()
ans=y_solver(s)
print(ans)

Measured memory_bytes: 122980
#include<bits/stdc++.h>
#define INF 1000000001
using namespace std;

int main()
{
  int N,M,R;scanf("%d %d %d",&N,&M,&R);
  int r[R];for(int i=0;i<R;i++){scanf("%d ",&r[i]);r[i]--;}
  vector<vector<int>> AB(N,vector<int>(N,INF));
  for(int A,B,C,i=0;i<M;i++)
  {
    scanf("%d %d %d",&A,&B,&C);
    A--;B--;AB[A][B]=C;AB[B][A]=C;
  }
  for(int k=0;k<N;k++)for(int i=0;i<N;i++)for(int j=0;j<N;j++)AB[i][j]=min(AB[i][j],AB[i][k]+AB[k][j]);
  sort(r,r+R);int answer=INF;
  do{
    int ans=0;
    for(int i=1;i<R;i++)ans+=AB[r[i-1]][r[i]];
    answer=min(ans,answer);
  }while(next_permutation(r,r+R));
  printf("%d",answer);
}

Measured memory_bytes: 3952