akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

int main(){
    int n,i,j,flag,t;
    char s[81],ans[81],tmp[81]={0},ch;
while(gets(s)!=NULL){
/*while(scanf("%c",ch)!=NULL){
    s[0]=ch;
    i=1;
    while(1){
        scanf("%c",&ch);
        if(ch=='\n'){
            s[i]='\0';
            break;
        }else{
            s[i]=ch;
        }
        i++;
    }*/
    for(i=0,n=0,flag=0;i<26;i++){
        for(j=0;s[j]!='\0';j++){
            if(!('a'<=s[j]&&s[j]<='z')){
                if(tmp[0]=='t'&&tmp[1]=='h'
                        &&((tmp[2]=='e'&&n==3)
                            ||(tmp[2]=='i'&&tmp[3]=='s'&&n==4)
                            ||(tmp[2]=='a'&&tmp[3]=='t'&&n==4))){
                    flag=1;
                    break;
                }
                n=0;
            }else{
                t=s[j]+i;
                if('a'<=t&&t<='z'){
                    tmp[n]=t;
                }else{
                    t-='z';
                    tmp[n]=t+'a'-1;
                }
                n++;
            }
        }
        if(flag)break;
    }

    if(flag){
        for(j=0;s[j]!='\0';j++){
            if('a'<=s[j]&&s[j]<='z'){
                t=s[j]+i;
                if('a'<=t&&t<='z'){
                    ans[j]=t;
                }else{
                    t-='z';
                    ans[j]=t+'a'-1;
                }
            }else{
                ans[j]=s[j];
            }
        }
        ans[j]='\0';
        printf("%s\n",ans);
    }
}
    return 0;
}

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

int main() {
    int n,a,b;
    cin>>n>>a>>b;
    
    if((b-a)%2) cout<< "Borys"<<endl;
    else cout<< "Alice" << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,H,W,ans;
  cin >> N >> H >> W;
  for (int i=0; i < N; i++){
    int A,B;
    cin >> A >> B;
    if(A >= H){
      if(B >= W){
        ans++;
      }
    }
  }
  cout << ans << endl;
 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> key(m);
    rep(i, 0, m) {
        int a, b;
        cin >> a >> b;
        int s = 0;
        rep(j, 0, b) {
            int c;
            cin >> c;
            c--;
            s |= 1 << c;
        }
        key[i] = make_pair(s, a);
    }

    vector<int> dp(1 << n, INF);
    dp[0] = 0;
    rep(s, 0, (1 << n)) {
        if (dp[s] == INF) continue;
        rep(i, 0, m) {
            int t = s | key[i].first;
            int cost = dp[s] + key[i].second;
            dp[t] = min(dp[t], cost);
        }
    }

    int ans = dp[(1 << n) - 1];
    if (ans == INF) ans = -1;
    cout << ans << endl;
    return 0;
}


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

int main() {
  int n; cin >> n;
  for (int i = 0; i < n; i++) {
    string a, b;
    cin >> a >> b;
    vector<int> va, vb;
    for (int i = a.size() - 1; i >= 0; i--) va.push_back(a[i] - '0');
    for (int i = b.size() - 1; i >= 0; i--) vb.push_back(b[i] - '0');
    vector<int> vc;
    int rem = 0;
    for (int i = 0; i < va.size() || i < vb.size(); i++) {
      if (i < va.size()) rem += va[i];
      if (i < vb.size()) rem += vb[i];
      vc.push_back(rem % 10);
      rem = rem / 10;
    }
    if (rem) vc.push_back(rem);
    if (vc.size() > 80) {
      cout << "overflow" << endl;
    } else {
      for (int i = vc.size() - 1; i >= 0; i--) cout << vc[i];
      cout << endl;
    }
  }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,M;
  cin >> N >> M;
  int A[N];
  int sum=0;
  for(int i=0;i<N;i++){
    cin >> A[i];
    sum +=A[i];
  }
  int count=0;
  for(int i=0;i<N;i++){
    if(A[i]>=double(sum)/4.0/double(M))count++;
  }
  if(count >=M) cout << "Yes";
  else cout << "No";
}


Measured memory_bytes: 256
import  numpy as np
a,b = map(int,input().split())
def factorize(N):
    up = int(np.sqrt(N))+2
    out = {}

    for i in range(2,up):
        if N%i == 0:
            temp = N
            count = 0
            while(True):
                N = N//i
                count += 1
                if N%i != 0:
                    break
            out[i] = count
        else:
            continue
    if N != 1:
        out[N] = 1
    return out

a = factorize(a)
b = factorize(b)

sa = set()
sb = set()

for t in a:
    sa.add(t)
for t in b:
    sb.add(t)

t = sa&sb
print(len(t)+1)

Measured memory_bytes: 14548
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 1000000000000000000
using namespace std;
bool judge(ll a,ll c,string s){
    for(int i=a;i<c;i++){
        if(s[i]=='#'&&s[i+1]=='#')return false;
    }
    return true;
}
int main(void){
    ll n,a,b,c,d;cin>>n>>a>>b>>c>>d;a--;b--;c--;d--;
    string s;cin>>s;
    if(c<b||(b<c&&c<d)){
        if(judge(a,c,s)&&judge(b,d,s))cout<<"Yes";
        else cout<<"No";
    }
    else{
        bool ans=true;
        for(int i=b;i<=d;i++){
            if(s[i-1]=='.'&&s[i]=='.'&&s[i+1]=='.'){
                if(judge(a,c,s)&&judge(b,d,s)){cout<<"Yes";ans=false;}
                break;
            }
        }
        if(ans)cout<<"No";
    }
    
}

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

int main()
{
    int N;
    cin >> N;
    int a = 0;
    for (int i = 1; i <= N; i++) {
        if (i % 2 != 0) a++;
    }
    float ans = a / (float)N;
    printf("%.10f", ans);
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

LL add(LL a, LL b) { return (a + b) % kMod; }
LL mul(LL a, LL b) { return (a * b) % kMod; }

int main() {
  string S; cin >> S;
  int L = S.size();
  LL total = 1;
  vector<map<char, LL>> dp(L + 1, map<char, LL>());
  for (int i = 0; i < L; ++i) {
    if (S[i] == 'A') {
      dp[i + 1]['a'] = add(dp[i]['a'], total);
      dp[i + 1]['b'] = dp[i]['b'];
      dp[i + 1]['c'] = dp[i]['c'];
    } else if (S[i] == 'B') {
      dp[i + 1]['a'] = dp[i]['a'];
      dp[i + 1]['b'] = add(dp[i]['b'], dp[i]['a']);
      dp[i + 1]['c'] = dp[i]['c'];
    } else if (S[i] == 'C') {
      dp[i + 1]['a'] = dp[i]['a'];
      dp[i + 1]['b'] = dp[i]['b'];
      dp[i + 1]['c'] = add(dp[i]['c'], dp[i]['b']);
    } else {  // ?
      dp[i + 1]['a'] = add(mul(dp[i]['a'], 3), total);
      dp[i + 1]['b'] = add(mul(dp[i]['b'], 3), dp[i]['a']);
      dp[i + 1]['c'] = add(mul(dp[i]['c'], 3), dp[i]['b']);
      total = mul(total, 3);
    }
  }
  cout << dp[L]['c'] << endl;
}


Measured memory_bytes: 26692
#include<bits/stdc++.h>
#define ll long long
#define N 200005
using namespace std;
int head[N],ver[N*4],nxt[N*4],tot;
void add(int a,int b)
{
	tot++;nxt[tot]=head[a];head[a]=tot;ver[tot]=b;
	tot++;nxt[tot]=head[b];head[b]=tot;ver[tot]=a;
	return ;
}
int n,a,b,x,y;
struct node
{
	int x,y,id;
	friend bool operator < (const node &aa,const node &bb)
	{
		if(aa.x!=bb.x)return aa.x<bb.x;
		return aa.y<bb.y;
	}
}p[N];
int v[N],ad[N],du[N];
long long ans;
void calc(int dx,int dy)
{
	sort(p+1,p+n+1);
	memset(ad,0,sizeof(ad));
	for(int i=1;i<=n;i++)
	{
		int l = lower_bound(p+1,p+n+1,(node){p[i].x-dx,p[i].y -dy,-1})-p;
        int r = upper_bound(p+1,p+n+1,(node){p[i].x-dx,p[i].y +dy,-1})-p;
 		
 		if(l>=r)continue;
 		
 		du[p[i].id]+=r-l;
 		add(p[i].id,p[l].id);
 		ad[l]++;ad[r-1]--;
	}
	for(int i=1;i<=n;i++)
	{
		ad[i]+=ad[i-1];
		if(ad[i]==0)continue;
		add(p[i].id,p[i+1].id);
	}
}

void dfs(int x)
{
	v[x]=1;
	ans+=du[x];
	for(int i=head[x];i;i=nxt[i])
	{
		if(!v[ver[i]])dfs(ver[i]);
	}
}
int main()
{
	scanf("%d%d%d",&n,&a,&b);
	for(int i=1;i<=n;i++)scanf("%d%d",&x,&y),p[i]={x-y,x+y,i};
	int d=max(abs(p[a].x-p[b].x),abs(p[a].y-p[b].y));
	calc(d,d);
	for(int i=1;i<=n;i++)swap(p[i].x,p[i].y);
	calc(d,d-1);
	dfs(a);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 12544
#include <iostream>
using namespace std;
int main(void){
   
    string S;
    cin >> S;
    

    if ( S == "Sunny" ){
        cout << "Cloudy" << endl;
    }
    if ( S == "Cloudy" ){
        cout << "Rainy" << endl;
    }
    if ( S == "Rainy" ){
        cout << "Sunny" << endl;
    }
}


Measured memory_bytes: 256
import sys
s = input()
for i in range(8):
    siki = s[0]
    tmp = int(s[0])
    for j in range(3):
        if i&(1<<j):
            siki = siki+'+'+s[j+1]
            tmp+=int(s[j+1])
        else:
            siki = siki + '-' + s[j+1]
            tmp-=int(s[j+1])
    if tmp==7:
        print(siki,"=7",sep="")
        exit()

Measured memory_bytes: 9204
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
#define size(a) int((a).size())
#define present(c, x) (c.find(x) != c.end()) 
#define printVerdict(verdict) cout << (verdict ? "yes": "no") << '\n'
#define printDecimal(d) printf("%.9f\n", d)
#define inrange(val, start, end) (val >= start && val <= end)
 
const int mod = 1e9 + 7; 
 
template <class T1, class T2, class T3> 
void printTuple(tuple<T1, T2, T3> t) { cout << get<0>(t) << " " << get<1>(t) << " " << get<2>(t) << '\n'; }
template <class T1, class T2>
void printPair(pair<T1, T2> p) { cout << p.first << " " << p.second  << '\n'; }
template <class T>
void printArray(vector<T> arr) { for (int i = 0; i<size(arr); i++) {cout << arr[i] << " ";} cout << '\n'; } 

map<int, int> cnt;

bool sieve(int maxVal) {
	vector<bool> is_prime(maxVal + 1, true);
	for (int i = 2; i<=maxVal; i++) {
		if (is_prime[i]) {
			int curr = (present(cnt, i) ? cnt[i] : 0);
			for (int j = i*2; j <=maxVal; j+= i) {
				is_prime[j] = false;
				if (present(cnt, j)) curr += cnt[j];
				if (curr > 1) return false;
			}
		}
	}
	return true;
}

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n, maxVal = 0; cin >> n;
	int a[n];
	for (int i = 0; i<n; i++) {
		cin >> a[i];
		maxVal = max(maxVal, a[i]);
		if (!present(cnt, a[i])) cnt[a[i]] = 1;
		else cnt[a[i]]++;
	}
	int curr_gcd = a[0];
	for (int i = 1; i<n; i++) curr_gcd = __gcd(curr_gcd, a[i]);
	if (curr_gcd != 1) cout << "not coprime" << '\n';
	else {
		bool pairwise = sieve(maxVal);
		cout << (pairwise ? "pairwise coprime" : "setwise coprime") << '\n';
	}
}



Measured memory_bytes: 54368
using System;
using System.Collections.Generic;
namespace ITP1_5_B
{
    class Problem
    {

        public static List<string[]> getinputdata (){

            List<string[]> list_temp = new List<string[]>();
            string strdata = Console.ReadLine ();

            while (strdata!=null) {

                string[] s_temp = strdata.Split (' ');

                list_temp.Add (s_temp);

                strdata = Console.ReadLine ();

            }

            return list_temp;
        }


        public static void DrawRectangle (int h,int w){

            //????±?????????°??????????????????
            for (int j = 0; j < h; j++)
            {
                
                //???????????¨??????????????????????????????
                if (j == 0 || j == h - 1)
                {
                    string strdata = new string('#', w);
                    Console.WriteLine(strdata);
                }
                else
                {
                    string strdata = "#" + new string('.', w - 2) + "#";
                    Console.WriteLine(strdata);
                }
                   

      
            }

            Console.WriteLine();
        }

        public static void Main (string[] args)
        {
            List<string[]> list_result = new List<string[]>();
            list_result = getinputdata ();

            int H;
            int W;

            for (int i = 0; i < list_result.Count-1; i++)
            {
                H = int.Parse(list_result[i][0]);
                W = int.Parse(list_result[i][1]);

                DrawRectangle(H, W);
            }

        }
    }
}

Measured memory_bytes: 9268
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
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; }

int k, t, a[110];

int main() {
    cin >> k >> t;
    rep(i, t) cin >> a[i];

    int ans = 0;
    rep(i, t) {
        if (a[i] >= k / 2) chmax(ans, 2 * a[i] - k - 1);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  int a,b,c;
  cin>>a>>b>>c;
  if(b - a == c - b) {
    cout <<"YES" << endl;
  } else {
    cout << "NO" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Spliterator;
import java.util.Spliterators;
import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.IntStream;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;

public class Main{
	static Scanner s=new Scanner(System.in);
	static long[] fal_rnd(int size){
		AtomicInteger l=new AtomicInteger(-1),r=new AtomicInteger(size);
		long[] res=new long[size];
		INS(size).unordered().parallel().mapToLong(Long::parseLong).forEach(v->res[ThreadLocalRandom.current().nextBoolean()?l.incrementAndGet():r.decrementAndGet()]=v);
		return res;
	}
	static IntStream REPS(int v){
		return IntStream.range(0,v);
	}
	static Stream<String> INS(long size){
		return StreamSupport.stream(Spliterators.spliterator(s,size,Spliterator.NONNULL&Spliterator.IMMUTABLE),false).limit(size);
	}
	
	public static void main(String[] __){
		int a=s.nextInt(),b=s.nextInt();
		System.out.println(Math.min(solve(a,b),solve(b,a)));
	}
	private static long solve(long w,long h){
		long r=Integer.MAX_VALUE;
		for(int i=0;i<=w;i++) {
			long sg=h*i;
			
			long sb=(h+1)/2*(w-i);
			long sr=h/2*(w-i);
			r=Math.min(r,Math.abs(Math.max(sg,sb)-Math.min(sg,sr)));
			sb=(w-i+1)/2*h;
			sr=(w-i)/2*h;
			r=Math.min(r,Math.abs(Math.max(sg,sb)-Math.min(sg,sr)));
		}
		return r;
	}
}



Measured memory_bytes: 23764
#!/usr/bin/env python3
import sys

class Node:
    def __init__(self,v):
        self.value = v
        self.next = None
        self.prev = None
    
    def insertHead(self,v):
        self.prev = v
        v.next = self
        return v

    def appendBottom(self,v):
        self.next = v
        v.prev = self
        return v

    def printRecursively(self):
        current = self
        s = ""
        while True:
            if current == None:
                break
            s += current.value
            current = current.next
        print(s)

    def printRecursivelyInvert(self):
        current = self
        s = ""
        while True:
            if current == None:
                break
            s += current.value
            current = current.prev
        print(s)

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S=next(tokens)
    Q=int(next(tokens))
    queries = []
    invert = False
    for i in range(Q):
        t = int(next(tokens))
        if t == 1:
            queries.append((t,))
        else:
            queries.append((t,int(next(tokens)),next(tokens)))
    tail = Node(S[0])
    head = tail
    for i in range(1,len(S)):
        tail = tail.appendBottom(Node(S[i]))
    for query in queries:
        if query[0] == 1:
            invert = not invert
        else:
            if query[1] == 1:
                if invert:
                    tail = tail.appendBottom(Node(query[2]))
                else:
                    head = head.insertHead(Node(query[2]))
            else:
                if not invert:
                    tail = tail.appendBottom(Node(query[2]))
                else:
                    head = head.insertHead(Node(query[2]))
    if invert:
        tail.printRecursivelyInvert()
    else:
        head.printRecursively()
    pass

if __name__ == '__main__':
    main()


Measured memory_bytes: 71120
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repk(i,m,n) for(int i=m;i<n;i++)
#define IOS ios::sync_with_stdio(false);cin.tie(0);
#define F first
#define S second
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
using namespace std;
const int MOD1=1e9+7;
const int MOD2=998244353;
const ll INF=2*1e18;
const ld PI=3.14159265358979323846;
int main()
{
    map<string,ll> m;
    string s;
    ll n,ans=0;
    cin>>n;
    rep(i,n)
    {
        cin>>s;
        if(m[s]==0) ans++;
        m[s]++;
    }
    cout<<ans;
}


Measured memory_bytes: 19256
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 1e-5
#define LONG_INF 2000000000000000000LL
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL
#define MOD 998244353LL
#define seg_size 262144
#define REP(a,b) for(long long a = 0;a < b;++a)
int main(){
#define int long long
	int n;
	cin >> n;
	vector<int> inputs;
	long long now = 0;
	REP(i, n) {
		int a;
		cin >> a;
		inputs.push_back(a);
		now += a;
	}
	long long ans = LONG_INF;
	long long now_itr = 0;
	REP(i, n) {
		now_itr += inputs[i];
		ans = min(ans, llabs(now_itr - (now - now_itr)));
	}
	cout << ans << endl;
}

Measured memory_bytes: 2420
#include <cstdio>
#include <vector>
using namespace std;
int main() {
	int n, k;
	while (scanf("%d %d",&n,&k)&&n!=0) {
		vector<int> a(n);
		for (int i=0; i<n; i++) scanf("%d",&a[i]);
		int max=0;
		for (int i=0; i<k; i++) max+=a[i];
		int tmp=max;
		for (int i=0; i<n-k; i++) {
			tmp=tmp-a[i]+a[i+k];
			if (tmp>max) max=tmp;
		}
		printf("%d\n",max);
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
/*    #ifndef ONLINE_JUDGE
      // for getting input from input.txt
      freopen("input.txt", "r", stdin);
      // for writing output to output.txt
      freopen("output.txt", "w", stdout);
  #endif*/
fast();
ll n;
cin>>n;
ll a[n],b[n],c[n];
for(int i=0;i<n;i++)
{
  c[i]=(i+1);
}
for(int i=0;i<n;i++)
{
  ll x;
  cin>>a[i];
  //a.pb(x);
  
}
  for(int i=0;i<n;i++)
  {
    ll x;
    cin>>b[i];
   // b.pb(x);
    
  }
ll x=0,y=0,i=0,j=0;
do{
  ll f=0,g=0;
  for(int k=0;k<n;k++)
  {
    if(a[k]!=c[k])
    {f=1;
      break;
    }
  }
  if(f==0)
  {
       x=i;
  }
        else
        {
          i++;
        }

        for(int k=0;k<n;k++)
  {
    if(b[k]!=c[k])
    {g=1;
      break;
    }
  }
  if(g==0)
  {
       y=j;
  }
        else
        {
          j++;
        }
}while(next_permutation(c,(c + n)));

cout << abs(x-y)<<endl;
  
  


return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FAST_IO                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define watch(x) cout << (#x) << " is: " << (x) << endl
#define vw(v)                        \
    cout << endl                     \
         << endl                     \
         << (#v) << " is: " << endl; \
    for (int B : (v))                \
    {                                \
        cout << B << " ";            \
    }                                \
    cout << endl
#define check(x) cout << "here " << (x) << "?" << endl
#define rep(i, a, b) for (long long i = (a); i < (b); i++)
#define per(i, a) for (long long i = (a - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rv(x) (x).rbegin(), (x).rend()
#define pb push_back
typedef long long ll;
ll const MAX = 2147483647, REALMAX = 9223372036854775806;
//const int N =
int main()
{
    FAST_IO
    string s;
    cin >> s;
    int sum = 0;
    rep(i, 0, s.size() / 2)
    {
        if (s[i] != s[s.size() - i - 1])
            sum++;
    }
    cout << sum;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static Scanner sc = new Scanner(System.in);
	public static void main(String[] args){
		//A
		int R = sc.nextInt();
		if(R < 1200)
			System.out.println("ABC");
		else if(R < 2800)
			System.out.println("ARC");
		else
			System.out.println("AGC");
	}
}


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

int main()
{
ll a,b,c,d,ans;
cin>>a>>b>>c>>d;
ans=a*c;
ans=max(ans,a*d);
ans=max(ans,b*c);
ans=max(ans,b*d);
cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 3632
# ABC 112: B – Time Limit Exceeded
N, T = [int(s) for s in input().split()]

min_cost = 9999

for _ in range(N):
    c, t = [int(s) for s in input().split()]
    min_cost = min(min_cost, c) if t <= T else min_cost

print(min_cost if min_cost != 9999 else 'TLE')

Measured memory_bytes: 3060
fn solve(ds: Vec<usize>) -> usize {
    let mut ans = 0;
    for i in 0..ds.len() {
        for j in (i + 1)..ds.len() {
            ans += ds[i] * ds[j];
        }
    }

    ans
}

#[test]
fn test_solve() {
    assert_eq!(solve(vec![3, 1, 2]), 11);
    assert_eq!(solve(vec![5, 0, 7, 8, 3, 3, 2]), 312);
}

#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        line.pop();
        line
    }};
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        let iter = line.split_whitespace();
        iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
    }};
}

fn main() {
    let _n = parse_line!(usize);
    let ds = parse_vec!(usize);

    println!("{}", solve(ds));
}


Measured memory_bytes: 4352
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define max0(a,b,c) max(max(a,b),c)
#define min0(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
using Graph = vector<vector<int>>;
typedef long long lint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldouble;
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<ull> ulvec;
typedef vector<double> dvec;
typedef vector<pair<int,int>> pvec;
typedef vector<pair<ll,ll>> plvec;
typedef vector<tuple<ll,ll,ll>> tvec;
typedef vector<string> svec;

int main(){
    ll n,m,v,p,ans=0;
    cin>>n>>m>>v>>p;
    lvec a(n);
    rep(i,n)cin>>a[i];
    sort(all(a));
    ans+=p;
    ll s=n-p;
    lvec r(n+1,0);
    for(int i=0;i<n;i++) r[i+1]=r[i]+a[i];
    for(int i=s-1;i>=0;i--){
        if(i-v+1>=0){
            if(a[i]+m>=a[s])ans++;
        }else{
            ll t=v-(i+1);
            if(n-t>s){
                if(a[i]+m>=a[s])ans++;
            }else{
                if(a[i]+m<a[s]) break;
                ll k=-p+t+1;
                if(a[i+k]==a[i])ans++;
                else{
                ll h=lower_bound(a.begin()+i+1,a.begin()+i+k,a[i]-m)-a.begin();
                ll j=i+k-(h-1);
                ll R=r[i+k+1]-r[h];
                ll A=m*j+R-(a[i]+m)*j;
                ll B=n-p-(i+k);
                ll C=B*(a[i]+m)-(r[n-p+1]-r[i+k+1]);
                if(A<=C)ans++;
                }
                
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
const int MAX_V =10010;
int V,E;//頂点数
vector<int> G[MAX_V];//グラフの隣接リスト
vector<int> rG[MAX_V];//辺の向きを逆にしたグラフ
vector<int> vs;//帰りがけ順の並び
bool used[MAX_V];//既に調べたか
int cmp[MAX_V];//強連結成分のトポロジカル順序
//同じ強連結成分に属しているな1そうでないなら0を返す
void dfs(int v){//まずdfsでたどる
	used[v]=true;
	for(int i =0;i < G[v].size();i++){
		if(!used[G[v][i]])dfs(G[v][i]);
	}
	vs.push_back(v);
}

void rdfs(int v,int k){//次に逆辺をたどる
	used[v]=true;
	cmp[v]=k;
	for(int i =0;i < rG[v].size();i++){
		if(!used[rG[v][i]])rdfs(rG[v][i],k);
	}
}

int scc(){//強連結成分を求める
	memset(used, false, sizeof(used));
	vs.clear();
	for(int v =0;v <V;v++){//まずdfsでたどる
		if(!used[v])dfs(v);
	}
	memset(used, false, sizeof(used));
	int k = 0;//今日連結成分の個数

	for(int i =vs.size()-1;i >=0;i--){
		if(!used[vs[i]])rdfs(vs[i],k++);
	}
	return k;
}


int main(){
	cin>>V>>E;
	for(int i =0;i < E;i++){
		int x,y;
		cin>>x>>y;
		G[x].push_back(y);
		rG[y].push_back(x);
	}
	scc();
	int Q;
	cin>>Q;
	for(int i =0;i <Q;i++){
		int x,y;
		cin>>x>>y;
		if(cmp[x]==cmp[y]){
			cout <<1<<endl;
		}else{
			cout <<0<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 2784
#include <cstdio>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

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

using ll = long long;

std::string N;

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

  ll ans = 0;

  rep( i, N.size()+1 ) if( i >= N.size() || N[i]-'0' >= 1 )
  {
    ll cnt = i<N.size()?N[i]-1-'0':0;

    rep( j, N.size() ) if( j != i )
      cnt += j<i ? N[j]-'0' : 9;

    ans = std::max( ans, cnt );
  }

  printf( "%lld\n", ans );

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long int
#define ldouble long double
#define vin vector<int> 
#define rep(i,a,n) for(i=(a);i<(n);i++)
#define INF (int)1000000007

//setprecision()<<

using namespace std;

void fin(int i,int n,vin &a){
    rep(i,0,n){
        cin>>a.at(i);
    } 
} 

signed main() {
    int i;
    int N;
    cin>>N;
    vin a(N);
    fin(i,N,a);
    vin result(0);
    int M=0;
    vin tmp(N,0);
    
    for(int i=N;i>0;i--){
        int sum=0;
        for(int j=2*i;j<=N;j+=i){
            sum=sum^tmp.at(j-1);
        }
        if(sum!=a.at(i-1)){
            result.push_back(i);
            M++;
            tmp.at(i-1)=1;
        }
    }

    cout<<M<<endl;
    for(int i=0;i<M;i++){
        cout<<result.at(i)<<" ";
    }
    if(M>0){
        cout<<endl;
    }
    
return 0;
}

Measured memory_bytes: 4980
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

template<typename T>
struct LazySegTree {
	vector<T> node, lazy;
	vector<bool> done;
	int n;
	T init_val;
	
	LazySegTree(int _n, T init_val) : init_val(init_val) {
		n = 1;
		while (n < _n) n *= 2;
		node.resize(n * 2 - 1, init_val);
		lazy.resize(n * 2 - 1, init_val);
		done.resize(n * 2 - 1, true);
	}
	
	void eval(int k, int l, int r) {
		if (done[k]) return;
		chmin(node[k], lazy[k]);
		// node[k] = lazy[k];
		
		if (r - l > 1) {
			chmin(lazy[k * 2 + 1], lazy[k]);
			chmin(lazy[k * 2 + 2], lazy[k]);
			// lazy[k * 2 + 1] = lazy[k];
			// lazy[k * 2 + 2] = lazy[k];
			done[k * 2 + 1] = false;
			done[k * 2 + 2] = false;
			
		}
		done[k] = true;
	}
	
	void update(int a, int b, T x, int k = 0, int l = 0, int r = -1) {
		if (r < 0) r = n;
		eval(k, l, r);
		
		if (a >= r || b <= l) return;
		if (a <= l && r <= b) {
			chmin(lazy[k], x);
			// lazy[k] = x;
			done[k] = false;
			eval(k, l, r);
		}
		else {
			update(a, b, x, k * 2 + 1, l, (l + r) / 2);
			update(a, b, x, k * 2 + 2, (l + r) / 2, r);
			node[k] = min(node[k * 2 + 1], node[k * 2 + 2]);
		}
	}
	
	T query(int a, int b, int k = 0, int l = 0, int r = -1) {
		if (r < 0) r = n;
		eval(k, l, r);
		
		if (a >= r || b <= l) return init_val;
		if (a <= l && r <= b) return node[k];
		
		T vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
		T vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
		return min(vl, vr);
	}
};

int main() {
	int N, M;
	string S;
	cin >> N >> M;
	cin >> S;
	
	LazySegTree<pii> seg(N + 1, pii(INF, 0));
	seg.update(0, 1, pii(0, -1));
	
	REP(i, S.size()) {
		if (S[i] == '1') continue;
		int r = i + M;
		chmin(r, N);
		seg.update(i + 1, r + 1, pii(seg.query(i, i + 1).fi + 1, i));
	}
	
	int ansl = seg.query(N, N + 1).fi;
	if (ansl == INF) {
		puts("-1");
		return 0;
	}
	
	vector<int> ans;
	int pos = N;
	while (pos != 0) {
		int npos = seg.query(pos, pos + 1).se;
		ans.push_back(pos - npos);
		pos = npos;
	}
	reverse(ALL(ans));
	REP(i, ans.size()) printf("%d%c", ans[i], i == ans.size() - 1 ? '\n' : ' ');
	return 0;
}


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


int main() {
    ll n; cin >> n;
    vector<ll> a(n);
    rep(i,n){
        cin >> a[i];
    }
    ll x=1;
    rep(i,n){
        if(a[i]==x){
            x++;
        }
    }
    if(x==1) x=n+2;
    cout << n-x+1 << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,A,B,C=0,D;
  
  cin>>N;
  A=N;
  while(A>=1){
     B=A%10;
    A=A/10;
   
    C=C+B;}
//cout<<C<<endl;
  D=N%C;
  
  if(D==0){
    cout<<"Yes"<<endl;}
else{
    cout<<"No"<<endl;}
}

Measured memory_bytes: 3616
from collections import Counter
import numpy as np

N,K=[int(_) for _ in input().split()]
a_lst=[int(_) for _ in input().split()]

counter=Counter(a_lst)
v_arr=np.zeros(len(counter)).astype(int)
for i, (k, v) in enumerate(counter.items()):
    v_arr[i]=v
v_arr=np.sort(v_arr)
total=v_arr.sum()
top=v_arr[-K:].sum()
print(total-top)

Measured memory_bytes: 41988
#include <stdio.h>

int main(void){
    int i, ANS=700;
    char S[10];
    scanf("%s", S);
    for(i=0; i<3; i++){
        if(S[i] == 'o') ANS+=100;
    }
    printf("%d\n", ANS);
    return 0;
}


Measured memory_bytes: 128
s = raw_input()
t = raw_input()

dp = [[0] * (len(t) + 1) for _ in range(len(s) + 1)]
for i in range(1, len(s) + 1):
    for j in range(1, len(t) + 1):
        dp[i][j] = max(dp[i - 1][j], dp[i][j - 1])
        if s[i - 1] == t[j - 1]:
            dp[i][j] = max(dp[i][j], 1 + dp[i - 1][j - 1])
        else:
            dp[i][j] = max(dp[i][j], dp[i - 1][j - 1])

l = dp[len(s)][len(t)]
resp = []
inds = len(s)
indt = len(t)
while len(resp) < l:
    if s[inds - 1] == t[indt - 1] and dp[inds][indt] == 1 + dp[inds - 1][indt - 1]:
        resp.append(s[inds - 1])
        inds -= 1
        indt -= 1
        continue
    if dp[inds][indt] == dp[inds - 1][indt - 1]:
        inds -= 1
        indt -= 1
        continue
    if dp[inds][indt] == dp[inds - 1][indt]:
        inds -= 1
        continue
    if dp[inds][indt] == dp[inds][indt - 1]:
        indt -= 1
        continue
resp.reverse()
print(''.join(resp))


Measured memory_bytes: 103580
import statistics

n=int(input())
a=list(map(int,input().split()))

ans=[]
for i in range(n):
  ans.append(a[i]-(i+1))
  
b=statistics.median(ans)
b=int(b)


mid=b
  
ans1=0

for j in range(n):
  ans1+=abs(a[j]-mid-(j+1))
  
print(ans1)

Measured memory_bytes: 113768
#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() {
    int n ;
    cin >> n ;
    string s ;
    cin >> s ;
   int ans=1 ;
    rep(i,n-1){
        if( s.at(i)!=s.at(i+1))
ans++ ;
         }

cout << ans <<endl ;
  return 0;

}


Measured memory_bytes: 512
N = int(input())
XY = tuple(tuple(map(int, input().split())) for _ in range(N))

lx = 0
rx = 1000
ans = 10 ** 18
for _ in range(100):
    ly = 0
    ry = 1000
    mlx = (2 * lx + rx) / 3
    for _ in range(100):
        mry = (ly + 2 * ry) / 3
        mly = (2 * ly + ry) / 3

        Rr = max((x - mlx) ** 2 + (y - mry) ** 2 for x, y in XY)
        Rl = max((x - mlx) ** 2 + (y - mly) ** 2 for x, y in XY)
        if Rl < Rr:
            ry = mry
        else:
            ly = mly
    R_left = Rl

    ly = 0
    ry = 1000
    mrx = (lx + 2 * rx) / 3
    for _ in range(100):
        mry = (ly + 2 * ry) / 3
        mly = (2 * ly + ry) / 3

        Rr = max((x - mrx) ** 2 + (y - mry) ** 2 for x, y in XY)
        Rl = max((x - mrx) ** 2 + (y - mly) ** 2 for x, y in XY)
        if Rl < Rr:
            ry = mry
        else:
            ly = mly
    R_right = Rl

    if R_left < R_right:
        rx = mrx
    else:
        lx = mlx

print(R_right ** 0.5)

Measured memory_bytes: 3188
import java.util.*;
import java.math.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		List<Integer> list = new ArrayList<>();

		int a = sc.nextInt();
		int b = sc.nextInt();
		int t = sc.nextInt();

		System.out.println((t / a) * b);
	}
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define forr(i,p,n) for(ll i=p;i<n;i++)
#define tam 12000
#define offset 50000
using namespace std;
typedef long long  ll;
typedef pair<ll,ll> ii;
typedef pair<ll,ii> iii;
const ll MOD=1e9+7;
vector<ll> pals(26,0);
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    ll n;
    cin>>n;
    string txt;
    map<vector<ll>,ll> mapa;
    ll tot=0;
    forr(i,0,n)
    {
        cin>>txt;
        forr(k,0,26)
        pals[k]=0;
        forr(j,0,txt.size())
        {
            pals[txt[j]-'a']++;
        }
        tot+=mapa[pals];
        mapa[pals]++;
    }
    cout<<tot<<'\n';
}

Measured memory_bytes: 29952
s = raw_input()
letters = [3]*26
done = False
for i in range(97,123):
    c = str(unichr(i))
    dist = -1
    for j in xrange(len(s)):
        if (dist >= 0):
            dist += 1
        if (c==s[j]):
            if (dist <= 2 and dist >= 0):
                done = True
                print str(j+1-dist) + " " + str(j+1)
                break
            dist = 0
    if done:
        break
if not done:
    print "-1 -1"

Measured memory_bytes: 2692
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n, k;
int v[51];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n >> k;
  REP(i, n) cin >> v[i];

  int ans = 0;
  for(int i=0; i<=min(n, k); i++) {
    for(int j=0; j<=min(n-i, k-i); j++) {
      priority_queue <int, vector<int>, greater<int>> que;
      int sum = 0;

      REP(k, i) {
        sum += v[k];
        if(v[k] < 0) que.push(v[k]);
      }

      for(int k=n-1;k>n-1-j; k--) {
        sum += v[k];
        if(v[k] < 0) que.push(v[k]);
      }

      int c = k-i-j;
      while (!que.empty() && c > 0) {
        sum -= que.top(); que.pop();
        c--;
      }

      ans = max(ans, sum);
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
n=int(input())
tarou=0
hanako=0
cnt=0

while True:
    t,h=input().split()
    a=0
    if t==h:
        tarou+=1
        hanako+=1
        a=1
    if a==0:
        for i in range(min(len(t),len(h))):
            if t[i]>h[i]:
                tarou+=3
                break
            elif t[i]<h[i]:
                hanako+=3
                break
            if i==min(len(t),len(h))-1:
                if len(t)>len(h):
                    tarou+=3
                    break
                else:
                    hanako+=3
                    break
    cnt+=1
    if cnt==n:
        break
print(tarou,hanako)




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

int gcd(int a, int b){
    if(a<b){
        int tmp=a;
        a = b;
        b = tmp;
    }
    if(b==0) return a;
    return gcd(b, a%b);
}

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n)   cin >> a[i];
    
    vector<int> l(n+1);
    vector<int> r(n+1);

    l[0] = 0;
    r[n] = 0;

    for(int i=1;i<=n;i++){
        l[i] = gcd(l[i-1], a[i-1]);
        r[n-i] = gcd(r[n-i+1], a[n-i]);
    }

    int ans = 0;
    rep(i, n){
        int tmp=gcd(l[i],r[i+1]);
        ans = max(ans, tmp);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}




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


  ll N ; cin >> N ;
  vector<ll> a;
  rep(i,N){
    ll inp; cin >> inp;
    a.pb(inp);
  }
  
  ll ans1 = 0;
  ll sum = 0;
  rep(i,N){
    sum += a[i];
    if(i%2 == 0){
      if(sum <= 0) { ans1 += abs(sum); ans1 ++; sum  = 1 ;}
    }
    else{
      if(sum >= 0){  ans1 += abs(sum); ans1 ++; sum = -1;}
    }
  }
  ll ans2 = 0;
  sum = 0;
  rep(i,N){
    sum += a[i];
    if(i%2 == 1){
      if(sum >0) continue;
      else {ans2 += abs(sum); ans2 ++; sum = 1; }
    }
    else{
      if(sum < 0 ) continue;
      else{ ans2 += abs(sum); ans2 ++; sum = -1;}
    }
  }

  cerr << ans1 << " " << ans2 << endl;
  cout << min(ans1, ans2) << endl;
  
  
  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


Measured memory_bytes: 1400
import java.math.BigDecimal;
import java.math.MathContext;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.next();
        long k = scanner.nextLong();
        for (int i = 0;i < s.length();++i){
            int a = Integer.valueOf(s.substring(i,i + 1));
            if(a != 1){
                System.out.println(a);
                return;
            }
            else if(k - 1 == i){
                System.out.println(a);
                return;
            }
        }
    }

}




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

#define pb push_back
#define eb emplace_back
#define ff first
#define ss second
typedef long long int ll;
typedef long double ld;
#define all(a) a.begin(),a.end()
typedef vector<ll> vl;
typedef map<ll,ll> ii;
const ll mod = 998244353;


//main code
int main() {
    ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
    
    ll t;cin>>t;
    vl v(t,0);
    ii m;
    for(int i=0;i<t;i++){
        cin>>v[i];
        m[v[i]]++;
    }
    ll ans=0;
    for (auto i:m){
        ans+=(i.ss*(i.ss-1))/2;
    }
    for(int i=0;i<t;i++){
        ll z=ans;
        ll a=m[v[i]];
        ans-=(a*(a-1))/2;
        a--;
        ans+=(a*(a-1))/2;
        
        cout<<ans<<"\n";
    
        ans=z;
    }
    
    return 0;
    
}
    

Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
ll gcd(ll a, ll b) {
return b ? gcd(b, a%b) : a;
}

ll lcm(ll a, ll b){
return a / gcd(a, b) * b;
}

int main(){
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    a--;
    ll ans;
    ans = b - b/c - b/d + b/lcm(c,d);
    ans -= a - a/c -a/d + a/lcm(c,d);
    cout << ans <<endl;
}

Measured memory_bytes: 256
def main():
    n=int(input())
    A=list(map(int,input().split()))
    B=list(map(int,input().split()))[::-1]
    Cnt=[0]*(n+1)
    for a,b in zip(A,B):
        Cnt[a]+=1
        Cnt[b]+=1
    if max(Cnt)>n:
        print('No')
        return
    l=0
    r=n-1
    for i in range(n):
        if A[i]==B[i]:
            if B[l]!=A[i] and A[l]!=A[i]:
                B[l],B[i]=B[i],B[l]
                l+=1
            else:
                B[r],B[i]=B[i],B[r]
                r-=1
    print('Yes')
    print(*B)
    return
    
if __name__=='__main__':
    main()

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

int32_t main(){
    int n, k;
    cin >> n >> k;
    vector<int> fruits(n);
    for(int i=0; i<n; i++){
        cin >> fruits[i];
    }
    sort(fruits.begin(), fruits.end());
    int ans = 0;
    for(int i=0; i<k; i++){
        ans += fruits[i];
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3648
#include<iostream>
#include<vector>
using namespace std;
int main(){
	int h,w;
	cin >> h >> w;
	vector<string> s(h);
	for(int i=0;i<h;i++) cin >> s[i];
	vector<vector<int>> num(h,vector<int>(w));
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(s[i][j]=='.') num[i][j]=0;
			else num[i][j]=-1;
		}
	}
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(num[i][j]==-1) {
				for(int x=-1;x<=1;x++){
					for(int y=-1;y<=1;y++){
						if((i+y<0||h<=i+y||j+x<0||w<=j+x) || (x==0&&y==0) || num[i+y][j+x]==-1) continue;
						else num[i+y][j+x]++;
					}
				}
			}
		}
	}
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(num[i][j]==-1) cout << '#';
			else cout << num[i][j];
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
enemy_sum = sum(A)
for i in range(N):
    if A[i] + A[i + 1] < B[i]:
        A[i+1] = 0
        A[i] = 0
    elif A[i] < B[i] <= A[i] + A[i + 1]:
        A[i+1] -= B[i] - A[i]
        A[i] = 0
    elif B[i] <= A[i]:
        A[i] -= B[i]

remained_enemies_sum = sum(A)
killed_enemies_sum = enemy_sum - remained_enemies_sum
print(killed_enemies_sum)



Measured memory_bytes: 19004
import sys
import numpy as np
input = sys.stdin.readline

H, N = map(int,input().split())

AB = []

for i in range(N):
	a,b = map(int, input().split())
	AB.append([a,b])
AB = np.array(AB)
A = AB[:,0]
B = AB[:,1]
dp = np.array([0]*(H+1))
for i in range(1, H+1):
	dp[i] = np.amin(dp[np.maximum(i - A, 0)]+B)

print(dp[H])

Measured memory_bytes: 12616
N = int(input())
B = list(map(int,input().split()))
 
def A(N,B):
   sum = B[0] + B[N-2]
   for i in range(N-2):
       sum += min(B[i],B[i+1])
   print(sum)
 
if __name__=='__main__':
   A(N,B)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
template<class T> void print(const T& t){ cout << t << endl; }
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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
  ll n;
  cin >> n;
  ll m = sqrt(n);
  for (ll i = m; i >= 1;i--){
    if(n%i==0){
      ll ans = i - 1 + n / i - 1;
      print(ans);
      break;
    }
  }
}


Measured memory_bytes: 256
#coding: utf-8
s = str(input())
ans = 1
flg = 0

for i in range(1,len(s)):
	# print(str(s[i-1])+","+str(s[i]))
	if flg == 2:
		ans = ans + 1
		flg = 0
	elif flg == 1:
		# print("aa")
		# ans = ans+1
		flg = 2
	elif s[i] != s[i-1]:
		# print(i)
		ans = ans+1
	else:
		if i != len(s)-1:
			ans = ans+1
			# print("z")
		flg = 1
	# print(str(i)+" "+str(ans))
# if flg > 0:
# 	ans = ans+1

print(ans)


Measured memory_bytes: 3500