akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main()
{
    int n, m;
    int *A;
    int *B;
    int *res;

    cin >> n >> m;

    if ((n >= 1 && n <= 100) && (m >= 1 && m <= 100)) {
        try {
            A = new int[n*m];
            B = new int[m];
            res = new int[n];
            
            int num = 0;

            int i, j;

            for (i = 0; i < n; i++) {
                for (j = 0; j < m; j++) {
                    cin >> A[num];
                    num++;
                }
            }

            for (i = 0; i < m; i++) {
                cin >> B[i];
            }

            num = 0;
            for (i = 0; i < n; i++) {
                res[i] = 0;
                for (j = 0; j < m; j++) {
                    res[i] += A[num] * B[j];
                    num++;
                }
            }

            for (i = 0; i < n; i++) {
                cout << res[i] << endl;
            }

            delete [] A;
            delete [] B;
            delete [] res;
        } catch (...) {
            return -1;
        }
    }

    return 0;
}


Measured memory_bytes: 3116
#!/usr/bin/env pypy
from __future__ import division, print_function

import os
import sys
from __builtin__ import xrange as range
from cStringIO import StringIO
from future_builtins import ascii, filter, hex, map, oct, zip
from io import IOBase

import __pypy__


def main():
    n, l = map(int, input().split())
    tot = n * l + (n * (n - 1) >> 1)

    res, m = 0, float('inf')
    for i in range(n):
        pie = tot - (l + i)
        if abs(pie - tot) < m:
            m = abs(pie - tot)
            res = pie

    print(res)


# region fastio

BUFSIZE = 8192


class FastI(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = StringIO()
        self.newlines = 0

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count("\n") + (not b)
            ptr = self._buffer.tell()
            self._buffer.seek(0, 2), self._buffer.write(b), self._buffer.seek(ptr)
        self.newlines -= 1
        return self._buffer.readline()


class FastO(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = __pypy__.builders.StringBuilder()
        self.write = lambda s: self._buffer.append(s)

    def flush(self):
        os.write(self._fd, self._buffer.build())
        self._buffer = __pypy__.builders.StringBuilder()


def print(*args, **kwargs):
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


sys.stdin, sys.stdout = FastI(sys.stdin), FastO(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


Measured memory_bytes: 29036
#include <bits/stdc++.h>
inline long long read();
using namespace std;

int main()
{
	cout<<read()/3;
}
inline long long read()
{
    register long long x=0,k=1;
    char c;
    c=getchar();
    while(c<'0'||c>'9'){if(c=='-')k=-1;c=getchar();}
    while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();
    return x*k;
}


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

int main() {
  int ans = 0;
  int n; cin >> n;
  int suma = 0, sumb = 0;
  vector<int> veca(n);
  vector<int> vecb(n);
  for (int i = 0; i < n; i++) {
    cin >> veca.at(i);
    suma += veca.at(i);
  }
  for (int i = 0; i < n; i++) {
    cin >> vecb.at(i);
    sumb += vecb.at(i);
  }
  int sum = 0, suma_d=0, sumb_d = sumb;
  for (int i = 0; i < n; i++) {
    suma_d += veca.at(i);
    if (i != 0) {
    sumb_d -= vecb.at(i-1) ;
    }
    sum = suma_d + sumb_d;
    ans = max(ans, sum);
  }
  cout << ans << endl;
}



Measured memory_bytes: 256
s = gets.strip.split('')

current = []
groups = []

s.each do |c|
  if current.last=='L' && c== 'R'
    groups.push(current)
    current = []
  end
  current.push(c)
end
groups.push(current)

result = []

groups.each do |group|

    r_count = group.select {|c| c=='R' }.length
    l_count = group.length - r_count
    l_value = r_value = group.length/2

    if group.length.odd?
      if l_count.odd?
        l_value+=1
      else
        r_value+=1
      end
    end

    (r_count-1).times { result.push(0) }
    result.push(r_value)
    result.push(l_value)
    (l_count-1).times { result.push(0) }

end

puts result.join(' ')


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

const int N = 210;
const int mod = 1e9 + 7;

typedef long long LL;

int frac[N], inv[N], n, k;

inline int Pow(int x, int y) {
    int res = 1;
    for (; y; y >>= 1, x = (LL)x * x % mod) if (y & 1) res = (LL)res * x % mod;
    return res;
}

inline int C(int n, int r) {
    return (LL)frac[n] * inv[r] % mod * inv[n - r] % mod;
}

char s[N];

vector<int> zjk;

inline bool check() {
    vector<int> R = zjk, B, T; 
    for (int i = 1; i <= k; i++) {
        if (R.size() + B.size() + T.size() == 0) return true;
        if (s[i] == 'r') {
            if (R.size()) {
                int t = R.back(); R.pop_back();
                if (t > 1) B.insert(B.begin(), t - 1);
            } else if (T.size()) {
                (*T.rbegin())--;
                if (!T.back()) T.pop_back();
            }
        } else {
            if (B.size()) {
                int t = B.back(); B.pop_back();
                if (t > 1) T.push_back(t - 1);
            } else if (T.size()) {
                (*T.rbegin())--;
                if (!T.back()) T.pop_back();
            }
        }
    }
    return R.size() + B.size() + T.size() == 0;
}

int res = 0;

void dfs(int mn, int mx, int lst) {
    if (mn > n) return;
//    cout << "dfs: " << mn << ' ' << mx << ' ' << lst << endl;
//    cout << "zjk: ";
//    for (auto t : zjk) cout << t << ' ';
//    cout << endl;
    if (!check()) return;
    int w = (LL)C(n - mn + mx - 1, mx - 1) * frac[zjk.size()] % mod;
    for (int i = 0; i < zjk.size(); i++) {
        int j = i;
        while (j + 1 < zjk.size() && zjk[j + 1] == zjk[j]) j++;
        w = (LL)w * inv[j - i + 1] % mod, i = j;
    }
//    cout << res << ' ' << w << endl;
    res = (res + w) % mod;
    for (int i = lst; mn + max(1, 2 * i - 1) <= n; i++) 
        zjk.push_back(i + 1), dfs(mn + max(1, 2 * i - 1) + (zjk.size() != 1), mx + (i + 1) * 2, i), zjk.pop_back();
}

int main() {
    scanf("%d%d%s", &n, &k, s + 1), frac[0] = inv[0] = 1;
    for (int i = 1; i <= 200; i++) frac[i] = (LL)frac[i - 1] * i % mod, inv[i] = Pow(frac[i], mod - 2);
    dfs(0, 1, 0);
    printf("%d\n", res);
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define ALL(v) v.begin(), v.end()
#define N 100007
#define INF 1000000007
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll fceil(ll a, ll b) { return (a % b == 0 ? a / b : a / b + 1); }
int main()
{
   int  d, n;
   cin >> d >> n;
   cout << (n + (n / 100LL)) * (int)pow(100, d) << endl;
   return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  vector<vector<int>> G(N);
  rep(i, M) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    G[a].push_back(b);
  }
  vector<bool> vis(N);
  vector<int> path;
  vector<int> ans;
  function<void(int, int)> dfs = [&](int tmp, int par) {
    if(vis[tmp]) {
      if(ans.size() == 0) {
        auto from = find(all(path), tmp);
        int size = path.end() - from;
        if(size != 0) {
          ans = vector<int>(size);
          copy(from, path.end(), ans.begin());
        }
      }
      return;
    }
    path.push_back(tmp);
    vis[tmp] = true;
    for(int ne: G[tmp]) dfs(ne, tmp);
    path.pop_back();
  };
  rep(i, N) dfs(i, -1);
  if(ans.size() == 0) {
    cout << -1 << endl;
  } else {
    auto check = [&](vector<int>& path) {
      set<int> se;
      for(int v: path) se.insert(v);
      int n = path.size();
      rep(i, n) {
        for(int ne: G[path[i]]) {
          if(se.count(ne) && ne != path[(i+1)%n]) {
            return make_pair(path[i], ne);
          }
        }
      }
      return make_pair(-1, -1);
    };

    while(true) {
      auto ret = check(ans);
      if(ret.first == -1) break;
      vector<int> newPath;
      int n = ans.size();
      int begin = find(all(ans), ret.second) - ans.begin();
      int end = find(all(ans), ret.first) - ans.begin();
      for(int i=begin; i!=end; i=(i+1)%n) {
        newPath.push_back(ans[i]);
      }
      newPath.push_back(ans[end]);
      ans = vector<int>(newPath.size());
      copy(all(newPath), ans.begin());
    }
    cout << ans.size() << endl;
    for(int a: ans) cout << a+1 << endl;
  }
  return 0;
}


Measured memory_bytes: 384
N = int(input())
S = list(str(input()))
x = 0
lists = []
for i in range(N):
    x = 0
    for j in range(N):
        if S[j] == "I":
            x += 1
            lists.append(x)
        else:
            x -= 1
            lists.append(x)
if max(lists) < 0:
    print("0")
else:
    print(max(lists))

Measured memory_bytes: 3316
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<queue>
#include<algorithm>
using namespace std;
const int maxn = 1e4 +5;
int vis[maxn] = { 0 };
int main()
{
	int N,A,B;
	int a,b,c,d;
	for( int i = 1 ; i <= 10000 ; i++ ){
		a = i/1000;
		b = i/100 % 10;
		c = i/ 10 % 10;
		d = i % 10;
		int sum0 = a + b + c + d;
		if( sum0 >= 1 && sum0 <= 36 )
			vis[i] = sum0;
	}
	vis[10000] = 1;
	while( ~scanf("%d %d %d",&N,&A,&B) ){
		int sum = 0;
		for( int i = 1 ; i <= N ; i++ ){
			if( vis[i] <= B && vis[i] >= A )
				sum = sum + i;
		}
		printf("%d\n",sum);
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <iomanip>
#define ll long long
 
using namespace std;
 
int main()
{
	int n;
	cin >> n;
	string a;
	cin >> a;
	char temp = a[0];
	int otpt=1;
	for (int i = 1;i<n;i++)
	{
		if (temp != a[i])
		{
			temp = a[i];
			otpt++;
		}
	}
	cout << otpt;
}

Measured memory_bytes: 512
require 'set'

def check(arr)
  return false if arr[1..8].any?{|i| arr[0] != i}
  return false if arr[10..11].any?{|i| arr[9] != i}
  return false if arr[13..14].any?{|i| arr[12] != i}
  return false if arr[16..17].any?{|i| arr[15] != i}
  return false if arr[19..20].any?{|i| arr[18] != i}
  return false if arr[22..29].any?{|i| arr[21] != i}
  true
end

MV = [[0,1,2,14,18,27,28,29,15,20],
      [6,7,8,12,9,21,22,23,17,11],
      [0,3,6,9,15,23,26,29,20,17],
      [2,5,8,11,12,21,24,27,18,14]]
  
gets.to_i.times do
  cube = gets.split(" ").map(&:to_i)
  s = Set.new(cube)
  q = []
  q << [cube, 0]
  until q.empty?
    tmp, cnt = q.shift
    if check(tmp)
      p cnt
      break
    end
    MV.each do |arr|
      tmp2 = tmp.dup
      arr[0,5].zip(arr[5,5]).each do |a, b|
        tmp2[a], tmp2[b] = tmp2[b], tmp2[a]
      end
      unless s.include?(tmp2)
        s.add(tmp2)
        q << [tmp2, cnt+1]
      end
    end
  end
end

Measured memory_bytes: 9232
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in Actual solution is at the top
 *
 * @author Silviase
 */
public class Main {

  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    Scanner in = new Scanner(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    BCommonRaccoonVsMonster solver = new BCommonRaccoonVsMonster();
    solver.solve(1, in, out);
    out.close();
  }

  static class BCommonRaccoonVsMonster {

    public void solve(int testNumber, Scanner in, PrintWriter out) {
      int h = in.nextInt();
      int n = in.nextInt();
      long x = 0;
      for (int i = 0; i < n; i++) {
        x += in.nextLong();
      }
      out.println(x >= h ? "Yes" : "No");
    }

  }
}



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

static const int INF=100000;
typedef long long ll;
typedef pair<int,int> P;
const int MAX=210000;
const long long MOD=1000000007;

typedef long long ll;

ll fac[MAX],finv[MAX],inv[MAX];

ll mod_pow(ll x, ll n){ //べき乗
    ll ans=1;
    while(n!=0){
        if(n&1) ans=ans*x%MOD;
        x=x*x%MOD;
        n=n>>1;
    }
    return ans;
}

void com_init(){ //初期化
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        //inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        //finv[i]=finv[i-1]*inv[i]%MOD;
        finv[i]=finv[i-1]*mod_pow(i,MOD-2)%MOD;//フェルマーの小定理より
    }
}

ll comb(ll n, ll k){ //nCk
    if(n<k) return 0;
    if(n<0||k<0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

int main(){
    ll N,K;
    cin >> N >> K;
    com_init();
    for(int i=1;i<=K;i++){
        ll ans;
        ans=comb(N-K+1,i)*comb(K-1,i-1)%MOD;
        cout << ans << endl;
    }
}


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

typedef long long ll;
const ll INF = 1e9, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define REPR(i,a,b) for(ll i=b;i>=a;i--)
#define repr(i,n) REPR(i,0,n)
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define fi first
#define se second
#define m_p make_pair

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

    ll k;
    vector<ll> a(5);
    rep(i,5) cin >> a[i];
    cin >> k;
    rep(i,4){
        REP(j,i+1,5){
            if(a[j]-a[i]>k){
                cout << ":(" << "\n";
                return 0;
            }
        }
    }
    cout << "Yay!" << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1 << 28;
const double EPS = 1e-10;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

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

	if (D == 25) cout << "Christmas" << endl;
	if (D == 24) cout << "Christmas Eve" << endl;
	if (D == 23) cout << "Christmas Eve Eve" << endl;
	if (D == 22) cout << "Christmas Eve Eve Eve" << endl;

	return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

// {{{
template<typename T>
void printmatrix(vector<vector<T> > ar){
    for (int i = 0; i < (int)ar.size(); i++) {
        for (int j = 0; j < (int)ar[0].size(); j++) {
            cout << ar[i][j];
        }
        cout << endl;
    }
}

template<typename T>
void printvector(vector<T> vec){
    for (int i = 0; i < (int)vec.size(); i++) {
        cout << vec[i] << endl;
    }
}

template<typename T>
void unique(vector<T>& vec){
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
}

template<typename T>
vector<T> cumsum(vector<T> vec){
    vector<T> newvec((T)vec.size());
    int tmp = 0;
    for (int i = 0; i < (int)vec.size(); i++) {
        tmp += vec[i];
        newvec[i] = tmp;
    }

    return newvec;
}

template<typename T>
T digitsum(T x){
    T y=0;
    while(x){
        y += x % 10;
        x /= 10;
    }

    return y;
}

template<typename T>
T gcd(T x, T y){
    if (x == 0 || y == 0) {
        return 0;
    }

    while (x != y){
        if (x > y) {
            x -= y;
        }else{
            y -= x;
        }
    }
    return x;
}

// }}}
/* vim:set foldmethod=marker: */

void solve(){
    int n;
    cin >> n;

    int ans=0;
    for (int j = 1; j <= n; j++) {
        int tmp=0;
        if (j % 2 == 0) {
            continue;
        }
        for (int i = 1; i <= j; i++) {
            if (j % i == 0) {
                tmp++;
            }
        }
        if (tmp == 8) {
            ans++;
        }
    }

    cout << ans  << endl;

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}

// sortの仕方
// int a[N];
// array<int,N> ar;
// vector<int> v;
//
// sort(a, a+N); // 配列
// sort(ar.begin(), ar.end()); // array
// sort(v.begin(), v.end()); // vector 昇順
// sort(v.begin(), v.end(), greater<int>()); // 降順

// Template
// template <class T>
// T foomax(T x, T y){
//   if (x > y){
//     return x;
//   }else{
//     return y;
//   }
// }

// string を int に変換 stoi("1010")
// int を string に変換 to_string(1010)


// map の key, value を全て抜き出す。
// for (auto itr = mp.begin(); itr != mp.end(); itr++) {
//     cout << "key" << itr->first << " value" << itr->second << endl;
// }

// 文字列の検索
// string s="abc";
// if (s.find('d') == string::npos){
//     cout << "find" << endl;
// }else{
//     cout << "not find" << endl;
// }


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

int nod(int n) {
    int res = 0;
    for(int i = 1; i <= n; ++i) if(n % i == 0) res++;
    return res;
}

int main() {
    int n, res = 0;
    scanf("%d", &n);
    for (int i = 1; i <= n; i += 2) {
        if(nod(i) == 8) res++;
    }
    printf("%d\n", res);
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

typedef  long long int lint;

#define rep(i, n) for (lint i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
#define mp make_pair
#define P pair<int,int>
#define enld endl

vector<lint> prime_factorization(lint N) {
	//素因数分解して配列で返す
	vector<lint> R;
	if (N < 2)return R;
	for (lint i = 2; i * i <= N; i++) {
		while (N % i == 0) {
			R.push_back(i);
			N /= i;
		}
	}
	if (N != 1) {
		R.push_back(N);
	}
	return R;
}

lint power(lint x, lint n, lint m) {
	//(x^n)%mを返す
	lint res = 1;
	x %= m;
	while (n > 0) {
		if (n % 2 == 1) {
			res = res * x % m;
		}
		x = x * x % m;
		n /= 2;
	}
	return res;
}

int main() {
	lint M, N;
	cin >> M >> N;
	lint MOD = 1000000007;
	cout << power(M, N, MOD) << enld;
}


Measured memory_bytes: 3092
#include <stdio.h>

int main(void){
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    int num[3]={a,b,c};
    int i,j,per = 0;
    for(i;i<3;i++){
        for(j=i+1;j<3;j++){
            if(num[i]>num[j]){
                per = num[i];
                num[i]=num[j];
                num[j]=per;
            }
        }
    }
    
    
    printf("%d %d %d\n",num[0],num[1],num[2]);
}


Measured memory_bytes: 2136
#include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pii;

int main(){
	int n;
	cin>>n;
	string s;
	rep(i,0,n){
		cin>>s;
		sort(all(s));
		int min=0,max=0;
		rep(j,0,8){
			min+=(s[j]-'0')*pow(10,7-j);
		}
		reverse(all(s));
		rep(j,0,8){
			max+=(s[j]-'0')*pow(10,7-j);
		}
		o(max-min);
	}
}

Measured memory_bytes: 1264
/*
 * 
　 　 　 　　　　　　　 　 　　　　　　　　　　　　　　　　 ,.へ
　　___ 　　　　　　　 　 　 　 　 　　　　　　　　　　　　ム　　i
　「 ヒ_i〉　　　 　 　　　　　　 　 　　　　　　　　　　　　 ゝ　〈
　ト　ノ 　　　　　　　　　　　　　　　　　　　　　　　　　　iニ(()
　i 　{ 　 　　　　　　　 　　　＿＿＿_ 　 　　　　　　　　| 　ヽ
　i　　i　　　 　　　　　　　／__,　 , ‐-＼ 　 　 　 　 　　i 　　}
　|　　 i　　　　　　 　　／（●) 　 ( ● )＼　　　　　　 {、　 λ
　ト?┤.　　　　　　／ 　 　（__人__） 　　　＼　　　 ,ノ　‾ ,!
　i　　　ゝ、_ 　　　　|　　　　　´‾` 　 　　　　|　,. '´ハ　　　,!
.　ヽ、 　　　｀`　、,__＼ 　　 　 　　　　　 　 ／"　＼ 　ヽ／
　　　＼ノ　ノ　　　ハ‾r/:::r?--?/::７　　 ノ　　　　／
　 　　 　 ヽ.　　　　　　ヽ::〈； . '::. :' |::/　　 /　　　,. "
　　　　　　　 `ー 、　　　　＼ヽ::. ;::：|/　　　　　ｒ'"
　　　　　／‾二二二二二二二二二二二二二二二二ヽ
　　　　　| 答 |　　　　 　A C C E P T E D　　　　　　　│|
　　　　　＼＿二二二二二二二二二二二二二二二二ノ

 */
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    /*
     * 各列の線の状態は、IOO, OIO, OOI, III の4通りしかないので、それらの間の遷移を考える。
     * ただし上手くやらないと線が連結ではなくなってしまうので、IIIはIOO->IIIとOOI->IIIの2通りに分けて考える
     */
    public static void main(String[] args) {
	Scanner scanner = new Scanner(System.in);
	int MOD = 1000000;
	int N = scanner.nextInt();
	int M = scanner.nextInt();
	if (M == 2) {
	    long[][] dp = new long[N][5];
	    Arrays.fill(dp[0], 1);
	    dp[0][4] = 0;
	    for (int i = 1; i < dp.length; i++) {
		dp[i][0] += (dp[i - 1][0] + dp[i - 1][1] + dp[i - 1][2] + dp[i - 1][4]);
		dp[i][0] %= MOD;
		dp[i][1] += (dp[i - 1][0] + dp[i - 1][1] + dp[i - 1][2]);
		dp[i][1] %= MOD;
		dp[i][2] += (dp[i - 1][0] + dp[i - 1][1] + dp[i - 1][2] + dp[i - 1][3]);
		dp[i][2] %= MOD;
		dp[i][3] += (dp[i - 1][0] + dp[i - 1][3]);
		dp[i][3] %= MOD;
		dp[i][4] += (dp[i - 1][2] + dp[i - 1][4]);
		dp[i][4] %= MOD;
	    }

	    long ans = dp[N - 1][0] + dp[N - 1][1] + dp[N - 1][2]
		    + dp[N - 1][3];
	    ans %= MOD;
	    System.out.println(ans);
	} else {
	    long ans = 1;
	    for (int i = 0; i < N; i++) {
		ans *= 2;
		ans %= MOD;
	    }
	    System.out.println(ans);
	}

    }

}

Measured memory_bytes: 26380
#include<stdio.h>
#include<iostream>
using namespace std;
int main(){
int n,m,t[1000],f[1000],i,j,g=0,tn,u,o=0;
cin>>n>>m;
for(i=0;i<m;i++){
scanf("%d %d",&t[i],&f[i]);
if(t[i]>=n){
o++;
t[i]=0;
}
}
for(i=0;i<m;i++){
for(j=i+1;j<m;j++){
if(t[i]<t[j]){
tn=t[i];
t[i]=t[j];
t[j]=tn;
}
}
}
u=m-1-o;
for(i=0;i<u;i++){
g+=n-t[i];
}
cout<<g<<endl;
return 0;
}

Measured memory_bytes: 3152
def ascan; gets.split.map(&:to_i); end

def guchoku(n,m,d)
    l = 0
    c = 0
    (1..n).to_a.repeated_permutation(m) do |li|
        l += li.each_cons(2).map{|a,b| (a-b).abs == d ? 1 : 0}.reduce(:+)
        c += 1
    end
    l.to_r/c
end


n,m,d = ascan.map(&:to_r)

# p guchoku(n,m,d)

if d == 0
    p ((m-1)/n).to_f
else
    p (2*(n-d)*(m-1)/(n*n)).to_f
end

# (10/25) 5 3 0 ; (m-1)/n
# (16/25) 5 3 1
# (12/25) 5 3 2
# (8/25)  5 3 3
# 
# (6/25) 5 2 2
# (12/25) 5 3 2
# (18/25) 5 4 2
# (24/25) 5 5 2 
# (30/25) 5 6 2
# 
# (8/25) 5 2 1
# (16/25) 5 3 1
# (24/25) 5 4 1
# 
# /6*6
# (1/3) 6 3 0 ; (m-1)/n
# (20/36) 6 3 1
# (16/36) 6 3 2

Measured memory_bytes: 1788
package main

import (
	"fmt"
)

func main() {
	var N int
	fmt.Scanf("%d", &N)
	words := map[string]bool{}
	var last byte
	var word string
	for i := 0; i < N; i++ {
		fmt.Scanf("%s", &word)
		if word[0] != last && last != 0 {
			fmt.Printf("No\n")
			return
		}
		if words[word] {
			fmt.Printf("No\n")
			return
		}
		words[word] = true
		last = word[len(word)-1]
	}
	fmt.Printf("Yes\n")
}


Measured memory_bytes: 512
import sys

R, C, K = map(int, input().split())
item = [[0] * (C + 1) for _ in range(R + 1)]  # dp配列と合わせるために, 0行目, 0列目を追加している.
for s in sys.stdin.readlines():
    r, c, v = map(int, s.split())
    item[r][c] = v

dp = [[[0] * (C + 1) for _ in range(R + 1)] for _ in range(4)]
for i in range(R + 1):
    for j in range(C + 1):
        for k in range(4):
            here = dp[k][i][j]
            if i + 1 <= R:
                dp[0][i + 1][j] = max(dp[0][i + 1][j], here)
                dp[1][i + 1][j] = max(dp[1][i + 1][j], here + item[i + 1][j])
            if j + 1 <= C:
                dp[k][i][j + 1] = max(dp[k][i][j + 1], here)
                if k < 3:
                    dp[k + 1][i][j + 1] = max(dp[k + 1][i][j + 1], here + item[i][j + 1])
ans = 0
for k in range(4):
    ans = max(ans, dp[k][-1][-1])
print(ans)

Measured memory_bytes: 430208
d, g = map(int, input().split())

problems = []
for i in range(1, d + 1):
    num, bonus = map(int, input().split())
    point = i * 100
    problems.append([point, num, bonus])

ans = []
for mask in range(2 ** d):
    score = 0
    count = 0
    target = 0
    for bit in range(d):
        if (mask >> bit) & 1:
            point, num, bonus = problems[bit]
            score += (point * num) + bonus
            count += num
        else:
            target = bit
            
    if score >= g:
        ans.append(count)
    else:
        point, num, bonus = problems[target]
        delta = g - score
        add = delta // point + bool(delta % point)
        if add < num:
            ans.append(count + add)
        else:
            continue

print(min(ans))


Measured memory_bytes: 3064
#include <iostream>

using namespace std;

void solve()
{
	int a[4];
	int b[4];
	while(cin >> a[0])
	{
		for(int i = 1; i < 4; ++i)
		{
			cin >> a[i];
		}
		for(int i = 0; i < 4; ++i)
		{
			cin >> b[i];
		}
		int hit = 0;
		int blow = 0;
		for(int i = 0; i < 4; ++i)
		{
			for(int j = 0; j < 4; ++j)
			{
				if(a[i] == b[j])
				{
					if(i == j)
					{
						++hit;
					}
					else
					{
						++blow;
					}
					break;
				}
			}
		}
		cout << hit << " " << blow << endl;
	}
}

int main()
{
	solve();
	return(0);
}

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

int main() {
    string s;
    map<string, int> m;
    while(cin >> s) {
        m[s]++;
    }
    string r1, r2;
    for(auto& p : m) {
        if(m[r1] < p.second) {
            r1 = p.first;
        }
        if(r2.size() < p.first.size()) {
            r2 = p.first;
        }
    }
    cout << r1 << ' ' << r2 << endl;
}


Measured memory_bytes: 3032
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

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

Measured memory_bytes: 256
x, n = map(int, input().split())
p = list(map(int, input().split()))
ans = 0

if n == 0:
    print(x)
    exit()

p.sort()

for i in range(p[0] - x, p[n - 1] + x):
    if (i not in p) and abs(x - i) < abs(ans - x):
        ans = i

print(ans)


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

typedef long long ll;

int main(void)
{
    int n, k;
    while(1)
    {
        cin >> n >> k;
        if(n == 0 and k == 0) return 0;
        vector<ll> a(n+1, 0);
        rep(i, n)
        {
            int x; cin >> x;
            a[i+1] = a[i] + x;
        }
        ll ans = -1e18;
        rep(i, n)
        {   
            if(i + k > n) continue; 
            ans = max(ans, a[i+k] - a[i]);
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3540
n,w=map(int,input().split())
vlst=[0 for i in range(n)]
wlst=[0 for i in range(n)]
for i in range(n):
    vlst[i],wlst[i]=map(int,input().split())

dp=[[0 for i in range(w+1)] for j in range(n+1)]
for i in range(1,n+1):
    for j in range(1,w+1):
        if j-wlst[i-1]>=0:
            dp[i][j]=max(dp[i-1][j-wlst[i-1]]+vlst[i-1],dp[i-1][j])
        else : dp[i][j]=dp[i-1][j]

print(dp[n][w])


Measured memory_bytes: 42264
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

ll ppow(ll a,ll b){
	a%=MOD;
	ll res=1;
	while(b){
		if(b&1)res=(res*a)%MOD;
		a=(a*a)%MOD;
		b>>=1;
	}
	return res;
}
class Fact{
	vector<ll>fact;
	vector<ll>inv;
public:
	Fact(){}
	Fact(int n){
		n=n*2+10;
		fact=inv=vector<ll>(n);
		fact[0]=inv[0]=1;
		for(int i=1;i<n;i++){
			fact[i]=(fact[i-1]*i)%MOD;
			inv[i]=ppow(fact[i],MOD-2);
		}
	}
	ll get(int n){
		return fact[n];
	}
	ll nPr(int n,int r){
		return fact[n]*inv[n-r]%MOD;
	}
	ll nCr(int n,int r){
		return nPr(n,r)*inv[r]%MOD;
	}
	ll nrP(int n,int r){
		return nPr(n+r,n);
	}
	ll nrC(int n,int r){
		return nCr(n+r,n);
	}
};
int main(){
	string s;cin>>s;
	ll ans=0;
	int cnt=0;
	for(int i=0;i<s.size();i++){
		if(s[i]=='1'){
			int len=s.size()-i-1;
			ll t=(ppow(2,cnt)*ppow(3,len)%MOD+MOD)%MOD;
			(ans+=t)%=MOD;
			cnt++;
		}
	}
	ll t=(ppow(2,cnt)+MOD)%MOD;
	(ans+=t)%=MOD;
	cout<<ans<<endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  int m = 0;
  rep(i, n+1) {
    if(i*(i+1)/2 == n) {
      m = i+1;
      break;
    } else if(i*(i+1)/2 > n) {
      cout << "No" << endk;
      return 0;
    }
  }
  cout << "Yes" << endk;
  vector<vector<int>> ans(m, vector<int>(m-1));
  int tmp = 1;
  rep(i, m) REP(j, i, m-1) ans[i][j] = tmp++;
  tmp = 1;
  rep(j, m) REP(i, j+1, m) ans[i][j] = tmp++;
  cout << m << endk;
  rep(i, m) {
    cout << m-1 << ' ';
    rep(j, m-1) cout << ans[i][j] << ' ';
    cout << endk;
  }
  return 0;
}


Measured memory_bytes: 3960
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    char c = sc.next().charAt(0);
    if(c == 'A'){
      System.out.println("T");
    }else if(c == 'T'){
      System.out.println("A");
    }else if(c == 'C'){
      System.out.println("G");
    }else{
      System.out.println("C");
    }
  }
}

Measured memory_bytes: 22736
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <algorithm>
#include <numeric>

typedef long long ll;
const ll INF = 1e18;

// Greatest Common Divisor
ll gcd(ll a, ll b)
{
  while (b != 0) {
    a = a % b;
    std::swap(a, b);
  }
  return a;
}

int main(int argc, char* argv[])
{
  ll N;
  std::cin >> N;

  ll ans = 0;
  for (ll i = 1; i <= N; i+=2) {
    ll cnt = 0;
    for (ll j = 1; j <= N; j++) {
      if (i % j == 0) {
	cnt++;
      }
    }
    if (cnt == 8) {
      ans++;
    }
  }

  std::cout << ans << std::endl;

  return 0;
}


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

using namespace std;

#define PI 3.14159265358979323846264338327950L

int main(void) {
	string S, T;
	int minDiff = INT_MAX, diff;

	cin >> S >> T;

	for (int i = 0; i <= S.size()-T.size(); i++) {
		diff = 0;
		for (int j = 0; j < T.size(); j++) {

			//if (i + j > S.size()) {
			//	continue;
			//}


			if (S[i + j] != T[j]) {
				diff++;
			}
		}

		if (minDiff > diff) {
			minDiff = diff;
		}
	}

	cout << minDiff << endl;


	return 0;
}



Measured memory_bytes: 3596
from itertools import combinations
import math
n = int(input())
ans = 0
for r in range(1,4): 
    if r>n:
        break
    for x  in combinations([x+1 for x in range(n)],r):
        if len(x)==1:
            ans += x[0]
        elif len(x)==2:
            ans += math.gcd(x[0],x[1])*6
        else:
            tmp = math.gcd(x[0],x[1])
            ans += math.gcd(x[2],tmp)*6
print(ans)

Measured memory_bytes: 9112
#include <iostream>
#include <vector>
#include <string>


uint64_t s(uint64_t x)
{
    uint64_t sum = 0;
    while(x != 0) {
        sum += x % 10;
        x /= 10;
    }
    return sum;
}

bool check(uint64_t x, uint64_t y) 
{
    uint64_t sx = s(x);
    uint64_t sy = s(y);
    return x * sy <= y * sx;
}

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

    uint64_t x = 1;
    uint64_t step = 1;


    for (int i = 0; i < k; i++) {
        std::cout << x << std::endl;
        if (!check(x + step, x + step + step)) {
            step *= 10;
        }
        x += step;
    }
    return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<cmath>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<ctype.h>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<math.h>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<stdio.h>
#include<stdlib.h>
#include<streambuf>
#include<string.h>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#define x first
#define y second
#define m_p make_pair
using namespace std;
int fa[100010],deg[100010];
map<int,int> mp[100010];
int main(void){
	int n;
	scanf("%d",&n);
	for (int i=2;i<=n;i++){
		scanf("%d",&fa[i]);
		deg[fa[i]]++;
	}
	queue<int> q;
	for (int i=1;i<=n;i++){
		if (!deg[i]){
			q.push(i);
		}
	}
	while(!q.empty()){
		int id=q.front(),res=0;
		q.pop();
		for (map<int,int>::iterator it=mp[id].begin();it!=mp[id].end();it++){
			if (it->y>1){
				mp[id][it->x+1]+=it->y-1;
			}
			res=it->x;
		}
		if (fa[id]){
			mp[fa[id]][res+1]++;
			if (!(--deg[fa[id]])){
				q.push(fa[id]);
			}
		}
		else{
			printf("%d",res);
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 10368
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();

    int total = a * b / 2;
    System.out.println(total);
  }

}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
const int MAX = 510000;
const int MOD =  998244353;


     signed main(){
     
    int n;
    string s;
    cin>>n>>s;
    char x[3];x[0]='R';x[1]='G';x[2]='B';
    vector<int> v[3];
    int p[3]={};
    for(int i=0;i<n;i++)for(int j=0;j<3;j++)if(s[i]==x[j]){
         p[j]++;
         v[j].push_back(i);
    }
    int k=max(p[0],max(p[1],p[2]));
    int o=0,l=1,d=2,ans=p[0]*p[1]*p[2];
    //cerr<<ans<<endl;
    if(p[o]==k)swap(o,d);if(p[l]==k)swap(l,d);
    for(int i=0;i<v[o].size();i++)for(int j=0;j<v[l].size();j++){
         if((v[o][i]+v[l][j])%2==0){
              if(x[d]==s[(v[o][i]+v[l][j])/2])ans--;
         }
         if(2*v[o][i]-v[l][j]>=0&&2*v[o][i]-v[l][j]<n&&x[d]==s[2*v[o][i]-v[l][j]])ans--;
         if(2*v[l][j]-v[o][i]>=0&&2*v[l][j]-v[o][i]<n&&x[d]==s[2*v[l][j]-v[o][i]])ans--;
    }
    cout<<ans<<endl;


      }

        


Measured memory_bytes: 3692
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;
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(){
	ll k,a,b;cin>>k>>a>>b;
	ll ans = k + 1;
	if ( a < b){
		ll tmp = 1;
		if (k > a){
			tmp += a - 1;
			k -= a - 1;
			tmp += (k / 2) * (b - a);
			if (k % 2 == 1){
				tmp++;
			}
		}
		ans = max(ans,tmp);
	}
	cout << ans << endl;
	return 0;
}

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

#define rep(i, u) for (int i = 0; i < u; i++)
double pi = 3.14159265359;

int main() {
  int a, b;
  char op;
  while (true) {
    cin >> a >> op >> b;
    if (op == '?') break;
    if (op == '+') cout << a + b << endl;
    if (op == '-') cout << a - b << endl;
    if (op == '*') cout << a * b << endl;
    if (op == '/') cout << a / b << endl;
  }
  return 0;
}



Measured memory_bytes: 3088
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	a := scanInts(n)
	sort.Ints(a)
	if a[0] == 0 {
		fmt.Fprintln(wr, 0)
		return
	}

	ans := 1
	for i := 0; i < n; i++ {
		if a[i] > 1e18/ans {
			fmt.Fprintln(wr, -1)
			return
		}
		ans *= a[i]
	}
	fmt.Fprintln(wr, ans)
}


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

int main(void){
  int N, L;
  cin >> N >> L;
  
  
  vector<string> vec(N);
  
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  
  sort(vec.begin(), vec.end());
  
  string ans = "";
  
  for (int i = 0; i < N; i++) {
    ans += vec.at(i);
  }
  
  cout << ans << endl;
  
  
}

Measured memory_bytes: 256
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define reps(i,a,b) for(int i=a;i<b;++i)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int n;
    cin >> n;
    map<int, int> mp;
    rep(i, n) {
        int a;
        cin >> a;
        mp[a]++;
    }
    int ans = 0;
    for (auto it = mp.rbegin(); it != mp.rend(); ++it) {
        int x = it->first, k = it->second;
        ll p = 1;
        while (p <= x) p <<= 1;
        if (p-x == x) {
            ans += k / 2;
        } else if (mp[p-x] != 0) {
            ans += min(mp[p-x], k);
            mp[p-x] -= min(mp[p-x], k);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 67496
#include<cstdio>
#include<iostream>
#include<string>
#include<cctype>
#include<cstring>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;
using namespace std;

int main() {
    int n;
    cin >> n;
    int t = 0;
    int h = 0;
    rep (i, n) {
        string tcard;
        string hcard;
        cin >> tcard >> hcard;
        if ( tcard > hcard ) {
                t += 3;
        } else if ( tcard < hcard ) {
                h += 3;
        } else {
            t += 1;
            h += 1;
        }

    }
    cout << t << " " << h << endl;
    return 0;
}



Measured memory_bytes: 3124
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a =scan.nextInt();
		int b =scan.nextInt();
		int c =scan.nextInt();
		int d =0;
		for(int i =a ; i<=b ; i++) {
			if(c%i==0) {
				d=d+1;
				

			}
		}
		System.out.println(d);
	}
}


Measured memory_bytes: 26288
#include<bits/stdc++.h>
 
#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define int         ll int
#define float       double
#define	endl		'\n'
#define mii         map<int,int>
#define msi         map<string,int>
#define mis         map< int, string>
#define mpi         map<pair< int, int>, int>
#define pii         pair< int, int>
#define vi          vector< int>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define what_is(x)  cerr << #x << " is " << x << endl;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
using namespace std;

#define N  100005
signed main()
{
	fast;
    int n;
    cin>>n;
    float pi=3.14159265358979323846;
    cout<<fixed<<setprecision(20)<<2.0*pi*n<<endl;
}

Measured memory_bytes: 3804
#include <stdio.h>

int main () {
	long long int n;
	scanf("%lld", &n);
	
	long long int sum = 0;
	for (int i = 1; i <= n; i++) {
		if (i % 3 == 0 && i % 5 == 0) {
			continue;
		}
		else if (i % 3 == 0) {
			continue;
		}
		else if (i % 5 == 0) {
			continue;
		}	
		else {
			sum += i;
		}
	}
	
	printf("%lld", sum);
	
	return 0;
}

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

int main(){
    
    int H,W;
    while(1){
        cin >> H >> W;
        if((H == 0 )&&(W == 0)){
          break;
        }

        for(int i=0 ; i < H ; i++){
            for(int j=0 ; j < W ; j++){
              if(((i+j) % 2) == 0){                 
                   cout << '#';
                 }else{
                   cout << '.';                     
                 }
            }
            cout << endl;
        }
        cout << endl;
    }
    return(0);
}


Measured memory_bytes: 3088
def f(gx,gy):
    ans = 10**9
    no = 0
    for i in range(m):
        tmp = abs(gx-checkpoint[i][0]) + abs(gy-checkpoint[i][1])
        if tmp < ans:
            ans = tmp
            no = i
    return no+1

n,m = map(int,input().split())
gakusei = []
for i in range(n):
    x,y = map(int,input().split())
    gakusei.append([x,y])
checkpoint = []
for j in range(m):
    x,y = map(int,input().split())
    checkpoint.append([x,y])

#print(gakusei,checkpoint)
for i in range(n):
    print(f(gakusei[i][0],gakusei[i][1]))

    

Measured memory_bytes: 9220
h,w=map(int,input().split());input();a,MAP,w1,h1=list(map(int,input().split())),[[0 for i in range(w)] for j in range(h)],0,0
for i,j in enumerate(a):
  for _ in range(j):
    if w1<w:
      MAP[h1][w1]= i+1
      w1+=1
      if w1==w:
        w1=0
        h1+=1
for i in range(h):
  if i%2!=0: MAP[i]=MAP[i][::-1]
[print(*i,sep=' ') for i in MAP]

Measured memory_bytes: 9400
import sys

s = ""
for i in sys.stdin:
    n = int(i)
    if n == 0:
        break
    max = -100000
    sum = int(input())
    for i in range(n-1):
        m = int(input())
        if sum < 0 and sum < m:
            sum = m
        else:
            if m < 0 and max < sum:
                max = sum
            sum += m
    if sum > max:
        s += str(sum) + "\n"
    else:
        s += str(max) + "\n"

print(s,end="")

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

int main(){
    int x1,x2,x3,x4,x5,ans;
    cin>>x1>>x2>>x3>>x4>>x5;

    ans=x1+x2+x3+x4+x5;

    cout<<(15-ans)<<endl;

    return 0;
}

Measured memory_bytes: 3552
import sys

def input(): return sys.stdin.readline()[:-1]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def MATINT(h): return [list(map(int, input().split())) for _ in range(h)]
def MATSTR(h): return [input() for _ in range(h)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
inf = float('inf')
mod = 10 ** 9 + 7

def main():
    S = input()
    if S[0] == S[1] and S[2] == S[3] and S[0] != S[2]:
        Yes()
    elif S[0] == S[2] and S[1] == S[3] and S[0] != S[1]:
        Yes()
    elif S[0] == S[3] and S[1] == S[2] and S[0] != S[1]:
        Yes()
    else:
        No()
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
n,a,b=map(int,input().split())
s=input()
cnt=0
cntt=0
for i in range(n):
  if s[i]=="a":
    if cnt+1<=a+b:
      cnt+=1
      print("Yes")
    else:
      print("No")
  if s[i]=="b":
    if cnt+1<=a+b and cntt+1<=b:
      cnt+=1
      cntt+=1
      print("Yes")
    else:
      print("No")
  if s[i]=="c":
    print("No")

Measured memory_bytes: 9252