akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
#define INT_MAX 1<<30
const int mod = 1e9+7;

int main(){
	ll n,k; cin >> n >> k;
	vl a(n); rep(i,n) cin >> a[i];
	vl sum(n-k+1,0);
	rep(i,n-k){
		sum[i+1] += sum[i] + max(0LL,a[i]);
	}
	ll s = 0;
	REP(i,n-k,n) s += a[i];
	ll ans = max(0LL,s) + sum[n-k];
	//print2(s,sum[n-k]);
	ll add = 0;
	for(ll i=n-k-1; i>=0; i--){
		s += a[i];
		s -= a[i+k];
		add += max(a[i+k],0LL);
		chmax(ans, max(0LL,s) + sum[i] + add);
		//print3(s,sum[i],add);
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <map>
using namespace std;
const int MAxn = 1e5 + 2;

map<int, int> S, T;

int main() {
    int n, m;
    while(cin >> n) {
        S.clear();
        T.clear();
        int flag = 1;
        for (int i = 1; i <= n; i++) {
            int x;
            cin >> x;
            S[x]++;
        }
        cin >> m;
        for (int i = 1; i <= m; i++) {
            int x;
            cin >> x;
            T[x]++;
            if(T[x] > S[x]) flag = 0;
        }
        if(flag) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 18944
n = int(input())
p = list(map(int,input().split()))
cn = 0
for i in range(1,n-1):
    if (p[i-1] < p[i] and p[i] < p[i+1]) or (p[i-1] > p[i] and p[i] > p[i+1]):
        cn += 1
print(cn)

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


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

  vector<int> A(N);
  int a;
  rep(i, N) {
    cin >> a;
    A[i] = a - 1;
  }

  ll b = 0, c = 0;
  vector<int> visited(N, -1);
  visited[0] = 0;

  int pos = 0;
  rep(i, N) {
    int next_pos = A[pos];
    if (visited[next_pos] == -1) {
      visited[next_pos] = i + 1;
    } else {
      b = visited[next_pos];
      c = i + 1 - b;
      break;
    }
    pos = next_pos;
  }
  // cout << b << ' ' << c << endl;

  int ans = 0;
  if (K <= b) {
    rep(i, K) ans = A[ans];
  } else {
    rep(i, b) ans = A[ans];
    K -= b;
    K %= c;
    rep(i, K) ans = A[ans];
  }
  cout << ans + 1 << endl;
  return 0;
}


Measured memory_bytes: 4824
#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define LOCAL 1

#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#define dbg(...) cout<<#__VA_ARGS__ ": ["; for(auto e: __VA_ARGS__){cout<<e<<", ";} cout<<"]\n"
#define dbg1(...) cout<<#__VA_ARGS__ " "<< __VA_ARGS__ 
#else
#define dbg(...) 1;
#define dbg1(...) 1;
#endif

typedef long long ll;
typedef unsigned long long ull;
constexpr int R=5e6+69, INF=2e9+6969;

ll n,m,k,b[R],ans,s,x;
vector <ll> v {};
int main()
{
	//  scanf("%lld%lld%lld", &n, &m, &k);
	cin >> n >> m >> k;
	for(int i=0;i<n;++i)
	{
		cin >> x;
		s+=x;
		if(s<=k) ans=i+1;
		v.pb(s);
	}
	//  for(auto e: v) printf("%lld ", e);
	//  puts("");
	//  printf("low: %d\n", lower_bound(v.begin(),v.end(),270)-v.begin());
	s=0;
	for(int i=0;i<m;++i)
	{
		cin >> x;
		//  scanf("%lld", &x);
		s+=x;
		if(s>k) continue;
		ll cur=0;
		cur = upper_bound(v.begin(),v.end(),k-s) - v.begin();	
		//  printf("%lld %lld\n", cur, s);
		ans=max(ans,cur+i+1);
	}
	cout << ans;
	//  printf("%lld\n", ans);
	return 0;
}


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

const int DIM = 1e5 + 5;

int col[DIM], cnt[3];
vector<pair<int, int>> edg[DIM];

void dfs(int x, int c, bool &ok, int &nrn, int &nre)
{
    ++cnt[c]; col[x] = c; ++nrn;
    
    for (pair<int, int> y : edg[x]) {
        if (y.second == 1)
            ++nre;
        if (col[y.first] == -1)
            dfs(y.first, (c + y.second + 3) % 3, ok, nrn, nre);
        if (col[y.first] != (c + y.second + 3) % 3)
            ok = false;
    }
    
    return;
}

int main(void)
{
    ios :: sync_with_stdio(false);
    cin.tie(); cout.tie();
    
    int n, m;
    cin >> n >> m;
    
    long long ans = m;
    for (int i = 1; i <= m; ++i) {
        int x, y;
        cin >> x >> y;
        
        edg[x].push_back(make_pair(y,  1));
        edg[y].push_back(make_pair(x, -1));
    }
    
    memset(col + 1, -1, n << 2);
    for (int i = 1; i <= n; ++i) {
        if (col[i] != -1) continue;
        bool ok = true; int nrn = 0, nre = 0;
        
        cnt[0] = cnt[1] = cnt[2] = 0;
        dfs(i, 0, ok, nrn, nre);
        
        if (!ok)
            ans += 1LL * nrn * nrn - nre;
        else
        if (cnt[0] and cnt[1] and cnt[2])
            ans += 1LL * cnt[0] * cnt[1] +
                   1LL * cnt[1] * cnt[2] +
                   1LL * cnt[2] * cnt[0] - nre;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 15488
// a = -b mod K
// b = -c = -a mod K
// therefore a = c mod K

// so a = b = c mod K

// (5. 3)
// (3, 3, 3)

#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

int main() {
	int n, k; scanf("%d %d", &n, &k);
	ll multCount = n / k;
	ll halfCount = (k % 2 == 0 ? (n + k/2) / k : 0);
	// printf("mc hc %lld %lld\n", multCount, halfCount);
	printf("%lld\n", multCount * multCount * multCount + halfCount * halfCount * halfCount);
	return 0;
}

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

int main() {
	long long int N = 0;
	long long int M = 0;
	int a[10000] = { 0 };
	int b[10000] = { 0 };
	int n = 0;
	cin >> N;
	M = 1;
	for (int i = 1; i < N+1; i++) {
		M =M* i;
		M = M % (10*10*10*10*10*10*10*10*10 + 7);
	}
	cout << M % (10 * 10 * 10 * 10 * 10 * 10 * 10 * 10 * 10 + 7);



}

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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, M = MAP()

# (鍵の購入コスト, 開けられる宝箱)
keys = [None] * M
for i in range(M):
    c, _ = MAP()
    # どの宝箱を開けられるのかをbitで持っておく
    s = 0
    for a in [a-1 for a in LIST()]:
        s += 1 << a
    keys[i] = (c, s)

# dp[i][j] := i個目の鍵まで見て、集合jの宝箱を開けるための最小コスト
dp = list2d(2, 1<<N, INF)
dp[0][0] = 0
for i in range(M):
    # 今回の鍵で開けられる宝箱の集合s
    s = keys[i][1]
    c = keys[i][0]
    cur = i % 2
    nxt = (i+1) % 2
    for j in range(1<<N):
        # 今回の鍵を買わない遷移
        dp[nxt][j] = min(dp[nxt][j], dp[cur][j])
        if dp[cur][j] != INF:
            m = j | s
            # 買う遷移：遷移元の開けられる宝箱の集合j | 今回の鍵で開けられる宝箱の集合s
            dp[nxt][m] = min(dp[nxt][m], dp[cur][j]+c)
ans = dp[M%2][-1]

if ans != INF:
    print(ans)
else:
    print(-1)


Measured memory_bytes: 49500
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

int main(){
  int n;
  cin >> n;
  double x[8];
  double y[8];
  rep(i,n) cin >> x[i] >> y[i];
  double sum = 0.0;
  rep(i,n){
    for(int j = i; j < n; j++){
      sum += sqrt((x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j]));
    }
  }
  printf("%lf\n", 2*sum/n);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;
const int MAX = 100010;

struct Point {
    int x, y;
};

int main() {
    vector<Point> p(4);
    for (int i = 0; i < 2; i++) {
        cin >> p[i].x >> p[i].y;
    }
    for (int i = 2; i < 4; i++) {
        p[i].x = p[i - 1].x - (p[i - 1].y - p[i - 2].y);
        p[i].y = p[i - 1].y + (p[i - 1].x - p[i - 2].x);
        cout << p[i].x << " " << p[i].y << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define  boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ull unsigned long long
#define deb(x) cout<<#x<<" "<<x<<endl;
#define deb2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define deb2l(x,y,i) cout<<#x<<i<<" "<<x<<" "<<#y<<i<<" "<<y<<endl;

#define fr(i,l,r) for(ll i=l;i<r;i++)
#define mems(a,x) memset(a,x,sizeof(a))
#define mod 1000000007
#define ff first
#define ss second
#define pb(x) push_back(x)
#define vll vector<ll>
#define pbp(x,y) push_back(make_pair(x,y))
#define  mat vector<vector<ll>>
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////



void solve(){
    map<string,int>m;
    string str1,str2,str3;
    cin>>str1>>str2;
    ll o1,o2;
    cin>>o1>>o2;
    m[str1]=o1;
    m[str2]=o2;
    cin>>str3;
    m[str3]--;
    cout<<m[str1]<<" "<<m[str2]<<endl;
    


  }
int main(){
    ll t=1;
   // cin>>t;
    while(t--){
        solve();
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define pii pair<int,int>
#define LL long long
using namespace std;

int main () {
    //clock_t start = clock();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin >> n;
    pair<string,int> a[n+5];
    for (int i=1;i<=n;i++) cin >> a[i].fi >> a[i].se;
    int ans=0;
    string s;
    cin >> s;
    bool y = 0;
    for (int i=1;i<=n;i++) {
        if (a[i].fi == s) {
            y = 1;
            continue;
        }
        if (y) ans += a[i].se;
    }
    cout << ans << endl;
    //cerr << fixed << setprecision(3) << (clock()-start)*1./CLOCKS_PER_SEC << endl;
    return 0;
}

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

using namespace std;

int a[111111];
long long an;
int n, x;

int main(){
//	freopen("input.inp", "r", stdin);
	scanf("%d%d",&n,&x);
	for(int i = 1; i <= n; ++i) scanf("%d",&a[i]);
	for(int i = 2; i <= n; ++i){
		int d = min(a[i], a[i] + a[i - 1] - x);
		if (d > 0){
			a[i] -= d;
			an += d;
		}
		if (a[i] + a[i - 1] > x){	
			an += a[i] + a[i - 1] - x;
			a[i - 1] -= (a[i] + a[i - 1] - x);
		}
	}
	printf("%lld",an);
	return 0;
}

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

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

  if (A >= 499) {
    cout << "Yes" << endl;
  }
  else if (A < 499 && N % 500 <= A) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;

vector <int> Zalgorithm(const string &S)
{
	int N = S.size();
    vector <int> A(N, 0);

    A[0] = N;

    int i = 1;
    int j = 0;
    while(i < N)
    {
        //jの位置が先頭のままだからだ
        while(i + j < N && S[j] == S[i+j])
        {
            //一致数
            ++j;
        }

        A[i] = j;

        if(j == 0)
        {
            ++i;
            continue;
        };
        int k = 1;
        //かつてA[k]については調べている
        while(i + k < N && k + A[k] < j)
        {
            A[i+k] = A[k];
            ++k;
        }
        i += k;
        j -= k;

    }
    return A;
}

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

    int res = 0;
    for(int i = 0; i < N; ++i)
    {
        string T = S.substr(i);
        auto lcp = Zalgorithm(T);

        for(int j = 0; j < T.size(); ++j)
        {
            int l = min(lcp[j], j);
            res = max(res, l);
        }
    }

    cout << res << endl;

    return 0;    
}



Measured memory_bytes: 256
import java.util.*;
import java.lang.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
            int A = sc.nextInt();
            int B = sc.nextInt();
        sc.close();

        if(A>=13){
            System.out.println(B);
        }
        else if(A >= 6 && A<= 12){
            System.out.println(B/2);
        }
        else{
            System.out.println(0);
        }
    }
}


Measured memory_bytes: 21460
n = int(input())
a = list(map(int, input().split()))
ca = [0] * (len(a) + 1)
for i in range(n):
    ca[i + 1] = ca[i] + a[i]


# TLE
# ans = 0
# for i in range(n):
#     # print(a[i], ca[i], ca, ca[i + 1:], ca[i + 1:].count(ca[i]))
#     ans += ca[i + 1:].count(ca[i])
# print(ans)

from collections import Counter

ans = 0
cac = Counter(ca)
# print(cac)
# ca.sort()
for v, c in cac.items():
    if c >= 2:
        ans += c * (c - 1) // 2
print(ans)

Measured memory_bytes: 112976
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#define MAX 2000000
#define INFTY (1<<30)

int H, A[MAX+1];

void maxHeapify(int i) {
    int l, r, largest;
    l = 2 * i;
    r = 2 * i + 1;

    // 左の子、自分、右の子で値が最大のノードを選ぶ
    if (l <= H && A[l] > A[i]) largest = l;
    else largest = i;
    if (r <= H && A[r] > A[largest]) largest = r;

    if (largest != i) {
        swap(A[i], A[largest]);
        maxHeapify(largest);
    }
}

int extract() {
    int maxv;
    if (H < 1) return -INFTY;
    maxv = A[1];
    A[1] = A[H--];
    maxHeapify(1);
    return maxv;
}

void increaseKey(int i, int key) {
    if (key < A[i]) return;
    A[i] = key;
    while (i > 1 && A[i/2] < A[i]) {
        swap(A[i], A[i/2]);
        i = i/2;
    }
}

void insert(int key) {
    H++;
    A[H] = -INFTY;
    increaseKey(H, key);
}

int main() {
    int key;
    char com[10];

    while(1) {
        scanf("%s", com);
        if (com[0] == 'e' && com[1] == 'n') break;
        if (com[0] == 'i') {
            scanf("%d", &key);
            insert(key);
        } else {
            printf("%d\n", extract());
        }
    }

    return 0;
}


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

int main(){
  int n;
  string s;
  vector<int> vec(200);
  cin >> n >> s;
  int ans = 0;
  for (int i=1;i<n;i++){
    int cnt = 0;
    for (char c='a';c<='z';c++){
      bool left=false ,right=false;
      for (int j=0;j<i;j++){
        if (s[j]==c){
          left = true;
        }
      }
      for(int j=i;j<n;j++){
        if (s[j]==c){
          right = true;
        }
      }
      if (right && left){
        cnt += 1;
      }
    }
    ans = max(ans,cnt);
  }
  cout<<ans<<endl;
}

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

using namespace std;




int main() {
    vector<long long> res(1e5,0);
    for(int c=1;c<=100;c++) {
        for(int c2=1;c2<=100;c2++) {
            for(int c3=1;c3<=100;c3++) {
                long long N = c*c+c2*c2+c3*c3+c*c2+c2*c3+c3*c;
                if(N<=1e4+1) {
                    res[N]++;
                }
            }
        }
    }
    int N;
    cin>>N;
    for(int c=1;c<=N;c++) {
        cout<<res[c]<<endl;
    }
}


Measured memory_bytes: 3740
import java.io.*;
import java.util.*;
public class Main
{
	
	private boolean solve()throws IOException
	{
		int n=nextInt();
		int a[]=new int[n];
		for(int i=1;i<=n;i++)
			a[nextInt()]++;
		int l;
		for(l=n-1;l>=1;l--)
			if(a[l]!=0)
				break;
		if(a[l]<2)
			return false;
		a[l]-=2;
		for(int i=1;i<=l-1;i++)
		{
			int d=Math.max(i,l-i);
			if(a[d]==0)
				return false;
			a[d]--;
		}
		int r=(l+1)/2;
		for(int i=1;i<=r;i++)
			if(a[i]>0)
				return false;
		return true;
	}

	 
	///////////////////////////////////////////////////////////

	public void run()throws IOException
	{
		br=new BufferedReader(new InputStreamReader(System.in));
		st=null;
		out=new PrintWriter(System.out);

		out.println(solve()?"Possible":"Impossible");
		
		br.close();
		out.close();
	}
	public static void main(String args[])throws IOException{
		new Main().run();
	}
	BufferedReader br;
	StringTokenizer st;
	PrintWriter out;
	String nextToken()throws IOException{
		while(st==null || !st.hasMoreTokens())
		st=new StringTokenizer(br.readLine());
		return st.nextToken();
	}
	String nextLine()throws IOException{
		return br.readLine();
	}
	int nextInt()throws IOException{
		return Integer.parseInt(nextToken());
	}
	long nextLong()throws IOException{
		return Long.parseLong(nextToken());
	}
	double nextDouble()throws IOException{
		return Double.parseDouble(nextToken());
	}
}

Measured memory_bytes: 22868
#include<functional>
#include <algorithm>
#include <iostream>
#include <memory.h>
#include <string.h>
#include <string>
#include <math.h>
#include <time.h>
#include <vector>
#include <queue>
#include<stack>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
using namespace std;
typedef long long ll;
int n;
vector<int> v;
ll dp[3001][3001][2];
ll calc(int i, int j, bool turn) {
	if (i > j)
		return 0;
	ll &ret = dp[i][j][turn];
	if (ret != -1)
		return ret;
	if (turn)
		ret = max(calc(i + 1, j, false) + v[i], calc(i, j - 1, false) + v[j]);
	else
		ret = min(calc(i + 1, j, true) - v[i], calc(i, j - 1, true) - v[j]);
	return ret;
}
int main() {
	//freopen("src.txt", "r", stdin);
	memset(dp, -1, sizeof dp);
	cin >> n;
	v.resize(n);
	for (int i = 0; i < n; ++i)
		cin >> v[i];
	cout << calc(0, n - 1, true) << endl;
	return 0;
}

Measured memory_bytes: 141436
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
int main()
{
  int n;
  cin >> n;
  vector<int> d(n);
  rep(i,n) cin >> d[i];
  sort(d.begin(), d.end());
  cout << d[n/2]-d[n/2-1] << "\n";
  return 0;
}


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

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b) {
		cout << c << endl;
	}
	else if(a==c){
		cout << b << endl;
	}
	else {
		cout << a << endl;
	}
	return 0;
}


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

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

  if(n%1000==0) cout << 0 << endl;

  else{
      int nn = n%1000;
      cout << 1000 - nn << endl;
  }
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;
typedef vector<vll> vvll;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define no cout<<"No"<<endl
#define NO cout<<"NO"<<endl
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

ll gcd(ll a, ll b){
  if(b==0)
    return a;
  if(a<b)
    return gcd(b,a);

  return gcd(b,a%b);
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll n;
  cin>>n;
  vll a(n);
  REP(i,n)cin>>a[i];

  vll gcd_fro(n), gcd_back(n);
  REP(i,n){
    if(i==0)
      gcd_fro[i]=a[i];
    else
      gcd_fro[i]=gcd(a[i],gcd_fro[i-1]);
  }

  for(ll i=n-1; i>=0; i--){
    if(i==n-1)
      gcd_back[i]=a[i];
    else
      gcd_back[i]=gcd(a[i],gcd_back[i+1]);
  }

  ll ans=1;
  REP(i,n){
    ll l=1,r=1;
    if(i!=0)
      l=gcd_fro[i-1];
    if(i!=n-1)
      r=gcd_back[i+1];

    ll now;
    if(i!=0 && i!=n-1)
     now=gcd(l,r);
    else
      now=l*r;
    ans=max(ans,now);
  }

  cout<<ans<<endl;
}



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

int main(){
  int N;
  cin >> N;
  double sum=0;
  double x;
  string u;
  for(int i=0; i<N; i++){
    cin >> x >> u;
    if(u[0] == 'J'){
      sum+=x;
    }
    else {
      sum+= x*380000.0;
    }
  }
  cout << sum << endl;
}

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

typedef struct{
  int x=0,y=0;
}SP;

int main(){
  while(true){
    vector<SP> point;
    int hmin=0,hmax=0,wmin=0,wmax=0;
    int N;
    
    cin >> N;
    --N;

    if(N == -1) break;
    if(N == 0){
      cout << 1 << " " << 1 << endl;
      continue;
    }
    
    SP s;
    s.x = s.y = 0;
    point.push_back(s);
    
    int work, work2;
    for(int i=0;i<N;++i){
      cin >> work >> work2;
      
      if(work2 == 0)      s.x = -1 , s.y = 0;
      else if(work2 == 1) s.x = 0  , s.y = 1;
      else if(work2 == 2) s.x = 1  , s.y = 0;
      else if(work2 == 3) s.x = 0  , s.y = -1;

      s.x += point[work].x;
      s.y += point[work].y;

      point.push_back(s);

      hmin = min(hmin, s.y);
      hmax = max(hmax, s.y);
      wmin = min(wmin, s.x);
      wmax = max(wmax, s.x);
    }

    cout << abs(wmin) + wmax+1 << " " << abs(hmin) + hmax+1 << endl;
    hmin = hmax = wmin = wmax = 0;
  }
  
  return 0;
}



Measured memory_bytes: 3100
# coding: utf-8

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

mod = int(1e9 + 7)

def f(r):
    if v[r]:
        return(False)
    v[r] = 1
    dpr = dp[r]
    dpr[0] = 1
    dpr[1] = 1
    for j in e[r]:
        if f(j):
            dpj = dp[j]
            dpr[0] = dpr[0] * (dpj[0] + dpj[1]) % mod
            dpr[1] = dpr[1] * dpj[0] % mod
    return(True)

n = int(input()) # 1 <= n <= 10^5
e = [set() for _ in range(n)]
for x, y in [map(int, input().split()) for _ in range(n - 1)]:
    e[x - 1].add(y - 1)
    e[y - 1].add(x - 1)
v = [0] * n
dp = [[0] * 2 for _ in range(n)]
f(0)
print((dp[0][0] + dp[0][1]) % mod)


Measured memory_bytes: 129792
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n,m;
  string c[100];
  string d[100];
  while(1){
    cin>>n;
    if(n==0)break;
    rep(i,n)
      cin>>c[i]>>d[i];

    cin>>m;
    rep(i,m){
      string s;
      cin>>s;
      rep(j,n)
        if(s[0]==c[j][0]){
          cout<<d[j][0];
          break;
        }
      if(j==n)cout<<s[0];
    }
    cout<<endl;
  }
}

Measured memory_bytes: 3008
#include <stdio.h>
int main(void){
  int n,i,count=0;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    if(i<10){count++;}
    else if(i>99&&i<1000){count++;}
    else if(i>9999&&i<100000){count++;}
  }
  printf("%d", count);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define sanyes ios_base::sync_with_stdio(0), cout.tie(0); cin.tie(0);
#define llong long long
#define pb push_back
#define bpc __builtin_popcount

const llong mxn = 1e6 + 7;
const llong mod = 1e9 + 7;
const llong inf = 1e18 + 9;

using namespace std;

llong n, a[21][21], k, dp[22][1 << 21], sum[mxn];
bool ok = 0;

int main (){
    cin >> n;
    for (int i = 0; i < n; i ++){
        for (int j = 0; j < n; j ++){
            cin >> a[i][j];
        }
    }dp[0][0] = 1;llong cnt = 0;
    for (int i = 1; i <= n; i ++){
        for (int mask = 0; mask < (1 << n); mask ++){
            llong x = bpc(mask);
            if(x != i) continue;
            for(int j = 0; j < n; j++){
                if(a[i - 1][j] == 1 && (mask & (1 << j))){
                    dp[i][mask] += (dp[i - 1][mask ^ (1 << j)]);
                    dp[i][mask] %= mod;
                }
            }
            //cout << i << ' ' << mask << ' ' << dp[i][mask] << endl;
        }
    }cout << dp[n][(1 << n) - 1];
    return 0;
}


Measured memory_bytes: 311552
#include<bits/stdc++.h>
using namespace std;
#define Max 500005
#define SENTINEL 2000000000 
int L[Max/2+2],R[Max/2+2];
int cnt; //统计交换次数 
int n;

void merge(int A[],int left,int mid,int right)
{
	int n1 = mid-left;
	int n2 = right-mid;
	for(int i = 0;i<n1;i++)
	{
		L[i] = A[left+i];
	}
	for(int i = 0;i<n2;i++)
	{
		R[i] = A[mid +i];
	}
	L[n1] = R[n2] = SENTINEL;
	int i = 0,j= 0;
	for(int k = left;k<right;k++)
	{
		cnt++;
		if(L[i]<=R[j])
		{
			A[k] = L[i++];
		}
			else{
				A[k] = R[j++];
			}
	}
}

void mergeSort(int A[],int left,int right)
{
	if(left+1<right)
	{
		int mid = (left +right)/2;
		mergeSort(A,left,mid);
		mergeSort(A,mid,right);
		merge(A,left,mid,right);
	}
}

int main()
{
	int A[Max],n,i;
	cnt = 0;
	
	cin>>n;
	for(int i =0;i<n;i++)cin>>A[i];
	
	mergeSort(A,0,n);
	
	for(i= 0;i<n;i++)
{
	if(i)cout<<' ';
	cout<<A[i];
}
	cout<<endl;
	cout<<cnt<<endl;
	return 0 ;	
	
}





Measured memory_bytes: 6980
N = gets.to_i
INF = 10**18
ans = 1
a = gets.split.map(&:to_i)
if a.include? 0 then
    p 0
    exit
end
a.each do |i|
    ans *= i
    if ans >  INF then
        ans = -1
        break
    end
end

p ans

Measured memory_bytes: 21624
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from heapq import heappush, heappop

n = ni()
d = list(li())

def isok(dur: int, d: list):
    pque = [24]
    for di in d:
        heappush(pque, di)

    cur = 0
    while pque:
        tmp = heappop(pque)
        if tmp - cur < dur and tmp >= 12:
            return False
        
        elif tmp - cur < dur:
            heappush(pque, 24-tmp)
            
        else:
            cur = tmp
        
    return True

ans = 13
for cand in range(12, -1, -1):
    if isok(cand, d):
        ans = cand
        break
        
print(ans) 

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

int main(){
  string s,t;
  cin >> s >> t;
  char a,b;
  int ans = 0;
  for(int i=0;i<3;i++){
    a = s[i];
    b = t[i];
    if(a == b){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    ans = 0
    for i in range(N):
        if A[i] >= B[i]:
            ans += B[i]
        else:
            ans += A[i]
            remain = B[i] - A[i]
            if A[i+1] >= remain:
                ans += remain
                A[i+1] -= remain
            else:
                ans += A[i+1]
                A[i+1] = 0
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 24060
#include <stdio.h>
int main(){
	int n,k;
	scanf("%d %d", &n,&k);
	int nilai[n];
	for(int i=0;i<n;i++){
		scanf("%d", &nilai[i]);
	}
	for(int j=0;j<n-k;j++){
		(nilai[j]<nilai[k+j])?puts("Yes"):puts("No");
	}
	return 0;
}

Measured memory_bytes: 3904
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
	// write your code here
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int ac=0;
        int wa = 0;
        int tle = 0;
        int re = 0;
        for (int i=0;i<=N;i++){
            String a = scan.nextLine();
            switch(a){
                case "AC":
                    ac++;
                    break;
                case "WA":
                    wa++;
                    break;
                case "TLE":
                    tle++;
                    break;
                case "RE":
                    re++;
                    break;
            }
        }

        System.out.println("AC x " + ac);
        System.out.println("WA x " + wa);
        System.out.println("TLE x " + tle);
        System.out.println("RE x " + re);
    }
}


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

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

ll n, k;
// string s;

int main() {
    cin >> n >> k;
    Vl a(n);
    REP(i, n) cin >> a[i];

    Vl cnt(40, 0);
    REP(i, n) {
        bitset<40> A(a[i]);
        REP(j, 40) if (A[j]) cnt[j]++;
    }

    bitset<40> K(k);
    VVl dp(41, Vl(2, -1e18));
    dp[40][0] = 0;

    RREP(i, 39, 0) {
        REP(j, 2) {
            REP(bit, j == 1 ? 2 : K[i]+1) {
                int j2 = (j == 1 || bit < K[i]) ? 1 : 0;
                ll sum = dp[i+1][j] + (bit == 0 ? cnt[i] : n-cnt[i]) * (1LL << i);
                dp[i][j2] = max(dp[i][j2], sum);
            }
        }
    }
    cout << max(dp[0][1], dp[0][0]) << '\n';

    return 0;
}


Measured memory_bytes: 1024
#!/usr/bin/env python3

import math


def main():
    a, b, h, m = map(int, input().split())
    rot_hr = (60 * h + m) / 720 * 2 * math.pi
    rot_mn = m / 30 * math.pi
    hr_x = a * math.sin(rot_hr)
    hr_y = a * math.cos(rot_hr)
    mn_x = b * math.sin(rot_mn)
    mn_y = b * math.cos(rot_mn)
    print(f'{math.sqrt((hr_x - mn_x) ** 2 + (hr_y - mn_y) ** 2): .9f}')


if __name__ == "__main__":
    main()


Measured memory_bytes: 9552
#include<iostream>
    #include<cstdlib>
    #include<math.h>
    #include<set>
    #include<string>
    #include<stdlib.h>
    using namespace std ;
    int main(){
      int a,b,c;
      cin>>a>>b>>c;
      cout<<a+b+c-max(max(a,b),c)<<endl;
      return 0;
    }

Measured memory_bytes: 256
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
#define ALL(X) X.begin(), X.end()
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef std::pair<LL,LL> PLL;//
typedef std::pair<int,int> PII;//
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18+20;
const double PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	//0123456789
	//1000000007
	int N;
	cin >> N;
	string A,B;
	cin >> A >> B;
	LL ans = 1;
	int pre = 0;//0:縦,1:横
	for(int i=0;i<N;++i){
		if( i == 0 ){
			if( A[i] == B[i] ){//縦
				ans = (ans*3) % MOD;
				pre = 0;//縦
			}else{
				ans = (ans*6) % MOD;
				pre = 1;//横
				++i;//一つとばす
			}
		}else{
			int now;
			if( A[i] == B[i] ){
				now = 0;//縦に置く
			}else{
				now = 1;//横に置く
			}
			if( pre == 0 ){//前が縦
				if( now == 0 ){
					ans = (ans*2) % MOD;
				}else{
					ans = (ans*2) % MOD;
				}
				pre = now;
			}else{//前が横
				if( now == 0 ){
					//ans = (ans*1) % MOD;
				}else{
					ans = (ans*3) % MOD;
				}
				pre = now;
			}
			if( now == 1 ){//横に置く
				++i;//一つとばす
			}
		}
	}
	cout << ans << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()

Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;

alias Pair = Tuple!(string, "name", int, "score", int, "index");

void main() {
    int n, m;
    scan(n, m);
    auto a = new int[][](m, 0);
    foreach (i ; 0 .. m) {
        a[i] = readln.split.to!(int[])[1 .. $];
        a[i][] -= 1;
    }
    auto p = readArr!(int)();

    int ans;

    foreach (s ; 0 .. 1 << n) {
        bool ok = true;

        foreach (j ; 0 .. m) {
            int t;

            foreach (sw ; a[j]) {
                t ^= (s >> sw) & 1;
            }

            if (p[j] != t) {
                ok = false;
                break;
            }
        }

        ans += ok;
    }

    writeln(ans);
}



















int[][] readGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new int[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v;
        scan(u, v);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= v;
        if (isUndirected) {
            adj[v] ~= u;
        }
    }

    return adj;
}

alias Edge = Tuple!(int, "to", int, "cost");

Edge[][] readWeightedGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new Edge[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v, c;
        scan(u, v, c);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= Edge(v, c);
        if (isUndirected) {
            adj[v] ~= Edge(u, c);
        }
    }

    return adj;
}

void yes(bool b) {
    writeln(b ? "Yes" : "No");
}

void YES(bool b) {
    writeln(b ? "YES" : "NO");
}

T[] readArr(T)() {
    return readln.split.to!(T[]);
}

T[] readArrByLines(T)(int n) {
    return iota(n).map!(i => readln.chomp.to!T).array;
}

void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 256
N, T = map(int, input().split())
A = [int(x) for x in input().split()]
buy = A[0]
max_profit = 0
ans = 1
for i in range(1,N):
    if A[i] > buy:
        if A[i] - buy > max_profit:
            max_profit = A[i] - buy
            ans = 1
        elif A[i] - buy == max_profit:
            ans += 1
    else:
        buy = A[i]
print(ans)


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
  int n, l;
  cin >> n >> l;
  int a[100001];
  int ng = 0;

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

  int c = -1;
  rep(i, 0, n - 1) {
    if(a[i] + a[i + 1] >= l) {
      c = i;
      break;
    }
  }

  if(c == -1) {
    cout << "Impossible" << endl;
    return 0;
  }

  cout << "Possible" << endl;

  rep(i, 1, c + 1) cout << i << endl;
  dep(i, n - 1, c + 2) cout << i << endl;
  cout << c + 1 << endl;
}


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

///////////////////////////////////////////
const long long int INF = INT64_MAX;
//const long long int INF = 1000000;
const long long int Mod = 1000000007;
using ll = long long int; //long long int は64bit
using ci = const int;
using vi = vector<int>;
using Vi = vector<long long int>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(int i=0;i<N;i++)
template<class T>bool chmax(T &former, const T &b) { if (former<=b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
typedef vector<vector<ll> > matrix;
///////////////////////////////////////////////////////////////////////////////////
Vi v;
ll n,k;
vi a(100000);
ll calu(int x,int y){//[x,y)の美しさ
    ll ans = 0;
    for(int i=x;i<y;i++){ ans += a[i]; }
    return ans;
}

int main(){
    cin>>n>>k;
    rep(i,n)cin>>a[i];
    rep(i,n){
		long long int S = 0;
		for(int j=i;j<n;j++){
			S += a[j];
			v.push_back(S);
		}
	}
    Sort(v);
    //cout<<v.size()<<endl;
   // rep(i,v.size())cout<<v[i]<<" ";
  //  cout<<""<<endl;
    ll sum =0;ll ct =0;
    for(int i=40;i>=0;i--){
        ct = 0;
        rep(j,v.size()){
            if( ( v[j] & (sum+(1LL<<i)) ) == (sum+(1LL<<i)) )ct++;
           //cout<<"i: "<<i<<" "<<sum+(1LL<<i)<<" "<<sum<<" "<<ct<<endl;
        }
        if(ct>=k){
            sum += (1LL<<i);
        }
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 6640
#include <bits/stdc++.h>
#define REP(i, n) for(long long 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 ll long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;

int main(){
  int n,k;
  string s;
  cin >> n >> s >> k;
  char ok = s[k-1];
  for(int i = 0 ;i < n ;i++) {
    if (s[i] != ok) {
      s[i] = '*';
    }
  }
  cout << s;
}

Measured memory_bytes: 256
N = int(input())
xmax = N//4
ymax = N//7
for x in range(0,xmax+1):
    for y in range(0,ymax+1):
        ans = 4*x + 7*y
        if ans > N:
            continue
        if N == ans:
            print("Yes")
            exit()
else:
    print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll                  long long
#define pb                  push_back
#define pf                  push_front
#define mp                  make_pair
#define in                  insert
#define sz(a)               (int)(a).size()
#define all(x)              (x).begin(), (x).end()
#define fore(i,a,b)         for(ll i=a; i<b; i+=1)
#define forr(i,a)           for(ll i=a; i>=0; i-=1)
#define forg(i,b,e,c)       for (ll i=(ll)b; i<(ll)e; i+=c)
#define ford(i,a)           for(auto i=a.begin(); i!=a.end(); i++) 
#define F first
#define S second
#define clr(a,val)          memset(a,val,sizeof (a))
#define min3(a, b, c)       min(min(a, b), c)
#define min4(a, b, c, d)    min(min(a, b), min(c, d))
#define max3(a, b, c)       max(max(a, b), c)
#define max4(a, b, c, d)    max(max(a, b), max(c, d))
#define endl "\n"
#define printV(arr)         fore(x,0,sz(arr)) cout << arr[x] <<" "; cout<<endl;
#define printR(arr,a,b)     fore(x,a,b) cout << arr[x] <<" "; cout<<endl;
#define setp(x)             fixed<<setprecision(x)
 
 
using namespace std;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;
typedef pair<ll,ll> lll;
typedef vector<ii> vii;
typedef vector<lll> vlll;
typedef pair<string, int> si;
typedef pair<int, string> is;
typedef vector<string> vs;
const int MAX=1e5+10;
const int MOD=1000000009;
const double pi=acos(-1);
const int dx[]={0,1,-1,0};
const int dy[]={-1,0,0,1};
const int dxc[]={0,1,-1,0,1,1,-1,-1};
const int dyc[]={-1,0,0,1,-1,1,-1,1};
 
ll min(ll a, ll b){
    if(a>b) return b;
    return a;
}
ll max(ll a, ll b){
    if(a>b) return a;
    return b;
}
 
ll gcd(ll a, ll b){
    while(b!=0){
        a%=b;
        swap(a,b);
    }
    return a;
}
ll lcm(ll a, ll b){
    return (a*b)/gcd(a,b);
}
bool isPrime(ll n){
    if(n<=1) return false;
    if(n==2) return true;
    if(n%2==0) return false;
    for(ll i=3; i*i<=n; i+=2){
        if(n%i==0) return false;
    }
    return true;
}
 
set<ll> gen(ll n){
    set<ll> divs;
    for(ll i=1; i*i<=n; i++){
        if(n%i==0){
            divs.insert(i);
            divs.insert(n/i);
        }
    }
    return divs;
}
 
map<ll, int> fact(ll n){
    map<ll, int> F;
    for(ll p = 2; p*p <= n; p++){
        while(n%p == 0){
            F[p]++;
            n /= p;
        }
    }   
    if(n > 1) F[n]++;
    return F;
}
 
ll sum(ll n){
    return (n*(n+1))/2;
}
 
ll binaryExp(ll a, ll b, ll c){
    if(b==0) return 1;
    if(b%2==0){
        ll temp=binaryExp(a,b/2,c);
        return (temp*temp)%c;
    }
    else{
        ll temp=binaryExp(a,b-1,c);
        return (temp*a)%c;
    }
}
 
bool isPal(string& cad){
    int p1=sz(cad)-1;
    fore(i,0,sz(cad)/2){
        if(cad[i]!=cad[p1]) return false;
        p1--;
    }
    return true;
}

double dis(double x1,double y1, double x2, double y2){
    double ff=pow(x2-x1,2)+pow(y2-y1,2);
    return sqrt(ff);
}

 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int n,x,t; cin>>n>>x>>t;
    int yy=(n+x-1)/x;
    cout<<yy*t<<endl;

    return 0;
}

Measured memory_bytes: 3640
n = gets.to_i

# 前に存在していた点
lx = ly = 0
# 前に存在していた点にいた時刻
lt = 0

n.times do
  t, x, y = gets.split.map(&:to_i)

  # 前に存在していた点からの距離（道のり）
  distance = (x - lx).abs + (y - ly).abs

  # 前に存在していた点にいた時刻からの経過時刻
  dt = t - lt

  if dt < distance
    puts 'No'
    exit    # 入力をgetsするのを途中でやめても大丈夫かな？
  end

  # 経過時刻が偶数なら距離も偶数じゃなければならない。奇数でも同様。
  if dt.even? != distance.even?
    puts 'No'
    exit
  end

  lt = t
  lx = x
  ly = y
end

puts 'Yes'


Measured memory_bytes: 1788
#include <stdio.h>
#include <math.h>

int main(void){
  double xp1,xp2,yp1,yp2,xp,yp;
  int q;
  scanf("%lf %lf %lf %lf",&xp1,&yp1,&xp2,&yp2);
  scanf("%d",&q);
  double v1x,v1y;
  double x,y;
  v1x=(xp2-xp1)/sqrt((yp2-yp1)*(yp2-yp1)+(xp2-xp1)*(xp2-xp1));
  v1y=(yp2-yp1)/sqrt((yp2-yp1)*(yp2-yp1)+(xp2-xp1)*(xp2-xp1));
  double dot;
  for(int i=0;i<q;i++){
    scanf("%lf %lf",&xp,&yp);
    dot=(xp-xp1)*v1x+(yp-yp1)*v1y;
    x=xp1+dot*v1x;
    y=yp1+dot*v1y;
    printf("%.16f %.16f\n", 2*x-xp,2*y-yp);
  }
  return 0;
}



Measured memory_bytes: 2132
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i ++)
#define irep(i,n) for (int i = (int)(n) - 1;i >= 0;--i)
using namespace std;
using ll = long long;
using PL = pair<ll,ll>;
using P = pair<int,int>;
constexpr int INF = 1000000000;
constexpr long long HINF = 1000000000000000;
constexpr long long MOD = 1000000007;// = 998244353;
constexpr double EPS = 1e-4;
constexpr double PI = 3.14159265358979;

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

    int N; cin >> N;
    ll K = 0;
    ll ans = 0;
    vector<ll> B;
    rep(i,N) {
        ll a,b; cin >> a >> b;
        if (a <= b) {
            ans += b;
            K += b - a;
        } else {
            B.push_back(b);
            ans += b;
        }
    }
    if ((int)B.size() == 0) {
        cout << 0 << '\n';
        return 0;
    }
    ans -= *min_element(B.begin(),B.end());
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3780
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(a,b) cout << "debug : " << a << " , "<< b << endl;
using ll=long long;
const ll INF=1LL<<60;



int main(){
  int n,m;
  cin >> n >> m;
  vector<int>a(n);
  int sum=0;
  rep(i,n){
    cin >> a[i];
    sum+=a[i];
  }
  int select=n;
  rep(i,n){
    if(a[i]*m*4<sum)select--;
  }
  if(select>=m)cout << "Yes";
  else cout << "No";
}



Measured memory_bytes: 256
from fractions import gcd
import functools

N, K = map(int,input().split())
A = list(map(int, input().split()))
max_A = max(A)
gcd_A = functools.reduce(gcd, A)
 
ans = 'POSSIBLE' if K <= max_A and K % gcd_A == 0 else 'IMPOSSIBLE'
 
print(ans)

Measured memory_bytes: 88172
use proconio::input;

fn main() {
    input!(n: usize, mut a: [u64; n]);
    a.sort_by_key(|&x| std::cmp::Reverse(x));
    let mut ans = 0;
    for i in 1..n {
        ans += a[i / 2];
    }
    println!("{}", ans);
}


Measured memory_bytes: 6208
// #pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#define String std::string
#define fi first
#define se second
#define mp std::make_pair
#define Pair std::pair<int, int>
#define Map std::map< int, int >
#define Vector std::vector<int>
 
using std::cin;
using std::cout;
using std::endl;
 
typedef long long ll;
typedef unsigned long long ull;
 
const int N = 100000 + 5;
const int M = 1000 + 5;
const int K = 1e7 + 5;
// const int MOD = 1e9 + 7;
const int MOD = 10007;
const int inv2 = 500000004;
const int LOG = 40;
const ull BASE = 19260817;
const int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };
const int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };
const double PI = acos(-1);

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
 
template<class T>
inline T readT() {
    T res = 0, f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) res = (res << 1) + (res << 3) + ch - '0';
    return res * f;
}
#define read readT<int>

// int a, b, c;
int n, m, x, y, max, min;

int main() {
    cin >> n >> m >> x >> y;
    x++;
    max = INT_MIN;
    min = INT_MAX;
    for (int i = 1; i <= n; i++) {
        int a;
        scanf("%d", &a);
        max = std::max(max, a);
    }
    for (int i = 1; i <= m; i++) {
        int a;
        scanf("%d", &a);
        min = std::min(min, a);
    }
    max++;
    if (max <= min && (max >= x && max <= y || min >= x && max <= y)) {
        puts("No War");
    } else {
        puts("War");
    }
    return 0;
}

Measured memory_bytes: 256