akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
#define RF(x) freopen(x,"r",stdin)
#define WF(x) freopen(x,"w",stdout)
typedef long long LL;
using namespace std;
typedef pair<LL,LL> PLL;
typedef pair<int,int> PII;
const LL MOD = (LL)1e9+7;
const int MAXN = 1e5+5;
const LL INF = 1LL<<30;
const long double eps = 1e-10;
const double PI=3.1415926535897932;

vector<int> adj[100009];
int mm[100009][2];//parent taken,not taken.

int dp(int x,int f,int p=-1){
	if(mm[x][f]!=-1)return mm[x][f];
	mm[x][f]=0;
	int rangecan[SZ(adj[x])];
	int ccc=0;
	REP(ii,SZ(adj[x])){
		int i=adj[x][ii];
		if(i==p){
			rangecan[ii]=0;
			if(ii)rangecan[ii]+=rangecan[ii-1];
			continue;
		}
		ccc++;
		rangecan[ii]=dp(i,1,x);
		if(ii)rangecan[ii]+=rangecan[ii-1];
	}
	if(f==0){
		return mm[x][f]=(rangecan[SZ(adj[x])-1]==ccc);
	}
	else{
		REP(ii,SZ(adj[x])){
			int i=adj[x][ii];
			if(i==p)continue;
			int midv=dp(i,0,x);
			if(!midv)continue;
			int cv=1;
			if(ii)cv+=rangecan[ii-1];
			cv+=rangecan[SZ(adj[x])-1]-rangecan[ii];
			if(cv==ccc)return mm[x][f]=1;
		}
		return mm[x][f]=0;
	}
}

int main(){
	DRI(n);
	REP(i,n-1){
		DRII(a,b);a--;b--;
		adj[a].PB(b);
		adj[b].PB(a);
	}
	MS1(mm);
	if(dp(0,1))puts("Second");
	else puts("First");
}


Measured memory_bytes: 6656
#include<bits/stdc++.h>
using namespace std;
#define mx 1007
string a,b;
int dp[mx][mx];
bool visited[mx][mx];

void init(int n)
{
    for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
    {
        visited[i][j]=false;
    }
}

int lcs(int i,int j)
{
    if(i==a.size() || j==b.size())
    {
        return 0;
    }

    if(visited[i][j])return dp[i][j];

    int ans=0;
    if(a[i]==b[j])
        ans=1+lcs(i+1,j+1);
    else ans+=max(lcs(i+1,j),lcs(i,j+1));

    dp[i][j]=ans;
    visited[i][j]=true;
    return dp[i][j];
}

int main()
{


 int n;
 cin>>n;
 while(n--)
 {
     cin>>a>>b;
     init(max(a.size(),b.size()));
     cout<<lcs(0,0)<<endl;
 }






    return 0;
}



Measured memory_bytes: 8160
#include <bits/stdc++.h>
using namespace std;
int main()
{   string str;
	cin>>str;
	//int len=str.length();
	 if(str[0]=='Y' && str[1]=='A' && str[2]=='K' && str[3]=='I'){
	 	cout<<"Yes";
	 }
	 else {cout<<"No";}
    return 0;
}

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

using namespace std;

constexpr int MAXN = 100;

char N[MAXN + 2];

int main() {
	int K;
	cin >> N >> K;
	int n = strlen(N);
	if(n < K) {
		cout << 0 << '\n';
		return 0;
	}
	for(int i = 0; i < n; i++) N[i] -= '0';
	N[n] = 1;
	int ans = 0;
	if(K == 1) {
		ans += N[0];
		ans += (n - 1) * 9;
	} else if(K == 2) {
		int i = 1;
		while(!N[i]) i++;
		if(i < n) ans = N[i] + (n - 1 - i) * 9;
		ans += (N[0] - 1) * (n - 1) * 9;
		ans += (n - 1) * (n - 2) / 2 * 9 * 9;
	} else if(K == 3) {
		int i = 1, j;
		while(!N[i]) i++;
		if(i < n - 1) {
			j = i + 1;
			while(!N[j]) j++;
			if(j < n) {
				ans += N[j];
				ans += (n - 1 - j) * 9;
			}
			ans += (N[i] - 1) * (n - 1 - i) * 9;
			int k = n - 1 - i;
			ans += k * (k - 1) / 2 * 9 * 9;
		}
		ans += (N[0] - 1) * (n - 1) * (n - 2) / 2 * 9 * 9;
		ans += (n - 1) * (n - 2) * (n - 3) / 6 * 9 * 9 * 9;
	}
	cout << ans << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#define INF 1000000011
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main(){
  int n,m,s;
  cin >> n >> m;
  vector<int> a(m),b(m);
  vector<set<int>> c(m,set<int>());
  for(int i=0;i<m;i++){
    cin >> a[i] >> b[i];
    for(int j=0;j<b[i];j++){
      cin >> s; c[i].insert(s);
    }
  }
  vector<int> check(n);
  for(int i=0;i<m;i++){
    for(int j=0;j<n;j++){
      check[j]+=c[i].count(j+1);
    }
  }
  bool flag=false;
  for(int i=0;i<n;i++){
    if(!check[i]) flag=true;
  }
  if(flag){
    cout << -1 << endl;
    return 0;
  }
  int k=(1<<n);
  vector<P> p;
  for(int i=0;i<k;i++){
    int cnt=0;
    for(int j=0;j<n;j++){
      if(i&(1<<j)) cnt++;
    }
    p.push_back(P(cnt,i));
  }
  sort(p.begin(),p.end());
  vector<int> ans(k,INF);
  ans[0]=0;
  for(int i=1;i<k;i++){
    vector<int> l;
    for(int x=0;x<12;x++){
      if(p[i].second&(1<<x)) l.push_back(x+1);
    }
    int ls=l.size();
    for(int j=0;j<m;j++){
      bool check=true;
      for(int x=0;x<ls;x++){
        if(!c[j].count(l[x])){
          check=false;
        }
      }
      if(check) ans[p[i].second]=min(ans[p[i].second],a[j]);
    }
    for(int j=0;j<(1<<ls);j++){
      int y=0,z=0;
      for(int x=0;x<ls;x++){
        if(j&(1<<x)) y+=(1<<(l[x]-1));
        else z+=(1<<(l[x]-1));
      }
      ans[p[i].second]=min(ans[p[i].second],ans[y]+ans[z]);
    }
  }
  cout << ans[k-1] << endl;
}

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

int main() {
    string s;

    cin >> s;

    string ans = "No";

    if (s.at(2) == s.at(3)) {
        if (s.at(4) == s.at(5)) ans = "Yes";
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<stack>
#include<vector>
using namespace std;
class point {
public:
	int color;
	bool used;
	point():color(-1),used(false){}
};
int main() {
	int X, Y;
	int make[][2] = { {2,4},{4,2} };
	while (cin >> X >> Y&&X != 0) {
		vector<vector<point> > map(X + 2, vector<point>(Y + 2));
		int sx, sy, gx, gy;
		cin >> sx >> sy >> gx >> gy;
		int n;
		cin >> n;
		for (int i = 0; i < n; ++i) {
			int color, d, x, y;
			cin >> color >> d >> x >> y;
			for (int dx = 0; dx < make[d][1]; ++dx) {
				for (int dy = 0; dy < make[d][0]; ++dy) {
					map[x + dx][y + dy].color = color;
				}
			}
		}
		stack<pair<int, int> > st;
		if (map[sx][sy].color != -1) {
			st.push(pair<int, int>(sx, sy));
		}
		int mx[] = { 1,0,-1,0 }, my[] = { 0,1,0,-1 };
		while (!st.empty()) {
			pair<int,int> dummy = st.top(); st.pop();
			if (map[dummy.first][dummy.second].used)continue;
			map[dummy.first][dummy.second].used = true;
			for (int i = 0; i < 4; ++i) {
				int x = dummy.first + mx[i];
				int y = dummy.second + my[i];
				if (map[dummy.first][dummy.second].color == map[x][y].color&&map[x][y].used == false) {
					st.push(pair<int, int>(x, y));
				}
			}
		}
		cout << (map[gx][gy].used ? "OK" : "NG") << endl;
	}
	return 0;
}

Measured memory_bytes: 3080
N = int(input())
A = list(map(int,input().split()))

money=1000
stocks=0

for i in range(N): 
    if i==N-1:
        #売る
        money+=(A[i]*stocks)
        stocks=0
    elif A[i+1]>A[i]:
        #買う
        plus_stock,money=divmod(money,A[i])
        stocks+=plus_stock
    elif A[i+1]<A[i]:
        #売る
        money+=(A[i]*stocks)
        stocks=0
print(money)

Measured memory_bytes: 9204
#include <iostream>

int main(){
  int cnt[4] = {0};
  int sum = 0;
  char str;
  int n;
  
  std::cin >> n;
  for(int i=0;i<n;i++){
    std::cin >> str;
    if(str == 'P'){
    	cnt[0] = 1;
    }else if(str == 'W'){
    	cnt[1] = 1;
    }else if(str == 'G'){
    	cnt[2] = 1;
    }else if(str == 'Y'){
    	cnt[3] = 1;
    }
  }
  
  for(int i=0;i<4;i++){
    sum += cnt[i];
  }
  
  if(sum == 3)std::cout << "Three" << std::endl;
  else if(sum == 4)std::cout << "Four" << std::endl;
  
  return 0;
}
  

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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int f(int a) {
  return (a * a + 4) / 8;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int x, y, z; cin >> x >> y >> z;
  x -= z;
  cout << x / (y + z) << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

ll Pow(ll n,ll p){
	ll r=1;
	for(;p>0;p>>=1){
		if(p&1) r=(r*n)%mod;
		n=(n*n)%mod;
	}
	return r;
}

const int M=2000005;
ll F[M];

void Init(){
	F[0]=1;
	for(int i=1;i<M;i++) F[i]=F[i-1]*i%mod;
}

ll Div(ll n,ll m){
	return n*Pow(m,mod-2)%mod;
}

ll nCk(ll n,ll k){
	return Div(F[n],F[n-k]*F[k]%mod);
}

ll n,m,k;
vl a,b;

int main(){
	cin>>n>>m>>k;
	a=vl(n+1),b=vl(m+1);
	for(int i=1;i<=n;i++){
		cin>>a[i];
		a[i]+=a[i-1];
	}
	for(int i=1;i<=m;i++){
		cin>>b[i];
		b[i]+=b[i-1];
	}
	ll res=0;
	for(int i=0;i<=n;i++) if(a[i]<=k){
		res=max(res,(ll)i-1+(upper_bound(b.begin(),b.end(),k-a[i])-b.begin()));
	}
	cout<<res<<endl;
}

Measured memory_bytes: 6400
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class Main {

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    void solve() throws IOException {
        int n = ni();
        int[] s = nia(n);
        int q = ni();
        int[] t = nia(q);

        int ans = 0;
        for (int i = 0; i < q; i++) {
            int high = n;
            int low = -1;
            while (high - low > 1) {
                int mid = (high + low) / 2;
                if (s[mid] > t[i]) {
                    high = mid;
                } else {
                    low = mid;
                }
            }
            if (low != -1 && s[low] == t[i]) ans++;
        }

        out.println(ans);
    }

    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }

    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }

    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

Measured memory_bytes: 45812
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
int main(){
	double a=100000000,b=-1,n;
	while(scanf("%lf",&n)!=EOF)a=min(n,a),b=max(n,b);
	printf("%.10lf\n",b-a);
	return 0;
}

Measured memory_bytes: 1236
def one_clue(k,x):
    j = k
    y = []
    for i in range(k,k*3-1):
        j -= 1
        y.append(x - j)

    return y

if __name__ == '__main__':
    k,x = map(int,input().split())

    ans = one_clue(k,x)
    for i in range(len(ans)):
        print(ans[i],end=" ")
    print("")

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main()
{
   int i, h, m, s;
   cin >> i;
   h = i / 3600;
   m = (i / 60) % 60;
   s = i % 60;
   cout << h << ":" << m << ":" << s << endl; 
   
   return 0;
}


Measured memory_bytes: 3084
#include<iostream>
using namespace std;
int main() {
	int H, W;
	 
	while (cin >> H >> W) {
		if (H == 0 && W == 0) {
			return 0;
		}else{
			 for (int i = 0; i < H; i++) {
				for (int j = 0; j < W; j++) {
					cout << "#";
				}cout << endl;
			 }cout << endl;
		}
	}
}

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

int main() {

  int N;
  cin >> N;
  vector<int> A(N);
  bool p = false,m = false;
  long long sum = 0;
  for(int i = 0;i < N;i++) {
    cin >> A.at(i);
    if(A.at(i) > 0) p = true;
    if(A.at(i) < 0) m = true;
    sum += A.at(i);
  }

  sort(A.begin(),A.end());
  if(p && !m) {
    cout << sum - A.at(0)*2 << endl;
    for(int i = 1;i < N-1;i++) {
      cout << A.at(0) << " " << A.at(i) << endl;
      A.at(0) -= A.at(i);
    }
    cout << A.at(N-1) << " " << A.at(0) << endl;
  }else if(!p && m) {
    reverse(A.begin(),A.end());
    cout << sum*(-1) + A.at(0)*2 << endl;
    for(int i = 1;i < N;i++) {
      cout << A.at(0) << " " << A.at(i) << endl;
      A.at(0) -=  A.at(i);
    }
  }else {
    int num = 0;
    sum = 0;
    for(int i = 0;i < N;i++) {
      if(A.at(i)<0) sum -= A.at(i);
      else sum += A.at(i);
      if(i < N-1 && A.at(i) < 0 && A.at(i+1) >= 0) num = i;
    }
    cout << sum << endl;

    for(int i = num+1;i < N-1;i++) {
      cout << A.at(num) << " " << A.at(i) << endl;
      A.at(num) -= A.at(i);
    }
    
    for(int i = 0;i <= num;i++) {
      cout << A.at(N-1) << " " << A.at(i) << endl;
      A.at(N-1) -= A.at(i);
    }
  }



}


Measured memory_bytes: 2304
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
	int n,m,k;
	cin>>n>>m>>k;
	for(int i=0;i<=n;i++){
		for(int j=0;j<=m;j++){
			if((j*(n-i))+(i*(m-j))==k){
				cout<<"Yes"<<endl;
				return 0;
			}
		}
	}
	cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
s = input()
n = len(s)
cnt = 0
now = s[0]
for i in range(1,n):
    if s[i] != now:
        cnt+=1
        now = s[i]
    
    
    


ans = cnt
cnt = 0
now = s[-1]
for i in range(n-2,-1,-1):
    if s[i] != now:
        cnt+=1
        now = s[i]
ans = min(cnt,ans)
print(ans)
    

Measured memory_bytes: 3188
# -*- coding: utf-8 -*-
# 整数の入力
n = int(input()) # Skip first line
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
point=sum(b)
# print("Point",point)
for i in range(n-1):
    if a[i] + 1 == a[i + 1]:
        point = point + c[a[i]-1]
print(point)   

exit(0)

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

public class Main{
    final static String alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".toLowerCase();//.toCharArray();
    static class FastReader{
        BufferedReader br;
        StringTokenizer st;
        public FastReader(){br = new BufferedReader(new InputStreamReader(System.in));}
        String next(){while (st == null || !st.hasMoreElements()){try{st = new StringTokenizer(br.readLine());}catch (IOException  e){e.printStackTrace();}}return st.nextToken();}
        int nextInt(){return Integer.parseInt(next());}
        long nextLong(){return Long.parseLong(next());}
        double nextDouble(){return Double.parseDouble(next());}
        int[] readArray(int n){int[] a=new int[n];for (int i=0; i<n; i++) a[i]=nextInt();return a;}
        long[] readLongArray(int n){long[] a=new long[n];for (int i=0; i<n; i++) a[i]=nextLong();return a;}
        String nextLine(){String str = "";try{str = br.readLine();}catch (IOException e){e.printStackTrace();}return str;}
    }
    static int getGcd(int n1,int n2){
        while(n1 != n2){
            if(n1 > n2) n1 -= n2;
            else n2 -= n1;
        }
        return n1;
    }
    static boolean isSorted(int[] arr, int n){
        for(int i=1;i<n;i++){
            if(arr[i]<arr[i-1]) return false;
        }
        return true;
    }
    static boolean isPrime(long n){
        if(n==2) return true;
        else if(n%2==0) return false;
        for(int i=3;i<=n/2;i+=2){
            if(n%i==0) return false;
        }
        return true;
    }
    static boolean isPrime(int n){
        if(n==2) return true;
        else if(n%2==0) return false;
        for(int i=3;i<=n/2;i+=2){
            if(n%i==0) return false;
        }
        return true;
    }
    static void printArray(int[] arr){
        for(int x:arr){
            System.out.print(x+" ");
        }
        System.out.println();
    }
    static long Fact(int n){
        //int p=1000000007;
        long result = 1;
        for (int i = 1; i <= n; i++) result = (result*i);
        //for (int i = 1; i <= n; i++) result = (result*i)%p;
        return result;
    }
    static final Random random=new Random();
    static void ruffleSort(int[] a) {
        int n=a.length;//shuffle, then sort
        for (int i=0; i<n; i++) {
            int oi=random.nextInt(n), temp=a[oi];
            a[oi]=a[i]; a[i]=temp;
        }
        Arrays.sort(a);
    }
    public static void main(String[] args) throws NumberFormatException, IOException {
        FastReader s = new FastReader();
        PrintWriter pw = new PrintWriter(System.out,true);
        int n=s.nextInt();
        int[] a = s.readArray(n);
        long sum=0;
        for(int i=1;i<n;i++){
            if(a[i]<a[i-1]){
                sum+=a[i-1]-a[i];a[i]=a[i-1];
            }
        }pw.println(sum);
    }
}

Measured memory_bytes: 54952
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
# define mod 1000000007
# define INF (1 << 29)
# define MAX_N 1000010
/* ACはうれCすぎてうれD */
 
int main(void){ 
    int n,k;
    cin >> n >> k;
    vector<int> v;
    for(int i=0; i<n; i++){
        int tmp_v;
        cin >> tmp_v;
        v.push_back(tmp_v);
    }
 
    int ans = 0;
    for(int a=0; a<=min(n,k); a++){
        for(int b=0; b<=min(n-a,k-a); b++){
            vector<int> get;
            int tmp_ans = 0;
 
            for(int i=0; i<a; i++){
                tmp_ans += v[i];
                get.push_back(v[i]);
            }

            for(int i=1; i<=b; i++){
                tmp_ans += v[n-i];
                get.push_back(v[n-i]);
            }
 
            sort(get.begin(), get.end());
            int size_g = get.size();
            
 
            for(int i=0; i<min(size_g, k-(a+b)); i++){
                if(get[i] < 0){
                    tmp_ans -= get[i]; 
                }
            }

            if(tmp_ans > ans) ans = tmp_ans;
        }
    }
    cout << ans;
    return 0;
}

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

int a, b, ans;
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> a >> b;
    a < b ? ans = 0 : ans = 10;
    cout << ans << "\n";
    return 0;
}

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

using namespace std;
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    double L;
    cin >> L;
    L /= 3;
    cout << L*L*L << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pii pair<int,int>
const long long MOD=1e9+7;

int main() {
    long long n,k;
    cin>>n>>k;
    vector<int> A(n);
    rep(i,n){
        cin>>A[i];
        A[i]--;
    }
    vector<int> see(n,-1);
    queue<int> que;
    que.push(0);
    long long pre=-1,roop=-1;
    long long dep=0;
    while(!que.empty()){
        int q=que.front();
        que.pop();
        if(see[q]!=-1){
            if(pre==-1) pre=see[q];
            if(roop==-1) roop=dep-see[q];
            continue;
        }
        see[q]=dep;
        que.push(A[q]);
        dep++;
    }
    //cout<<pre<<" "<<roop<<endl;
    if(k>=pre) k=pre+(k-pre)%roop;
    //cout<<k<<endal<<endl;
    rep(i,n) if(see[i]==k) cout<<i+1<<endl;
;    return 0;
}

Measured memory_bytes: 4844
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <math.h>
#include <bits/stdc++.h>

#define INF (1ll<<60)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;

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

template<class T>bool umax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool umin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using namespace std;

// gcd
template<typename T>
T gcd(T a, T b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}

// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);

    return result;
}

template<typename T>
T lcm( T m, T n )
{
    // 引数に0がある場合は0を返す
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;

    return ((m/gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}


// sort big to small
// sort(A,A+N, greater<int>());

// v.front() = -BOUND;
// v.back() = BOUND;

// Iterator
// v.begin
// v.end

int main(){
    ll N,M;
    ll ans=0;
    cin >> N >> M;
    ans=1900*M+100*(N-M);

    while(M>0){
        ans*=2;
        M--;
    }

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



Measured memory_bytes: 256
while 1:
    lists,pla = [],[]
    x,y,count = 10,10,0
    n = int(input())
    if n==0:break
    for i in [0]*n:
         s = list(map(int, input().split()))
         lists.append(s)
    for i in [0]*int(input()):
        way,num = input().split()
        if way=="N":[pla.append([x,y+i]) for i in range(1,int(num)+1)]
        elif way=="S":[pla.append([x,y-i]) for i in range(1,int(num)+1)]
        elif way=="E":[pla.append([x+i,y]) for i in range(1,int(num)+1)]
        elif way=="W":[pla.append([x-i,y]) for i in range(1,int(num)+1)]
        x,y = pla[-1]
    for i in lists:
        if i in pla:count +=1
    if count==n:print("Yes")
    else:print("No")

Measured memory_bytes: 7660
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <random>

using namespace std;

#define int long long

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

    int n;
    cin >> n;
    vector<pair<int, int>> a;
    for (int i = 0; i < n; i++) {
        int l, r;
        cin >> l >> r;
        a.push_back({l, r});
    }
    int res = 0;
    auto tryy = [&](vector<pair<int, int>> ord) {
        ord.push_back({0, 0});
        int cpos = 0;
        int ans = 0;
        for (auto t : ord) {
            int l, r;
            tie(l, r) = t;
            if (l <= cpos && cpos <= r) {
                //
            } else if (cpos <= l) {
                ans += abs(cpos - l);
                cpos = l;
            } else {
                ans += abs(cpos - r);
                cpos = r;
            }
        }
        res = max(res, ans);
    };
    vector<pair<int, int>> ord;
    {
        vector<int> ind1(n);
        iota(ind1.begin(), ind1.end(), 0);
        vector<int> ind2 = ind1;
        sort(ind1.rbegin(), ind1.rend(), [&](int i, int j) {
            return a[i].first < a[j].first;
        });
        sort(ind2.begin(), ind2.end(), [&](int i, int j) {
            return a[i].second < a[j].second;
        });
        set<int> hv;
        for (int i = 0; i < 2 * n; i++) {
            int v = -1;
            if ((i & 1)) {
                v = ind2[i / 2];
            } else {
                v = ind1[i / 2];
            }
            if (!hv.count(v)) {
                hv.insert(v);
                ord.push_back(a[v]);
            }
        }
        tryy(ord);
        hv.clear();
        ord.clear();
        for (int i = 0; i < 2 * n; i++) {
            int v = -1;
            if (!(i & 1)) {
                v = ind2[i / 2];
            } else {
                v = ind1[i / 2];
            }
            if (!hv.count(v)) {
                hv.insert(v);
                ord.push_back(a[v]);
            }
        }
        tryy(ord);
    }
    
    cout << res << endl;
}   


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

using namespace std;

long long h,c,t;
long long f(long long mid){
  return mid*(h+c-2*t) +h -t;
}
void solve()
{
  int a , b, c, d, e;
  cin >> a >> b>> c>> d>>e;
  if (b >d && (long long)(b-d)*e >= abs(a-c))
    cout<<"YES\n";
  else cout << "NO\n";
}
int main()
{
  int t;
  t =1;
  while(t--)
  {
    solve();
  }
}


Measured memory_bytes: 3636
S = input()
A = tuple(S)
N = len(A)
ans = 1
ind = 1
pr = A[0:1]
while ind <= N - 3:
    if len(pr) == 2:
        pr = A[ind:ind + 1]
        ans += 1
        ind += 1
        continue
    if pr == A[ind:ind + 1]:
        pr = A[ind:ind + 2]
        ans += 1
        ind += 2
    else:
        pr = A[ind:ind + 1]
        ans += 1
        ind += 1
if N <= 2:

    if N == 1:
        ans = 1
    else:
        if A[0] == A[1]:
            ans = 1
        else:
            ans = 2
elif ind == N - 1:
    ans += 1

else:
    if pr == A[-2:] or pr == A[-2:-1]:
        ans += 1
    elif A[-2] == A[-1]:
        ans += 1
    else:
        ans += 2
print(ans)

Measured memory_bytes: 4968
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>

#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007

using namespace std;

int main(void){
  int x,y,a,b,c;
  cin >> x >> y >> a >> b >> c;
  vector<ll> p(a),q(b),r(c);
  rep(i,a)cin >> p[i];
  rep(i,b)cin >> q[i];
  rep(i,c)cin >> r[i];
  sort(p.begin(),p.end());
  sort(q.begin(),q.end());
  sort(r.begin(),r.end());

  ll ans = 0;
  rep(i,x)ans += p[a-1-i];
  rep(i,y)ans += q[b-1-i];
  int cura = a-x,curb = b-y; 
  rep(i,c){
    if(cura != a && curb != b){
     if(p[cura] <= q[curb] && p[cura] < r[c-1-i]){
      ans += r[c-1-i]-p[cura];
      cura++;
     }
     else if(curb != b && q[curb] < p[cura] && q[curb] < r[c-1-i]){
      ans += r[c-1-i]-q[curb];
      curb++;
     }
    }
    else if(cura != a){
      if(p[cura] < r[c-1-i]){
	ans += r[c-1-i]-p[cura];
	cura++;
      }
    }
    else{
      if(q[curb] < r[c-1-i]){
	ans += r[c-1-i]-q[curb];
	curb++;
      }
    }
  }

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


Measured memory_bytes: 2560
n = int(input())
count = 0

def prime(m):
    for t in range(2,int(m**(1/2))+1):
        if m % t == 0:
            return False
    return True

for i in range(n):
    k = int(input())
    if k != 2 and k % 2 == 0:
        continue
    
    if prime(k):
        count += 1

print(count)


Measured memory_bytes: 5660
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<stack>
using namespace std;

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

int main() {
	string s;
	int K;
	cin >> s >> K;

	int len = s.length();
	REP(i, len) {
		if (s[i] == 'a') continue;
		else if (s[i] - 'a' + K >= 26) {
			K -= (26 - (s[i] - 'a'));
			s[i] = 'a';
		}
	}
	if (K > 0) {
		s[len - 1] = (s[len - 1] - 'a' + K) % 26 + 'a';
	}


	cout << s << endl;
	return 0;
}

Measured memory_bytes: 512
def main():
    N = int(input())
    S = input()
    X = int(S, 2)
    C = S.count('1')
    xc0 = X % (C + 1)
    xc1 = X % (C - 1) if C > 1 else 0
 
    def f(x):
        c = 0
        while x:
            c += 1
            x = x % bin(x).count('1')
        return c
 
    for i, s in enumerate(S):
        k = N - 1 - i
        if s == '0':
            print(f((xc0 + pow(2, k, C + 1)) % (C + 1)) + 1)
        else:
            if C > 1:
                print(f((xc1 - pow(2, k, C - 1)) % (C - 1)) + 1)
            else:
                print(0)
 
 
main()

Measured memory_bytes: 9284
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

short int t[5001][5001];
int main() {
  int n, m;
  cin >> n >> m;
  REP(i,m) {
    int a, b, x;
    cin >> a >> b >> x;
    a--;b--;
    t[a][b] = max((int)t[a][b], x+1);
  }
  int ans = 0;
  REP(i,n) {
    REP(j,i+1) {
      if (t[i][j] > 0) ans++;
      t[i+1][j] = max((int)t[i+1][j], t[i][j]-1);
      t[i+1][j+1] = max((int)t[i+1][j+1], t[i][j]-1);
    }
  }
  cout << ans << endl;
}

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

using namespace std;
typedef long long ll;

#define rep(i , j , n) for(long long i = j ; i <= n ; i++)
const int N = 123456;
double a[N];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll n;

    double t , h;

    cin >> n >> t >> h;

    rep(i , 1 , n) {
        cin >> a[i];
    }

    int ind = -1;

    rep(i , 1 , n) {
        double temp = t - (a[i] * 0.006);
        a[i] = temp;
    }

    double maxi = INT_MAX;
    rep(i , 1 , n) {
        if(abs(a[i] - h) <= maxi) {
            maxi = abs(a[i] - h);
            ind = i;
        }
    }

    cout << ind << endl;

    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
from itertools import permutations,  combinations, accumulate
from functools import *
from collections import deque, defaultdict, Counter
from heapq import heapify, heappop, heappush, heappushpop

INF = float('inf')
NIL = - 1


N, M = map(int, input().split())
jobs = [[] for _ in range(M + 1)]
for _ in range(N):
    a, b = map(int, input().split())
    if a <= M:
        jobs[M - a].append(b)

heap = []
for day in range(M + 1):
    for job in jobs[day]:
        if len(heap) < day + 1:
            heappush(heap, job)
        else:
            heappush(heap, job)
            heappop(heap)

print(sum(heap))


Measured memory_bytes: 62640
# AOJ ALDS1_4_C Dictionary
# Python3 2018.7.3 bal4u

import sys
from sys import stdin
input = stdin.readline

dic = {}
n = int(input())
for i in range(n):
	s = input()
	if s[0] == 'i': dic[s[7:]] = 1
	else: print("yes" if s[5:] in dic else "no")


Measured memory_bytes: 33716
#include <iostream>

using namespace std;

const int MOD = 1000000007;
long long fr[2001];
int main(){
	
	long long n,k;
	cin>>n>>k;
	int a[n];
	long long res = 0;
	for(int i =0;i<n;i++){
		cin>>a[i];
		fr[a[i]]++;
		long long ma = 0;
		//cout<<i<<endl;
		for(int j = a[i]+1;j<=2000;j++)ma += fr[j];
		//cout<<i<<endl;
		res = (res + ma*k)%MOD;
	}
	long long s = 0;
	long long sk = (k * (k-1) /2)%MOD;
	for(int i=1;i<=2000;i++){
		res  = (res + fr[i] * s * sk) %MOD;
		s+=fr[i];
	}
	cout<<res<<endl;
		
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,k;
    cin>>n>>k;
    vector<vector<int> > input(n,vector<int>(2));
    for(int i=0;i<n;++i){
        cin>>input[i][0]>>input[i][1];
    }
    ll inf=LONG_LONG_MAX;
    int max_value=1e5+1;
    vector<vector<ll> > dp(n+1,vector<ll>(max_value,inf));
    dp[0][0]=0;
    for(int i=1;i<=n;++i){
        for(int j=0;j<max_value;++j){
            int weight=input[i-1][0];
            int value=input[i-1][1];
            if(j-value>=0){
                dp[i][j]=min((dp[i-1][j-value]!=inf?dp[i-1][j-value]+weight:inf),dp[i-1][j]);
            }
            else{
                dp[i][j]=dp[i-1][j];
            }
        }
    }
    int ans=-1;
    for(int i=max_value-1;i>=0;--i){
        if(dp[n][i]<=k){
            ans=i;
            break;
        }
    }
    cout<<ans;
    cout<<endl;
}


Measured memory_bytes: 83176
n = int(input())
p = list(map(int, input().split()))
cnt = 0

for i in range(1, n-1):
    if p[i - 1] <= p[i] < p[i + 1] or p[i + 1] <= p[i] < p[i - 1]:
        cnt += 1
print(cnt)

Measured memory_bytes: 3060
from collections import deque

n,u,v=map(int, input().split())
G=[[] for _ in range(n+1)] # 隣接リスト

for i in range(n-1):
    a,b=map(int, input().split())
    G[a].append(b)
    G[b].append(a)
    
def dfs(x,n): # 再帰じゃない DFS かく(DFSでもBFSでもどっちでも同じか)
    stack=deque([x])
    dist=[-1]*(n+1)
    dist[x]=0
    
    while len(stack)>0:
        a=stack.pop()
        for k in G[a]:
            if dist[k]<0:
                dist[k]=dist[a]+1
                stack.append(k)
    return dist # リストを返している

distt=dfs(u,n) # u高橋くんからの最短距離
dista=dfs(v,n) # v青木くんからの最短距離

ans=0
for i in range(1,n+1):
    if distt[i] < dista[i]:
        ans=max(ans,dista[i]-1)
print(ans)

Measured memory_bytes: 64492
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;
#define maxn 200005
typedef long long LL;
#define pi pair<LL,LL> 
#define fir first
#define sec second
#define mp make_pair
vector<pi> A[maxn];
int father[maxn],son[maxn][2],a[maxn],n;
LL ans;
bool flag[maxn];
pi t1[maxn],t2[maxn];

inline int read(void) 
{
	int x=0;
	char ch=getchar();
	while (ch>'9'||ch<'0') ch=getchar();
	while (ch>='0'&&ch<='9') 
	{
		x=x*10+ch-'0';
		ch=getchar();
	}
	return x;
}

void insert(int u,pi tmp) 
{
	int siz=A[u].size();
	if (siz==0) {A[u].push_back(tmp);return;}
	if (A[u][siz-1].sec<=tmp.sec) return;
	A[u].push_back(tmp);
}

bool dfs(int u,LL limit) 
{
	if (!flag[u]) 
	{
		A[u].push_back(mp(0,0));
		return 1;
	}
	int s1=son[u][0],s2=son[u][1];
	if (!dfs(s1,limit)) return 0;
	if (!dfs(s2,limit)) return 0;
	int tot1=0,tot2=0;	
	int siz1=A[s1].size();
	int siz2=A[s2].size();
	for (int i=0;i<siz1;i++) A[s1][i].fir+=a[s1],A[s1][i].sec+=a[s1];
	for (int i=0;i<siz2;i++) A[s2][i].fir+=a[s2],A[s2][i].sec+=a[s2];
	int p;
	p=siz2-1;
	for (int i=siz1-1;i>=0;i--) 
	{
		while (p>=0&&A[s1][i].sec+A[s2][p].fir>limit) p--;
		if (p<0) break;
		t1[++tot1]=mp(A[s1][i].fir,A[s2][p].sec);
	}
	p=siz1-1;
	for (int i=siz2-1;i>=0;i--) 
	{
		while (p>=0&&A[s2][i].sec+A[s1][p].fir>limit) p--;
		if (p<0) break;
		t2[++tot2]=mp(A[s2][i].fir,A[s1][p].sec);
	}
	reverse(t1+1,t1+tot1+1);
	reverse(t2+1,t2+tot2+1);
	int p1=1,p2=1;
	while (p1<=tot1&&p2<=tot2) 
		if (t1[p1]<=t2[p2]) insert(u,t1[p1]),p1++;
		else insert(u,t2[p2]),p2++;
	while (p1<=tot1) insert(u,t1[p1]),p1++;
	while (p2<=tot2) insert(u,t2[p2]),p2++;
	return A[u].size()>0;
}

int main()
{
	n=read();
	for (int i=2;i<=n;i++) 
	{
		father[i]=read();
		flag[father[i]]?son[father[i]][1]=i:son[father[i]][0]=i;
		flag[father[i]]=1;
		a[i]=read();
	}
	LL L=0,R=1e10;
	while (L<=R) 
	{
		LL mid=(L+R)>>1;
		for (int i=1;i<=n;i++) A[i].clear();
		if (dfs(1,mid)) 
		{
			ans=mid;
			R=mid-1;
		}
		else L=mid+1;
	}
	printf("%lld\n",ans);
	return 0;
}

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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
using ld = long double;
ll mod = 1000000007;

int main() {
    ll n, k;
    cin >> n >> k;
    ll a[n];
    rep(i, n) { cin >> a[i]; }
    rep(i, k) {
        ll temp[n + 1] = {};
        rep(j, n) {
            ll index_min = max(0LL, j - a[j]);
            ll index_max = min(j + a[j] + 1, n);
            temp[index_min]++;
            temp[index_max]--;
        }

        a[0] = temp[0];
        repd(j, 1, n) { a[j] = a[j - 1] + temp[j]; }

        bool all_n = true;
        rep(j, n) {
            if (a[j] != n) {
                all_n = false;
            }
        }
        if (all_n) {
            break;
        }
    }

    rep(i, n) { cout << a[i] << " "; }
    cout << endl;
    return 0;
}



Measured memory_bytes: 6696
#include <bits/stdc++.h>
// #include "bits:stdc++.h"
using namespace std;
#define LLINF 1234567890987654321
#define ph push
#define ins insert
#define db 0
#define f first
#define s second
typedef long long ll;
typedef pair <ll, ll> pi;
typedef pair <ll, pi> spi;
map <ll, ll> mp;
ll n, m, ans, A[100001], sum[100001];
void make_sum(ll i)
{
	if(i==0)sum[i] = A[i];
	else sum[i] = sum[i-1] + A[i];
}
ll get_sum(ll x, ll y)
{
	if(x == 0)return sum[y];
	else return sum[y] - sum[x-1];
}
int main()
{
	cin >> n >> m;
	for(ll i = 0; i < n; i++)cin >> A[i];
	for(ll i = 0; i < n; i++)make_sum(i);
	mp[0] = 1;
	for(ll i = 0; i < n; i++)
	{
		ll sum = get_sum(0, i);
		ans += mp[sum%m];
		mp[sum%m]++;
	}
	cout << ans << '\n';
}


Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
const int mex=1000001;
#define ll long long 
#define test int t;cin>>t;while(t--)
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fo(i,a,n) for(int i=a;i<n;i++)
#define rfo(i,a,b) for(int i=a;i>=b;i--)
#define bg begin()
#define en end()
#define fi first
#define se second
#define ub upper_bound
#define lb lower_bound
#define pb push_back
#define veci vector<int>
#define veclli vector<long long int> 
#define all(x) x.begin(),x.end()
#define sci(x) scanf("%d",&x);
#define scc(x) scanf("%c",&x);
#define scs(x) scanf("%s",x);
#define debug(arr,n) for(int i=0;i<n;i++) printf("%d ",arr[i]);
#define sz(x) x.size()
#define loop(x) for(auto it=x.begin();it!= x.end();it++) 
ll int power(ll int a,int b)
{
    ll int ans=1,f=a;
    while(b)
    {
        if(b&1) ans=(ans*f)%mod;
        f=(f*f)%mod;
        b=b>>1;
    }
    return ans%mod;
}
int main()
{
    fast
  int n;
  cin>>n;
 ll int arr[n];
 vector<pair<int,int> > v[n+1];
 fo(j,0,n)
 {cin>>arr[j];
 int tp=arr[j];
 for(ll int i=2;i*i<=arr[j];i++)
 {
     int cnt=0;
     while(tp%i==0)
     {
         tp=tp/i;
         cnt++;
     }
     if(cnt) v[j].pb({i,cnt});
 }
 if(tp!=1) v[j].pb({tp,1});
 }
int mp[mex]={0},ans1[n+1];
fo(i,0,n+1)
ans1[i]=1;
 fo(i,0,n)
 {
    // cout<<'#'<<i<<" ";
     fo(j,0,sz(v[i]))
     {
        // cout<<v[i][j].fi<<" "<<v[i][j].se<<"  ";
         ans1[i]=(ans1[i]*power(v[i][j].fi,v[i][j].se))%mod;
         mp[v[i][j].fi]=max(mp[v[i][j].fi],v[i][j].se);
     }
     //cout<<endl;
 }
 ll int ans=1;
 vector<pair<int,int> > v2;
 fo(i,0,mex)
 {
     if(mp[i])
     {v2.pb({i,mp[i]});
     ans=(ans*power(i,mp[i]))%mod;
     //cout<<i<<" "<<mp[i]<<"  ";
     }
     
 }
 ans%=mod;
 ll int sum=0;
 fo(i,0,n)
 {
    // cout<<arr[i]<<" ";
    ll int an=(ans*power(arr[i],mod-2))%mod;
    sum+=an;
   // cout<<an<<" ";
    sum%=mod;
 }
 cout<<sum;
}


Measured memory_bytes: 5248
#include<iostream>
#include<string>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int count_alpha[4][4];
	for (int i = 0; i<4; i++)
	{
		for (int j = 0; j<4; j++)
		{
			count_alpha[i][j] = 0;
		}
	}

	for (int i = 0; i<4; ++i)
	{
		for (int j = 0; j<4; ++j)
		{
			if (s[i] == s[j])
			{
				++count_alpha[i][j];//自分と絶対一緒になるからそれはノーカン
			}
		}
	}
	int flug = 1;
	for (int i = 0; i<4; ++i)
	{
		int all = 0;
		for (int j = 0; j<4; ++j)
		{
			all += count_alpha[i][j];
		}
		if (all != 2)
		{
			cout << "No";
			flug = 0;
			break;

		}
		
	}
	if (flug == 1)
	{
		cout << "Yes";
	}
	return 0;
}

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

#define rep(X,N) for(ll X = 0LL; X < (N); X++)
#define ALL(V) (V).begin(),(V).end()
#define endl "\n"

using namespace std;
typedef long long ll;

const double PI = 3.1415926535897932384626;
const ll MODN = 1000000007;
const ll MODN2 = 998244353;
const double EPS = 1e-10;

int main(){

    int n, k;
    cin >> n >> k;

    vector<int> a(n);

    rep(i, n) cin >> a[i];

    int ng = 0;
    int ok = 1000000000;

    while(ok - ng > 1){
        int tmp = (ok + ng) / 2;
        int count = 0;

        rep(i, n){
            count += ((a[i] + tmp - 1) / tmp) - 1;
        }

        if(count <= k){
            ok = tmp;
        }else{
            ng = tmp;
        }
    }

    cout << ok << endl;

    return 0;
}


Measured memory_bytes: 3940
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {in_n: isize, in_m: isize, in_a: [isize; in_n]};
    let s = in_a.iter().fold(0, |s, x| s + x);
    let t = (s + (4 * in_m) - 1) / (4 * in_m);
    let mut count = 0;

    for a in in_a {
        if a < t {
            continue;
        }

        count += 1;
    }

    if count < in_m {
        println!("No");
    } else {
        println!("Yes");
    }
}


Measured memory_bytes: 2168
N = int(input())
S = input()
b = [0]*N
w = [0]*N
ans = []
for n in range(N):
    if S[n] == '#':
        if n == 0:
            b[n] = 1
        else:
            b[n] = b[n-1] +1
    else:
        if n == 0:
            b[n] = 0
        else:
            b[n] = b[n-1]

    if S[N-1-n] == '.':
        if N-1-n == N-1:
            w[N-1-n] = 1
        else:
            w[N-1-n] = w[N-n] +1
    else:
        if N-1-n == N-1:
            w[N-1-n] = 0
        else:
            w[N-1-n] = w[N-n]

for n in range(N):
    ans.append(b[n]+w[n])


print(min(ans)-1)

Measured memory_bytes: 20968
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;
int INF = 1001001001;

int main() {
  int n;
  cin >> n;
  vector<int> h(n);
  rep(i, n) cin >> h[i];
  int before = 0;
  int ans = 0;
  for(int i=n-2; i>=0; i--) {
    if(h[i] >= h[i+1]) before++;
    else before =0;
    ans = max(before, ans);
  }
  cout << ans << endl;
  return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main() {
  deque<long long> L;
  rep(i,9)
    L.push_back(i+1);
  
  int K;
  cin >> K;
  
  long long a;
  int b;
  rep(i,K-1){
    a = L.front();
    L.pop_front();
    b = a%10;
    if (b != 0)
      L.push_back(a*10+b-1);
    L.push_back(a*10+b);
    if (b != 9)
      L.push_back(a*10+b+1);
  }
  cout << L.front() << endl;
}

Measured memory_bytes: 5092
#include<stdio.h>
int main(void){
    int a,b;
    while(1){
        scanf("%d %d",&a,&b);
        if(a==0 && b == 0){
            break;
        }
        if(a < b){
            printf("%d %d\n",a,b);
        }else {
            printf("%d %d\n",b,a);
        }
    }
    return 0;
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long x, y; cin >> x >> y;
    long long ans = 1e18;
    long long X = -x, Y = -y;
    if(x <= y) ans = min(ans, y-x);
    if(x <= Y) ans = min(ans, Y-x+1);
    if(X <= y) ans = min(ans, y-X+1);
    if(X <= Y) ans = min(ans, Y-X+2);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#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++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999999
#define MOD 10007
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef vector<llong> LV;

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


// bool gousei(llong *x,llong *y){
//     if(*x<*y){
//         *y=x+y
//     }
// }

int main() {
	llong N,A,B,C;
	cin >> N >> A >> B >> C;
    LV take(N);
    REP(i,N){
        cin >> take[i];
    }
    llong cost = INF;
    llong ca,cb,cc,cnow;
    llong na,nb,nc;
    llong cnt =0;
    REP(a,1 << (N) ){
        REP(b,1 << (N) ){
            REP(c,1 << (N) ){
                if( (a&b) || (a&c) || (b&c) ) continue;
                cnt++;
                na = A;nb = B;nc=C;
                ca = cb = cc = -10;
                REP(i,N){
                    if( a&(1<<i) ){
                        na -= take[i]; ca+=10;
                    }
                }
                REP(i,N){
                    if( b&(1<<i) ){
                        nb -= take[i]; cb+=10;
                    } 
                }
                REP(i,N){
                    if( c&(1<<i) ){
                        nc -= take[i]; cc+=10;
                    }
                }
                if (ca<0 || cb<0 || cc <0) continue;
                ca += abs(na);
                cb += abs(nb);
                cc += abs(nc);
                cnow = ca + cb + cc;
                cost = (cnow < cost) ? cnow : cost;
            }
        }
    }
    cout << cost << endl;
    // cout << "cnt" << cnt << endl;
    // LV use_facet(N,0);
    // REP(i,N){

    // }




}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main()
{
  int N,i;
  int *A;

  scanf("%d",&N );
  A = calloc(N, sizeof(int));

  for(i=0; i<N; i++)
    scanf("%d",&A[i]);

  for(i=0; i<N; i++){
    if(A[i]%2 != 0)
      continue;
    else if(A[i]%6 == 0 || A[i]%10 == 0)
      continue;
    else{
      printf("DENIED");
      return 0;
    }
  }
  printf("APPROVED");

  free(A);

  return 0;
}


Measured memory_bytes: 1716
n, k = [int(i) for i in input().split()]

a_ls = [0] * n
for i in range(k):
    d = int(input())
    a = [int(i) for i in input().split()]
    for j in a:
        if a_ls[j-1] == 0:
            a_ls[j-1] = 1
print(n - sum(a_ls))

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

int main(){
	vector<int> haiku(3);
	for(int i=0; i<3; i++) cin >> haiku.at(i);

	int five = 0;
	int seven = 0;
	for(int i=0; i<3; i++){
		if(haiku.at(i) == 5) five++;
		else if(haiku.at(i) == 7) seven++;
	}
	if(five == 2 && seven == 1) cout << "YES" << endl;
	else cout << "NO" << endl;

	return 0;
}


Measured memory_bytes: 3544
#include <iostream>
#include <cstring>

using namespace std;

const int dx[] = { 1, 0, -1, 0 };
const int dy[] = { 0, 1, 0, -1 };
bool field[201][201];

int main(){
	while(true){
		int W, H, N;
		cin >> W >> H >> N;
		if(W == 0 && H == 0 && N == 0){ break; }
		memset(field, 0, sizeof(field));
		for(int i = 0; i <= H * 2; ++i){
			field[i][0] = field[i][W * 2] = true;
		}
		for(int i = 0; i <= W * 2; ++i){
			field[0][i] = field[H * 2][i] = true;
		}
		while(N--){
			int x1, y1, x2, y2;
			cin >> x1 >> y1 >> x2 >> y2;
			if(x1 != x2){
				if(x2 < x1){ swap(x1, x2); }
				for(int i = x1 * 2; i <= x2 * 2; ++i){
					field[y1 * 2][i] = true;
				}
			}else{
				if(y2 < y1){ swap(y1, y2); }
				for(int i = y1 * 2; i <= y2 * 2; ++i){
					field[i][x1 * 2] = true;
				}
			}
		}
		int xe1, ye1, xe2, ye2, xg, yg, xs, ys;
		cin >> xe1 >> ye1 >> xe2 >> ye2 >> xg >> yg;
		xg = xg * 2 + 1; yg = yg * 2 + 1;
		int dir = 0;
		if(xe1 != xe2){
			xs = min(xe1, xe2) * 2 + 1;
			if(ye1 == 0){
				ys = 0;
				dir = 1;
			}else{
				ys = (H * 2);
				dir = 3;
			}
		}else{
			ys = min(ye1, ye2) * 2 + 1;
			if(xe1 == 0){
				xs = 0;
				dir = 0;
			}else{
				xs = (W * 2);
				dir = 2;
			}
		}
		field[ys][xs] = false;
		int x = xs, y = ys, answer = 0;
		while(true){
			int nx = x + dx[dir], ny = y + dy[dir];
			while(field[ny][nx]){
				dir = (dir - 1) & 3;
				nx = x + dx[dir], ny = y + dy[dir];
			}
			if(!field[ny + dy[(dir + 1) & 3]][nx + dx[(dir + 1) & 3]]){
				dir = (dir + 1) & 3;
			}
			x = nx; y = ny;
			if((x & 1) == 1 && (y & 1) == 1){ ++answer; }
			if(x == xs && y == ys){
				answer = -1;
				break;
			}else if(x == xg && y == yg){
				break;
			}
		}
		if(answer < 0){
			cout << "Impossible" << endl;
		}else{
			cout << answer << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 908