akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			Scanner cin = new Scanner();
			int n = cin.Int();
			long k = cin.Long();
			var ab = new Tuple<long, long>[n];
			for (int i = 0; i < n; i++) {
				long a = cin.Long();
				long b = cin.Long();
				ab[i] = new Tuple<long, long>(a, b);
			}

			var ab2 = ab.OrderBy(x => x.Item1).ToArray();

			long cnt = 0;
			long ans = 0;
			for (int i = 0; i < n; i++) {
				cnt += ab2[i].Item2;
				if (cnt >= k) {
					ans = ab2[i].Item1;
					break;
				}
			}

			Console.WriteLine(ans);
		}
	}

	public class Scanner
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private string[] buf_;
		private int index_;

		public Scanner()
		{
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = Console.ReadLine();
			while (st == "") {
				st = Console.ReadLine();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}
	}
}

Measured memory_bytes: 27592
#include<stdio.h>

int main(){
    int a,b,d,r;
    double f;
    scanf("%d%d",&a,&b);
    d = a/b;
    r = a%b;
    f = (double)a/(double)b;
    printf("%d %d %lf\n",d,r,f);
    return 0;
}


Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

template <typename T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  int64_t res = 1LL << 60;
  for (int bit = 0; bit < (1 << N); bit++) {
    int k = 1, ma = A[0];
    int64_t cost = 0;
    for (int i = 1; i < N; i++) {
      int diff = 0;
      if ((bit >> i) & 1) {
        diff = max(0, ma - A[i] + 1);
        cost += diff;
      }
      if (chmax(ma, A[i] + diff)) k++;
    }
    if (k >= K) res = min(res, cost);
  }
  cout << res << '\n';
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    static boolean map[][]=new boolean[12][12];
    static int ans=0; 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()){
            for(int i=0;i<12;i++){
                char[] c = sc.next().toCharArray();
                for(int j=0;j<12;j++){
                    map[i][j]=c[j]=='1';
                }
            }
            int ans=0;
            for(int i=0;i<12;i++){
                for(int j=0;j<12;j++){
                    if(map[i][j]){
                        dfs(i, j);
                        ans++;
                    }
                }
            }
            System.out.println(ans);
        }   
    }
    public static void dfs(int x,int y){
        map[x][y] = false;
        int x_c[]={1,0,-1,0};
        int y_c[]={0,1,0,-1};
        for(int i=0;i<4;i++){
            int x1=x+x_c[i];
            int y1=y+y_c[i];
            if(0<=x1&&0<=y1&&x1<12&&y1<12&&map[x1][y1])//
                dfs(x1, y1);        
        }
    }
}

Measured memory_bytes: 26348
#include<stdio.h>
#define max 100
int main(void){
  int i,n,j;
  int a[max];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  for(j=n-1;j>0;j--){
    printf("%d ",a[j]);
  }
  printf("%d\n",a[0]);

  return 0;
}



Measured memory_bytes: 2032
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
 
const ll INF = 1e9;
 
void out(VI &ans){
    REP(i,ans.size()){
        if (ans[i] == 0) break;
        printf("%d ", ans[i]);
    }
    cout << endl;
}
 
int main() {
    int n, k;
    cin >> n >> k;
 
    if (n % 2 == 0){
        printf("%d ", n/2);
        REP(i,k-1) printf("%d ", n);
        cout << endl;
        return 0;
    }
 
    if (n == 1){
        VI ans((k+1)/2, 1);
        out(ans);
        return 0;
    }
 
    VI ans(k, (n+1)/2);
    int d = k/2;
    REP(i,d){
        int j = k - 1;
        while (ans[j] == 0) j--;
        ans[j]--;
        if (ans[j] > 0){
            j++;
            while (j < k) ans[j++] = n;
        }
        // out(ans);
    }
 
    out(ans);
 
    return 0;
}

Measured memory_bytes: 3456
#include <iostream>

#define FOUND 1
#define NOT_FOUND 0

using namespace std;

class Array
{
public:
    Array();
    ~Array();

    int length, *p;
    void print();
};

bool binarysearch(const int*, const int, const int);

int main()
{
    Array a[2];
    for(int i=0; i < 2; ++i)
    {
        cin >> a[i].length;
        a[i].p = new int[a[i].length];
        for(int j=0; j < a[i].length; ++j)
            cin >> a[i].p[j];
    }

    int cnt = 0;
    for(int i=0; i<a[1].length; ++i)
    {
        bool tmp = binarysearch(a[0].p, a[0].length, a[1].p[i]);
        if(tmp == true) ++cnt;
    }
    cout << cnt << endl;
        
    return 0;
}

Array::Array()
{
    length = 0;
    p = nullptr;
}

Array::~Array()
{
    delete [] p;
    //cout << "DELETE ARRAY" << endl;
}

void Array::print()
{
    for(int i=0; i<length; ++i)
    {
        if(i) cout << " ";
        cout << p[i];
    }
    cout << endl;
}

bool binarysearch(const int *p, const int length, const int key)
{
    //cout << "key = " << key << endl;
    int left = 0, right = length;
    while(left < right)
    {
        int mid = (left + right) / 2;
        //cout << "mid = " << mid << ", p[mid] = " << p[mid] << endl;
        if(p[mid] == key)
            return (FOUND);
        
        else if(key < p[mid])
            right = mid;
        
        else
            left = mid + 1;
    }
    return (NOT_FOUND);
}


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

using namespace std;

// input
ll a[5];

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<int> t(5);
  t[0] = 5;
  t[1] = 7;
  t[2] = 5;
  t[3] = 7;
  t[4] = 7;
  while(true) {
    int num;
    cin >> num;
    if(num == 0)break;
    vector<string> w(num);
    rep(i,num){
        cin >> w[i];
    }
    bool ok = false;

    rep(i,num) {
        if(w[i].size() > 5)continue;
        string buf = "";
        int k = 0;
        for(int j = i; j < num; j++) {
            buf +=w[j];
            if(buf.size() == t[k]) {
                k++;
                buf = "";
            }
            else if(buf.size() > t[k])break;
            if(k == 5)ok =true;
        }
        if(ok) {
            cout << i+1 << endl;
            break;
        }
    }
  }
}


Measured memory_bytes: 3192
#include<bits/stdc++.h>
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")

using namespace std;

typedef long long ll;

//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>pb_ds;

#define pi pair<int,int>
#define F first
#define S second
#define pb push_back
#define pp pop_back
#define mod 1000000007
#define pai acos(-1)
#define N 505



int main ()
{
//    ios_base::sync_with_stdio(false);
//    cin.tie(NULL);
//    freopen("in.txt","r",stdin);
//   freopen("out.txt","w",stdout);
    int n,m;
    cin>>n>>m;
    int sum=0,ar;
    for(int i=1;i<=m;i++){
        cin>>ar;
        sum+=ar;
    }
    if(sum<=n) cout<<n-sum<<endl;
    else cout<<-1<<endl;
    return 0;
}



Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define INF (1ll<<62)
#define EPS 1e-9
#define MOD (1e9+7)
void put(string d){}template<class H,class...T>void put(string d,H&h,T&...t){cout<<h;if(sizeof...(t))cout<<d;put(d,t...);}
template<class T>void puti(T&a,string d=" "){bool f=1;for(auto&_:a)cout<<(exchange(f,0)?"":d)<<_;cout<<endl;}
template<class T>void putii(T&a,string d=" "){for(auto&_:a)puti(_,d);}

int main(){
	int n,m;
	cin>>n>>m;
	vector<ll> ans(n+1,INF);
	vector<tuple<int,int,ll>> e(m); 
	rep(i,m){
		int a,b; ll c;
		cin>>a>>b>>c;
		e[i]=make_tuple(a,b,-c);
	}
	ans[1]=0;
	rep(i,n*2){
		bool isCng=false;
		for(auto p:e){
			int a,b; ll c;
			tie(a,b,c)=p;
			if(ans[a]!=INF and ans[b]>ans[a]+c){
				isCng=true;
				ans[b]=ans[a]+c;
			}
		}
		if(i==n-1) {
			if(isCng){
				ans[0]=ans[n];
			}else break;
		}
		if(i==n*2-1){
			if(ans[0]!=ans[n]){
				cout<<"inf"<<endl;
				return 0;
			}else break;
		}
		if(!isCng) break;
	}
	if(ans[n]==INF){
		cout<<"inf"<<endl;
	}else cout<<-ans[n]<<endl;
	return 0;
}


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

int main() {
  string s;
  cin >> s;
  vector<bool>alpha(26,true);
  for(int i = 0;i < s.size();i++) alpha[s[i]-'a'] = false;
  if(s.size() != 26){
    for(int i = 0;i < 26;i++){
      if(alpha[i]){
        s.push_back('a'+i);
        break;
      }
    }
    cout << s << endl;
    return 0;
  }
  else if(s == "zyxwvutsrqponmlkjihgfedcba"){
    cout << -1 << endl;
    return 0;
  }
  else{
    for(int i = 25;i > 0;i--){
      if(s[i] < s[i-1]){
        alpha[s[i]-'a'] = true;
        s.pop_back();
      }
      else{
        alpha[s[i]-'a'] = true;
        s.pop_back();
        char t = s[s.size()-1];
        s.pop_back();
        for(int j = 0;j < 26;j++){
          if(alpha[j] && t-'a' < j){
            s.push_back('a'+j);
            break;
          }
        }
        cout << s << endl;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var a, b, ans string
	fmt.Scan(&a, &b)
	
	if a == "H" {
		ans = b
	} else if b == "H" {
		ans = "D"
	} else {
		ans = "H"
	}

	fmt.Println(ans)
}


Measured memory_bytes: 512
def main():
    N = int(input())
    A = [int(input()) for _ in range(N)]
    sorted_A = sorted(A, reverse=True)
    ans = []
    for a in A:
        if a == sorted_A[0]:
            ans.append(str(sorted_A[1]))
        else:
            ans.append(str(sorted_A[0]))
    print("\n".join(ans))


if __name__ == '__main__':
    main()


Measured memory_bytes: 107164
s = input()
#dummy = set(s)
#print(dummy,s[0],s[2])
ans = s[0]
count = 0
for i in s:
  if i == ans:
    count += 1
    if count == 3:
      print("Yes")
      break
  else:
    count = 1
  ans = i
if count <= 2:
  print("No")




Measured memory_bytes: 2940
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define fore(x, c) for(auto &&x : c)
#define rep(i, a, n) for(int i = a, i##len = (int)(n); i < i##len; ++i)
#define rrep(i, a, n) for(int i = (int)(n - 1); i >= a; --i)
#define sz(c) ((int)c.size())
#define contains(c, x) (c.find(x) != end(c))
#define inseg(l, x, r) ((l) <= (x) && (x) < (r))
#define dump(...)
#define pb push_back
#define eb emplace_back
#define _ 0
const signed INF_ = 1001001001; const long long INF = 1001001001001001001LL;
const int DX[9] = {0,1,0,-1,1,1,-1,-1,0}, DY[9] = {-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os, const vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is, vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
  is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a, const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a, const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap = priority_queue<T, deque<T>, greater<T>>;
struct before_main_function {
  before_main_function() {
      cin.tie(nullptr); ios::sync_with_stdio(0);
      cout << setprecision(15) << fixed;
  }
} before_main_function;
// clang-format on
//------------------8<------------------------------------8<--------------------

signed main() {
  int A, B;
  cin >> A >> B;
  rep(i, 0, 1001) {
    if (floor(i * 0.08) == A && floor(i * 0.1) == B) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return (0 ^ _ ^ 0);
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int m,n,a,b,c,d,e,f,g;
    while(1){
        cin >> m;
        if(m==0){
            break;
        }
        a=1000-m;
        b=a/500;
        c=(a-500*b)/100;
        d=(a-500*b-100*c)/50;
        e=(a-500*b-100*c-50*d)/10;
        f=(a-500*b-100*c-50*d-e*10)/5;
        g=(a-500*b-100*c-50*d-e*10-f*5)/1;
        n=b+c+d+e+f+g;
        cout << n << endl;
    }
    
}



Measured memory_bytes: 3012
#from collections import deque,defaultdict
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True  and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

def modinv2(x,r):
  return pow(x,r-2,r)

def comb(n,k):
    ret = fact[n]*modinv2(fact[n-k]*fact[k],R)%R
    #ddprint(f"comb {n=} {k=} {ret=}")
    return ret

n = inn()
a = inl()
fact = [1]*(n+1)
for i in range(1,n+1):
    fact[i] = (fact[i-1]*i)%R
ddprint(fact)
c = [-1]*(n+1)
for m in range(n+1):
    x = a[m]
    if c[x]>=0:
        i = c[x]
        j = m+1
        break
    c[x] = m+1
#ddprint(f"{n=} {i=} {j=}")
print(n) # k=1
for k in range(2,n):
    #ddprint(f"{k=}")
    v0 = comb(n-1,k) if k<=n-1 else 0
    #ddprint(f"{v0=}")
    v2 = comb(n-1,k-2) if k>=2 else 0
    #ddprint(f"{v2=}")
    v1 = 2*comb(n-1,k-1) - \
         (0 if n-j+i<k-1 else comb(n-j+i,k-1))
    #ddprint(f"{k=} {v0=} {v1=} {v2=}")
    print((v0+v1+v2)%R)
if n>1:
    print(n if j==i+1 else n+1) # k=n
print(1) # k=n+1


Measured memory_bytes: 85788
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		int E = sc.nextInt();
		int K = sc.nextInt();

		if((E - A) > K){
			System.out.println(":(");
		} else {
			System.out.println("Yay!");
		}
	}
}

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

#define ll long long
#define pb push_back
#define eb emplace_back
//#define st first
#define sc second

using namespace std;

const ll mod = 1e9 + 7;
const int e = 55;
const int base = 311;

// dung inverse module de tinh nCk
// beginer 82
// mbeginer
// cach tao hoan vi tu n so : n*(n+1)/2;

//vector<pair<ll,ll>>adj[e];
//vector<ll>adj[e];

/*ll Pow(ll n, ll dem)
{
    if(dem == 0) return 1;
    if(dem == 1) return n ;
    ll t = Pow(n, dem/2);
    if(dem % 2 == 0) return (t*t);
    else return ((t * t) * n);
}*/

/*ll C(ll k, ll n)
{
    if(k == 0) return 1;
    if(n < k) return 0;
    return (gt[n]%mod * (igt[k]%mod * igt[n-k]%mod)%mod)%mod;
}*/


int main()
{
  ll s, w;
  cin >> s >> w;
  if(s <= w) cout <<"unsafe";
  else cout <<"safe";
}
/*

*/


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
constexpr int P = 1E9 + 7, N = 3E2;
void inc(int &a, int b) {(a += b) >= P ? a -= P : 0;}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<int> a(2 * n), c(2 * n);
    for (int i = 0; i < 2 * n; ++i) {
        cin >> a[i];
        if (a[i] != -1)
            c[--a[i]] = 1;
    }
    int cnt = 0;
    for (int i = 0; i < n; ++i) {
        if (a[2 * i] != -1 && a[2 * i + 1] != -1)
            c[a[2 * i]] = c[a[2 * i + 1]] = 2;
        if (a[2 * i] == -1 && a[2 * i + 1] == -1)
            ++cnt;
    }
    int f[2 * N + 1][N + 1][N + 1] {};
    f[2 * n][0][0] = 1;
    for (int i = 2 * n - 1; i >= 0; --i) {
        if (c[i] == 2) {
            memcpy(f[i], f[i + 1], sizeof(f[i]));
            continue;
        }
        for (int j = 0; j <= n; ++j) {
            for (int k = 0; k <= n; ++k) {
                int val = f[i + 1][j][k];
                if (val == 0)
                    continue;
                if (c[i] == 1) {
                    if (k < n)
                        inc(f[i][j][k + 1], val);
                    if (j > 0)
                        inc(f[i][j - 1][k], val);
                } else {
                    if (j < n)
                        inc(f[i][j + 1][k], val);
                    if (j > 0)
                        inc(f[i][j - 1][k], val);
                    if (k > 0)
                        inc(f[i][j][k - 1], 1LL * k * val % P);
                }
            }
        }
    }
    int ans = f[0][0][0];
    for (int i = 1; i <= cnt; ++i)
        ans = 1LL * ans * i % P;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 212992
#include <iostream>
#include <algorithm>
using namespace std;
#define INF 1e9+5

int main(){
    int N,ma=-INF,mi=INF,b;
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>b;
        ma=max(ma,b);
        mi=min(mi,b);
    }
    cout<<ma-mi<<endl;
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vint;
typedef vector<double> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<int> > vvint;
typedef vector<pair<int, int> > vpii;
typedef vector<pair<ll, ll> > vpll;
typedef priority_queue<int, vector<int>, greater<int> > spqint; //小さい順に取り出し
typedef priority_queue<ll, vector<ll>, greater<ll> > spqll;     //小さい順に取り出し
typedef priority_queue<int, vector<int>, less<int> > bpqint;    //大きい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll> > bpqll;        //大きい順に取り出し

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (int)a; i < (int)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define PF push_front
#define TS to_string
#define BS binary_search
#define LB lower_bound
#define UB upper_bound
#define NP next_permutation
#define DI(v,i) distance((v).begin(),(auto(i)))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)

const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
const double PI = M_PI;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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; }     //最小公倍数

void yes()
{
    cout << "Yes" << endl;
}
void no()
{
    cout << "No" << endl;
}
//-----------------------------------------

//-----------------------------------------
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int k ;
    string s ;
    cin >> k >> s ;
    int n = SZ(s) ;
    if(n<=k){
        cout << s <<endl ;
    }
    else{
        cout << s.substr(0,k) <<"..."<<endl ;
    }

    

    return 0;
}



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

int main() {
  int n,count,ans;
  cin>>n;
  vector<long int> a(n);
  for(int i=0;i<n;i++)cin>>a.at(i);
  sort(a.begin(),a.end());
  ans=0;
  count=1;
  
  for(int i=0;i<n-1;i++){
    if(a.at(i)==a.at(i+1)){
      count++;
    }
    else{
      ans+=count%2;
      count=1;
    }
  }
  ans+=count%2;
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

int main() {
   
    int n;
    string s;
    cin >> n >> s;
    int red = 0;
    int blue = 0;
    for (ll i=0;i<n;i++){
        if(s[i] == 'B'){
            blue++;
        }else{
            red++;
        }
    }
    if(red > blue){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }


}

Measured memory_bytes: 768
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back

typedef long long LL;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<LL> VL;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;

int const MAX_N = 100009;

int par[MAX_N];
int high[MAX_N];
int sz[MAX_N];

void init(int n) {
	rep(i, n) { par[i] = i; high[i] = 0; sz[i] = 1; }
}
int root(int x) {
	return (par[x] == x) ? (x) : (par[x] = root(par[x]));
}
bool same(int x, int y) {
	return root(x) == root(y);
}
LL getsize(int x) {
	return (LL)sz[root(x)];
}
void unite(int x, int y) {
	x = root(x), y = root(y);
	if (x == y)return;

	if (high[x] < high[y]) {
		par[x] = y;
		sz[y] += sz[x];
	}
	else {
		par[y] = x;
		sz[x] += sz[y];
		if (high[x] == high[y])high[x]++;
	}
}

void parprint(int n) {
	rep(i, n) {
		printf("%d(%d, %d) ", i, par[i], sz[i]);
	}
	puts("\n");
}

LL aaa(int x) { return (LL)x * (x - 1) / 2; }

int main() {
	int n, m; cin >> n >> m;
	VI a(m), b(m); rep(i, m) {
		cin >> a[i] >> b[i];
		a[i]--; b[i]--;
	}

	init(n);
	vector<LL> print(m); print[m - 1] = aaa(n);

	for (int i = m - 1; i >= 1; i--) {
		if (!same(a[i], b[i])) {
			LL be1 = getsize(a[i]), be2 = getsize(b[i]);
			unite(a[i], b[i]);
			LL af = getsize(a[i]);

			//printf("unite(%d, %d) -> size(%lld, %lld)\n", a[i], b[i], be1, be2);
			//parprint(n);

			print[i - 1] = print[i] - be1 * be2;
		}
		else {
			print[i - 1] = print[i];
		}
	}
	rep(i, m)cout << print[i] << endl;
}

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

int main(void) {


	int a[26] = {};

	string str;
	// getline(cin, str);

	while (getline(cin, str)) {
		for(int i=0;i<str.size();i++) {
			if('a' <= str[i] && str[i] <= 'z') {
				a[(int)str[i]-'a'] += 1;
			} else if('A' <= str[i] && str[i] <= 'Z') {
				a[(int)str[i]-'A'] += 1;
			}
		}
	}

	for(int i=0;i<26;i++) {
		cout << (char)(i+(int)'a') << " : " << a[i] << endl;
	}

    return 0;
}

Measured memory_bytes: 1176
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define pi 3.1415926535897932384
#define E9 1000000000

int main(){
  int64_t X, Y; cin >> X >> Y;
  int N = 1 + (int)log2l(Y/X);
  cout << N << endl;

  return 0;
}

Measured memory_bytes: 512
N = int(input())

#print(int(str(N)[0]))
#print(int(str(N)[-1]))

ans = 0

ansDict = {}
for i in range(10, 100):
    inAns = 0
    head = int(i / 10)
    tail = int(i % 10)

    #先頭行が0の場合は考慮しない（0件）
    if tail == 0:
        ansDict[i] = 0
        continue

    # 先頭と末尾が同じ桁数の時は、1桁の数値も組み合わせに含める
    if(head == tail):
        inAns = inAns + 1

#    print("key = " + str(head * 10 + tail))
    B = tail * 10 + head
    keta = 1
    while(B <= N):
#        print(B)
        inAns = inAns + 1
        next = B + 10
        if(int(str(next)[0]) != tail):
            keta = keta + 1
            B = tail * (10 ** keta) + head
        else:
            B = next

    ansDict[i] = inAns


for i in range(1, N + 1):
    head = int(str(i)[0])
    tail = int(str(i)[-1])
    ans = ans + ansDict[head * 10 + tail]

print(ans)

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

int main() {
	int n, a[100];
	cin >> n;
	for (int i = 0; i <= n-1; i++) {
		cin >> a[i];
	}
	
	for (int i = 0; i <= n-1; i++) {
		int v = a[i];
		int j = i - 1;
		while (j >= 0 && a[j] > v) {
			a[j+1] = a[j];
			j--;
		}
		a[j+1] = v;
		for (int k = 0; k <= n-1; k++) {
			cout << a[k];
			if (k < n-1) {
				cout << " ";
			} else {
				cout << endl;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 3100
x,y,z,w=map(int,input().split())
def m(a,b):
  return [sum(a[i][j]*b[j]for j in range(2))for i in range(2)]
def a(a,b,s=None):
  if s:
    return [a[i]-b[i]for i in range(2)]
  else:
    return [a[i]+b[i]for i in range(2)]
r=[[0,-1],[1,0]]
p=a([z,w],[x,y],True)
f=m(r,p)
s=m(r,f)
print(*a([z,w],f),end=' ')
print(*a(a([z,w],f),s),end=' ')

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] a = new long[n];
		long an = 0;
		for(int i = 0; i < n; i++)
		{
			a[i] = sc.nextLong();
			if(i == 0 && a[i] != 0)
			{
				System.out.println(-1);
				return;
			}
			if(i!=0)
			{
				if(a[i] != 0 && a[i] - a[i-1] > 1)
				{
					System.out.println(-1);
					return;
				}
				if(a[i]-a[i-1]==1)
				{
					an++;
				}
				else
				{
					an+=a[i];
				}
			}
		}
		System.out.println(an);
	}

}


Measured memory_bytes: 89092
n = int(input())
alist=list(map(int,input().split()))

alist = sorted(alist,reverse=True)
ans = alist[0]
count = 1
flag = True
for i in range(n-2):
    if flag:
        ans += alist[count]
        flag = False
    else:
        ans += alist[count]
        count += 1
        flag = True

print(ans)

Measured memory_bytes: 31452
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Long> a = new ArrayList<>();
        IntStream.range(0, n).forEach(i -> a.add(sc.nextLong()));

        int count = 0;
        Map<Long, Integer> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            long target = a.get(i);
            if (map.containsKey(target)) {
                map.put(target, map.get(target) + 1);
                continue;
            }
            map.put(target, 1);
        }
        for (Long key : map.keySet()) {
            if (map.get(key) % 2 != 0) {
                count++;
            }
        }
        System.out.println(count);
    }

}


Measured memory_bytes: 63252
#include <bits/stdc++.h>
using namespace std;
#define equals(a, b) (fabs((a) - (b)) < EPS)

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

const int INF = 1 << 28;
const ll LLINF = 1LL << 60;
const double EPS = 1e-9;

int main()
{
    bool flag = false;
    string S;
    cin >> S;
    for(int i = 0; i < S.size() - 1; i++) {
        if(S[i] == 'A' && S[i + 1] == 'C') {
            flag = true;
        }
    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
    return (0);
}

Measured memory_bytes: 256
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**9)
from collections import deque
from math import ceil

h,w,k=map(int,input().split())
MAP=[]
for i in range(h):
    s=list(input().strip())
    for j,t in enumerate(s):
        if t=='S':
            sx,sy=i,j
    MAP.append(s)
delta=[[1,0],[0,1],[-1,0],[0,-1]]
q=deque()
q.append((sx,sy,k))
dist=float('inf')
Visited=[[False]*w for _ in range(h)]
Visited[sx][sy]=True
while q:
    x,y,t=q.popleft()
    dist=min(dist,x,y,h-1-x,w-1-y)
    if not dist:
        break
    if t:
        t-=1
        for dx,dy in delta:
            if MAP[x+dx][y+dy]=='.' and not Visited[x+dx][y+dy]:
                q.append((x+dx,y+dy,t))
                Visited[x+dx][y+dy]=True
print(1+ceil(dist/k))

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

int main(){
    int n,ans;
    cin >> n;
    vector<int>count(101,0);
    for(int i = 1;i<=n;i++){
        ans = i;
        for(int j = 1;j<=7;j++){

            if(ans % 2 == 0){
                ans /= 2;
                count.at(i) ++;
            }else{
                break;
            }
        }
    }
    sort(count.begin(),count.end());
    reverse(count.begin(),count.end());
    int koko=1;
    for(int i =0 ;i< count.at(0);i++){
        koko *= 2;
    }
    cout << koko << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define FORUL(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#define FORULE(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define FOREACH(it, X) for(__typeof((X).begin()) it = (X).begin(); it != (X).end(); it++)
#if defined(_MSC_VER) || __cplusplus > 199711L
#define AUTOVAR(newvar,v) auto newvar = (v)
#else
#define AUTOVAR(newvar,v) __typeof(newvar) r = (v)
#endif
#define PB(x) push_back(x)
#define MP(x,y) make_pair((x),(y))
#define MEMSET(m,v) memset(m,v,sizeof(m))

typedef long long				 ll;
typedef unsigned long long		ull;

#define DEBUG 1

#if DEBUG
#define DOUT cout<<"["<<__LINE__<<"]:"
#else
#define DOUT 0 && cout
#endif

using namespace std;

string S;

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

	cin >> S;
	bool good=true;
	for(int i=0; i<S.length(); i++) {
		if(i%2==0) {
			if (S[i]=='R'||S[i]=='U'||S[i]=='D') {
				continue;
			}
			else {
				good=false;
				break;
			}
		}
		else {
			if (S[i]=='L'||S[i]=='U'||S[i]=='D') {
				continue;
			}
			else {
				good=false;
				break;
			}
		}
	}
	if(good) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
	cout << endl;

	return 0;
}




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


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

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

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




int main() {
    string s, t;
    cin >> s >> t;
    REP(i, s.size()){
        if(s == t){
            cout << "Yes" << endl;
            return 0;
        }
        s = s.back() + s.substr(0, s.size() - 1);
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define MAX 987654321
#define vi vector<int>
using namespace std;
int ans = 987654321,n,m,x,csum=0;

void findRemove(vi & cost,vi & sum,vector<vi> & skill,int depth){
	bool isAns = true;
	for(int i=0;i<m;i++){
		if(sum[i] < x){
			isAns = false; break;
		}
	}
	if(isAns) ans = min(ans,csum);
	if(depth == n) return;
	for(int i=0;i<m;i++) sum[i] -= skill[depth][i];
	csum -= cost[depth];
	findRemove(cost, sum, skill, depth + 1);
	csum += cost[depth];
	for(int i=0;i<m;i++) sum[i] += skill[depth][i];
	findRemove(cost, sum, skill, depth + 1);
}	
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	cin>>n>>m>>x;
	vector<int> cost(n),sum(m);
	vector<vi> skill(n,vi(m));
	for(int i=0;i<n;i++){
		cin>>cost[i];
		csum += cost[i];
		for(int j=0;j<m;j++){
			cin>>skill[i][j];
			sum[j] += skill[i][j];
		}
	}
	findRemove(cost,sum,skill,0);
	cout<<(MAX == ans ? -1 : ans);
}

Measured memory_bytes: 3664
#include <cstdio>
#include <vector>

int main(void){

	int n, count, next_node, num_neighbors, min_distance;
	std::vector< std::vector<int> > edges;
	std::vector< std::vector<int> > neighbors;
	std::vector<bool> isUsed;
	std::vector<int> distance;
	scanf("%d", &n);
	edges.resize(n);
	isUsed.resize(n);
	neighbors.resize(n);
	distance.resize(n);
	for(int i=0;i<n;i++){
		scanf("%d %d", &next_node, &num_neighbors);
		edges[next_node].resize(num_neighbors);
		neighbors[next_node].resize(num_neighbors);
		for (int j=0;j<num_neighbors;j++){
			scanf("%d %d", &neighbors[next_node][j], &edges[next_node][j]);
		}
		isUsed[next_node]=-false;
		distance[next_node]=-1;
	}
	isUsed[0] = true;
	distance[0] = 0;
	count=0;
	for(int i=0;i<neighbors[0].size();i++){
		distance[neighbors[0][i]] = edges[0][i];
	}
	int neighbor;
	while(count<n-1){
		min_distance = 100000;
		for(int i=0;i<n;i++){
			if(!isUsed[i] && distance[i] != -1 && distance[i]<min_distance){
				next_node = i;
				min_distance = distance[i];
			}
		}
		isUsed[next_node] = true;
		for(int i=0;i<neighbors[next_node].size();i++){
			neighbor = neighbors[next_node][i];
			if(distance[neighbor] > distance[next_node]+edges[next_node][i] || distance[neighbor] <0){
				distance[neighbor] = distance[next_node] + edges[next_node][i];
			}
		}
		count ++;
	}
	for(int i=0;i<n;i++){
		printf("%d %d\n", i, distance[i]);
	}
	return 0;
}

Measured memory_bytes: 6268
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
int cl(int a, int b) {
	return (a - (a%b)) / b;//b=0だと積む
}
int up(int a, int b) {
	return cl(a + b - 1, b);//b=0だと積む
}
int ord(int a, int p) {
	if (a%p == 0) {
		return ord(a / p, p) + 1;
	}
	else {
		return 0;
	}
}
long long ruin(int a, int n, long long  p) {
	if (n == 0) {
		return (1%p);
	}
	else {
	long long x = ruin(a, (n - (n % 2)) / 2, p);
		if (n % 2 == 0) {
			return (x*x) % p;
		}
		else {
			return (((x*x) % p)*a) % p;
			
		}
	
	}
	
}
long long com(int n, int r, int p) {
	if (r == 0) {
		return (1%p);
	}
	else {
		long long x = com(n, r - 1, p);
		return (x*(n - r) / r) % p;
	}
}
long long sum(long long n, long long p) {
	if (n == 0) {
		return 0;
	}
	else {
		long long x = (n%p) + sum((n - (n%p)) / p, p);
		return x;
	}
}
int main() 
{
	int n, a, b,c;
	cin >> n >> a >> b>>c;
	vector<int> ca(n);
	for (int i = 0; i < n; i++) {
		cin >> ca[i];
	}
	sort(ca.begin(), ca.end());
	reverse(ca.begin(), ca.end());
	int pr = a;
	int cal = c;
	int to = 1;
	for (int i = 0; i < n and to == 1; i++) {
		if (ca[i]*pr >= cal*b) {
			pr = pr + b;
			cal = cal + ca[i];
		}
		else {
			to = 0;
		}
	}
	cout << cal/pr <<endl;
}



Measured memory_bytes: 3164
n, x = map(int, input().split())
xlist = [int(n) for n in input().split()]
dis_list = [abs(x - y) for y in xlist]
dis_list = sorted(dis_list)

def gojo(num1, num2):

	if num2 == 0:
		return num1
	else:
		return gojo(num2, num1 % num2)
if n == 1:
	print(dis_list[0])
else:
	gcd = gojo(dis_list[1], dis_list[0])
	for i in range(1, n):
		gcd = gojo(dis_list[i], gcd)
	print(gcd)

Measured memory_bytes: 14252
#include <iostream>
#include <vector>
#include <algorithm>

int main()
{
    unsigned int n ;
    std::cin >> n ;

    std::vector<unsigned long> as(n), bs(n) ;
    for(unsigned int i = 0 ; i < n ; i ++) {
        std::cin >> as[i] >> bs[i] ;
    }

    std::sort(as.begin(), as.end()) ;
    std::sort(bs.begin(), bs.end()) ;

    if(n % 2 != 0) {
        //odd (1 step)
        auto am = as[(n + 1) / 2 - 1] ;
        auto bm = bs[(n + 1) / 2 - 1] ;
        std::cout << bm - am + 1 << std::endl ;
    }
    else {
        //even (1 or 0.5 step)
        auto am = (as[n / 2 - 1] + as[n / 2]) ;
        auto bm = (bs[n / 2 - 1] + bs[n / 2]) ;
        std::cout << bm - am + 1 << std::endl ;
    }

    return 0 ;
}

Measured memory_bytes: 6360
fun main(args: Array<String>) {
    val (n, m, x) = readLine()!!.split(" ").map(String::toInt)
    val a = readLine()!!.split(" ").map(String::toInt)
    val left = a.filter { it < x }.size
    val right = a.filter { it > x }.size
    println(Math.min(right, left))
}

Measured memory_bytes: 37620
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N,M;
	int a[1001],b[1001],c[1001][15];
	int keybit[1001];
	ll dp[5000];
	scan(N>>M);
	fill(dp,dp+4900,INFl);
	rep(i,M){
		scan(a[i]>>b[i]);
		int bit=0;
		rep(j,b[i]){
			scan(c[i][j]);
			bit+=(1<<(c[i][j]-1));
		}
		keybit[i]=bit;
	}
	int twoNth=(1<<N);
	dp[0]=0;
	rep(bit,twoNth){
		rep(i,M){
			dp[(bit|keybit[i])]=min(dp[(bit|keybit[i])],dp[bit]+a[i]);
		}
	}
	if(dp[twoNth-1]==INFl) prin(-1);
	else prin(dp[twoNth-1]);
	return 0;
}


Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main () {
  int A, B;
  cin >> A >> B;

  int ans = B * 10;
  for (int i = 0; i <= 9; i++) {
    if ((int) ((double) (ans + i) * 0.08) == A) {
      cout << ans + i << endl;
      return 0;
    }
  }

  cout << -1 << endl;
}


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

bool isByTurn(char leg1, char leg2){
  if(leg1 != leg2) return true;
  else return false;
}

bool isOnFloor(char right_leg, char left_leg){
  if(right_leg == 'd' && left_leg == 'd') return true;
  else return false;
}

bool isOnStep(char right_leg, char left_leg){
  if(right_leg == 'u' && left_leg == 'u') return true;
  else return false;
}

int main(void){
  int n;
  while(cin >> n, n){
    int ans = 0;
    vector<string> action;
    char right_leg = 'd';
    char left_leg  = 'd';
    for(int i=0; i < n; i++){
      string tmp; cin >> tmp;
      action.push_back(tmp);
    }
    if(n == 1){
      cout << 0 << endl;
      continue;
    }

    for(int i=0; i < n-1; i++){
      if(isOnFloor(right_leg, left_leg) && isByTurn(action[i][0], action[i+1][0])){

	i++;
	ans++;
	right_leg = 'u';
	left_leg = 'u';

      }else if(isOnStep(right_leg, left_leg) && isByTurn(action[i][0], action[i+1][0])){
	i++;
	ans++;
	right_leg = 'd';
	left_leg = 'd';      

      }else{
	if(action[i][0] == 'l'){
	  left_leg = action[i][1];
	}else{
	  right_leg = action[i][1];
	}
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1216
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#define ll long long
using namespace std;
int main(){
	ll n,a,b;
	scanf("%lld%lld%lld",&n,&b,&a);
	n-=b;
	if(n<=0){
		printf("1");
		return 0;
 	}
	if(a>=b){
		printf("-1");
		return 0;
	}
	ll bb=(b-a);ll nn=n/bb;
	if(bb*nn<n)
		printf("%lld",(nn+1)*2+1);
	else printf("%lld",nn*2+1);
	return 0;
}


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

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintStream out = new PrintStream(System.out);

        long a, b, x, num;

        a = sc.nextLong();
        b = sc.nextLong();
        x = sc.nextLong();

        num = b/x - a/x;

        if (a%x == 0) {
            num++;
        }
        
        out.println(num);
        sc.close();
    }
}

Measured memory_bytes: 23764
#include <iostream>
#include <vector>

using namespace std;

int main(int argc, char* argv[]) {
  int N;
  cin >> N;

  vector<long long> a(N);
  for (int i = 0; i < N; ++i)
    cin >> a[i];

  if (N <= 2) {
    cout << 1 << endl;
    return 0;
  }

  // start until change
  int i;
  long long s = a[0];
  bool increasing;
  for (i = 1; i < N; ++i) {
    if (a[i - 1] == a[i])
      continue;
    if (a[i - 1] < a[i])
      increasing = true;
    else
      increasing = false;
    break;
  }

  int ret = 1;
  --i;
  for (; i < N - 1; ++i) {
    bool change = false;
    if (increasing && a[i] > a[i + 1]) {
      ++ret;
      increasing = false;
      change = true;
    } else if (!increasing && a[i] < a[i + 1]) {
      ++ret;
      increasing = true;
      change = true;
    }

    if (change) {
      for (int j = i + 1; j < N - 1; ++j) {
        if (a[j] == a[j + 1])
          continue;
        if (a[j] < a[j + 1])
          increasing = true;
        else
          increasing = false;
        break;
      }
    }
  }

  cout << ret << endl;

  return 0;
}

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

int abc(int x){
if (x > 0){
return x;
}
  return -1 * x;
}
int main () {
int n, m;
  cin >> n >> m;
  int ans = 0;
  if (n >= 0 && m>= 0) {
  if (n > m) {
    if (m == 0) {
    cout << n - m + 1 << endl;
    }
    else {
  cout << n - m + 2 << endl;
    }
  }
    else {
    cout << m - n << endl;
    }
  }
  if (n >= 0 && m < 0) {
  cout << 1 + abc(n - abc(m)) << endl;
  }
  if (n < 0 && m >= 0) {
    if (m == 0) {
    cout << abc(m - abc(n)) << endl;
    }
    else {
  cout << 1 + abc(m - abc(n))<<endl;
  }}
  if (n < 0 && m < 0) {
  if (n < m ){
  cout << m - n << endl;
  }
    else {

    cout << n - m + 2 << endl;
    }
  }
}


Measured memory_bytes: 256
def divisor(n):
    res = []
    i = 1
    while i*i <= n:
        if n%i == 0:
            res.append(i)
            if i*i != n:
                res.append(n//i)
        i += 1
    res.sort()
    return res

N, K = map(int, input().split())
A = list(map(int, input().split()))
S = sum(A)
ans = 1
for d in divisor(S):
    rs = [a%d for a in A]
    rs.sort()
    Sum = [0]*(N+1)
    Sum2 = [0]*(N+1)
    for i in range(1,N+1):
        Sum[i] = Sum[i-1]+rs[i-1]
        Sum2[i] = Sum2[i-1]+(d-rs[i-1])
    for i in range(N+1):
        if Sum[i] == Sum2[N]-Sum2[i]:
            if Sum[i] <= K:
                ans = d
print(ans)


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

int main() {
    int a,b,c,x;
    cin >> a >> b >> c >> x;
    int ans = 0;
    int as = 0;
    while(as*500 <= x && as <= a) {
        int rem = x-as*500;
        int bs = 0;
        while(bs*100 <= rem && bs <= b) {
            int rem2 = rem-bs*100;
            if(rem2/50 <= c) ans++;
            bs++;
        }
        as++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;
 
int main() {
 
    long long n, m;
    cin >> n >> m;
    long long a = n % 2019;
    long long b = m % 2019;
    long long c = n / 2019;
    long long d = m / 2019;
    long long res = INT64_MAX;
    int MIN = min(a, b);
    int MAX = max(a, b);
    if (c != d) {
        cout << 0;
    } else {
        for (int i = MIN; i < MAX; ++i) {
            for (int j = MIN + 1; j <= MAX; ++j) {
                res = res > (i * j) % 2019 ? (i * j) % 2019 : res;
            }
        }
        cout << res;
    }
    return 0;
 
}

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

using namespace std;

void solve();

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

void solve() {
    int n;
    cin >> n;
    int c[n-1],s[n-1],f[n-1];
    for(int i = 0; i < n-1; i++) {
        cin >> c[i] >> s[i] >> f[i];
    }
    for(int i = 0; i < n; i++) {
        int now = 0;
        for(int j = i; j < n-1; j++) {
            if(now <= s[j]) {
                now = c[j] + s[j];
            } else {
                if(now % f[j] == 0) {
                    now = c[j] + now;
                } else {
                    now = c[j] + f[j] - (now % f[j]) + now;
                }
                
            }
            //cout << now << endl;
        }
        cout << now << endl;
    }
}

Measured memory_bytes: 384
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip> 
#include <complex> 
#include <string>
#include <vector> 
#include <list>
#include <deque> 
#include <stack> 
#include <queue> 
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm> 
#include <numeric> 
#include <typeinfo> 
#include <cstdio>
#include <cstdlib> 
#include <cstring>
#include <cmath>
#include <climits> 
#include <ctime>
using namespace std;

int n;
long long int lo;
long long int res=0;
vector<long long int> s;

int main(void){
	while(1){
		res=0;
		s.clear();
		scanf("%d",&n);
		if(n==0)break;
		for(int i=0;i<n;i++){
			int b;
			scanf("%lld",&b);
			res+=b;
		}
		lo=res;
		res*=n;
		for(int i=0;i<n-1;i++){
			int b;
			scanf("%lld",&b);
			s.push_back(b);
		}
		sort(s.begin(),s.end());
		reverse(s.begin(),s.end());
		int ki=0;
		while(ki<n-1){
			lo+=s[ki];
			if(lo*(n-ki-1)>res)res=lo*(n-ki-1);
			ki++;
		}
		printf("%lld\n",res);
	}
    return 0;
}

Measured memory_bytes: 1708
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _USE_MATH_DEFINES
#include <math.h>
#define rep(i,n) for(int i = 0;i < n;i++)
#define NIL = -1;
#define all(x) x.begin(),x.end()
const ll INF = 1e9;
const ll mod = 1e9 + 7;

int digit(ll x) {
    if (x / 10 == 0) return 1;
    return digit(x / 10) + 1;
}

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

ll lcm(ll a,ll b){
    return ((a * b == 0)) ? 0 : (a / gcd(a,b) * b);
}

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


/////////////////////////////////////////////////////////////////////////////////////////

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

    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> m(n + 1);
    ll sum = 0;
    for (int i = 0;i < n;i++){
        cin >> a[i];

        sum += m[a[i]]++; // sumにm[a[i]]を加えてから、m[a[i]] + 1
    }

    for (int i = 0;i < n;i++){
        cout << sum - m[a[i]] + 1 << endl;
    }

    return 0;
}


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

int main()
{
    int n;
    cin >> n;
    map<int, int> mp;
    rep(i, n) {
        int a;
        cin >> a;
        mp[a]++;
    }
    int ans = 0;
    for(auto x : mp) {
        if(x.second % 2 == 1) ans++;
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
  long long n, p;
  cin >> n >> p;
  for (long long i = pow(p, 1 / (long double)n); i >= 1; i--) {
    if (p % (long long)pow(i, n) == 0) {
      cout << i << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256