akhauriyash/Code-Regression huggingface dataset:
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, n) revi(i, 0, n)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数 __builtin_popcount bitの個数

int main() {
  ve<int> A(3);
  rep(i, 3){
    ci(A.at(i));
  }
  sort all(A);
  co(A.at(1) + A.at(0) + A.at(2) * 10);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pi acos(-1.0)
using namespace std;
int main()
{

	double a,b,h,m;
	cin>>a>>b>>h>>m;

	double x = abs(5.5*m-30*h) ;
	double z  = abs(x);
	if(x>180) z = 360-z;



	double p = cos((z*pi)/180.0);


	double you = (a*a+b*b);

	double q = you-(2.0*a*b*p);
	cout << fixed << setprecision(20) << sqrt(q) <<endl;

    return 0;
}





Measured memory_bytes: 4228
fun main(args:Array<String>){
    val (s, t) = readLine()!!.split(" ")
    var (a, b) = readLine()!!.split(" ").map{it.toInt()}
    val u = readLine()
    if(u == s) a--
    if(u == t) b--
    println("$a $b")
}

Measured memory_bytes: 37652
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>

using namespace std;
using ll = long long;

int main(){
    int r;
    cin >> r;
    double rr;
    rr = (double) r;
    cout << 2*rr*3.1415926535 << endl;
}

Measured memory_bytes: 3776
#include <stdio.h>
int main()
{
    int vida, atqs, dano = 0, soma = 0;
    scanf("%d%d",&vida, &atqs);

    for(int i = 0; i < atqs; ++i) {
        scanf("%d",&dano);
        soma = soma + dano;
        vida = vida - dano;

    }

    if (vida > 0)
        printf("No\n");
    else
        printf("Yes\n");

    //printf("DANO NO JOGO: %d", soma);
    return 0;
}


Measured memory_bytes: 128
import math

def koch(n, p1, p2):
    if n == 0:
        return
    
    sx = 2*p1[0]/3 + p2[0]/3
    sy = 2*p1[1]/3 + p2[1]/3
    tx = p1[0]/3 + 2*p2[0]/3
    ty = p1[1]/3 + 2*p2[1]/3
    ux = (tx - sx)*math.cos(math.radians(60))  - (ty - sy)*math.sin(math.radians(60)) + sx
    uy = (tx - sx)*math.sin(math.radians(60)) + (ty - sy)*math.cos(math.radians(60)) + sy
    koch(n-1, p1, [sx, sy])
    print(sx, sy)
    koch(n-1, [sx, sy], [ux, uy])
    print(ux, uy)
    koch(n-1, [ux, uy], [tx, ty])
    print(tx, ty)
    koch(n-1, [tx, ty], p2)
    
    
    
    
    
    
n = int(input())
#問題文より，　端点がp1 = (0,0), p2 =(100,0)と指定されている
p1 = [0, 0]
p2 = [100, 0]
print(p1[0], p1[1])
koch(n, p1, p2)
print(p2[0], p2[1])


Measured memory_bytes: 5780
#include<stdio.h>
int main(){
  int h,w,n,x,y,i,j;
  while(1){
    int m[20][20]={0};
    scanf("%d %d",&w,&h);
    if(!(w||h))break;
    scanf("%d",&n);
    for(i=0;i<n;i++){
      scanf("%d %d",&x,&y);
      m[y][x]=-1;
    }
    m[1][1]=1;
    for(i=1;i<=h;i++){
      for(j=1;j<=w;j++){
	if(m[i][j]==-1)continue;
	if(m[i][j-1]!=-1)m[i][j]+=m[i][j-1];
	if(m[i-1][j]!=-1)m[i][j]+=m[i-1][j];
      }
    }
    /* for(i=0;i<=h;i++){
      for(j=0;j<=w;j++){
	printf("%3d",m[i][j]);
      }
      printf("\n");
      }*/
    printf("%d\n",m[h][w]);
  }
  return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

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

  vector<string> p = {
    "dreamer", "dream", "eraser", "erase"
  };

  std::reverse(S.begin(), S.end());
  rep(i, p.size()) {
    std::reverse(p[i].begin(), p[i].end());
  }

  int i = 0;
  while (i < S.size()) {
    bool found = false;

    rep(j, p.size()) {
      bool match = true;

      if (S.size() - i >= p[j].size()) {
        rep(k, p[j].size()) {
          if (S[i+k] != p[j][k]) {match = false; break;}
        }
      } else {
        match = false;
      }

      if (match) {found = true; i += p[j].size(); break;}
    }

    if (!found) { cout << "NO" << endl; return 0;}
  }

  cout << "YES" << endl;

  return 0;
}


Measured memory_bytes: 512
import random
d = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(d)]
ans = 0
last = [0]*26
for i in range(1,d+1):
    res = -float("inf")
    maindex = 0
    ma = 0
    for k in range(26):
        if (s[i-1][k]>ma):
            ma = s[i-1][k]
            maindex = k+1
    print(maindex)
    

Measured memory_bytes: 9892
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
 
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int n,t;
  cin >> n >> t;
  int ans = 10000;
  rep(i, n){
    int c,x;
    cin >> c >> x;
    if(x > t) continue;
    if(ans > c){
      ans = c;
    }
  }
  if(ans != 10000) cout << ans << endl;
  else cout << "TLE" << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vc = vector<char>;
using vvc = vector<vector<char>>;
using vi = vector<int>;
using vs = vector<string>;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repp(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define repd(i, n) for(ll i = n - 1; i >= 0; i--)
#define all(x) x.begin(), x.end()

ll k, l, m, n;
const ll M = 1e9 + 7;



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

    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    const int dx = tx - sx, dy = ty - sy;

    cout << string(dy, 'U') << string(dx, 'R');
    cout << string(dy, 'D') << string(dx, 'L');
    cout << 'L' << string(dy+1, 'U') << string(dx+1, 'R') << 'D';
    cout << 'R' << string(dy+1, 'D') << string(dx+1, 'L') << 'U';

    cout << endl;
}

Measured memory_bytes: 3628
n,m=gets.split.map &:to_i
h=(0..n).map{[]}
(1..m).each{|i|
    p,y=gets.split.map &:to_i
    h[p] << [y,i]
}
res=[]
(1..n).each{|i| h[i].sort.each.with_index(1){|(_, k), j| res[k-1]="%06d%06d" % [i, j]}}
puts res*$/


Measured memory_bytes: 33144
import sys

input = sys.stdin.readline
max_a = 0
big_a = 0
max_index = 0
n = int(input())
for i in range(n):
    a = int(input())
    if max_a < a:
        max_index = i
        big_a = max_a
        max_a = a
    elif max_a == a:
        max_index = -1
    elif big_a < a:
        big_a = a
    else:
        continue

for i in range(n):
    print([max_a, big_a][i == max_index])

Measured memory_bytes: 9156
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

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

    char s[11];

    cin >> s;

    if (s[0] == 'S')
    {
        cout << "Cloudy\n";
    }
    else if (s[0] == 'C')
    {
        cout << "Rainy\n";
    }
    else
    {
        cout << "Sunny\n";
    }
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define tc int t; cin>>t; while(t--)
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define mod 1000000007
#define pb push_back
#define vi vector<int>
#define vc vector<char>
#define eb emplace_back
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define fo(i,x,n) for(int i=x;i<n;i++)
#define csb(x) __builtin_popcount(x)
#define tz(x) __builtin_ctz(x)
#define lsbp(x) __builtin_ffs(x)
#define msbp(x) __lg(x)
#define btoi(str,i) stoi(str,0,i)
#define ff first
#define ss second
const int inf=0x3f3f3f3f3f3f3f3f;

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

int32_t main(){
zz();
int n,k;cin>>n>>k;
int z=0;
int x=0;
for(int i=k;i<=n+1;i++){
   x=(i*(i-1))/2;
   x-=1;
   int y=(i*(2*(n-i+1)+(i-1)))/2;
   z+=(y-x);
   //z+=y;
   //cout<<y<<" "<<x<<endl;
   z%=mod;
}
cout<<z<<endl;

}

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

int main() {
	int n,k,x,y;
	cin >> n >> k >> x >> y;
	if(k<n){
		cout << (k*x)+((n-k)*y) <<"\n";
		//cout << ((n-k)*y) << "\n";
	}
	else cout << (n*x) << "\n";
	// your code goes here
	return 0;
}

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

int main()
{
    ios::sync_with_stdio(false);
    int n;
    double d;
    cin >> n >> d;
    int ans = 0;
    for (int i = 1; i <= n; i++)
    {
        double x, y;
        cin >> x >> y;
        if (sqrt(x * x + y * y) - d <= 1e-10)
            ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3792
#pragma GCC optimize ("-O3")
    #include <bits/stdc++.h>  
     
    using namespace std;
     
    typedef long long ll;
    typedef long double ld;
    typedef pair<int,int> p32;
    typedef pair<ll,ll> p64;
    typedef pair<double,double> pdd;
    typedef vector<ll> v64;
    typedef vector<int> v32;
    typedef vector<vector<int> > vv32;
    typedef vector<vector<ll> > vv64;
    typedef vector<vector<p64> > vvp64;
    typedef vector<p64> vp64;
    typedef vector<p32> vp32;
    ll MOD = 998244353;
    #define forn(i,e) for(ll i = 0; i < e; i++)
    #define forsn(i,s,e) for(int i = s; i < e; i++)
    #define rforn(i,s) for(ll i = s; i >= 0; i--)
    #define rforsn(i,s,e) for(ll i = s; i >= e; i--)
    #define ln "\n"
    #define dbg(x) cout<<#x<<" = "<<x<<ln
    #define mp make_pair
    #define pb push_back
    #define fi first
    #define se second
    #define INF 1e18
    #define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
    #define all(x) (x).begin(), (x).end()
    #define sz(x) ((ll)(x).size())
     
    ll mpow(ll a, ll b){
        if(b >= (MOD-1)) b %= (MOD-1);
        if(b==0) return 1;
        ll t1 = mpow(a,b/2);
        t1 *= t1;
        t1 %= MOD;
        if(b%2) t1 *= a;
        t1 %= MOD;
        return t1;
    }
     
    ll mpow(ll a, ll b, ll p){
        if(b==0) return 1;
        ll t1 = mpow(a,b/2,p);   t1 *= t1;
        t1 %= p;
        if(b%2) t1 *= a;
        t1 %= p;
        return t1;
    }
    ll modinverse(ll a, ll m){
        ll m0 = m; 
        ll y = 0, x = 1; 
        if (m == 1) return 0; 
        while (a > 1){
            ll q = a / m; 
            ll t = m; 
            m = a % m, a = t; 
            t = y; 
            y = x - q * y; 
            x = t; 
        }
        if (x < 0) x += m0; 
        return x; 
    }
    ll range(ll l, ll r){
        return l + rand()%(r-l+1);
    }
    
    int main()
    {
        ll t=1;//cin>>t;
        while(t--)
        {
            int x;cin>>x;
            int mv = 1;
            int ca = x;
            while(true)
            {
                if(ca%360==0)break;
                ca += x;
                mv++;
            }
            cout<<mv<<endl;
        }
    }

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

using namespace std;
using ll = long long;

#define gc getchar
int getint() { unsigned int c; int x = 0; while (((c = gc()) - '0') >= 10) { if (c == '-') return -getint(); if (!~c) exit(0); } do { x = (x << 3) + (x << 1) + (c - '0'); } while (((c = gc()) - '0') < 10); return x; }
int getstr(char *s) { int c, n = 0; while ((c = gc()) <= ' ') { if (!~c) exit(0); } do { s[n++] = c; } while ((c = gc()) > ' ' ); s[n] = 0; return n; }
template<class T> inline bool chmin(T &a, T b) { return a > b ? a = b, 1 : 0; }
template<class T> inline bool chmax(T &a, T b) { return a < b ? a = b, 1 : 0; }


int main () {
    ll q = getint();
    ll h = getint();
    ll s = getint();
    ll d = getint();
    chmin(h, 2 * q);
    chmin(s, 2 * h);
    ll n = getint();
    ll res = 0;
    if (d < 2 * s) {
        int m = n / 2;
        n = n - m * 2;
        res += d * m;
    }
    res += n * s;
    cout << res << endl;
    return 0;
}



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

#define ll long long int
#define li int64_t

int main()
{
	int n;
	cin>>n;
	int a[n],b[n];
	bool flag = false;
	for(int i=0;i<n;i++)
	{
		cin>>a[i]>>b[i];
	}
	for(int i=0;i<n-2;i++)
	{
		if(a[i] == b[i] && a[i+1] == b[i+1] && a[i+2] == b[i+2] )
		{
			flag = true;
		}
	}
	if(flag)
	{
		 cout<<"Yes\n";
	}
	else
	{
		cout<<"No\n";
	}
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int a[4];
    for(int i=0;i<3;i++){
        scanf("%d",&a[i]);
    }
    sort(a,a+3);
    printf("%d",a[0]+a[1]);
    return 0;
}




Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))[::-1]
b=list(map(int,input().split()))[::-1]
ans=0
for i in range(n):
  c=max(b[i]-a[i],0)
  ans+=min(b[i],a[i])
  ans+=min(c,a[i+1])
  a[i+1]=max(a[i+1]-c,0)
  
print(ans)

Measured memory_bytes: 18624
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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

func main() {
	sc.Split(bufio.ScanWords)

	N := getInt()
	rate := make([]int, 9)
	for i := 0; i < N; i++ {
		a := getInt()
		switch {
		case a >= 1 && a <= 399:
			rate[0]++
		case a >= 400 && a <= 799:
			rate[1]++
		case a >= 800 && a <= 1199:
			rate[2]++
		case a >= 1200 && a <= 1599:
			rate[3]++
		case a >= 1600 && a <= 1999:
			rate[4]++
		case a >= 2000 && a <= 2399:
			rate[5]++
		case a >= 2400 && a <= 2799:
			rate[6]++
		case a >= 2800 && a <= 3199:
			rate[7]++
		case a >= 3200:
			rate[8]++
		}
	}

	ans := 0
	for i := 0; i < 8; i++ {
		if rate[i] != 0 {
			ans++
		}
	}
	min := ans
	if ans == 0 {
		min = 1
	}
	max := ans + rate[8]
	out(min, max)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
#define mod 1000000007
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define setA0(a) for(ull i =0;i<n;i++){a[i] = 0;}
#define aout(a) for(auto x : a){cout<<x<<' ';} // array output macro 
#define ain(a) for(ull i =0;i<n;i++){cin>>a[i];} //array input macro
#define NofSetBits(x) __builtin_popcount(x);
#define InpGrph(g,e) while(e--){ll x;ll y;cin>>x>>y ;g[x].pub(y);g[y].pub(x);}
#define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);


int main(){
  FastIO;
  int a,b;
  cin>>a>>b;
  cout<<(a^b^1^2^3);
  return 0;
}


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

int main() {
	int N,c;
	cin >> N;
	int a[N];
	for(int i = 0;i<N;i++)
		cin >> a[i];
	c=0;
	for(int i = 0;i<N;i++){
		for(;a[i]%2!=1;c++){
			a[i]=a[i]/2;
		}
	}
	cout << c << endl;
	return 0;
}

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

int main(){

    int N, ans;
    cin >> N;
    
    if (N % 1000 == 0){
        ans = 0;
    } else {
        ans = 1000 - (N % 1000);
    }

    cout << ans << "\n";

    return 0;
}



Measured memory_bytes: 3156
#include <iostream>
using namespace std;
int main()
{
    int a,b,c,max,min;
   while( cin>>a>>b>>c)
   {
    if(a<b)
		min=a;
	else
		min=b;
	if(c<min)
		min=c;
    cout<<min<<" ";
	if(a>b)
		max=a;
	else
		max=b;
	if(c>max)
		max=c;
	cout<<max;
	cout<<endl;
   }
}


Measured memory_bytes: 3136
#!/usr/bin/env python3

import sys
from math import gcd
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

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


# L[i] = gcd(A[0], A[1], ... , A[i-1])
# R[N-i] = gcd(A[i+1], A[i+2], ..., A[N-1])
L = [0]
R = [0]

for i in range(N):
    L.append(gcd(L[i], A[i]))
    R.append(gcd(R[i], A[N-i-1]))


# M[i] = gcd(L[i], R[N-i
M = [gcd(L[i], R[N-i-1]) for i in range(N)]
print(max(M))



Measured memory_bytes: 25524
def main():
    mod=998244353
    n,s=map(int,input().split())
    a=list(map(int, input().split()))
    dp=[0]*(s+1)
    ans=0
    for i,x in enumerate(a):
        dp[0]+=1
        if x>s:
            continue
        ans=(ans+dp[s-x]*(n-i))%mod
        for k in range(s-1,x-1,-1):
            dp[k]=(dp[k]+dp[k-x])%mod
    print(ans)
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 39920
/* author   : mpily :-()
title : Competing.cpp
time :Sat Dec 21 07:56:01 2019

*/
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	int left = 0;
	int count =  0;
	int right = s.size()-1;
	while(left  < right){
		if(s[left] != s[right])count+=1;
		left+=1;
		right-=1;
	}
	cout<<count<<"\n";
	return  0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include<functional>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <typeinfo>
#define PI 3.14159265359
#define INF 99999999;
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(n) rep(i, n)
#define EPS 1e-10
typedef long long ll;
using namespace std;



/*
class Target
{
public:
	vector <string> draw(int n)
	{

	}
};
*/



int main()
{
	for (char s[5]; scanf("%s", s), strcmp(s, "0000")!=0;)
	{
		if (count(s, s + 4, s[0]) == 4)
		{
			cout << "NA" << endl;
			continue;
		}
		
		int ans = 0;
		while (strcmp(s, "6174") != 0)
		{
			char s1[5];
			strcpy(s1, s);
			sort(s1, s1 + 4);
			char s2[5];
			strcpy(s2, s);
			sort(s2, s2 + 4, greater<char>());
			int a1 = atoi(s1);
			int a2 = atoi(s2);
			sprintf(s, "%04d", a2 - a1);
			ans++;
		}
		cout << ans << endl;
	}
	
	return 0;
}

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

/**
 * vector<int>ar(3);
 * for(auto&e:ar){
 *     scanf("%d",&e);
 * }
 * sort(ar.begin(),ar.end())
 * int sum=accumulate(ar.begin(),ar.end(),0);
 ***/

int main(){
    double pai=3.141592653589;
    int a,b;
    char op;
    for(;;){
        scanf("%d %s %d",&a,&op,&b);
        if(op=='?'){
            break;
        }else if(op=='+'){
            printf("%d\n",a+b);
        }else if(op=='-'){
            printf("%d\n",a-b);
        }else if(op=='*'){
            printf("%d\n",a*b);
        }else if(op=='/'){
            printf("%d\n",a/b);
        }
    }
    return 0;
}

Measured memory_bytes: 1172
PROGRAM piyo
      IMPLICIT NONE
      integer(16) :: ans,n,i
      
      read*,n
      
      ans = 0
      do i = 1,n
        if( mod(i,3)/=0 .and. mod(i,5)/=0 )then
          ans = ans + i
        endif
      end do
      
      
      print*,ans
      
      
      
      END PROGRAM

Measured memory_bytes: 2764
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)





int main() {
    int n;
    scanf("%d", &n);
    vector<ll> a(n), b(n);
    vector<pair<ll, int>> v(n);
    for(int i = 0; i < n; i++){
        scanf("%lld %lld", &a[i], &b[i]);
        v[i] = {a[i] + b[i], i};
    }
    sort(v.begin(), v.end(), greater<pair<ll, int>>());
    ll ans = 0;
    for(int i = 0; i < n; i++){
        if(i & 1){
            ans -= b[v[i].second];
        }
        else{
            ans += a[v[i].second];
        }
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 3328
//pragma
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

#define YOU using
#define DONT namespace
#define SAY std

YOU DONT SAY;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define REPP(i,a,b,d) for(int i=a;i<=b;i+=d)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,d) for(int i=a;i>=b;i-=d)
#define REV(i,a,b) REVV(i,a,b,1)

#define FOR(i,a) for(int i=0; i<a; i++)
#define FORD(i,a) for(int i=(int)a-1; i>=0; i--)

#define mp make_pair

#define pb push_back
#define F first
#define S second

const int OO = 1e9;
const ll INF = 1e18;

const int irand(int lo,int hi){
	return ((double)rand()/(RAND_MAX + 1.0)) * (hi-lo+1) + lo;
}

const ll lrand(ll lo,ll hi){
	return ((double)rand()/(RAND_MAX + 1.0)) * (hi-lo+1) + lo;
}

#define getc getchar
template<typename T>
T getnum(){
	int sign = 1;
	T ret = 0;
	char c;

	do{
		c = getc();
	}while(c == ' ' || c == '\n');
	if(c == '-')sign = -1;
	else ret = c-'0';
	while(1){
		c = getc();
		if(c < '0' || c > '9')break;
		ret = 10*ret + c-'0';
	}
	return sign * ret;
}

inline void ini(int& x){
	x = getnum<int>();
}

inline void scani(int& x){
	scanf("%d",&x);
}

//end of macro

const ll MOD = 1e9 + 7;

inline ll addmod(ll a, ll b){
    if(a+b<MOD)return a+b;
    return a+b-MOD;
}
inline ll submod(ll a, ll b){
    return addmod(a, MOD-b);
}
inline ll mulmod(ll a, ll b){
    return (a*b)%MOD;
}
inline ll expmod(ll a, ll e){
    ll ret = 1;
    while(e){
        if(e&1)ret = mulmod(ret, a);
        a = mulmod(a, a);
        e >>= 1;
    }
    return ret;
}
inline ll divmod(ll a, ll b){
    return mulmod(a, expmod(b, MOD-2));
}

const int N = 5005;

int n;
string str;

int memo[N][N];
int dp(int now, int left){
    if(left == 0)return (now==str.size()) ? 1 : 0;
    int& ret = memo[now][left];
    if(ret != -1)return ret;
    
    // advance
    ret = dp(now+1, left-1);
    
    // backspace
    if(now == 0)ret = addmod(ret, dp(now, left-1));
    else ret = addmod(ret, mulmod(2, dp(now-1, left-1)));
    
    return ret;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #define endl '\n'
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(10);
    
    cin>>n>>str;
    memset(memo, -1, sizeof memo);
    cout << dp(0, n) << endl;
    
    return 0;
}

Measured memory_bytes: 98432
#include <bits/stdc++.h> 
using namespace std; 
#define for_(i, s, e) for (int i = s; i < e; i++)
#define for__(i, s, e) for (ull i = s; i < e; i++)
#define SSTR(x) static_cast<std::ostringstream&>((std::ostringstream() << std::dec << x)).str()
typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;


int main() {
    #ifndef ONLINE_JUDGE
	// freopen("test.in", "r", stdin);
    #endif
    
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n; cin >> n;
    vi nums(n);
    for_(i, 0, n) {
        cin >> nums[i];
    }

    ll ans = 10000000000000;
    for_(k, 1, 101) {
        ll sum = 0;
        for_(i, 0, n) {
            ll d = k - nums[i];
            sum += d*d;
        }
        ans = min(ans, sum);
    }
    cout << ans << endl;


    return 0;
}

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

int main() {
  int A,B,C,D,E,F,G,H,J;
  cin>>A>>B>>C;
  cin>>D>>E>>F;
  cin>>G>>H>>J;
  int a=0,b=0,c=0,d=0,e=0,f=0,g=0,h=0,j=0;
  
  int N;
  cin>>N;
  
  int Z;

  for (int i;i<N;i++)
  {
    cin>>Z;
    if(A==Z) a++;
    else if (B==Z) b++;
    else if (C==Z) c++;
    else if (D==Z) d++;
    else if (E==Z) e++;
    else if (F==Z) f++;
    else if (G==Z) g++;
    else if (H==Z) h++;
    else if (J==Z) j++;
  }
  if (a+b+c==3||d+e+f==3||g+h+j==3||a+e+j==3||c+e+g==3||a+d+g==3||b+e+h==3||c+f+j==3)
    cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
<?php
list($a,$b,$C) = explode(" ",trim(fgets(STDIN)));
$h = $b * sin(deg2rad($C));
$S = $a * $h / 2;
$CC = pow($a,2) + pow($b,2) - 2 * $a * $b * cos(deg2rad($C));
$L = $a + $b + sqrt($CC);
echo sprintf("%.5f\n",$S);
echo sprintf("%.5f\n",$L);
echo sprintf("%.5f\n",$h);

Measured memory_bytes: 15620
#include <stdio.h>

#define Max 100000

struct queue {
	char name[10];
	int time;
	int jump;
}; typedef struct queue queue;

queue A[Max];

void  swap(queue *x, queue *y)
{
    queue  buff;
	
	buff = *x;
	*x = *y;  
	*y = buff;
}

int main( ) {
	int n, q, i, j, total_time, new_i, count;

	scanf("%d %d", &n, &q);

	for (i = 0; i < n; i++) {
		scanf("%s %d", A[i].name, &A[i].time);
		A[i].jump = 0;
	}

	j = n;
	i = 0;
	total_time = 0;

	while (j > 0) {
		new_i = 0;
		count = 0;
		for (i = 0; i < j; i++) {
			if (A[i].time <= q) {
				total_time += A[i].time;
				printf("%s %d\n", A[i].name, total_time);
				count++;
			}
			else {
				total_time += q;
				A[i].time -= q;
				swap(&A[new_i++], &A[i]);
			}
		}
		j -= count;
	}

	return 0;
}

Measured memory_bytes: 1576
import java.util.*;

public class Main {

    private static int MOD = 1_000_000_007;

    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }


    // int N = Integer.parseInt(scanner.nextLine());
    // int N = scanner.nextInt(), M = scanner.nextInt();
    // scanner.nextLine();
    // int[] n = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    // long[] n = Arrays.stream(scanner.nextLine().split(" ")).mapToLong(Long::parseLong).toArray();
    static void solve(Scanner scanner) {
        scanner.nextLine();
        String S = scanner.nextLine();
        if (S.length() % 2 == 1) {
            System.out.println("No");
            return;
        }
        String f = S.substring(0, S.length() / 2);
        String l = S.substring(S.length() / 2);
        System.out.println(f.equals(l) ? "Yes" : "No");
    }

}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
namespace modular_space {
	long long mod;
	struct umod {
		long long val;
		umod(): val(0ll){}
		umod(long long x){ x %= mod; if(x < 0) x += mod; val = x; }
		umod& operator += (umod oth){ val += oth.val; if(val >= mod) val -= mod; return *this; }
		umod& operator -= (umod oth){ val -= oth.val; if(val < 0) val += mod; return *this; }
		umod& operator *= (umod oth){ val = val * oth.val % mod; return *this; }
		umod& operator /= (umod oth){ return *this *= oth.inverse(); }
		umod& operator ^= (long long oth){ return *this = pwr(*this, oth); }
		umod operator + (umod oth) const { return umod(*this) += oth; }
	       	umod operator - (umod oth) const { return umod(*this) -= oth; }
		umod operator * (umod oth) const { return umod(*this) *= oth; }
		umod operator / (umod oth) const { return umod(*this) /= oth; }
		umod operator ^ (long long oth) const { return umod(*this) ^= oth; }
		bool operator < (umod oth) const { return val < oth.val; }
		bool operator > (umod oth) const { return val > oth.val; }
		bool operator <= (umod oth) const { return val <= oth.val; }
		bool operator >= (umod oth) const { return val >= oth.val; }
		bool operator == (umod oth) const { return val == oth.val; }
		bool operator != (umod oth) const { return val != oth.val; }
		umod pwr(umod a, long long b) const {
			umod r = 1;
			for(; b; a *= a, b >>= 1)
				if(b&1)
					r *= a;
			return r;
		}
		umod inverse() const {
			long long a = val, b = mod, u = 1, v = 0;
			while(b){
				long long t = a/b;
				a -= t * b; swap(a, b);
				u -= t * v; swap(u, v);
			}
			if(u < 0)
				u += mod;
			return u;
		}
		friend istream& operator >> (istream &is, umod &oth);
		friend ostream& operator << (ostream &os, const umod& oth);
	};
	ostream& operator << (ostream &os, const umod &oth){
		os << oth.val;
		return os;
	}
	istream& operator >> (istream &is, umod &oth){
		long long x; is >> x;
		oth = umod(x);
		return is;
	}
	struct binprime_kit {
		int sz;
		vector<umod> fat, ifat;
		void init(int s){
			sz = s;
			fat.resize(sz + 1);
			ifat.resize(sz + 1);
			fat[0] = 1;
			for(int i = 1; i <= sz; i++) fat[i] = fat[i - 1] * i;
			ifat[sz] = fat[sz] ^ (mod - 2);
			for(int i = sz - 1; i >= 0; i--) ifat[i] = ifat[i + 1] * (i + 1);
		}
		umod coef(int n, int r){
			if(n < r) return 0;
			return fat[n] / (ifat[r] * ifat[n - r]);
		}
	};
};
using umod = modular_space::umod;
const int maxn = 202;
int x[maxn], y[maxn];
int seen[maxn][maxn];
int main(){
	modular_space::mod = 998244353;
	int n; cin >> n;
	for(int i = 0; i < n; i++) cin >> x[i] >> y[i];
	umod ans = umod(2) ^ n;
	for(int i = 0; i < n; i++){
		for(int j = i + 1; j < n; j++){
			if(seen[i][j]) continue;
			vector<int> now;
			for(int k = 0; k < n; k++){
				int val = (x[k] - x[i]) * (y[j] - y[i]) - (x[j] - x[i]) * (y[k] - y[i]);
				if(val == 0){
					now.push_back(k);
				}
			}
			int len = now.size();
			ans -= umod(2) ^ len;
			ans += len + 1;
			for(int k = 0; k < len; k++) for(int l = k + 1; l < len; l++) seen[now[k]][now[l]] = 1;
		}
	}
	ans -= n + 1;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<queue>
#include<time.h>
using namespace std;
int main()
{
    int n,x,i,j;
   int s[100008]={0};
    long long int r=0;
    scanf("%d%d",&n,&x);
    for(i=0;i<n;i++)
    {
        scanf("%d",&s[i]);
        if(s[i]>x)
        {
            r=r-x+s[i];
            s[i]=x;
        }
    }
    for(i=1;i<n;i++)
    {
        if(s[i]+s[i-1]>x)
        {
//            if(s[i]+s[i+1]<=x)
//            {
//                r=r-x+s[i]+s[i-1];
//                s[i]=s[i]-x+s[i-1];
//            }
//            else if(s[i]+s[i+1]>x)
//            {
//                int w=max(s[i]-x+s[i-1],s[i+1]-x+s[i]);
//
//            }
                r=r-x+s[i]+s[i-1];
                s[i]=s[i]-s[i]+x-s[i-1];

        }
    }
    printf("%lld\n",r);
    return 0;
}


Measured memory_bytes: 640
def smallk(n , k , ab):
    count = 0
    for i in range(n):
        if count + int(ab[i][1]) >= k:
            return int(ab[i][0])
        else:
            count += int(ab[i][1])

def main():
    n , k = map(int , input().split())
    ab = [list(map(int,input().split())) for i in range(n)]
    ab.sort()
    print(smallk(n , k , ab))

if __name__ == '__main__':
    main()


Measured memory_bytes: 60632
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

int main()
{
	char a[20], ans[20];
	scanf("%s", a + 1);
	int len = strlen(a + 1);
	int p = 1;
	for(int i = 1; i <= len; i++) {
		if(a[i] == '0' || a[i] == '1') {
			ans[p] = a[i];
			p++;
		}
		else if(a[i] == 'B' && i != 1 && p != 1) {
			p--;
		}
		else if(p == 1 && a[i] == 'B') continue;
	}
	for(int i = 1; i < p; i++) {
		printf("%c", ans[i]);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstring>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int MOD = 1e9+7;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  rep(i, n) cin >> a[i];
  rep(i, n) cin >> b[i];
  vector<int> h(n);
  h[0] = a[0];
  for (int i = 1; i < n; i++) {
    if (a[i] != a[i-1])
      h[i] = a[i];
  }
  if (h.back() && h.back() != b.back()) {
    cout << 0 << endl;
    return 0;
  }
  h.back() = b.back();
  for (int i = n-2; i >= 0; i--) {
    if (h[i]) {
      if (b[i] != b[i+1] && h[i] != b[i]) {
        cout << 0 << endl;
        return 0;
      }
      if (b[i] == b[i+1] && h[i] > b[i]) {
        cout << 0 << endl;
        return 0;
      }
    }
    else if (b[i] != b[i+1])
      h[i] = b[i];
  }
  ll ans = 1;
  rep(i, n) {
    if (!h[i])
      (ans *= min(a[i-1], b[i+1])) %= MOD;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1408
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
using namespace std;
//#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=1000050;
//ここまでテンプレ
int main(){
	int N;
	cin>>N;
	cout<<N/3<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; inline void fileio(const char* in, const char* out) { freopen(in, "r", stdin); freopen(out, "w", stdout); } 
#define TD typedef
#define forx(i,n) for(int i = 0; i < (n); ++i)
TD long long ll; TD long double ld; TD pair<int,int> pii; TD pair<ll, ll> pll; TD vector<int> VI; TD vector<bool> VB; TD vector<ll> VL;
const char nl = '\n'; const int INF = 0x3f3f3f3f; const ll LINF = 0x3f3f3f3f3f3f3f3fll; const ld EPS = 1e-9, PI = acos(-1);
#define ff first
#define ss second

class ModInt {
  ll val; static const int MOD = 1e9 + 7; static_assert(MOD > 0ll, "Modulus not set!");
  int modInverse(int a) { // simplified extended GCD, only solving for x
    int b = MOD, x = 0, x_ = 1, q; while (a != 0) { q = b / a; swap(b, a); a %= b;
    swap(x, x_); x_ -= q * x; } assert(b == 1); return (x %= MOD) < 0 ? (x + MOD) : x; }
  public: ModInt() : val(0) { } ModInt(int v) : val(v) { if ((val %= MOD) < 0) val += MOD; }
    ModInt& operator += (const ModInt& b) { if ((val += b.val) >= MOD) val -= MOD; return *this; }
    ModInt& operator -= (const ModInt& b) { if ((val -= b.val) < 0) val += MOD; return *this; }
    ModInt& operator *= (const ModInt& b) { val = (val*b.val) % MOD; return *this; }
    ModInt& operator /= (const ModInt& b) { if (((val *= modInverse(b.val)) %= MOD) < 0) val += MOD; return *this; }
#define _op(op, btype, op2) ModInt operator op (btype b) const { ModInt ans = *this; return ans op2 b; }
    _op(+, const ModInt&, +=); _op(-, const ModInt&, -=); _op(*, const ModInt&, *=); _op(/, const ModInt&, /=);
    _op(+, int, +=); _op(-, int, -=); _op(*, int, *=); _op(/, int, /=);
#undef _op
    operator int() const { assert(0 <= val && val < MOD); return val; }
};

int n;
bool compat[22][22];
bool is_set[22][2097152 + 5];
ModInt mem[22][2097152 + 5];

//j_[k] = false iff the kth woman is free
// considering the ith man, picking from remaining women encoded by j
ModInt solve(int i, int j_) {
  if (i == n) return 1; //made it to the end
  if (!is_set[i][j_]) {
    mem[i][j_] = 0;
    for (int k = 0; k < n; k++) {
      if (!(j_ & (1 << k)) && compat[i][k]) {
        //try this woman
        mem[i][j_] += solve(i+1, j_ | (1 << k));
      }
    }
    is_set[i][j_] = true;
  }
  return mem[i][j_]; 
}

int main() {
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  // Emily <3
  cin >> n;
  int temp;
  forx(i,n) forx(j,n) {
    cin >> temp;
    compat[i][j] = temp;
  }
  
  cout << solve(0, 0) << nl;

  cerr << "Time: " << (ld)clock() / CLOCKS_PER_SEC << nl;
  return 0;
}



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

int main(void){
  int n,i,j,flag=0,l;
  char w[100][256];

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",w[i]);
  }
  for(i=0;i<n-1;i++){
    for(j=i+1;j<n;j++){
      if(strcmp(w[i],w[j])==0){
	flag++;
      }
    }
    if(flag!=0){
      printf("No\n");
      return 0;
    }
    flag=0;
  }

  for(i=0;i<n-1;i++){
    l = strlen(w[i]);
    if(w[i][l-1]!=w[i+1][0]){
      printf("No\n");
      return 0;
    }
  }
  printf("Yes\n");



  return 0;
}


Measured memory_bytes: 128
#include<set>
#include<map>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<math.h>
#include<time.h>
#include<vector>
#include<bitset>
#include<memory>
#include<utility>
#include<fstream>
#include<stdio.h>
#include<sstream>
#include<iostream>
#include<stdlib.h>
#include<string.h>
#include<algorithm>
using namespace std;
char a[305];
int dp[305][305][305];
int n;
void dfs(int l,int r,int k)
{
    if (dp[l][r][k]!=-1)
    {
        return;
    }
    if (l>=r)
    {
        dp[l][r][k]=0;
        return;
    }
    if (k>=r-l)
    {
        dp[l][r][k]=r-l;
        return;
    }
    dfs(l+1,r,k);
    dp[l][r][k]=dp[l+1][r][k];
    int i;
    for (i=l;i<r;i++)
    {
        if (a[l]==a[i])
        {
            dfs(l+1,i,k);
            if (l+1<=i)
            {
                dp[l][r][k]=max(dp[l][r][k],dp[l+1][i][k]+2);
            }
            else
            {
                dp[l][r][k]=max(dp[l][r][k],dp[l+1][i][k]+1);
            }
        }
        else if (k>0)
        {
            dfs(l+1,i,k-1);
            if (l+1<=i)
            {
                dp[l][r][k]=max(dp[l][r][k],dp[l+1][i][k-1]+2);
            }
            else
            {
                dp[l][r][k]=max(dp[l][r][k],dp[l+1][i][k-1]+1);
            }
        }
    }
}
int main()
{
    #ifdef absi2011
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    memset(dp,-1,sizeof(dp));
    scanf("%s",a);
    n=strlen(a);
    int k;
    scanf("%d",&k);
    dfs(0,n,k);
    printf("%d\n",dp[0][n][k]);
    return 0;
} 


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

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define SORT(v, n) sort(v, v+n)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define ddvi vector<vector<int>>

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

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
// ここに処理を記述

	int N;

	cin >> N;

	FOR(i,1,50000){
		int val = (int)i*1.08;
		if( val == N){
			cout << i << "\n";
			return 0;
		}
	}

	cout << ":(" << "\n";

return 0;
}

Measured memory_bytes: 256
#![allow(unused_mut, unused_macros, unused_variables, unused_assignments, non_snake_case, unused_imports)]

use std::cmp::*;
use std::collections::*;

// [Rustで競技プログラミングの入力をスッキリ記述するマクロ - Qiita]
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 から拝借
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    // ABC128-C-Switches用に拡張
    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, $t);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        N : usize, M : usize,
        A : [usize; N],
        BC : [(usize, usize); M]
    }

    let mut cards = HashMap::new();
    for a in &A {
        *cards.entry(*a).or_insert(0) += 1;
    }
    for tu in BC {
        *cards.entry(tu.1).or_insert(0) += tu.0;
    }
    let sorted_keys = {
        let mut keys = Vec::new();
        for key in cards.keys() {
            keys.push(key);
        }
        keys.sort();
        keys.reverse();
        keys
    };
    let (mut sum_value, mut sum_num) = (0u64, N);
    for key in sorted_keys {
        //println!("{} {} {}", key, sum_num, sum_value);
        let current_num = cards[key];
        if sum_num < current_num {
            sum_value += (key * sum_num) as u64;
            break;
        }
        sum_value += (key * current_num) as u64;
        sum_num -= current_num;
    }
    println!("{:?}", sum_value);
}


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

int main() {
    string s;
    cin >> s;
    map<char,int> m;
    rep(i,4) {
        m[s[i]] ++;
    }
    if(m.size() != 2) cout << "No" << endl;
    else {
        bool flag = true;
        for(auto p : m) {
            if(p.second != 2) flag = false;
            break;
        }
        if(flag) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

Measured memory_bytes: 384
"use strict";
function Main(input) {
    let n = input.split("\n")[0].split(/\s/).map((v) => v - 0) 
    let ans = (n[0] == n[1]) && (n[1] == n[2]) && (n[0] == n[2]);
    console.log(ans ? "Yes" : "No");
}
 Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

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

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
  string s[100001];
  ll n, result = 0, ma[5] = {0};
  cin >> n;
  rep(i, n) {
    cin >> s[i];
    switch (s[i].at(0)) {
      case 'M':
        ma[0]++;
        break;
      case 'A':
        ma[1]++;
        break;
      case 'R':
        ma[2]++;
        break;
      case 'C':
        ma[3]++;
        break;
      case 'H':
        ma[4]++;
        break;
      default:
        break;
    }
  }

  rep(i, 5) {
    FOR(j, i + 1, 5) {
      FOR(k, j + 1, 5) {
        result += ma[i] * ma[j] * ma[k];
      }
    }
  }
  cout << result << endl;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  if (a < b) swap(a, b);
  int c = a - b;
  if (c % 2 == 1) {
    cout << "IMPOSSIBLE" << endl;
    return 0;
  }
  int ans = b + c / 2;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;
int main(){
    int n,d;
    cin >> n >> d;
    int k = 2*d + 1;
    int ans = 0;
    int cnt = 0;
    while(cnt < n){
        ans ++;
        cnt += k;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
  val (N, K) = readInts()
  val (R, S, P) = readInts()
  val T = readLine()!!.toMutableList()

  fun getWinPoint(enemy: Char) = when (enemy) {
    'r' -> P
    's' -> R
    'p' -> S
    else -> 0
  }

  var sum = 0
  for (i in 0 until N) {
    val l = T.getOrNull(i - K) ?: '?'
    val r = T[i]
    if (l != r) {
      sum += getWinPoint(r)
    } else {
      T[i] = '*'
    }
  }

  println(sum)
}

fun readInts() = readLine()!!.split(" ").map { it.toInt() }


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

int main(){
	int M,N,A;
  	cin >> N >> M;
  	for(int i = 0;i < M;i++){
    	cin >> A;
      	N -= A;
    }
  	if(N < 0){
    	cout << -1 << endl;
    }else{
    	cout << N << endl;
    }
}

Measured memory_bytes: 3632
/* Author - thiolhub */

#include <bits/stdc++.h>

using namespace std;

#define ll              long long int
#define ld              long double
#define db              double
#define pi              3.1415926535897932384626
#define PI              acos(-1.0)
#define endl            "\n"
#define mod             1000000007
#define mk              make_pair
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(t)            ll t; cin>>t; while(t--)
#define sc(a)	        scanf("%lld",&a);
#define pr(a)	        printf("%lld\n",a)
#define f(i,a,n)		for(ll i=a;i<n;i++)
#define m(a)		    memset(a,0,sizeof(a))
#define FastIO          ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)


int main(){ FastIO;

ll i,j,k,n;cin>>n;
unordered_map<string,ll> h;
for(i=0;i<n;i++)
{
	string s;cin>>s;
	sort(s.begin(),s.end());
	h[s]++;
}
ll res=0;
for(auto u : h)
{
	res+=(u.second*(u.second-1))/2;
}
cout<<res;



return 0;
}


Measured memory_bytes: 10660
a = input()
if a == 'SUN':
    print(7)
elif a == 'MON':
    print(6)
elif a == 'TUE':
    print(5)
elif a == 'WED':
    print(4)
elif a == 'THU':
    print(3)
elif a == 'FRI':
    print(2)
elif a == 'SAT':
    print(1)


Measured memory_bytes: 38256
// D - Brick Break
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

int solve(int N, vi &A){
	int ans = 0, ix = 1;
	rp(i, 0, N) if(A[i] != ix) ans++; else ix++;
	return ans<N? ans:-1;
}

int main(){
	int N; cin>>N;
	vi A(N); rp(i, 0, N) cin>>A[i];
	cout<< solve(N,A) <<endl;
}

Measured memory_bytes: 1024