akhauriyash/Code-Regression huggingface dataset:
#define  _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
#pragma comment (linker, "/STACK:526000000")

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144*2LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = time(NULL);
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(10);
}

#define int ll

void solve() {
	while (true) {
		int n, m;
		cin >> n >> m;
		if (n == 0) return;
		vector<tuple<int, int, int>> inputs;
		REP(i, m) {
			int a, b, c;
			cin >> a >> b >> c;
			inputs.push_back(make_tuple(a, b, c));
		}
		sort(ALL(inputs));
		int cnt[30000] = {};
		cnt[1] = 1;
		REP(i, inputs.size()) {
			if (cnt[get<1>(inputs[i])]) {
				cnt[get<2>(inputs[i])] = 1;
			}
		}
		int ans = 0;
		REP(i, n + 1) {
			ans += cnt[i];
		}
		cout << ans << endl;
	}
}
#undef int

int main() {
	init();
	solve();
}


Measured memory_bytes: 4472
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp>
//#include <functional> // for less
#define PI acos(-1.0)
#define eps 1e-9
#define ll long long
#define ull unsigned long long
#define nl printf("\n")
#define sf scanf
#define pf printf
#define INF (ll)1e15
#define mod 1000000007

///#define isValid(n,m,nx,ny)nx>=0&&nx<n&&ny>=0&&ny<m
///int kx[]={1, 1, -1, -1, 2, 2, -2, -2}; //knight moves
///int ky[]={2,-2,  2, -2, 1,-1,  1, -1}; //knight moves
///int dx[]={1,-1,0,0,1,-1,1,-1};//eight direction
///int dy[]={0,0,1,-1,1,-1,-1,1};//eight direction
 
///using namespace __gnu_pbds;
using namespace std;
 
///inline double toRad(double deg){return deg*PI/180;}
///inline double toDeg(double rad){return rad*180/PI;}
///typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set;
 
const int S=123456;
int main()
{
    #ifndef ONLINE_JUDGE
    //freopen("input.txt","r",stdin);
    #endif
    int n;
    while(sf("%d",&n)==1)
    {
        string s;
        cin>>s;
        s.insert(s.begin(),'N');
        n++;

        int lw[n+5];
        lw[0]=0;
        for(int i=1;i<=n;i++)
        {
            if(s[i]=='W')lw[i]=lw[i-1]+1;
            else lw[i]=lw[i-1];
        }

        int re[n+5];
        re[n+1]=0;
        for(int i=n;i>=1;i--)
        {
            if(s[i]=='E')re[i]=re[i+1]+1;
            else re[i]=re[i+1];
        }

        int mn=INT_MAX;
        for(int i=1;i<=n;i++)
        {
            mn=min(mn,lw[i-1]+re[i+1]);
        }
        pf("%d\n",mn);
    }
    return 0;
}
 









 




























Measured memory_bytes: 2948
import java.util.*;
import java.io.*;

public class Main {
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		
		int n = sc.nextInt();
		
		char s[] = sc.next().toCharArray();
		
		for (int i = 0; i < s.length; i++) {
			s[i]+=n;
			if(s[i]>'Z') {
				s[i]-=26;
			}
		}
		for (int i = 0; i < s.length; i++) {
			System.out.print(s[i]);
		}
	}

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}
}


Measured memory_bytes: 23508
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//等価なものに変換する思考
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//配列はvector<>を使う：意味わからないエラーがなくなる。
//背反な事象にちゃんとわける
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

//nC2の計算
ll C(ll N) {
	return N * (N - 1) / 2;
}

//円周率
const double PI = 3.14159265358979323846;

int main() {
	ll N; cin >> N;
	vector<ll> A(N + 1); rep(i, N + 1) cin >> A[i];
	vector<ll> B(N); rep(i, N)cin >> B[i];

	ll ans = 0;
	for (int i = 0; i < N + 1; i++) {
		if (i == 0) {
			ans += min(A[i], B[i]);
			B[i] -= min(A[i], B[i]);
		}
		else if (i == N) {
			ans += min(A[i], B[i - 1]);
		}
		else {
			ans += min(A[i], B[i - 1]);
			A[i] -= min(A[i], B[i - 1]);
			if (A[i] == 0) continue;
			else {
				ans += min(A[i], B[i]);
				B[i] -= min(A[i], B[i]);
			}
		}
	}

	cout << ans << endl;
}

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

int main(){

    int N;
    cin >> N;

    typedef tuple<string,int,int> mytp;
    vector<mytp> v;

    for(int i=0;i<N;i++){
        string s;
        int t;
        cin >> s;
        cin >> t;
        v.emplace_back(s,t,i+1);
    }

    sort(v.begin(),v.end(),
            [](mytp const &a,mytp const &b){
                if(get<0>(a) != get<0>(b))return get<0>(a) < get<0>(b);
                if(get<1>(a) != get<1>(b))return get<1>(a) > get<1>(b);
            }
    );



    for(auto t:v){
        cout << get<2>(t) << endl;
    }

    return 0;
}

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

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

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <cstring>
#include <algorithm>
#include <cstdio>

#define FOR(i, a, b) for(int i = (a), _b = (b); i <= _b; i++)

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  long long n, a, b;
  while (cin >> n >> a >> b) {
    long long res;
    if (b < a) res = 0;
     else res = (n - 2) * (b - a) + 1;
    if (res < 0) res = 0;
    cout << res << endl;
  }
  return 0;
}


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

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

typedef long long ll;

using namespace std;

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

ll lcm(ll a,ll b){ return a/gcd(a,b)*b; }

ll solve(ll a,ll c,ll d){
	return a-a/c-a/d+a/lcm(c,d);
}

int main(){
	ll a,b,c,d; cin>>a>>b>>c>>d;
	cout<<solve(b,c,d)-solve(a-1,c,d)<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ll long long
#define MAXN 200005
using namespace std;
using namespace __gnu_pbds;  

ll x;

void solve()
{
	cin>>x;
	ll p=(x/500)*1000;
	x=x%500;
	p+=((x/5)*5);
	cout<<p<<endl;
}

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cout.tie(NULL);
	solve();
}


Measured memory_bytes: 256
#include<algorithm> // sort,reverse,min
#include<iostream>
#include<list>
using namespace std;
#define df 0
#define inscope(i,j) (0<=i && i<h && 0<=j && j<w)
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int nearist(int i,int j,int h,int w){
  return min({i,j,h-i-1,w-j-1});
}
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; }

void show(list<pair<int,int>> const& que){
  printf("que:[");
  for(auto const& cell: que){
    printf(" (%d %d)",cell.first,cell.second);
  }
  printf(" ]\n");
}

int main(){
  if(df) printf("*debug mode*\n");
  int h,w,k; cin >> h >> w >> k;
  string maze[h];
  list<pair<int,int>>que;
  for(int i=0;i<h;i++){
    cin >> maze[i];
    for(int j=0;j<w;j++){
      if(maze[i].at(j)=='S')que.push_back(make_pair(i,j));
    }
  }
  int near=nearist(que.front().first,que.front().second,h,w);
  if(df)printf("k:%d\n",k);
  for(int i=0;i<k;i++){
    if(df)show(que);
    list<pair<int,int>>temp;
    for(auto const& cell: que){
      for(int i=0;i<4;i++){
	int ii=cell.first+dx[i],jj=cell.second+dy[i];
	if(df)printf("(%d,%d)->",ii,jj);
	if(not inscope(ii,jj)){if(df)printf("out of range\n"); continue;}
	if(maze[ii].at(jj)=='#'){if(df)printf ("blocked\n");continue;}
	if(df)printf("succeed!(%d)\n",nearist(ii,jj,h,w));
	maze[ii].at(jj)='#';
	temp.push_back(make_pair(ii,jj));
	chmin(near,nearist(ii,jj,h,w));
      }
    }
    que.swap(temp);
    if(df){
      printf("i:%d\n",i);
    }
  }
  cout << 1+(near+k-1)/k;
}

/// confirm df==0 ///


Measured memory_bytes: 1152
#include<iostream>
#include<algorithm>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<math.h>
#include <string>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;
int main(){
 	int n,q; cin >>n>>q;
 	string s; cin >>s;
 	char t[q],d[q];
 	for(int i=0;i<q;i++){
 		cin >>t[i]>>d[i];
 	}
 	int ans=n;
 	int low=-1; int high=n;
 	while(low+1<high){
 		int mid=(low+high)/2;
 		int now=mid;
 		for(int i=0;i<q&&0<=now&&now<n;i++){
 			if(t[i]==s[now]){
 				if(d[i]=='L'){
 					now--;
 				}
 				else now++;
 			}
 		}
 		if(now<0){
 			low=mid;
 		}
 		else{
 			high=mid;
 		}
 	}
 	ans-=(low+1);
 	low=-1; high=n;
 	while(low+1<high){
 		int mid=(low+high)/2;
 		int now=mid;
 		for(int i=0;i<q&&0<=now&&now<n;i++){
 			if(t[i]==s[now]){
 				if(d[i]=='L'){
 					now--;
 				}
 				else now++;
 			}
 		}
 		if(now>=n){
 			high=mid;
 		}
 		else{
 			low=mid;
 		}
 	}
 	ans-=(n-high);
 	cout << max(0,ans) << endl;
 }

Measured memory_bytes: 900
#include <bits/stdc++.h>
using namespace std;
vector <string> v;
string s;

int main(){
  int N;
  string  ans;
  char drc[] = {'N','W','S','E'};
  int d_xy[][2] = {{0,1},{-1,0},{0,-1},{1,0}};
  cin >>N;

  while (N != 0) {
    ans = "Yes";
    int mp[21][21] = {0};
    int M;
    int jems = 0;

    for(int i = 0;i<N;i++){
      int x,y;
      cin >>x>>y;
      mp[x][y]++;
    }
    cin >>M;
    int x_now = 10, y_now = 10;
    for (int i = 0;i<M;i++){
      char d;
      cin >> d;
      for(int j = 0;j<4;j++){
        if(d == drc[j]){
          int g;
          cin >> g;
          for(int k = 0; k < g; k++){
            jems += mp[x_now += d_xy[j][0]][y_now += d_xy[j][1]];
            if(mp[x_now][y_now])mp[x_now][y_now] = 0;
          }
        }
      }
    }
    if(jems != N)ans = "No";
    v.push_back(ans);
    cin >> N;
  }

  for (int i = 0;i<(int)v.size();i++){
    cout <<v[i]<<endl;
  }
  return 0;
}



Measured memory_bytes: 3156
#include<iostream>

using namespace std;

int N, a,b;

int gcd(int a, int b){return a%b?gcd(b,a%b):b;}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	cin>>N;
	
	for(int i = 0; i < N; i++){
		cin>>b;
		a = gcd(a,b);
		if(a==1)break;
	}
	
	cout<<a<<endl;
	
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <cstdio>
#define LL long long
#define pb push_back
#define mp make_pair
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define F first
#define S second
using namespace std;
typedef pair<int,int>pii;
string S;
int N;
int main(){
	cin>>S;
	N=S.size();
	vector<int>res(N);
	for(int ri=0;ri<2;ri++){
		int cnt=0;
		for(int i=0;i<N;i++){
			if(S[i]=='R'){
				cnt++;
			}else{
				res[i]+=cnt/2;
				res[i-1]+=(cnt+1)/2;
				cnt=0;
			}
		}
		reverse(res.begin(),res.end());
		reverse(S.begin(),S.end());
		for(int i=0;i<N;i++){
			if(S[i]=='L')
				S[i]='R';
			else
				S[i]='L';
		}
	}
	for(int i=0;i<N;i++)
		cout<<res[i]<<" ";
	cout<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>

using namespace std;
using ll=long long int;

bool calc(vector<int> &a, int m) {
    ll prev = m;
    for (int i = 0; i < a.size(); ++i) {
        prev = a[i] - prev;
    }
    return prev >= m;
}

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (auto &e: a) cin >> e;

    int l = 0, r = a[0]+1;
    while (r - l > 1) {
        int m = (l+r)/2;
        if (calc(a, m)) l = m;
        else r = m;
    }
    
    int prev = l;
    cout << prev * 2;
    for (int i = 0; i < n-1; ++i) {
        prev = a[i] - prev;
        cout << " " << prev * 2;
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
#define rep(i, n) for(int i=0; i<n; ++i)
#define REP(i, n) for(int i=1; i<=n; ++i)
#define all(obj) (obj).begin(), (obj).end()
const int inf = 1e9;
const ll INF = 1e18;
const ll MOD = 1e9+7;
const ll MAX = 1e9+7;

ll sum_pyramid(ll num){
    ll current_num = 0;
    while(num > 0){
        current_num++;
        num -= current_num;
    }
    if(num < 0) return current_num - 1;
    else return current_num;
}

int main(){
    ll n; cin >> n;
    ll ans = 0;
    ll n_; n_ = n;
    for(ll i=2; i*i <= n; i++){
        ll division = 0;
        while(n_ % i==0){
            division++;
            n_ /= i;
        }
        ans += sum_pyramid(division);
    }
    if(n_ != 1) ans++;

    if(n == 1) cout << 0 << endl;
    else cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int main() {
	int w, h, n; cin >> w >> h >> n;
	int fi[100][100] = {};
	rep(i, n) {
		int x, y, a;
		cin >> x >> y >> a;
		if (a == 1) {
			rep(j, x) {
				rep(k, h) {
					fi[j][k] = 1;
				}
			}
		}
		else if (a == 2) {
			Rep(j, x, w) {
				rep(k, h) {
					fi[j][k] = 1;
				}
			}
		}
		else if (a == 3) {
			rep(k, y) {
				rep(j, w) {
					fi[j][k] = 1;
				}
			}
		}
		else {
			Rep(k, y, h) {
				rep(j, w) {
					fi[j][k] = 1;
				}
			}
		}
	}
	int cnt = 0;
	rep(i, w) {
		rep(j, h) {
			if (!fi[i][j])cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}

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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, M; cin >> N >> M;
    int A[N]; rep(i, N) cin >> A[i];
    int sum = 0; rep(i, N) sum += A[i];
    sort(A, A+N); reverse(A, A+N);
    //A[M-1]を選べるか
    //A[M-1] >= sum/4M -> Yes
    if(A[M-1]*4*M >= sum) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import deque
from bisect import bisect_left
N = int(input())
A = [int(input()) for i in range(N)]

X = deque([])

for a in A:
  i = bisect_left(X,a)
  if i == 0:
    X.appendleft(a)
  else:
    X[i-1] = a
print(len(X))

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

int main(){
  int N;
  string S;
  cin >> N >> S;
  for(int i=0;i<S.size();i++){
    S.at(i)=(S.at(i)-'A'+N)%26+'A';
  }
  cout << S << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<stack>/*** LIFO *** stack<type> var;
push(), top():to get data, pop():to remove, size(), empty() ***/
using namespace std;

#define Fp(I, STAT, END) for(int I = STAT; I < END; I++)
#define Fm(I, STAT, END) for(int I = STAT; I > END; I--)

int main(){
    int N;
    cin >> N;
    double A[N], num = 0;
    Fp(i, 0, N){
        cin >> A[i];
        num += 1 / A[i];
    }
    printf("%.10f", 1 / num);
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes(x) cout<<(x?"Yes":"No")<<endl;
#define YES(x) cout<<(x?"YES":"NO")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " " 
#define INF 10000000000
#define LINF 9000000000000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(lli i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    cout << std::fixed << std::setprecision(10);
    lli a, b, c;
    cin>>a>>b>>c;
    out((b/a>c?c:b/a));

}

Measured memory_bytes: 3576
N = int(input())
X = list(map(int, input().split()))

ans = -1
for i in range(100):
    I = i + 1
    res = 0
    for j in range(N):
        res += (I - X[j]) * (I - X[j])
    if ans == -1:
        ans = res
    else:
        ans = min(ans, res)

print(ans)

Measured memory_bytes: 39024
#include <bits/stdc++.h>
/////////////////////////////////////
#define ll long long  
#define lld long long double
#define mod 1000000007
#define pb push_back
#define forn(i,n) for(int i=0;i<(int)n) ;i++)
#define DEBUG(a) cerr << #a << " = " << a << endl;
#define DEBUG_ARRAY(a,n)  for(long long i=0;i<(int)n;i++) cerr << a[i]<< "  ";cout<<endl;
#define max(a,b) ((a)>(b))?(a):(b)
#define min(a,b) ((a)<(b))?(a):(b)
//#define _DEBUG

using namespace std;

/////////////////////////////////////
void solve(){
    
     string s;
     cin>>s;
     string s1=s+s;
     ll k,ans=0,ans1=0;
     cin>>k;
     int i,j;
     
      if ( s == string(s.size(), s.at(0))) {
        cout << s.size() * k /2 << endl;
        return ;
    }
    
    for( i=0;s[i]!='\0';i++){
	    
	    for( j=i+1;s[j]!='\0'&&s[i]==s[j];j++);
	   if(i!=j+1) ans+=(j-i)/2,i=--j;
	   
	  //  cout<<ans<<endl;
	    
    }
    for( i=0;s1[i]!='\0';i++){
	    
	    for( j=i+1;s1[j]!='\0'&&s1[i]==s1[j];j++);
		if(i!=j+1) ans1+=(j-i)/2,i=--j;
	   
	  //  cout<<ans<<endl;
	    
    }
       ll diff = ans1-ans;
       //cout<<ans1<<ans<<diff;
     if(k==1){
	 cout<< ans<<endl ;
    }else{
	
	cout<<(ans+ (k-1)*diff)<<endl;
    }
     
}
int main() {
    /////////////////////////////////////
    #ifdef _DEBUG
	int tt = (int) clock();
    #endif
    /////////////////////////////////////
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /////////////////////////////////////
  
    solve();
    /////////////////////////////////////
    #ifdef _DEBUG
        cerr << "TIME = " << (double)(clock() - tt) / CLOCKS_PER_SEC << endl;
    #endif
    /////////////////////////////////////
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char const *argv[]){
   int K;
   string S;
   cin >> K >> S;
   if(S.size() > K){
      cout << S.substr(0,K) << "..." << endl;
   }else{
      cout << S << endl;
   }
   return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second)
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) (find(all(v),x)!=v.end())
#define incls(s,c) (s.find(c)!=string::npos)
#define lb(a,x) distance((a).begin(),lower_bound(all(a),(x)))
#define ub(a,x) distance((a).begin(),upper_bound(all(a),(x)))
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(all(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
//const long double EPS = 1e-14;
const int INF = (1<<30)-1;
const ll LINF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; cin >> x; return x;}
inline ll lin() { ll x; cin >> x; return x;}
inline char chin() { char x; cin >> x; return x;}
inline string stin() { string x; cin >> x; return x;}
inline double din() { double x; cin >> x; return x;}
//template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const vector<T>& a) { ll res(0); for (auto&& x : a) res += x; return res;}
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; }
char itoa(int n) { return n + '0';}
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
const int dx[4] = {1, 0,-1, 0};
const int dy[4] = {0, 1, 0,-1};

int main () {
  int a;
  cin >> a;
  cout << a+a*a+a*a*a << endl;
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(int i=0;i<n;i++)
#define vec vector
typedef int64_t intl;
#define fi first
#define se second
#define pushb push_back
#define popb pop_back
#define SortA(v) sort(v.begin(), v.end())
#define SortD(v) sort(v.rbegin(), v.rend())
vec<int> dx = {0, 1, 0, -1, 1, 1, -1, -1};
vec<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};



int main(){
 int N,M,X;
  cin >> N>>M>>X;
  vec<int> C(N);
  vec<vec<int>> A(N , vec<int>(M) );
  Rep(i,N){
    cin >> C.at(i);
    Rep(j,M){
      cin >>A.at(i).at(j);
    }
  }

  int times=1;
  Rep(i,N){ times *=2;}
  int mincost = 100000000;
  Rep(i,times){
    bitset<12> wbook(i);
    vec<int> rikai(M,0);
    int cost = 0;
    bool rikaiOK =1;
    Rep(j,N){
      if(wbook.test(j)){ 
        cost += C.at(j);
        Rep(k,M){
          rikai.at(k) += A.at(j).at(k);
        }
      }
    }
    Rep(l,M){
      if(rikai.at(l) < X){rikaiOK =0;}
    }
    if(rikaiOK){
      mincost = min (mincost,cost);
    }
  }
  if( mincost == 100000000){cout <<-1;}
  else {cout <<mincost;}
}

Measured memory_bytes: 3636
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF         1e9
#define INFLL       1e18
#define EPS         1e-9
#define REP(i,n)    for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)   for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)   for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)  for(ll i=(n);i>0;--i)
#define REPC(i,obj) for(auto i:obj)
#define ALL(obj)    (obj).begin(),(obj).end()
#define SETP(n)     cout << fixed << setprecision(n)
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

inline double norm(const pair<double, double>&p1, const pair<double, double>&p2) {
	return hypot(p1.first - p2.first, p1.second - p2.second);
}
double heron(const pair<double, double>&p1, const pair<double, double>&p2, const pair<double, double>&p3) {
	double a = norm(p1, p2), b = norm(p2, p3), c = norm(p3, p1);
	double z = (a + b + c) / 2;
	return sqrt(z * (z - a) * (z - b) * (z - c));
}
signed main()
{
	vector<pair<double, double>>cood;
	double x, y;
	while (scanf("%lf,%lf", &x, &y) != EOF) {
		cood.push_back(make_pair(x, y));
	}
	double area = 0;
	REP1(i, cood.size() - 2) {
		area += heron(cood[0], cood[i], cood[i + 1]);
	}
	SETP(20);
	cout << area << endl;
}


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

int main() {
  int A, B, C, D;
  int Acnt, Ccnt = 0;
  cin >> A >> B >> C >> D;
  while(A > 0) {
    A -= D;
    Acnt++;
  }
  while(C > 0) {
    C -= B;
    Ccnt++;
  }
  if (Acnt == Ccnt) cout << "Yes";
  if (Acnt < Ccnt) cout << "No";
  else if (Acnt > Ccnt)cout << "Yes";
}


Measured memory_bytes: 3632
T=!!0
F=!T
[T,F].map{|c|
class<<c
alias:%:==
def!=x
!self|x
end
end
}
until gets=~/#/
puts (0..2047).all?{|x|
eval $_.tr"-=>*+abcdefghijk","!%=&|"+("%011b"%x).tr("01","TF")
}?'YES':'NO'
end

Measured memory_bytes: 13116
#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define gcd __gcd
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define read(v,i,n) for(i=0;i<n;i++)in(v[i])
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
#define pr(n) printf("%d ",n)
#define out(n) printf("%d\n",n)
#define inl(a) cin >> a
#define prl(a) cout << a << " "
#define outl(a) cout << a << endl
#define yes printf("YES\n")
#define no printf("NO\n")
#define lin printf("\n")
#define dbg(v,i,n) for(i=0;i<n;i++)pr(v[i]); lin
#define ck printf("continue\n")
#define all(vec) vec.begin(),vec.end()
#define asc(vec) sort(vec.begin(),vec.end())
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define tf(mytuple) get<0>(mytuple)
#define ts(mytuple) get<1>(mytuple)
#define tt(mytuple) get<2>(mytuple)
#define tddd tuple<double,double,double>
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<int,pair<int,int> > >
#define vvii vector<vector<pair<int,int> > >
#define lp(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define N 100005
typedef long long int ll;
vvi ad(N);
int vis[N];
ll f[N],g[N];
void dfs(int s)
{
    vis[s]=1;
    int i,x,a;
    x=ad[s].size();
    ll w=1,b=1;
    rep(i,x)
    {
        a=ad[s][i];
        if(!vis[a])
        {
            dfs(a);
            w*=(f[a]+g[a]),w%=M;
            b*=f[a],b%=M;
        }
    }
    f[s]=w,g[s]=b;
    return ;
}
int main()
{
    int n,i,a,b;
    in(n);
    rep(i,n-1)
    {
        in2(a,b);
        ad[a].pb(b);
        ad[b].pb(a);
    }
    dfs(1);
    outl((f[1]+g[1])%M);
}










Measured memory_bytes: 14720
#include <bits/stdc++.h>
using namespace std;
    int main(){
        int x,y,z;cin>>x>>y>>z;
        bool ok=false;
        if(x==y&&x!=z)ok=true;
        if(x==z&&x!=y)ok=true;
        if(z==y&&z!=x)ok=true;
        if(ok)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }






Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

namespace C_ABC166
{
    class MainClass
    {

        static int[] s,l;

        public static void Main(string[] args)
        {

            s = Array.ConvertAll(ReadLine().Split().ToArray(), int.Parse);
            l = Array.ConvertAll(ReadLine().Split().ToArray(), int.Parse);
            int n = s[0];
            int m = s[1];
            int[] ansl = new int[n];
            int ans = n;
            for(int i = 0;i<m;i++){
                int[] ab =Array.ConvertAll(ReadLine().Split().ToArray(), int.Parse); 
                int a = ab[0] -1;
                int b = ab[1] -1;
                if(l[a]>l[b]){
                    if(ansl[b]==0){
                        ansl[b]=-1;
                        ans--;
                    }
                }else if(l[a]<l[b]){
                    if(ansl[a]==0){
                        ansl[a]=-1;
                        ans--;
                    }
                }else{
                    if(ansl[a]==0&&ansl[b]==0){
                        ansl[a]=-1;
                        ansl[b]=-1;
                        ans--;
                        ans--;
                    }else if(ansl[a]==0){
                        ansl[a]=-1;
                        ans--;
                    }else if(ansl[b]==0){
                        ansl[b]=-1;
                        ans--;
                    }else{

                    }
                }
            }
            WriteLine(ans);

        }
    }
}


Measured memory_bytes: 49960
def calc_prefix(pattern):
    """
        a b|c   a b[c] # matched        matched_len = 2
        1 2
        a b c|  a b[c] # increase       matched_len = 3
        1 2 3

        a b|c   a b[d] # not matched    matched_len = 2
        1 2
        a|b c   a b[d] # not matched    matched_len = 1
        1 2
       |a b c   a b[d] # not matched    matched_len = 0
        1 2 0

        a b|c   a b[a] # not matched    matched_len = 2
        1 2
        a|b c   a b[a] # not matched    matched_len = 1
        1 2
       |a b c   a b[a] # matched        matched_len = 0
        1 2
        a|b c   a b[a] # increase       matched_len = 1
    """
    pattern_len = len(pattern)
    # matched_len = 0
    matched_table = [0] * pattern_len
    for calc_idx in range(1, pattern_len):
        matched_len = matched_table[calc_idx - 1]
        while matched_len > 0 and pattern[matched_len] != pattern[calc_idx]:  # not matched
            matched_len = matched_table[matched_len - 1]  # matched_lenが-1される
        if pattern[matched_len] == pattern[calc_idx]:  # matched!
            matched_len += 1
        matched_table[calc_idx] = matched_len
    return matched_table


def kmp(text, pattern):
    matched_table = calc_prefix(pattern)
    pattern_len = len(pattern)
    text_len = len(text)
    text_idx = 0
    pattern_idx = 0
    matched_idxs = []
    while text_idx < text_len:
        if pattern[pattern_idx] == text[text_idx]:
            pattern_idx += 1
            text_idx += 1
        if pattern_idx == pattern_len:
            matched_idxs.append(text_idx - pattern_idx)
            pattern_idx = matched_table[pattern_idx - 1]
        elif text_idx < text_len and pattern[pattern_idx] != text[text_idx]:
            if pattern_idx == 0:
                text_idx += 1
            else:
                pattern_idx = matched_table[pattern_idx - 1]

    return matched_idxs


def main():
    text = input()
    pattern = input()
    matched = kmp(text, pattern)
    for match_idx in matched:
        print(match_idx)


if __name__ == "__main__":
    main()



Measured memory_bytes: 47928
N=int(input())
H=list(map(int,input().split()))
H[0]-=1
for i in range(1,N-1):
	if H[i]>H[i+1]:
		H[i]-=1
		if H[i]>H[i+1]:
			print('No')
			exit()
		if H[i-1]>H[i]:
			print('No')
			exit()
	elif H[i-1]<=H[i]-1:
		H[i]-=1
print('Yes')

Measured memory_bytes: 20688
MOD = 1000000007
N, M = map(int, input().split())
A = [int(input()) for _ in range(M)]
is_broken = [False for _ in range(N+1)]
for a in A:
  is_broken[a] = True

# dp[i] = (i段目に辿り着くルートの総数)

# init 
dp = [0]*(N+1)
dp[0] = 1

# DP
for i in range(N):
  if not is_broken[i+1]:
    dp[i+1] += dp[i]
    dp[i+1] %= MOD
  if i+2 <= N:
    if not is_broken[i+2]:
      dp[i+2] += dp[i]
      dp[i+2] %= MOD

print(dp[N])

Measured memory_bytes: 55512
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define bitrep(X,N) for(ll X = 0; X < (1 << (N)); X++)
#define PI (acos(-1.0))
#define sorta(V) sort(V.begin(), V.end())
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end() 


using namespace std;


int main(){

    string s;
    cin >> s;

    rep(i,3){
        if(s[i] == '1'){
            s[i] = '9';
        }else if(s[i] == '9'){
            s[i] = '1';
        }
    }

    cout << s << endl;
    return 0;
}

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  	char x;
  	cin >> x;
  	if(x>='a' && x<='z')
      cout << 'a';
    else
      cout << 'A';
    return 0;
}

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


int main(){
	int N;
	cin>>N;
	int x[N],y[N],h[N];
	for(int i=0;i<N;i++){
		cin>>x[i]>>y[i]>>h[i];
	}
	int temp;
	for(int i=0;i<101;i++){
		for(int j=0;j<101;j++){
			for(int k=0;k<N;k++){
				if(h[k]!=0){
					temp = h[k]+abs(x[k]-i)+abs(y[k]-j);
					break;	
				}
			}
			if(temp<=0)break;
			int aa;
			bool flag=true;
			for(int k=0;k<N;k++){
				aa=max(temp-abs(i-x[k])-abs(j-y[k]),0);
				if(aa!=h[k]){
					flag=false;
					break;
				}
			}
			if(flag==true){
				cout<<i<<" "<<j<<" "<<temp<<endl;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int l;

int order(char *, char *);

int order(char *ss, char *tt){
  for(int k = 0; k < l; k++){
    if(*ss > *tt){
      return 1;
      break;
    }
    else if(*tt > *ss){
      return 2;
      break;
    }
    else if(k == l - 1){
      return 3;
    }
    ss++; tt++;
  }
}
      

int
main(int argc, char *argv[])
{
  int n;
  char s[200][200], t[200];
  scanf("%d %d", &n, &l);
  for(int i = 0; i < n; i++){scanf("%s", s[i]);}
  
  for(int i = 0; i < n - 1; i++){
    for(int j = i + 1; j < n; j++){
      if(order(s[i], s[j]) == 1){
        strcpy(t, s[j]);
        strcpy(s[j], s[i]);
        strcpy(s[i], t);
      }
    }
  }
  
  for(int i = 0; i < n; i++){printf("%s", s[i]);}
  printf("\n");
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = (ll)a;i < (ll)b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = (ll)b-1LL;i >= (ll)a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define SIGN(a) (a==0?0:(a>0?1:-1))

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;
typedef long double ld;
typedef pair<ld,ld> pdd;

const ll INF=(1LL<<60);
#if __cplusplus<201700L
ll gcd(ll a, ll b) {
  a=abs(a);
  b=abs(b);
  if(a==0)return b;
  if(b==0)return a;
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif
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(a>b){
    a=b;
    return true;
  }
  return false;
}
template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}


void solve(long long N){
  ll ans=0;
  for(ll i=2;i*i <= N;i+=2){
    if(N%i==0){
      ll cnt=0;
      while(N%i==0){
        N/=i;
        ++cnt;
      }
      For(j,cnt+10){
        if(j*(j+1)/2>cnt){
          ans+=j-1;
          break;
        }
      }
    }
    if(i==2)--i;
  }
  if(N>1)++ans;
  cout<<ans<<endl;
}

int main(){
  cout<<setprecision(1000);
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a)
{
    return is >> a.first >> a.second;
}
ostream &operator<<(ostream &os, const P &a) { return os << "(" << a.first << "," << a.second << ")"; }

template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    ll sum = 0;
    rep(i, n) sum += a[i];
    double k = (double)sum / (4 * m);
    int num = 0;
    rep(i, n) num += a[i] >= k;

    string ans = (num >= m) ? "Yes" : "No";

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999

using namespace std;

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

int main(){
	int N,K,x[50];
	cin>>N>>K;
	REP(i,N){
		cin>>x[i];
	}
	SORT(x,N);
	REVERSE(x,N);
	int l=0;
	REP(j,K)l=l+x[j];
	cout<<l;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
using edge = struct { int to; int cost; };
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 int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

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

  if (s[s.size()-1] == 's') s += 'e';
  s+='s';

  COUT(s);

  return 0;
}

Measured memory_bytes: 3608
/**
  * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0000
  * QQ
  */
object Main {
  def main(args: Array[String]): Unit = {
    (for (x <- 1 to 9; y <- 1 to 9)
      yield s"${x}x${y}=${x * y}")
      .foreach(println)
  }
}

Measured memory_bytes: 43768
import sys
import math
from collections import Counter
import itertools
import fractions
#from functools import reduce

# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'

# リストを改行区切りで出力する
p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))
p2S = lambda x: print(*x, sep=" ")

# ###########################################
 
T,X=MI()
print(T/X)

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

int main(void) {
    int N;
    cin>>N;
    string S,T;
    cin>>S>>T;
    for (int i = 0; i < N; i++)
    {
        cout << S[i] << T[i];
    }
    cout << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int x, y, tmp;
  for(;;){
    scanf("%d %d", &x, &y);
    if(x == 0 && y == 0)
      break;
    if(x > y){
      tmp = x;
      x = y;
      y = tmp;
    }
    printf("%d %d\n", x, y);
  }
  return 0;
}

Measured memory_bytes: 600
n=int(input())
l=list(map(int,input().split()))

c=[]
for i in range(n):
  for j in range(i+1,n):
    for k in range(j+1,n):
      c.append((i,j,k))
cnt=0
for i in c:
  s=l[i[0]]
  t=l[i[1]]
  u=l[i[2]]
  
  if s+t>u and t+u>s and u+s>t and len(set([s,t,u]))==3:
    cnt+=1
print(cnt)

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

// int/long:		-2147483648 - 2147483648 (-2^31 <= int < 2^31)
// long/long long:	-9223372036854775808 - 9223372036854775807 (-2^63 <= long < 2^63)
#define	INF (1<<29)
//536870912

#define	MOD 1000000007

int	get_g(int i, vector<int> &grp) {
	if (i==grp.at(i)) return i;
	return get_g(grp.at(i), grp);
}

int     main() {
	// N: Number of nodes
	// M: Number of links
	int N, M;
	cin >>N >>M;
	// Links
	// Each link connects nodes x and y
	// (Swap rules)
	vector<int> x(M, 0);
	vector<int> y(M, 0);
	for (int i=0; i<M; i++)
		cin >>x.at(i) >>y.at(i);
	// For each bridge
	int S=0;
	for (int ii=0; ii<M; ii++) {
		// Data store
		// p: Original value for each position
		// grp: Group#
		// grp_depth: Steps to the group root
		vector<int> grp(N+1, 0);
		vector<int> grp_depth(N+1, 0);
		// Read data for each node
		// Initialize group# as each own
		for (int i=1; i<=N; i++)
			grp.at(i)=i;
		// Grouping
		for (int i=0; i<M; i++) {
			if (i!=ii) {
				int xx=x.at(i);
				int yy=y.at(i);
				xx=get_g(xx, grp);
				yy=get_g(yy, grp);
				// Already in same group, do nothing
				if (xx==yy) continue;
				// Put into one group
				if (grp_depth.at(xx)==grp_depth.at(yy)) {
					// Groups have same height
					// Merge into less-number-group
					grp.at(max(xx, yy)) = get_g(min(xx, yy), grp);
					grp_depth.at(min(xx, yy))++;
				} else if (grp_depth.at(xx)>grp_depth.at(yy)) {
					// x is higher
					// Merge into x so that the hight will not increase
					// (height for y will be +1)
					grp.at(yy) = xx;
				} else
					// y is higher
					// Merget into y
					grp.at(xx) = yy;
			}
		}
		for (int i=2; i<=N; i++)
			if (get_g(i, grp)!=get_g(1, grp)) {
				S++;
				break;
			}
	}
	cout <<S <<endl;
	return 0;
};


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

int main(){
    int r;

    string ans = "ABC";

    cin >> r;

    if(r < 1200){
        ans = "ABC";
    }else if(r < 2800){
        ans = "ARC";
    }else{
        ans = "AGC";
    }

    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n = int(ipt())
    a = []
    b = []
    for i in range(n):
        ai,bi = map(int,ipt().split())
        a.append(ai)
        b.append(bi)
    ans = 0
    for i in range(n):
        ai = a[n-1-i]
        bi = b[n-1-i]
        pi = bi-(ai+ans-1)%bi-1
        ans += pi
    print(ans)
    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 77908
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n; scanf("%d", &n);
	std::string s; cin >> s;

	for(auto c: s) {
		int ord = c - 'A';
		int nxt = (ord + n) % ('Z' - 'A' + 1);

		printf("%c", (char)(nxt + 'A'));
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 256
import itertools

H,W = map(int,input().split())
cost = [list(map(int,input().split())) for _ in range(10)]
A = [list(map(int,input().split())) for _ in range(H)]


to1 = [10**3 for i in range(10)]

nlist = [0] + [i for i in range(2,10)]

for i in range(1,10):
    for v in itertools.permutations(nlist,i):
        c = 0
        for j in range(i-1):
            c += cost[v[j]][v[j+1]]
        c += cost[v[i-1]][1]
        to1[v[0]] = min(to1[v[0]], c)

ans = 0
for h in range(H):
    for w in range(W):
        if A[h][w] != 1 and A[h][w] != -1:
            ans += to1[A[h][w]]

print(ans)

        


Measured memory_bytes: 41692
# AGC028A - Two Abbreviations
def gcd(a, b):
    while b > 0:
        a, b = b, a % b
    return a


def main():
    n, m = tuple(map(int, input().rstrip().split()))
    S, T = tuple(input().rstrip() for _ in range(2))
    g = gcd(n, m)
    flg = S[:: n // g] == T[:: m // g]
    print(n // g * m if flg else -1)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define EB emplace_back
#define G(i,x) get<i>(x)
#define F(i,s,n) for(int i = s; i < n; i++)

#define MAXN 100
#define MAXW 100000
long N;
long W;
long w[MAXN];
long v[MAXN];
long long dp[MAXN][MAXW];

long long sol(int i, int we) {
	if (i == N) {
		return 0;
	}

	if (dp[i][we] != -1) {
		return dp[i][we];
	}

	//not choose
	long long option1 = sol(i + 1, we);

	if (we + w[i] > W) {
		return dp[i][we] = option1;
	}
	//choose
	long long option2 = sol(i + 1, we + w[i]) + v[i];
	
	
	return dp[i][we] = max(option2, option1);


}



int main( ) {
	cin >> N >> W;
	F(i,0,N) {
		cin>> w[i]>>v[i];
		F(j,0,MAXW) {
			dp[i][j] = -1;
		}
	}
	sol(0,0);

	cout <<dp[0][0];


}

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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

ll dp[1010][1010];
ll maze[1010][1010];
const ll MOD = 1e9+7;

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

  int H, W;
  cin >> H >> W;
  rep(i, H){
    rep(j, W){
      dp[i][j] = 0;
    }
  }

  string s;
  rep(i, H){
    cin >> s;
    rep(j, W){
      if(s[j] == '.'){
        maze[i][j] = 1;
      }else{
        maze[i][j] = 0;
      }
    }
  }
  dp[0][0] = 1;
  rep(i, H){
    rep(j, W){

      // 右
      if(maze[i][j+1] == 1){
        dp[i][j+1] = (dp[i][j+1] + dp[i][j]) % MOD;
      }

      if(maze[i+1][j] == 1){
        dp[i+1][j] = (dp[i+1][j] + dp[i][j]) % MOD;
      }

    }
  }

  cout << dp[H-1][W-1] << endl;



  return 0;
}


Measured memory_bytes: 16128