akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

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

        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadLong;
            var M = cin.ReadLongArray(5).Min();
            var ans = (long)Ceiling((double)N / (double)M) + 4;
            Console.WriteLine(ans);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}


Measured memory_bytes: 13396
import java.util.Scanner;

public class Main {
   public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      String s = sc.nextLine();
      String p = sc.nextLine();
      
      String check = s + s.substring(0,p.length());
      if(check.contains(p)) {
         System.out.println("Yes");
      } else {
         System.out.println("No");
      }
   }
}


Measured memory_bytes: 26332
#include<stdio.h>
int main(void){

	int a=0,b=0;
	int sum=0;
	int count=0;

	while(scanf("%d %d",&a,&b)!=EOF){
		count=1;
		sum=a+b;

		while(sum>=10){
			sum=sum/10;
			count++;
		}

		printf("%d\n",count);

	}
	return 0;
}



Measured memory_bytes: 2084
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

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

// container util
#define all(x) (x).begin(), (x).end()

// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x)                                         \
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
       << " " << __FILE__ << endl;

// typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

// constant
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
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 main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int a;
  string s;
  cin >> a >> s;

  if (3200 <= a)
    cout << s << endl;
  else
    cout << "red" << endl;

  return 0;
}

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

int N,L;

bool solve()
{
    bool isFind = false;
        for(int i=0;i<=N;i++)
        {
            if((2*i + 4*(N-i))==L)isFind = true;            
        }
    return isFind;
}

int main(void)
{
    bool result;
    cin >> N >> L;

    if(L%2!=0)cout << "No" << endl;
    else
    {
        result=solve();
        if(result) cout << "Yes" << endl;
        else cout << "No" << endl;
    }     

    return 0;

}

Measured memory_bytes: 3612
if __name__ == '__main__':
    S = list(input())
    N = len(S) - 1
    #print(S ,N)
    total = 0
    for i in range(1 << N):
        p = []
        for j in range(N):
            if ((i >> j) & 1) == 1:
                p.append(j+1)
        p.append(10)
        #print(p)
        b = 0
        a = 0
        for x in p:
            #print(S[b:x])
            a += int(''.join(S[b:x])) 
            b = x
        total += a
    print(total)

Measured memory_bytes: 3064
#include<stdio.h>
int main(void)
{
	int w, h, x, y, r;
	scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);
	if(((x-r)>=0)&&((y-r)>=0)&&((x+r)<=w)&&((y+r)<=h))
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 1012
package main

import (
	"fmt"
)

func main() {

	// 読み込み数取得
	var day string
	fmt.Scan(&day)

	// 曜日データ取得
	days := [...]string{"SUN", "SAT", "FRI", "THU", "WED", "TUE", "MON"}

	for i, checkDay := range days {
		if checkDay == day {
			if i != 0 {
				fmt.Printf("%d", i)
			} else {
				fmt.Printf("7")
			}
		}

	}

}


Measured memory_bytes: 512
n = int(input())
nums = [int(input()) for _ in range(n)]

sorted_nums = sorted(nums)

nums_idx = {}
for idx, num in enumerate(nums):
    nums_idx[num] = idx

sorted_nums_idx = {}
for idx, num in enumerate(sorted_nums):
    sorted_nums_idx[num] = idx

ans = 0
for num in sorted_nums:
    if (nums_idx[num] - sorted_nums_idx[num]) % 2 :
        ans += 1

print(ans // 2)


Measured memory_bytes: 35080
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const int MOD=1000000007;


int main() {
  int n,k;
  cin >> n >> k;
  vector<int> a(n);
  map<int,int> m;
  for(int i=0;i<n;i++){
    cin >> a.at(i);
    if(m.count(a.at(i)))
      m[a.at(i)]++;
    else
      m[a.at(i)]=1;
  }
  int s=m.size();
  int ans=0;
  if(s<=k){
    cout << 0 << endl;
    return 0;
  }
  else{
    priority_queue<int, vector<int>, greater<int>> pq;
    for (auto p : m) {
      auto v = p.second;
      pq.push(v);
    }
    int t=s-k;
    while(t>0){
      ans+=pq.top();
      pq.pop();
      t--;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 14376
//13-3
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define segment_size 65536
#define ROOP() while (true)

int main(){
    int N;
    cin >> N;
    for(int i=0; i<N; i++){
        int x,y,b,p;
        cin >> x >> y >> b >> p;
        int ans = x*b + y*p;

        int tmp = (5*x + 2*y) * 4 / 5;
        if(b == 6) tmp += x * 4 / 5;
        if(p >= 3) tmp += (p-2) * y * 4 / 5;
        ans = min(ans, tmp);

        /*tmp = (5*x + 2*y) * 4 / 5 * 2;
        if(p >= 5) tmp += (p+4) * y;
        ans = min(ans, tmp);

        tmp = (5*x + 2*y) * 4 / 5 * 3;
        ans = min(ans, tmp);*/
        
        cout << ans << endl;
    }

    return 0;
}



Measured memory_bytes: 3092
#include "bits/stdc++.h"
#define int long long
#define double long double
#define low lower_bound
#define upp upper_bound
#define mod (int)1e9+7
#define inf (int)1e16
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=n;i>=0;i++)
#define all(vec) vec.begin(),vec.end()
#define cend cout<<endl;
#define P pair<int,int>
#define prique priority_queue<P,vector<P>,greater<P>>
using namespace std;
int a,b;
char ans[100][100];
signed main() {
	cin>>a>>b;
	a--; b--;
	printf("100 100\n");
	rep(i,100) {
		rep(j,100) {
			if(i<50) ans[i][j]='.';
			else ans[i][j]='#';
		}
	}
	rep(i,50) {
		bool end=false;
		for(int j=0;j<100;j+=4) {
			if(b==0) {
				end=true;
				break;
			}
			if(i%2==0) {
				ans[i][j]='#';
			}
			else {
				ans[i][j+2]='#';
			}
			b--;
		}
		if(end) break;
	}
	rep(i,50) {
		bool end=false;
		for(int j=0;j<100;j+=4) {
			if(a==0) {
				end=true;
				break;
			}
			if(i%2==0) {
				ans[99-i][j]='.';
			}
			else {
				ans[99-i][j+2]='.';
			}
			a--;
		}
		if(end) break;
	}
	rep(i,100) {
		rep(j,100) {
			printf("%c",ans[i][j]);
		}
		printf("\n");
	}
	/*
	 * #...#...#...
	 * ..#...#...#.
	 * #...#...#...
	 * .###.###.###
	 * ##.###.###.#
	 * .###.###.###
	 */
}


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

int main(){

	int x,y,a,b,c; cin>>x>>y>>a>>b>>c;
	vector<int> R(a),G(b),C(c);
	//vector<pair<int,char> > tot;
	vector<pair<int,char> > v,ot;
	for(int i=0;i<a;i++){
		cin>>R[i];
		v.push_back({R[i],'r'});
	}
	for(int i=0;i<b;i++){
		cin>>G[i];
		v.push_back({G[i],'g'});
	}
	for(int i=0;i<c;i++){
		cin>>C[i];
		v.push_back({C[i],'c'});
	}
	sort(v.begin(),v.end());
	int cnt_r=0,cnt_g=0;
	for(int i=v.size()-1;i>=0;i--){
		char tipo=v[i].second;
		int val=v[i].first;
		if(tipo=='c') ot.push_back({val,tipo});
		if(tipo=='r' and cnt_r<x){
			ot.push_back({val,tipo});
			cnt_r++;
		}
		if(tipo=='g' and cnt_g<y){
			ot.push_back({val,tipo});
			cnt_g++;
		}
	}

	long long int sum=0;
	cnt_g=0,cnt_r=0;

	for(int i=0,j=ot.size()-1;i<ot.size();){

		char tipo_left=ot[i].second,tipo_right=ot[j].second;
		int val_left=ot[i].first,val_right=ot[j].first;

		if(cnt_g==y and cnt_r==x) break;

		if(tipo_left=='c'){
			if(val_left>=val_right and tipo_right!='c'){
				sum+=val_left;
				if(tipo_right=='g') cnt_g++;
				else cnt_r++;
				i++;
			}
			j--;
		}else{
			if((tipo_left=='g' and cnt_g<y) or (tipo_left=='r' and cnt_r<x)){
				sum+=val_left;
				if(tipo_left=='g') cnt_g++;
				else cnt_r++;
			}
			i++;
		}
	}


	cout<<sum<<endl;	

	return 0;
}

Measured memory_bytes: 12652
#include<bits/stdc++.h>
#define FOR0(i,n) for(ll i=0;i<n;i++)
#define FOR1(i,n) for(ll i=1;i<=n;i++)
#define FORl(i,l,n) for(ll i=l;i<n;i++)
using namespace std;
#define pi pair<ll,ll>
#define pb push_back
#define ll long long
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define mst0(x) memset(x,0,sizeof(x));
#define vi vector<ll>
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define sp <<" "<<
#define intmax 1e14
#define M 1000000007

ll power(ll num,ll g,ll mod){
  if(g==0)return 1;
  if(g%2==1)return (num*power((num*num)%mod,g/2,mod))%mod;
  return power((num*num)%mod,g/2,mod);
}
 
int main(){
	ll n, k;
	cin>>n>>k;
	vector<ll> vec(n);
	FOR0(i, n)	cin>>vec[i];
	vector< vector<ll> > dp(n, vector<ll> (k+1, 0));
	vector< vector<ll> > ps(n, vector<ll> (k+1, 0));
	ps[0][0] = 1;
	FOR0(i, k+1){
		if(i <= vec[0])
			dp[0][i] = 1;
		if(i > 0)
			ps[0][i] = (ps[0][i] + dp[0][i] + ps[0][i-1]) % M;
	}
	FOR1(i, n-1){
		FOR0(j, k+1)
			dp[i][j] = (j-vec[i]-1) >= 0 ? (ps[i-1][j] - ps[i-1][j - vec[i] - 1] + M) % M : ps[i-1][j] % M;
		FOR0(j, k+1){
			ps[i][j] = j==0 ? dp[i][j] : (dp[i][j] + ps[i][j-1]) % M;
		}
	}
	cout<<dp[n-1][k]<<"\n";
}

Measured memory_bytes: 157552
#include <iostream>

using namespace std;

int main(){

	int i, j, n, q, count = 0;
	int dataS[10001], dataT[501];
	cin >> n;
	for (i = 0; i < n; i++){
		cin >> dataS[i];
	}

	cin >> q;
	for (i = 0; i < q; i++){
		cin >> dataT[i];
	}
	for (int j = 0; j < q; j++){
		for (int i = 0; i < n; i++){
			if (dataT[j] == dataS[i]){
				count++;
				break;
			}
		}
	}
	cout << count << "\n";

	return 0;
}

Measured memory_bytes: 1200
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    int[] alp = new int[26];
    for(int i = 0; i < S.length(); i++){
      char c = S.charAt(i);
      alp[c-'a']++;
    }
    for(int i = 0; i < 26; i++){
      if(alp[i] == 0){
        System.out.println((char)(i + 'a'));
        return;
      }
    }
    System.out.println("None");
  }
}

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


int main()
{
    int n,l;
    cin>>n>>l;
    vector<string> a(n);
    for(int i=0;i<n;i++)    cin>>a[i];
    sort(a.begin(),a.end());
    string res="";
    for(int i=0;i<n;i++)    res += a[i];
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 256
import sys
input=sys.stdin.readline
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ans=10**9
def bubble_sort(arr):
    change = True
    num=0
    while change:
        change = False
        for i in range(len(arr) - 1):
            if arr[i] > arr[i + 1]:
                arr[i], arr[i + 1] = arr[i + 1], arr[i]
                change = True
                num+=1
    return num
for i in range(2**n):
    even=[]
    odd=[]
    for j in range(n):
        x=(i>>j)%2
        if j%2==0:
            if x==0:
                even.append((a[j],j))
            else:
                odd.append((b[j],j))
        else:
            if x==0:
                odd.append((a[j],j))
            else:
                even.append((b[j],j))
    if len(odd)!=n//2:
        continue
    even.sort()
    odd.sort()
    check=True
    order=[]
    new=[]
    for j in range(n//2):
        order.append(even[j][1])
        order.append(odd[j][1])
        new.append(even[j][0])
        new.append(odd[j][0])
    if n%2!=0:
        new.append(even[-1][0])
        order.append(even[-1][1])
    for j in range(n-1):
        if new[j]>new[j+1]:
            check=False
    if not check:
        continue
    x=bubble_sort(order)
    ans=min(ans,x)
if ans==10**9:
    print(-1)
else:
    print(ans)
    
    
    
    


Measured memory_bytes: 49500
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int H,W;
    cin >> H >> W;
    int cnt[26] = {};
    rep(i,0,H){
        string s;
        cin >> s;
        for(auto c:s)cnt[c-'a']++;
    }
    int num[3] = {};
    rep(i,0,26){
        if(cnt[i] % 4 == 0)num[0]++;
        else if(cnt[i] % 2 == 0)num[1]++;
        else num[2]++;
    }
    if(H % 2 && W % 2){
        if(num[2] == 1 && num[1] < (H + W)/2){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }else if(H % 2 || W % 2){
        int c = (H % 2 ? W : H) / 2;
        if(num[2] == 0 && num[1] <= c){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }else{
        if(num[2] == 0 && num[1] == 0){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 256
#include<algorithm>//sort(all(変数),greater<型名>())で降順に,reverse()で逆に
#include<cmath>//切り上げceil(値)
#include<deque>
#include<iomanip>//setprecision(数字)
#include<iostream>
#include<list>
#include<map>
#include<numeric> //xとyの最大公約数は__gcd(x,y),xとyの最小公倍数は(x*y)/__gcd
#include<queue>
#include<set>
#include<stack>
#include<string>//変数.substr(どこから,何文字)で文字列ゲット
#include<vector>

#include<bits/stdc++.h>
#include<cstdio>
#include<cstdlib>
#include<tuple>
#include<utility>
#define rep(i,n) for(ll i=0; i<n; i++)
#define vll vector<ll>
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  int a,b;  cin >> a >> b;
  int ans = 0,cnt = 1;
  while(cnt < b){
    cnt += a-1;
    ans++;
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 256
import collections
import fractions


class Dinic:
    """Dinic Algorithm: find max-flow
       complexity: O(EV^2)
       used in GRL6A(AOJ)
    """
    class edge:
        def __init__(self, to, cap, rev):
            self.to, self.cap, self.rev = to, cap, rev

    def __init__(self, V, E, source, sink):
        """ V: the number of vertexes
            E: adjacency list
            source: start point
            sink: goal point
        """
        self.V = V
        self.E = [[] for _ in range(V)]
        for fr in range(V):
            for to, cap in E[fr]:
                self.E[fr].append(self.edge(to, cap, len(self.E[to])))
                self.E[to].append(self.edge(fr, 0, len(self.E[fr])-1))
        self.maxflow = self.dinic(source, sink)

    def dinic(self, source, sink):
        """find max-flow"""
        INF = float('inf')
        maxflow = 0
        while True:
            self.bfs(source)
            if self.level[sink] < 0:
                return maxflow
            self.itr = [0] * self.V
            while True:
                flow = self.dfs(source, sink, INF)
                if flow > 0:
                    maxflow += flow
                else:
                    break

    def dfs(self, vertex, sink, flow):
        """find augmenting path"""
        if vertex == sink:
            return flow
        for i in range(self.itr[vertex], len(self.E[vertex])):
            self.itr[vertex] = i
            e = self.E[vertex][i]
            if e.cap > 0 and self.level[vertex] < self.level[e.to]:
                d = self.dfs(e.to, sink, min(flow, e.cap))
                if d > 0:
                    e.cap -= d
                    self.E[e.to][e.rev].cap += d
                    return d
        return 0

    def bfs(self, start):
        """find shortest path from start"""
        que = collections.deque()
        self.level = [-1] * self.V
        que.append(start)
        self.level[start] = 0

        while que:
            fr = que.popleft()
            for e in self.E[fr]:
                if e.cap > 0 and self.level[e.to] < 0:
                    self.level[e.to] = self.level[fr] + 1
                    que.append(e.to)

while True:
    M, N = map(int, input().split())
    if M == 0 and N == 0:
        break
    blue, red = [], []
    while True:
        for x in input().split():
            blue.append(int(x))
        if len(blue) == M:
            break
    while True:
        for x in input().split():
            red.append(int(x))
        if len(red) == N:
            break
    V = M + N + 2
    edge = [[] for _ in range(V)]
    for i, b in enumerate(blue):
        for j, r in enumerate(red):
            if fractions.gcd(b, r) != 1:
                edge[i].append((M+j, 1))
    for i in range(M):
        edge[M+N].append((i, 1))
    for j in range(N):
        edge[M+j].append((M+N+1, 1))
    print(Dinic(V, edge, M+N, M+N+1).maxflow)

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

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

	if (S[0] != 'A') {
		cout << "WA" << endl;
		return 0;
	}

	int nc = 0;
	int ic = -1;
	for (int i = 2; i <= S.size()-2; i++) {
		if (S[i] == 'C') {
			nc++;
			ic = i;
		}
	}
	if (nc != 1) {
		cout << "WA" << endl;
		return 0;
	}

	for (int i = 1; i < S.size(); i++) {
		if (i == ic) continue;
		if (isupper(S[i])) {
			cout << "WA" << endl;
			return 0;
		}
	}

	cout << "AC" << endl;

	return 0;
}


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

int main(){
  int c;
  cin >> c;
  for (int cc = 1; cc <= c; cc++){
    vector<vector<int> > m(8, vector<int>(8, 0));
    for (int i = 0; i < 8; i++){
      for (int j = 0; j < 8; j++){
        char temp;
        cin >> temp;
        if (temp == '0'){
          m[i][j] = 0;
        }else{
          m[i][j] = 1;
	}
      }
    }
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    vector<pair<int,int> > q;
    q.push_back(pair<int,int>(x,y));
    while(q.size() > 0){
      pair<int,int> next = q[q.size()-1];
      q.pop_back();
      m[next.second][next.first] = 0;
      for (int i = -3; i <= 3; i++){
        if (i == 0){
          continue;
        }
        int bx = next.first+i;
        int by = next.second;
        if ((0 <= bx) && (bx < 8) && (0 <= by) && (by < 8)){
          if (m[by][bx] == 1){
            q.push_back(pair<int,int>(bx,by));
	  }
          m[by][bx] = 0;
	}
        bx = next.first;
        by = next.second+i;
        if ((0 <= bx) && (bx < 8) && (0 <= by) && (by < 8)){
          if (m[by][bx] == 1){
            q.push_back(pair<int,int>(bx,by));
	  }
          m[by][bx] = 0;
	}
      }
    }
    cout << "Data " << cc << ":" << endl;
    for (int i = 0; i < 8; i++){
      for (int j = 0; j < 8; j++){
        cout << m[i][j];
      }
      cout << endl;
    }
  }
  
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;

int gcd(int a, int b) {
  return b ? gcd(b, a%b) : a;
}

int main() {
  int n;
  cin >> n;
  vi a(n);
  rep(i,n) cin >> a.at(i);
  vi lgcd(n);
  rep(i,n) {
    if(i==0) lgcd[i] = a[i];
    else lgcd[i] = gcd(lgcd[i-1],a[i]);
  }
  vi rgcd(n);
  per(i,n) {
    if(i==n-1) rgcd[i] = a[i];
    else rgcd[i] = gcd(rgcd[i+1],a[i]);
  }
  int ans = 1;
  rep(i,n) {
    if(i==0) ans = max(ans, rgcd[i+1]);
    else if(i==n-1) ans = max(ans,lgcd[i-1]);
    else ans = max(ans,gcd(lgcd[i-1],rgcd[i+1]));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1408
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigDecimal;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
		// 1行目数字、2行目文字
		// 1行目数字、2行目文字
		BigDecimal x = new BigDecimal(br.readLine());

		BigDecimal b11 = new BigDecimal("11");
		BigDecimal b0 = new BigDecimal("0");
		BigDecimal b1 = new BigDecimal("1");
		BigDecimal b2 = new BigDecimal("2");
		BigDecimal b6 = new BigDecimal("6");
		
		
		if (x.compareTo(b6) <= 0) { 
			System.out.println(1);
			return;
		}
		
		if (x.compareTo(b11) <= 0) { 
			System.out.println(2);
			return;
		}
		
		
		//i = 7 % 3;    // i = 1
		BigDecimal a = x.divide(b11, 0, BigDecimal.ROUND_DOWN);
		a = a.multiply(b2);

		BigDecimal mod = x.remainder(b11);


		if (mod.compareTo(b0) == 0) {
		} else {
			if (mod.compareTo(b6) > 0) {
				a = a.add(b2);
			} else {
				a = a.add(b1);
			}
		}
		
		

        //System.out.println("mod=[" + mod + "]");
        System.out.println(a);
        return;
    }
    // Debug.Print
    static void dp(String s) {
		System.out.println(s);
	}
    static void dp(StringBuilder s) { dp(s.toString()); }
    static void dp(int i) { dp(String.valueOf(i)); }
    static void dp(long i) { dp(String.valueOf(i)); }

}

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

using namespace std;

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

  for (int i = 0; i < n; i++) {
    string order;
    int a, b;
    cin >> order >> a >> b;

    if (order == "print") {
      for (int j = a; j <= b; j++) {
        cout << str[j];
      }
      cout << endl;
    } else if (order == "reverse") {
      string s;
      for (int j = a; j <= b; j++) {
        s[j - a] = str[j];
      }

      int k = 0;
      for (int j = b; j >= a; j--) {
        str[j] = s[k];
        k++;
      }
    } else if (order == "replace") {
      string q;
      cin >> q;

      for (int j = a; j <= b; j++) {
        str[j] = q[j - a];
      }
    }
  }

  return 0;
}


Measured memory_bytes: 3224
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int n;
    cin >> n;
    cout << (n-1)/2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int sz[200001], par[200001];
int find(int idx){
    while(idx!=par[idx]){
        idx=par[idx];
    }
    return idx;
}
void join(int x, int y){
    if(x==y) return;
    if(sz[x]<sz[y]){
        swap(x,y);
    }
    sz[x]+=sz[y];
    sz[y]=0;
    par[y]=x; 
}
int main() {
	// your code goes her
	int n, k, flag=0, cnt[200001],p[200001],ans=0; 
	cin>>n>>k;
  cnt[1]=0;
	for(int i=1; i<=n; i++){
	    cin>>p[i]; 
	    if(i<=n-k+1) sz[i]=1,par[i]=i; 
	    if(i>1&&p[i]>p[i-1])cnt[i]=cnt[i-1];
	    cnt[i]++;
	    if(cnt[i]>=k) flag=1;
	}
	set<int> s; 
	for(int i=1; i <=k; i++){
	    s.insert(p[i]);
	}
	for(int i=k+1;i<=n;i++){
	    s.erase(p[i-k]);
	    if(p[i-k]< *s.begin() && *s.rbegin() < p[i]) join(find(i-k),find(i-k+1)); 
	    s.insert(p[i]);
	}
	for(int i=1;i<=n-k+1;i++) ans+=(sz[i]!=0 && cnt[i+k-1]<k);
	cout<<ans+flag<<endl;
	return 0;
}


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

def solve(N: int, A: int, B: int, C: int, D: int, E: int):
    cost = [A,B,C,D,E]
    cost.sort()
    max = math.ceil(N/cost[0])
    print(max + 4)
    return


# Generated by 1.1.3 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()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    E = int(next(tokens))  # type: int
    solve(N, A, B, C, D, E)

if __name__ == '__main__':
    main()
        

Measured memory_bytes: 3064
<?php
// AOJ 0121
// @kankichi573
// 2014/6/22 P.E
$a=array(0,1,2,3,4,5,6,7);
$tesuu=array(0);

function swap($a,$pos,$offset)
{
	$wk=$a[$pos];
	$a[$pos]=$a[$pos+$offset];
	$a[$pos+$offset]=$wk;
	return($a);
}


function prepare($a,$te,$pos) 
 { 
   global $tesuu;

   //echo implode($a).": $te \n";
   if($te>40)
     return;
   //$pos=search_zero($a); 
   if(($pos % 4) < 3) 
     {	 
       $b=$a;
       $b=swap($b,$pos,1);
       $mystring=implode($b);	
       if(empty($tesuu[$mystring]) || 
	  $tesuu[$mystring] > $te)
	    {
	      $tesuu[$mystring] = $te+1;	
	      prepare($b,$te+1,$pos+1);
	    }
     }
   
   if(($pos % 4) > 0)
     {	
       $b=$a;
       $b=swap($b,$pos,-1);
       $mystring=implode($b);	
       if(empty($tesuu[$mystring]) || 
	  $tesuu[$mystring] > $te)
	 {
	   $tesuu[$mystring] = $te+1;
	   prepare($b,$te+1,$pos-1);
	 }
     }		
   if($pos > 3)
     {	
       $b=$a;
       $b=swap($b,$pos,-4);
       $mystring=implode($b);	
       if(empty($tesuu[$mystring]) || 
	       $tesuu[$mystring] > $te)
	 {
	   $tesuu[$mystring] = $te+1;
	   prepare($b,$te+1,$pos-4);
	 }
     }		
   if($pos < 4)
     {	
       $b=$a;
       $b=swap($b,$pos,4);
       $mystring=implode($b);	
       if(empty($tesuu[$mystring]) || 
	  $tesuu[$mystring] > $te)
	 {
	   $tesuu[$mystring] = $te+1;
	   prepare($b,$te+1,$pos+4);
	 }
     }
 }

$tesuu[implode($a)]=1;
prepare($a,1,0);
while($input=fscanf(STDIN,"%d %d %d %d %d %d %d %d"))
  {
    //echo "input=>".implode($input)."\n";
    fprintf(STDOUT,"%d\n",$tesuu[implode($input)]-1);
  }
  return(0);
?>

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

using namespace std;
int a[1000];

int main()
{
    int x, n; cin >> x >> n;
    for(int i=1; i<=n; ++i){
        int y; cin >> y;
        a[y] = 1;
    }
    int ans = 1e9, pos;
    for(int i=0; i<=110; ++i) if (abs(i - x) < ans && !a[i]){
        ans = abs(i - x);
        pos = i;
    }
    cout << pos;
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18

ll mod = 1e9+7;
  
// 検索タグ
int main() {
	// 入力
	ll H, W, K;cin>>H>>W>>K;
	ll S[H][W];
	REP(i,H){
		string tmp;cin>>tmp;
		REP(j, W){
			if (tmp[j]=='0')S[i][j] = 0;
			else S[i][j] = 1;
		}
	}
	// REP(i,H){
	// 	REP(j, W){
	// 		printf("%lld ", S[i][j]);
	// 	}
	// 	printf("\n");
	// }
    
	// 解法
	ll split = H*W;
	ll n = H-1;
	// printf("check\n");
    // {0, 1, ..., n-1} の部分集合の全探索
	REP(bit, (1<<n)){ // (1<<n) = 2**n
        /* きちんとできていることを確認してみる */
        // bit の表す集合を求める
        vector<ll> H_split;
        ll block[H]; // i行目が何個目のブロックに当たるか
		block[0] = 0; 
        REP(i, H){
			if (bit & (1<<i)){ // i が bit に入るかどうか
                block[i+1] = block[i] + 1; // 次のブロックに割り当てる
            }
			else{
				block[i+1] = block[i]; //同じブロックに割り当てる
			}
			
            if (bit & (1<<i)){ // i が bit に入るかどうか
				H_split.push_back(i);
			}
        }
        // bit の表す集合の出力
        // cout << bit << ": {";
		// REP(i, H_split.size()) cout << H_split[i] << " ";
        // cout << "}" << endl;
		// REP(i,H) printf("%lld ", block[i]);
		// printf("\n");

		// 貪欲法
		ll split_bit = block[H-1];
		ll num_block = block[H-1]+1;
		ll count[num_block]; //各ブロックのカウント
		REP(i, num_block)count[i] = 0; // 初期化
		
		// printf("split: %lld,", split_bit);
		// REP(l, block[H-1]+1)printf("%lld ", count[l]);
		// printf("\n");
		bool no_solution_flag = false;
		REP(j,W){ // 各列について
			bool over_count_flag = false;
			ll count_tmp[block[H-1]+1]; //j列の各ブロックの値をカウント
			REP(i, num_block)count_tmp[i] = 0; // 初期化
			REP(i, H){
				count_tmp[block[i]] += S[i][j];
			}
			REP(i, num_block){
				if (count_tmp[i]>K){ // j列だけでKを超えたら解なし
					no_solution_flag = true;
				}
			}
			if (no_solution_flag){
				// printf("no solution flag!\n");
				break;
			}
			else{
				REP(i, num_block){
					count[i] += count_tmp[i];
				}
			}
			REP(i, num_block){
				if (count[i]>K){ // countがKを超えたら
					over_count_flag = true;
				}
			}
			if (over_count_flag){//countがKを超えたら分割処理
				split_bit++;
				REP(i, num_block){
					count[i] = count_tmp[i];
				}
			}
			
			// printf("j: %lld, split: %lld,", j, split_bit);
			// REP(l, block[H-1]+1)printf("%lld ", count[l]);
			// printf("\n");
		}
		if (split_bit<split & !no_solution_flag) split = split_bit;
	}

	//出力
	// cout << ans << endl;
	printf("%lld\n", split);
	// if (ans) printf("Yes\n");
	// else printf("No\n");
}


Measured memory_bytes: 384
#include<iostream>


using namespace std;

int main(){
	
	int s,h,m;

	cin >> s;

	h = s / 3600;
	m = (s - (3600 * h))/60;
	cout << h << ":" << m << ":" << s-(3600*h)-(60*m) << endl;

	return 0;
}


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

int main() {
    int n, num = 1, ans = 0;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; ++i) cin >> a[i];
    for(int i = 0; i < n; ++i) {
        if(a[i] == num) {
            num++;
        } else {
            ans++;
        }
    }
    if(ans == n) ans = -1;
    cout << ans << '\n';
}


Measured memory_bytes: 1152
/** 
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

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

#define fori(n) for(ll i=0; i<(n); i++)
#define forn(i, n) for(ll i=0; i<(n); i++)
#define forn3(i, x, n) for(ll i=(x); i<(n); i++)


int main() {
cin.tie(nullptr);
std::ios::sync_with_stdio(false);
int n;
    cin>>n;
    vector<vector<int>> abc(n, vector<int>(3));
    fori(n)
        cin>>abc[i][0]>>abc[i][1]>>abc[i][2];

    vector<vector<int>> dp(n, vector<int>(3)); // dp[i][j][k]=max joy on day i when choosen aktivity j that day, and notsame/same the day before

    fori(2) {
        dp[0][0]=abc[0][0];
        dp[0][1]=abc[0][1];
        dp[0][2]=abc[0][2];
    }

    forn3(i, 1, n)
        forn3(j, 0, 3)
           dp[i][j]=max(dp[i-1][(j+1)%3], dp[i-1][(j+2)%3]) + abc[i][j];

    int ans=0;
    fori(3)
        ans=max(ans, dp[n-1][i]);

    cout<<ans<<endl;
}



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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

template<class T>
inline void Max(T &x, T t) {
	if(t > x) {
		x = t;
	}
}
template<class T>
inline void Min(T &x, T t) {
	if(t < x) {
		x = t;
	}
}



int main() {
//	freopen("input.txt", "r", stdin);
	
	ll Q, H, S, D, N;
	cin >> Q >> H >> S >> D >> N;
	Q *= 4;
	H *= 2;
	Min(S, min(Q, H));
	Min(D, S * 2);
	cout << D * (N / 2) + (N & 1) * S << endl;
	
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
//
#define int long long
#define ALL(x) (x).begin(), (x).end()
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))
// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((a) >> (b)) & 1
#define bitcount(a) __builtin_popcountll((a))
//
typedef long long lint;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;
//
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1};
const int dy[] = {0, -1, 1, 0};
//
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

int N, M;
int A[101010];
map<int, int> mp;

signed main() {
  cin >> N >> M;
  for (int i = 1; i <= N; i++) {
    cin >> A[i];
    A[i] %= M;
  }

  int sum[101010];
  sum[0] = 0;
  mp[0]++;
  for (int i = 1; i <= N; i++) {
    sum[i] += sum[i - 1] + A[i];
    sum[i] %= M;
    mp[sum[i]]++;
  }

  int cont = 0;
  for (int i = 1; i <= N; i++) {
    cont += (mp[sum[i]] * (mp[sum[i]] - 1)) / 2;
    mp[sum[i]] = 0;
  }
  cout << cont << endl;
  return 0;
}


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

int sum_n(int n) {
	int sum = 0;

	while (n > 0) {
		sum += n % 10;
		n /= 10;
	}
	return sum;
}


int main() {
	int n, a, b;
	cin >> n >> a >> b ;
	int all_sum = 0;

	for (int i = 1; i < n + 1; ++i) {
		int sum_now = sum_n(i);
		if (sum_now >= a && sum_now <= b) {
			all_sum += i;
		}
	}
	cout << all_sum << endl;
}

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

int main(){
	int l[11],v1,v2,ans;
	double x;
	while(1){
		int sum=0,y=0;
		rep(i,0,10){
			scanf("%d,",&l[i]);
			sum+=l[i];
		}
		if(scanf("%d,%d",&v1,&v2)==EOF) break;
		x=(double)sum*v1/(v1+v2);
		rep(j,0,10){
			y+=l[j];
			if(y>=x){
				ans=j+1;
				break;
			}
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1208
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var s = cin.next();

            var ans = int.MaxValue;
            for (int i = 0; i < s.Length-2; i++)
            {
                var ss = "";
                for (int j = i; j < i + 3; j++)
                {
                    ss += s[j];
                }
                ans = Math.Min(ans, Math.Abs(int.Parse(ss)-753)); ;
            }
            
            Console.WriteLine(ans);
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

long long power(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}


int n, l;
vector<vector<int>> adj;

int timer;
vector<int> tin, tout;
vector<vector<int>> up;
int  vis[100005];

void dfs2(int ver)
{
    vis[ver]=1;
    for(auto i:adj[ver])
    {
        if(!vis[i])
            dfs2(i);
    }
}

void dfs(int v, int p)
{
    tin[v] = ++timer;
    up[v][0] = p;
    vis[v]=1;
    for (int i = 1; i <= l; ++i)
        up[v][i] = up[up[v][i-1]][i-1];

    for (auto u : adj[v]) {
        if (!vis[u])
            dfs(u, v);
    }

    tout[v] = ++timer;
}

bool is_ancestor(int u, int v)
{
    return tin[u] <= tin[v] && tout[u] >= tout[v];
}

int lca(int u, int v)
{
    if (is_ancestor(u, v))
        return u;
    if (is_ancestor(v, u))
        return v;
    for (int i = l; i >= 0; --i) {
        if (!is_ancestor(up[u][i], v))
            u = up[u][i];
    }
    return up[u][0];
}

void preprocess(int root) {
    tin.resize(n);
    tout.resize(n);
    timer = 0;
    l = ceil(log2(n));
    up.assign(n, vector<int>(l + 1));
    dfs(root, root);
}
int dp[100005];

void dfs3(int ver)
{
    vis[ver]=1;
    for(auto i:adj[ver])
    {
        if(!vis[i])
        {
            dfs3(i);
            dp[ver]+=dp[i];
        }
    }
}

signed main()
{

ios_base::sync_with_stdio(false);
cin.tie(NULL);  
cout.tie(0);   

#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif  

    int m;
    cin>>n>>m;
    adj.resize(n+1);
    int x,y;
    map<pair<int,int> ,int>mm;
    for(int i=0;i<m;i++)
    {
        cin>>x>>y;
        x--;
        y--;
        int xx=min(x,y);
        int yy=max(x,y);
        mm[{xx,yy}]++;
    }

    for(auto i:mm)
    {
        if(i.second&1)
        {
            adj[i.first.first].push_back(i.first.second);
            adj[i.first.second].push_back(i.first.first);
        }
    }
    
    vector<int>temp;

    for(int i=0;i<n;i++)
    {
        if(!vis[i])
        {
            dfs2(i);
            temp.push_back(i);
        }
    }

    fill_n(vis,n+1,0);    
    int sz=temp.size();
    for(int i=0;i<sz-1;i++)
    {
        adj[temp[i]].push_back(temp[i+1]);
        adj[temp[i+1]].push_back(temp[i]);
    }

    preprocess(0);

    for(auto i:mm)
    {
        if(i.second&1)
        {
            int x=i.first.first;
            int y=i.first.second;
            dp[x]++;
            dp[y]++;
            int loda=lca(x,y);
            dp[loda]-=2;
        }
    }

    fill_n(vis,n+1,0);    

    for(int i=1;i<n;i++)
    {
        if(dp[i]&1)
        {
            cout<<"NO";
            return 0;
        }
    }
    cout<<"YES";
} 
    
 


Measured memory_bytes: 39012
#include <bits/stdc++.h>
#include<list>
#include<algorithm>
#define ll long long int
#define ld long double
#define pb push_back
#define FF first
#define SS second
#define rep(a,b,c) for(a=b;a<c;a++)
#define repr for(i=n-1;i>=0;i--)
#define PLL pair<ll, ll>
#define inf 100000001
#define mod 1000000007
#define LP lower_bound
#define UP upper_bound
#define MP make_pair
#define rep1 for(i=1;i<=n;i++)
#define VLL vector<ll>
#define ef else if
#define all(x) (x).begin(), (x).end()
#define SORT(A) sort(A.begin(), A.end());
#define REVERSE(A) reverse(A.begin(), A.end());
#define MAX LLONG_MAX
#define MIN LLONG_MIN
#define UMP unordered_map
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll myXOR(unsigned long long int x, unsigned long long int y)
{
    return (x|y)&(~x|~y);
}
ll powerLL(ll x, ll n) 
{ 
    ll result = 1; 
    while (n) { 
        if (n & 1) 
            result = result * x % mod; 
        n = n / 2; 
        x = x * x % mod; 
    }
    return result; 
}
int main()
{
    fastio
    ll a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r, t,u,w,x,y,z;
    string str, ss, str1;
    /*
    **  author : mahiman12
    **  created : 2020-05-03 18:43 
    */
    cin>>n;
    ll arr[n];
    map<ll,vector<ll>>up, down;
    rep(i,0,n)
    {
        cin>>arr[i];
        up[i+arr[i]].push_back(i);
        down[i-arr[i]].push_back(i);
    }
    ll res=0;
    rep(i,0,n)
    {
        ll val = i + arr[i];
        res += down[val].end() - upper_bound(all(down[val]), i);
    }
    cout<<res;
}

Measured memory_bytes: 59656
n = int(input())
a = list(map(int,input().split()))
p = 1
mod = 1e18
f0 = 0
f1 = 0
for i in range(0,n):
    if a[i] == 0:
        f0 = 1
        break
    else:
        if f1 == 0:
            p = p*a[i]
            if p > mod:
                f1 = 1

if f0 == 1:
    print(0)
elif f1 == 1:
    print(-1)
else:
    print(p)

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

int main(){
    int sum=0,A[101],N;
    bool flag=1;
    cin >> N;
    for(int i=0;i<N;i++) cin >> A[i];
    
    for(int i=0;flag;i++){
        flag = 0;
        for(int j=N-1;j>i;j--){
            if(A[j]<A[j-1]){
                swap(A[j],A[j-1]);
                flag = 1;
                sum++;
            }
        }
    }
    
    for(int i=0;i<N;i++){
        if(i) cout << " ";
        cout << A[i];
    }
    cout << endl;
    cout << sum << endl;
    return 0;
}


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

using namespace std;

typedef long long int ll;
#define pb push_back
#define ALL(a) (a).begin() , a.end()

int mod = 1e9 + 7;
int add(int a, int b){
	if(a + b >= mod)return a+ b - mod;
	return a + b;
}
int mul(int a, int b){
	return 1LL * a * b  % mod;
}
int sub(int a, int b){
  if(a >= b)return a-b;
  return a - b + mod;
}
int power(int a, int b){
	int re = 1;
	while(b){
		if(b&1)re= mul(re, a);
		a = mul(a, a);
		b>>=1;
	}
	return re;
}
int const N = 100 *1001;

/********************i**********************************/
vector<int> vec[10];
void dfs(int a, int p){
  cout << a << " ";
  for(int b : vec[a]){
    if(b == p)continue;
    dfs(b, a);
  }
  cout << a << " ";
}
void solve(){
  int n, k;
  cin >> n >> k;
  vector<ll>vec(n);
  for(auto &a : vec)cin >> a;
  if(k >= n){
    cout << 0;
    return ;
  }
  sort(ALL(vec));
  ll  ans = 0;
  for(int x = 0; x<n-k; x++){
    ans += vec[x];
  }
  cout << ans;
}
/******************************************************/
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(nullptr);
	int t;
	t = 1;
	// cin >> t;
	while(t--){
		solve();
	}
}

Measured memory_bytes: 1792
#include<iostream>
using namespace std;
string str;
int t[10];
int main(){
  while(cin>>str){
    for(int i=0;i<10;i++)t[i]=str[i]-'0';
    for(int i=0;i<9;i++){
      for(int j=0;j<9-i;j++){
	t[j]=(t[j]+t[j+1])%10;
      }
    }
    cout<<t[0]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1180
#include<bits/stdc++.h>
#define REG register
using namespace std;
inline void read(int& x){
    static char c;
    while(!isdigit(c=getchar()));x=c^48;
    while(isdigit(c=getchar()))x=(x*10)+(c^48);
}

int n,m;

int a[105];

int sum,cnt;

inline void Work(){
    read(n),read(m);
    for(REG int i=1;i<=n;++i) read(a[i]),sum+=a[i];
    sum=(sum-1)/(4*m)+1;
    for(REG int i=1;i<=n;++i)
        if(a[i]>=sum) ++cnt;
    if(cnt>=m) puts("Yes");
    else puts("No");
    // getchar(),getchar();
}

int main(){Work();}

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

typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define MP make_pair
#define MT make_tuple
#define F first
#define S second
#define PB push_back
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((ll)(x).size())
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define pvd(v) cout << setprecision(16) << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RANGE(a, start_index, num)  (a).begin()+(start_index),(a).begin()+(num)

int main() {
	ll h, w;
	cin >> h >> w;
	ll res;
	ll ki = (w + 1) / 2;

	if (w % 2 == 0) {
		res = ki*h;
	}
	else {
		res = ki * h - (h / 2);
	}

	if (h == 1 || w == 1) {
		res = 1;
	}

	pv(res);
	return 0;
}

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

int main()
{
    int64_t N;
    cin >> N;
    int64_t ans = 0;
    vector<int64_t> cnt(N + 10);
    for (int i = 1; i <= N; i++)
    {
        int64_t j = 1;
        while (i * j <= N)
        {
            cnt[i * j]++;
            j++;
        }
    }
    rep(i, N + 1) ans += i * cnt[i];
    // rep(i, N + 1) cout << cnt[i] << endl;
    cout << ans << endl;
}

Measured memory_bytes: 81396