akhauriyash/Code-Regression huggingface dataset:
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws FileNotFoundException {
		new Main().run();
	}

	public void run() throws FileNotFoundException {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long l = sc.nextLong();
		long[] a = new long[n];
		for (int i = 0; i < n; ++i) {
			a[i] = sc.nextLong();
		}
		int j = -1;
		for (int i = 0; i + 1 < n; ++i) {
			if (a[i] + a[i + 1] >= l) {
				j = i;
			}
		}
		if (j == -1) {
			System.out.println("Impossible");
		} else {
			System.out.println("Possible");
			for (int i = 0; i < j; ++i) {
				System.out.println(i + 1);
			}
			for (int i = n - 1; i >= j + 2; --i) {
				System.out.println(i);
			}
			System.out.println(j + 1);
		}
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}


Measured memory_bytes: 70380
if __name__ == '__main__':
    S = str(input())
    k = len(S)

    S_list = []

    win_cnt = 0
    for i in range(len(S)):
        if S[i] == 'o':
            win_cnt += 1

    if 15 - k + win_cnt >= 8:
        print("YES")
    else:
        print("NO")

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    string s;
    cin >> s;
    int n = s.size();
    bool ans = true;
    {
        string r = s;
        reverse(r.begin(), r.end());
        if (r != s) ans = false;
    }

    {
        string t = s.substr(0, (n-1)/2);
        string r = t;
        reverse(r.begin(), r.end());
        if (r != t) ans = false;
    }

    {
        string t = s.substr((n+3)/2-1, n);
        string r = t;
        reverse(r.begin(), r.end());
        if (r != t) ans = false;
    }

    cout << (ans? "Yes" : "No") << endl;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
int n,m;
long long ans;

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    scanf("%d %d",&n,&m);
    if(m%n==0){
        printf("%d",m/n);
        return 0;
    }
    int st=m;
    for(long long i=1;i*i<=m;i++){
        if(m%i) continue;
        if(m%i==0){
            if(m/i>=n) ans=max(ans,i);
            if(i>=n) ans=max(ans,m/i);
        }
    }
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 256
while True:
  n, m = map(int, input().split())
  if n == 0:
    break
  gs = [list(map(float, input().split())) for _ in range(n)]
  dp = [[0] * n for _ in range(m + 1)]
  for i in range(n):
    dp[1][i] = 1.0
  for i in range(2, m + 1):
    for j in range(n):
      dp[i][j] = max([dp[i - 1][k] * gs[k][j] for k in range(n)])
  print(format(max(dp[m]), ".2f"))


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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define SORTG(v) sort(v.begin(),v.end(),greater<>())
#define SORT(v) sort(v.begin(),v.end())
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/3

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<string> Vs;

template<class T> void chmax(T& a, T b) {if(a<b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a>b){a=b;}}
void YesNo(int a){cout<<((a)?"Yes":"No")<<endl;}
void YESNO(int a){cout<<((a)?"YES":"NO")<<endl;}
void AorB(int a,string b,string c){cout<<((a)?b:c)<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
void start(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);}

signed main(){start();
    int n,ma,mb,ans=INF;
    cin>>n>>ma>>mb;
    Vi a(n),b(n),c(n);
    REP(i,0,n) cin>>a[i]>>b[i]>>c[i];
    
    const int nmax=40,amax=400,bmax=400;
    vector<VVi> dp(nmax+1,VVi(amax+1,Vi(bmax+1,INF)));
    dp[0][0][0]=0;
    REP(i,0,n){
        REP(j,0,amax){
            REP(k,0,bmax){
                if(dp[i][j][k]==INF) continue;
                chmin(dp[i+1][j][k],dp[i][j][k]);
                if(j+a[i]<=amax && k+b[i]<=bmax) chmin(dp[i+1][j+a[i]][k+b[i]],dp[i][j][k]+c[i]);
            }
        }
    }
    for(int i=1; i*ma<=amax && i*mb<=bmax; i++){
        chmin(ans,dp[n][i*ma][i*mb]);
    }
    if(ans==INF) ans=-1;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 53504
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int n = len(s);
    int ans = INF;
    rep(i,n){
        if(s[i] != s[i+1]){
            ans = min(ans,max(i+1,n-1-i));
        }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 512
from collections import Counter
from itertools import combinations
S = [input()for _ in range(int(input()))]
C = Counter(s[0] for s in S)
march = [s for s in "MARCH" if s in C]
ans = 0
for p in combinations(march, 3):
    ans += C[p[0]]*C[p[1]]*C[p[2]]
print(ans)

Measured memory_bytes: 10104
#include <iostream>
#include <string.h>

using namespace std;
int main(void){
    // Your code here!
    int N;
    string S;
    
    cin >> N;
    cin >> S;
    int ans = 0;
    for(int i = 0;i < N - 2;i++){
        if(S[i] == 'A' && S[i + 1] == 'B' && S[i + 2] == 'C'){
            ans++;
        }
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  int n, k;
  pair<int,int> sushi[SIZE];

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

  for(int i=0;i<n;i++){
    int t, d;
    scanf("%d%d", &t, &d);
    sushi[i] = {d, t};
  }

  sort(sushi, sushi + n, greater<pair<int,int> >());


  ll sum = 0;
  ll kind = 0;
  bool used[SIZE] = {};
  priority_queue<int> use, unuse;


  for(int i=0;i<k;i++){
    int t = sushi[i].second;
    int d = sushi[i].first;

    if (used[t]) use.push(-d);
    sum += d;
    kind += !used[t];
    used[t] = true;
  }

  for(int i=k;i<n;i++){
    int t = sushi[i].second;
    int d = sushi[i].first;

    if(!used[t]) {
      unuse.push(d);
      used[t] = true;
    }
  }

  ll ans = sum + kind * kind;

  while(unuse.size() && use.size()){
    sum += use.top() + unuse.top();
    use.pop(); unuse.pop();

    kind++;
    ans = max(ans, sum + kind * kind);
  }

  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 2432
///-----Bismillahir Rahmanir Rahim-----///

#include<bits/stdc++.h>
using namespace std;

///---FAST I/O---///
#define Boost() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

///---DATA TYPE---///
typedef long long ll;
typedef long long int lli;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<int>::iterator vit;
typedef set<int>::iterator sit;

///---LOOP---///
#define rep0(i,n) for(i=0;i<n;i++)
#define rep1(i,n) for(i=1;i<=n;i++)

///---I/O---///
#define sf scanf
#define pf printf

///---OTHERS---///
#define pb push_back
#define all(c)		c.begin(),c.end()
#define MK make_pair
#define F first
#define S second
#define endl '\n'


///---INITIALIZATION---//
#define mem(a,b) memset(a, b, sizeof(a) )

///---CALCULATE---///
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) ((a) * (a))

///---BIT OPERATION---///
inline bool checkBit(ll n, int i)
{
    return n&(1LL<<i);
}
inline ll setBit(ll n, int i)
{
    return n|(1LL<<i);;
}
inline ll resetBit(ll n, int i)
{
    return n&(~(1LL<<i));
}

///------String/Char Related Functions-----///
string makeintString(int x)
{
    stringstream ss;
    ss << x;
    string str = ss.str();
    ///cout<<str<<endl;
    return str;
}
string makellString(ll x)
{
    stringstream ss;
    ss << x;
    string str = ss.str();
    ///cout<<str<<endl;
    return str;
}
char cpp(char c)
{
    return static_cast<char>(c + 1);
}

///------------Sorting STL----------///
struct func
{
    //this is a sample overloading function for sorting stl
    bool operator()(pii const &a, pii const &b)
    {
        if(a.F==b.F)
            return (a.S<b.S);
        return (a.F<b.F);
    }
};

///---CONSTANT---///
const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000007

int main()
{
    Boost();

    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        ll n,m,k,x,ans=0;
        cin>>n>>m>>k;
        vector<ll>a;
        a.pb(0LL);
        for(ll i=1; i<=n; i++)
        {
            cin>>x;
            a.pb(x);
            a[i]+=a[i-1];
        }
        vector<ll>b;
        b.pb(0LL);
        for(ll i=1; i<=m; i++)
        {
            cin>>x;
            b.pb(x);
            b[i]+=b[i-1];
        }

//        for(ll i=0; i<=m; i++)
//        {
//            cout<<b[i]<<" ";
//        }
//        cout<<endl;

        for(ll i=0; i<=n; i++)
        {
            if(a[i]>k) break;
            ll baki=k-a[i];
            ll lb=upper_bound(b.begin(),b.end(),baki)-b.begin();
            lb--;
            //cout<<" baki: "<<baki<<"lb: "<<lb<<endl;
            ans=max(ans,i+lb);
            //cout<<ans<<endl;
        }
        cout<<ans<<endl;

    }
    return 0;
}


Measured memory_bytes: 7884
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))

tmp = 10 ** 9 + 7
ind = -1

for i, j in zip(H, list(range(1, N + 1))):
    c_tmp = abs(A - T + i * 0.006)
    if c_tmp < tmp:
        tmp = c_tmp
        ind = j
print(ind)


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main{
  public static void main(String[] args){

    Scanner s1 = new Scanner(System.in);
    String line = s1.nextLine();
    String[] eachNumStr = line.split(" ",0);

    int[] eachNum = new int[3];

    for(int i=0; i<eachNumStr.length; i++){
      eachNum[i] = Integer.parseInt(eachNumStr[i]);
    }

    if(eachNum[0] <= eachNum[2] && eachNum[2] <= eachNum[1]){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}


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


ll cc(ll n,ll a){
  ll tmp=1;
  while(a--){
    tmp=tmp*n%mod;
    n--;
  }
  return tmp;
}

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,a,b;
  cin>>n>>a>>b;
  ll na=cc(n,a);
  ll aa=cc(a,a);
  ll nb=cc(n,b);
  ll bb=cc(b,b);
  ll x=powmod(2,n,mod)-1;
  ll a1=powmod(aa,mod-2,mod)*na%mod;
  ll b1=powmod(bb,mod-2,mod)*nb%mod;
  ll sum=(a1+b1)%mod;
  if(x<sum)x+=mod;
  cout<<(x-sum)%mod<<endl;
  return 0;
}


Measured memory_bytes: 256
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n,a,b = readInts()
if a > b:
    print(0)
else:
    if n == 1:
        if a != b:
            print(0)
        else:
            print(1)
    elif a == b:
        print(1)
    else:
        print((b * (n-1) + a) - ((a*(n-1)) + b) + 1)


Measured memory_bytes: 10360
// 200219.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>

using namespace std;

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

    if (A == B && A != C) {
        cout << "Yes" << endl;
    }
    else if (A == C && A != B) {
        cout << "Yes" << endl;
    }
    else if (B == C && A != B) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
using namespace std;
// 型シノニム
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
// 定数
constexpr ll INF   = 1e16;
constexpr ll INM   = 114514;
constexpr ll MOD   = 1e9 + 7;
constexpr ld EPS   = 1e-12;
constexpr ll dx[4] = {1, 0, -1, 0};
constexpr ll dy[4] = {0, 1, 0, -1};
// 便利関数
void IOS() { ios::sync_with_stdio(false), cin.tie(0); }
template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, ll t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll mod) {
	if (a > 0) return a % mod;
	if (a % mod == 0) return 0;
	ll x = -a / mod + 1;
	a += x * mod;
	return a % mod;
}
ll powm(ll a, ll b, ll m) {
	if (b == 0) {
		return 1;
	} else if (b % 2 == 0) {
		ll d = powm(a, b / 2, m);
		return (d * d) % m;
	} else {
		return (powm(a, b - 1, m) * a) % m;
	}
}

// 本体

int main() {
	IOS();
	ll a, b;
	cin >> a >> b;
	dump(a * b);
}

Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
#include <vector>
#include <fstream>
#include <string>
#include <sstream>
#include <math.h>
#include <set>
using namespace std;
#define rep(i,n) for(int i = 0; i < n ; i++)
#define pb push_back
static const int INF = (1 << 21);

int main (void) {
  string a,b;
  cin >> a >> b;

  int LD[a.size()+1][b.size()+1];
  rep(i,a.size()+1){
    LD[i][0] = i;
  }
  rep(j,b.size()+1){
    LD[0][j] = j;
  }

  for(int i = 1; i < a.size()+1; i ++){
    for(int j = 1; j < b.size()+1; j ++){
      if(a[i-1] == b[j-1]){
        LD[i][j] = LD[i-1][j-1];
      }else{
        LD[i][j] = min(LD[i-1][j]+1,min(LD[i][j-1]+1,LD[i-1][j-1]+1));
      }

    }
  }
/*
  rep(i,a.size()+1){
    rep(j,b.size()+1){
      cout << LD[i][j] << " " ;
    }
    cout << endl;
  }*/

  cout << LD[a.size()][b.size()] << endl;
  return 0;
}

Measured memory_bytes: 5100
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
 
int main () {
  int n, t, a;
  cin >> n >> t >> a;
  vector<double> hc;
  for ( int i = 0; i < n; i++ ) {
     int h;
     cin >> h;
     double tmp = t - h * 0.006; //cout<<tmp<<endl;
     hc.push_back(fabs(a - tmp) );
  }
  vector<double>::iterator minIt = min_element(hc.begin(), hc.end());
  size_t minIndex = distance(hc.begin(), minIt);
  cout<< minIndex + 1;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int H=0,W=0,i=0,j=0,t=0,u=0;
    for(;scanf("%d %d",&H,&W),H;puts("")){
        for(i=0,t=H-1;i<H;i++,t--){
            for(j=0,u=W-1;j<W;j++,u--){
                printf("%s%s",i*j*t*u?".":"#",j==W-1?"\n":"");
            }
        }
    }
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

int imax = INT_MAX;
int imin = INT_MIN;
ll llmax = LLONG_MAX;
ll llmin = LLONG_MIN;


int main()
{
	int n;
	cin >> n;
	vector<int> a(10e5+2);
	for(int i = 0; i < n; i++) {
		int x;
		cin >> x;
		a[x]++;
	}
	int ma = -10e6;
	for (int i = 0; i < 10e5 -2; i++) {
		int t = a[i] + a[i+1] + a[i+2];
		if (t > ma) ma = t;
	}
	cout << ma << endl;
	return 0;
}

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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

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

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF = 1e9;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

vector<int> A;

bool next_up(int idx)
{
    int s = A[idx];
    for (int i=idx+1; i<A.size(); i++) {
        if (A[i] > s) return true;
    }
    return false;
}

int main()
{
    ios::sync_with_stdio(false);

    int N; cin >> N;
    if (N == 1) { 
        cout << 1 << endl;
        return 0;
    }

    A.resize(N);
    rep(i, N) cin >> A[i];

    vector<int> B;
    int old = A[0];
    B.push_back(old);
    REP(i, 1, N) {
        if (A[i] != old) {
            B.push_back(A[i]);
            old = A[i];
        }
    }

    A = B;
    N = A.size();

    int ans = 0;
    int up = (A[1] > A[0]);

    REP(i, 2, N) {
        if (up == -1) {
            up = (A[i] > A[i-1]);
            continue;
        }

        if (up == 1 && A[i] < A[i-1]) {
            // cerr << "up = true && i = " << i << endl;
            ans++;
            up = -1;
        } else if (up == 0 && A[i] > A[i-1]) {
            // cerr << "up = false && i = " << i << endl;
            ans++;
            up = -1;
        }
    }
    cout << ans + 1 << endl;
}

Measured memory_bytes: 1276
n = int(input())

a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

h = 0

h += sum(b)

for i in range(1,n):
    if a[i-1] + 1 == a[i]:
        h += c[a[i-1]-1]
    
print(h)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;
struct E{
	int x;
	long long int y;
	bool operator<(const E& e1)const{
		return y<e1.y;
	}
};

vector<long long int> ds[100001],ds2,ds3;
long long int dp1[100001],dp2[100001];
int flag[100001]={0};
priority_queue<E> pq1;
int main() {
	// your code goes here
	int n,k;
	cin>>n>>k;
	for(int i=0;i<n;i++){
		int x,y;
		cin>>x>>y;
		ds[x].push_back(y);
	}
	for(int i=1;i<=n;i++){
		E e1;
		e1.y=0;
		e1.x=i;
		for(int j=0;j<ds[i].size();j++){
			e1.y=ds[i][j];
			pq1.push(e1);
		}
	}
	while(pq1.empty()==false){
		E e1;
		e1=pq1.top();
		pq1.pop();
		if(flag[e1.x]==0){
			flag[e1.x]=1;
			ds3.push_back(e1.y);
		}else{
			ds2.push_back(e1.y);
		}
	}
	sort(ds2.begin(),ds2.end());
	sort(ds3.begin(),ds3.end());
	reverse(ds2.begin(),ds2.end());
	reverse(ds3.begin(),ds3.end());

	long long int sum=0;
	for(int i=0;i<ds2.size();i++){
		long long int t=ds2[i];
		ds2[i]=sum;
		sum+=t;
	}
	ds2.push_back(sum);
	sum=0;
	long long int add=1;
	for(int i=0;i<ds3.size();i++){
		long long int t=ds3[i];
		ds3[i]=sum;
		sum+=t+add;
		add+=2;
	}
	ds3.push_back(sum);
	//for(int i=0;i<ds3.size();i++){
	//	cout<<ds3[i]<<" ";
	//}
	//cout<<"\n";
	//for(int i=0;i<ds2.size();i++){
	//	cout<<ds2[i]<<" ";
	//}
	//cout<<"\n\n";
	long long int ans=0;
	for(int i=0;i<=k;i++){
		int p1=i;
		if(ds3.size()<=p1)continue;
		int p2=k-i;
		if((p2<0)||(ds2.size()<=p2))continue;
		long long int add1=ds3[p1];
		long long int add2=ds2[p2];
		//cout<<p1<<" "<<p2<<" "<<add1<<" "<<add2<<endl;
		ans=max(ans,ds3[p1]+ds2[p2]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 9456
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <climits>
#include <cmath>
#include <functional>
#include <map>
#include <queue>
#include <set>

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define size_t unsigned long long
#define ll long long
#define rep(i,a) for(int i=0;i<(a);i++)
#define repr(i,a) for(int i=(int)(a)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=a;i--)
#define ALL(a) a.begin(), a.end()
using namespace std;
int si() { int x; scanf("%d", &x); return x; }
long long sl() { long long x; scanf("%lld", &x); return x; }
string ss() { string x; cin >> x; return x; }
void pi(int x) { printf("%d ", x); }
void pl(long long x) { printf("%lld ", x); }
void pd(double x) { printf("%.15f ", x); }
void ps(const string &s) { printf("%s ", s.c_str()); }
void br() { putchar('\n'); }

const int MOD = 1e9 + 7;

struct mint {
    int n;
    mint(int n_ = 0) : n(n_) {}
};

mint operator+(mint a, mint b) { a.n += b.n; if (a.n >= MOD) a.n -= MOD; return a; }
mint operator-(mint a, mint b) { a.n -= b.n; if (a.n < 0) a.n += MOD; return a; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }

const int maxi = 1e6+10;
string s,t;
vector<int> v[maxi];
int n,m;
ll a[maxi];

int main () {
  s = "No";
  int i=0;
  cin >> s >> t;
  if(s[0] == t[0]) i++;
  if(s[1] == t[1]) i++;
  if(s[2] == t[2]) i++;
  cout << i << endl;
}


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

int main() {
  int N,j;
  int sum;
  int x,y,z;
  
  j= 0;
  sum = 0 ;
  cin >> N ;
  y = N ;
  
  for(int i = 8 ; i>=0; i--){
      
      j++;
      
      z=std::pow(10,i);
      
    x = y / z;
    
    sum += x ;
    
    y -= x * z;
    
    /*
    cout << z << endl;
    cout << "No." << j << endl;
    cout << "x=" << x <<endl;
    cout << "sum=" << sum <<endl;
    cout << "y=" << y << endl;
    */
    
  } 
  
  
  
  if(N%sum == 0){
   cout <<"Yes"; 
  }else{
   cout << "No" ; 
  }
  
}


Measured memory_bytes: 256
n, k = gets.split(' ').map(&:to_i)
d = gets.split(' ').map(&:to_i)
max = 0
(0..[n, k].min).each do |i|
  (0..i).each do |j|
    picked = d.slice(0, (i - j)) + d.slice((n - j), j)
    picked.sort!
    sum = 0
    picked.each_with_index do |v, l|
      sum += v if v >= 0 || l >= (k - i)
    end
    max = [sum, max].max
  end
end
puts max

Measured memory_bytes: 1916
import sys
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

asum = sum(a)
bsum = sum(b)

if bsum - asum < 0:
    print("No")
    sys.exit()
    
kai = 0
for i in range(n):
    if b[i] > a[i]:
        kai += (b[i]-a[i]+1) // 2
        
if kai > bsum - asum:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 40432
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();

        long ans = solve(a, b);
        System.out.println(ans);
    }

    static long solve(long a, long b) {

        Set<Long> al = divisor(a);
        Set<Long> bl = divisor(b);

        List<Long> gcdPair = new ArrayList<>();
        if (al.size() >= bl.size()) {
            for (Long bnum : bl) {
                if (al.contains(bnum)) {
                    gcdPair.add(bnum);
                }
            }
        } else {
            for (Long anum : al) {
                if (bl.contains(anum)) {
                    gcdPair.add(anum);
                }
            }
        }

        Collections.sort(gcdPair);

        long ans = 0;
        for (int i = 0; i < gcdPair.size(); i++) {
            long num = gcdPair.get(i);
            if (IsPrime(num)) {
                ans++;
            }
        }
        return ans + 1;
    }

    static Set<Long> divisor(long n) {
        Set<Long> ret = new HashSet<>();
        for (long i = 1; i * i <= n; i++) {
            if (n % i == 0) {
                ret.add(i);
                if (i != n / i)
                    ret.add(n / i);
            }
        }
        return ret;
    }

    static boolean IsPrime(long n) {
        if (n < 2)
            return false;
        else if (n == 2)
            return true;
        else if (n % 2 == 0)
            return false;
        double sqrtNum = Math.sqrt(n);
        for (long i = 3; i <= sqrtNum; i += 2) {
            if (n % i == 0) {
                return false;
            }
        }
        return true;
    }
}


Measured memory_bytes: 23888
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<queue>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long int ll;
ll dx[4] = {1,0,0,-1};
ll dy[4] = {0,1,-1,0};

#define ARRAY_MAX 1005

int main(){

    int n,r,p,c;

    while(cin >> n >> r,n){
        vector<int> a(n);
        REP(i,n){
            a[i] = n-i;
        }
        REP(j,r){
            //r回の試行
            vector<int> b;//上にもっていく要素
            cin >> p >> c;
            //cout << p << " " << c << endl;
            for(int k = p-1+c-1;k >= p-1;k--){
                b.push_back(a[k]);
                a.erase(find(a.begin(),a.end(),a[k]));
            }
            REP(k,b.size()){
                a.insert(a.begin(),b[k]);
            }
            b.shrink_to_fit();
        }
        /*REP(m,a.size()){
            cout << a[m] << " ";
        }
        cout << endl;*/
        cout << a[0] << endl;
        a.shrink_to_fit();
        //cout << "a" << endl;
    }

    return 0;
}


Measured memory_bytes: 3008
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<set>
#include<utility>
using namespace std;
typedef pair<int,int> pii;
typedef pair<int,pii> pipii;
typedef long long ll;
typedef pair<ll,ll> pll;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const int MAXN=100000;
const int MAXE=100000;
const int MAXV=10000;
const ll INF=2e18;
const ll MOD=1e9+7;
struct edge{
    int to;
    int cost;
};
int main(){
    int N,K;cin>>N>>K;
    vector<ll> x(N),y(N);
    vector<pll> p(N);
    for(int i=0;i<N;++i){
        cin>>x[i]>>y[i];
        p[i]=make_pair(x[i],y[i]);
    }
    sort(x.begin(),x.end());
    sort(y.begin(),y.end());
    ll ans=(x[N-1]-x[0]+1)*(y[N-1]-y[0]+1);
    for(int i1=0;i1<N;++i1){
        for(int i2=i1+1;i2<N;++i2){
            for(int j1=0;j1<N;++j1){
                for(int j2=j1+1;j2<N;++j2){
                    int num=0;
                    for(int i=0;i<N;++i){
                        if(x[i1]<=p[i].first&&p[i].first<=x[i2]
                        &&y[j1]<=p[i].second&&p[i].second<=y[j2]){
                            num++;
                        }
                    }
                    if(num>=K){
                        ans=min(ans,(x[i2]-x[i1])*(y[j2]-y[j1]));
                    }
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 3600
#include <bits/stdc++.h>
// clang-format off
using namespace std; using ll = int64_t; using ull = uint64_t; const ll INF = 9e18;
void print() { cout << endl; }
template<typename Head,typename... Tail> void print(Head head,Tail... tail){cout<<head;if(sizeof...(Tail)>0)cout<<" ";print(tail...);}
void print0() {}
template<typename Head,typename... Tail> void print0(Head head,Tail... tail){cout<<head;print0(tail...);}
// clang-format on

template <class T>
class bsegment_tree {
   public:
    ll size;
    vector<T> data;
    T default_value;

    bsegment_tree(ll n, T default_value_) {
        default_value = default_value_;

        ll siz = 1;
        while (siz < n) {
            siz = siz * 2;
        }
        data.resize(siz * 2, default_value);
        size = siz;
    }

    ~bsegment_tree() {}

    T compare(T& a, T& b) {
        //  ここをカスタム ex) min
        return min(a, b);
    }

    void update(ll k, T value) {
        // 葉の節点
        k += size - 1;
        data[k] = value;

        while (k > 0) {
            // 順に親に向かっていく
            k = (k - 1) / 2;
            data[k] = compare(data[k * 2 + 1], data[k * 2 + 2]);
        }
    }

    // [a, b) で compare 最強のもの
    T query(ll a, ll b, ll k, ll l, ll r) {
        if (r <= a || b <= l) {  // 共通要素がない
            return default_value;
        }
        if (a <= l && r <= b) {  // 完全に含んでいる
            return data[k];
        }

        // 2つの子の compare で勝つほう
        T vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
        T vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
        return compare(vl, vr);
    }

    T query(ll a, ll b) {
        return query(a, b, 0, 0, size);
    }
};

using segment_tree = bsegment_tree<ll>;

int main() {
    ll N, Q;
    cin >> N >> Q;

    auto min_hori = segment_tree(N + 1, N);
    auto min_vert = segment_tree(N + 1, N);

    ll darks = (N - 2) * (N - 2);
    for (ll i = 0; i < Q; i++) {
        ll qtype, x;
        cin >> qtype >> x;
        if (qtype == 1) {
            ll hori = min_hori.query(x, N + 1);
            if (min_vert.query(hori, hori + 1) > x) {
                min_vert.update(hori, x);
            }
            darks = darks - hori + 2;
        } else {
            ll vert = min_vert.query(x, N + 1);
            if (min_hori.query(vert, vert + 1) > x) {
                min_hori.update(vert, x);
            }
            darks = darks - vert + 2;
        }
    }
    print(darks);
}


Measured memory_bytes: 11456
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        String[] ary = new String[k];
        for (int i = 0; i < k; i++) {
            String a = sc.next();
            ary[i] = a;
        }
        first : for (int i = n; i < 100000; i++) {
            String nStr = String.valueOf(i);
            for (String str : ary) {
                if (nStr.contains(str)) {
                    continue first;
                }
            }
            System.out.println(i);
            break;
        }
    }
}


Measured memory_bytes: 27732
#include <stdio.h>
#include <algorithm>
using namespace std;

const long long mod = 998244353;
long long inv[500500],fib[500500];

pair<long long, long long> ffib(long long n)
{
	if (n == 0) return {1,0};
	if (n % 2){
		auto p = ffib(n-1);
		return {p.second,(p.first+p.second)%mod};
	}
	auto p = ffib(n/2);
	return {(p.first*p.first+p.second*p.second)%mod, (2*p.first+p.second)*p.second%mod};
}

int main()
{
	inv[1] = 1; fib[1] = 1;
	for (int i=2;i<500500;i++){
		inv[i] = (mod - mod / i) * inv[mod % i] % mod;
		fib[i] = (fib[i-1] + fib[i-2]) % mod;
	}

	int N; long long M;
	scanf ("%d %lld",&N,&M);

	long long base = ffib(M+(N-1)*2).second;
	long long mul = 1;

	M %= mod;
	for (int i=1;i<N;i++){
		base = (base + mod - mul * fib[2*(N-i)] % mod) % mod;
		mul = mul * M % mod;
		mul = mul * inv[i] % mod;
		if (!mul) break;
		M = (M + 1) % mod;
	}
	printf ("%lld\n",base);

	return 0;
}

Measured memory_bytes: 7936
#include <iostream>
using namespace std;
int main(void) {
	int a[200][200], b[200][200];
	long long int c[200][200] = {};
	int n, m, l;
	cin >> n >> m >> l;
	for (int d = 1; d <= n; d++) {
		for (int e = 1; e <= m; e++) {
			cin >> a[d][e];
		}
	}
	for (int d = 1; d <= m; d++) {
		for (int e = 1; e <= l; e++) {
			cin >> b[d][e];
		}
	}
	for (int d = 1; d <= n; d++) {
		for (int e = 1; e <= l; e++) {
			for (int f = 1; f <= m; f++) {
				c[d][e] += a[d][f] * b[f][e];
			}
		}
	}
	for (int d = 1; d <= n; d++) {
		for (int e = 1; e < l; e++) {
			cout << c[d][e] << " ";
		}
		cout << c[d][l] << endl;
	}
	return 0;
}

Measured memory_bytes: 1644
import java.util.*;

class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int sum = 0;
        for(int i = 0; i < M ; i++) {
            sum += sc.nextInt();
        }
        int res = N >= sum ? N - sum : -1;
        System.out.println(res);
    }
}


Measured memory_bytes: 46260
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;
ll a,b,c,d;
ll gcd (ll a, ll b){
    if (b==0) return a;
    return gcd(b, a%b);
}
ll lcm(ll a, ll b){
    return a/gcd(a,b)*b;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>a>>b>>c>>d;
    cout << b-a+1-(b/c-(a-1)/c+b/d-(a-1)/d-(b/lcm(c,d)-(a-1)/lcm(c,d)))<<"\n";
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys
import math


debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        # for line in sys.stdin:
        #     lines.append(line)
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    (n, r) = [int(e) for e in lines[0].split(" ")]

    return (n, r)


def solve(n, r):
    
    inner_r = r 
    if n < 10:
       inner_r = r + 100 * (10 - n)
    

    result = inner_r 
        
    return result
    


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()
	

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main(){
  unsigned long long x;
  unsigned long long count500 = 0;
  unsigned long long count5 = 0;

  cin >> x;
  
  while(x>=500){
    x = x - 500;
    count500++;
  }
  while(x>=5){
    x = x - 5;
    count5++;
  }
  cout << count500*1000+count5*5 << endl;

}

Measured memory_bytes: 256
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;
#define ll int64_t
const long MOD = 1e9 + 7;




int main()
{
  int n, t; //かっている数//最大100
  cin >> n ;

  long ans =0;

  for (int i = 1; i <=9 ; ++i){
    if (n <= i*100 +i*10 + i){
      ans = i*100 +i*10 + i;
      break;
    }
  }





  cout << ans;

  return 0;
}



























Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <numeric>
#include <climits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <utility>
#include <cctype>
#include <iterator>
////////////////////////////////////////////////
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define FOR(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define REPe(e, mp) for (auto& e : mp)
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
using ll = long long int;
using vecint = vector<int>;
using vecll = vector<ll>;
using vec2int = vector<vector<int>>;
using P = pair<int, int>;
////////////////////////////////////////////////
////////////////////////////////////////////////
int main() {
  ////////////////////////////////////////////////
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ////////////////////////////////////////////////
  int n;
  cin >> n;
  cout << n + n*n + n*n*n << endl;
}


Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
static const int giga = pow(10,9);

int main(void){
  int a,b,c;
  cin >> a >> b >> c;
  if(a <= c && c <= b){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

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

int main()
{
    double a,b;
    double A, B, ck = 0;
    cin>>a>>b;

    int i;
    for(i=1; i<=1000; i++)      ///MAX A = 1250 & B = 1000. So here 1000
    {
        A = int(double(i*.08));
        B = int(double(i*.1));
        //cout<<"i :"<<i<<" "<<A<<" "<<B<<endl;

        if(A==a && B==b)
        {
            ck=1;
            break;
        }
    }

    if(ck==1)
        cout<<i<<endl;
    else
        cout<<"-1"<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <set>
#include <array>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <vector>
#include <tuple>
#include <string>
#include <math.h>
#include <time.h>
#include <bitset>
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <limits>
#include <climits>
#include <numeric>
#include <functional>

#define lnd '\n'
// #define reverse(i, n) for(ll i = n-1; i >= 0; --i)
#define from(i, n) for (ll i = 0; i < n; ++i)
#define loop(i, n) for(ll i = 0; i < n; i++)
#define REPN(i, n) for (ll i = 1; i <= n; ++i)
#define ALL(s) (s).begin(), (s).end()
#define rALL(s) (s).rbegin(), (s).rend()
#define sz(s) (int)(s).size()
#define mk make_pair
#define pb push_back
#define sqr(s) ((s) * (s))

using namespace std;

typedef long long ll;
typedef long long int lli;
typedef long double ld;
typedef unsigned long long ull;
typedef unsigned int ui;

template <class T>
T GCD (T a, T b) {
  if(a == 0) return b;
  return GCD(b%a, a);
}

template <class T>
T LCM(T a, T b){
  return a*b/GCM(a,b);
}

template <class T>
T modpow(T x, T p){
    T res = 1;
    while(p > 0){
        if(p&1) res *= x;
        x *= x;
        p /= 2;
    }
    return res;
}

template <class T>
T modpow(T x, T p, ll mod){
    T res = 1;
    while(p > 0){
        if(p&1) res = (res*x)%mod;
        x = (x*x)%mod;
        p /= 2;
    }
    return res%mod;
}

template <class T>
void print(T a[], ll n){
    for (ll i = 0; i < n; i++) std::cout << a[i] << ' ';
    cout << endl;
}

template<class T>
void printc(T c){
    for(auto const& v: c) std::cout << v << ' ';
    cout << endl;
}

struct HASH{
  size_t operator()(const pair<long,long>&x)const{
    return hash<long long>()(((long long)x.first)^(((long long)x.second)<<32));
  }
};

bool pair_sort(const pair<int, int> &p1, const pair<int,int> &p2){
    if(p1.first != p2.first) return p1.first < p2.first;
    else return p1.second < p2.second;
}

const int INF = std::numeric_limits<int>::max();
const ll M_INF = std::numeric_limits<ll>::min();
const ll LL_INF = std::numeric_limits<ll>::max();

void solution();
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solution();
    return 0;
}

ll result[200005] = {0};
void fact(ll n) {
   if (n >= 0) {
      result[0] = 1;
      for (ll i = 1; i <= n; ++i) {
         result[i] = i * result[i - 1];
      }
   }
}

void dfs(ll n, ll m, ll i, vector<ll> &v){
  if(i == n){
  }else{
    for(int k = 1; k <= m; k++){
      v.push_back(k);
      dfs(n, m, i+1, v);
      v.pop_back();
    }
  
  }
}

void solution(){
  ll k;
  cin >> k;
  string s;
  cin >> s;

  ll n = s.size();
  if(n <= k){
    cout << s << endl;
  }else{
    cout << s.substr(0, k) + "..." << endl;
  }
}     



Measured memory_bytes: 3136
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>
 
using namespace std;
 
int main(void){
    long long a,b,x;
    cin>>x;
    for(a=-1000;a<=1000;a++){
        for(b=-1000;b<=1000;b++){
            if(a*a*a*a*a - b*b*b*b*b == x){
                cout<<a<<" "<<b<<endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))


int main(){
	string s;
	cin >> s;
	int ans = 0;
	int len = s.size()/2;
	FOR(i,0,len){
		int j = s.size() - 1 - i;
		if(s[i]!=s[j])ans++;
	}
	cout << ans << endl;
}

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

typedef long long  LL;
int n,ans1,ans2;
LL a[100010];
vector <LL> ans,V;
map <vector <LL> ,int> M;

LL mul(LL a,LL b,LL mo)
{
	return (a*b-(LL)((long double)a/mo*b+1e-3)*mo+mo)%mo;
}

LL ksm(LL a,LL b,LL mo)
{
	LL x=a;  a=1;
	while (b)
		{
			if (b&1)  a=mul(a,x,mo);
			x=mul(x,x,mo),b>>=1;
		}
	return a;
}

bool miller_robin(LL n)
{
	if (n==2)  return 1;
	if ((n==1)||(!(n&1)))  return 0;
	LL m=n-1,k=0;
	while (!(m&1))  m>>=1,k++;
	for (int i=1; i<=10; i++)
		{
			LL x=ksm(rand()%(n-1)+1,m,n),y;
			for (int j=1; j<=k; j++)
				{
					y=mul(x,x,n);
					if (y==1)  {if ((x!=1)&&(x!=n-1))  return 0;  else  break;}
					x=y;
				}
			if (y!=1)  return 0;
		}
	return 1;
}

LL gcd(LL a,LL b){return b?gcd(b,a%b):a;}
LL f(LL x,LL c,LL n){return (mul(x,x,n)+c)%n;}

void pollard_rho(LL n)
{
	while (!(n&1))  n>>=1,ans.push_back(2);
	if (n==1)  return;
	if (miller_robin(n))  {ans.push_back(n);  return;}
	LL x=rand()%(n-1)+1,y=x,c=rand()%(n-1)+1,g;
	for (LL i=1,j=1; ; i++)
		{
			x=f(x,c,n);
			g=gcd(abs(x-y),n);
			if (x==y)  x=rand()%(n-1)+1,y=x,c=rand()%(n-1)+1,i=0,j=1;
			if ((g>1)&&(g<n))  break;
			if (i==j)  y=x,j<<=1;
		}
	pollard_rho(g),pollard_rho(n/g);
}

void work()
{
	scanf("%d",&n);
	for (int i=1; i<=n; i++)
		{
			scanf("%lld",&a[i]),ans.clear(),V.clear();
			pollard_rho(a[i]),sort(ans.begin(),ans.end());
			for (int j=0,s; j<ans.size(); )
				{
					a[0]=ans[j];
					for (s=0; j<ans.size()&&ans[j]==a[0]; j++,s++);
					if (s%3)  V.push_back(a[0]),V.push_back(s%3);
				}
			if (V.size())  M[V]++;  else  ans1=1;
		}
	for (map <vector <LL> ,int> ::iterator it=M.begin(); it!=M.end(); it++)
		{
			V=(*it).first;
			for (int j=1; j<V.size(); j+=2)  V[j]=3-V[j];
			if (M.find(V)!=M.end())  ans2+=max(M[V],(*it).second);
			else  ans1+=(*it).second;
		}
	printf("%d",ans1+ans2/2);
}

int main()
{
	work();
	return 0;
}


Measured memory_bytes: 15488
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;
int main()
{
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  rep(i, N)
  {
    cin >> A[i];
  }
  ll ans = (N - 2) / (K - 1) + 1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3696
/* ＵＴＦ－８ */
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

int main()
{
	int N;
	std::deque<int> V;

	std::cin >> N;
	V.resize(N);
	for (auto& v : V) {
		std::cin >> v;
	}

	double result;
	std::sort(V.begin(), V.end());
	result = *V.begin();
	V.pop_front();
	for (auto v : V) {
		result = (result + v) / 2;
	}

	printf("%.20f\n", result);
}


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


struct team{
	  int  id, c, p;
	  vector<int> w;
	  team(int i, int correct, int pena, int num_pro){
			id = i; c = correct; p = pena; w = vector<int>(num_pro+1,0);
	  }
	  bool operator < (const team& tgt) const {
			if(c != tgt.c) return c < tgt.c;
			if(p != tgt.p) return p > tgt.p;
			return id > tgt.id;
	  }
};

int main(){
	  
	  while(1){
			int t,p,r; cin >> t >> p >> r;
			if(!t) break;

			vector<team> teams;
			teams.push_back( team(10000,-1,1000000,10) );
			for(int i=1; i<=t; i++)
				  teams.push_back( team(i,0,0,p) );
			
			for(int i=0; i<r; i++){
				  int tid,pid,time;
				  string m;
				  cin >> tid >> pid >> time >> m;

				  if(m == "CORRECT"){
						teams[tid].c ++;
						teams[tid].p += teams[tid].w[pid] * 1200 + time;
				  }
				  else{
						teams[tid].w[pid]++;
				  }
			}
			sort(teams.begin(),teams.end());
			reverse(teams.begin(),teams.end());
			for(int i=0; i<t; i++)
				  cout << teams[i].id << " " << teams[i].c << " " << teams[i].p << endl;
				  
	  }
	  
}

Measured memory_bytes: 1256