akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll MOD = 1000000007;

int main(){
  int N;cin >> N;
  vector<int> A(N,0);
  for(int i=0;i<N;i++){
    cin >> A[i];
  }
  sort(A.begin(),A.end());
  for(int i=1;i<N;i++){
    if(A[i-1]==A[i]){
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}

Measured memory_bytes: 1152
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		String S = input.next();
		String T = input.next();
		int A = input.nextInt();
		int B = input.nextInt();
		String U = input.next();
		
		if(U.equals(S)) {
			System.out.println((A-1)+" "+B);
		}
		else {
			System.out.println(A+" "+(B-1));
		}
	}
}


Measured memory_bytes: 21844
x = Array.new(51, 0)
i = j = k = l = 10
i.times{ |i|
  j.times{ |j|
    k.times{ |k|
      l.times{ |l|
        x[i+j+k+l] += 1
      }
    }
  }
}

while line = ARGF.gets do
  puts x[line.to_i]
end

Measured memory_bytes: 6096
#include<bits/stdc++.h>
using namespace std;
int main(){
 string s;
  cin>>s;
  if(s=="Sunny"){
    cout<<"Cloudy"<<endl;
  }else if(s=="Cloudy"){
    cout<<"Rainy"<<endl;
  }else{
    cout<<"Sunny"<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define y0 yy
#define y1 Yy
#define yn YY
#include <assert.h>
#include <algorithm>
#include <vector>
using namespace std;

int n,dpa[100005],res;
vector<int> g[100005];

void dfs(int x){
    vector<pair<int,int> > c;
    for(size_t i=0;i<g[x].size();i++){
        dfs(g[x][i]);
        c.push_back(make_pair(dpa[g[x][i]],i));
    }
    sort(c.begin(),c.end());
    int dd=0;
    for(int i=c.size()-1;i>=0;i--){
        dpa[x]=max(dpa[x],dpa[g[x][c[i].second]]+dd);
        dd++;
    }
    dpa[x]++;
}

int main(){
    scanf("%d",&n);
    for(int i=1;i<n;i++){
        int ai;
        scanf("%d",&ai);
        g[ai-1].push_back(i);
    }
    dfs(0);
    printf("%d\n",dpa[0]-1);
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (auto &i : a) cin >> i;
  map<int,ll> mp;
  rep (i,n) mp[a[i]]++;
  ll total = 0;
  for (auto i = mp.begin(); i != mp.end(); i++) total += mp[i->first] * (mp[i->first] - 1) / 2;
  rep (i,n) cout << total + 1 - mp[a[i]] << endl;
  return 0;
}

Measured memory_bytes: 10240
import java.util.*;
public class Main {
		public static char [] ns = new char [8];
		public static char[] perm =new char[8];
		public static boolean[] used =new boolean[8];
		public static  int max,min;
		
	    public static void main(String[] args) throws java.io.IOException{
	        Scanner scan = new Scanner(System.in);
	        int n=scan.nextInt();
	        scan.nextLine();
	        for(int i=0;i<n;i++){
	        ns = scan.nextLine().toCharArray();
	        max=0;
	        min=99999999;
	        permutation(0,8);
	        System.out.println(max-min);
	        }
	        
	    }
	    public static void permutation(int pos,int n){
	    	if(pos==n){
	    		StringBuilder sb =new StringBuilder();
	    		for(int i=0;i<n;i++){
	    			sb.append(perm[i]);
	    		}
	    		max=Math.max(max,Integer.parseInt(sb.toString()));
	    		min=Math.min(min,Integer.parseInt(sb.toString()));
	    		return ;
	    		
	    	}
	    	
	    	for(int i=0;i<n;i++){
	    		if(!used[i]){
	    			perm[pos] = ns[i];
	    			used[i]=true;
	    			permutation(pos+1,n);
	    			used[i]=false;
	    		}
	    	}
	    	return ;
	    }
}
	    

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define PI 3.1415926535897932384626433
#define mod 1000000007
 
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
 
int lcm(int a, int b) { return a * b / gcd(a, b); }
 
int main(){
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; i++){
        cin >> v[i];
    }

    sort(v.begin(), v.end());

    double ans = (v[0] + v[1]) / 2.0;
    for (int i = 2; i < n; i++){
        ans = (ans + v[i]) / 2;
    }
    printf("%.10f", ans);
    return 0;
}

Measured memory_bytes: 256
X, N = map(int, input().split())
p = [int(i) for i in input().split()]

res = -1
i=0
while(res==-1):
    check_low = X - i
    if check_low not in p:
        res = check_low
    else:
        check_high = X + i
        if check_high not in p:
            res = check_high
    i += 1

print(res)

Measured memory_bytes: 9192
#include<iostream>
using namespace std;
int main()
{
  int  k, s, ans = 0;
  cin >> k >> s;
  for(int i = 0; i <= min(k, s); i++)
  {
    for(int j = 0; j <= min(k, s - i); j++)
    {
        if(s - i - j >= 0 && s - i - j <= k)
          ans++;
    }
  }
  cout << ans;
  return 0;
}


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

int main(){

  int n,m;

  cin>>n>>m;

  int a[100][100];
  for(int i=0;i<n;i++)
    for(int j=0;j<m;j++) cin>>a[i][j];

  int b[100];
  for(int i=0;i<m;i++) cin>>b[i];

  int c[100] = {};
  for(int i=0;i<n;i++)
    for(int j=0;j<m;j++) c[i] += a[i][j] * b[j];

  for(int i=0;i<n;i++) cout<<c[i]<<endl;

  return 0;
}



Measured memory_bytes: 3124
#include<vector>
#include<iostream>
#include<numeric>

using namespace std;



int main(){
    int N, M;
    cin >> N >> M;
    vector<vector<int> > em(N, vector<int>(N, 0));
    int t1, t2;
    for(int i=0; i!=M; i++){
        cin >> t1 >> t2;
        em.at(t1-1).at(t2-1)++;
        em.at(t2-1).at(t1-1)++;
    }
    
    int out = 0;
    vector<int> lv(N);
    iota(lv.begin(), lv.end(),0);
    vector<vector<int> > lvl;
    lvl.push_back(lv);

    while(!lvl.empty()){
        vector<int> clv = lvl.back();
        lvl.pop_back();
        if(clv.size()==1) out ++;
        int pos = clv.front();
        for(int i=1; i!= clv.size(); i++){
            if(em.at(pos).at(clv.at(i))){
                vector<int> newlv(clv);
                newlv.erase(newlv.begin() + i);
                newlv.at(0) = clv.at(i);
                lvl.push_back(newlv);
            }
        }
    }
    cout << out << endl;
    return 0;
    
}

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

using namespace std;

int main()
{
    int n ;
    cin >> n ;
    string s, t ;
    cin >> s >> t ;
    string ans ;
    for(int i = 0 ; i < n ; i++)
    {
        ans +=(s[i]) ;
        ans += t[i] ;
    }
    cout << ans << endl ;
    return 0 ;
}


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

using namespace std;

const int MAXN = 2e5 + 5;
const int inf = 1e9;

int dp[MAXN][2];
int pr[MAXN][2];

int main() {
	string s;
	cin >> s;
	int n = s.size();

	for (int i = 0; i < n; i++) {
		if (s[i] != '?')
			cout << s[i];
		else
			cout << 'D';
	}
	cout << endl;
	return 0;
	//0 - P
	//1 - D
	dp[0][0] = 0;
	dp[0][1] = 1;

	pr[0][0] = 0;
	pr[0][1] = 0;
	if (s[0] == 'P') {
		dp[0][1] = -inf;
	}
	if (s[0] == 'D') {
		dp[0][0] = -inf;
	}
	for (int i = 1; i < n; i++) {
		if (s[i] == 'P') {
			int val1 = dp[i - 1][0];
			int val2 = dp[i - 1][1];
			if (val1 >= val2) {
				dp[i][0] = val1;
				pr[i][0] = 0;
			}
			else {
				dp[i][0] = val2;
				pr[i][0] = 1;
			}
			dp[i][1] = -inf;
		}


		if (s[i] == 'D') {
			int val1 = dp[i][0] + 2;
			int val2 = dp[i][1] + 1;
			if (val1 >= val2) {
				dp[i][1] = val1;
				pr[i][1] = 0;
			}
			else{
				dp[i][1] = val2;
				pr[i][1] = 1;
			}
			dp[i][0] = -inf;
		}
		
		if (s[i] == '?') {
			//put P
			int val1 = dp[i - 1][0];
			int val2 = dp[i - 1][1];
			if (val1 >= val2) {
				dp[i][0] = val1;
				pr[i][0] = 0;
			}
			else {
				dp[i][0] = val2;
				pr[i][0] = 1;
			}

			//put D
			val1 = dp[i - 1][0] + 2;
			val2 = dp[i - 1][1] + 1;
			if (val1 >= val2) {
				dp[i][1] = val1;
				pr[i][1] = 0;
			}
			else {
				dp[i][1] = val2;
				pr[i][1] = 1;
			}

		}
	}
	int st = 0;
	if (dp[n - 1][1] > dp[n - 1][0])
		st = 1;
	string ans = "";
	for (int i = n - 1; i >= 0; i--) {
		if (st == 0)
			ans += 'P';
		else
			ans += 'D';
		st = pr[i][st];
	}
	reverse(ans.begin(), ans.end());
	cout << ans << endl;
	//for (int i = 0; i < n; i++) {
	//	cerr << dp[i][0] << "/" << dp[i][1] << " ";
	//}
	//cerr << endl;
}

Measured memory_bytes: 3700
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;
 
template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)
 
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

 
int main() {
    int N, M; cin >> N >> M;
    vector<int> s(M), c(M);
    rep(i,M) {
        cin >> s[i] >> c[i];
    }

    int res = -1;
    int a = pow(10,N-1);
    int b = pow(10,N);
    if (N == 1) a = 0;
    repr(n, a, b) {
        string n_str = to_string(n);
        bool flg = true;
        rep(i,M) {
            if (n_str[s[i]-1] != '0' + c[i]) flg = false;
        }
        if (flg) {
            res = n;
            break;
        }
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#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;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

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

#define P pair<int,int>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    int from,to,value;
    Edge(int a,int b,int c){
        from = a;
        to = b;
        value = c;
    }
    Edge(int a,int b){
        from = a;
        to = b;
    }
};
LL calc(int n,V<LL> vec){
    LL ins = 0;
    REP(a,vec.size()){
        ins += abs(vec.at(a)-n);
    }
    return ins;
}
int main(){
    CIN(N);
    V<LL> vec;
    REP(a,N){
        CIN(b);
        vec.pb(b-a-1);
    }
    LL ma = *max_element(ALL(vec));
    LL mi = *min_element(ALL(vec));
    while(true){
        if(abs(ma-mi) <= 3){
            break;
        }
        LL ins1 = (ma-mi)*2/3 + mi;
        LL ins2 = (ma-mi)/3 + mi;
        if(calc(ins1,vec) > calc(ins2,vec)){
            ma = ins1;
        }else{
            mi = ins2;
        }
    }
    LL ans = LINF;
    for(int a = mi;a <= ma;a++){
        ans = min(ans,calc(a,vec));
    }
    COUT(ans);
    return 0;
}


Measured memory_bytes: 5104
#include<iostream>
#include<complex>
#include<vector>
using namespace std;

struct Point {
  int x;
  int y;
};

typedef struct Point Point;

vector<Point> rotate(vector<Point> p) {

  for(int i=0; i<p.size(); i++) {

  }

}

bool compare(vector<Point> r,vector<Point> l) {
  vector<Point> p = vector<Point>(l.rbegin(), l.rend());

  if( r.size() != l.size() ) return false;

  bool f1=true,f2=true,f3=true,f4=true,f5=true,f6=true,f7=true,f8=true;
  for(int i=0; i<r.size(); i++) {

    //cout<<i<<endl;
    //cout<<"r"<<r[i].x<<" "<<r[i].y<<"l"<<l[i].x<<" "<<l[i].y<<"p"<<p[i].x<<" "<<p[i].y<<endl;
    if( !(r[i].x == l[i].x && r[i].y == l[i].y) ) f1 = false;
    if( !(r[i].x == -1*l[i].y && r[i].y == l[i].x) ) f2 = false;
    if( !(r[i].x == -1*l[i].x && r[i].y == -1*l[i].y ) ) f3 = false;
    if( !(r[i].x == l[i].y && r[i].y == -1*l[i].x) ) f4 = false;
    if( !(r[i].x == p[i].x && r[i].y == p[i].y) ) f5 = false;
    if( !(r[i].x == -1*p[i].y && r[i].y == p[i].x) ) f6 = false;
    if( !(r[i].x == -1*p[i].x && r[i].y == -1*p[i].y ) ) f7 = false;
    if( !(r[i].x == p[i].y && r[i].y == -1*p[i].x) ) f8 = false;
  }


  if( f1 || f2 || f3 || f4 || f5 || f6 || f7 || f8 ) return true;
  return false;
}

int main() {

  int n;
  while(true) {
    cin>>n;
    if( n==0 ) break;

    n++;
    vector< vector<Point> > polys;
    while(n--) {

      int m;
      cin>>m;
      vector<Point> poly,tmp;


      while(m--) {
	int x,y;
	cin>>x>>y;
	Point p;
	p.x = x;
	p.y = y;
	tmp.push_back(p);
      }

      //cout<<"!!!"<<endl;
      for(int i=1; i<tmp.size(); i++) {
	Point p;
	p.x = tmp[i].x - tmp[i-1].x;
	p.y = tmp[i].y - tmp[i-1].y;
	//pcout<<p.x<<" "<<p.y<<endl;
	poly.push_back(p);
      }

      polys.push_back(poly);

    }

    //cout<<"output"<<endl;
    for(int i=1; i<polys.size(); i++) {
      if( compare( polys[0], polys[i] ) ) {
	cout<<i<<endl;
      }
    }

    cout<<"+++++"<<endl;
  }
}

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

const int inf = 1001001001;
const int dx[] = {-1, 0, 0, 1}, dy[] = {0, -1, 1, 0};

int h, w, k;
char c[1000][1000];
int d[1000][1000];

bool inside(int y, int x) {
  return 0 <= y && y < h && 0 <= x && x < w;
}

int main() {
  cin >> h >> w >> k;

  for (int i = 0; i < 1000; ++i) {
    for (int j = 0; j < 1000; ++j) {
      d[i][j] = inf;
    }
  }

  queue<pair<int, int>> q;
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      cin >> c[i][j];
      if (c[i][j] == 'S') {
        q.push(pair<int, int>(i, j));
        d[i][j] = 0;
      }
    }
  }

  while (!q.empty()) {
    int y = q.front().first;
    int x = q.front().second;
    q.pop();

    for (int i = 0; i < 4; ++i) {
      int ny = y + dy[i];
      int nx = x + dx[i];
      if (inside(ny, nx) && c[ny][nx] == '.' && d[ny][nx] > d[y][x] + 1) {
        d[ny][nx] = d[y][x] + 1;
        if (d[ny][nx] != k) {
          q.push(make_pair(ny, nx));
        }
      }
    }
  }

  int ans = inf;
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      if (d[i][j] == inf) continue;
      int dist = min({i, j, h - i - 1, w - j - 1});
      ans = min(ans, (dist + k - 1) / k + 1);
    }
  }

  cout << ans << endl;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> a(3 * n);

    for (auto &x : a) {
        cin >> x;
    }
    sort(a.begin(), a.end());

    int64_t ans = 0;

    for (int i = n; i < 3 * n; i += 2) {
        ans += a.at(i);
    }

    cout << ans << endl;
}


Measured memory_bytes: 4572
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
ll a,b,c,i,j,k,l,m,n,ans;
string s;
int main(){
  cin>>n>>s;
  int lr,lg,lb,rr,rg,rb;
  for(int i=1;i<n;i++){
    lr=0,lg=0,lb=0,rr=0,rg=0,rb=0;
    if(s[i]=='R'){
      lg=count(s.begin(), s.begin()+i, 'G');
      lb=count(s.begin(), s.begin()+i, 'B');
      rg=count(s.begin()+i+1, s.end(), 'G');
      rb=count(s.begin()+i+1, s.end(), 'B');
    }
    if(s[i]=='G'){
      lr=count(s.begin(), s.begin()+i, 'R');
      lb=count(s.begin(), s.begin()+i, 'B');
      rr=count(s.begin()+i+1, s.end(), 'R');
      rb=count(s.begin()+i+1, s.end(), 'B');
    }
    if(s[i]=='B'){
      lg=count(s.begin(), s.begin()+i, 'G');
      lr=count(s.begin(), s.begin()+i, 'R');
      rg=count(s.begin()+i+1, s.end(), 'G');
      rr=count(s.begin()+i+1, s.end(), 'R');
    }
    for(int j=1;j<n;j++){
      if(i-j>=0&&i+j<n){
        if(s[i]=='R'){
          if((s[i-j]=='G'&&s[i+j]=='B')||(s[i-j]=='B'&&s[i+j]=='G')){
            ans--;
          }
        }
        if(s[i]=='G'){
          if((s[i-j]=='R'&&s[i+j]=='B')||(s[i-j]=='B'&&s[i+j]=='R')){
            ans--;
          }
        }
        if(s[i]=='B'){
          if((s[i-j]=='G'&&s[i+j]=='R')||(s[i-j]=='R'&&s[i+j]=='G')){
            ans--;
          }
        }
      }
    }
    if(s[i]=='R')ans+=(lg*rb+rg*lb);
    if(s[i]=='G')ans+=(lr*rb+rr*lb);
    if(s[i]=='B')ans+=(lg*rr+rg*lr);
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int a[33]= {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;
int main()
{
    cin>>k;
    k--;
    for(int i=0; i<32; i++)
        if(i==k)
            cout<<a[i];
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<algorithm>
#include<queue>
#include<cmath>
#include<map>
#include<string>
#include<vector>
#include<iomanip>
#include<cstdio>
#include<stack>
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int maxn = 300005;
int main()
{
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n, k, a, ans = 0;
	cin >> n >> k;
	while (n--)
	{
		cin >> a;
		if (a >= k) ans++;
	}
	cout << ans << endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>
#include <tuple>

template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
  if (lhs > rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
  if (lhs < rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

// [l, r) from l to r
struct range {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { ++i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr range(int l_, int r_): l(l_), r(std::max<int>(l_, r_)) { }
  constexpr itr begin() const { return l; }
  constexpr itr end() const { return r; }
};

// [l, r) from r to l
struct revrange {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { --i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr r, l;
  constexpr revrange(int l_, int r_): l(l_ - 1), r(std::max<int>(l_, r_) - 1) { }
  constexpr itr begin() const { return r; }
  constexpr itr end() const { return l; }
};

template <class T>
inline T scan() {
  T res;
  std::cin >> res;
  return res;
}

int main() {
  const int N = scan<int>();
  std::vector<int> L(N), R(N);
  for (int i: range(0, N)) {
    std::cin >> L[i] >> R[i];
  }
  long long ans = 0;
  std::sort(L.rbegin(), L.rend());
  std::sort(R.begin(), R.end());
  std::vector<long long> sum_l(N + 1), sum_r(N + 1);
  for (int i: range(0, N)) {
    sum_l[i + 1] = sum_l[i] + L[i];
    sum_r[i + 1] = sum_r[i] + R[i];
  }
  for (int i: range(0, N + 1)) {
    if (i + i > N) {
      break;
    }
    chmax(ans, sum_l[i] - sum_r[i]);
    if (i + i + 1 <= N) {
      chmax(ans, sum_l[i + 1] - sum_r[i]);
      chmax(ans, sum_l[i] - sum_r[i + 1]);
    }
  }
  std::cout << ans * 2 << '\n';
  return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include<math.h>
#define rep(i,a) for(int i=0;i<a;i++)
#define nrep(i,a,b) for(int i=a;i<b;i++)
#define mrep(i,a) for(int i=a;i>=0;i--)
#define mmrep(i,a) for(int i=a;i>0;i--)
#define ll long long
#define INF 1123456789012
using namespace std;

int main(){

	ll n; cin >> n;
	string s = to_string(n);
	ll n_size = s.size();
	ll a = n_size / 2+1;
	ll temp = pow(10, a)-1;
	ll ans = INF;
	mmrep(i, temp) if ((n / i)*i == n){
		string ans_1 = to_string(i);
		string ans_2 = to_string(n / i);
		ll ngo = max(ans_1.size(), ans_2.size());
		ans=min(ans,ngo);
	}cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
// AOJ Collatz's Problem :http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0158

package main

import (
	"fmt"
)

func main() {
	for {
		var n int

		fmt.Scanf("%d", &n)

		if n == 0 {
			break
		}

		count := 0
		for n != 1 {
			if n%2 == 0 {
				n /= 2
			} else {
				n = n*3 + 1
			}
			count++
		}
		fmt.Println(count)
	}
}



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

#pragma optimize("O3")

//#define int long long



struct A {
    int a, b, c, d;
    bool operator < (A other) {
        return d < other.d;
    }
};

vector<A> a;
int n, m, q;

int best = 0;

void dfs(vector<int>& cur) {
    if (cur.size() == n) {
        int sum = 0;
        for (auto i : a) {
            if (cur[i.b - 1] - cur[i.a - 1] == i.c) {
                sum += i.d;
            }
        }
        best = max(best, sum);
        return;
    }

    for (int i = cur.back(); i <= m; ++i) {
        cur.push_back(i);
        dfs(cur);
        cur.pop_back();
    }
}

signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    cin >> n >> m >> q;
    a.resize(q);
    for (int i = 0; i < q; ++i) {
        cin >> a[i].a >> a[i].b >> a[i].c >> a[i].d;
    }

    vector<int> t;

    for (int i = 1; i <= m; ++i) {
        t = {i};
        dfs(t);
    }

    cout << best;

    return 0;
}

Measured memory_bytes: 3636
#include <cstdio>
#include <iostream>
#include <algorithm>
#define N 2010
#define M 4000000
#define P 1000000007

using namespace std;

typedef long long ll;

int n,k;
ll f[N][N],fac[N*N],inv[N*N];

inline int C(int x,int y){
  if(x<y) return 0;
  return fac[x]*inv[y]%P*inv[x-y]%P;
}

int main(){
  scanf("%d%d",&n,&k);
  if(k==1) return puts("1"),0;
  fac[0]=inv[0]=inv[1]=1;
  for(int i=1;i<=M;i++) fac[i]=fac[i-1]*i%P;
  for(int i=2;i<=M;i++) inv[i]=(P-P/i)*inv[P%i]%P;
  for(int i=1;i<=M;i++) inv[i]=inv[i]*inv[i-1]%P;
  f[0][0]=1;
  for(int i=1;i<=n;i++)
    for(int j=i;~j;j--){
      f[i][j]=f[i][j+1]%P;
      if(j) (f[i][j]+=f[i-1][j-1]*C(i*k-j-1,k-2))%=P;
    }
  printf("%lld\n",f[n][0]*fac[n]%P);
  return 0;
}


Measured memory_bytes: 94848
import math


tax8, tax10 = map(int, input().split())

price8_ue = math.ceil((tax8 + 1) / 0.08) - 1
price8_shita = math.ceil(tax8 / 0.08)
price10_ue = math.ceil((tax10 + 1) / 0.1) - 1
price10_shita = math.ceil(tax10 / 0.1)

range8 = set(range(price8_shita, price8_ue))
range10 = set(range(price10_shita, price10_ue))
tax = range8 & range10
if not tax:
    print(-1)
else:
    print(min(tax))

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long y = sc.nextLong();
		String ans = "-1 -1 -1";

		y /= 1000;//全部千円のときの枚数

		//10 5 1でy/1000を作れるか
		//10を1が10枚と考える？
		//5を1が5枚
		if(n > y || n < y/10) {
			System.out.println(ans);
			return;
		}
		long nowMaisu;
		for(long toMan = 0; toMan <= y/10; toMan++) {
			for(long toGo = 0; toGo <= y/5; toGo++) {
				nowMaisu = y - 9*toMan - 4*toGo;
				if(nowMaisu==n&&n-toMan-toGo >= 0) {
					System.out.println(toMan+" "+toGo+" "+(n-toMan-toGo));
					return;
				}
			}
		}
		System.out.println(ans);
	}
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < n; ++i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define stl_repr(itr, x) for (auto itr = x.rbegin(); itr != x.rend(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

using llong = long long int;

const static int MOD = 1000000007;
const static int inf = INT_MAX;
const static llong INF = LLONG_MAX;
const static int dx[4] = {1, 0, -1, 0};
const static int dy[4] = {0, 1, 0, -1};

template<typename T> T my_gcd(T a, T b) {
    return (a ? my_gcd(b % a, a) : b);
}

template<typename T> T my_lcm(T a, T b){
    return a * b / my_gcd(a, b);    
}

void solve();

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    solve();

    return 0;
}

void solve() {
    int n;
    cin >> n;
    vector<int> A(n);
    rep(i, n) cin >> A[i];

    int target = 1;
    rep(i, n) {
        if (A[i] == target) ++target;
    }

    if (target == 1) cout << -1 << endl;
    else cout << n - (target - 1) << endl; 
}

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

int a[15];

int main()
{
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	int len = s.size();
	int ans = 0;
	for (int i = 0; i < len; i++)
	{
		if (s[i] == '0')
		{
			ans++;
			a[ans] = 0;
		}
		else if (s[i] == '1')
		{
			ans++;
			a[ans] = 1;
		}
		else if (s[i] == 'B' && ans >= 1) ans--;
	}
	
	for (int i = 1; i <= ans; i++) cout << a[i];
	return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test() int t;cin>>t;for(int test=1;test<=t;test++)
#define pb push_back
#define nl cout<<"\n"
#define F first
#define S second
#define all(x) x.begin(),x.end()

template<class C> void min_self( C &a, C b ){ a = min(a,b); }
template<class C> void max_self( C &a, C b ){ a = max(a,b); }

const ll MOD = 1000000007;
ll mod( ll n, ll m=MOD ){ n%=m,n+=m,n%=m;return n; }

const int MAXN = 1e5+5;
const int LOGN = 21;
const ll INF = 1e14;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

template<class T1, class T2> void add( T1 &x, T2 y, ll m = MOD )
{
    x += y;
    if( x >= m )
        x -= m;
}

template<class T1, class T2> void sub( T1 &x, T2 y, ll m = MOD )
{
    x -= y;
    if( x < 0 )
        x += m;
}

int phi[MAXN+5];
bool is_composite[MAXN+5];
vector<int>prime;

void sieve( int n )
{
    fill( is_composite, is_composite+n, false );
    phi[1] = 1;
    for(int i=2;i<n;i++)
    {
        if( !is_composite[i] )
        {
            prime.pb(i);
            phi[i] = i-1;
        }
        for(int j=0;j<prime.size() && i*prime[j] < n ; j++)
        {
            is_composite[i*prime[j]] = true;
            if( i%prime[j] == 0 )
            {
                phi[i*prime[j]] = phi[i] * prime[j];
                break;
            }
            else
            {
                phi[i*prime[j]] = phi[i] * phi[prime[j]];
            }
        }
    }
}


ll expo( ll base, ll exp, ll m = MOD )
{
    ll res = 1;
    while( exp )
    {
        if( exp&1 )
            res = mod( res*base, m );
        base = mod( base*base, m );
        exp >>= 1;
    }
    return res;
}

int main() 
{
    fastio();

    sieve(MAXN);

    int n,k;
    cin>>n>>k;

    ll ans = 0;
    for(int g=1;g<=k;g++)
    {
        ll now = expo( k/g, n );
        now = mod( phi[g]*now );
        add( ans, now );
    }
    cout<<ans,nl;

    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}


Measured memory_bytes: 4252
use strict;

my @lines = <STDIN>;
my ($N, $M) = split(/ /, $lines[0]);
my @A = split(/ /, $lines[1]);
my %h = (0 => 1);
my $count = 0;
my $S = 0;

for (my $i = 0; $i < $N; $i++) {
    $S += $A[$i];
    $count += $h{$S % $M};
    $h{$S % $M} ++;
}

print $count, "\n";


Measured memory_bytes: 23244
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define swap(a, b, type) { type _tmp = a; a = b; b = _tmp; }
typedef long long ll;
typedef unsigned long long ull;

int l[50];

int main()
{
	int N, K, ans = 0;

	cin >> N >> K;
	rep(i, N) cin >> l[i];

	sort(l, l + N, greater<int>());

	rep(i, K) ans += l[i];

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int m = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		int xMax = x;
		int yMin = y;

		int[] aryX = new int[n];
		int[] aryY = new int[m];

		for (int i=0; i<n; i++){
			aryX[i] = sc.nextInt();
			xMax = Math.max(xMax, aryX[i]);
		}

		for (int i=0; i<m; i++){
			aryY[i] = sc.nextInt();
			yMin = Math.min(yMin, aryY[i]);
		}

		if (xMax < yMin){
			System.out.println("No War");
		} else {
			System.out.println("War");
		}
	}
}

Measured memory_bytes: 24148
N, M = map(int, input().split())
sc_dict = {}
for i in range(M):
    s, c = map(int, input().split())
    s -= 1
    if sc_dict.get(s) is not None:
        if sc_dict.get(s) != c:
            print(-1)
            exit()
    else:
        sc_dict[s] = c

for i in range(10**N):
    tmp = str(i)

    if len(tmp) != N:
        continue

    flg = True
    for s, c in sc_dict.items():
        if tmp[s] != str(c):
            flg = False

    if flg:
        print(tmp)
        exit()

print(-1)


Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
    public static double solve[][] = new double[3001][3001];
    public static double probabilities[] = new double[3000];
    public static void main(String args[])throws IOException
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        long n=Long.parseLong(br.readLine());
        String S[]=br.readLine().split(" ");
        for(int i=0;i<n;i++)
            probabilities[i]=Double.parseDouble(S[i]);
        for(int i=0;i<=n;i++)
        {
            for(int j=0;j<=n;j++)
                solve[i][j]=0;
        }
        solve[0][0]=1;
        for(int i=0;i<=n;i++)
        {
            for(int j=i;j<=n;j++)
            {
                solve[i][j+1]+=solve[i][j]*(1-probabilities[j]);
                solve[i+1][j+1]=solve[i][j]*(probabilities[j]);
            }
        }
        double totalProbability=0.0d;
        for(int i=0;i<(n+1)/2;i++)
            totalProbability+=solve[i][(int)n];
        System.out.println(1-totalProbability);
 
    }
}

Measured memory_bytes: 131028
#include <iostream>
#include <bits/c++io.h>
#include <algorithm>
#include <iomanip>
#include <math.h>
using namespace std;

int main()
{
string x,y;
cin>>x>>y;
reverse(x.begin(),x.end());
if(x==y)
    cout<<"YES"<<endl;
else
    cout<<"NO"<<endl;

 return 0;
}


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

int main(void){
    long long int i, j, k, n, ans=0, po=0, x[5];
    char s[200005], t[200005];
    for(i=0; i<200005; i++){
        s[i] = '\0';
        t[i] = '\0';
    }
    scanf("%s %s", s, t);
    for(i=0; 1; i++){
        if(s[i] == '\0') break;
        if(s[i] != t[i]) ans++;
    }
    printf("%lld", ans);
    
    
}

Measured memory_bytes: 2124
#include<stdio.h>
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    int i,x=0;
    for(i=1;i<=m;i++)
    {
        int a;
        scanf("%d",&a);
        x=x+a;
    }
    if(x>n)
    {
        printf("%d\n",-1);
    }
    else
        printf("%d\n",n-x);
    return 0;
}


Measured memory_bytes: 1704
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#define _GLIBCXX_DEBUG // check []
#define DIVISOR 1000000007

using namespace std;
typedef pair<int,int> pii;
typedef pair<int64_t, int64_t> pII;

template<typename T>
void cins(vector<T>& arr) { for(T& e: arr) cin >> e; }

#ifdef DEBUG
#define debug(fmt, ...) \
    printf("[debug: %s] " fmt, __func__, __VA_ARGS__)
#define ps(arr) \
    debug("size %ld: ", arr.size()); \
    for(auto e: arr) cout << e << " "; \
    cout << endl;
#else
#define debug(fmt, ...)
#define ps(arr)
#endif


int main(void) {
    string str;
    cin >> str;
    int len = str.length();
    vector<int> map(26);
    for(int i = 0; i < len; i++) {
        map[str[i]-'a']++;
    }
    char next = -1;
    for(int i = 0; i < 26; i++) {
        if(!map[i]) {
            next = i;
            break;
        }
    }
    if(next>-1) {
        cout << str << (char)(next + 'a') << endl;
        return 0;
    }
    vector<int> arr(len);
    vector<int> old(len);
    for(int i = 0; i < len; i++) {
        arr[i] = str[i]-'a';
        old[i] = arr[i];
    }
    if(!next_permutation(arr.begin(), arr.end())) {
        cout << -1 << endl;
    } else {
        for(int i = 0; i < len; i++) {
            putchar(arr[i]+'a');
            if(arr[i] != old[i]) break;
        }
        putchar('\n');
    }
    return 0;
}

Measured memory_bytes: 3576
#include<iostream>
#include<string>
#include<map>
#define su "Sunny"
#define cl "Cloudy"
#define ra "Rainy"
using namespace std;
map<string,string>mp;
string s;
int main(void){
	cin>>s;
	mp[su]=cl;mp[cl]=ra;mp[ra]=su;
	cout<<mp[s];
	return 0;
} 

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import numpy as np
import sys
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect
from scipy.special import comb
import copy
sys.setrecursionlimit(10**6)


def zz():
    return list(map(int, sys.stdin.readline().split()))


def z():
    return int(sys.stdin.readline())


def S():
    return sys.stdin.readline()[:-1]


def C(line):
    return [sys.stdin.readline() for _ in range(line)]


S = S()
cut_l = 0
cut_r = 0
for cut_l in range(len(S)):
    for cut_r in range(len(S)):
        # print(cut_l, cut_r)
        # print(S[:cut_l] + S[cut_r:])
        if (S[:cut_l] + S[cut_r:] == 'keyence'):
            print('YES')
            exit()
print('NO')


Measured memory_bytes: 42312
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    private static int DIRECTION_LEFT = -1;
    private static int DIRECTION_RIGHT = -1;
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int Q = scan.nextInt();
        String s = scan.next();
        List<Query> list = new ArrayList<>();
        for (int i = 0; i < Q; i++) {
            char c = scan.next().toCharArray()[0];
            char direction = scan.next().toCharArray()[0];
            int d = 'L' == direction ? -1 : 1;
            Query q = new Query();
            q.c = c;
            q.d = d;
            list.add(q);
        }
        s = "@" + s + "@";
        Status status = new Status(N, s, list);
        int left_index = find(status, 0, N + 1, 0);
        int right_index = find(status, N + 1, 0, N + 1);
        if (right_index <= left_index) {
            System.out.println(0);
        } else {
            System.out.println(right_index - left_index - 1);
        }
    }

    private int find(Status status, int lower, int upper, int expected_position) {
        while (Math.abs(upper - lower) > 1) {
            int middle = (lower + upper) / 2;
            if (status.apply_move(middle, expected_position)) {
                lower = middle;
            } else {
                upper = middle;
            }
        }
        boolean x = status.apply_move(lower, expected_position);
        if (x) {
            return lower;
        }
        return upper;
    }

    class Status {
        private int N;
        private int[] data;
        private char[] problem;
        private List<Query> queries;
        Status(int N, String s, List<Query> queries) {
            this.N = N;
            HashMap<Character, List<Integer>> m = new HashMap<>();
            this.problem = s.toCharArray();
            this.queries = queries;
            init();
        }
        void init() {
            int[] data = new int[N+2];
            Arrays.fill(data, 1);
            data[0] = 0;
            data[N+1] = 0;
            this.data = data;
        }
        boolean apply_move(int position, int expected_position) {
            int current_position = position;
            if (is_end(current_position, expected_position)) {
                return true;
            }
            for(Query q : queries) {
                if (problem[current_position] == q.c) {
                    current_position += q.d;
                }
                if (is_end(current_position, expected_position)) {
                    return true;
                }
            }
            return false;
        }
        boolean is_end(int current_position, int expected_position) {
            return current_position == expected_position;
        }
    }
    class Query {
        char c;
        int d;
    }
}


Measured memory_bytes: 88316
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;cin>>N;
  vector<int>A(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i);
  }
  int count=0;
  for(int i=1;i<N;i++){
    if(A.at(i)==A.at(i-1)){
      A.at(i)=0;
      count++;
    }
  }
  cout<<count<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#define a(b) (100+b)/100
#define f(x) for(x=1;x<t;x++)
using namespace std;
int main(){
    int e,o,t,i,j;
    while(cin>>e>>o>>t,e){
        int n=0;
        f(i)f(j)if(i*a(e)+j*a(e)==t) n=max(n,i*a(o)+j*a(o));
        cout<<n<<endl;
    }
}

Measured memory_bytes: 1160
N,K = map(int,input().split())
A = list(map(int,input().split()))
UP = max(A)
UL = UP.bit_length()
KL = K.bit_length()
MAX = max(UL,KL)
INF = float("inf")
#dp[i][j]: 上からi桁目までを決めて、N未満で確定ならj=1、Nと一致しているならばj=0
dp = [[-INF] * 2 for _ in range(MAX+1)] #-INFにしておかないとないケースから来てしまう。
dp[0][0]=0
ZF = True
L = [[0]*2 for _ in range(MAX)]
for i in range(N):
  for j in range(MAX):
    if A[i]>>j&1 == 1:
      L[MAX-1-j][1] += 1
    else:
      L[MAX-1-j][0] += 1

#print(MAX,KL)
#print(L)
for i in range(MAX):
  fac = pow(2,(MAX-1-i))
  if K>>(MAX-1-i)&1 == 1:
    ZF = False
  if ZF: #ここのビットは必ず0．つまり1の個数がかけられる。
    dp[i+1][0] = dp[i][0] + fac*L[i][1]
    dp[i+1][1] = 0
  else:
    if K>>(MAX-1-i)&1 == 1:
      kbit = 1
    else:
      kbit = 0
    #print(kbit,i)
    if kbit == 1: #どちらでも良い
      dp[i+1][1] = max(dp[i][1] + fac*max(L[i]), dp[i][0] + fac*L[i][1]) #未満
      dp[i+1][0] = dp[i][0] + fac*L[i][0] #一致, kbitが1なので0の個数
    else: #完全一致なら0のみ、それ以外ならどちらも
      dp[i+1][1] = dp[i][1] + fac*max(L[i]) #未満
      dp[i+1][0] = dp[i][0] + fac*L[i][1] #一致 kbitが0なので1の個数      
#print(dp)
ans = max(dp[MAX])
print(ans)
  


Measured memory_bytes: 20396
N,T=map(int,input().split())
A=[int(x) for x in input().split()]

maxA=[0]*(N+1)
minA=[10**10]*(N+1)

for i in range(N):
  maxA[N-i-1]=max(maxA[N-i],A[N-i-1])
  minA[i+1]=min(minA[i],A[i])

b = 0
for i in range(N+1):
  b=max(b,maxA[i]-minA[i])
tmp = -1
cnt = 0
for i in range(N):
  if maxA[i]-minA[i]==b:
    tmp=maxA[i]
  if A[i]==tmp:
    cnt+=1
print(cnt)
  

Measured memory_bytes: 62704
//https://beta.atcoder.jp/contests/abc095/tasks/abc095_b
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main() {
    int N,X,m[110];
    int sum=0,min = 1100,ans=0;
    cin >> N >> X;
    for(int i=0;i<N;i++){
        cin >> m[i];
        sum += m[i];
        if(min>m[i]) min = m[i];
    }
    cout << (X - sum)/min + N << endl;
}


Measured memory_bytes: 256
//Compete against Yourself.
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n, a, b, k;

int32_t main(){_
   

   cin >> a >> b >> k;

   int y =  min(a, k);
   a -= y;
   k -= y;

   y =  min(b, k);
   b -= y;
   k -= y;

   cout<<a<<" "<<b;

   return 0;
}

Measured memory_bytes: 256
S = input()
n = len(S)

import string
def f(x, mn=None):
    for c in string.ascii_lowercase:
        if c in x: continue
        if mn and c <= mn: continue
        return c
    return None

if n < 26:
    print(S + f(S))
    exit()

i = n-2
while i >= 0:
    if S[i] < S[i+1]: break
    i -= 1
else:
    print(-1)
    exit()

t = S[:i]
print(t + f(t, S[i]))

Measured memory_bytes: 3772
#define _GLIBCXX_DEBUG
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
  ll n; cin>>n;
  if(n%10==3) cout <<"bon"<<endl;
  else if(n%10==0||n%10==1||n%10==6||n%10==8) cout <<"pon"<<endl;
  else cout <<"hon"<<endl;
}
  

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string S;
    cin >>S;
    
        if(S.at(0)=='S'&&S.at(1)=='S'&&S.at(2)=='S'){
            cout <<0<<endl;
        }
         else if(S.at(0)=='S'&&S.at(1)=='S'&&S.at(2)=='R'){
            cout <<1<<endl;
        }
                 else if(S.at(0)=='S'&&S.at(1)=='R'&&S.at(2)=='R'){
            cout <<2<<endl;
        }
                 else if(S.at(0)=='S'&&S.at(1)=='R'&&S.at(2)=='S'){
            cout <<1<<endl;
        }
                 else if(S.at(0)=='R'&&S.at(1)=='S'&&S.at(2)=='S'){
            cout <<1<<endl;
            
        }
                 else if(S.at(0)=='R'&&S.at(1)=='S'&&S.at(2)=='R'){
            cout <<1<<endl;
        }
                         else if(S.at(0)=='R'&&S.at(1)=='R'&&S.at(2)=='S'){
            cout <<2<<endl;
        }
                         else if(S.at(0)=='R'&&S.at(1)=='R'&&S.at(2)=='R'){
            cout <<3<<endl;
        }
}


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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    vector<int> a(n);
    vector<int> b(n);
    for(int i=0;i<n;i++) {
        cin>>a[i];
    }
    bool flag = true;
    int j = 0;
    int k = n-1;
    for(int i=n-1;i>=0;i--) {
        if(flag) {
            b[j] = a[i];
            j++;
            flag = false;
        }
        else {
            b[k] = a[i];
            k--;
            flag = true;
        }
    }
    for(int i=0;i<n;i++) {
        cout<<b[i]<<" ";
    }
    return 0;
}


Measured memory_bytes: 3712
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long int LL;
typedef pair<LL,LL> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

map<P,LL> m1;

LL gcd(LL a,LL b){
	if(a<0)a=-a;
	if(b<0)b=-b;
	if(a<b)swap(a,b);
	if(b==0)return a;
	return gcd(b,a%b);
}

long long int pow_mod(long long int p_a,long long int p_n,long long int p_p=1e9+7){
	//p_a^p_n mod p_p
	long long int p_b=1,p_t=1;
	for(;p_b<=p_n;p_b<<=1);
	for(p_b>>=1;p_b>0;p_b>>=1){
		p_t*=p_t;
		if(p_t>=p_p)p_t%=p_p;
		if(p_n&p_b)p_t*=p_a;
		if(p_t>=p_p)p_t%=p_p;
	}
	return p_t;
}

int main(){
	int n,m;
	int i,j,k;
	LL a,b,c,d;
	LL s=1,s2=0;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a>>b;
		if(a==0 && b==0){
			s2++;continue;
		}
		c=gcd(a,b);
		a/=c,b/=c;
		if(a<0 || (a==0 && b<0))a=-a,b=-b;
		m1[make_pair(a,b)]++;
	}
	for(auto& node:m1){
		a=node.first.first,b=node.first.second;
		c=pow_mod(2,node.second)-1;
		swap(a,b);
		b=-b;
		if(a<0 || (a==0 && b<0))a=-a,b=-b;
		if(m1.find(make_pair(a,b))!=m1.end()){
			d=m1[make_pair(a,b)];
			if(d==-1)continue;
		}else d=0;
		c+=pow_mod(2,d);
		c%=MAX;
		s*=c;
		s%=MAX;
		node.second=-1;
	}
	s--;
	s+=s2;
	if(s<0)s+=MAX;
	s%=MAX;
	cout<<s<<endl;
}

Measured memory_bytes: 16080
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(v) v.begin(),v.end()
#define mem(arr) memset(arr, 0, sizeof(arr))
#define ff first
#define ss second
#define int long long int
const int MOD = 1e9 + 7;
const int INF = 1e18;
const int N = 1e6 + 20;
vector<int> g[N];
vector<int> vis(N);
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tc = 1;
    while(tc--){
        int n;
        cin >> n;
        int a[n];
        int ans = 0, sum = 0;
        for(int &it : a){
            cin >> it;
            if(it == 0){
                ans += sum / 2;
                sum = 0;
            }else{
                sum += it;
            }
        }
        ans += sum / 2;
        cout << ans << '\n';
    }
}

Measured memory_bytes: 32384
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;
const int maxx=100010;
const int inf=0x7fffffff;
int v,e,ans=0;
class edge{
	public:
		int source,target,cost;
		edge(int source,int target,int cost):
			source(source),target(target),cost(cost){}
		bool operator < (const edge &e ) const {
			return cost<e.cost;
		}	
};

vector<edge > A;
int pre[maxx];

int find(int u){
	if(pre[u]!=u) pre[u]=find(pre[u]);
	return pre[u];	
}

void hebing(int x,int y){
	if(find(x)!=find(y)) pre[find(y)]=find(x);
	find(y);
	return ;
}

int main (){
	cin>>v>>e;
	if(e==0) {
		cout<<"0"<<endl;return 0;
	}
	int x,y,z;
	while(e--){
		cin>>x>>y>>z;
		A.push_back(edge(x,y,z));
	}
	sort(A.begin(),A.end());
	for(int i=0;i<v;i++) pre[i]=i;
	for(int i=0;i<A.size();i++){
//		for(int i=0;i<v;i++){
//			cout<<i<<"  "<<pre[i]<<endl;
//		}cout<<endl;
		if(find(A[i].source)!=find(A[i].target)) {
			hebing(A[i].source,A[i].target);
			ans+=A[i].cost;
			//cout<<A[i].source<<"  "<<A[i].target<<"  "<<A[i].cost<<endl;
		}
	}
	cout<<ans<<endl;
	return 0;
	
}


Measured memory_bytes: 4544