akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

#define EPS (1e-7)
#define PI (acos(-1))
//const ll mod = 1000000007;
ll dp[100500];
deque<l_l> deq;
ll N, M;
vector<l_l> Query[100500];
const ll INF = 1e18;
struct LazySegmentTree {
private:
    int n;
    vector<ll> node, lazy;
    vector<bool> lazyFlag;
 
public:
    LazySegmentTree() {
        int sz = 100050;
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n-1, INF);
        lazy.resize(2*n-1, INF);
        lazyFlag.resize(2*n-1, false);
 
        for(int i=0; i<sz; i++) node[i+n-1] = INF;
        for(int i=n-2; i>=0; i--) node[i] = min(node[i*2+1], node[i*2+2]);
    }
 
    void lazyEvaluate(int k, int l, int r) {
        if(lazyFlag[k]) {
            node[k] = min(lazy[k], node[k]);
            if(r - l > 1) {
                chmin(lazy[k*2+1], lazy[k]);
                chmin(lazy[k*2+2], lazy[k]);
                lazyFlag[k*2+1] = lazyFlag[k*2+2] = true;
            }
            lazyFlag[k] = false;
            lazy[k] = INF;
        }
    }
 
    void update(int a, int b, ll x, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        lazyEvaluate(k, l, r);
        if(b <= l || r <= a) return;
        if(a <= l && r <= b) {
            lazy[k] = x;
            lazyFlag[k] = true;
            lazyEvaluate(k, l, r);
        }
        else {
            update(a, b, x, 2*k+1, l, (l+r)/2);
            update(a, b, x, 2*k+2, (l+r)/2, r);
            node[k] = min(node[2*k+1], node[2*k+2]);
        }
    }
 
    ll find(int a, int b, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        lazyEvaluate(k, l, r);
        if(b <= l || r <= a) return INF;
        if(a <= l && r <= b) return node[k];
        ll vl = find(a, b, 2*k+1, l, (l+r)/2);
        ll vr = find(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
    }
};


int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M;
    for(int i = 1; i <= M; i++) {
        ll L, R, C;
        cin >> L >> R >> C;
        Query[L].emplace_back(R, C);
    }
    for(int i = 1; i <= N; i++) {
        dp[i] = INF;
    }
    LazySegmentTree seg;
    for(int pos = 1; pos <= N; pos++) {
        dp[pos] = seg.find(pos, pos + 1);
        if(pos == 1) {
            dp[pos] = 0;
        }
        //cerr << pos << " " << dp[pos] << endl;
        if(dp[pos] == INF) {
            cout << -1 << endl;
            return 0;
        }
        for(auto now : Query[pos]) {
            seg.update(pos, now.first + 1, dp[pos] + now.second);
        }
    }
    cout << dp[N] << endl;
    return 0;
}


Measured memory_bytes: 10624
#include <bits/stdc++.h> //全てのヘッダファイルをインクルード

//ループ
#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++) //最初の数値を指定したループ

//型名省略
typedef long long ll;

using namespace std;

int main(){
    ll N, ans;
    
    cin >> N;
    if(N<1 || N>100){
        return 1;
    }

    ans = N/2+N%2;

    cout << ans;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
#define SortAsc(c) std::sort(c.begin(), c.end())
#define SortDesc(c) std::sort(c.rbegin(), c.rend())
int dx[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int dy[8] = {1, 0, -1, 0, 1, -1, 1, -1};

int main() {
  string s;
  cin >> s;
  vector<int> n(s.size());
  for (int i = 0; i < s.size(); i++) {
    int v = int(s[i] - '0');
    n.at(i) = v;
  }

  for (int i = 0; i < (1 << 3); i++) {
    bitset<3> b(i);
    int res = n.at(0);
    for (int j = 0; j < 3; j++) {
      int op = b[j] ? 1 : -1;
      res += op * n.at(j + 1);
    }
    // cout << "res = " << res << endl;
    if (res == 7) {
      string o = to_string(n.at(0));
      for (int j = 0; j < 3; j++) {
        string op = b[j] ? "+" : "-";
        int v = n.at(j + 1);
        if (v == 0) {
          op = "+";  // -0 は+0でもいいので見栄え
        }
        o += op + to_string(v);
      }
      cout << o << "=7" << endl;
      return 0;
    }
  }

  cout << "answer not found" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#define ll long long
#define INF 1e+15
#define MOD 1000000007
using namespace std;


ll dp[101][100001];
int main(){
    ll N,W;
    cin >> N >> W;
    
    for(int i=0; i<=100; i++){
        for(int j=0; j<=100000; j++){
            if(j==0){
                dp[i][j]=0;
            }else{
                dp[i][j]=INF;
            }
        }
    }
    
    ll w[101];
    ll v[101];
    for(int i=0; i<N; i++){
        cin >> w[i] >> v[i];
    }
    

    
    for(int i=1; i<=N; i++){
        for(int j=1; j<=100000; j++){
            if(j-v[i-1]>=0){
                dp[i][j] = min( min((ll)INF, dp[i-1][j-v[i-1]]+w[i-1] ), dp[i-1][j] );
            }else{
                dp[i][j]=dp[i-1][j];
            }
        }
    }
    
    for(int j=100000; j>=0; j--){
        if(dp[N][j]<=W){
            cout<<j<<endl;
            return 0;
        }
    }
    
    return 0;
}


Measured memory_bytes: 79104
#include <iostream>
#include <cmath>

using namespace std;

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

    bool isPlus = (X>=0);
    if(!isPlus) X *= -1;

    for(int a=0;a<=1000;a++){
        A = a;

        // B < 0
        for(int b=0;b<=1000;b++){
            B = -b;
            if(pow(A,5.0)-pow(B,5.0) >= X)break;
        }
        if(pow(A,5.0)-pow(B,5.0) == X)break;

        // B > 0
        for(int b=0;b<=1000;b++){
            B = b;
            if(pow(A,5.0)-pow(B,5.0) <= X)break;
        }
        if(pow(A,5.0)-pow(B,5.0) == X)break;
    }
    
    if(!isPlus){
        int W = A;
        A = B;
        B = W;
    }

    cout << A << " " << B << endl;
}

Measured memory_bytes: 4060
#include <bits/stdc++.h>
using namespace std;
#define ll int
const ll N = 3e3 + 5;
string s, t, dp[2][N];
int main()
{
    ios::sync_with_stdio(0), cin.tie(0);
    cin >> s >> t;
    for (ll i = 0; i < s.size(); i++)
        for (ll j = 0; j < t.size(); j++)
            if (s[i] == t[j])
                dp[i % 2][j + 1] = dp[!(i % 2)][j], dp[i % 2][j + 1].push_back(s[i]);
            else if (dp[i % 2][j].size() > dp[!(i % 2)][j + 1].size())
                dp[i % 2][j + 1] = dp[i % 2][j];
            else
                dp[i % 2][j + 1] = dp[!(i % 2)][j + 1];
    cout << dp[!(s.size() % 2)][t.size()];
}

Measured memory_bytes: 18088
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF INT_MAX
#define LLINF LLONG_MAX
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	ll ans = 0;
	int tmp;
	int n, k;
	cin >> n >> k;
	vector<int> p(n);
	REP(i, n) cin >> p[i];
	sort(p.begin(), p.end());
	REP(i, k) ans += p[i];
	cout << ans << endl;
}

Measured memory_bytes: 3588
n=gets.to_i
a=$<.read.split.map{|x|x.to_i/400}                                        
s=a.select{|x|x<8}.uniq.size
t=a.select{|x|x>7}.size
if(s==0)
  puts "1 #{n}"
else
  puts "#{s} #{s+t}"
end


Measured memory_bytes: 1788
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;

  long A, B, C, D, E, F; rd(A, B, C, D, E, F);

  A*=100; B*=100;
  long tot=A, su=0;
  for(long a=0; a<=F; a+=A)for(long b=0; a+b<=F; b+=B){
    for(long c=0; a+b+c<=F; c+=C){
      if(c*100>(a+b)*E) continue;
      for(long d=0; a+b+c+d<=F; d+=D){
        if((c+d)*100>(a+b)*E) continue;
        long wa_=a+b, su_=c+d, to_=wa_+su_;
        if(su*to_<tot*su_){
          tot=to_;
          su=su_;
        }
      }
    }
  }

  writeln(tot, " ", su);
}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x) e=l[i].to!(typeof(e));
}

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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;
class matrix{
public:
    int n;
    vector<vi> val;
    matrix(int n=2);
    matrix operator+(const matrix&) const;
    matrix operator-(const matrix&) const;
    matrix operator*(const matrix&) const;
    matrix& operator=(const matrix& b){
        val=b.val;
        n=b.n;
        return *this;
    }
    void set(int x){
        rep(i,0,n){
            rep(j,0,n){
                val[i][j]=x;
            }
        }
    }
    void print(){
        rep(i,0,n){
            rep(j,0,n){
                cout<<val[i][j]<<" ";
            }
            cout<<endl;
        }
    }
    matrix mul(int a){
        matrix ans(this->n);
        rep(i,0,this->n){
            rep(j,0,this->n){
                ans.val[i][j]=a*this->val[i][j];
            }
        }
        return ans;
    }
};
matrix::matrix(int x){
    n=x;
    val.resize(x);
    rep(i,0,x){
        val[i].resize(x);
    }
}
matrix matrix::operator+(const matrix& b) const{
    matrix ans(b.n);
    rep(i,0,b.n){
        rep(j,0,b.n){
            ans.val[i][j]=this->val[i][j]+b.val[i][j];
        }
    }
    return ans;
}
matrix matrix::operator-(const matrix& b) const{
    matrix ans(b.n);
    rep(i,0,b.n){
        rep(j,0,b.n){
            ans.val[i][j]=this->val[i][j]-b.val[i][j];
        }
    }
    return ans;
}
matrix matrix::operator*(const matrix& b) const{
    matrix ans(b.n);
    rep(i,0,b.n){
        rep(j,0,b.n){
            rep(k,0,b.n){
                ans.val[i][j]=(ans.val[i][j]+1LL*this->val[i][k]*b.val[k][j])%hell;
            }
        }
    }
    return ans;            
}
matrix identity(int N=2){
    matrix ans(N);
    rep(i,0,N){
        ans.val[i][i]=1;
    }
    return ans;
}
matrix matexpo(matrix a, int n){
    if(n==0){
        return identity(a.n);
    }
    if(n==1) return a;
    matrix x=matexpo(a,n/2);
    matrix r=x*x;
    if(n&1) r=r*a;
    return r;
}
void solve(){
    int n,k;
    cin>>n>>k;
    matrix mat(n);
    rep(i,0,n){
        rep(j,0,n){
            cin>>mat.val[i][j];
        }
    }
    int ans=0;
    mat=matexpo(mat,k);
    rep(i,0,n){
        rep(j,0,n){
            ans=(ans+mat.val[i][j])%hell;
        }
    }
    cout<<ans<<endl;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> X(N);
    for(int i=0; i<N; i++) cin >> X[i];
    vector<int> Y = X;
    sort(Y.begin(), Y.end());

    int a = Y[N/2-1];
    int b = Y[N/2];

    for(int i=0; i<N; i++){
        if(X[i] < b) cout << b << endl;
        else cout << a << endl;
    }


    return 0;
}

Measured memory_bytes: 3712
#include <stdio.h>

int main(){
  int i1[5] = {};
  int x,y;
  for(int n = 0; n < 5; n++)
    scanf("%d",&i1[n]);

  x = i1[0] * i1[4];
  if(i1[4] <= i1[2]) y = i1[1];
  else y = i1[1] + ((i1[4] - i1[2]) * i1[3]);
  
  if(x == y) printf("%d\n",x);
  else if(x > y) printf("%d\n",y);
  else if(x < y) printf("%d\n",x);
} 

Measured memory_bytes: 2568
using System;
using System.Collections.Generic;
using static System.Math;
using System.Linq;
using System.Text;
 
class DandA {
    static void Main(string[] args) {
        int n = ReadLineInt();
        int[] hArr = ReadLineIntArray();
        bool flg = true;
        for (int i = n - 1; i > 0;i--) {
            if (hArr[i -1] - 1 == hArr[i]){
                hArr[i -1]--;
            } else if (hArr[i -1] - 1 > hArr[i]){
                flg = false;
                break;
            }
        }
        if (flg) {
            Console.WriteLine("Yes");
        } else {
            Console.WriteLine("No");
        }
    }
 
    static string Alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ";
    static string[] strAry = new string[] {"L", "R", "U", "D"};
    static int[] intArray = new int[10];
    static List<int> intList = new List<int>();
  
    static private string ReadLineStr() {return Console.ReadLine();}
    static private int ReadLineInt() {return int.Parse(Console.ReadLine());}
    static private long ReadLineLong() {return long.Parse(Console.ReadLine());}
    static private double ReadLineDouble() {return double.Parse(Console.ReadLine());}
    static private string[] ReadLineStrArray() {return Console.ReadLine().Trim().Split();}
    static private int[] ReadLineIntArray() {return Console.ReadLine().Trim().Split().Select(a => int.Parse(a)).ToArray();}
    static private long[] ReadLineLongArray() {return Console.ReadLine().Trim().Split().Select(a => long.Parse(a)).ToArray();}
    static private double[] ReadLineDoubleArray() {return Console.ReadLine().Trim().Split().Select(a => double.Parse(a)).ToArray();}
    static private decimal[] ReadLineDecimalArray() {return Console.ReadLine().Trim().Split().Select(a => decimal.Parse(a)).ToArray();}
    static private List<int> ReadLineIntList() {return Console.ReadLine().Trim().Split().Select(a => int.Parse(a)).ToList();}
    static private List<long> ReadLineLongList() {return Console.ReadLine().Trim().Split().Select(a => long.Parse(a)).ToList();}
    static private string[][] ReadMLineStrArray(int arg) { return new int[arg].Select(_ => Console.ReadLine().Split()).ToArray();}
    static private int[][] ReadMLineIntArray(int arg) { return new int[arg].Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).ToArray();}
 
    static private bool IsPrime(int num) {
        if (num < 2) return false;
        if (num == 2) return true;
        else if (num % 2 == 0) return false;
        double sqrtNum = Math.Sqrt(num);
        for (int i = 3; i <= sqrtNum; i += 2) {
            if (num % i == 0) return false;
        }
        return true;
    }
  
    static private string IntToNString(int x, int n) {
        var nstring = "";
        var numbers = new string[] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f" };
        int r = 1;
        int q = x;
        while (q > 0) {
            r = q % n;
            nstring += numbers[r];
            q = q / n;
        }
        return string.Join("",nstring.Reverse());
     }
}

Measured memory_bytes: 28252
#include <iostream>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;

int main() {
  string s;
  cin >> s;
  map<char,int> mp;
  for (auto c : s) mp[c]++;
  bool ans = mp.size() == 2;
  auto c = [](pair<char,int> x){return x.second==2;};
  if (ans) ans = all_of(mp.begin(), mp.end(), c);
  
  cout << (ans? "Yes" : "No") << endl;
}

Measured memory_bytes: 504
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

using namespace std;

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

	string S;
	cin >> S;

	string T;
	cin >> T;

	if (T.find(S) == 0)
	{
		cout << "Yes";
	}
	else
	{
		cout << "No";
	}

	return 0;
}

Measured memory_bytes: 3648
from collections import defaultdict
from collections import deque
from collections import Counter
import math
import itertools

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

a,b,c,d = readInts()

ans = max(a*c,a*d,b*c,b*d)

print(ans)

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


int main()
{
  int N;
  cin >> N;

  if (N%1000 == 0)
  {
    cout << 0 << endl;
  }
  else
  {
    cout << 1000-N%1000 << endl;
  }




}


Measured memory_bytes: 3616
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	
	words := make(map[string]int,n)
	var word string
	var preword byte
	for i := 0; i < n; i++ {
		fmt.Scan(&word)
		words[word]++
      if words[word] > 1 || (preword != 0 && preword != word[0]) {
			fmt.Println("No")
			return
		}
		preword = word[len(word) - 1]
	}
	fmt.Println("Yes")
}


Measured memory_bytes: 512
#include<stdio.h>
int main(){
  char s[11];
  while(1){
    int n,m,h,d,a[30][12]={0};
    int i,j,k,t,c;
    scanf("%d",&n);
    if(n==0)break;
    scanf("%d\n%d\n%d\n",&m,&h,&d);
    for(i=0;i<d;i++){
      fgets(s,11,stdin);
      for(j=1;j<n;j++){
	a[i][j]=s[j-1]-'0';
      }
    }
    c=m;
    for(i=0;i<d;i++){
      if(a[i][c]==1)c++;
      else if(a[i][c-1]==1)c--;
    }
    if(c==h)printf("0\n");
    else{
      for(t=0;t<d;t++){
	for(k=1;k<n;k++){
	  if(a[t][k-1]==0&&a[t][k]==0&&a[t][k+1]==0){
	    a[t][k]=1;
	    c=m;
	    for(i=0;i<d;i++){
	      if(a[i][c]==1)c++;
	      else if(a[i][c-1]==1)c--;
	    }
	    if(c==h){
	      printf("%d %d\n",t+1,k);
	      t=d+1;
	      k=n+1;
	    }
	    a[t][k]=0;
	  }
	}
      }
    }
    if(t==d)printf("1\n");	    
  }
  return 0;
}  

Measured memory_bytes: 616
s=list(input())
s1=s[0]+s[1]
s2=s[2]+s[3]

if 1<=int(s1)<=12 and 1<=int(s2)<=12:print('AMBIGUOUS')
elif 1<=int(s1)<=12 and 0<=int(s2)<=99:print('MMYY')
elif 1<=int(s2)<=12 and 0<=int(s1)<=99:print('YYMM')
else:print('NA')

Measured memory_bytes: 3064
#include<iostream>

using namespace std;

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

int main() {
  int n, t, e;
  cin >> n >> t >> e;
  rep (i, n) {
    int x;
    cin >> x;
    for (int j = t - e; j <= t + e; ++j) {
      if (j % x == 0) {
	cout << i + 1 << endl;
	return 0;
      }
    }
  }
  cout << -1 << endl;
  return 0;
}

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

int main() {
  double w,h,x,y;
  cin >> w >> h >> x >> y;
  
  cout << setprecision(12) << (w*h)/2 << ' ';
  cout << ((x==w/2 && y==h/2)? "1":"0") << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<math.h>
#include<string>
#include<limits.h>
#define ll long long
#define vl vector<ll> 
#define vb vector<bool> 
#define vvl vector<vector<ll> > 
#define vvb vector<vector<ll> > 
#define rep(i,n) for(int i=0;i<n;i++)
#define nrep(i,a,b) for(int i=a;i<b;i++)
#define mrep(i,a) for(int i=a;i>=0;i++)
#define mmrep(i,a) for(int i=a;i>0;i++)
#define INF 1123456789012345
using namespace std;

ll n, a, b,ans;
vl h;
bool check(ll t) {
	ll a_t = t;
	rep(i, n) {
		if (h[i] - (b*t) > 0) {
			ll temp = (h[i] - b*t) / a;
			if (((h[i] - b*t) % a)) temp++;
			a_t -= temp;
			if (a_t < 0) return false;
		}
	}return true;
}

void binary(ll l, ll r) {
	if (l > r) return;
	//cout << "l=" << l << " r=" << r << endl;
	ll mid = (l + r) / 2;
	//cout << "mid=" << mid << endl;
	if (check(mid)) {
		//cout << "yes" << endl;
		ans = mid;
		binary(l, mid-1);
	}
	else {
		//cout << "no" << endl;
		binary(mid+1, r);
	}
}

int main() {
	cin >> n >> a >> b;
	a -= b;
	h.resize(n); rep(i, n) cin >> h[i];
	ll t = 1000000000;
	binary(1, t);
	cout << ans << endl;
	//cout << check(700000000) << endl;
	return 0;
}

Measured memory_bytes: 1024
#include  <iostream>
#include <string>

using namespace std;

int main(int argc, char const* argv[])
{
	string s;
	cin >> s;
	int res = 0;
	for(int i = 0; i < 4; i++){
			if(s[i] == '+')res++;
			else res--;
	}
	cout << res << endl;
	return 0;
}


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

using namespace std;
using ll =long long;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
//Write From this Line

int main()
{
	ll n, k;
	cin >> n >> k;
	vector<ll> a(n);
	rep(i,n){
		cin >> a[i];
		a[i]--;
	}
	// 絶対周期があるはず。
	ll count = 0; //2回目にある街 i に来た時のカウントを見ればいい。
	
	// 一回目に来た時と二回目に来た時の差がループにかかる回数
	map<ll,pair<int,int>> mp;
	mp[0].first = 0, mp[0].second = 1; // secondは何回そこにきたか
	ll memo = 0;
	ll roop = 0;
	for(ll i = 0; i < k; i++){
		count ++;
		ll next = a[memo];
		if(mp[next].second == 1){
			roop = count - mp[next].first;
			memo = next;
			break;
		}
		mp[next].second = 1;
		mp[next].first = count;
		memo = next;
	}
	if(count == k){
		cout << memo + 1 << endl;
		return 0;
	}
	// count 回移動して、次にループを消費しよう。
	int town = 0;
	rep(i,count){
		town = a[town];
	}
	k -= count;
	k %= roop;
	rep(i,k){
		town = a[town];
	}
	cout << town + 1 << endl;
}


Measured memory_bytes: 14728
#include <stdio.h>

int main() {
  char ch[250]={0};
  char a[250] ={0};
  int h;
  int i,j,k,l,n,m;


  while(1){
    i=0;
    while(1){
      
      scanf("%c",&ch[i]);
      if(ch[i] == '\n') {    
	break;
      }
      
      i++;
    }
   
    if ( i == 1 && ch[0] == '-' ) break;

    //  printf("%d",i);
    
    scanf("%d",&m);
    
    for(j=0;j<m;j++){
      scanf("%d", &h );
      
      for(k=0;k<i-h;k++) {
	a[k] = ch[h+k];
	//    printf("a[%d] = ch[%d]の%c\n",k ,h+k,ch[h+k]);
      }
      for(k=0;k<h;k++){
	a[i-h+k] = ch[k];
	//   printf("a[%d] = ch[%d]の%c\n",i-h+k,k,ch[k]);
      }
      for(k=0; k<i; k++){
	ch[k] = a[k];
	// printf("ch[%d] = a[%d]の%c\n",k,k,a[k]);
      }
    }
    for(k=0;k<i;k++) {
      printf("%c",ch[k]);
    }
    printf("\n");
      scanf("%c",&ch[0]);
  }
  
  
  return 0;
  
}



Measured memory_bytes: 2080
import core.bitop;
import std.algorithm;
import std.array;
import std.ascii;
import std.container;
import std.conv;
import std.format;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
  int n = readln.chomp.to!int;
  int sum = 0;
  foreach (i; 0..n) {
    auto lr = readln.chomp.split.map!(to!int);
    sum += lr.back - lr.front + 1;
  }
  sum.writeln;
}


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

int main() {
  int N,M;
  cin >> N>>M;
  vector<int> vec(N);
  
  for (int i=0; i<M;i++){
    int a,b;
    cin >> a >>b;
    vec.at(a-1)++;
    vec.at(b-1)++;
  }
  
  for (int i=0;i<N;i++){
    cout << vec.at(i) << endl;
  }
  
}




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

int main () {
    int  a, b, c ; 
    cin >> a >> b >> c;
    int m=min({a+b,b+c,a+c});
    //int m=min(a+b,min(b+c,a+c));
    cout << m <<endl;

    return 0;
}


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

using namespace std;

int main(){
    int N, Y;

    cin >> N >> Y;


    int n = 0;
    int y = 0;
    for(int i = 0; i <= N; i++){
        for(int j = 0; j <= N - i ; j++){
            for(int k = 0; k <= N - i - j; k++){
                n = i + j + k;
                if( n != N ) continue;

                y = 1000*i + 5000*j + 10000*k;
                if( y == Y ){
                    printf("%d %d %d\n", k, j, i);
                    return 0;
                } else if( y > Y){
                    break;
                }
            }
        }
    }

    printf("-1 -1 -1\n");
    return 0;
}


    


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <functional>
#include <string>
#include <array>
#include <vector>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <queue>
#include <complex>
#define full(c) c.begin(), c.end()
#define vector2d(name,type,h,w,init) vector<vector<type>> name(h,vector<type>(w,init)) 
const int PRIME = 1000000007;
const int INT_INF = 2147483647;
const long long int LL_INF = 9223372036854775807;
const double PI = acos(-1);
const double EPS = 0.000000001;
typedef unsigned long long int ull;
typedef long long int ll;
using namespace std;

int main(){
	//ios_base::sync_with_stdio(false);
	//cin.tie(NULL);
	ll i, n, cnt = 0;
	cin >> n;
	for (i = 0; i < n; i++){
		int a;
		cin >> a;
		while (a % 2 == 0){
			a /= 2;
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main(){
    int n,y;
    cin>>n>>y;
    rep(i,n+1){
        rep(j,n+1){
            int k=y-(i*5000+j*1000);
            if(k<0) break;
            if(i+j+k/10000==n&&k%10000==0){
                cout<<k/10000<<" "<<i<<" "<<j;
                return 0;
            }
        }
    }
    cout<<-1<<" "<<-1<<" "<<-1;
}

Measured memory_bytes: 3660
s = input()
sr = s[::-1]
mod = [0]*2019
mod[0] += 1
T = 0
d = 1 
for s in sr:
  T = T + int(s) * d
  T %= 2019
  mod[T] += 1
  d = (d * 10) % 2019
  
res = [m*(m-1)//2 for m in mod]
print(sum(res))

  

  

    

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

int main()
{
    vector<int> A(4);
    cin >> A[0];
    cin >> A[1];
    cin >> A[2];
    cin >> A[3];
    sort(A.begin(), A.end());
    int temp = A[0] * 1000 + A[1] * 100 + A[2] * 10 + A[3];
    if (temp == 1479)
    {
        cout << "YES";
    }
    else
    {
        cout << "NO";
    }
}

Measured memory_bytes: 256
$n = gets.to_i
$v = gets.split.map(&:to_i)
$c = gets.split.map(&:to_i)

def f(i, sm)
  if(i == $n)
    return sm
  end

  mx = [f(i+1, sm), f(i+1, sm+$v[i]-$c[i])].max
  return mx
end

p f(0, 0)


Measured memory_bytes: 3836
#include <stdio.h>
#include <iostream>

using namespace std;

int main()
{
    int a,b,c, counter = 0;
    cin>>a>>b>>c;
    int i;
    for(i=1; i<=c; i++)
    {
        if(c%i == 0)
            if(a<=i && b>=i)
                counter++;
    }
    cout<<counter<<endl;

    return 0;
}



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

int main() {
    vector<int> a(9);
    for(int i = 0; i < 9; i++)cin >> a[i];
    int n;cin >> n;
    for(int i = 0; i < n; i++){
        int b;cin >> b;
        for(int j=0; j<9; j++){
            if(b == a[j])a[j] = -1;
        }
    }
    bool yes = false;
    for (int i = 0; i < 3; i++)
    {
        if(a[i] == -1 && a[i+3] == -1 && a[i+6] == -1)yes = true;
        else if(a[3*i] == -1 && a[3*i+1] == -1 && a[3*i+2] == -1)yes = true;
    }
    if(a[0] == -1 && a[4] == -1 && a[8] == -1 || a[2] == -1 && a[4] == -1 && a[6] == -1)yes = true;
    if(yes)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3592
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/icl/interval_map.hpp>

#define REPI(i, S, N) for(int i=int(S); i<int(N); i++)
#define REP(i, N) REPI(i, 0, N)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::integer;

using ll = long long;
namespace bst = boost;
namespace icl = boost::icl;
template<typename T> class in {
    T value;
public:
    in() { cin >> value; }
    operator const T&() const { return value; }
    operator T&() { return value; }
    in& operator=(T source) { value = source; return *this; }
};
template<> class in<string> : public string {
public:
    in() { cin >> *this; }
};
template<class T> class inseq : public T {
public:
    template<typename... Arg> inseq(Arg... arg) : T(forward<Arg>(arg)...) { for (auto&& i : *this) cin >> i; }
};
template<class T> using invec = inseq<vector<T>>;

auto solve() {
  in<ll> X, K, D;

  __int128 nx = abs(X) % D, nk = abs(X) / D;
  if (nk > K)
    return (ll)(abs(X) - (__int128)K * D);
  else if ((K-nk) % 2 == 0){
    return (ll)nx;
  }
  else
    return (ll)abs(nx - D);
}

template<typename T> void plot(const T& func) { cout << setprecision(9) << func() << endl; }
template<> void plot<void()>(void(&func)()) { func(); }

int main() {
  plot(solve);

  return 0;
}




Measured memory_bytes: 3564
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
typedef pair<int,int> pii;
#define endl '\n'
#define F first
#define S second
const int MAX_N=2e5+5;

int n;
int h[MAX_N], a[MAX_N];
set<ll> st;
ll dp[MAX_N];

int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%d",&h[i]);
	for(int i=0;i<n;i++) scanf("%d",&a[i]);
	st.insert(0);
	set<ll>::iterator it, it2;
	for(int i=0;i<n;i++)
	{
		it=st.upper_bound(h[i]);
		it--;
		dp[h[i]]=max(dp[h[i]],dp[(*it)]+a[i]);
		it=st.insert(h[i]).F;
		it2=++it;
		while(it2!=st.end()&&dp[h[i]]>=dp[(*it2)]) it2++;
		st.erase(it,it2);
	}
	printf("%lld\n",dp[*st.rbegin()]);
	return 0;
}



Measured memory_bytes: 12800
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n;
string s;

int putq(int starti){
    cout<<"? ";
    for(int i=0;i<n;i++){
      cout<<((starti+i)%(2*n)+1)<<" ";
    }
    cout<<endl;
    cin>>s;
    if (s=="Blue"){
      return 1;
    }
    return 2;
}


int putq2(int starti){
    cout<<"? ";
    for(int i=0;i<n-1;i++){
      cout<<((starti+i)%(2*n)+1)<<" ";
    }
    cout<<endl;
    cin>>s;
    if (s=="Blue"){
      return 1;
    }
    return 2;
}





int main(){
  ll ans=0;
  cin >> n;

  
  vi a(n*2);


  
  string ms="";




//2分岐探索
    int end=n;
    int srt=0;
    int mid;
    int srtcol=putq(0);
    int endcol=3-srtcol;
    int midcol=0;
    //2分岐？でSUM i～n-1までのリダクション
    for(int j=0;;j++){
      mid=(srt+end)/2;
      midcol=putq(mid);
      if (srtcol==midcol){
        srt=mid;
      }else{
        end=mid;
      }
      if ((end-srt)==1)break;
    }


    



  if (endcol==1){
    a[(end+n-1)%(2*n)]=1;
    a[srt]=2;
  }else{
    a[(end+n-1)%(2*n)]=2;
    a[srt]=1;
  }





/*
  int idx=-1;
  REP(j,n+1){
    ms=s;
    if ((ms!=s)&(ms!=""))
    {
      if (s=="Blue"){
        a[(i+j+n*2-1)%(2*n)]=1;
        a[(i+j+n-1)%(2*n)]=2;
      }else{//blue
        a[(i+j+n*2-1)%(2*n)]=2;
        a[(i+j+n-1)%(2*n)]=1;
      }
      idx=i+j;
      break;
    }
  }
  */



  int idx=end;
  int dindx=idx;
  idx+=n;
  idx%=2*n;
  for(int i=0;i<n-1;i++){
    
    cout<<"? ";
    REP(j,n-1){
      cout<<((dindx+j)%(2*n)+1)<<" ";
    }
    cout<<(idx+1)<<" ";
    cout<<endl;
    cin>>s;
    
    if (s=="Blue"){
      a[idx]=1;
    }else{//red
      a[idx]=2;
    }

    idx++;
    idx%=2*n;
    
  }



  idx=dindx;
  dindx+=n;
  dindx%=2*n;

  for(int i=0;i<n-1;i++){
    
    cout<<"? ";
    REP(j,n-1){
      cout<<((dindx+j)%(2*n)+1)<<" ";
    }
    cout<<(idx+1)<<" ";
    cout<<endl;
    cin>>s;
    
    if (s=="Blue"){
      a[idx]=1;
    }else{//red
      a[idx]=2;
    }

    idx++;
    idx%=2*n;
    
  }




  //答え
  cout<<"! ";
  REP(i,n*2){
    if (a[i]==1)cout<<"B";
    if (a[i]==2)cout<<"R";
  }
cout<<endl;





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

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

int D[6];
void spin(char c)
{
    if(c=='E'){
        swap(D[0],D[3]);swap(D[3],D[5]);swap(D[5],D[2]);
    }
    else if(c=='W'){
        swap(D[0],D[2]);swap(D[2],D[5]);swap(D[5],D[3]);
    }
    else if(c=='S'){
        swap(D[0],D[1]);swap(D[0],D[4]);swap(D[4],D[5]);
    }
    else if(c=='N'){
        swap(D[0],D[1]);swap(D[1],D[5]);swap(D[5],D[4]);
    }
}


int main() {
    int q, a, b;
    char SWS[10] = {"SSSSWSSSS"};
    for (int i = 0; i < 6; i++)cin >> D[i];
    cin >> q;
    for (int i = 0; i < q; i++) {
        cin >> a >> b;

        for (int i = 0; i < 10; i++) {
            if (D[1] == b)break;
            spin(SWS[i]);
        }

        for (int i = 0; i < 4; i++) {
            if (D[0] == a) { cout << D[2] << endl;break; }
            spin('W');
        }
    }
    return 0;
}

Measured memory_bytes: 1160
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<P> Graph;

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

  ll k;
  cin >> k;
  
  cout << 50 << endl;
  
  ll num[50];
  ll a = k/50;
  ll b = k % 50;
  REP(i,50){
    num[i] = 49 + a - b;
  }
  
  REP(i,b){
    num[i] += 51;
  }
  
  REP(i,50){
    cout << num[i] << " ";
  }
  
  cout << endl;

  return 0;
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<string,int>;

const int MOD = 1e9 + 7;

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

    int a, b;
    cin >> a >> b;

    if(a % b != 0) {
        cout << a << endl;
    }else{
        cout << -1 << endl;
    }

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <random>
#include <chrono>
#include <tuple>
#include <random>
#include <cmath>

using namespace std;

typedef long long ll;
typedef long double ld;
#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

const ll SIZE = 1e6 * 2 + 10, INF = 1e9 * 1e9 + 10, eps = 1e-7;



int main()
{
    fastInp;

    ll n; ld d;
    cin >> n >> d;

    ll cnt = 0;
    for (int i = 0; i < n; i++) {
        ld x, y;
        cin >> x >> y;
        if (sqrt((x * x) + (y * y)) <= d + eps) cnt++;
    }

    cout << cnt;
    
    return 0;
}

Measured memory_bytes: 3828
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

void showArray(int a[], int n) {
    for (int i=0; i<n; i++) {
        cout << a[i];
    } cout << endl;
}

void showString(string s) {
    for (int i=0; i<s.size(); i++) {
        cout << s[i];
    }
    cout << endl;
}

void showReverse(string s) {
    for (int i=s.size(); i>=0; i--) {
        cout << s[i];
    }
    cout << endl;
}

int main() {
    string s;
    getline(cin, s);
    if (s.size() == 2) {
        cout << s[0] << s[1] << endl;
    } else {
        // showReverse(s);
        cout << s[2] << s[1] << s[0] << endl;
    }

    // if (s.length() == 3) {
    //     swap(s[0], s[2]);
    // }
    // cout << s << endl;

    return 0; 
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

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

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

	int N=in();
	string S=in<string>();
	array<int,26> F[2];
	int maxS = 0;
	REP(i,N){
		fill(ALL(F[0]),0);
		for(int j=0;j<i;j++){
			F[0][S[j]-'a']++;
		}
		fill(ALL(F[1]),0);
		for(int j=i;j<N;j++){
			F[1][S[j]-'a']++;
		}
		int sum = 0;
		for(int j=0;j<26;j++){
			if(F[0][j] && F[1][j]) sum++;
		}
		maxS = max(maxS,sum);
	}
	
	cout << maxS << endl;
	return 0;
}


Measured memory_bytes: 256
x = 0
max_value = [0]

n = int(input())
s = input()

list = [i for i in s]

for j in list:
    if j == 'I':
        x += 1
        max_value.append(x)
    else:
        x -= 1
        max_value.append(x)
print(max(max_value))

Measured memory_bytes: 3060
#include<stdio.h>
#include<string.h>
long long bao[100005];
int main(){
	long long n,k,i;
	while(scanf("%lld%lld",&n,&k)!=EOF){
		memset(bao,0,sizeof(bao));
		long long a,b,max=0;
		for(i=0;i<n;i++){
			scanf("%lld%lld",&a,&b);
			bao[a]+=b;
			if(a>max)
				max=a;
		}
		for(i=0;i<=max;i++){
			if(bao[i]==0)
				continue;
			if(k<=bao[i]){
				printf("%lld\n",i);break;
			}
			else{
				k-=bao[i];
			}
		}
	
	}
	return 0;
}

Measured memory_bytes: 896
#include<cstdio>
#include<iostream>
using namespace std;
int n,a[200];
int main()
{
	cin>>n;
	for (int i = 0 ; i < n ; i++)
		scanf("%d",&a[i]);

int ans = 0;
	for (int i = 0 ; i < n ; i++)
	{

		int x = a[i];

		for (int j = i; j < n ; j++)
		{
			int y = a[j];

			for (int k = j; k < n ; k++)
			{
				int z = a[k];
				if (x != y && x != z && y != z)
				{
					if (x + y > z && x + z >  y && y + z > x) ans++;
				}
			}
		}
	}

	cout<<ans<<endl;
	


return 0;
}

Measured memory_bytes: 3752
import collections

N = int(input())

A = list(map(int, input().split()))
count = collections.Counter(A)
d = dict(count)
total =0
for j in count.items():
    total +=(j[1])*(j[1]-1)/2
    d[j[0]] = (j[1]-1)

for i in A:
    print(int(total - d[i]))

Measured memory_bytes: 27452
S = list(reversed(input()))

length = len(S)

a = [0]*length
for i in range(length):
    pickup = int(S[i])
    a[i] = pickup*pow(10, i, 2019)

b = [0]*(length+1)
for i in range(1, length+1):
    b[i] = (b[i-1] + a[i-1]) % 2019
cnt, ans = [0] * 2019, 0
for x in b:
    ans += cnt[x]
    cnt[x] += 1

print(ans)

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

int main() {
    //ifstream cin("e.in");

    int n, m; cin >> n >> m;
    
    vector<vector<int>> g(n), c(n);

    for(int i = 0; i < m; ++i) {
        int x, y; cin >> x >> y;
        x -= 1, y -= 1;
        g[x].push_back(y);
        g[y].push_back(x);

        c[x].push_back(i);
        c[y].push_back(i);
    }

    vector<vector<int>> state(n, vector<int> (n, -1));
    vector<int> bad(n, 0);

    for(int i = 0; i < n; ++i) {
        state[i][i] = m + 1;

        queue<int> q;
        q.push(i);
        
        while(not q.empty()) {
            int node = q.front();
            q.pop();

            for(int j = 0; j < int(g[node].size()); ++j) {
                int v = g[node][j];
                if(c[node][j] >= state[i][node])
                    continue;
                if(state[i][v] >= 0 and c[node][j] != state[i][v]) {
                    bad[i] = 1;
                    break;
                }
                if(state[i][v] == -1) {
                    state[i][v] = c[node][j];
                    q.push(v);
                }
            }

            if(bad[i]) {
                break;
            }
        }
    }
    
    int ans = 0;

    for(int i = 0; i < n; ++i) {
        for(int j = i + 1; j < n; ++j) {
            if(bad[i] or bad[j])
                continue;
            bool good = true;
            for(int k = 0; k < n; ++k) {
                if(state[i][k] >= 0 and state[j][k] >= 0 and state[i][k] != state[j][k]) {
                    good = false;
                    break;
                }
            }

            if(good)
                ans += 1;
        }
    }

    cout << ans << "\n";
}

Measured memory_bytes: 3200
while line = gets

    line = line.chomp.split(" ").map(&:to_i)
        menber = line[0]
        winner = line[1]
        houseEdge  = line[2]
    
    data = []
    
    menber.times{
        
        line = gets
        data << line.chomp.to_i
        
    }
    
    if data == []
        break
    else 
    end 
    
    if data[winner-1] == 0 
        puts 0 
    else 
        puts ((data.inject(:+))*(100-houseEdge))/data[winner-1]
    end 
    
end

Measured memory_bytes: 8636
n, m = map(int, input().split())
x = sorted(list(map(int, input().split())))

if n >= m or m == 1:
    print(0)
else:
    move = sorted([x[i] - x[i - 1] for i in range(1, m)])

    ans = sum(move[:-n + 1]) if n > 1 else sum(move)
    print(ans)


Measured memory_bytes: 13968
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<bitset>
#include<sstream>
#include<list>
#include<climits>

using namespace std;
#define rep(i,i0,n) for(int i=(i0);i<(int)(n);++i)
typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vii;
typedef long long ll;


int main(){
    int n,m;
    cin>>n>>m;
    ll x[1010],y[1010],z[1010];
    rep(i,0,n)cin>>x[i]>>y[i]>>z[i];
    ll ret=0;
    rep(a,0,2)rep(b,0,2)rep(c,0,2){
        int e1=(int)pow(-1,a), e2=(int)pow(-1,b),e3=(int)pow((-1),c);
        vector<ll> t(n);
        rep(i,0,n)t[i]=e1*x[i]+e2*y[i]+e3*z[i];
        sort(t.begin(),t.end(),greater<ll>());
        ll tmp=0;
        rep(i,0,m)tmp+=t[i];
        ret=max(ret,tmp);
    }
    cout<<ret<<endl;
	return 0;
}



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

int main(){
  string s; cin >> s;
  int res = 0;
  int curr = 0;
  for(int i = 0; i < 3; i++){
    if(s[i] == 'R')curr++;
    else curr = 0;
    res = max(res, curr);
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3592
#include<iostream>
#include<string>
using namespace std;
int main()
{
	string s;
	cin >> s;
	int count = 0;
	for (int i = 0; i < s.size()-1; i++){
		if (s[i] != s[i + 1])
			count++;
	}
	cout << count << endl;
}

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

using namespace std;

int N;
int p[300005];

bool check(int l, int r)
{
	if(r == N && p[r] == r) r--;
	//cout << l << " " << r << endl;
	if(l == r) return false;
	for(int i = l; i <= r; i++){
		if(p[i] < l || p[i] > r) return false;
	}
	for(int i = l+1; i <= r; i += 2){
		if(p[i] != i) return false;
	}
	
	vector<int> mov, rem;
	for(int i = r; i >= l; i -= 2){
		if(p[i] < i) mov.push_back(p[i]);
		else rem.push_back(p[i]);
	}
	for(int i = 0; i < (int)mov.size()-1; i++){
		if(mov[i] < mov[i+1]) return false;
	}
	for(int i = 0; i < (int)rem.size()-1; i++){
		if(rem[i] < rem[i+1]) return false;
	}
	return true;
}

int main(void)
{
	cin >> N;
	for(int i = 1; i <= N; i++) cin >> p[i];
	for(int i = 1; i <= N; i++){
		if(p[i]%2 != i%2){
			cout << "No" << endl;
			return 0;
		}
	}
	
	int pre = 0;
	for(int i = 1; i <= N; i++){
		if(pre == 0){
			if(p[i] == i) continue;
			else pre = i;
		}
		else{
			if(p[i] == i && p[i-1] == i-1 && i >= 2){
				if(!check(pre, i-2)){
					cout << "No" << endl;
					return 0;
				}
				pre = 0;
			}
			if(p[i] != i && p[i-1] != i-1 && i >= 2){
				if(!check(pre, i-1)){
					cout << "No" << endl;
					return 0;
				}
				pre = i;
			}
		}
	}
	if(pre && !check(pre, N)) cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 2620
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
	string s, t, r;
	int n, a, b;
	cin >> s >> n;
	for (int i = 0; i < n; i++) {
		cin >> t >> a >> b;
		if (t == "print")
			cout << s.substr(a, b - a + 1) << endl;
		else if (t == "reverse")
			for (int j = 0; j < (b - a + 1) / 2; j++)
				swap(s[a + j], s[b - j]);
		else {
			cin >> r;
			s.replace(a, b - a + 1, r);
		}
	}
}

Measured memory_bytes: 1224
using System;

namespace abc070b
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);
            int c = int.Parse(input[2]);
            int d = int.Parse(input[3]);

            if (d < a || b < c)
            {
                Console.WriteLine(0);
                return;
            }

            int start = Math.Max(a, c);
            int end = Math.Min(b, d);

            Console.WriteLine(end - start);
        }
    }
}

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

using namespace std;


typedef pair <long long ,long long>	PII;
typedef vector <int>	VI;
typedef vector <PII>    VII;
typedef priority_queue<PII,vector<PII>,greater<PII>> pairMinHeap;
typedef priority_queue<PII> pairMaxHeap;
typedef priority_queue<long long ,vector<long long>,greater<long long>> minHeap;
typedef priority_queue<long long> maxHeap;

#define what_is(x) cerr <<#x<<" is "<<x<<endl;
#define wis(x,y) cerr <<#x<<" is "<<x<<" and "<<#y<<" is "<<y<<endl;
#define getarr(n,d) for(int i=0;i<n;i++)cin>>d[i];
#define getgraph(n,g) for(int i=1;i<n;i++){int a,b;cin>>a>>b;a--;b--;g[a].push_back(b);g[b].push_back(a);}
#define getpartree(n,tree) for(int i=1;i<n;i++){int a;cin>>a;tree[a-1].push_back(i);}

struct POS{
    int x=0,y=0;
    POS():x(0),y(0){}
    POS(int _x,int _y):x(_x),y(_y){}
};

struct triple{
    int f,s,t;
    triple():f(0),s(0),t(0){}
    triple(int _f,int _s,int _t):f(_f),s(_s),t(_t){}
};

const int INF = 1e9+9;
const long long LINF = 1e17+9;
const long long MD=998244353 ;

inline long long po(long long a,long long b){
    long long ans=1;
    while(b>0){
        if(b&1)ans = (ans*a)%MD;
        a = (a*a)%MD;
        b/=2;
    }
    return ans;
}


const int N=1e5+33;

long long n,m,k,t;
long long arr[N];
string s;


int main() {
	ios_base::sync_with_stdio(false);cout.tie(nullptr);cin.tie(nullptr);cout << fixed;cout << setprecision(10);
    cin>>s;
    string w = "keyence";
    if(s.size()<w.size()){cout<<"NO";return 0;}
    int i=0;
    for(;i<w.size();i++){
        if(s[i]!=w[i])break;
    }
    int h=w.size()-i;
    if(h==0){
            cout<<"YES";
            return 0;

    }
    for(int j=0;j<h;j++){
        if(s[s.size()-j-1]!=w[w.size()-j-1])break;
        if(j==h-1){
            cout<<"YES";
            return 0;
        }
    }

    cout<<"NO";

    return 0;
}


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

int main () {
  int a;
  int b;
  cin >> a >> b;
  int c = (a + b) % 2;
  if (c == 1) {
  cout << (a + b) / 2 + 1 << endl;
  }
  else {
   cout << (a + b) / 2 << endl;
  }
}

Measured memory_bytes: 3596