akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES    
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <array>
#include <random>
#include <complex>
#include <regex>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
#define quickIO()   {cin.tie(0);    cout.sync_with_stdio(false);}
#define rep(i,n)    for(ll i=0; i<(ll)n; i++)
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define fcout cout << fixed << setprecision(10) 
const ll inf = 1e18;
const ll mod = 1e9 +7;
     
ld sqrtld(ld x){
    ld left = 0, right = x;
    rep(i, 100){
        ld mid = (left + right)/2;
        if (mid*mid <= x)   left =mid;
        else    right = mid;
    }
    return left;
}

ll gcd(ll a, ll b){
    if(b>a){
        ll c =b; b=a;   a=c;
    }
    ll d = a%b;
    if(d==0){
        return b;
    }else if(d==1){
        return 1;
    }else{
        gcd(b,d);
    }
}


ll cul(ll n){
    return (n-1)*n/2;
}

int cou[30];
int main (){
    string s;   cin >> s;
    int b=0,a=0;
    while(b<s.size()){
        if(b-a<3){
            int c= s[b]-'a';
            cou[c] +=1;
            if(cou[c]==2){
                cout << a+1 << " " << b+1 << endl;
                return 0;
            }
            b++;
        }else{
            int d = s[a]-'a';
            cou[d] -= 1;
            a++;
        }
    }

    cout << -1 << " " << -1 << endl;
    return 0;
}



Measured memory_bytes: 512
N, M = map(int, input().split())

a_b = [list(map(int, input().split())) for _ in range(N)]
c_d = [list(map(int, input().split())) for _ in range(M)]

for i in range(N):
    ans = 0
    a = a_b[i][0]
    b = a_b[i][1]

    for j in range(M):
        c_ans = c_d[ans][0]
        d_ans = c_d[ans][1]
        c = c_d[j][0]
        d = c_d[j][1]
        
        if abs(a-c) + abs(b-d) < abs(a-c_ans) + abs(b-d_ans):
             ans = j
    print(ans+1)

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AIZU {
	class Program {
		static int cin() { return int.Parse(Console.ReadLine()); }
		static int cin(int D) {
			string s = Console.ReadLine();
			if (string.IsNullOrEmpty(s))
				return D;
			return int.Parse(s);
		}
		static int[] cins() {
			string s = Console.ReadLine();
			if (string.IsNullOrEmpty(s))
				return new int[] { };
			string[] ss = s.Split(' ');
			int[] Res = new int[ss.Length];
			for (int i = 0; i < ss.Length; i++)
				Res[i] = int.Parse(ss[i]);
			return Res;
		}
		static void print(object j) { Console.WriteLine(j.ToString()); }
		static void print(string j) { Console.WriteLine(j); }

		static void Main(string[] args)
		{
			int[] H;
			int a, b;
			bool k=false;
			while (true) {
				H = cins();
				a = H[0];b = H[1];
				if (a == 0 && b == 0)
					break;
				if (k) print("");
				else k = true;
				var Res = Enumerable.Range(a, b - a + 1).
					Where(i => i % 4 == 0 && (i % 100 != 0 || i % 400 == 0));
				if (Res.Count() == 0)
					print("NA");
				else
					foreach (int j in Res)
						print(j);
			}
		}
	}
}

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

int main(){
	long long n, k;
	cin >> n >> k;
	long long sum = 0;
	for (long long i = k; i < n + 2; ++i)
	{
		sum += i*n - (i*i - i)+ 1;
	}
	cout << sum % 1000000007 << endl;
}

Measured memory_bytes: 3636
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<usize>();
    let (n, _) = (v[0], v[1]);
    let a = read_vec::<i64>();
    let mut max_array = vec![0; n];
    max_array[n - 1] = a[n - 1];
    for i in (0..n - 1).rev() {
        max_array[i] = max(max_array[i + 1], a[i]);
    }
    let mut map = BTreeMap::new();
    for i in 0..n {
        let gain = max_array[i] - a[i];
        *map.entry(gain).or_insert(0) += 1;
    }
    for key in map.keys().rev() {
        println!("{:?}", map[key]);
        break;
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 10492
#include <iostream>
#include <vector>

using namespace std;

int main(){
    long long a, b;
    cin >> a >> b;
    long long m, n;
    m = a;
    n = b;
    
	long long temp;
	while (m % n != 0)
	{
		temp = n;
		n = m % n;
		m = temp;
	}
	cout << (a * b)/n << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define sz(a) int(a.size())
#define re return
using namespace std;
int main()
{
	int n;
	cin>>n;
	int kg=0;
	for (int i=0;i<=n;i+=4)  if ((n-i)%7==0)  kg=1;
	if (kg==1)  cout<<"Yes";
	else  cout<<"No";
	re 0;
}


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

int main()
{
    long long int n,m,i,sum=0;
    cin>>n>>m;
    long long int a[m];
    for(i=0 ; i<m ; i++){
        cin>>a[i];
        sum+=a[i];
    }
    if(sum>n){
        cout<<-1;
    }
    else if(sum==n){
        cout<<0;
    }
    else{
        cout<<n-sum;
    }
    return 0;
}

Measured memory_bytes: 3668
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    ll N, K;
    cin >> N >> K;
    ll ans = 0;
    if (K == 0) {
        cout << N * N << endl;
        return 0;
    }
    REP(b, K + 1, N + 1) {
        int i = b - K;
        ans += i * ((N + 1) / b);
        if ((N + 1) % b!= 0)
            ans += max((N) % b - K + 1, 0LL);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int L,N,x,w,i,j,kake,sum=0,a,b,c,y;
    scanf("%d%d",&L,&N);
    for(i=0;i<N;i++){
        for(i=0;i<N;i++){
            scanf("%d%d",&x,&w);
            kake = x*w;
            sum += kake;
        }
    }
    if(sum == 0) printf("%d",sum);
    else {
    j = 0-sum;
    while(1){
      a = j%L;
      b = L;
      L--;
      if(a == 0) break;
    }
    c = j/b;
    if(c>=0) printf("%d\n%d %d\n",1,b,c);
    else printf("%d\n%d %d\n",1,-b,-c);
    }
    return 0;
}

Measured memory_bytes: 600
import java.util.*;
import java.io.*;
class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int N = sc.nextInt();
        int A = sc.nextInt();
        if(N%A==0) p(N/A);
        else p(N/A+1);
    }
    public static <T> void p(T element) {
	System.out.println(element);
    }
    public static int min(int a, int b, int c) {
	int min = Math.min(a,b);
	min = Math.min(min,c);
	return min;
    }
    public static int max(int a, int b,int c) {
	int max= Math.max(a,b);
	max = Math.max(max,c);
        return max;
    }
}
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
 
    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }
 
    private boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }
 
    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }
 
    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
 
    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
 
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }
 
    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int MAX_N = 100005;
int A[MAX_N];

int main()
{
	int N,K;
	cin >> N >> K;
	int idx1 = 0;
	rep(i,N)
	{
		cin >> A[i];
		//if (A[i] == 1) idx1 = i;
	}
	cout << (N-1 + K-1 - 1) / (K-1) << endl;
	return 0;
}

Measured memory_bytes: 3956
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 998244353;
const ll MAX = 1000000;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

//gcd,lcm,べき,二進展開
//組み合わせ、mod計算
//最短路問題、bit、union find

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



	
int main() {
	ll N, M, X;
	cin >> N >> M >> X;

	ll A[MAX];

	repn(i, M) cin >> A[i];

	ll lef=0;
	ll ri = 0;

	repn(i, M) {
		if (A[i] < X) { lef++; }
		else { ri++; }
	}

	cout << min(lef, ri);

	system("PAUSE");
}

Measured memory_bytes: 504
import java.util.*;
 
public class Main {
    Scanner sc = new Scanner(System.in);
 
    public static void main(String[] args) {
    	new Main(); 
    }
 
    public Main() {
    	new A().doIt();
    }
    class A{
    	void doIt(){
    		while(true){
    			int x = sc.nextInt();
    			int y = sc.nextInt();
    			int s = sc.nextInt();
    			if(x + y + s == 0)break;
    			int length = (s / 2)+1;
    			int max = 0;
    			for(int i = 1;i < length;i++){
    				int low = (i * 100)/(100+x);
    				int high = ((s-i) * 100)/(100+x);
    				if((i * 100) % (100+x) != 0){
    					low += 1;
    				}
    				if(((s-i) * 100) % (100+x) != 0){
    					high += 1;
    				}
    				if((low * (100 + x))/100 != i)continue;
    				if((high* (100 + x))/100 != (s-i))continue;
//    				System.out.print(low+" "+high);
    				low = (low * (100 + y))/100;
    				high = (high * (100 + y))/100;
    				max = Math.max(max,low+high);
//    				System.out.println(" "+(low+high));
    			}
    		System.out.println(max);
    		}
    	}
    }
}

Measured memory_bytes: 29276
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int n, k; cin >> n >> k;
  vector<vector<int> > graph(n);
  REP(_, n - 1) {
    int a, b; cin >> a >> b; --a; --b;
    graph[a].emplace_back(b);
    graph[b].emplace_back(a);
  }
  int ans = INF;
  if (k % 2 == 0) {
    REP(root, n) {
      vector<int> dist(n, -1);
      dist[root] = 0;
      vector<int> que{root};
      while (!que.empty()) {
        vector<int> nx;
        for (int src : que) {
          for (int dst : graph[src]) {
            if (dist[dst] == -1) {
              dist[dst] = dist[src] + 1;
              nx.emplace_back(dst);
            }
          }
        }
        que.swap(nx);
      }
      int cnt = 0;
      REP(i, n) cnt += dist[i] > k / 2;
      chmin(ans, cnt);
    }
  } else {
    REP(root1, n) {
      for (int root2 : graph[root1]) {
        if (root1 > root2) continue;
        vector<int> dist(n, -1);
        dist[root1] = dist[root2] = 0;
        vector<int> que{root1, root2};
        while (!que.empty()) {
          vector<int> nx;
          for (int src : que) {
            for (int dst : graph[src]) {
              if (dist[dst] == -1) {
                dist[dst] = dist[src] + 1;
                nx.emplace_back(dst);
              }
            }
          }
          que.swap(nx);
        }
        int cnt = 0;
        REP(i, n) cnt += dist[i] > (k - 1) / 2;
        chmin(ans, cnt);
      }
    }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
int check1[30], check2[30];
char arr[103];
int ans[103];
int main(){
    int n, sum=0, maxsum=0;
    char t;
    scanf("%d",&n);
    scanf("%s", arr);
    for(int i=0;i<n-1;i++)
    {
        for(int k=0;k<30;k++)
            check1[k]=check2[k]=0;
        sum=0;
        for(int j=0;j<i;j++)
            check1[arr[j]-'a']=1;
        for(int j=i;j<n;j++)
            check2[arr[j]-'a']=1;
        for(int k=0;k<30;k++)
            sum+=check1[k]&check2[k];
        maxsum=maxsum>sum?maxsum:sum;
    }
    printf("%d",maxsum);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n;
  while(cin>>n,n){
    int c[n];
    for(int i=0;i<n;i++) cin>>c[i];
    typedef pair<int,int> P;
    vector<P> v;
    v.push_back(P(-1,0));
    for(int i=0;i<n;i++){
      if(i%2==0){
	if(v.back().first==c[i]) v[v.size()-1].second++;
	else v.push_back(P(c[i],1));
      }else{
	if(v.back().first==c[i]) v[v.size()-1].second++;
	else{
	  int k=v.back().second;
	  v.pop_back();
	  if(v.back().first<0) v.push_back(P(c[i],k+1));
	  else v[v.size()-1].second+=k+1;
	}
      }
    }
    //for(P p:v) cout<<p.first<<" "<<p.second<<endl;
    int ans=0;
    for(P p:v) if(p.first==0) ans+=p.second;
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 3776
class Node
  attr_accessor :id, :children, :parent_id

  def initialize id
    @id = id.to_i
    @children = []
    @parent_id = -1
  end

  def setChild child_id
    @children << child_id
  end

  def setParent parent_id
    @parent_id = parent_id
  end
end

$input_map = {}
n = 0
count = 0
line_count = 0
STDIN.each_line {|line|
  if count == 0
    count += 1
    n = line.to_i
    next
  end

  hoge = 0
  array = line.split " "
  id = array[0].to_i
  $input_map[id] = Node.new id
  array.each do |num|
    hoge += 1
    if hoge==1
      # n = num.to_i
      next
    elsif hoge==2
      next
    end

    $input_map[id].setChild num.to_i
  end

  line_count += 1
}

# set parent
$input_map.each_pair { |id, node|
  node.children.each do |child_id|
    $input_map[child_id].setParent id
  end
}

# search root
root_id = -1
$input_map.each_pair { |id, node|
  if node.parent_id == -1
    root_id = id
    break
  end
}

$print_list = Array.new n
def PrintNode id, parent_id, depth
  child_str = ""
  type = depth == 0 ? "root" : "internal node"
  if type != "root" && $input_map[id].children.empty?
    type = "leaf"
  else
    child_str = $input_map[id].children.join ", "
  end

  $print_list[id] = "node ", id, ": parent = ", parent_id, ", depth = ", depth, ", ", type, ", ", "[", child_str ,"]\n"

  $input_map[id].children.each do |child_id|
    PrintNode child_id, id, depth + 1
  end
end

PrintNode root_id.to_i, -1, 0
n.times do |i|
    print $print_list[i].join ""
end



Measured memory_bytes: 107200
#include <bits/stdc++.h>
using namespace std;
int main() {
    #ifdef DEBUG
    std::ifstream in("/home/share/inputf.in");
    std::cin.rdbuf(in.rdbuf());
    #endif
    int N;
    cin >> N;
    int sgn = 0;
    if(N < 0) sgn = 1;
    N = abs(N);
    if(N == 0) {
        cout << 0 << endl;
        return 0;
    }
    int ans[10000];
    int i;
    for(i = 0; i < 10000; i++) {
        ans[i] = 0;
    }
    for(i = 0; N; i++) {
        if(sgn) {
            if(N & 1) {
                ans[i]++;
                if(!(i & 1)) {
                    ans[i+1]++;
                }
            }
        } else {
            if(N & 1) {
                ans[i]++;
                if(i & 1) {
                    ans[i+1]++;
                }
            }
        }
        N >>= 1;
    }
    int M = i;
    for(i = 0; i < 9900; i++) {
        ans[i + 2] += ans[i] / 2;
        ans[i + 1] += ans[i] / 2;
        ans[i] %= 2;
    }
    bool flag = false;
    for(int i = 9000; i >= 0; i--) {
        if(ans[i]) flag = true;
        if(flag) cout << ans[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	long long int n;
	cin>>n;
	long long int a[n];
	for (long long int i = 0; i < n; ++i)
	{
		cin>>a[i];
	}
	long long int sum=0;
	long long int maxi=a[0];
	for (long long int i = 1; i < n; ++i)
	{
		// maxi=max(maxi)
		if (a[i]>maxi)
		{
			maxi=a[i];
		}
		else
			sum+=abs(maxi-a[i]);
	}
	cout<<sum;
}

Measured memory_bytes: 5168
#include <cstdio>
#include <iostream>
using namespace std;
int main()
{
	int i,n,k,l,r,x,ans=0;
	scanf("%d%d",&n,&k);
	for(i=1;i<=n;i++){
		scanf("%d",&x);
		if(x==1)l=r=i;
	}
	//while(l>1)l+=k-1,++ans;
	//while(r<n)r+=k-1,++ans;
	ans=(n-1)/(k-1);
	if((n-1)%(k-1)>0)++ans;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define until(x) while(!(x))
#define unless(x) if(!(x))
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define pc __builtin_popcount
const int mod = 1e9+7;

int fac[2000050];

int pw(int base, int expo){
	if(!expo){
		return 1;
	}
	int k = pw(base,expo/2);
	k*=k;
	k%=mod;
	if(expo&1){
		k*=base;
		k%=mod;
	}
	return k;
}

int inv(int n){
	return pw(n,mod-2);
}

int comb(int n, int r){
	return (((fac[n]*inv(fac[r]))%mod)*inv(fac[n-r]))%mod;
}

int32_t main(){
	fac[0]=1;
	for(int i=1;i<=2e6+10;i++){
		fac[i]=i*fac[i-1];
		fac[i]%=mod;
	}
	int r1,r2,c1,c2;
	cin>>r1>>c1>>r2>>c2;
	int ans = comb(r2+c2+2,r2+1);
	ans -= comb(r2+c1+1,r2+1);
	ans -= comb(r1+c2+1,r1);
	ans += comb(r1+c1,r1);
	ans += mod;
	ans %= mod;
	cout<<ans;
}


Measured memory_bytes: 15872
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<map>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  int sum,N,C,D[40][40],c[501][501],col[3][31],res=INF_INT;
  cin >> N >> C;
  REP(i,C)REP(j,C)
    cin >> D[i][j];
  REP(i,N)REP(j,N){
    cin >> c[i][j];
    c[i][j]--;
  }
  REP(i,3)REP(j,C){
    sum = 0;
    REP(p,N)REP(q,N){
      if((p+q) % 3 == i){
        sum += D[c[p][q]][j];
        
      }
    }
    col[i][j] = sum;
  }
  REP(i,C){
    REP(j,C){
      if( j == i)
        continue;
      REP(k,C){
        if(k == j || k == i)
          continue;
        sum = col[0][i]+col[1][j]+col[2][k];
        res = min(sum,res);
      }
    }
  }
  cout << res << endl;
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}



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

int main(){
  vector<int> a(3);
  rep(i,3){
      cin >> a.at(i);
  }
  int five = 0;
  int seven = 0;

  rep(i,3){
      if (a.at(i) == 5){
          five ++;
      }
      else if (a.at(i) == 7){
          seven++;
      }
  }
  if ((five == 2) && (seven == 1)){
      cout << "YES" << endl;;
  }
  else {
      cout << "NO" << endl;
  }

  

}

Measured memory_bytes: 256
import java.util.Scanner;

/*
1回の操作でk-1個を最小値に変換
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int k = sc.nextInt();
        int[] arr = new int[N];
        for(int i = 0; i < N; i++) {
            arr[i] = sc.nextInt();
        }
        int res = 0;
        while(N > 0) {
            res++;
            N = N - k;
            if(N==0) break;
            N++;
        }
        System.out.println(res);
    }
}


Measured memory_bytes: 59116
#coding:utf-8

N, M = (int(x) for x in input().split())
l = []

for i in range(N):
	a, b = (int(x) for x in input().split())
	l.append([a,b])
	
l.sort()

ans = 0
count = 0

for i in range(N):
	count += l[i][1]
	if count >= M:
		count -= l[i][1]
		count = M - count
		ans += l[i][0] * count
		break
	ans += l[i][0] * l[i][1]
		
print(ans)


Measured memory_bytes: 20072
#include <cstdio>
#include <iostream> 
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
 
using namespace std;
using ll = long long;
 
const ll INF = 1e9;
const ll MOD = 1e9 + 7;

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

int main()
{
    int h, w;
    string a[505], aka[505], ao[505];

    cin >> h >> w;

    REP(i, h){
        cin >> a[i];

        if(i % 2 == 0){
            REP(j, w - 1){
                aka[i] += "#";

                if(a[i][j] == '#'){
                    ao[i] += "#";
                }
                else{
                    ao[i] += ".";
                }
            }

            aka[i] += ".";
            ao[i] += "#";
        }
        else{
            aka[i] += "#";

            if(a[i][0] == '#'){
                ao[i] += "#";
            }
            else{
                ao[i] += ".";
            }

            for(int j = 1; j < w; j++){
                if(a[i][j] == '.'){
                    aka[i] += ".";
                }
                else{
                    aka[i] += "#";
                }

                ao[i] += "#";
            }
        }
    }

    REP(i, h){
        cout << aka[i] << endl;
    }
    cout << endl;
    REP(i, h){
        cout << ao[i] << endl;
    }
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using Edge = pair<int, ll>;
using Graph = vector<vector<int>>;
using WeightedGraph = vector<vector<Edge>>;
const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

const int CASES = 3;

void solve() {
    ll X, Y; cin >> X >> Y;
    ll m = 2 * X;
    ll M = 4 * X;
    string ans = "No";
    if(m <= Y && Y <= M && Y % 2 == 0) ans = "Yes";
    cout << ans << endl;
}

int main() {
#ifdef MYLOCAL
    vector<string> filenames {"input1.txt", "input2.txt", "input3.txt", "input4.txt", "input5.txt"};
    cout << "------------\n";
    for(int i = 0; i < CASES; ++i){
        ifstream in(filenames[i]);
        cin.rdbuf(in.rdbuf());
        solve();
        cout << "------------\n";
    }
#else

    solve();

#endif
    return 0;
}


Measured memory_bytes: 3592
#include <stdint.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

using int_type = int64_t;

#define FOR(i, n) for (int_type i = 0; i < n; ++i)

int_type gcd(int_type a, int_type b) {
    return b == 0 ? a : gcd(b, a % b);
}
int_type lcm(int_type a, int_type b) {
    return (a * b) / gcd(a, b);
}

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

    int_type N;
    cin >> N;

    string S;
    cin >> S;

    int_type A = 0;
    FOR(i, N - 2) {
        if (memcmp("ABC", &S[i], 3) == 0) {
            ++A;
        }
    }
    cout << A;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  bool flag = true;
  if(N %2 == 1){
    flag = false;
  }
  else{
    for(int i=0; i<N/2; i++){
      if(S.at(i) != S.at(N/2 + i)){
        flag = false;
      }
    }
  }
  if(flag){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
void fastIO(){
  ios_base::sync_with_stdio(0); cin.tie(0);
}


int main(){
  fastIO();
  string s;
  cin>>s;
  int tot = 1;
  for(int i=1;i<s.length();i++){
  	if(s[i]!=s[i-1]){
  		tot++;
  	}
  }
  cout<<tot-1<<endl;
}



Measured memory_bytes: 512
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	defer writer.Flush()
	H, W, K := ReadInt(), ReadInt(), ReadInt()
	grid := make([]string, H)
	for i := 0; i < H; i++ {
		grid[i] = ReadString()
	}

	ans := make([][]int, H)
	cnt := 0
	for h := 0; h < H; h++ {
		pos := make([]int, 0) // この行のイチゴ位置
		for w := 0; w < W; w++ {
			if grid[h][w] == '#' {
				pos = append(pos, w)
			}
		}
		if len(pos) == 0 {
			// イチゴがなければ次の行へ
			continue
		}
		// イチゴがあれば、この行の左から右まで、番号を付ける。
		row := make([]int, W)
		left := 0
		for i, right := range pos {
			for w := left; w <= right; w++ {
				row[w] = cnt + i + 1
			}
			left = right + 1
		}
		for w := left; w < W; w++ {
			row[w] = cnt + len(pos)
		}
		cnt += len(pos)
		ans[h] = row

		// 上で未設定の行にも、同じ番号をつける
		for nh := h - 1; nh >= 0 && len(ans[nh]) == 0; nh-- {
			ans[nh] = row
		}
		if cnt == K {
			// イチゴが全部見つかったので下の行にも同じ番号をつけて終了
			for nh := h + 1; nh < H; nh++ {
				ans[nh] = row
			}
			break
		}
	}

	for h := 0; h < H; h++ {
		for w := 0; w < W; w++ {
			Printf("%d ", ans[h][w])
		}
		Println()
	}
}

var writer = bufio.NewWriter(os.Stdout)

func Printf(format string, a ...interface{}) { fmt.Fprintf(writer, format, a...) }
func Println(a ...interface{})               { fmt.Fprintln(writer, a...) }

var scanner = bufio.NewScanner(os.Stdin)

func init() {
	scanner.Buffer(make([]byte, 256), 1e9)
	scanner.Split(bufio.ScanWords)
}
func ReadString() string { scanner.Scan(); return scanner.Text() }
func ReadInt() int {
	a, err := strconv.Atoi(ReadString())
	if err != nil {
		panic(err)
	}
	return a
}


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

typedef long long ll;
typedef unsigned long long int ull;
#define endl "\n"
#define pb push_back
#define sq(a) (a)*(a)
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugv(v) cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;
#define MOD 1000000007
#define PI 3.141592653589793238
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);

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

ll exp(ll x,ll n,ll mod)
{
    ll result=1;
    while(n)
    {
        if(n & 1)
            result=(result * x)%mod;
        x=(x*x)%mod;
        n>>=1;
    }
    return result;
}



int32_t main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    IOS

    int n;
    cin>>n;

    int d1[n],d2[n];
    for(int i=0;i<n;i++)
    	cin>>d1[i]>>d2[i];

    bool ans=false;
    for(int i=0;i<n;i++)
    {
    	if(d1[i]==d2[i])
    	{
    		int pos=i+1;
    		while(pos<n && d1[pos]==d2[pos])
    			pos++;

    		if(pos-i >= 3)
    		{
    			ans=true;
    			break;
    		}

    		i=pos;
    	}
    }

    if(ans)
    	cout<<"Yes"<<endl;
    else
    	cout<<"No"<<endl;
    
    return 0;
}

Measured memory_bytes: 3652
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 * @throws NumberFormatException 
	 */
	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		int n = Integer.parseInt(br.readLine());
		
		int input[] = new int[n + 1];
		
		String[] tmpArray = br.readLine().split(" ");
		for(int i = 1; i <= n; i++){
			input[i] = Integer.parseInt(tmpArray[i - 1]);
		}
		
		boolean result[] = new boolean[n + 1];
		
		int count = 0;
		for(int i = n; i >= 1; i--){
			int tmpCount = 0;
			
			for(int j = 2; j * i <= n; j++){
				if(result[j * i]){
					tmpCount++;
				}
			}
			
			if((tmpCount%2 == 0 && input[i] == 1) || (tmpCount%2 == 1 && input[i] == 0)){
				result[i] = true;
				count++;
			}
		}
		
		System.out.println(count);
		boolean first = true;
		for(int i = 1; i <= n; i++){
			if(result[i]){
				if(first){
					System.out.print(i);
					first = false;
				}
				else{
					System.out.print(" "+i);
				}
			}
		}
		if(count != 0){
			System.out.println();
		}
	}

}


Measured memory_bytes: 51908
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
using namespace std;
int main() {
    int n;
    string s;
    cin >> n >> s;
    char animals[2] = {'S', 'W'};

    for(int i=0; i<4; i++){
        string str = "";
        str += animals[i/2];
        str += animals[i%2];
        for(int j=2; j<n; j++){
            if (s[j-1] == 'o' ^ str[j-1] == 'S' ^ str[j-2] == 'S'){
                str += 'S';
            }else{
                str += 'W';
            }
        }

        if (s[n-1] == 'o' ^ str[n-1] == 'S' ^ str[n-2] == 'S'){
            if (str[0] != 'S'){
                continue;
            }
        }else{
            if (str[0] != 'W'){
                continue;
            }
        }

        if (s[0] == 'o' ^ str[0] == 'S' ^ str[n-1] == 'S'){
            if (str[1] == 'S'){
                cout << str << endl;
                return 0;
            }
        }else{
            if (str[1] == 'W'){
                cout << str << endl;
                return 0;
            }
        }
    }
    printf("-1\n");
}

Measured memory_bytes: 640
number = gets.to_i

if number == 0
    puts 0
    exit
end

result = []
i = 0
while number != 0
    if number % 2 == 1
        result[i] = 1
        number -= (-1)**i
    else
        result[i] = 0
    end
    number /= 2
    i += 1
end

print result.reverse.join


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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef map<ll,ll>::iterator itll;
typedef long double ld;
typedef map<ll,ll> mapll;

#define con continue
#define pb push_back
#define fi first
#define se second
#define fr front()
#define one 1.0
#define inf 1000000000000000000
#define all(vl) vl.begin(),vl.end()
#define m_p make_pair 
#define sz(a) sizeof(a)
#define forn(mp,it) for(it = mp.begin();it!=mp.end();it++)
#define FOR(i,a,n) for(int i=a;i<n;i++) 
#define FORE(i,a,n) FOR(i,a,n+1)
#define Endl endl
#define eNdl endl
#define enDl endl
#define endL endl
#define PI 3.14159265358979323846

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cerr.tie(nullptr);
	ll a,b,c;
	cin>>a>>b>>c;
	if(c-a-b<=0)
	{
		cout<<"No\n";return 0;
	}
	if(4*a*b>=(c-a-b)*(c-a-b))
	{
		cout<<"No\n";return 0;
	}
	cout<<"Yes\n";
	return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int main(){

    int k;
    string s;
    cin >> s >> k;

    vector<string> substring;
    for(int i = 0;i < s.size();i++){

        for(int j = 1; i+j <= s.size() && j <= k;j++){
            substring.push_back(s.substr(i,j));
        }
    }

    VSORT(substring);
    set<string> p(substring.begin(),substring.end());
    vector<string> ans(p.begin(),p.end());
    cout << ans[k-1] << endl;

    return 0;
}

Measured memory_bytes: 2428
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <sstream>
#include <string>
#include <stack>
#include <set>
#include <vector>

using namespace std;

#define all(c) ((c).begin()), ((c).end())
#define dump(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = (int)(a); i <= (int)(b); i++)

#define mp make_pair
#define fst first
#define snd second
#define pb push_back

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

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

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
    return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
    os<<'[';
    rep(i,a.size()) os<<(i?" ":"")<<a[i];
    return os<<']';
}

int dp[110][20];
int plan[110];
int N;

char get_ng_pasta(char state) {
    repi(t, 1, 3) {
        int m = (1 << 2) - 1;
        if ((state & m) == t && (state >> 2 & m) == t) return t;
    }
    return 0;
}

int go(int day, char state) {
    if (dp[day][state] != -1) return dp[day][state];
    if (day == N) return dp[day][state] = 1;
    
    char ng_pasta = get_ng_pasta(state);
    int ans = 0;
    if (plan[day] != 0) {
        if (ng_pasta != plan[day]) ans += go(day + 1, state >> 2 | plan[day] << 2);
        ans %= 10000;
    }
    else {
        repi(t, 1, 3) if (t != ng_pasta) {
            ans += go(day + 1, state >> 2 | t << 2);
            ans %= 10000;
        }
    }

    return dp[day][state] = ans;
}

int main() {
   int K; cin >> N >> K;
   rep(i, K) {
        int A, B; cin >> A >> B;
        plan[A - 1] = B;
   }
   
   memset(dp, -1, sizeof(dp));
   cout << go(0, 0) << endl;

    return 0;
}

Measured memory_bytes: 1180
import collections
n=int(input())
s=[]
for i in range(n):
    s.append(input())
c=collections.Counter(s).most_common()

ans=[c[0][0]]
mx=c[0][1]
for i in range(1,len(c)):
    if c[i][1]==mx:
        ans.append(c[i][0])
    else:
        break

ans.sort()
for res in ans:
    print(res)
    

Measured memory_bytes: 45040
#include <stdio.h>

int main(){
	int i,count=0;
	char w[11],m[101];
	scanf("%s",&w);
	while (1){
		scanf("%s",&m);
		if (strcmp("END_OF_TEXT",m)==0) break;
		for (i=0;i<101;i++){
			if (m[i]>='A'&&m[i]<='Z')
				m[i]=m[i]+32;
		}
		if (strcmp(w,m)==0) count++;
	}
	printf("%d\n",count);
	return 0;
}	

Measured memory_bytes: 548
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100005,INF=1<<30;

ll rui(ll a,ll b){
    ll ans=1;
    while(b>0){
        if(b&1) ans=ans*a%mod;
        a=a*a%mod;
        b/=2;
    }
    return ans;
}

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

int f(int a,int b){
    if(a<b) return 0;
    if(a%b==0) return a/b;
    ll can=(a-a/b*b)/(a/b+1)+1,can2;
    ll c=a/b+1,d=a%b;
    if(d%c==0) can2=d/c;
    else{
        ll g=gcd(c,d);
        c/=g;
        d/=g;
        can2=d*rui(c,b-2);
      if(can2<can) return 1;
    }
    return f(a-(a/b+1)*min(can,can2),b);
}

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;cin>>N;
    int grundy=0;
    
    while(N--){
        int a,b;cin>>a>>b;
        grundy^=f(a,b);
    }
    
    if(!grundy) cout<<"Aoki"<<endl;
    else cout<<"Takahashi"<<endl;
}


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

int main(int argc, const char * argv[]) {
    int N;
    cin>>N;
    int *L=new int[N];
    for(int i=0;i<N;++i){
        cin>>L[i];
    }
    int count=0;
    for(int i=0;i<N;++i){
        int a=L[i];
        for(int j=i+1;j<N;++j){
            int b=L[j];
            if(a==b){
                continue;
            }
            for(int k=j+1;k<N;++k){
                int c=L[k];
                if(a!=c&&b!=c&&abs(a-b)<c&&c<a+b){
                    ++count;
                }
            }
        }
    }
    cout<<count<<endl;
    return 0;
}


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

const int MAXN = 1e5 + 7;

int main() {
    long long n, ans = 2;
    cin >> n;
    if(n <= 3) {
        cout << n << endl;
        return 0;
    }
    n--;
    long long tmp = 3, mx = 3, now;
    while(1) {
        now = tmp + mx*4;
        if(now <= n) {tmp = now, mx *= 3, ans += 2;}
        else break;
    }
    n -= tmp;
    now = mx;
    while(n > 0 && now >= 1) {
        ans += (n/now);
        n %= now;
        now /= 3;
    }
    ans += (n/mx);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3116
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

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

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

typedef long long ll;

using namespace std;
ll dp[50][2];



int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,k;
  cin>>n>>k;
  vector<ll>a(n);
  rep(i,n)cin>>a[i];
  ll mask=(1LL<<49);
  rep(i,49)
  {
    mask>>=1;
    int num=0;
    rep(i,n)if(a[i]&mask)num++;
    ll cost[2]={mask*(num),mask*(n-num)};
    if(mask&k)
    {
      dp[i+1][0]=dp[i][0]+cost[1];
    }
    else
    {
      dp[i+1][0]=dp[i][0]+cost[0];
    }

    if(mask&k)dp[i+1][1]=dp[i][0]+cost[0];
    if(dp[i][1]>0)chmax(dp[i+1][1],dp[i][1]+max(cost[0],cost[1]));
  }
  cout<<max(dp[49][0],dp[49][1])<<endl;


  return 0;

}


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

int main (){
	
	int N;
	cin >> N;
	vector<long> A(N);
	for(int i=0;i<N;i++){
		cin >> A[i];
	}
	
	const int Nmax=1e5;
	long cnt[Nmax+2];
	long Max=0;
	long num;
	
	for(int i=0;i<Nmax+2;i++){
		cnt[i]=0;
	}
	
	for(int i=0;i<N;i++){
		num = A[i];
		//num=10;
		cnt[num]++;
		cnt[num+1]++;
		cnt[num+2]++;
	}
	
	for(int i=0;i<Nmax+2;i++){
		Max=max(Max,cnt[i]);
	}
	cout << Max << endl;
}

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

int main() {
	int cards[4][13] = {};
	int n;
	cin >> n;

	for (int i = 0; i < n; i++) {
		char m;
		int l;
		cin >> m >> l;
		
		if (m == 'S') cards[0][l - 1] = 1;
		else if (m == 'H') cards[1][l - 1] = 1;
		else if (m == 'C') cards[2][l - 1] = 1;
		else if (m == 'D') cards[3][l - 1] = 1;			
	}

	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 13; j++) {
			if (cards[i][j] == 1) continue;
			if (i == 0) cout << "S" << " " << j+1 << endl;
			else if (i == 1) cout << "H" << " " << j+1 << endl;
			else if (i == 2) cout << "C" << " " << j+1 << endl;
			else if (i == 3) cout << "D" << " " << j+1 << endl;
		}
	}

	return 0;

}



Measured memory_bytes: 3076
#include <string>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <functional>
#include <queue>
using namespace std;
const int INT_INF = 500000000;
const long long LONG_LONG_INF = (long long)pow(10,18);
const int MOD = pow(10,9) + 7;
/* contest template */
int N;
int A[100002];
int d[100002];
int ans[100001];

int main()
{
    cin>>N;
    for(int i=1;i<=N;i++){
      cin>>A[i];
    }
    d[0]=0;
    A[0]=0;
    for(int i=1;i<=N;i++){
      d[i]=d[i-1]+abs(A[i]-A[i-1]);
    }
    d[N+1]=d[N]+abs(A[N]);
    for(int i=1;i<=N;i++){
      ans[i]=d[i-1]+d[N+1]-d[i+1]+abs(A[i-1]-A[i+1]);
    }
    for(int i=1;i<=N;i++){
      cout<<ans[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 2432
import math

def pn(n):
  if n == 1 and n == 2 or n == 3:
    return False
  for i in range(3,int(math.sqrt(n))+1,2):
    if n%i == 0:
      return True
  else:
	  return False

Q = int(input())
lr = [list(map(int,input().split())) for i in range(Q)]

cnt = [-1]*(100001)
dp = [0]*(100001)

cnt[2] = 0
for i in range(1,100001,2):
  if pn(i) == False:
    cnt[i] = 0
for i in range(1,100001,2):
  if cnt[i] == 0:
    if cnt[(i+1)//2] == 0:
      dp[i] = 1

for i in range(1,100001,2):
  dp[i] += dp[i-2]
  
for l,r in lr:
  if l == 1:
    print(dp[r]-1) 
  else:
    print(dp[r]-dp[l-2])

Measured memory_bytes: 30928
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
 
int main() {
	int n;
	cin >> n;
	vector <int> d(n);
	for (int i =0 ; i<n;i++) cin >> d[i];
	int sum =0;
	for (int i=0;i<n;i++) {
		for (int j =i+1; j <n; j++) {
			sum += d[i] * d[j];
		}
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 888
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#include<algorithm>

using namespace std;

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

    vector<int> dp(n + 1);
    dp[0] = 1;
    dp[1] = 1;
    for (int i = 2; i < n + 1; i++) {
        dp[i] = dp[i - 2] + dp[i - 1];
    }

    cout << dp[n] << endl;

    return 0;
}



Measured memory_bytes: 3100
#include <iostream>
#include <vector>
#include <cstdio>
#include <sstream>
#include <map>
#include <string>
#include <algorithm>
#include <queue>
#include <cmath>
#include <set>
#include <functional>
using namespace std;

int main(){
	int N;
	cin >> N;
	map<string, pair<int,int> > ing;

	vector<pair<int,int>> v(N);
	for(int i=0; i<N; i++){
		string s;
		int x;
		cin >> s >> x;
		ing[s] = {x, i};
		v[i] = {x,i};
	}

	sort(v.begin(), v.end());


	vector<vector<int>> G(N);
	int M;
	cin >> M;
	for(int i=0; i<M; i++){
		char c[100];
		char c_[100];
		scanf("%s %s", c, c_);
		string s_(c), t_(c_);

		int x = ing.find(s_)->second.second;
		int y = ing.find(t_)->second.second;

		G[x].push_back(y);
		G[y].push_back(x);
	}

	vector<bool> used(N, false);
	long long ans = 0;

	function<long long (int)> dfs = [&](int pos) -> long long{
		if(used[pos]) return 0;
		used[pos] = true;
		long long ret = 0;
		for(int i=0; i<G[pos].size(); i++){
			ret += dfs(G[pos][i]);
		}
		return ret + 1;
	};

	for(int i=0; i<N; i++){
		ans += v[i].first * dfs(v[i].second);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 2004
#include<bits/stdc++.h>
using namespace std;
int ans,n,k;
int main(){
	std::ios::sync_with_stdio(false);
	cin>>n>>k;
	ans=1;
	for(int i=1;i<=n;i++) ans+=min(ans,k);
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define rep2(i,a,n) for(int i=(a); i<(n); i++)
#define all(vec) vec.begin(),vec.end()
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
int main() {
  string S; cin >> S;
  string ans = "";
    rep(i, (int)S.size()){
      if (S[i] == 'B'){
        if (ans.size() == 0) continue;
        else ans.pop_back();
      }
      else ans += S[i];
    }
  cout << ans <<endl;
  return 0;
}

Measured memory_bytes: 3632
import fractions
def lcm(a,b):
  return (a*b)//fractions.gcd(a,b)
n=int(input())
if n>1:
  x=lcm(int(input()),int(input()))
  for i in range(n-2):
    x=lcm(x,int(input()))
  print(x)
else:print(int(input()))

Measured memory_bytes: 5432