akhauriyash/Code-Regression huggingface dataset:
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define PI 3.14159265358979323846264338327950L

#define YESNO(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

#define int long long

template<typename A, size_t N, typename T>

void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//ここにグローバル変数宣言

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//ここに関数宣言




//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
signed main(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int K,S;
cin>>K>>S;
int cnt =0;

FOR(X,0,K)FOR(Y,0,K){
	if ((S-X-Y)>=0 && (S-X-Y)<=K){ cnt++;}
}

cout<<cnt<<endl;




return 0;

}


Measured memory_bytes: 3648
import java.util.Scanner;


public class Main {
	
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner s = new Scanner(System.in);
		int A = s.nextInt();
		int B = s.nextInt();
		int C = s.nextInt();
		int X = s.nextInt();
		
		int count = 0;
		for(int i = 0;i <= A;i++){
			for(int j = 0;j <= B;j++){
				for(int k = 0;k <= C;k++){
					if(i*500 + j*100 + k*50 == X){
						count++;
					}
				}
			}
		}
		System.out.println(count);
		
	}
	
}

Measured memory_bytes: 23764
#include<cstdio>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<sstream>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
struct qaq{
    int x,y,step;
    qaq(int a,int b,int c):x(a),y(b),step(c){}
};
char mmp[1005][1005];
bool vis[1005][1005];
int h,w,n,startx,starty,cur,nex[4][2]={0,1,0,-1,1,0,-1,0};
int bfs(int x,int y)
{
    queue<qaq> que;
    vis[x][y]=true;
    que.push(qaq(x,y,0));
    while(!que.empty()){
        qaq q=que.front();
        que.pop();
        for(int i=0;i<4;i++){
            int tx=q.x+nex[i][0];
            int ty=q.y+nex[i][1];
            if(tx<0||tx>=h||ty<0||ty>=w||vis[tx][ty]||mmp[tx][ty]=='X')
                continue;
            if(mmp[tx][ty]=='0'+cur){
                while(!que.empty()) que.pop();
                memset(vis,0,sizeof(vis));
                cur++;
                vis[tx][ty]=true;
                que.push(qaq(tx,ty,q.step+1));
                if(cur==n+1) return q.step+1;
                break;
            }
            vis[tx][ty]=true;
            que.push(qaq(tx,ty,q.step+1));
        }
    }
}
int main()
{
    cur=1;
    scanf("%d%d%d",&h,&w,&n);
    for(int i=0;i<h;i++){
        scanf("%s",mmp[i]);
        for(int j=0;j<w;j++){
            if(mmp[i][j]=='S') startx=i,starty=j;
        }
    }
    printf("%d\n",bfs(startx,starty));
    return 0;
}

Measured memory_bytes: 5196
#include<iostream>
#include<cmath>
using namespace std;
const int mod=1e9+7;
int jieshu(int k,int n)
{
    int count=0,i,j=1;
    for(i=1; ;i++)
    {
        j=j*k;
        if(j>n) break;
        count+=n/j;
    }
    count+=1;
    return count;
}
int prime(int p)
{
    int o,j;
    if(p==1||p==4) j=2;
    if(p==2||p==3) j=1;
    if(p>=5)
    {
        o=sqrt(p);
        for(int i=2;i<=o;i++)
        {
            if(p%i==0) {j=2;break;}
            else if(i>=o) j=1;
        }
    }
    return j;
}
int main()
{
    int n,g,s;
    long long sum;
    while(cin>>n)
    {
        sum=1;
       for(g=1;g<=n;g++)
       {
           s=prime(g);
           if(s==1)
           {
               sum*=jieshu(g,n);
               sum=sum%mod;
           }
       }
       cout<<sum<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll mod = 1000000007;

ll r(ll x, ll y) {
  if (y == 0) return 1;
  else if (y % 2 == 0) return r(x, y/2) * r(x, y/2) % mod;
  else return x * r(x, (y-1)/2) % mod * r(x, (y-1)/2) % mod;
}
  
int main() {
  double d;
  cin >> d;
  cout << 2 * d * 3.1415 <<endl;
} 


Measured memory_bytes: 3788
import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;


public class Main {
    static final int UNCALC = -1;
    static int n;
    static int[] memo;
    static int[] h;

    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        n = sc.nextInt();
        h = sc.nextIntArray(n);
        memo = new int[n];
        Arrays.fill(memo, UNCALC);
        out.println(dp(0));
        out.flush();
        out.close();

    }

    static int dp(int i) {
        if (i == n - 1) return 0;
        if (memo[i] != UNCALC) return memo[i];
        int min = dp(i + 1) + Math.abs(h[i + 1] - h[i]);
        if (i < n - 2) min = Math.min(min, dp(i + 2) + Math.abs(h[i + 2] - h[i]));
        return memo[i] = min;
    }


    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream system) {
            br = new BufferedReader(new InputStreamReader(system));
        }

        public Scanner(String file) throws Exception {
            br = new BufferedReader(new FileReader(file));
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public String nextLine() throws IOException {
            return br.readLine();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }

        public char nextChar() throws IOException {
            return next().charAt(0);
        }

        public Long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public boolean ready() throws IOException {
            return br.ready();
        }

        public void waitForInput() throws InterruptedException {
            Thread.sleep(3000);
        }

        public int[] nextIntArray(int n) throws IOException {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public Integer[] nextIntegerArray(int n) throws IOException {
            Integer[] a = new Integer[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

    }
}

Measured memory_bytes: 44268
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         sort(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7

void solve() {
  string s; cin >> s;
  int li = s.find('A');
  int ri = s.rfind('Z');
  outl(ri - li + 1);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 888
import java.util.*;
import java.lang.Math;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
        int n = sc.nextInt();
      	int m = sc.nextInt();
      	int x = sc.nextInt();
      	long books[][] = new long[n][m+1];
      	long uv[] = new long[m];
      	int np = (int)Math.pow(2,n);
      	int prc;
      	int prc_min = -1;
      	int istack;
      	boolean nb[] = new boolean[n];
      	boolean con;
      
      	for(int i = 0;i < n; i++){
          for(int j = 0;j < m+1; j++){
            books[i][j] = sc.nextLong();
          }
        }
      
      	for(int i = 0;i < np; i++){
          istack = i;
          for(int j = 0; j < n && istack > 0;j++){
          	  if(istack%2 == 1) {
                nb[j] = true;
              }
          	  else nb[j] = false;
          	  istack /= 2;
          }
          Arrays.fill(uv,0);
          prc = 0;
       	  for(int j = 0; j < n;j++){
            if(nb[j]){
              prc += books[j][0];
              for(int k = 1; k < m+1; k++){
              	uv[k-1] += books[j][k];
              }
            }          
          }
          con = true;
          for(int j = 0;j < m && con;j++){
            if(uv[j] < x) con = false;
          }
          if(con){
            if(prc_min == -1 || prc_min > prc) prc_min = prc;
          }
        }
	  
      	System.out.println(prc_min);
	}
}

Measured memory_bytes: 38064
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { 
  INIT(){cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  string s; 
  cin >> s;

  map<char, int> m;
  REP(i, s.size()) m[s[i]]++;

  for(auto p : m) if(p.second != 1){
    cout << "no" << "\n";
    return 0;
  }
  cout << "yes" << "\n";

  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 REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n

typedef long long ll;

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<string> vs;

typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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;}

ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	bool b=true;
	string s;
	cin >> s;
	for(ll i=1;i<SIZE(s);i++){
		if(s[i]!='9') b=false;
	}
	if(b) cout << s[0]-'0'+(SIZE(s)-1)*9 << endl;
	else cout << s[0]-'0'-1+(SIZE(s)-1)*9 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
typedef long long ll;
using namespace std;
int main(void){
  ll n;
  cin >> n;
  for(ll i = 1; i <= 3500; i++){
    for(ll j = 1; j <= 3500; j++){
      ll num = i*j*n;
      ll den = 4*i*j-(i+j)*n;
      if(den <= 0) continue;
      if(num % den == 0){
        cout << i << " " << j << " " << num/den << endl;
        return 0;
      }
    }
  }
  return 0;
}

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

int main(void) {
    std::string str;

    std::cin >> str;
    std::for_each(str.crbegin(), str.crend(), [](const char& ch) {
        std::cout << ch;
    });
    std::cout << std::endl;

    return 0;
}

Measured memory_bytes: 1172
#include <bits/stdc++.h>
using namespace std;
#define ll long long 

const ll MOD = 1e9+7;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int n,k; cin >> n >> k;
	ll a[n];
	for(int i=0;i<n;i++) cin >> a[i];
	
	ll ans = LLONG_MIN, pro = 1;
	if(n == k) {
		for(int i=0;i<n;i++) {
			pro *= a[i]; pro %= MOD;
		}
		cout << ((pro+MOD)%MOD);
		return 0;
	}
	if(*max_element(a, a+n) < 0) {
		if(k&1) sort(a, a+n, greater<ll>());
		else sort(a, a+n);
		for(int i=0;i<k;i++) {
			pro *= a[i]; pro %= MOD;
		}
		cout << ((pro+MOD)%MOD);
		return 0;
	}
	
	vector<ll> pos, neg;
	for(int i=0;i<n;i++) {
		if(a[i] >= 0) pos.push_back(a[i]);
		else neg.push_back(a[i]);
	}
	sort(pos.rbegin(), pos.rend());
	sort(neg.begin(), neg.end());
	
	vector<ll> pospre, negpre;
	pospre.push_back(1);
	for(int i=0;i<pos.size();i++) {
		pospre.push_back((pos[i]*pospre.back())%MOD);
	}
	negpre.push_back(1);
	for(int i=0;i<neg.size();i++) {
		negpre.push_back((neg[i]*negpre.back())%MOD);
	}
	
	int pidx = min((int)pos.size(), k);
	int nidx = k-pidx;
	if(nidx&1) { ++nidx; --pidx; }
	while(nidx+2 <= neg.size() && pidx-2 >= 0 && (pos[pidx-1]*pos[pidx-2] < neg[nidx+1]*neg[nidx])) {
		nidx += 2; pidx -= 2;
	}
	ans = (pospre[pidx]*negpre[nidx])%MOD;
	ans += MOD; ans %= MOD;
	
	cout << ans;
}


Measured memory_bytes: 9508
def bugged(N: int, S: list)->int:
    not_ten = []
    not_ten_sum, ten_sum = 0, 0
    for s in S:
        if s % 10 == 0:
            ten_sum += s
        else:
            not_ten.append(s)
            not_ten_sum += s

    not_ten.sort()

    for s in not_ten:
        if not_ten_sum % 10 > 0:
            break
        not_ten_sum -= s

    return 0 if not_ten_sum == 0 else not_ten_sum + ten_sum


if __name__ == "__main__":
    N = int(input())
    S = [int(input()) for _ in range(N)]
    ans = bugged(N, S)
    print(ans)


Measured memory_bytes: 3060
function Main(input) {
    input = input.split("\n");
    var n = parseInt(input[0], 10);
    var h = input[1].split(" ");
    var b = 'Yes';
    for(var i = n - 1 ; i > 0; i--){
        if(h[i-1] - h[i] > 1){
            b = 'No';
            break;
        }else if(h[i-1] - h[i] == 1){
            h[i-1] = h[i-1] - 1;
        }
    }
	//出力
	console.log(b);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 17816
n,k = input().split()
hate = list(input().split())
exi = True
t = True

while True:
    for c in hate:
        t = True
        if c in list(n):
            t = False
            break
    if t:
        print(n)
        break

    intN = int(n) + 1
    n = str(intN)

Measured memory_bytes: 9156
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

string s;
stringstream ss;
int check;
int snum;

int judge(){
	int num;
	int tmp;
	int ans = 0;
	vector<int> vec;
	while(snum < s.size()){
		ss.clear(stringstream::goodbit);
		if(s[snum] == '[' && s[snum + 1] == '['){
			snum++;
			vec.push_back(judge());
			//cout << vec[vec.size()-1] << endl;
		}
		else if(s[snum] == '['){
			num = 0;
			snum++;
		}
		else if(s[snum] == ']' && s[snum + 1] == '['){
			snum++;
		}
		else if(s[snum] == ']' && s[snum + 1] == ']'){
			sort(vec.begin(),vec.end());
			for(int i = 0;i <= vec.size()/2;i++){
				ans += vec[i];
			}
			snum++;
			return ans;
		}
		else{
			num *= 10;
			ss << s[snum];
			ss >> tmp;
			num += tmp;
			if(s[snum + 1] == ']'){
				vec.push_back(num);
				if(s[snum + 2] == ']'){
					sort(vec.begin(),vec.end());
					for(int i = 0;i <= vec.size()/2;i++){
						ans += (vec[i]/2) + 1;
					}
				snum+=2;
				return ans;	
				}
			}
			snum++;
		}
	}
}

int main(){

	int n,ans;
	cin >> n;
	for(int i = 0;i < n;i++){
		check = 1;
		snum = 1;
		cin >> s;
		ans = judge();
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3272
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <bitset>
#include <math.h>
#include <iomanip>
#include <queue>
#define inp(X) cin >> X
#define out(X) cout << X << endl
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define SORT(A) sort(A.begin(),A.end())
using namespace std;

typedef long long int ll;
#define MOD 1000000007
#define INF 1000000001

int mem(vector<int> &dp, int i, int N, vector<int> S)
{
	if(dp[i]!=INF) return dp[i];
	int ret = INF;
	if(i<=N-2) ret = min(ret,mem(dp,i+1,N,S));
	if(i<=N-3) ret = min(ret,mem(dp,i+2,N,S));
	if(i<=N-4) ret = min(ret,mem(dp,i+3,N,S));
	if(S[i]==1) ret++;
	return dp[i]=ret;
}

int main(void) {
	int N;	
	inp(N);
	vector<pair<int,int>> A;
	rep(i,N) {
		int a;
		inp(a);
		A.push_back(make_pair(a,i+1));
	}
	SORT(A);
	rep(i,N){
		cout << A[i].second << ' ';
	}
	cout << endl;

}




Measured memory_bytes: 1780
import sys
import math
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res

N,K=LI()
LI()
print(1 + (N-K)//(K-1) + (1 if (N-K) % (K-1) else 0))


Measured memory_bytes: 14004
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define mod 1000000007
int main() { 
    ll n, d;
    cin >> n >> d;
    ll d2 = d * d;
    int ret = 0;
    for (int i = 0; i < n; i++) {
        ll x, y;
        cin >> x >> y;
        if (x * x + y * y <= d2) ret++;
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3560
fun main(args: Array<String>) {
    val (n, m) = readLine()?.split(" ")?.map(String::toInt) ?: return
    val a = readLine()?.split(" ")?.map(String::toLong)?.sorted() ?: return
    val b = 0.until(m).map {
        val (b, c) = readLine()?.split(" ")?.map(String::toLong) ?: return
        Pair(b, c)
    }.sortedBy { -it.second }

    var j = 0
    var r = b[j].first
    var t = 0L
    0.until(n).forEach { i ->
        val aa = a[i]
        val bb = if (r > 0L) {
            b[j].second
        } else {
            0L
        }
        if (aa > bb) {
            t += aa
        } else {
            r--
            if (r == 0L) {
                if (j + 1 < b.size) {
                    j++
                    r = b[j].first
                }
            }
            t += bb
        }
    }
    println(t.toString())
}


Measured memory_bytes: 101372
ans = {}
N = int(input())
for _ in range(N):
  S = input()
  if S in ans:
    ans[S] += 1
  else:
    ans[S] = 1
    
N = int(input())
for _ in range(N):
  S = input()
  if S in ans:
    ans[S] -= 1
  else:
    ans[S] = -1

maxans = 0
for key in ans.keys():
  maxans = max(maxans, ans[key])
print(maxans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, j, k) for(int i=j; i<=k; i++)
#define FFOR(i, j, k) for(int i=j; i<k; i++)
#define DFOR(i, j, k) for(int i=j; i>=k; i--)
#define bug(x) cerr<<#x<<" = "<<x<<'\n'
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
template <typename T> inline void read(T &x){
    char c;
    bool nega=0;
    while((!isdigit(c=getchar()))&&(c!='-'));
    if(c=='-'){
        nega=1;
        c=getchar();
    }
    x=c-48;
    while(isdigit(c=getchar())) x=x*10+c-48;
    if(nega) x=-x;
}
template <typename T> inline void writep(T x){
    if(x>9) writep(x/10);
    putchar(x%10+48);
}
template <typename T> inline void write(T x){
    if(x<0){
        putchar('-');
        x=-x;
    }
    writep(x);
}
template <typename T> inline void writeln(T x){
    write(x);
    putchar('\n');
}
#define taskname "C"
int n;
int k;
bool bad[10];
int d;
bool check(int x){
    while(x>0){
        if(bad[x%10]) return 0;
        x/=10;
    }
    return 1;
}
int main(){
    #ifdef Megumin
        if(fopen(taskname".inp", "r"))
            freopen(taskname".inp", "r", stdin);
    #endif // Megumin
    read(n);
    read(k);
    FOR(i, 1, k){
        read(d);
        bad[d]=1;
    }
    while(true){
        if(check(n)){
            write(n);
            return 0;
        }
        n++;
    }
}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
#if DEBUG
            ReadLine();
#endif
        }

        public void Solve(ConsoleInput cin)
        {
            int x = cin.ReadInt;

            if(x == 3 || x == 5|| x == 7)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }

    class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;

        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }

        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }

        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}


Measured memory_bytes: 11220
#include <iostream>
#include <string>
#include <cctype>

using namespace std;

struct Result {
        int value, p;
};

#define PARSER_DECL(name) \
        Result name (const string &s, int p)

PARSER_DECL(expr);
PARSER_DECL(term);
PARSER_DECL(factor);
PARSER_DECL(number);

PARSER_DECL(expr){
        Result r = term(s, p);
        while(s[r.p] == '+' || s[r.p] == '-'){
                Result q = term(s, r.p + 1);
                if(s[r.p] == '+'){
                        r.value += q.value;
                        r.p = q.p;
                }else if(s[r.p] == '-'){
                        r.value -= q.value;
                        r.p = q.p;
                }
        }
        return r;
}

PARSER_DECL(term){
        Result r = factor(s, p);
        while(s[r.p] == '*' || s[r.p] == '/'){
                Result q = factor(s, r.p + 1);
                if(s[r.p] == '*'){
                        r.value *= q.value;
                        r.p = q.p;
                }else if(s[r.p] == '/'){
                        r.value /= q.value;
                        r.p = q.p;
                }
        }
        return r;
}

PARSER_DECL(factor){
        Result r;
        if(s[p] == '('){
                r = expr(s, p + 1);
                ++r.p;
        }else{
                r = number(s, p);
        }
        return r;
}

PARSER_DECL(number){
        Result r;
        r.value = 0;
        r.p = p;
        while(isdigit(s[r.p])){
                r.value = (r.value * 10) + (s[r.p] - '0');
                ++r.p;
        }
        return r;
}

int main(){
        int n;
        cin >> n;
        while(n--){
                string s;
                cin >> s;
                s.resize(s.size() - 1);
                cout << expr(s, 0).value << endl;
        }
        return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll =  long long;
using P = pair<int,int>;
const int INF = 1001001001;
const int mod = 1000000007;


int main(){
    int v[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;
    cout << v[k - 1] << endl;
}


Measured memory_bytes: 256
// God put a smile upon your face <3

#include <bits/stdc++.h>

#define slld(longvalue) scanf("%lld", &longvalue)

#define ll long long
#define ull unsigned long long
#define pll pair < long long, long long >

#define fastio ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0)

#define pb push_back

#define bug printf("BUG\n")

#define mxlld LLONG_MAX
#define mnlld -LLONG_MAX

#define mxd 2e8
#define mnd -2e8

#define pi 3.14159265359

using namespace std;

bool check(ll n, ll pos)
{
	return n & (1LL << pos);
}

ll Set(ll n, ll pos)
{
	return n = n | (1LL << pos);
}

string s;

bool solve()
{
	for(auto it: s) for(auto jt: s) if(it != jt) return 1;

	return 0;
}

int main()
{
    ll i, j, k, l, m, n, o, r, q;
    ll testcase;
    ll input, flag, tag, ans;

//    freopen("input.txt", "r", stdin);

//    freopen("output.txt", "w", stdout);

    while(cin >> s)
    {
		if(solve()) cout << "Yes\n";
		else cout << "No\n";
    }


}





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

    using namespace std;

    #define int long long
    #define faster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
    #define cint int t;cin>>t;while(t--)
    #define rep(i,a,b) for(int i=a;i<b;i++)
    #define vint vector<int>
    #define all(v) (v).begin(), (v).end()
    #define pii pair<int,int>
    #define pb push_back

    int mod=1e9+7;

    int32_t main() {
        faster;

        int h,w;
        cin>>h>>w;

        char a[h][w];
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                cin>>a[i][j];
            }
        }

        queue<pair<int,int>> q;
        q.push({0,0});

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

        int fin[h][w];
        for(int i=0;i<h;i++) for(int j=0;j<w;j++) fin[i][j]=INT64_MAX;

        fin[0][0]=(a[0][0]=='#');
        int vis[h][w];
        for(int i=0;i<h;i++) for(int j=0;j<w;j++) vis[i][j]=0;

        vis[0][0]=1;

        while(!q.empty()){
            auto tmp=q.front();
            q.pop();


            for(int i=0;i<2;i++){
                int x=tmp.first+dx[i];
                int y=tmp.second+dy[i];
//                cout<<"hu";
//cout<<x<<" "<<y<<endl;
                if(x<h&&y<w){
//                    swap(x,y);
//                    cout<<"fhi";
                    if(vis[x][y]==0){
                        q.push({x,y});
                        vis[x][y]=1;
//                        cout<<"hu";
                    }
                    fin[x][y]=min(fin[x][y],(a[x][y]=='#')-(a[x][y]=='#'&&(a[tmp.first][tmp.second]=='#'))+fin[tmp.first][tmp.second]);
    //                fin[x][y]=max(fin[x][y],0LL);
                }
            }
        }

//        for(int i=0;i<h;i++){
//            for(int j=0;j<w;j++) cout<<fin[i][j]<<" ";
//            cout<<endl;
//        }
        cout<<fin[h-1][w-1]<<endl;
    }

Measured memory_bytes: 384
#include<iostream>
#include <algorithm>
#include<string>
#include <bitset>
#include <vector>
#include <functional>
#include <climits>
#include <iomanip>
#include <utility>
#include <stack>
#include <queue>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <numeric>
using namespace std;
using ll = long long;

typedef pair <int, int> pii;

int main()
{

	ll a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, ans = 0;
	string s, t;
	ll x[200005] = {}, y[200005] = {};
	cin >> a;
	cin >> b;
	cin >> c;
	if (a % 2 == 1)
	{
		d++;
	}
	else
	{
		e++;
	}
	if (b % 2 == 1)
	{
		d++;
	}
	else
	{
		e++;
	}
	if (c % 2 == 1)
	{
		d++;
	}
	else
	{
		e++;
	}
	if (d == 2)
	{
		ans++;
		if (a % 2 == 1)
		{
			a++;
		}if (b % 2 == 1)
		{
			b++;
		}if (c % 2 == 1)
		{
			c++;
		}
	}if (e == 2)
	{
		ans++;
		if (a % 2 == 0)
		{
			a++;
		}if (b % 2 == 0)
		{
			b++;
		}if (c % 2 == 0)
		{
			c++;
		}
	}
	d = -9999999999;
	d = max(max(a, b), c);
	if (d != a)
	{
		ans += (d - a) / 2;
	}if (d != b)
	{
		ans += (d - b) / 2;
	}
	if (d != c)
	{
		ans += (d - c) / 2;
	}



	cout << ans << endl;
	//cout <<  << endl;

	////std::cout << std::fixed;
	//cout << std::setprecision(20) << << endl;
	//cout << d+1 << endl;
	//cout << "" << endl;

	return 0;
}
//char型の文字数字は、-'0'で数値に変換できる
//accumulate(x, x + a, 0);//int型までの配列の合計
//memcpy(x, visited, sizeof(ll)*n);
//void kansuu(ll num, ll visited[10]) {}
//kansuu(1, zz);
//cout << setprecision(15) << v << endl;
//cout << char(z - 'a');
//log10(i) + 1 //10進数の桁数を取得

//int temp;
//for (int i = 0; i < n - 1; i++) {
//	for (int j = n - 1; j > i; j--) {
//		if (w[j - 1] < w[j]) {  /* 前の要素の方が大きかったら */
//			temp = w[j];        /* 交換する */
//			w[j] = w[j - 1];
//			w[j - 1] = temp;
//		}
//	}
//}

//最小公倍数
//ll x = a * b;
//ll tmp;
///* 自然数 a > b を確認・入替 */
//if (a<b) {
//	tmp = a;
//	a = b;
//	b = tmp;
//}
///* ユークリッドの互除法 */
//ll r = a % b;
//while (r != 0) {
//	a = b;
//	b = r;
//	r = a % b;
//}
//a = x / b;//答え

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

int64_t calcGCD(int64_t a, int64_t b)
{
	while (a)
	{
		b %= a;
		std::swap(a, b);
	}
	return b;
}

int64_t calcLCM(const int64_t a, const int64_t b)
{
	// if (a * b == 0) return 0;
	return a / calcGCD(a, b) * b;
}

int main()
{
	int64_t A, B;
	scanf("%lld%lld", &A, &B);
	printf("%lld\n", calcLCM(A, B));

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<numeric>
using namespace std;

int a[1500][1500];
int dp[1500][1500];
int main(void){
    int n,m;
    int maximum=0;
    cin>>n>>m;
        for(int i=0;i<n+1;i++){
        for(int j=0;j<m+1;j++){
            dp[i][j]=0;
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            cin>>a[i][j];
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(a[i][j]==1){
                dp[i][j]=0;            
            }
            else{
                dp[i][j]=min(dp[i-1][j],min(dp[i][j-1],dp[i-1][j-1]))+1;
                maximum=max(maximum,dp[i][j]);
            }
        }
    }
    
    cout<<maximum*maximum<<endl;

    return 0;
}



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

#define ll long long int
#define VI vector<ll>
#define lf(i,a,b) for(ll i=a;i<=b;i++)
ll k;
ll up(ll a,ll b)
	{	if(a%b==0)
			return a/b;
		else
			return (a/b)+1;
	}

ll fun(ll n)
	{	//cout<<(n)<<endl;
		return up((n-1),(k-1));
	}	
int main()
{	ll n;cin>>n>>k;
	ll ind;
	lf(i,1,n)
	{	ll a;cin>>a;
		if(a==1)
			ind=i;
	}
	ll mini=INT_MAX;
	lf(i,1,k)
	{	if((ind-k+i>=1) && ((ind+i-1)<=n))
			mini=min(mini,1+fun(ind-k+i)+fun(n-(ind+i-2)));
	}
	cout<<mini<<endl;
}

Measured memory_bytes: 3588
import itertools
import bisect

a = []
for i in range(3, 10):
    for j in itertools.product([3, 5, 7], repeat=i):
        if j.count(3) > 0 and j.count(5) > 0 and j.count(7) > 0:
            a.append(int("".join(map(str, j))))
a.sort()
n = int(input())
print(bisect.bisect_right(a, n))

Measured memory_bytes: 4108
//                          VIVEK UPADHYAY
//                          MANIT, BHOPAL(M.P)
/**********************************************************************************************/
/**********************************************************************************************/
//                        $$ JAB-TAK TODEGA NHI,
//                           TAB -TAK CHODEGA NHI :D
#include<iostream>
#include<algorithm>
#include<vector>
#include<list>
#include<cstdlib>
#include<unistd.h>
#include<string>
#include<cstring>
#include<stack>
#include<queue>
#include<utility>
#include<cmath>
#include<set>
#include<unordered_map>
#include<cstdio>
#include<map>
#include<numeric>
using namespace std;
#define F first
#define S second
#define mk(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define LINE cout<<"\n" ;
#define ok cout<<"ok\n" ;
#define dbg(x) cout<<#x<<" = "<<(x)<<"\n";
#define fill(A, VAL) memset(A, VAL, sizeof(A))
#define sz(a) ((int) a.size())
typedef long long ll;
const int MAXN = 2*1e5 + 10;
const int MAX = 1e7 + 1 ;
double pi = 3.1415926535897932384626433832795;
const ll inf=1e18 ;
ll mod = 998244353 ;
ll powr(ll a , ll b){ if(b==0) return 1LL ; ll x = powr(a,b/2) ; x = (x*x)%mod ; if(b%2) return ((a%mod)*x)%mod ; return x ;}
ll gcd(ll a , ll b){if(a==0) return b ; return gcd(b%a,a);}
int main () {
    string s ;
    cin >> s ;
    string ans = "keyence" ;
    int i =0 , j =0 ;
    bool flag = false;
    if(s[i]==ans[j]) {
        
        while(i < s.length() && j < ans.length() && s[i]==ans[j]){
            i++ ;
            j++ ;
        }
        if(j==ans.length())
            flag = true ;
    }
    for(i = 0 ; i < ans.length();i++) {
        int st = 0 ;
        j = 0;
        while(st < i && j < s.length() && ans[st]==s[j]){
            j++ ;
            st++ ;
        }
        if(st==i){
            int k =sz(ans) - 1;
            j = sz(s)- 1;
            while(k >= i && j >=0 && ans[k]==s[j]) {
                j--;
                k--;
            }
            if(k==i - 1){
                flag = true ;
                break ;
            }
        }
    }
    if(j==-1) flag = true ;
    if(flag) cout<<"YES\n" ;
    else cout<<"NO\n" ;
    return 0 ;
}
//zkeyzenceszkeyence


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int  b[50],j,i,x,t,n;
    float k,k2,sum[50],max,syo,y,r;
    while(1){
        max=-1;
        scanf("%d",&n);
        if(n==0)break;
        scanf("%f",&y);
        for(i=0;i<n;i++){
            scanf("%d %f %d",&b[i],&r,&t);
//          printf("%d\n",r);
            if(t==1){
                syo=r/100;
                sum[i]=10000*(1+y*syo);
            }
            if(t==2){
                syo=r/100;
                k=1+syo;
                k2=k;
//              printf("%f\n",k);
                for(j=0;j<y-1;j++){
                    k=k*k2;
                }
                sum[i]=10000*k;
            }
        }
        for(i=0;i<n;i++){
//          printf("%f\n",sum[i]);
            if(max<sum[i]){
                max=sum[i];
                x=b[i];
            }
        }
        printf("%d\n",x);
    }
    return 0;
}

Measured memory_bytes: 1060
#include<iostream>
#include<vector>
#include<cinttypes>
#include<algorithm>
#include<numeric>
class union_find {
//	std::vector <T>;
public:
	using value_type = std::int32_t;
private:
	std::vector<value_type> parent_, size_;

	std::vector<value_type> weight_;

public:
	union_find()
		:parent_{}, size_{}, weight_{} {}

	union_find(unsigned int n)
		: parent_{}, size_{}, weight_{}{
		
	/*
		data.resize(n);
		for (int i{}; i < data.size(); ++i)
			data[i] = i;
	*/
		parent_.resize(n);
		std::iota(std::begin(parent_), std::end(parent_), 0);

		size_.resize(n, 1);
		weight_.resize(n, 0);
	}

	auto root(value_type  x)->decltype(parent_)::value_type {
		//auto x = static_cast<const std::uint32_t>(index);
		if (parent_[x] == x)
			return x;
		else {
			auto r = root(parent_[x]);

			weight_[x] += weight_[ parent_[x] ];

			return parent_[x] = r;
		}
	}

	auto size(value_type  x) {
		return size_[root(x)];
	}

	auto unite(value_type  t, value_type s) {
//		std::cout << "unite:";
		auto x = root(t);
		auto y = root(s);
//		std::cout << x << " " << y << " ";
		if ( x == y )
			return;

		auto sx = size(x);
		auto sy = size(y);

		if (sx < sy)
			std::swap(x, y);

		if (sx == sy)
				++size_[ x ];

			parent_[x] = y;

	}

	auto same(value_type  t, value_type  s){
		return 
			root(t) == root(s);
	}

	
	auto weight(value_type  x) {
		root(x);
		return 
			this->weight_[x];
	}

	auto relate(value_type  t, value_type  s, value_type  weight_v) {

		auto rt = root(t);
		auto rs = root(s);
		if (rt == rs)
			return;


		weight_v += weight(t);//
		weight_v -= weight(s);

		auto st = size(rt);
		auto ss = size(rs);

		if (st < ss) {
			std::swap(st, ss);
			std::swap(rt, rs);
			weight_v *= -1;
		}

		if (st == ss)
			++size_[rt];
		
		parent_[rs] = rt;
		weight_[rs] += weight_v;
		size_[rt] += ss;
		

	}

	auto diff(value_type  t, value_type  s)->decltype(weight_)::value_type{
//		if (!this->same(t, s))
//			return -1;
//		else
			return weight_[s] - weight_[t];
	}

};

int main() {
	std::uint32_t n, q;
	std::cin >> n >> q;
	union_find uf{ n };

	for (std::uint32_t i{}; i < q; ++i) {
		int c, x, y;
		std::cin >> c >> x >> y;

		if (c == 0) {
			decltype(n) w;
			std::cin >> w;
//			uf.unite(x, y);
			uf.relate(x, y, w);
//			std::cout <<(uf.same(x, y) ? "yes" : "no" )<< "\n";
//			std::cout << uf.root(x) << " " << uf.root(y) << "\n";
//			std::cout <<"size: "<< uf.size(x) << " " << uf.size(y) << "\n";
//			std::cout << w << " " << uf.weight(x) << " " << uf.weight(y) << "\n";
		}
		else {
//			std::cout <<( uf.same(x, y) ? 1 : 0 )<< "\n";
//			std::cout <<"wght : " <<uf.weight(x) << " " << uf.weight(y) << "\n";
//			auto res = uf.diff(x, y);
			if (uf.same(x,y))
				std::cout << uf.diff(x, y) << "\n";
			else
				std::cout << "?\n";
			
		}
	}

}


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

using namespace std;


const int N=100005;


int dp[N];

int fuad[N];

int Apply_dp(int idx,int n)
{

   //  cout<<"idx "<<idx<<endl;

   if(idx==n-1)
    return 0;
    if(idx>=n)
        return 10e6;

    if(dp[idx]!=-1)
        return dp[idx];
    int r1=0,r2=0;

  if((idx+1)<n)
    r1=abs(fuad[idx]-fuad[idx+1]);

  if((idx+2)<n)
    r2=abs(fuad[idx]-fuad[idx+2]);
    r1+=Apply_dp(idx+1,n);
    r2+=Apply_dp(idx+2,n);


  return dp[idx]=min(r1,r2);
}


int main()
{


 // freopen("input.txt","r",stdin);

    int n;
    cin>>n;

    for(int i=0; i<n; ++i)
        cin>>fuad[i];

//        for(int i=0; i<n; ++i)
//        cout<<fuad[i]<<" ";
       // cout<<endl;

       memset(dp,-1,sizeof(dp));

    int result=Apply_dp(0,n);

    cout<<result<<endl;
    return 0;
}


Measured memory_bytes: 5760
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <array>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <random>
#include <chrono>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <sstream>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>

using namespace std;
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

const int MOD = 1e9 + 7;
class Modint {
public:
	long long val;

	Modint (long long _val = 0)
		: val((_val + MOD) % MOD) {}

	Modint operator+ (Modint other) {
		return Modint(val + other.val);
	}

	void operator+= (Modint other) {
		val += other.val;
		val %= MOD;
	}

	Modint operator- () {
		return Modint(MOD - val);
	}

	Modint operator- (Modint other) {
		return Modint(val + MOD - other.val);
	}

	void operator-= (Modint other) {
		val += MOD - other.val;
		val %= MOD;
	}

	Modint operator* (Modint other) {
		return Modint(val * other.val);
	}

	void operator*= (Modint other) {
		val *= other.val;
		val %= MOD;
	}

	bool operator== (Modint other) {
		return val == other.val;
	}

	bool operator!= (Modint other) {
		return val != other.val;
	}
};

Modint exp (Modint a, int k) {
	if (k == 0) {
		return Modint(1);
	} else if (k % 2 == 0) {
		Modint half = exp(a, k / 2);
		return half * half;
	} else {
		return a * exp(a, k - 1);
	}
}

Modint inv (Modint a) {
	return exp(a, MOD - 2);
}

ostream& operator<< (ostream& out, Modint p) {
	out << p.val;
	return out;
}


int main() {

	int n; cin >> n;
	vector<int> a(n + 2, 0); for (int i = 1; i <= n; i++) cin >> a[i];
	vector<Modint> suff(n + 2, 0); for (int i = n; i >= 1; i--) suff[i] = suff[i + 1], suff[i] += a[i];

	Modint ans = 0;
	for (int i = 1; i <= n; i++) {
		Modint curr = suff[i + 1] * a[i];
		ans += curr;
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 5572
/*
   Author : tarang
*/
#include<bits/stdc++.h>
#define ll long long
#define fastio ios_base::sync_with(false); cin.tie(0);cout.tie(0);
#define PI = acos(-1)
using namespace std ;
ll power(ll b,ll e,ll m)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b%m,e/2,m)%m;
    return power(b*b%m,e/2,m);
}
int main(){
	 ll m = 1000000007;
     ll n ; cin >> n ;
     vector<ll> v(n);
     for(ll i = 0 ; i < n ; i++){
     	cin >> v[i];
	 }
	 ll f[68] = {0};
//	 for(auto x:f) cout << x << " ";
//	 cout << endl;
	 for(ll i = 0 ; i < n ; i++){
	 	  for(ll j = 0 ; j < 61  ; j++){
	 	  	    if((v[i] & (1LL << j)))
	 	  	       f[j]++;
		   }
	 }
	// for(auto x :f) cout << x << " ";
	// cout << endl;
	 ll res = 0 ;
	 for(ll i = 0 ; i < 61 ; i++){
	 	  ll x = f[i];
	 	  ll z = (n-x);
	 	  ll ans = power(2 , i , m);
	 	  //cout << x << " " << z << " " << ans << endl;
	 	  ll ans2 = ( x % m * z % m) % m ;
	 	  ans2 = ( ans2 % m * ans%m) % m ;
	 	  res = ( res % m + ans2%m) %m ;
	 }
	 cout << (res)%m << endl;
}



Measured memory_bytes: 5520
from copy import deepcopy
from collections import deque

H, W = map(int, input().split())
S = [input() for _ in range(H)]

table = [[None] * W for _ in range(H)]
table[0][0] = (0 if S[0][0] == '.' else 1)

D = deque([(0, 0)])
new_D = deque()
while D:
    h, w = D.popleft()
    for dh, dw in ((1, 0), (0, 1)):
        if 0 <= h + dh < H and 0 <= w + dw < W and table[h + dh][w + dw] is None:
            if S[h + dh][w + dw] == S[h][w]:
                D.append((h + dh, w + dw))
                table[h + dh][w + dw] = table[h][w]
            else:
                new_D.append((h + dh, w + dw))
                table[h + dh][w + dw] = table[h][w] + 1
    if not D:
        D = deepcopy(new_D)
        new_D.clear()

print((table[H - 1][W - 1] + 1) // 2)


Measured memory_bytes: 3572
#from math import gcd
from fractions import gcd
from functools import reduce

def lcm(a,b):
    return a * b // gcd(a,b)
def ls_lcm(A):
    return reduce(lcm ,A)
def ls_gcd(A):
    return reduce (gcd, A)

def check_two(A):
    old = None
    for n in A:
        cnt = 0
        while(n & 1 == 0):
            cnt += 1
            n = n >> 1
        if old is None:
            old = cnt
        else:
            if old!=cnt:
                return False
    return True

N, M = map(int, input().split())
A = list(map(int, input().split()))
if not check_two(A):
    print (0)
    exit()
A = [a//2 for a in A]
half = ls_lcm(A)
print ((M + half) // (2*half))

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

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

    string s;
    cin >> s;
    int n = s.size();
    vector<vector<int> > dp(2, vector<int>(n));
    dp[0][n-1] = s[n-1] == '0';
    dp[1][n-1] = s[n-1] == '1';
    for (int i = n-2; i >= 0; --i) {
        dp[0][i] = (s[i] == '0')+dp[1][i+1];
        dp[1][i] = (s[i] == '1')+dp[0][i+1];
    }
    cout << min(dp[0][0], dp[1][0]) << "\n";
}

Measured memory_bytes: 1616
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
using P = pair<long long,long long>;

long long n,m,msize = 0;
vector<long long> memo,sum;
vector<P> v;
map<long long,long long> mp;

long long solve();

int main(){
    cin >> n >> m;
    v.resize(n);
    for(int i = 0;i < n;++i){
        cin >> v[i].fi >> v[i].se;
        memo.push_back(v[i].fi);
        memo.push_back(v[i].se);
    }
    sort(memo.begin(),memo.end());
    memo.erase(unique(memo.begin(),memo.end()),memo.end());
    msize = memo.size();
    for(int i = 0;i < msize;++i)mp[memo[i]] = i;
    cout << solve() << endl;
    return 0;
}

long long solve(){
    long long ans = 0,maxnum = 0,maxid = 0,ansc = -1;
    sum.assign(msize,0);
    for(int i = 0;i < n;++i){
        ++sum[mp[v[i].fi]];
        if(v[i].se != memo[memo.size()-1])--sum[mp[v[i].se]+1];
    }
    maxnum = sum[0];
    for(int i = 1;i < msize;++i){
        sum[i] += sum[i-1];
        if(sum[i] > maxnum || (sum[i] == maxnum && maxnum % 2)){
            maxid = i;
            maxnum = sum[i];
        }
    }
    ans = (maxnum - 1) * m;
    for(int i = 0;i < n;++i)
        if(v[i].fi <= memo[maxid] && memo[maxid] <= v[i].se){
            if(maxnum % 2){
                if(ansc == -1)ansc = v[i].se;
                else ansc = min(ansc,v[i].se);
            }
            else{
                if(ansc == -1)ansc = v[i].fi;
                else ansc = max(ansc,v[i].fi);
            }
        }
    if(maxnum % 2)ans += ansc;
    else ans += m - ansc;
    return ans;
}


Measured memory_bytes: 37356