akhauriyash/Code-Regression huggingface dataset:
#ifndef DEBUG
#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const Ld pi = M_PI;
const Int MOD = 1000000007;
const Int INF = 1LL << 62;

Int Floor(Int a, Int b) {
    return (a - (a % b)) / b;
}

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

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

    Int R, C, K;
    cin >> R >> C >> K;
    vector rc(R, vector<Int>(C, 0));
    for (Int i = 0; i < K; i++) {
        Int r, c, v;
        cin >> r >> c >> v;
        r--;
        c--;

        rc[r][c] = v;
    }

    const int state = 4;

    vector dp(R + 5, vector(C + 5, vector<Int>(state, 0)));

    for (Int i = 0; i < R; i++) {
        for (Int j = 0; j < C; j++) {
            for (Int k = 2; k >= 0; k--) {
                chmax(dp[i][j][k + 1], dp[i][j][k] + rc[i][j]);
            }

            for (Int k = 0; k < state; k++) {
                chmax(dp[i + 1][j][0], dp[i][j][k]);
                chmax(dp[i][j + 1][k], dp[i][j][k]);
            }
        }
    }

    Int ans = 0;
    for (Int i = 0; i < state; i++) {
        chmax(ans, dp[R - 1][C - 1][i]);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 708848
#include<stdio.h>
#include<math.h>
int main(){
    int n,ax,ay,bx,by,cx,cy,m,bax,bay,cax,cay,u;
    double t,x,y,p,q,r,s;
    scanf("%d%d%d%d",&ax,&ay,&bx,&by);
    scanf("%d",&n);
    bax=bx-ax;
    bay=by-ay;
    while(n--){
        scanf("%d%d",&cx,&cy);
        cax=cx-ax;
        cay=cy-ay;
        t=(bax*cax+bay*cay)/(pow(bax,2)+pow(bay,2));
        x=ax+t*bax;
        y=ay+t*bay;
        m=-(cx-x)*bay+(cy-y)*bax;
        u=bax*cax+bay*cay;
        p=pow(u,2);
        q=(pow(bax,2)+pow(bay,2))*(pow(cax,2)+pow(cay,2));
        if(p==q&&u<0&&(ax!=cx||ay!=cy)){
            puts("ONLINE_BACK");
        }else if(p==q){
            r=pow(bax,2)+pow(bay,2);
            s=pow(cax,2)+pow(cay,2);
            if(s>r){
                puts("ONLINE_FRONT");
            }else{
                puts("ON_SEGMENT");
            }
        }else if(m>0){
            puts("COUNTER_CLOCKWISE");
        }else if(m<0){
            puts("CLOCKWISE");
        }
    }
    return 0;
}

Measured memory_bytes: 584
#include <stdio.h>

#include <algorithm>

using namespace std;

#define fi first
#define se second
#define long long long
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
int main()
{
    // ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	// freopen("input.in", "r", stdin);
	long a[3];
	long k;
	scanf("%lld %lld %lld %lld", &a[0], &a[1], &a[2], &k);
	printf("%lld\n", (k%2 == 0)? a[0]-a[1] : a[1]-a[0]);

}











Measured memory_bytes: 128
#include<iostream>

using namespace std;
//Aの倍数はいくつ足してもAの倍数
int main(){
    int A,B,C,amari; cin >>A >>B >>C;

    for(int i=1; i<=B; i++){
      amari = (i*A) % B;
      if(amari == C){
        cout << "YES" << endl;
        return 0;
      }
    }

    cout <<"NO"<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef tuple<ll, ll, ll> ti;
ll mod=1E9+7;
 
#define REP(a,b,c) for(ll a=b;a<(c);a++)
#define PER(a,b,c) for(ll a=b;a>=(c);a--)
 
ll ii(){ ll x; cin >> x; return x; }
string is(){ string x; cin >> x; return x; }
ld id(){ ld x; cin >> x; return x; }
void oi(ll x){ cout << x; }
void od(ld x){ cout << fixed << setprecision(10) << x; }
void os(string x){ cout << x; }
void oe(){ cout << endl; }
void oie(ll x){ oi(x); oe(); }
void ode(ld x){ od(x); oe(); }
void ose(string x){ os(x); oe(); }

int main(){
    ll ret = 0;
    ll N = ii();
    vector<ll> A;
    REP(i,0,N){
        ll a = ii();
        ret ^= a;
        A.push_back(a);
    }
    REP(i,0,A.size()){
        oi(ret ^ A[i]);
        if(i!=A.size()-1){
            os(" ");
        }
    }
    oe();
    return 0;
}

Measured memory_bytes: 5228
def main():
  M=10**9+7
  a,b,c,d=map(int,input().split())
  n=c+d+2
  fac=[0]*(n+1)
  fac[0]=lt=1
  for i in range(1,n+1):fac[i]=lt=lt*i%M
  inv=lambda n:pow(fac[n],M-2,M)
  f=lambda r,c:fac[r+c+2]*inv(c+1)*inv(r+1)-c-r-2
  print((f(c,d)-f(c,b-1)-f(a-1,d)+f(a-1,b-1))%M)
main()

Measured memory_bytes: 82164
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
using ll = long long;
#define rep(i, j, n) for(int i = (j); i < (n); ++i)
#define rrep(i, j, n) for(int i = (n) - 1; (j) <= i; --i)

constexpr ll MOD = 1000000007;
constexpr ll INF = 1LL << 60;



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

	string s; cin >> s;
	int a = 0, b = 0;
	rep(i, 0, (int)s.size()) {
		(s[i] == '0' ? a : b) += 1;
	}
	cout << min(a, b) * 2 << endl;
	return 0;
}

Measured memory_bytes: 3756
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define perm(c) sort(ALL(c));for(bool c##p=1;c##p;c##p=next_permutation(ALL(c)))
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
typedef vector<ll> vec;
typedef vector<vector<ll>> vec2;
typedef vector<vector<vector<ll>>> vec3;
ll MOD = 1e9 + 7;
ll devc(ll x, ll y) { return 1 + (x - 1) / y; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    string w;
    cin >> w;
    map<char, ll> mp;
    for(auto c : w) ++mp[c];
    for (char c = 'a'; c <= 'z'; ++c) if(mp[c] % 2){
        print("No");
        return 0;
    }

    print("Yes");

    return 0;
}

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


def main():
    n, k = map(int, input().split())
    s = input()
    ans = ''

    for i, si in enumerate(s):
        if i == k - 1:
            ans += si.lower()
        else:
            ans += si

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
n = int(input())
f = [list(map(int,input().split())) for i in range(n)]
p = [list(map(int,input().split())) for i in range(n)]
ans = -float("inf")
for i in range(1,2**10):
    now = 0
    for j in range(n):
        cou = 0
        for k in range(10):
            if (i >> k & f[j][k]) == 1:
                cou += 1
        now += p[j][cou]
    ans = max(ans,now)
print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {


    public static void main(String args[])
    {
        Scanner sc=new Scanner(System.in);
        long a =sc.nextLong();
        String s=sc.next();
        long b=(s.charAt(0)-'0')*100+(s.charAt(2)-'0')*10+(s.charAt(3)-'0');
        long c=(a*b)/100;
        System.out.println(c);

    }
}


Measured memory_bytes: 35772
#include<bits/stdc++.h>
using namespace std;
int n,i,j,a,c;
string s;
int main()
{
  for(cin>>s;i<s.size();i++){
    for(c=0,j=i;j<s.size()&&(s[j]=='A'||s[j]=='C'||s[j]=='G'||s[j]=='T');j++)c++;
    a=max(a,c);
  }
  cout<<a;
}

Measured memory_bytes: 256
import math


def main(K=None):
    if not K:
        K = int(input())
    ans = 0
    for i in range(1, K+1):
        for j in range(1, K+1):
            for k in range(1, K+1):
                ans += math.gcd(math.gcd(i, j), k)
    print(ans)
    return ans


if __name__ == "__main__":
    # assert main(2) == 9
    # assert main(200) == 10813692
    main()


Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define ULL(...) ull __VA_ARGS__;in(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;in(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;in(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;in(__VA_ARGS__)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);in(name)
#define vv(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define VV(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__));in(name)
#define vvv(type,name,h,w,...) vector<vector<vector<type>>>name(h,vector<vector<type>>(w,vector<type>(__VA_ARGS__)))
inline int scan(){ return getchar(); }
inline void scan(int &a){ scanf("%d", &a); }
inline void scan(unsigned &a){ scanf("%u", &a); }
inline void scan(long &a){ scanf("%ld", &a); }
inline void scan(long long &a){ scanf("%lld", &a); }
inline void scan(unsigned long long &a){ scanf("%llu", &a); }
inline void scan(char &a){ cin >> a; }
inline void scan(float &a){ scanf("%f", &a); }
inline void scan(double &a){ scanf("%lf", &a); }
inline void scan(long double &a){ scanf("%Lf", &a); }
inline void scan(vector<bool> &vec){ for(unsigned i = 0; i < vec.size(); i++) { int a; scan(a); vec[i] = a; } }
inline void scan(string &a){ cin >> a; }
template<class T> inline void scan(vector<T> &vec);
template<class T, size_t size> inline void scan(array<T, size> &vec);
template<class T, class L> inline void scan(pair<T, L> &p);
template<class T, size_t size> inline void scan(T (&vec)[size]);
template<class T> inline void scan(vector<T> &vec){ for(auto &i : vec) scan(i); }
template<class T, size_t size> inline void scan(array<T, size> &vec){ for(auto &i : vec) scan(i); }
template<class T, class L> inline void scan(pair<T, L> &p){ scan(p.first); scan(p.second); }
template<class T, size_t size> inline void scan(T (&vec)[size]){ for(auto &i : vec) scan(i); }
template<class T> inline void scan(T &a){ cin>>a; }
inline void in(){}
template <class Head, class... Tail> inline void in(Head &head, Tail&... tail){ scan(head); in(tail...); }
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);}
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; }
using Graph = vector<vector<int>>;
/* 4方向への隣接頂点への移動を表すベクトル */
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

const long long INF = 1LL << 60;
int main(){
    LL(A,B);

    if(A<=5){
        cout << 0 << endl;
        return 0;
    } else if(A >=13) {
        cout << B << endl;
        return 0;

    } else {
        cout << B/2 << endl;
    }
}

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

namespace ABC162_C
{
    class Program
    {
        static void Main(string[] args)
        {
            var K = int.Parse(Console.ReadLine());
            var ans = 0;
            int n1 = 0;
            for (int i = 1; i <= K; i++)
            {
                for (int j = 1; j <= K; j++)
                {
                    if (i != 1 && j != 1)
                    {
                        if (i > j)
                        {
                            n1 = Gcd(i, j);
                        }
                        else if (i < j)
                        {
                            n1 = Gcd(j, i);
                        }
                        else
                        {
                            n1 = i;
                        }
                    }
                    for (int k = 1; k <= K; k++)
                    {
                        if (i == 1 || j == 1 || k == 1)
                        {
                            ans += 1;
                            continue;
                        }

                        if (n1 > k)
                        {
                            ans += Gcd(n1, k);
                        }
                        else if (n1 < k)
                        {
                            ans += Gcd(k, n1);
                        }
                        else
                        {
                            ans += n1;
                        }
                    }
                }
            }
            Console.WriteLine(ans);
        }

        static int Gcd(int a, int b)
        {
            if (a % b == 0)
            {
                return b;
            }
            return Gcd(b, a % b);
        }
    }
}


Measured memory_bytes: 17508
//
//  main.cpp
//  CoderTest
//
//  Created by yuya on 2019/07/25.
//  Copyright © 2019 yuya. All rights reserved.
//

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;


int main()
{
    
    int N,D;
    cin >> N >> D;
    vector<vector<double>> X(N);
    for(int i=0;i<N;i++){
        X[i].assign(D, 0);
        for(int j=0;j<D;j++){
            cin >> X[i][j];
        }
    }
    
    
    double dist=0;
    int cnt=0;
    for(int i=0;i<N-1;i++){
        for(int j=i+1;j<N;j++){
            dist=0;
            for(int k=0;k<D;k++){
                dist += pow(X[i][k] - X[j][k] , 2);
            }
            dist = sqrt(dist);
            if(dist == floor(dist)) cnt++;
        }
    }
    
    cout << cnt << endl;
    
    return 0;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
INF = 10**18
d = [[INF]*n for _ in range(n)]
for i in range(n): d[i][i] = 0
A = [0]*m
B = [0]*m
C = [0]*m
for i in range(m):
    a,b,c = map(int,input().split())
    a -= 1
    b -= 1
    A[i] = a
    B[i] = b
    C[i] = c
    d[a][b] = c
    d[b][a] = c

for k in range(n):
    for i in range(n):
        for j in range(n):
            d[i][j] = min(d[i][j], d[i][k]+d[k][j])

ans = 0
for i in range(m):
    if d[A[i]][B[i]] < C[i]: ans += 1
print(ans)

Measured memory_bytes: 9308
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string.h>
#include<string>
#include<set>
#include<vector>
#include<bitset>
#include<map>
#define N 100005
#define ll long long
#define oo 100000000
#define For(i,x,y) for(int i=x;i<=y;i++)
#define Rep(i,x,y) for(int i=x;i>=y;i--)
#define Forn(i,x,y) for(int i=x;i<y;i++)
using namespace std;
inline int read(){int x=0,f=0;char ch=getchar();for(;ch<'0'||ch>'9';ch=getchar()) if(ch=='-') f=1;for(;ch>='0'&&ch<='9';ch=getchar()) x=(x<<1)+(x<<3)+ch-48;return f?-x:x;}
inline void write(ll x){if(x<10) putchar(x+48);else write(x/10),putchar(x%10+48);}
inline void writeln(ll x){if(x<0) putchar('-'),x=-x;write(x);putchar('\n');}
int n,a[N],x;
ll sum;
inline bool cmp(int x,int y){return x>y;}
int main(){
	n=read();For(i,1,n) a[i]=read();
	sort(a+1,a+1+n,cmp);
	x=a[1];
	For(i,2,n){
		if(x==a[i]){
			if(!sum) sum=a[i],x=0;
			else{
				sum=1ll*sum*a[i];
				writeln(sum);
				return 0;
			}
		}else x=a[i];
	}
	puts("0");
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <algorithm>
const int mod=1e9+7;
using LL=long long;
using std::cout;using std::endl;using std::cin;
using std::vector;using std::string;using std::set;using std::multiset;
using std::pair;using std::map;
using std::min;using std::max;
using std::make_pair;
std::ostream& operator<<(std::ostream& os,std::map<int,int>& obj){for(std::map<int,int>::iterator itr=obj.begin();itr!=obj.end();itr++){os<<itr->first<<"^"<<itr->second<<" ";}return os;}
std::ostream& operator<<(std::ostream& os,std::vector<std::map<int,int>>& obj){for(auto itr=obj.begin();itr!=obj.end();itr++){os<<*itr<<std::endl;}return os;}
std::ostream& operator<<(std::ostream& os,std::vector<int>& obj){for(auto itr=obj.begin();itr!=obj.end();itr++){os<<*itr<<" ";}return os;}

namespace ndifix{
template<class T> void sort(T &v){std::sort(v.begin(),v.end());}
}

int main(){
  int n;cin>>n;
  vector<int> l(n);for(int i=0;i<n;i++)cin>>l[i];
  ndifix::sort(l);
  int sum=0;
  for(int i=0;i<n-1;i++)sum+=l[i];
  if(sum > l.back())cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


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

int main() {
  int n;
  cin >> n;
  int x[n];
  for (int i=0; i<n; i++) {
    cin >> x[i];
  }
  int mini = -1;
  for (int i=0; i<100; i++) {
    int sum = 0;
    for (int j=0; j<n; j++) {
      sum += (i+1-x[j])*(i+1-x[j]);
    }
    if (sum < mini || mini == -1) {
      mini = sum;
//      cout << sum << endl;
    }
  }
  cout << mini << endl;
}




Measured memory_bytes: 3592
#include<stdio.h>
#define MAX 500
#define INFTY  100000000
int main(){
  int n, i, j,k,c,u,v,minv;
  int M[MAX][MAX],d[MAX],vis[MAX];


  scanf("%d", &n);
  for ( i = 0; i< n; i++ ){
    for ( j = 0; j < n; j++ ){
      M[i][j] = INFTY;
    }
  }

  for ( i = 0; i < n; i++ ){
    scanf("%d %d", &u, &k);
    for ( j = 0; j < k; j++ ){
      scanf("%d %d", &v, &c);
      M[u][v] = c;
    }
  }

  for ( i = 0; i < n; i++ ) {
    d[i] = INFTY;
    vis[i] = 0;
  }

  d[0] = 0;

  while(1){
    minv = INFTY;
    u = -1;
    for ( i = 0; i < n; i++ ){
      if ( minv > d[i] && !vis[i] ){
 u = i;
 minv = d[i];
      }
    }
    if ( u == -1 ) break;
    vis[u] = 1;
    for ( v = 0; v < n; v++ ){
      if ( !vis[v] && M[u][v] != INFTY ){
 if ( d[v] > d[u] + M[u][v] ){
   d[v] = d[u] + M[u][v];
 }
      }
    }
  }

  for ( i = 0; i < n; i++ ){
    printf("%d %d\n", i, (d[i]==INFTY?-1:d[i]));
  }

  return 0;
}


Measured memory_bytes: 2084
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
typedef long long ll;
ll MOD = 1e9+7;

using namespace std;

int main()
{
	int n;
	int keta1,keta2;
	int ans=0;
	
	cin>>n;
	keta1=n%10;
	keta2=n/100;
	if(keta1==keta2)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

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

using namespace std;

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

	int as = s.size();

	int num = 0;
	for (int i = 0; i < as-1; ++i) {
		if (s[i] != s[i + 1]) {
			num = num + 1;
		}
	}
	cout << num << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V) {
os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
    return os << "(" << P.first << "," << P.second << ")";}

// #define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
typedef long long ll;
typedef double ld;
#define pll pair<ll,ll>
#define pb push_back
#define mp(x, y) make_pair((x), (y))
#define F first
#define S second
#define I insert
#define vll vector<ll>
#define vpll vector<pll>
#define all(x) (x).begin(), (x).end()
#define sz(x) (ll)(x).size()
   
const ll Mod = 1e9 + 7;
int main(){
   ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
   int n , k ;
   string s;
   cin >> n >> k >> s;
   if(s[k-1] == 'A')
    s[k-1] = 'a';
    if(s[k-1] == 'B')
    s[k-1] = 'b';
    if(s[k-1] == 'C')
    s[k-1] = 'c';
    cout << s << endl;
   return 0;
}

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

int main() {
  int K,N;
  long long ans;
  ans=0;
  cin>>K>>N;
  vector<int>p(K);
  for(int i=0;i<K;i++){
    cin>>p[i];
  }
  sort(p.begin(),p.end());
  for(int i=0;i<N;i++){
    ans+=p[i];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3632
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {
    static void answer(long a){
        System.out.println(a);
        System.exit(0);
    }
    static void impossible(){
        answer(-1);
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();

        SortedSet<Integer>[] sChars = new SortedSet[26];
        for(int x=0; x<26; x++) sChars[x] = new TreeSet<Integer>();
        for(int i=0; i<s.length(); i++){
            sChars[s.charAt(i)-'a'].add(i);
        }
        long word = 0;
        int current=0;
        for(int j=0; j<t.length(); j++){
            if(sChars[t.charAt(j)-'a'].tailSet(current).isEmpty()){
                word++;
                if(sChars[t.charAt(j)-'a'].isEmpty()) impossible();
                else current = sChars[t.charAt(j)-'a'].first()+1;
            }else{
                current = sChars[t.charAt(j)-'a'].tailSet(current).first() + 1;
            }
        }
        answer(word*s.length()+current);
    }
}


Measured memory_bytes: 48680
#include<bits/stdc++.h>
using namespace std;
const unsigned int MOD = 1000000007;
#define ll long long
#define PI 3.1416
string day[]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
vector<string>v;
void dfs(string str,string t="",int cnt=0){
    if(cnt==2){
        v.push_back(t);
        return;
    }else{
        for(int i=0;i<str.size();i++){
            dfs(str,t+str[i],cnt+1);
        }
    }
}
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int m,d;
    while(cin>>m>>d){
        if(d<m){
            cout<<m-1<<endl;
        }else{
            cout<<m<<endl;
        }
    }
    return 0;
}


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

int main() {
    int N; cin >> N;
    vector<int> p(N+1); vector<bool> isSameWithInd(N+1);
    for(int i = 1; i <= N; i++) {
        cin >> p[i];
        if(p[i] == i) {
            isSameWithInd[i] = true;
        } else {
            isSameWithInd[i] = false;
        }
    }

    int cnt = 0;
    for(int i = 1; i <= N; i++) {
        if(isSameWithInd[i] == true) {
            cnt++;
            i++;
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int N, K; cin >> N >> K;
  vector<ll> h(N);
  rep(i,N) cin >> h[i];
  sort(h.begin(), h.end(), greater<ll>());
  ll min_dif = 1000000010;
  rep(i,N-K+1) {
    ll temp_dif = h[i] - h[i+K-1];
    min_dif = min(min_dif, temp_dif);
  }
  cout << min_dif << endl;
  return 0;
}

Measured memory_bytes: 3580
#include <vector>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <cstdlib>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,n,s) for(int i=s;i<n;i++)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a) (a).begin(),(a).end()

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

  string s;
  cin >> s;

  bool yymm = false;
  bool mmyy = false;

  if((s[2] == '0' && s[3] != '0') || (s[2] == '1' && (s[3] == '0' || s[3] == '1' || s[3] == '2'))) {
    yymm = true;
  }
  if((s[0] == '0' && s[1] != '0') || (s[0] == '1' && (s[1] == '0' || s[1] == '1' || s[1] == '2'))) {
    mmyy = true;
  }

  if(yymm && mmyy) {
    cout << "AMBIGUOUS" << endl;
  } else if(yymm) {
    cout << "YYMM" << endl;
  } else if(mmyy) {
    cout << "MMYY" << endl;
  } else {
    cout << "NA" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <utility>
#include <climits>
#include <bitset>
#include <cmath>

#define BP 1000000007

using namespace std;

typedef unsigned long long ull;
typedef unsigned long ul;
typedef long long ll;
typedef unsigned int ui;

typedef vector<ull> vull;
typedef vector<ll> vll;
typedef vector<ui> vui;
typedef vector<long> vl;
typedef vector<int> vi;
typedef vector<vl> vvl;
typedef vector<vi> vvi;

typedef pair<ull, ull> pull;
typedef pair<ll, ll> pll;
typedef pair<ui, ui> pui;
typedef pair<long, long> pl;
typedef pair<int, int> pi;

template <class T>
void printv(vector<T> vc) {
    for (auto e: vc) cout << e << " ";
    cout << endl;
}

template <class T>
void printvv(vector<T> vvc) { 
    for (auto vc: vvc) {
        for (auto e: vc) cout << e << " ";
        cout << endl;
    }
}

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

    string s = "";
    int as = 0;
    for (char c: str) {
        if (c != 'A') s += c;
        else          ++as;
    }
    
    if (s != "KIHBR" || str.size() > 9 || as > 4) {
        cout << "NO" << endl;
        return 0;
    }

    /// kih
    if ((int)str.find("KIH") == -1) {
        cout << "NO" << endl;
        return 0;
    }

    /// aa
    if ((int)str.find("AA") != -1) {
        cout << "NO" << endl;
        return 0;
    }

    cout << "YES" << endl;

    return 0;
}

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

int N;

int main() {
    cin >> N;
    int a[N];
for(int i=0; i<N; i++) std::cin >> a[i];
int max = a[0];
int min = a[0];
for (int i = 1; i < N; ++i) {
        if (max < a[i]) {
            max = a[i];
        }
        if (min > a[i]) {
            min = a[i];
        }
    }

int result = max - min;
cout << result << endl;
}


Measured memory_bytes: 256
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iomanip>
#include <iostream>
#include <limits>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;

template<typename T>
vector<T> make_vec_nd(T init, size_t size) {
    return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, size_t size, Args... rest) {
    auto inner = make_vec_nd(init, rest...);
    return vector<decltype(inner)>(size, inner);
}

int main() {
    ll N, M;
    cin >> N >> M;
    struct Key {
        ll cost;
        vector<ll> boxes;
    };
    vector<Key> keys;
    for (ll k = 0; k < M; k++) {
        Key key;
        ll a, b;
        cin >> a >> b;
        key.cost = a;
        for (ll i = 0; i < b; i++) {
            ll box;
            cin >> box;
            box--;
            key.boxes.push_back(box);
        }
        keys.push_back(key);
    }
    auto dp = make_vec_nd(numeric_limits<ll>::max(), M + 1, (1 << N));
    dp[0][0] = 0;
    for (ll n_key = 1; n_key <= M; n_key++) {
        for (ll flag = 0; flag < (1 << N); flag++) {
            Key key = keys[n_key-1];
            ll flag_before = flag;
            for (ll box : key.boxes) {
                flag_before = flag_before & ~(1 << box);
            }
            if (dp[n_key-1][flag_before] == numeric_limits<ll>::max()) {
                dp[n_key][flag] = dp[n_key-1][flag];
            } else {
                dp[n_key][flag] = min(dp[n_key-1][flag], dp[n_key-1][flag_before] + key.cost);
            }
        }
    }
    if (dp[M][(1 << N) - 1] == numeric_limits<ll>::max()) {
        cout << -1 << endl;
    } else {
        cout << dp[M][(1 << N) - 1] << endl;
    }
}


Measured memory_bytes: 32512
/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
*/
import java.util.*;
import java.io.*;

   public class Main
   {
      public static void main(String args[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         int M = Integer.parseInt(st.nextToken());
         System.out.println(Math.max(0, N-M-M));
      }
   }

Measured memory_bytes: 23124
#include <bits/stdc++.h> 
using namespace std; 
  
// Function to return the XOR of elements 
// from the range [1, n] 
long long int findXOR(long long int n) 
{ 
    int mod = n % 4; 
  
    // If n is a multiple of 4 
    if (mod == 0) 
        return n; 
  
    // If n % 4 gives remainder 1 
    else if (mod == 1) 
        return 1; 
  
    // If n % 4 gives remainder 2 
    else if (mod == 2) 
        return n + 1; 
  
    // If n % 4 gives remainder 3 
    else
        return 0; 
} 
  
// Function to return the XOR of elements 
// from the range [l, r] 
long long int findXOR(long long int l, long long int r) 
{ 
    return (findXOR(l - 1) ^ findXOR(r)); 
} 
int main()
{long long int a,b;
cin>>a>>b;
cout<<findXOR(a,b);}

Measured memory_bytes: 3640
#include <algorithm>
#include <iostream>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

const ll INF = 1000000000000;

bool comp(const P &p0, const P &p1){
    if(p1.first * p0.second + p1.second == p0.first * p1.second + p0.second) return p0.second < p1.second;
    return p1.first * p0.second + p1.second < p0.first * p1.second + p0.second;
}

ll dp[200005][40];

int main()
{
    ll n, t;
    cin >> n >> t;
    t++;
    ll k1 = 0, k2 = 0;
    P p[200005];
    ll d[200005];
    for(int i = 0; i < n; i++){
        ll a, b;
        cin >> a >> b;
        if(a){
            p[k1] = P(a + 1, b + 1);
            k1++;
        }
        else{
            d[k2] = b + 1;
            k2++;
        }
    }
    sort(p, p + k1, comp);
    for(int i = 0; i <= k1; i++){
        for(int j = 0; j < 40; j++) dp[i][j] = INF;
    }
    dp[0][0] = 1;
    for(int i = 1; i <= k1; i++){
        for(int j = 0; j < 40; j++) dp[i][j] = dp[i - 1][j];
        for(int j = 1; j < 40; j++){
            if(dp[i - 1][j - 1] <= t) dp[i][j] = min(dp[i][j], p[i - 1].first * dp[i - 1][j - 1] + p[i - 1].second);
        }
    }
    sort(d, d + k2);
    ll r[200005];
    r[0] = 0;
    for(int i = 1; i <= k2; i++) r[i] = r[i - 1] + d[i - 1];
    int ans = 0;
    for(int j = 0; j < 40; j++){
        if(dp[k1][j] > t) continue;
        int l = upper_bound(r, r + k2 + 1, t - dp[k1][j]) - r - 1;
        ans = max(ans, j + l);
    }
    cout << ans << endl;
}


Measured memory_bytes: 68608
import java.awt.Point;
import java.awt.geom.Point2D;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws java.io.IOException {
		Scanner sc = new Scanner(System.in);
		while (sc.hasNext()) {
			Point2D.Double a = new Point2D.Double(sc.nextDouble(),
					sc.nextDouble());
			Point2D.Double b = new Point2D.Double(sc.nextDouble(),
					sc.nextDouble());
			Point2D.Double c = new Point2D.Double(sc.nextDouble(),
					sc.nextDouble());
			Point2D.Double p = new Point2D.Double(sc.nextDouble(),
					sc.nextDouble());
			Point2D.Double ab = new Point2D.Double(b.x - a.x, b.y - a.y);
			Point2D.Double bc = new Point2D.Double(c.x - b.x, c.y - b.y);
			Point2D.Double ca = new Point2D.Double(a.x - c.x, a.y - c.y);
			Point2D.Double ap = new Point2D.Double(p.x - a.x, p.y - a.y);
			Point2D.Double bp = new Point2D.Double(p.x - b.x, p.y - b.y);
			Point2D.Double cp = new Point2D.Double(p.x - c.x, p.y - c.y);
			String ans = isPositiveEP(ab, ap) ^isPositiveEP(bc, bp) || isPositiveEP(bc, bp) ^ isPositiveEP(ca, cp) ? "NO"
					: "YES";
			System.out.println(ans);

		}
	}

	public static Boolean isPositiveEP(Point2D.Double a, Point2D.Double b) {
		return (a.x * b.y - a.y * b.x) > 0;
	}
}

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

using ll = long long;

int N, A;
int x[111];
ll dp[111][111][5555];

int main() {
   cin >> N >> A;
   for (int i = 0; i < N; i++) cin >> x[i];

   dp[0][0][0] = 1;
   for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
         for (int k = 0; k <= 5000; k++) {
            // 選ばない
            dp[i+1][j][k] += dp[i][j][k];
            // 選ぶ
            if (k >= x[i]) {
               dp[i+1][j+1][k] += dp[i][j][k-x[i]];
            }
         }
      }
   }

   ll ans = 0;
   for (int j = 1; j <= N; j++) {
      ans += dp[N][j][j*A];
   }
   cout << ans << endl;

   return 0;
}

Measured memory_bytes: 207872
package main

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

type graph [][]int
type isSeen []bool

var (
	n    int
	m    int
	g    graph
	seen isSeen
)

func dfs(excA, excB, v int) {
	seen[v] = true

	for _, nv := range g[v] {
		if (v == excA && nv == excB) || (v == excB && nv == excA) {
			continue
		}

		if !seen[nv] {
			dfs(excA, excB, nv)
		}
	}
}

func main() {
	n = getInt()
	m = getInt()
	seen = make(isSeen, n)

	g = make(graph, n)
	candidatesOfBridge := make([]struct{ a, b int }, m)
	for i := range g {
		g[i] = make([]int, 0, m)
	}
	for i := 0; i < m; i++ {
		a, b := getInt()-1, getInt()-1
		g[a] = append(g[a], b)
		g[b] = append(g[b], a)
		candidatesOfBridge[i].a = a
		candidatesOfBridge[i].b = b
	}

	ans := 0
	for _, e := range candidatesOfBridge {
		seen.AssignBoolToSlice(false)
		cnt := 0
		for v := 0; v < n; v++ {
			if !seen[v] {
				dfs(e.a, e.b, v)
				cnt++
			}
		}
		if cnt > 1 {
			ans++
		}
	}

	fmt.Println(ans)
}

func (seen isSeen) AssignBoolToSlice(b bool) {
	for i := range seen {
		seen[i] = b
	}
}

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	// tmp := 200001
	// sc.Buffer(make([]byte, tmp), tmp)
	sc.Split(bufio.ScanWords)
}

func getInt() int {
	i, err := strconv.Atoi(getString())
	if err != nil {
		panic(err)
	}
	return i
}

func getString() string {
	sc.Scan()
	s := sc.Text()
	return s
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
 
#define ll long long 
#define repd(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, n) repd(i, 0, n)
using namespace std;
 
int main(){
  char c;
  cin >> c;
  if('a' <= c && c <= 'z'){
    cout << 'a' << endl;
  }else{
    cout << 'A' << endl;
  }
  return 0;
}

Measured memory_bytes: 3064
//Andrew Yang
#include <iostream>
#include <stdio.h>
#include <sstream>
#include <fstream>
#include <string>
#include <string.h>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>	
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <climits>
using namespace std;
#define FOR(index, start, end) for(int index = start; index < end; index++)
#define RFOR(index, start, end) for(int index = start; index > end; index--)
#define FOREACH(itr, b) for(auto itr = b.begin(); itr != b.end(); itr++)
#define RFOREACH(itr, b) for(auto itr = b.rbegin(); itr != b.rend(); itr++)
#define INF 1000000000
#define M 1000000007
typedef long long ll;
typedef pair<int, int> pii;

int main(void)
{
	ll n;
	cin >> n;
	int ans = INF;
	FOR(i, 1, sqrt(n) + 1)
	{
		if (n % i == 0)
		{
			ans = min(ans,(int)max(to_string(i).length(), to_string(n / i).length()));
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let s: String = read();
    let t: String = read();

    let mut ans: usize = 0;
    for i in 0..3 {
        if s.chars().nth(i) == t.chars().nth(i) {
            ans += 1;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
import java.util.*
import java.lang.Math.*

fun main(args: Array<String>) {
  val (n, m) = readLine()!!.split(" ").map { it.toInt() }
  var list = ArrayList<Int>()
  val sqrtM = sqrt(m.toDouble()).toInt()
  for (i in 1..sqrtM) {
    if (m % i == 0) {
      if (i <= m / n) list.add(i)
      if (i * i != m && m / i <= m / n) list.add(m / i)
    }
  }
  val ans = list.max()
  println(ans)
}


Measured memory_bytes: 37940
#include <stdio.h>

int main() {
	int n;
	
	while( scanf("%d", &n) != EOF ) {
		
		int count = 0;
		int a,b,c,d;
		
		for(a=0; a<=9; a++){
			for(b=0; b<=9; b++){
				for(c=0; c<=9; c++) {
					for(d=0; d<=9; d++) {
						if(a+b+c+d == n) count++;
					}
				}
			}
		}
		
		printf("%d\n", count);
		
	}
	
	return 0;
}

Measured memory_bytes: 596
#import 
#=input()
#int(input())
a,b,c=map(int,input().split())
k = int(input())
#=list(map(int,input().split()))
#=[list(map(int,input().split())) for _ in range()]

cnt = 0
while a >= b:
    b *= 2
    cnt += 1
while b >= c:
    c *= 2
    cnt += 1
if cnt <= k:
    print('Yes')
else:
    print('No')

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

int is_kai(string str)
{
  int i, j;
  i = 0;
  j = str.size();
  for (int i = 0; i < str.size()/2; i++)
  {
    if(str[i] != str[j-1])
      return (0);
    j--;
  }
  return (1);
}

int main()
{
  string str;
  cin >> str;
  int n1 = str.size()/2;
  int n2 = (str.size()+3)/2; 
  
  string ans = "No";
  if (is_kai(str)==1 &&is_kai(str.substr(0, n1))==1 && is_kai(str.substr(n2-1, str.size()-n2+1))==1)
    ans = "Yes";

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b;cin >> a >> b;
	a--;b--;
	vector<string> s(100);
	rep(i,100){
		s.at(i)="";
		rep(j,100){
			if(i<50) s[i]+='#';
			else s[i]+='.';
		}
	}
	for(int i=0;i<50;i+=2){
		bool flg=false;
		for(int j=0;j<100;j+=2){
			if(a==0){
				flg=true;
				break;
			}
			s[i][j]='.';
			a--;
		}
		if(flg) break;
	}
	for(int i=99;i>50;i-=2){
		bool flg=false;
		for(int j=0;j<100;j+=2){
			if(b==0){
				flg=true;
				break;
			}
			s[i][j]='#';
			b--;
		}
		if(flg) break;
	}
	cout << 100 << " " << 100 << endl;
	rep(i,100){
		cout << s.at(i) << endl;
	}
}

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

int main() {
  int a,b,c;
  cin >> a>>b>>c;

  if (a==7 &&b==5 &&c==5) {
    cout << "YES" << endl;
  }
  else if(b==7 &&a==5 &&c==5) {
    cout << "YES" << endl;
  }
  else if(c==7 &&b==5 &&a==5) {
    cout << "YES" << endl;
  }
  else {
    cout<<"NO"<<endl;
  } 
}

  



Measured memory_bytes: 256
n, m = map(int, input().split())
C = list(map(int, input().split()))
T = [0]+[float('inf')]*n

for i in range(m):
  for j in range(C[i], n+1):
    T[j] = min(T[j], T[j-C[i]]+1)


# for i in range(m):
#   for j in range(n):
#     T[i][j] = min(T[i-1][j], T[i][j-C[i]] +1)
print(T[j])


Measured memory_bytes: 7524
x = int(input())
if 400 <= x <= 599:    print(8)
if 600 <= x <= 799:    print(7)
if 800 <= x <= 999:    print(6)
if 1000 <= x <= 1199:    print(5)
if 1200 <= x <= 1399:    print(4)
if 1400 <= x <= 1599:    print(3)
if 1600 <= x <= 1799:    print(2)
if 1800 <= x <= 1999:    print(1)

Measured memory_bytes: 9192
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
int main(void){
    int n,i,tmp;
    int *x;
    int *y;
    double p[4] ={};
    scanf("%d",&n);
    x = (int *)malloc(n * sizeof(int));
    y = (int *)malloc(sizeof(int) * n);
    for(i=0;i<n;i++){
        scanf("%d",&x[i]);
    }
    for(i=0;i<n;i++){
        scanf("%d",&y[i]);
        tmp = fabs(x[i] - y[i]);
        p[0] = p[0] + tmp;
        p[1] = p[1] + pow(x[i] - y[i],2);
        p[2] = p[2] + pow(tmp,3);
        if(tmp > p[3]) p[3] = tmp;
    }
    p[1] = sqrt(p[1]);
    p[2] = cbrt(p[2]);
    for(i=0;i<4;i++){
        printf("%lf\n",p[i]);
    }
 
    return 0;
}
 

Measured memory_bytes: 708
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
    int N;
    long long A, B;
    cin>>N>>A>>B;
    vector<long long> h(N);
    for (long long &t: h)
        cin>>t;

    auto check = [&](long long c)
    {
        long long x = 0;
        for (long long t: h)
            x += max(0LL, (t-B*c+A-B-1)/(A-B));
        return x<=c;
    };

    long long ans = 0;
    for (long long b=0x80000000LL; b>0; b/=2)
        if (!check(ans+b))
            ans += b;
    cout<<ans+1<<endl;
}


Measured memory_bytes: 1024
/*       Rohan Balot
    NSIT, New Delhi, India  */
#include <bits/stdc++.h>
#include <unordered_set>
#include <unordered_map>
using namespace std;
 
#define FIND(c, e) (c).find(e) != (c).end()
#define NFIND(c, e) (c).find(e) == (c).end()
#define ALL(t) (t).begin(), (t).end()
#define ALLR(t) (t).rbegin(), (t).rend()
#define MP make_pair

const int N = int( 1e5 ) + 1;
const int M = int( 1e6 ) + 1;
const int MOD = int( 1e9 ) + 7;
const double PI = acos(-1.0);
const double eps = 1e-6;
template<typename T> T gcd(T a,T b){while (b){T r=a%b;a=b;b=r;}return a;}
template<typename T> T lcm(T a,T b){return (a*b)/gcd(a,b);}

void __answer()
{
	int a, b, c;
	cin >> a >> b;
	c = a + b;
	if(a % 3 == 0 ||
	   b % 3 == 0 ||
	   c % 3 == 0)
	   cout << "Possible";
	else cout << "Impossible";
}  
int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    #ifdef LOCAL
        freopen("sample_input.txt", "r", stdin);
        // freopen("data.txt", "w", stdout);
        // freopen("log.txt", "w", stderr);
    #endif
    __answer();
    return 0;
}  

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

#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REP(n) for(int i=0;i<int(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)

int main() {
    int num,a, b, c, d;
    a = b = c = d = 0;
    string s;
    cin >> num;

    REP(num) {
        cin >> s;
        if (s == "AC")a++;
        else if (s == "WA")b++;
        else if (s == "TLE")c++;
        else d++;
    }
    cout << "AC x " << a << endl;
    cout << "WA x " << b << endl;
    cout << "TLE x " << c << endl;
    cout << "RE x " << d << endl;
}
 

Measured memory_bytes: 3612
n = int(input())
ans = float('Inf')
for i in range(1, n):
  if i > n//2:
    break
  if eval('+'.join(str(i))) + eval('+'.join(str(n - i))) < ans:
    ans = eval('+'.join(str(i))) + eval('+'.join(str(n - i)))
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
using namespace std;
typedef struct pair<int,int> P;
typedef long long ll;

ll n,k,l;

ll a[100001]={};
ll c[200001]={};
int main() {

	cin>>n;

	for(int i=0;i<n;++i){
		cin>>a[i];
	}
	sort(a,a+n);
	int t=0;
	int a1=0;

	int r=0;
	for(int i=0;i<n;++i){
		if(a[i]==a1){
			if(t>0){
				t--;
			}else{
				r++;
			}
		}else{
			if(t>0){
				r+=a1-t;
			}
			t=a[i]-1;
			a1=a[i];
		}
	}
	if(t>0){
		r+=a1-t;
	}
	cout <<r<< endl;
	return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

template <class T>
vector<T> sumup(const vector<T>& a) {
  int N = a.size();
  vector<T> res(N + 1);
  for (int i = 0; i < N; i++) res[i + 1] = res[i] + a[i];
  return res;
}

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int K, N;
  while (cin >> N >> K) {
    vector<int> p(N);
    for (auto& x : p) cin >> x;
    vector<double> e(N);
    for (int x : p) {
      double sum = x * (x + 1) / 2;
      e.push_back(sum / x);
    }
    auto S = sumup(e);
    double res = 0;
    for (int i = K; i <= S.size(); i++) {
      double y = S[i] - S[i - K];
      chmax(res, y);
    }
    printf("%.20f\n", res);
  }
  return 0;
}


Measured memory_bytes: 7268
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int MAX_N = 105;
const ll MOD = 1e9+7;
ll cnt[MAX_N][65]; //A-0 C-1 G-2 T-3
char c[4] = {'A','C','G','T'};

int getid(char a, char b, char d)
{
	int res = 0;
	if (a == 'C') res += 1;
	else if (a == 'G') res += 2;
	else if (a == 'T') res += 3;
	res *= 4;

	if (b == 'C') res += 1;
	else if (b == 'G') res += 2;
	else if (b == 'T') res += 3;
	res *= 4;

	if (d == 'C') res += 1;
	else if (d == 'G') res += 2;
	else if (d == 'T') res += 3;

	return res;
}

int main()
{
	int N;
	cin >> N;
	rep(i,4)
	{
		rep(j,4)
		{
			rep(k,4)
			{
				bool flag = true;
				if (c[i]=='A'&&c[j]=='G'&&c[k]=='C') flag = false;
				if (c[i]=='G'&&c[j]=='A'&&c[k]=='C') flag = false;
				if (c[i]=='A'&&c[j]=='C'&&c[k]=='G') flag = false;
				if (flag) cnt[3][getid(c[i],c[j],c[k])] = 1;
			}
		}
	}

	for (int i = 0; i < N-3; ++i)
	{
		rep(j,4)
		{
			rep(k,4)
			{
				rep(l,4)
				{
					rep(m,4)
					{
						bool flag2 = true;
						if (c[k]=='A'&&c[l]=='G'&&c[m]=='C') flag2 = false;
						if (c[k]=='G'&&c[l]=='A'&&c[m]=='C') flag2 = false;
						if (c[k]=='A'&&c[l]=='C'&&c[m]=='G') flag2 = false;
						if (c[j]=='A'&&c[l]=='G'&&c[m]=='C') flag2 = false;
						if (c[j]=='A'&&c[k]=='G'&&c[m]=='C') flag2 = false;
						if (flag2)
						{
							cnt[i+4][getid(c[k],c[l],c[m])] = (cnt[i+4][getid(c[k],c[l],c[m])] + cnt[i+3][getid(c[j],c[k],c[l])]) % MOD;
						}
					}
				}
			}
		}
	}
	ll ans = 0;
	rep(i,4)
	{
		rep(j,4)
		{
			rep(k,4)
			{
				ans = (ans + cnt[N][getid(c[i],c[j],c[k])]) % MOD;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

public class AtCoderABC141C
{
    static void Main(string[] args)
    {
        // 自分の得意な言語で
        // Let's チャレンジ！！

        var line = System.Console.ReadLine();
        var spl = line.Split();
        var N = int.Parse(spl[0]); // 人数
        var K = int.Parse(spl[1]); // 初期ポイント
        var Q = int.Parse(spl[2]); // 問題数

        var Players = Enumerable.Repeat(K - Q, N).ToList();

        for (var i = 0; i < Q; i++)
        {
            var A = int.Parse(System.Console.ReadLine());
            Players[A - 1]++;
        }

        var ret = Players.Select(f => f > 0 ? "Yes" : "No").ToList();
        System.Console.WriteLine(string.Join("\n",ret));
        Console.ReadKey();
    }

}


Measured memory_bytes: 20192