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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define fst first
#define snd second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define EPS (1e-9)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

const string YES = "";
const string NO  = "";

typedef long long ll;
typedef pair<int,int> ii;

struct Data {
  ll x,y,v;
  bool operator < ( const Data &data) const {
    if( x != data.x ) return x < data.x;
    return v < data.v;
  }
};

#define MAX 3010
int H,W,K;
ll vs[MAX][MAX];
ll dp[MAX][MAX][4];


void solve() {
  ll maxi = 0;
  memset(dp, -1, sizeof dp);
  dp[0][0][3] = 0;
  if( vs[0][0] != -1 ) {
    dp[0][0][2] = vs[0][0];
    maxi = max(maxi,dp[0][0][2]);
  }
  
  rep(i,H) {
    rep(j,W) {
      rep(rem,4) {
      	if( dp[i][j][rem] == -1 ) continue;
	// do nothing
	if( i + 1 < H ) {
	  dp[i+1][j][3] = max(dp[i+1][j][3], dp[i][j][rem]);
	  //maxi = max(maxi,dp[i+1][j][3]);
	}
	if( j + 1 < W ) {
	  dp[i][j+1][rem] = max(dp[i][j+1][rem], dp[i][j][rem]);
	  //maxi = max(maxi,dp[i][j+1][rem]); 
	}
	// do
	if( i + 1 < H ) {
	  if( vs[i+1][j] != -1 ) {
	    ll v = vs[i+1][j];
	    dp[i+1][j][2] = max(dp[i+1][j][2], dp[i][j][rem]+v);
	    maxi = max(maxi,dp[i+1][j][2]);
	  }
	}
	if( rem - 1 >= 0 && j + 1 < W ) {
	  if( vs[i][j+1] != -1 ) {
	    ll v = vs[i][j+1];
	    dp[i][j+1][rem-1] = max(dp[i][j+1][rem-1], dp[i][j][rem]+v);

	    maxi = max(maxi,dp[i][j+1][rem-1]);
	  }
	}
      }
    }
  }
  cout << maxi << endl;
}

int main() {
  cin >> H >> W >> K;
  memset(vs, -1, sizeof vs);
  ll x,y,v;
  rep(i,K) {
    cin >> y >> x >> v;
    --y, --x;
    vs[y][x] = v;
  }
  //rep(i,MAX) sort(ALL(deq[i]));
  solve();
  return 0;
}


Measured memory_bytes: 357520
import sys
input = lambda: sys.stdin.readline().rstrip()
N = int(input())
def I():
    s = input()
    mi = 0
    su = 0
    t = 0
    for a in s:
        if a == "(":
            t += 1
        else:
            t -= 1
            mi = min(mi, t)
    return (mi, t)

X = [I() for _ in range(N)]
if sum([x[1] for x in X]):
    print("No")
    exit()

X = sorted(X, key = lambda x: -10**10 if x[0] == 0 else -10**9 - x[0] if x[1] > 0 else x[0] - x[1])
T = 0
for mi, t in X:
    if T + mi < 0:
        print("No")
        exit()
    T += t
print("Yes")

Measured memory_bytes: 99640
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int num = 0;
		boolean flag = false;
		for(int i=1; i*(i+1)<=2*n; i++){
			if(i*(i+1)==2*n){
				num = i;
				flag = true;
				break;
			}
		}
		if(flag==false){
			System.out.println("No");
		}
		else{
			int[][] s = new int[num+1][num+1];
			for(int i=0; i<=num; i++){
				s[i][0] = num;
			}
			int[] cnt = new int[num+1];
			for(int i=0; i<num; i++){
				for(int j=0; j<=i; j++){
					s[j][++cnt[j]] = i*(i+1)/2 + 1 + j;
					s[i+1][++cnt[i+1]] = i*(i+1)/2 + 1 + j;
				}
			}
			System.out.println("Yes");
			System.out.println(num + 1);
			for(int i=0; i<num+1; i++){
				for(int j=0; j<num+1; j++){
					System.out.print(s[i][j] + " ");
				}
				System.out.println("");
			}
		}
	}
}

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

int main() {
    char X, Y;
    cin >> X >> Y;
    if (X > Y) {
        cout << '>' << endl;
    } else if (X < Y) {
        cout << '<' << endl;
    } else {
        cout << '=' << endl;
    }
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = [int(i) for i in input().split()]
Total = abs(A[0]) + abs(A[N-1])
for i in range(1, N):
    Total += abs(A[i]-A[i-1])

start = 0
for i in range(N-1):
    cut = abs(A[i+1] - A[i]) + abs(A[i]-start) - abs(A[i+1] - start)
    print(Total - cut)
    start = A[i]
cut = abs(0 - A[N-1]) + abs(A[N-1] - start) - abs(0 - start)
print(Total - cut)

Measured memory_bytes: 14048
import numpy as np
n,m,x = map(int,input().split())
a = [list(map(int,input().split())) for i in range(n)]

ans = np.inf
flag = 0
for i in range(2**n):
    r = np.array([0]*(m+1))
    for j in range(n):
        if (i>>j)&1:
            for k in range(m+1): r[k] += a[j][k]
    if np.all(r[1:]>=x):
        if ans > r[0]: ans = r[0]
        flag = 1
    else: flag = 0

if flag: print(ans)
else: print("-1")


Measured memory_bytes: 27256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
const int mod = 1000000007;
ll modpow(ll a, int b) { return b ? modpow(a * a % mod, b / 2) * (b % 2 ? a : 1) % mod : 1; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a -= mod; }



void solve();

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

  int T;
  // cin >> T;
  T = 1;

  while (T--) {
      solve();
  }
}

void solve() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<int> v(26);
  rep(i, n) v[s[i] - 'a']++;
  ll ans = 1;
  rep(i, 26) (ans *= 1 + v[i]) %= mod;
  cout << (ans - 1 + mod) % mod << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vlll = vector<vll>; using vpll = vector<pll>;
using vs = vector<string>; using tll = tuple<ll, ll, ll>; using vtll = vector<tll>;
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; }
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define co(i) cout << i << endl;
#define co2(i,j) cout << i << " " << j << endl;
#define co3(i) cout << i << " ";
#define po(i) cout << i.first << " " << i.second << endl;
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.second < secondElof.second;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop, bitSearch, bitList, nod, LIS, digitDP, treeDP, Rerooting//
//gcdlcm, isPrime, eratos, primeFactorize, Npow, combination, divisor, modinv, doubling//
//dfs, bfs, dijkstra, WarshallFloyd, BellmanFord, UnionFind, Kruskal, RMQ, LCA, FordFulkerson//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R, Q, T;
ll MOD = 1000000007, INF = 1LL << 60, ans = 0, z = 0, o = 1;
vl flag, D; vector<vpll> path;

int main() {
	ll N, X, T;
	cin >> N >> X >> T;
	cout << ((N - 1) / X + 1)*T;
}







Measured memory_bytes: 3636
#include<cstdio>
#include<iostream>
using namespace std;
int main(){
  int a, b, c, d, e, f,i,j,k,l,ans1,ans2;
  cin >> a >> b >> c >> d >> e >> f;
  ans1=0;
  ans2=0;
  double co=-5;
  for (i=0;i*a*100<=f;i++){
    for(j=0;i*a*100+j*b*100<=f;j++){
      int w=i*a*100+j*b*100;
      for(k=0;c*k<=e*w/100&&w+c*k<=f;k++){
        int s=c*k;
        for (l=0;s+d<=e*w/100&&w+s+d<=f;l++){
          s+=d;
        }
        if(w!=0){
          double res=1000000*s/(w+s);
          if(co<res){
            co=res;
            ans1=w+s;
            ans2=s;
          }
        }
      }
    }
  }
  cout << ans1 << ' ' << ans2 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int arr[n][3];
	for(int i=0;i<n;i++){
		for(int j=0;j<3;j++) cin>>arr[i][j];
	}
	int dp[n][3];
	for(int i=0;i<3;i++){
		dp[0][i]=arr[0][i];
	}
	for(int i=1;i<n;i++){
		dp[i][0]=max(dp[i-1][1],dp[i-1][2])+arr[i][0];
		dp[i][1]=max(dp[i-1][0],dp[i-1][2])+arr[i][1];
		dp[i][2]=max(dp[i-1][0],dp[i-1][1])+arr[i][2];
	}
	cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;
}

Measured memory_bytes: 2688
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>

typedef std::pair<int, int> Pair;

constexpr int MAX_HW = 1000;
constexpr int MAX_N = 9;
constexpr int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

int H, W, N;
int sx[MAX_N], sy[MAX_N], gx[MAX_N], gy[MAX_N];
char map[MAX_HW][MAX_HW];

int bfs(const int& n);

int main(){
    scanf("%d%d%d", &H, &W, &N);
    
    for(int i = 0; i < H; ++i){
        scanf("\n");
        for(int j = 0; j < W; ++j){
            scanf("%c", &map[j][i]);
            if(map[j][i] == 'S'){
                sx[0] = j, sy[0] = i;
            }
            if(map[j][i] >= '1' && map[j][i] < (N + '0')){
                sx[map[j][i] - '0'] = j, sy[map[j][i] - '0'] = i;
                gx[map[j][i] - '0' - 1] = j, gy[map[j][i] - '0' - 1] = i;
            }
            if(map[j][i] == (N + '0')){
                gx[N - 1] = j, gy[N - 1] = i;
            }
        }
    }
    
    int ans = 0;
    for(int i = 0; i < N; ++i){
        ans += bfs(i);
    }
    
    printf("%d\n", ans);
    
    return 0;
}

int bfs(const int& n){
    int dis[MAX_HW][MAX_HW];
    memset(dis, -1, sizeof(dis));
    dis[sx[n]][sy[n]] = 0;
    
    std::queue<Pair> que;
    que.push(Pair(sx[n], sy[n]));
    
    while(que.size()){
        Pair p = que.front(); que.pop();
        
        if(p.first == gx[n] && p.second == gy[n]){
            break;
        }
        
        for(int i = 0; i < 4; ++i){
            int nx = p.first + dx[i], ny = p.second + dy[i];
            if(nx >= 0 && ny >= 0 && nx < W && ny < H && map[nx][ny] != 'X' && dis[nx][ny] == -1){
                que.push(Pair(nx, ny));
                dis[nx][ny] = dis[p.first][p.second] + 1;
            }
        }
    }
    
    return dis[gx[n]][gy[n]];
}





Measured memory_bytes: 7560
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
const double PI=3.14159265358979323846;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

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

void dump(const vector<int> &v)
{
	REP(i, SZ(v)-1){ cout << v[i] << " "; }
	cout << v[SZ(v)-1] << endl;
}

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

	vector<int> v(n);
	REP(i, n){
		cin >> v[i];
	}

	reverse(ALL(v));

	dump(v);

	return 0;
}




Measured memory_bytes: 3124
#include <iostream>
#include <vector>
using namespace std;
int main()
{
	int n, t;
	cin >> n;
	int a[200005], b[200005]={0};
	vector<int> ans;
	int cnt=0;
	for (int i=1; i<=n; i++)
	{
		cin >> a[i];
	}
	for (int i=n; i>=1; i--)
	{
		t=0;
		for (int j=2*i; j<=n; j+=i)
		{
			if (b[j])
			{
				t++;
			}
		}
		if (t%2!=a[i])
		{
			b[i]=1;
			ans.push_back(i);
		}
	}
	cout << ans.size() << endl;
	vector<int>::iterator it=ans.begin();
	if (!ans.empty())
	{
		cout << *it;
		for (it++; it!=ans.end(); it++)
		{
			cout << " " << *it;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
//#include <__msvc_all_public_headers.hpp>
 
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
 
typedef long long  ll;

#define press_F_to_pay_respect ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn for(int i=0;i<n;i++) 
#define fore(i,a,b) for(int i = a; i < (b); i++)
#define pb push_back 
#define pob pop_back()
#define mp make_pair 
#define sc second 
#define f first 
#define ld long double
#define kek cout<<"\n"; 
#define rep(i,a,b) for(int i=a;i<b;i++)
#define all(v) ((v).begin()), ((v).end()) 
#define halt {cout<<"NO"; return 0;}

const ll MOD = 1e9 + 7;
const ll MOD1 = 998244353;
const int N = 5010;
const int INF = 1e8;
const ll LL_INF=1e18;
const long double pi=3.1415926535;
using namespace std;
using namespace __gnu_pbds;
typedef tree<ld,null_type,less<ld>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
int divide(int a, int b)
{
          return (a+b-1)/b;
}
int main()
{
    #if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
    #endif
 press_F_to_pay_respect;
 // cout << fixed << setprecision(12) << ans;
 // string al = "abcdefghijklmnopqrstuvwxyz";
 int questions=1;
 // cin>>questions;
 while(questions--)
 {
        ll x,k,d;
        cin>>x>>k>>d;
        ll was=x;
        if(x==0) 
        {
                  if(k&1) cout<<abs(x+d);
                  else cout<<abs(x);
                  return 0;
        }
        ll cnt=abs(x/d);
        if(k<=cnt)
        {
             if(x<0) x+=k*d;
             else x-=k*d;
        }
        else 
        {
               if(x>0) x-=cnt*d;
               else x+=cnt*d;
               k-=cnt;
               if(x==0)
               {
                  if(k&1) cout<<abs(x+d);
                  else cout<<abs(x);
                  return 0;   
               }
               if(x>0) 
               {
                         
                     if(k&1) cout<<abs(x-d);
                     else cout<<abs(x);
                     return 0;
               }
               else
               {
                         if(k&1) cout<<abs(x+d);
                         else cout<<abs(x);
                         return 0;
               }
        }
        cout<<abs(x);
         
 }
 
 
 
 
 // !!! LOOK AT NUMBER OF QUESTIONS IN A PROBLEM !!! (cin>>questions)
 
 
 
  // cout <<"Runtime is:"<<clock() * 1.0 / CLOCKS_PER_SEC <<endl;
   return 0;
   
   
 
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using pi = pair<int,int>;
constexpr ll mod = 1000000007;
void pPRINTl(ostream& ost) { ost << endl; }
template <class T>void pPRINTL(ostream& ost,T t){ost<<t<<endl;}
template <class T, class... U>void pPRINTl(ostream& ost, T t, U... u) {ost << t << " ";pPRINTl(ost, u...);}
template <class... T>void PRINTl(T... t) { pPRINTl(cout, t...); }
//#define PRINTl
void pPRINT(ostream& ost) {}
template <class T>void pPRINT(ostream& ost, T t){ost<<t<<" ";}
template <class T, class... U>void pPRINT(ostream& ost, T t, U... u) {ost << t << " ";pPRINT(ost, u...);}
template <class... T>void PRINT(T... t) { pPRINT(cout, t...); }
//#define PRINT

//#define DEBUG PRINTl("DEBUG line:",__LINE__)
#define DEBUG 

constexpr ll MAX = 1e9;

int main(){
  
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll a,b;
  
  cin>>a>>b;
  
  ll k = (a+b)/2;
  
  if(a+b==2*k)PRINT(abs(k));
  else PRINT("IMPOSSIBLE");
  
  return 0;
}

Measured memory_bytes: 256
/*
このコード、と～おれ!
Be accepted!
  ∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

//保留所有权利。
#include<iostream>
#include<stdio.h>//printするよ
#include<vector>
#include<algorithm>//辞書順はnext_permutationだよ
#include<set>
#include<string>
#include<sstream>
#include<string.h>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swapで数値交換するよ
//END OF LIBRARIES.
#define rt "\n"//改行を最速化させるよ
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define cncn int cnt=0
#define smsm int sum=0
#define str srting
#define v vector
#define please return
#define AC 0//おまじないだよ
#define Rapid cin.tie(0);ios::sync_with_stdio(false)
//END OF DEFINE.
using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
//printf("%02d:%02d:%02d\n", h, m, s);・・・2文字は埋める・h、m、ｓ
//END OF TYPEDEF.

//最大公約数（GCD）を求めるよ
//最小公倍数（LCM）は＜＜　A × B ÷ GCD　 ＞＞で求まるよ

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}
/*
  for A以上B未満でI探索 for (int I = A; i <= B; i++)

  string s = to_string(i);　iをstringでsに変換

  char　小文字のほうが32大--------------------大文字と小文字の境=93

  大文字→小文字 文字列のn文字目を大文字で出力→ (char)toupper(a[0])

  int i = sqrt (n) で、ｎの平方根(9に対する3)をiに入れる

  pow(a,b) → aのb乗を求める

  s1.erase(n) 文字列s1の、n文字目以降削除
  */
int a=0, b=0, c = 0;
string s = "";

int main(void) {
	//vector,set,map,stack,queue,deque,priority_queue

	int n, r;
	cin >> n >> r;
	if (n >= 10) {
		cout << r << rt;
	}
	else {
		cout << r + (100 * (10 - n)) << rt;
	}

	please AC;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;
public class Main{
 public static void main(String[] args) {
   Scanner kbd =new Scanner(System.in);
   int n =kbd.nextInt();
   int k =kbd.nextInt();
   int[] A= new int[n];
   for(int i=0;i<n;i++){
     A[i]=kbd.nextInt();
   }

   Arrays.sort(A);
   int x=0;
   for(int i=0;i<k;i++){
     x=x+A[i];
   }
   System.out.println(x);
 }
}


Measured memory_bytes: 38952
#include<bits/stdc++.h>
const int M=1e9+7;// M=1e9+7;//M=300000;//
const int N=2e6+5;
typedef long long int ll;
using namespace std;
 
ll cnt(0),sum(0),n,m,x,y,t,i,j,temp,k,ans(0),mn(M),mx(-9e9);
vector<ll> v[N];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	cin>>n>>m;
	ll a[n+1];
	for(i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	for(i=0;i<m;i++)
	{
		cin>>x>>y;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	for(i=1;i<=n;i++)
	{
		bool flag=false;
		//sort(v[i].begin(),v[i].end());
		for(j=v[i].size()-1;j>=0;j--)
		{
			if(a[v[i][j]]<a[i])
			{
				continue;
			}else{
				break;
			}
		}
		if(j<0)
		{
			ans++;
		}
	}
	cout<<ans;
	
}

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

int main() {
    set<int> s;
    int q; cin >> q;
    while (q--) {
        int com, x; cin >> com >> x;
        if (com == 0) {
            s.emplace(x);
            cout << s.size() << endl;
        } else if (com == 1) {
            cout << s.count(x) << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 12456
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
#define vector2(a,b,c) vector<vector<int>> a(b/*縦！w*/,vector<int>(c/*横！w*/))
#define INF 1e10
#define MOD 1e9+7
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>>;
signed main(){
  int a;
  cin>>a;
  vector<int> b(a);
  rep(i,a)
    cin>>b[i];
  sort(all(b));
  bool e=true;
  rep(i,a-1){
    if(b[i]==b[i+1])
      e=false;
      }
  if(e)
    cout<<"YES"<<endl;
    else
      cout<<"NO"<<endl;
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <iomanip>

int main() {
	int N; std::cin >> N;
	int min = N + 1;
	int count = 0;
	for (int i = 0; i < N; ++i) {
		int p;  std::cin >> p;
		min = std::min(p, min);
		if (min == p)++count;
	}
	std::cout << count << std::endl;

	return 0;
}


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

using namespace std;
using llong = long long;
using ldbl = long double;
using P = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

const llong inf = 1100100100100100ll;
const llong mod = 1e9+7;

int main(){
	llong N, K;
	cin >> N >> K;

	ldbl ans = 0;
	vector<llong> ni(41);
	vector<ldbl> logni(41,0);
	ni[0] = 1;
	for (llong i = 1; i < 41; i++)
		ni[i] = ni[i-1]*2;
	for (int i = 0; i < 41; i++)
		logni[i] = log((ldbl)ni[i]*1.0);

	for (int i = 1; i <= N; i++) {
		int n = max(ldbl(0), ((ldbl)log(K) - (ldbl)log(i))/logni[1] + 0.9999);
		ans += (ldbl)1.0 / (ldbl)ni[n]*1.0;
	}

	ans /= (ldbl)N*1.0;
	cout << fixed << setprecision(20) << ans << endl;


	return 0;
}


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

int main(){
    string x;
    int z,result = 1000;
    cin >> x;
    for(int i=0 ;i<x.length()-2; i++){
        string s = x.substr(i,3);
        z = abs(stoi(s)-753);
        result = min(result,z);
    }
    cout << result << endl;
}

Measured memory_bytes: 256
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9;
const ll INF=5e18;
using P=pair<int,int>;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int n,k,h[100005]={},ans=inf;
  cin >> n >> k;
  for(int i=0; i<n; i++) {
    cin >> h[i];
  }
  sort(h,h+n);
  for(int i=0; i<n-k+1; i++) {
    ans=min(ans,h[i+k-1]-h[i]);
  }
  cout << ans <<endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)
#define ROP(i, n)       for(int i = 1 ; i <= n ; i++)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define VECOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define SORT(obj) sort(ALL(obj))
#define GSORT(obj) sort(ALL(obj) , greater<int>())
#define P pair<int , int>
#define V vector<int>
#define VLL vector<long long>
#define M map<int, int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

int main(void) {

	ios::sync_with_stdio(false);	cin.tie(0);
    int K, N;  cin >> K >> N;
    V A(2*N);
    for(int i = 0 ; i < N ; i++){
      int a;  cin >> a;
      A[i] = A[i + N] = a;
    }

    int ans = A[N - 1] - A[0];
    for(int i = 1 ; i < N ; i++)
      ans = min(ans, K-A[i] + A[i+N-1]);
  
    cout << ans << endl;
	return 0;
}

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

typedef long long ll;
#define rep(i,n) for( ll (i)=0; (i)<(n); ++(i) )
#define rpi(i,n) for( int (i)=0; (i)<(n); ++(i) )
#define rpv(d) for(auto& v:d)
#if __cplusplus < 201703L
  std::ostream& co_(){ return std::cout << std::endl; }
  std::istream& cn_(){ return std::cin; }
  template<class Head, class... Args>
  std::ostream& co_( Head&& head, Args&&... args ){ std::cout << head; return co_(std::forward<Args>(args)...); }
  template<class Head, class... Args>
  std::istream& cn_( Head&& head, Args&&... args ){ std::cin >> head; return cn_(std::forward<Args>(args)...); }
#else
  template<class... Args>
  std::ostream& co_( Args... args ){ return std::cout << ... << args << std::endl; }
  template<class... Args>
  std::istream& cn_( Args... args ){ return std::cin >> ... >> args; }
#endif
#define co(...) co_(__VA_ARGS__);
#define cn(...) cn_(__VA_ARGS__);
#define all(x) (x).begin(), (x).end()
#define rgt(x,i) (x).begin(), (x).begin()+(i)

int main(){
  int n,k;cn(n,k)
  int t = 1;
  rpi(i,n){
    t = t+k < 2*t ? t+k : 2*t;
  }
  co(t)
}

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

int main() {
    int n, k, ans = 0;
    cin >> n >> k;
    vector<vector<int> > g(n);
    vector<int> a(n), d(n,1), deg(n);
    cin >> a[0];
    for(int i=1;i<n;i++){
        cin >> a[i];
        a[i]--;
        deg[a[i]]++;
    }
    queue<int> que;
    for(int i=1;i<n;i++){
        if(deg[i]==0) que.push(i);
    }
    while(!que.empty()){
        int v = que.front();
        que.pop();
        if(v == 0) continue;
        if(d[v]==k && a[v] != 0){
            ans++;
            d[v] = 0;
        }
        int p = a[v];
        d[p] = max(d[p], d[v]+1);
        deg[p]--;
        if(deg[p]==0) que.push(p);
    }
    if(a[0] != 1) ans++;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4224
// AOJ 2356: Palindromic Anagram
// 2017.10.4 bal4u@uu

#include <stdio.h>

long long fac[21];

char buf[43];
int f['z'];

int main()
{
	int i, w, odd;
	long long ans;
	char *p;

	for (fac[0] = 1, i = 1; i <= 20; i++) fac[i] = fac[i-1]*i;

	scanf("%s", buf); p = buf, w = 0;
	while (*p) f[*p++]++, w++;
	for (odd = 0, i = 'a'; i <= 'z'; i++) odd += f[i] & 1, f[i] >>= 1;

	ans = 0;
	if ((w & 1) && odd == 1 || !(w & 1) && !odd) {
		ans = fac[w/2];
		for (i = 'a'; i <= 'z'; i++) if (f[i] > 0) ans /= fac[f[i]];
	}
	printf("%lld\n", ans);
}

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

using namespace std;
 
#define PB	push_back
#define ALL(x)	(x).begin(), (x).end()
#define ALLR(x)	(x).rbegin(), (x).rend()
#define MP	make_pair
 
#define debug(_x)		cerr << #_x << '=' << (_x) << endl;
#define debug2(_x, _y)	cerr << #_x << '=' << (_x) << ' ' << #_y << '=' << (_y) << endl;
#define debugn(_a)		cerr << #_a << ": "; for (const auto _x: _a) cerr << (_x) << ' '; cerr << endl;

#define HERE debug(__LINE__);

#define FAST_IO ios::sync_with_stdio(false); cin.tie(0)

#define int long long int

typedef pair<int, int> ii;
typedef pair<pair<int, int>, int> iii;
typedef vector<int> vi;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef unsigned long long ull;

const int INF = LONG_LONG_MAX>>1;
const int NINF = LONG_LONG_MIN/2;

const int N = 200009;
bool vis[N];

int32_t main() {
	FAST_IO;
	
	int n, k;
	cin >> n >> k;
	
	int a[n];
	for (int& x: a) {
		cin >> x;
		--x;
	}
	
	int s = 0;
	int p = a[s];
	vis[s] = true;
	vi path = {s};
	while (!vis[p]) {
		vis[p] = true;
		path.PB(p);
		p = a[p];
	}
	if (k < (int)path.size()) {
		cout << path[k]+1 << endl;
	} else {
		int e = 0;
		while (e < (int)path.size() && path[e] != p) e++;
		vi np;
		for (int i = e; i < (int)path.size(); i++) np.PB(path[i]);
		k -= e;
		cout << np[k%(int)np.size()]+1 << endl;
	}
}

// g++ -Wall -Wextra -Wshadow -fsanitize=undefined


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

typedef long long ll;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define sz(v) ll(v.size())

ll finalPos(ll mid, string s, vector<string> t, vector<string> d) {
    ll currentPos = mid;
    rep(i, sz(t)) {
        if (s[currentPos] == char(t[i][0])) {
            if (d[i] == "L") currentPos--;
            else currentPos++;
        }
        if (currentPos < 0 || currentPos >= sz(s)) break;
    }
    return currentPos;
}


void solve(ll N, ll Q, string s, vector<string> t, vector<string> d){
    ll l = -1;
    ll r = sz(s);
    while (r > l + 1) {
        ll mid = (r + l) / 2;
        if (finalPos(mid, s, t, d) < 0) {
            l = mid;
        } else {
            r = mid;
        }
    }
    ll left = r;
    l = -1;
    r = sz(s);
    while (r > l + 1) {
        ll mid = (r + l) / 2;
        if (finalPos(mid, s, t, d) >= sz(s)) {
            r = mid;
        } else {
            l = mid;
        }
    }
    ll right = l;
    cout << right - left + 1 << endl;
}

int main() {
  ll N;
    scanf("%lld",&N);
    ll Q;
    scanf("%lld",&Q);
    string s;
    cin >> s;
    vector<string> t(Q);
    vector<string> d(Q);
    for(int i = 0 ; i < Q ; i++){
        cin >> t[i];
        cin >> d[i];
    }
  solve(N, Q, s, move(t), move(d));
  return 0;
}


Measured memory_bytes: 35076
N = int(input())
S = []
S.append(input())
ans = 'Yes'

for i in range(N - 1):
	s = input()
	S.append(s)

	# 重複した単語の場合はNG
	if S.count(s) != 1:
		ans = 'No'
		break

	# しりとりになっていない場合はNG
	S1 = S[i]
	S2 = S[i + 1]
	if S1[-1] != S2[0]:
		ans = 'No'
		break

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;



int main() {
    ll n,m=0;
    cin >> n;
    
    for (ll i = 1; i < n; i++)
    {
        m += (n-1)/i;
    }
    
    
    cout << m << endl;
}



Measured memory_bytes: 3544
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
const int INF = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;
const string YES = "Yes";
const string NO = "No";

int main()
{
  std::string S;
  std::cin >> S;
  std::string T;
  std::cin >> T;
  vector<int> a[26], b[26];
  for (int i = 0; i < S.size(); ++i)
  {
    a[S[i] - 'a'].push_back(i);
    b[T[i] - 'a'].push_back(i);
  }
  int cnt = 0;
  int x = 0, y = 0;
  for (int i = 0; i < 26; ++i)
  {
    if (a[i].size())
      x++;
    for (int j = 0; j < 26; ++j)
    {
      if (a[i].size() && b[j].size() && a[i] == b[j])
        cnt++;
      if (i == 0 && b[j].size())
        y++;
    }
  }
  if (x == y && cnt == x)
    cout << YES << endl;
  else
    cout << NO << endl;

  return 0;
}


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

int main()
{
    string s;
    cin>>s;
    int n;
    cin>>n;
    int l=s.size();
    for(int i=0;i<l;i++)
    {
        if(i%n==0)
        {
            cout<<s[i];
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  vector<int>a{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;
  cin>>k;
  cout<<a.at(k-1)<<endl;

}


Measured memory_bytes: 384
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

a,b,c=mp()
print(max(c-a+b,0))

Measured memory_bytes: 10436
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
#define ll long long
#define N 110
int read()
{
    int x=0,f=1;char c=getchar();
    while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
    while (c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
    return x*f;
}
int n,a,b,p[N];
int main()
{
	n=read(),a=read(),b=read();
	for (int i=1;i<=n;i++) p[i]=read();
	int ans=0,x=0,y=0,z=0;
	for (int i=1;i<=n;i++)
	{
		if (p[i]<=a) x++;
		if (p[i]>a&&p[i]<=b) y++;
		if (p[i]>b) z++;
	}
	cout<<min(x,min(y,z));
}

Measured memory_bytes: 256
import sys

ordA = ord('a')

ss = input()
ts = input()

lenS, lenT = len(ss), len(ts)

setS = set(ss)
for t in ts:
    if t not in setS:
        print(-1)
        sys.exit()

poss = [-1] * 26
for i, s in enumerate(ss):
    ch = ord(s)-ordA
    if poss[ch] == -1:
        poss[ch] = i + lenS

nextss = [[0]*(26) for _ in range(lenS)]
for i in reversed(range(lenS)):
    ch = ord(ss[i])-ordA
    poss[ch] = i
    for ch, pos in enumerate(poss):
        nextss[i][ch] = pos-i

i = 0
ans = 1
for t in ts:
    ch = ord(t)-ordA
    d = nextss[i][ch]
    ans += d+1
    i = (i+d+1) % lenS

print(ans-1)


Measured memory_bytes: 73720
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int64_t n,a=2,b=1,temp;
  cin>>n;
  for(int i=0;i<n-1;i++){
    temp=b;
    b+=a;
    a=temp;
  }
  cout<<b<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
ll a[100010], mxx[100010];
int main(){
    ll n;
    while(cin>>n){
        ll ans=0;
        bool l=1;
        ll mn=1, mx=1;
        mxx[0]=1;
        for(ll i=0; i<=n; ++i){
            scanf("%lld",a+i);
            // a[i]=0;
            if(i>0){
	            mxx[i]=mxx[i-1]*2-a[i];
	            if(mxx[i]<0){
	            	l=0;
	            }
	            mxx[i]=min(mxx[i], (ll)1e14);
            }
        }
        // a[n]=1;
        // ans=1;
        ll tmp;
        ll sm=0;
        for(ll i=n; i>=1; --i){
        	tmp=mxx[i-1];
        	ans+=a[i];
        	a[i]+=sm;
        	assert(a[i]<=1e13);
        	if(a[i]>tmp*2){
        		l=0;
        		break;
        	}
        	else{
        		ans+=min(tmp, a[i]);
        	}
        	sm=min(tmp, a[i]);
        }
        if(a[0]>0){
        	l=0;
        }
        if(n==0){
        	if(a[0]==1){
        		l=1;
        		ans=1;
        	}
        	else{
        		l=0;
        	}
        }
        if(l==0){
        	printf("-1\n");
        }
        else{
        	printf("%lld\n",ans);
        }
    }
  return 0;
}




Measured memory_bytes: 5296
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M,S;
  cin >> N;
  S=0;
  M=N;
  while (N>0){
    S+=N%10;
    N/=10;
  }
  if (M%S==0)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}
    

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <limits>
#include <vector>
#include <map>
#include <cmath>
#include <limits>
#include <iomanip>
#include <queue>
#include <string.h>
#include <bitset>
#define ll long long int
#define ld long double
#define rep(i,n) for(int i = 0;i < n;i++)
#define rep1(i,n) for(int i = 1;i < n;i++)
#define co(x) cout << x << endl
#define cosp(x) cout << x << " "
#define all(x) x.begin(),x.end()
#define allr(x) x.begin(),x.end(),greater<int>()
#define P pair<ll,ll>
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define INF 1ll << 60
#define PI 3.14159265359

using namespace std;

int main(){
	cout << "square1001" << endl;
	return 0;
}


Measured memory_bytes: 3068
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
void input(vector<int>&);
int solve(vector<int> );
int func(vector<int> ,int);
int main(){
    vector<int> cake;
    input(cake);
    cout<<solve(cake)<<endl;
    return 0;
}
int func(vector<int> cake,int startnum){
    int res = startnum;
    cake[0]-=startnum;
    for(int i=0;i<cake.size()-1;++i){
        if(cake[i]>0){
            int num = cake[i];
            res += num*2;
            cake[i+1]-=num;
        }
    }
    if(cake.back()>0){
        res+=cake.back();
    }
    return res;
}
int solve(vector<int> cake){
    int res = (1<<31)-1;
    for(int i=0;i<=cake.front();++i){
        res = min(res,func(cake,i));
    }
    return res;
}
void input(vector<int> &cake){
    int num;
    cin>>num;
    cake.resize(num);
    for(int i=0;i<num;++i){
        cin>>cake[i];
    }
}

Measured memory_bytes: 3204
import sys
import time
import math
import itertools as it
def inpl():
    return list(map(int, input().split()))
st = time.perf_counter()
# ------------------------------

N = int(input())
P = inpl()
mn = 1001001001
ans = 0
for i in P:
    mn = min(mn, i)
    if i == mn:
        ans += 1
print(ans)

# ------------------------------
ed = time.perf_counter()
print('time:', ed-st, file=sys.stderr)


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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

long long INF=LLONG_MAX;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	string s; cin >> s;
	ll n = s.length();
	int a[n+1]; memset(a,0,sizeof(a));
	for(int i = 1; i <= n; i++)a[i]=s[i-1]-'0';
	ll sum = 0;
	for(int i = n; i >= 1; i--){
		if(a[i]>=6||a[i]==5&&a[i-1]>=5)a[i-1]++;
		sum += min(a[i],10-a[i]);
	}
	sum += a[0];
	cout << sum << endl;
}	


Measured memory_bytes: 5276
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<cstdlib>
#include<map>
#include<set>
#include<queue>
#include<vector>
#include<algorithm>
using namespace std;
typedef pair <int,int> pii;
typedef long long ll;
#define rep(i,n) for (int i=0;i<n;i++)
const int size=200005;
int a[size];
ll s[size];
int main(){
	int n;
	cin>>n;
	for (int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		s[i]=a[i]+s[i-1];
	}
	ll x,y,ans=abs(s[1]+s[1]-s[n]);
	for (int i=1;i<n;i++){
		x=s[i];
		y=s[n]-s[i];
		ans=min(ans,abs(s[i]+s[i]-s[n]));
	}
	cout<<ans;
}

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
    vector<int> a(m);
    rep(i,m) cin >> a[i];
    ll ans = n;
    rep(i,m) ans -= a[i];
    if (ans >= 0) cout << ans << endl;
    else          cout << -1  << endl;
	return 0;
}


Measured memory_bytes: 3632
#include<stdio.h>
         
        int main()
        {
            int n,k;
         
          scanf("%d %d",&n,&k);
         char s[n];
          scanf("%s",s);
          
          if(s[k-1] == 'A') s[k-1]='a';
          else if(s[k-1] == 'B') s[k-1]='b';
          else s[k-1] = 'c';
          
          printf("%s\n",s);
          return 0;
        }

Measured memory_bytes: 128
#include <iostream>
using namespace std;
 
int main() {
	string color="";
	cin>>color;
	int x=0;
	for(int i=1; i<color.length(); i++){
		if(color[i]!=color[i-1]){
			x=x+1;
		}
	}
	cout<<x<<'\n';
}

Measured memory_bytes: 3220
#include <bits/stdc++.h>
#define X first
#define Y second
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define ini(x, y) memset(x, y, sizeof(x))
#define endl '\n'
#define fastio cin.sync_with_stdio(false); cin.tie(nullptr)
using namespace std;

using ll = long long;
using pii = pair<int, int>;
const int MOD = 1e9 + 7;
const int dx[] = { -1, 0, 1, 0, -1, 1, 1, -1 };
const int dy[] = { 0, 1, 0, -1, 1, 1, -1, -1 };

int main() {
	fastio;
	int N, M;
	cin >> N >> M;

	vector<pii> vec(M);
	for (int i = 0; i < M; ++i) cin >> vec[i].X >> vec[i].Y;

	for (int i = 0; i <= 999; ++i) {
		string s = to_string(i);
		if (sz(s) != N) continue;

		bool flg = 1;
		for (int j = 0; j < M; ++j) {
			if (s[vec[j].X - 1] != vec[j].Y + 48) {
				flg = 0;
				break;
			}
		}

		if (flg) return cout << i, 0;
	}

	cout << -1;

	return 0;
}

Measured memory_bytes: 256
//g++ t.cpp -o t && t < p.txt
//d>p.txt&&t<p.txt&&t2<p.txt

#include <iostream> // プログラムの耳と口
#include <vector> // 超有能配列秘書
#include <algorithm> // みんな大好きソートと二分探索
#include <queue> // きゅーちゃん、だいすき
#include <string> // to_string
#include <functional> // 関数を変数に入れる子
#include <set> // 値の取得・挿入・削除を高速に
#include <map> // setの妹 これまた優秀
#include <random> // 乱択さん
#include <ctime>
#include <bitset>

#define DB cerr<<"D"<<endl
using namespace std; using ll=long long; using ld=long double; const int INF=1e9; const ll LINF=1e18; const double dINF = 1e18; const ld ldINF = 1e18; const double EPS = 1e-6;
template<typename T, typename U, typename O> void caut(T a, U b, O c){cout<<"("<<a<<","<<b<<","<<c<<") ";} template<typename T, typename U> void caut(T a, U b){cout<<"("<<a<<","<<b<<") ";} template<typename T> void caut(T a){cout<<"("<<a<<") ";};
using P=pair<ll,ll>;
const ll M = 1e9+7;
ll mod_pow(ll x, ll a) { ll an = 1; while(a > 0) { if (a&1) an = an * x % M; x = x * x % M; a >>= 1;} return an;}
void add(ll& x, ll y) {x+=y; x%=M;}; void mul(ll& x, ll y) {x*=y; x%=M;}; template<typename T, typename U> void chmax(T& x, U y) {if (x<y) x=y;}; template<typename T, typename U> void chmin(T& x, U y) {if (x>y) x=y;}
bool vaild(int x, int y, int hh, int ww){return 0<=x&&x<hh&&0<=y&&y<ww;}
int keta(ll a) {int res=0; while(a>0) res+=a%10, a/=10; return res;}
const int up[]={1,-1,0,0}, lf[]={0,0,1,-1};

int main() {
  string s; cin>>s;
  int n=s.size();
  int an=0;
  for(int i=0;i<n;i++) {
    an+=s[i]-'0';
  }
  if (an%9) {
    cout<<"No"<<endl;
  } else {
    cout<<"Yes"<<endl;
  }
}
// ・配列の大きさok？　・priority_queueはgreater？　・debug消した？
// ・落ち着いて。提出まで4分待ってね……WJ……1/10……2/10……

// Thank you for making problems and running the contest


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

int32_t main() {
    map<long long, int> st;
    int n;
    cin >> n;
    st[0] = 1;
    int acc = 0;
    int ans = 0;
    for(int i = 1; i <= n; i++) {
        int x;
        cin >> x;
        acc += x;
        if(st.count(acc)) {
            ans += st[acc];
        }
        st[acc]++;
    }

    cout << ans << endl;
}


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

int main() {
    double n,k; cin >> n >> k;
    double ans = 0.0;
    for(double i = 1; i <= n; i ++) {
        int p = i;
        double c = 0.0;
        while(p<k) {
            p*=2.0;
            c ++;
        }
        ans += pow(0.5, c)/n;
    }
    cout << setprecision(14) << ans << endl;
    return 0;
}

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

static const int N = 100;

void trace(int *a, int n) {
    for (int i = 0; i < n; i++) {
        if (i > 0) cout << ' ';
        cout << a[i];
    }
    cout << endl;
}

int insertionSort(int *a, int n) {
    for (int i = 1; i < n; i++) {
        int key = a[i];
        int j = i - 1;
        while (j >= 0 && a[j] > key) {
            a[j+1] = a[j];
            j--;
        }
        a[j+1] = key;
        trace(a, n);
    }
}

int main() {
    int a[N], n;

    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    trace(a, n);
    insertionSort(a, n);
    return 0;
}



Measured memory_bytes: 3036
#include<iostream>
#include<vector>
#include<algorithm>
#include<memory.h>
#include<queue>
using namespace std ;
#define ll long long 
#define all(x) x.begin() , x.end()
int const N = 505 , MOD = 1e9 + 7; 
int n , x , v[N] , cnt ;
vector<int>an;
int main(){
   scanf("%d%d",&n,&x);
   for(int i=0;i<n;++i){
        scanf("%d",v+i);
   }
   sort(v,v+n);
   int i=0;
   while(x >= 0 && i < n){
      x-=v[i];
      ++cnt;
      ++i;
   }
   if(x<0 || x>0 && cnt)--cnt;
   cout << cnt << "\n";
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int bubbleSort(int* A, int N)
{
	bool flag = 1;
	int count = 0;

	while (flag)
	{
		flag = 0;
		for (int j = N - 1; j > 0; j--)
		{
			if (A[j] < A[j - 1]) {
				swap(A[j], A[j - 1]);
				count++;
				flag = 1;
			}
		}
	}

	return count;
}

int selectionSort(int* A, int N)
{
	int count = 0;

	for(int i = 0; i < N; i++)
	{
		int minj = i;
		for (int j = i; j < N; j++)
		{
			if (A[j] < A[minj])
			{
				minj = j;
			}
		}
		if (i != minj)
		{
			swap(A[i], A[minj]);
			++count;
		}
	}

	return count;
}

int main() 
{
	int N;
	int A[100];

	cin >> N;

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

	int count = selectionSort(A, N);

	for (int i = 0; i < N; i++)
	{
		if (i) cout << " ";
		cout << A[i];
	}

	cout << endl;
	cout << count << endl;

	return 0;
}


Measured memory_bytes: 3100
#include<cstdio>
#include <cstring>
#define rep(i,a,b) for(int i=(a);i<(b);i++)

int n,k;
int map[105][105]={};

int main(void){
while(1){
  scanf("%d%d",&n,&k);
  if(!n)break;
  memset(map,-1,sizeof(map));
  rep(i,0,n)map[i][i]=0;
  rep(i,0,k){
    int q;
    scanf("%d",&q);
    if(q==0){
      int a,b;
      scanf("%d%d",&a,&b);
      printf("%d\n",map[a-1][b-1]);
    }
    else{
      int a,b,c;
      scanf("%d%d%d",&a,&b,&c);
      a--;b--;
      if(map[a][b]!=-1 && map[a][b]<=c)continue;
      map[a][b]=map[b][a]=c;
      rep(j,0,n){
	      rep(k,0,n){
	        if(map[j][a]>=0 && map[b][k]>=0){
	          int ne=map[j][a]+c+map[b][k];
	          if(map[k][j]>ne || map[k][j]==-1)map[k][j]=map[j][k]=ne;
	        }
	        if(map[j][b]>=0 && map[a][k]>=0){
	          int ne=map[j][b]+c+map[a][k];
	          if(map[k][j]>ne || map[k][j]==-1)map[k][j]=map[j][k]=ne;
	        }
	      }
      }
    }
  }
}
  return 0;
}

Measured memory_bytes: 1072
A, B, M = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
b = list(map(int, input().split(' ')))
discountDic = {}
for i in range(M):
    x, y, c = map(int, input().split(' '))
    key = (x-1)*B+(y-1)
    if key not in discountDic or discountDic[key] > a[x-1] + b[y-1] - c:
        discountDic[key] = a[x-1] + b[y-1] - c
discount_min_price = min(discountDic.values())
all_low_price = min(a) + min(b)
if discount_min_price < all_low_price:
    print(discount_min_price)
else:
    print(all_low_price)

Measured memory_bytes: 28320