akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <string>
#include <map>
#include <stdio.h>
#include <set>
using namespace std;

void setIn(string s){freopen(s.c_str(), "r", stdin);}
void setOut(string s){freopen(s.c_str(), "w", stdout);}
void unsyncIO(){cin.tie(0) -> sync_with_stdio(0);}
void setIO(string s = ""){
	unsyncIO();
	if(s.size()){
		setIn(s + ".in");
		setOut(s + ".out");
	}
}


#define ll long long
const ll mod = 1e9 + 7;
const int MX = 200005;

ll st[MX * 4];
pair<ll, ll> lz[MX * 4];

void prop(int nd, int cl, int cr){
	if(lz[nd] != make_pair(-1ll, -1ll)){
		st[nd] = cl - lz[nd].first + lz[nd].second;
		if(cl != cr){
			lz[nd * 2] = lz[nd];
			lz[nd * 2 + 1] = lz[nd];
		}
		lz[nd] = make_pair(-1, -1);
	}
}

void upd(int nd, int cl, int cr, int l, int r, int val, int ps){
	prop(nd, cl, cr);
	if(cl > cr || l > r || cr < l || r < cl) return;
	if(l <= cl && cr <= r){
		lz[nd] = {ps, val};
		prop(nd, cl, cr);
		return;
	}

	int md = (cl + cr) / 2;
	upd(nd * 2, cl, md, l, r, val, ps);
	upd(nd * 2 + 1, md + 1, cr, l, r, val, ps);
	st[nd] = min(st[nd * 2], st[nd * 2 + 1]);
}

ll que(int nd, int cl, int cr, int l, int r){
	if(l == 0) return mod;
	prop(nd, cl, cr);	
	if(cl > cr || l > r || cr < l || r < cl) return mod;
	if(l <= cl && cr <= r) return st[nd];

	int md = (cl + cr) / 2;
	return min(que(nd * 2, cl, md, l, r), que(nd * 2 + 1, md + 1, cr, l, r));
}

int h, w;

int main(){
	setIO();

	for(int i = 0; i < MX * 4; i ++) lz[i] = {-1, -1};

	cin >> h >> w;
	for(int l, r, i = 1; i <= h; i ++){
		cin >> l >> r;

		int gt = que(1, 1, w, l - 1, l - 1);
		upd(1, 1, w, l, r, gt, l - 1);

		gt = que(1, 1, w, 1, w) + i;
		if(gt >= mod) gt = -1;
		cout << gt << endl;
	}
}

Measured memory_bytes: 20200
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      int h = sc.nextInt();
      int w = sc.nextInt();
      char [][] s = new char[h][w];
      for(int i=0;i<h;i++){
        String str = sc.next();
        for(int j=0;j<w;j++){
          s[i][j] = str.charAt(j);
        }
      }
      for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
          if(s[i][j]=='.'){
            int count=0;
            for(int k=i-1;k<i+2;k++){
              for(int l=j-1;l<j+2;l++){
                if(0<=k && k<h && 0<=l && l<w){
                  if(s[k][l]=='#'){
                    count++;
                  }
                }
              }
            }
            s[i][j]=(char)(count+48);
          }
        }
      }
     for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
          System.out.print(s[i][j]);
        }
       System.out.println();
      }
    }
}


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

using namespace std;

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

constexpr static int MOD = 1000000000 + 7;
constexpr static int inf = INT_MAX / 2;
constexpr static llong INF = 1LL << 31;
constexpr static int dx[] = {1, 0, -1, 0};
constexpr static int dy[] = {0, 1, 0, -1};

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

    int n;
    cin >> n;
    map<string, int> m;
    vector<pair<string, pair<int, int> > > r;
    int cnt = 0;
    rep(i, n) {
        string s;
        int p;
        cin >> s >> p;
        if (! m[s]) ++cnt;
        else ++m[s];
        r.push_back({s, {p, i + 1}});
    }
    sort(all(r));

    int p = 0;
    string cur = r[0].first;
    vector<vector<pair<int, int> > > tmp(cnt);
    tmp[p].push_back({r[0].second.first, r[0].second.second});
    for (int i = 1; i < n; ++i) {
        if (r[i].first == cur) {
            tmp[p].push_back({r[i].second.first, r[i].second.second});
        } else {
            ++p;
            tmp[p].push_back({r[i].second.first, r[i].second.second});
            cur = r[i].first;
        }
    }

    rep(i, cnt) {
        sort(allr(tmp[i]));
        rep(j, (int)tmp[i].size()) {
            cout << tmp[i][j].second << endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 256
def c_gcd_on_blackboard(N, A):
    # editorial通り
    from fractions import gcd

    left, right = [0] * (N + 1), [0] * (N + 1)
    for i in range(N):
        left[i + 1] = gcd(left[i], A[i])
    for i in range(N - 1, -1, -1):
        right[i] = gcd(right[i + 1], A[i])

    return max([gcd(left[i], right[i + 1]) for i in range(N)])

N = int(input())
A = [int(i) for i in input().split()]
print(c_gcd_on_blackboard(N, A))

Measured memory_bytes: 14056
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ll long long
#define ull unsigned long long
// #define ordered_set tree<pair<ll, ll>, null_type, less<pair<ll, ll>>, rb_tree_tag, tree_order_statistics_node_update> 
ll mod=1e9+7;
#define PI 3.1415926535897932385
#define inf 9e18
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
typedef pair<long long, long long> ii;
#define S second
#define F first
ll max(ll a,ll b){if(a>b){return a;}return b;}
ll min(ll a,ll b){if(a<b){return a;}return b;}
#define MAXN 200005
// Comment this out for interactice problem
// #define endl '\n'
// string to integer stoi() Remember: it takes string not character
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
// To compile--> g++ -std=c++0x -o output one.cpp
// To run--> ./output

int main() 
{ 
    fastio;
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    ll a[5];
    cin>>a[0]>>a[1]>>a[2]>>a[3]>>a[4];
    for (int i = 0; i < 5; ++i)
    {
        if(a[i]==0){
            cout<<i+1;
            return 0;
        }
    }


    return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<math.h>
#include<vector>
#include <algorithm>


using namespace std;

int main(){
  int a,b;
  vector<char> v;
  string s,result;
  cin >> s;
  for(int i=0;i<s.size();i++){
    v.push_back(s[i]);
  }
  for(int i=0;i<s.size();i++){
    if(count(v.begin(),v.end(),s[i])!=2){
      cout << "No";
      return 0;
    }
  }
  cout << "Yes";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a;
	cin >> a;
	for(int i = 1;i <= 9; ++i){
		if(a/i <= 9 && (a/i) * i == a){
			cout << "Yes\n";
			return 0;
		}
	}
	cout << "No\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e3 + 10;

int dp[N][1 << 12];
int p[N];
int sum[N];

int main() {
  //  freopen("in","r",stdin);
    ios::sync_with_stdio(false); cin.tie(0);
    int n,m;
    cin >> n >> m;
    for(int i = 1;i <= m;++i) {
        int cnt;
        cin >> p[i] >> cnt;
        for(int j = 0;j < cnt;++j) {
            int x;
            cin >> x;
            x--;
            sum[i] += (1 << x);
        }
    }
    memset(dp,0x3f,sizeof dp);
    for(int i = 0;i < m;++i) {
        dp[i][0] = 0;
        for(int j = 0;j < (1 << n);++j) {
            dp[i + 1][j] = min(dp[i + 1][j],dp[i][j]);
            if(dp[i][j] != 1061109567)
                dp[i + 1][j | sum[i + 1]] = min(dp[i + 1][j | sum[i + 1]],dp[i][j] + p[i + 1]);
        }
    }
    // for(int i = 0;i <= m;++i) {
    //     for(int j = 0;j < (1 << n);++j) {
    //         printf("dp[%d][%d] = %d\n",i,j,dp[i][j]);
    //     }
    //     cout << '\n';
    // }
    if(dp[m][(1 << n) - 1] == 1061109567) cout << -1 << '\n';
    else cout << dp[m][(1 << n) - 1] << '\n';
    return 0;
}

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

vector<int> a(5);

string solve(){
    sort(a.begin(), a.end());
    int pair = 0;
    rep(i,5)rep(j,i) if(a[i] == a[j]) pair++;
    bool straight = true;
    rep(i,4) if(a[i] + 1 != a[i+1]) straight = false;
    if(a[0]==1 &&
       a[1]==10 &&
       a[2]==11 &&
       a[3]==12 &&
       a[4]==13) return "straight";
    if(straight) return "straight";

    if(pair == 6) return "four card";
    else if(pair == 4) return "full house";
    else if(pair == 3) return "three card";
    else if(pair == 2) return "two pair";
    else if(pair == 1) return "one pair";
    else return "null";
}

int main(){
    while(scanf("%d,%d,%d,%d,%d",&a[0],&a[1],&a[2],&a[3],&a[4])!=EOF){
        cout << solve() << endl;
    }
}

Measured memory_bytes: 1220
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static void Main(string[] args)
    {
        var sc = new Scanner();
        int n = sc.NextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) a[i] = sc.NextInt();

        int ans = 0;
        for (int i = 1; i < n; i++)
        {
            if (a[i - 1] == a[i])
            {
                ans++;
                i++;
            }
        }
        Console.WriteLine(ans);
    }

    static long Gcd(long a, long b)
    {
        if (a < b) return Gcd(b, a);
        if (b == 0) return a;
        return Gcd(b, a % b);
    }
}

class Scanner
{
    int index = -1;
    string[] buf;

    public Scanner()
    {
    }

    public int NextInt()
    {
        CheckNext();
        return int.Parse(buf[index++]);
    }

    public long NextLong()
    {
        CheckNext();
        return long.Parse(buf[index++]);
    }

    public double NextDouble()
    {
        CheckNext();
        return double.Parse(buf[index++]);
    }

    public string NextString()
    {
        CheckNext();
        return buf[index++];
    }

    private void CheckNext()
    {
        if (index >= 0 && index < buf.Length) return;

        buf = Console.ReadLine().Split(' ');
        index = 0;
    }
}


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

#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef unsigned long long ull;

using namespace std;


ll bc(ll n, ll k, vector<ll>& fct, vector<ll>& rev, ll mod) {
    auto div = (rev[k] * rev[n - k]) % mod;
    return (fct[n] * div) % mod;

}

ll bp(ll a, ll d, ll mod) {
    if (d == 0) {
        return 1;
    }
    auto h = bp(a, d / 2, mod);
    auto res = (h * h) % mod;
    if (d % 2) {
        res = (res * a) % mod;
    }
    return res;
}

void one_case() {
   ll n, m, k;
   cin >> n >> m >> k;
   ll mod = 998244353;

   vector<ll> fct(n + 1), rev(n + 1), deg(n + 1);
   fct[0] = 1;
   for (int i = 1; i <= n; ++i) {
       fct[i] = (i * fct[i - 1]) % mod;
   }
   rev[0] = 1;
   for (int i = 1; i <= n; ++i) {
       rev[i] = bp(fct[i], mod - 2, mod);
   }
   deg[0] = 1;
   for (int i = 1; i <= n; ++i) {
       deg[i] = ((m - 1) * deg[i - 1]) % mod;
   }



   ll res = 0;
   for (int d = 0; d <= k; ++d) {
       ll mult = bc(n - 1, d, fct, rev, mod);
       res = (res + deg[n - 1 - d] * mult) % mod;
   }
   cout << (res * m) % mod;

}



int main() {
//    std::ios::sync_with_stdio(false);
//    std::cin.tie(nullptr);

    int t = 1;
//    cin >> t;
    while (t--) {
        one_case();
    }

    return 0;
}


Measured memory_bytes: 8016
#include <bits/stdc++.h>
#define int long long
#define inf 2e10+7
using namespace std;

int n,m,s=1,cnt;
int head[200005],dis[100005],visited[100005],ans[100005];

struct edge{
    int next;
    int to;
    int dis;
}e[500005];

struct node{
    int dis;
    int pos;
    bool operator < (const node x) const
    {
        return x.dis<dis;
    }
};

priority_queue<node> q;

void add_edge(int u,int v,int w){
    cnt++;
    e[cnt].to=v;
    e[cnt].dis=w;
    e[cnt].next=head[u];
    head[u]=cnt;
}

void dijkstra(){
    dis[s]=0;
    q.push((node){0,s});
    
    while(!q.empty()){
        node tmp=q.top();
        q.pop();
        
        int x=tmp.pos;
        if(visited[x])
            continue;
            
        visited[x]=1;
        
        for(int i=head[x];i;i=e[i].next){
            int y=e[i].to;
            if(dis[y]>dis[x]+e[i].dis){
                ans[y]=x;
                dis[y]=dis[x]+e[i].dis;
                if(!visited[y])
                    q.push((node){dis[y],y});
            }
        }
    }
}

signed main(){
    cin>>n>>m;
    for(int i=1;i<=m;i++){
        int u,v;
        cin>>u>>v;
        add_edge(u,v,1);
        add_edge(v,u,1);
    }
    
    for(int i=1;i<=n;i++)
        dis[i]=inf;
        
    dijkstra();
    
    for(int i=2;i<=n;i++)
        if(ans[i]==0)
            return cout<<"No\n",0;
            
    cout<<"Yes\n";
    
    for(int i=2;i<=n;i++)
        cout<<ans[i]<<"\n";
        
    return 0;
}

Measured memory_bytes: 17288
N = int(input())
X = [[int(a)-1 for a in input().split()] for _ in range(N)]
Y = [0] * N
Z = [-1] * N

L = [a for a in range(N)]
f = 1
d = 0
c = 0
while f:
    d += 1
    f = 0
    NL = []
    for l in L:
        a, aa = Y[l], Z[l]
        if a >= N - 1: continue
        ll = X[l][a]
        b, bb = Y[ll], Z[ll]
        if b >= N - 1: continue
        lll = X[ll][b]
        if lll == l and aa < d and bb < d:
            f = 1
            c += 1
            Y[l] += 1
            Z[l] = d
            if Y[l] < N - 1: NL.append(l)
            Y[ll] += 1
            Z[ll] = d
            if Y[ll] < N - 1: NL.append(ll)
    if c == N*(N-1)//2:
        print(d)
        break
    L = NL
else:
    print(-1)




Measured memory_bytes: 35572
'use strict'

const main = input => {
	const args = input.split('\n').map(arg => arg.split(' '))
	const x = args[0][0]

	if (x === '7') console.log('YES')
	else if (x === '5') console.log('YES')
	else if (x === '3') console.log('YES')
	else console.log('NO')
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 7372
#include<stdio.h>

int main(void)
{

int time;
int z,h,b;

scanf("%d",&time);

z = time/(60*60);
h = (time - (z*60*60))/60;
b = time - ((z*60*60)+(h*60));
printf("%d:%d:%d\n",z,h,b);

return 0;
}

Measured memory_bytes: 592
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#solve
def solve():
    a, b, k = LI()
    A = max(0, a - k)
    k = k - (a - A)
    B = max(0, b - k)
    print(A,B)
    return


#main
if __name__ == '__main__':
    solve()


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

int main(int argc, char **argv)
{
    int N;
    std::string S;

    std::cin >> N;
    std::cin >> S;

    int west_side = 0;
    int east_side = 0;
    for(int i = 1; i < N; i++){
        if(S.at(i) == 'E') east_side++;
    }
    int min = west_side + east_side;
    for(int i = 1; i < N; i++){
        if(S.at(i-1) == 'W') west_side++;
        if(S.at(i) == 'E') east_side--;
        min = std::min(min, west_side+east_side);
    }
    std::cout << min << std::endl;    
}


Measured memory_bytes: 900
def main():

    from bisect import bisect_left as bl, bisect_right as br, insort
    import sys,heapq,math
    from collections import defaultdict as dd, deque
    def data(): return sys.stdin.readline().strip()
    def mdata(): return list(map(int, data().split()))
    out = sys.stdout.write
    # sys.setrecursionlimit(100000)
    INF = int(1e9)
    mod = int(1e9)+7

    s=data()
    if s=='ABC':
        print('ARC')
    else:
        print("ABC")



if __name__ == '__main__':
    main()


Measured memory_bytes: 65232
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int inf=1e18;
int32_t main(){
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(0),cin.tie(0);
	int n,k,r,s,p,ans=0;
	cin >> n >> k;
	cin >> s >> p >> r;
	string st;
	cin >> st;
	for(int i=0;i<k;i++){
		if(st[i]=='r')ans+=r;
		if(st[i]=='s')ans+=s;
		if(st[i]=='p')ans+=p;
		// cout <<  ans << endl;
	}
	for(int i=k;i<st.size();i++){
		if(st[i-k]==st[i])st[i]='#';
		else{
			if(st[i]=='r')ans+=r;
			if(st[i]=='s')ans+=s;
			if(st[i]=='p')ans+=p;
		}
	}
	cout << ans;
}


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

using namespace std;
const int MAXN = 1e5 + 7;
const int INF = 1e9 + 7;

long long dp[100][MAXN];
int w[MAXN], v[MAXN];
int n, W;

long long solve(int on, int weight) {
  if(on == n || weight == 0) return 0;
  long long &ans = dp[on][weight];
  if(~ans) return ans;
  ans = solve(on + 1, weight);
  if(weight - w[on] >= 0) ans = max(ans, v[on] + solve(on + 1, weight - w[on]));
  return ans;
}

int main() {
  memset(dp, -1, sizeof(dp));
  cin >> n >> W;
  for (int i = 0; i < n; i++) {
    cin >> w[i] >> v[i];
  }
  cout << solve(0, W);
  return 0;
}

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

int main(){
    const int MAX_N = 1e5 + 20;
    int N, d[MAX_N];
    cin >> N;
    for (int i = 0; i < N; ++i){
        cin >> d[i];
    }

    sort(d, d+N);

    cout << (d[N/2]-d[N/2-1]) << endl;

}

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

int main() {
  string str;
  vector<string> v;
  
  getline(cin, str);
  int cnt = 0;
  for(int i=0; i<=str.size(); i++) {
    if( ( str[i] == ' '
	  || str[i] == '.' 
	  || str[i] == ','
	  || str[i] == '\0' ) && ( 3 <= cnt && cnt <= 6 ) ) v.push_back( str.substr( i-cnt, cnt ) ), cnt = 0;
    else if( str[i] == ' '
	     || str[i] == '.' 
	     || str[i] == ','
	     || str[i] == '\0' ) cnt = 0;
    else cnt ++;
  }

  for(int i=0; i<v.size(); i++) {
    if( i == v.size()-1 ) cout << v.back() << endl;
    else cout << v[i] << " ";
  }
  
  return 0;
}

Measured memory_bytes: 1176
#if 0
    感想
#endif
#include <iostream>
#include <vector>
#include <map>
using namespace std;

int H, W, hA[1010], wA[1010];
vector<int> heights, widths;

int solve()
{
    map<int, int> heightMap, widthMap;
    int count = 0;
    for (int key = H; key > 0; --key)
    {
        for (int i = 0; i < key; i++)
        {
            int length = heights[key] - heights[i];
            heightMap[length] = heightMap[length] + 1;
        }
    }
    for (int key = W; key > 0; --key)
    {
        for (int i = 0; i < key; i++)
        {
            int length = widths[key] - widths[i];
            widthMap[length] = widthMap[length] + 1;
        }
    }
    for (auto itr = heightMap.begin(); itr != heightMap.end(); ++itr)
    {
        int length = itr->first;
        int hNum = itr->second;
        int wNum = widthMap[length];
        count += hNum * wNum;
    }
    return count;
}

int main()
{
    while (cin >> H >> W && (H > 0) && (W > 0))
    {
        heights.resize(H + 1);
        widths.resize(W + 1);
        heights[0] = 0;
        widths[0] = 0;
        int buf;
        // 端からの長さに変換
        for (int i = 0; i < H; ++i)
        {
            cin >> buf;
            heights[i + 1] = heights[i] + buf;
        }
        for (int i = 0; i < W; ++i)
        {
            cin >> buf;
            widths[i + 1] = widths[i] + buf;
        }
        cout << solve() << endl;
    }
}



Measured memory_bytes: 34336
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl

const ll INF = (ll)(1e18) + 1;
const int MAXN = 200005;
vector<ll> a(MAXN);
bool f(ll x, ll k) {
  ll sum = 0LL;
  int n = a.size();
  rep(i, n) {
    if(a[i] < 0) {
      int ng = -1, ok = n;
      while(abs(ok - ng) > 1) {
        int mid = (ng + ok) / 2;
        if(a[mid] * a[i] < x)
          ok = mid;
        else
          ng = mid;
      }
      sum += n - ok;
    } else {
      int ok = -1, ng = n;
      while(abs(ok - ng) > 1) {
        int mid = (ng + ok) / 2;
        if(a[mid] * a[i] < x)
          ok = mid;
        else
          ng = mid;
      }
      sum += ok + 1;
    }
    if(a[i] * a[i] < x) sum--;
  }
  sum >>= 1;
  return sum < k;
}

int main() {
  int n;
  ll k;
  cin >> n >> k;
  a.resize(n);
  rep(i, n) cin >> a[i];
  sort(all(a));
  ll ok = -INF, ng = INF;
  while(abs(ok - ng) > 1) {
    ll mid = (ok + ng) / 2;
    if(f(mid, k))
      ok = mid;
    else
      ng = mid;
  }
  cout << ok << endl;
  return 0;
}

Measured memory_bytes: 1920
n = int(input())
aa = list(map(int, input().split()))
total_odd = sum(aa[1::2])
total_eve = sum(aa[0::2])
tmp = total_eve - total_odd
print(tmp)
for i in range(1,n):
    tmp = 2*aa[i-1] - tmp
    print(tmp)

Measured memory_bytes: 14028
#include <stdio.h>

int main()
{
	int A, B, C, sum;
	scanf("%d%d%d", &A,&B,&C);
	if(A>=1&&B>=1&&C<=10){
		sum = A + B + C;
		if(sum==17)
		printf("YES\n");
		else
		printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] p = new int[N];
    for(int i = 0;i < N;i++){
      p[i] = sc.nextInt();
    }
    int max = 0;
    int max_i = 0;

    for(int i = 0;i < N;i++){
      if(max < p[i]){
        max = p[i];
        max_i = i;
      }
    }
    p[max_i] = p[max_i] / 2;
    
    int sum = 0;
    for(int i = 0;i < N;i++){
      sum += p[i];
    }
    System.out.println(sum);
  }
}


Measured memory_bytes: 21716
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, K = MAP()

ans = set(range(1, N+1))
for _ in range(K):
	d = INT()
	A = LIST()
	ans -= set(A)
print(len(ans))


Measured memory_bytes: 10048
#include <numeric>
#include <iostream>
#include <array>
#include <string>
#include <vector>
#include <cassert>
#include <algorithm>
#include <math.h> 
#include <set>
#include <map>
#include <utility>
#include <deque>
#include <queue>
#include <iomanip>
#include <bitset>
using namespace std;

#define ll long long int
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repp(i, n) for(ll i = 1; i <= n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define riverse(v) reverse((v).begin(), (v).end())
#define pb push_back
#define mp make_pair
#define all(a)  (a).begin(),(a).end()
using vi = vector<int>;
using vs = vector<string>;
using vc = vector<char>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vb = vector<bool>;
using vvb = vector<vb>;
set<char> alphabet = { 'a','b','c','d','e','f','g','h','i','j','k','l','m',
               'n','o','p','q','r','s','t','u','v','w','x','y','z' };

int main() {
    int N, K;
    cin >> N >> K;
    vector<double> p(N);
    rep(i, N)cin >> p[i];
    vector<double> dp(N - K + 1);
    rep(i, K) {
        dp[0] += (p[i]/2.0)+0.5;
    }
    repp(i, N - K) {
        dp[i] = dp[i - 1] + p[i + K - 1]/2.0 - p[i - 1]/2.0;
    }
    double ans = 0;
    int index = 0;
    rep(i, N - K + 1) {
        if (ans < dp[i]) {
            ans = dp[i];
            index =i;
        }
    }
    cout << fixed << setprecision(15) << ans << endl;

}

Measured memory_bytes: 3328
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

using namespace std;


void solve() {
    int N, Q; string S;
    cin >> N >> S >> Q;

    vector<set<int>> s(26);

    for (int i = 0; i < (int)S.size(); i++) {
        s[S[i] - 'a'].insert(i+1);
    }

    for (int q = 0; q < Q; q++) {
        int query; cin >> query;

        if (query == 1) {
            int i; char c; 
            cin >> i >> c;
            s[S[i-1] - 'a'].erase(i);
            s[c - 'a'].insert(i);
            S[i-1] = c;
        }

        else if (query == 2) {
            int l, r; cin >> l >> r;

            int cnt = 0;

            for (int i = 0; i < 26; i++) {
                if (s[i].size() != 0) {
                    auto lit = s[i].lower_bound(l);
                    auto rit = s[i].upper_bound(r);
                    if (lit != rit) cnt++;
                }
            }

            cout << cnt << endl;
        }
    }
}


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

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

int main() {

  int N, T, A;
  cin >> N >> T >> A;

  vector<double> temp_del(N);
  for(int i=0; i<N; i++){
    int height;
    cin >> height;
    temp_del.at(i) = abs(A - (T - height * 0.006));
  }

  int ans = 0;
  double min = temp_del.at(0);

  for(int i=1; i<N; i++){
    if(temp_del.at(i) < min){
      min = temp_del.at(i);
      ans = i;
    }
  }

  cout << ans + 1 << endl;
  
  
}


Measured memory_bytes: 256
//g++ -std=gnu++14 a.cpp

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>
#include <stdio.h>

using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;
ll MODP = 998244353;

ll kai(ll x,ll y){
  if(y == 0)return 1;
  if(y == 1)return x;
  if(y&1){
    return (x*kai(x,y-1))%MOD;
  }else{
    ll t = kai(x,y/2);
    return (t*t)%MOD;
  }
}

ll comb(ll a,ll b,vector<ll> &p){
  if(a == 0)return 1;
  if(b == 0)return 1;
  ll ans = p[a+b];
  ans = (ans*kai(p[a],MOD-2))%MOD;
  ans = (ans*kai(p[b],MOD-2))%MOD;
  return ans;
}

int main(){
  ll N;
  cin >> N;
  vector<ll> A(N+1);
  rep(i,N)cin >> A[i];
  A[N] = 0;
  ll ans = 1000,kabu = 0;
  rep(i,N){
    if(kabu > 0){
      ans += kabu*A[i];
      kabu = 0;
    }
    if(A[i] < A[i+1]){
      ll buy = ans/A[i];
      kabu += buy;
      ans -= A[i]*buy;
    }else{
      continue;
    }



  }

  cout << ans << endl;




  return 0;
}


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

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

    vector<int> l(n);
    rep(i, 0, n) cin >> l[i];

    int ans = 1000000;
    int num_loop = 1;
    rep(i, 0, n) num_loop *= 4;
    rep(i, 0, num_loop)
    {
        int a, b, c;
        a = b = c = 0;

        int state = i;
        int idx = 0;
        int point = 0;

        while (state > 0)
        {
            point += 10;
            int act = state % 4;
            if (act == 0) point -= 10;
            else if (act == 1) a += l[idx];
            else if (act == 2) b += l[idx];
            else if (act == 3) c += l[idx];
            
            state /= 4;
            idx++;
        }
        point -= 30;
        if (a == 0 or b == 0 or c == 0) continue;
        else
        {
            point += abs(A - a);
            point += abs(B - b);
            point += abs(C - c);
        }
        ans = min(ans, point);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    REP(i, N) { cin >> A[i]; }
    ll money = 1000LL;
    ll stocks = 0LL;
    REP(i, N - 1) {
        // A[i] < A[i+1] -> buy
        // A[i] > A[i+1] -> sell
        if(A[i] < A[i + 1]) {
            long long buy = money / A[i];
            stocks += buy;
            money -= buy * A[i];
        } else if(A[i] > A[i + 1]) {
            money += stocks * A[i];
            stocks = 0LL;
        }
    }
    money += stocks * A[N - 1];
    cout << money << endl;
    return 0;
}

Measured memory_bytes: 3628
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 = A+B;

		int ans = B;

		if(C<=D) {

			ans += C;

		}else {

			ans += D+1;
		}

		System.out.println(ans);
	}

}


Measured memory_bytes: 22228
n, m, x = gets.split.map(&:to_i)
c = Array.new(n)
a = Array.new(n) { Array.new(m) }
n.times do |i|
  c[i], *a[i] = gets.split.map(&:to_i)
end
# p [n,m,x,c,a]

ans = 10**12
[true,false].repeated_permutation(n) do |bit|
  know = Array.new(m,0) #理解度
  cost = 0
  n.times do |i|
    next if !bit[i]
    m.times do |j|
      know[j] += a[i][j]
    end
    cost += c[i]
  end
  if know.all?{|v|v>=x}
    ans = cost if cost < ans
  end
end

puts ans == 10**12 ? -1 : ans


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

int A[100], N;

int bubbleSort();
void trace();

int main() {
  cin >> N;
  for (int i = 0; i < N; ++i) { cin >> A[i]; }
  
  int count = bubbleSort();
  trace();
  cout << count << "\n";
  
  return 0;
}

// sort
int bubbleSort() {
  int count = 0;
  unsigned char flag = 1;
  for (int i = 0; flag; ++i) {
    flag  = 0;
    for (int j = N - 1; j >= i + 1; --j) {
      if (A[j] < A[j - 1]) {
        flag = 1;
        swap(A[j], A[j - 1]);
        count++;
      }
    }
  }
  return count;
}

// print
void trace() {
  for (int i = 0; i < N; ++i) {
    if (i) { cout << " "; }
    cout << A[i];
  }
  cout << "\n";
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
typedef long long LL;
using namespace std;

int main() {
  while (true) {
    int n;
    cin >> n;
    if (n == 0) break;
    vector<int> a(n);
    int sum = 0;
    for (int i = 0; i < n; i ++) {
      cin >> a[i];
      sum += a[i];
    }
    double av = (double)sum / n;

    double ans = 0;
    for (int i = 0; i < n; i ++) {
      ans += (a[i] - av) * (a[i] - av);
    }
    ans /= n;

    cout << setprecision(15) << sqrt(ans) << endl;
  }
}



Measured memory_bytes: 3204
#include <iostream>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
using namespace std;

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

  ll n; cin >> n;
  int ans = 1;
  for(int i = 1; i*i <= n; ++i) {
    ans = max(ans, i*i);
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <math.h>
#include <cstdio>
#include <string.h>
#include <vector>
#include <functional>
#include <stack>
#include <queue>
#include <string>
using namespace std;

vector<int> igets(int N) {
	vector<int> A;
	int temp;
	for (int i = 0; i < N; ++i) {
		cin >> temp;
		A.push_back(temp);
	}
	return A;
}
int main(void) {
	int N,time=0,res;
	cin >> N >>res;
	queue<int> q;
	queue<string> q_t;
	//GET
	for (int i = 0; i < N; ++i) {
		string temp_t;
		cin >> temp_t;
		q_t.push(temp_t);
		int temp;
		cin >> temp;
		q.push(temp);
	}
	//RUN
	while (!q.empty()) {
		if (q.front() <= res) {
			time += q.front();
			cout << q_t.front() << " " << time <<endl;
			q.pop();
			q_t.pop();
		}else{
			time += res;
			q.push(q.front()-res);
			q.pop();
			q_t.push(q_t.front());
			q_t.pop();
		}
	}
}


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

using namespace std;

using ll = long long;

int main(void) {
    constexpr ll MOD = 1e9 + 7;

    vector<ll> fact(2e6+1, 1), ifact(2e6+1, 1);
    for(ll i=2; i<=2e6; i++) fact[i] = i * fact[i-1] % MOD;
    {
        ll &r = ifact[2e6], a = fact[2e6], b = MOD-2;
        while(b) {
            if(b&1) (r *= a) %= MOD;
            (a *= a) %= MOD;
            b >>= 1;
        }
    }
    for(ll i=2e6; i>0; i--) ifact[i-1] = i * ifact[i] % MOD;
    
    auto powm = [&](ll a, ll b) {
        ll r = 1;
        while(b) {
            if(b&1) (r *= a) %= MOD;
            (a *= a) %= MOD;
            b >>= 1;
        }
        return r;
    };

    ll n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;

    vector<ll> dp(n+1);
    dp[n] = 1;
    for(ll i=a; i<=b; i++) {
        vector<ll> pre = dp;
            for(ll k=n; k>=0; k--) {
        for(ll j=c; j<=min(d, k/i); j++) {
            // k - i*j >= 0
            // j <= k/i
                if(k - i*j >= 0) {
                    ll t = 1;
                    (t *= pre[k]) %= MOD;
                    // kCij * (ij)! / (i!)^j / j!
                    // k! / (k-ij)! j! (i!)^j
                    (t *= fact[k]) %= MOD;
                    (t *= ifact[k-i*j]) %= MOD;
                    (t *= ifact[j]) %= MOD;
                    (t *= powm(ifact[i], j)) %= MOD;

                    (dp[k - i*j] += t) %= MOD;
                }
        }
            }
    }
    cout << dp[0] << endl;
}


Measured memory_bytes: 31488
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include <cmath>
#include <time.h>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define LINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f
#define PI 3.14159265
#define RAND (rand()*rand())
#define MAX(x, y) ((x) > (y) ? (x):(y)) 
#define MIN(x, y) ((x) > (y) ? (y):(x))
#define ABS(x) ((x) > 0 ? (x) : -(x))
#define CEIL(x, y) (((x) + (y) - 1)/(y))
using namespace std;
const int MAXN = 1e5 + 5;
const ll MOD = 1e9 + 7;
const double eps = 1e-7;
int N, M, K, Q, T;
ll gcd(ll a, ll b) {
	if (b == 0LL) return a;
	return gcd(b, a % b);
}

unsigned long long A[MAXN];

int main()
{
	int i, j;
	unsigned long long x, mul, lim;
	lim = 1e18;
	mul = 1ULL;
	scanf("%d", &N);
	bool flag = false;
	for (i = 1; i <= N; ++i) {
		scanf("%llu", &A[i]);
		if (A[i] == 0ULL) {
			flag = true;
		}
	}
	if (flag) {
		printf("0");
		return 0;
	}

	for (i = 1; i <= N; ++i) {
		unsigned long long a = (lim + mul - 1ULL) / mul;
		if (A[i] > a) {
			printf("-1");
			return 0;
		}
		mul *= A[i];
		if (mul > lim) {
			printf("-1");
			return 0;
		}
	}
	printf("%llu", mul);
	return 0;
}

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

int main() {
	int n,m,l;
	long long A[100][100], B[100][100], C[100][100];

	cin >>n>>m>>l;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)cin>>A[i][j];
	for (int i = 0; i < m; i++)
		for (int j = 0; j < l; j++)cin >> B[i][j];

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < l; j++) {
			C[i][j] = 0;
			for (int k = 0; k < m; k++) {
				C[i][j] += A[i][k] * B[k][j];
			}
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j <l; j++) {
			if (j)cout << " ";
			cout << C[i][j];
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 3288
#define _USE_MATH_DEFIMES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007;
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

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







int main(){
    int N, r(0), w(0); std::cin >> N;
    std::string c; std::cin >> c;
    for(int i(0); i < N; ++i){
        if(c[i] == 'R') ++r;
    }
    int ans(std::max(r, w));
    for(int i(0); i < N; ++i){
        if(c[i] == 'R') --r;
        else ++w;
        chmin(ans, std::max(r, w));
    }
    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 3688
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <string>
//
const long long maxsize = 1e5 + 7, maxint = 0X3f3f3f3f, con = 21;
double error = 1e-7;
#define _USE_MATH_DEFINES
using namespace std;
//
string s;
char w='a';

/*
long long mini(long long index,long long a,long long b,long long c){
//base
if(index==3)
    return abs(a-b)+abs(a-c)+abs(b-c);
//transit
if(index==0)
    return min(mini(index+1,arr[0],b,c),min(mini(index+1,arr[0]+1,b,c),mini(index+1,arr[0]-1,b,c)));
else if(index==1)
    return min(mini(index+1,a,arr[1],c),min(mini(index+1,a,arr[1]+1,c),mini(index+1,a,arr[1]-1,c)));
else
    return min(mini(index+1,a,b,arr[2]),min(mini(index+1,a,b,arr[2]+1),mini(index+1,a,b,arr[2]-1)));
}
bool check(long long x){
    for(long long i=0;i<v.size()-1;i++){
        if(abs(v[i])>=(x)&&abs(v[i+1])>=(x))
            return 1;
    }
    return 0;
}
long long bin(){
    long long st=0,en=1e9,mid;
    while(st!=en){
        mid=(st+en+1)/2;
        if(check(mid))
            st=mid;
        else
            en=mid-1;
    }
    return st;
}

void sieve(){
primes.push_back(1);
primes.push_back(2);
for(long long i=3;i<=1e6;i+=2){
    if(!l[i]){
        primes.push_back(i);
        if(i<=sqrt(1e6)){
            for(long long u=i*2;u<=1e6;u+=i)
                l[u]=1;
        }
    }
}
}

bool isprime(long long x){
    for(long long i=2;i*i<=x;i++){
        if(x%i==0)
            return 0;
    }
    return 1;
}
long long fastpow(long long m,long long p){
    if(p==0)
        return 1;
    long long left=fastpow(m,(p/2))%con;
    if(p%2==0)
        return (left*left)%con;
    else
        return (((left*left)%con)*(m%con))%con;
}


long long fastpow(long long m,long long p){
    if(p==0)
        return 1;
    long long left=fastpow(m,(p/2))%con;
    if(p%2==0)
        return (left*left)%con;
    else
        return (((left*left)%con)*(m%con))%con;
}
*/



int main()
{
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
   // freopen("in", "rd", stdin);
    //freopen("out","wd",stdout);
    cin>>s;
    bool e=0;
    for(;w<='z';w++){
        e=1;
        for(int u=0;u<s.size();u++)
            if(s[u]==w){
                e=0; 
                break;
            }
        if(e){
            cout<<w;
            return 0;
        }
    }
    cout<<"None\n";
    return 0;
}

Measured memory_bytes: 3672
from collections import defaultdict
n = int(input())
a = list(map(int,input().split()))
d = defaultdict(int)
for i in range(n):
  d[a[i]]+=1
tmp=0
for v in d.values():
  tmp+=v*(v-1)//2

for v in a:
  if d[v]>1:
  	print(tmp-d[v]+1)
  else:
    print(tmp)

Measured memory_bytes: 26772
def resolve():
    S = input()  # 問題文中のS'
    T = input()

    sl = len(S)
    tl = len(T)

    # Tと一致する文字がSに含まれるかをSの先頭から1つづつずらして判定する
    check = False
    for i in range(sl - tl, -1, -1):
        for j in range(tl):
            if S[i + j] == T[j] or S[i + j] == '?':
                check = True
            else:
                check = False
                break
        if check:
            print((S[:i] + T + S[i + tl:]).replace('?', 'a'))
            break
    if check is False:
        print('UNRESTORABLE')

        
resolve()


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

int main() {
  int a,b,c;cin>>a>>b>>c;
  bool ans = c >= a && c <= b;
  cout << (ans ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,z,zs;
int main()
{
	cin>>n;
	for(int i=int(sqrt(n));i>=1;i--)
	{
		if(n%i==0)
		{
			z=n/i;
			for(;z>0;z/=10)
			zs++;
			cout<<zs<<endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
using ll = long long;
using P = pair<ll,ll>;

int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
ll n;
cin >> n;
vector<ll> a(n);
rep(i,n)
cin >> a[i];
ll basis = a[0];
bool up = false, down = false;
ll ans = 1;
rep(i,n){
    if(up && basis > a[i]){
        up = false;
        ans++;
    }
    else if(down && basis < a[i]){
        down = false;
        ans++;
    }
    else if(!up && basis < a[i]){
        up = true;
    }
    else if(!down && basis > a[i]){
        down = true;
    }
    basis = a[i];
}
cout << ans << endl;
}

Measured memory_bytes: 3944
temp=input().split()
N=int(temp[0])
K=int(temp[1])
ab=[[int(j) for j in input().split()] for i in range(N)]

ab.sort()
while ab[0][1]<K:
	K-=ab[0][1]
	del ab[0]
	#print(ab)
print(ab[0][0])

Measured memory_bytes: 23188
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
using namespace std;

//	データセットの終わりを処理したら0,
//	それ以外なら1を返す関数
//	問題を解く部分
int solve();

int main() 
{
	while(solve()){}
	return 0;
}

int solve() 
{
	typedef long double ld;
	
	// 入力
	int D, E;
	cin >> D >> E;
	
	if(!(D|E)) { return 0; } // データセットの終わり
	//入力ここまで
	
	//　解法　全探索O(N)
	//　x + y = Dとなる(x, y)を全列挙し
	//  abs( sqrt( x^2 + y^2 ) - E )の最小値を出力する
	//　線対称だから x = [D/2], y = D - xのあたりで最小 
	
	ld ans = 10e20;
	const ld e = static_cast<ld>(E);
	for( int i = 0; i <= D; i++)
	{
		ld x = static_cast<ld>(i);
		ld y = static_cast<ld>(D-i);
		
		ans = min( abs(sqrt(x*x+y*y)-e), ans );
	}
	
	cout << fixed << setprecision(6) << ans << endl;
	
	return 1;
}


Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i,n) for(int i = 0;i<n;i++)
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0;}

const int INF = 1000000000;
int main() {
    int n,k;
    std::cin >> n >> k;
    std::vector<int>h(n);
    rep(i,n){
        std::cin >> h[i];
    }
    std::vector<int>dp(n,INF);
    dp[0]=0;
    rep(i,n){
        for(int j=i+1;j<=k+i;j++){
            if(j>n){
                break;
            }
            dp[j]=std::min(dp[j],dp[i]+abs(h[i]-h[j]));
        }
    }
    std::cout << dp[n-1] << std::endl;
}


Measured memory_bytes: 1024
package main

import (
	"fmt"
)

// x^y
func pow(x, y int) int {
	ret := 1
	for i := 0; i < y; i++ {
		ret *= x
	}
	return ret
}

func main() {
	var n int
	fmt.Scan(&n)
	var s string
	fmt.Scan(&s)

	ans := 0
	for i := 0; i < 1000; i++ {
		can := true
		digit := 0 // ラッキーナンバーのインデックス

		for j := 2; j >= 0 && can; j-- { // iの調査する桁数
			checkNum := (i / pow(10, j)) % 10
			for ; ; digit++ {
				if digit == n {
					can = false
					break
				}
				if checkNum == int(s[digit]-48) {
					digit++
					break
				}
			}
		}

		if can {
			ans++
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 768
import java.util.Scanner;

public class Main {
	public static void main(String [] args){
        Scanner scan = new Scanner(System.in);
        
        while(true){
            String line = scan.nextLine();
            int s = 0;
            
            if(line.charAt(0) == '0'){
                break;
            }
            
            for(int i = 0; i < line.length(); ++i){
                s += Character.digit(line.charAt(i), 10);
            }
            
            System.out.println(s);
        }
    }
}

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

int main() {
	int H, W, N;
	cin >> H >> W >> N;
	vector<pair<int, int>> points;
	for (int i = 0; i < N; i++) {
		int x, y; cin >> x >> y;
		points.push_back(pair<int, int>(x, y));
	}

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

	int z = H;
	int c = 0;
	for (int i = 0; i < N; i++) {
		pair<int, int> p = points[i];
		int x = p.first, y = p.second;
		if (y > x-c) continue;
		else if (y == x - c) {
			c++;
		}
		else {
			z = x - 1;
			break;
		}
	}
	cout << z << endl;
	return 0;
}

Measured memory_bytes: 2420
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<algorithm>
#include<cmath>
#include<iomanip>
using namespace std;

typedef long long int llint;

int main(){
	int N;
	cin >> N;
	int x[N],y[N];
	vector<int> cities;
	for(int i=0;i<N;i++){
		cin >> x[i] >> y[i];
		cities.push_back(i);
	}

	double distanceSum=0;
	int distanceCnt=0;
	do{
		double distance=0;
		int currentCity=cities[0];
		for(const int& c:cities){
			distance+=sqrt(pow(x[c]-x[currentCity],2)+pow(y[c]-y[currentCity],2));
			currentCity=c;
		}
		distanceSum+=distance;
		distanceCnt++;
	}while(next_permutation(cities.begin(),cities.end()));

	cout << setprecision(8) << (distanceSum/distanceCnt) << endl;
	return 0;
}


Measured memory_bytes: 256
line = input().split()
object_ = input()

N = int(line[0])
A = int(line[1])-1
B = int(line[2])-1
C = int(line[3])-1
D = int(line[4])-1

placing_objects = [True if s == '#' else False for s in list(object_)]

def main():
    if (A < B and C < D) or (A > B and C > D):
        for i in range(N-1):
            if placing_objects[i] and placing_objects[i+1] and i > A and i < max(C, D):
                print('No')
                return
        print('Yes')
        return
    else:
        possible_trans = False
        trans_index = []
        for i in range(N-1):
            if placing_objects[i] and placing_objects[i+1] and i > A and i < max(C, D):
                print('No')
                return
            if i < N-2 and (not placing_objects[i]) and (not placing_objects[i+1]) and (not placing_objects[i+2]):
                possible_trans = True
                trans_index.append(i+1)
        if not possible_trans:
            if C < D:
                if placing_objects[C-1] or placing_objects[C+1]:
                    print('No')
                    return
            else:
                if placing_objects[D-1] or placing_objects[D+1]:
                    print('No')
                    return
        else:
            if A > B:
                if A > max(trans_index):
                    print('No')
                    return
            else:
                if B > max(trans_index) or D < min(trans_index):
                    print('No')
                    return
        print('Yes')
        
main()

Measured memory_bytes: 6460
#include<stdio.h>
#include<math.h>
int main()
{
	int a[100050]={0};	
	int b[100050]={0};
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	scanf("%d",&a[i]);
  int t=0;
	for(int i=0;i<n;i++)
	{   b[a[i]]++;
	}
	for(int j=0;j<n;j++)
	{
		b[a[j]-1]++;
		b[a[j]+1]++;
	}
	int max=b[a[0]];
	for(int i=0;i<n;i++)
	{
		if(b[a[i]]>max)
		max=b[a[i]];
	}
	printf("%d\n",max);
  return 0;
}

Measured memory_bytes: 896