akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

int W, H;
char B[30][30];

int dfs(int y, int x) {
   int ret = 1;
   B[y][x] = '#';
   rep (i, 4) {
      int nx = x + dx[i], ny = y + dy[i];
      if (nx < 0 || nx >= W || ny < 0 || ny >= H || B[ny][nx] == '#') continue;
      ret += dfs(ny, nx);
   }
   return ret;
}

void solve() {
   rep (i, H) {
      cin >> B[i];
   }
   rep (i, H) {
      rep (j, W) {
         if (B[i][j] == '@') {
            cout << dfs(i, j) << endl;
            return;
         }
      }
   }
}

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

   return 0;
}


Measured memory_bytes: 3104
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int K = Integer.parseInt(sc.next());
        int[] a = new int[N];
        for (int i=0;i<N;i++) {
            a[i] = Integer.parseInt(sc.next());
        }

        int[] grundy = new int[K+1];
        for (int i=K;i>=0;i--) {
            boolean flag = false;
            for (int j=0;j<N;j++) {
                if (i+a[j]<K+1) {
                    if (grundy[i+a[j]]==0) flag=true;
                }
            }
            if (flag) grundy[i]=1;
            else grundy[i]=0;
        }
        if (grundy[0]==1) System.out.println("First");
        else System.out.println("Second");
    }
}

Measured memory_bytes: 21972
#include <cstdio>
#include <cstdint>
#include <cinttypes>
#include <vector>
#include <set>
#include <algorithm>

int main()
{
    int64_t a, p;
    scanf("%" PRId64 " %" PRId64, &a, &p);

    printf("%" PRId64 "\n", (a * 3 + p) / 2);
    return 0;
}


Measured memory_bytes: 760
from array import array;
while True:
    n = int(raw_input())
    if n == 0:
        break
    m = int(raw_input())

    s = raw_input()

    cache = array('i', (0 for x in xrange(m)))

    for i in xrange(len(s) - 2):
        if s[i:i+3] == 'IOI':
            cache[i + 2] = cache[i] + 1

    print sum(1 for x in cache if x >= n)

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

#define ll long long int
#define ld long double
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define INF 0x3f3f3f3f // 100'000'000'000'000
#define all(x) x.begin(),x.end()
#define show(x) cerr<<#x<<" : "<<x<<'\n';
#define yogeshk972() cerr<<"\nTime Taken : "<<(float)(clock()-time_p)/CLOCKS_PER_SEC<<"\n";
clock_t time_p=clock();

using namespace std;
const int N= 1e5+10, mod=1e9+7;

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);  

	int n,m;
	cin>>n>>m;


	ll res=0;
	int l=1,r=n+1;
	ll ls=0,rs=0;
	while(l<=m){
		ls+=l;
		++l;
		rs+=r;
		--r;
	}
	
	while(l<=n+2){
		res+=rs-ls+1;
		res%=mod;
		
		ls+=l;
		++l;
		rs+=r;
		--r;
	}
	cout<<res;
	
    return 0;
}



Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

// list up all factors
template <typename T>
set<T> factors(T a) {
    set<T> facs;
    for (T i = 1; i * i <= a; ++i) {
        if (a % i == 0) {
            facs.insert(i);
            facs.insert(a / i);
        }
    }
    return facs;
}

lint digits(lint n) {
    lint ret = 0;
    while (n) {
        ret++;
        n /= 10;
    }
    return ret;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    lint n;
    cin >> n;
    auto facs = factors(n);
    lint ret  = inf;
    for (auto &f : facs) {
        ret = min(ret, max(digits(f), digits(n / f)));
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 384
n=int(input())
arr=[list(map(int,input().split())) for x in range(n)]
l=[i for i in range(1,201)]
for i in range(101):
  for j in range(101):
    tmp1=set()
    tmp2=10**5
    for k in range(n):
      if arr[k][2]!=0:
        tmp1.add(arr[k][2]+abs(arr[k][0]-i)+abs(arr[k][1]-j))
      else:
        if abs(arr[k][0]-i)+abs(arr[k][1]-j)<tmp2:
          tmp2=abs(arr[k][0]-i)+abs(arr[k][1]-j)
    if tmp2==10**5:
      if len(list(tmp1))==1:
        print(i,j,list(tmp1)[0])
    else:
      if len(list(tmp1))==1 and len(list(tmp1&set(l[:tmp2])))==1:
        print(i,j,list(tmp1)[0])

Measured memory_bytes: 3064
n=int(input())

def bai(x):
    return int(x)*2.0

xy=[list(map(bai, input().split())) for _ in range(n)]

#nは50だから4重ループでも間に合う？
#2500*2500

if n==2:
    print((((xy[0][0]-xy[1][0])**2 +(xy[0][1]-xy[1][1])**2) **0.5)*0.5*0.5)
    exit()

ans=10**9

def gaishin(a,b,c,d,e,f):
    if (a-c)*(d-f)==(c-e)*(b-d):
        y=(max([b,d,f])-min([b,d,f]))/2.0+min([b,d,f])
        x=(max([a,c,e])-min([a,c,e]))/2.0+min([a,c,e])

        #print(a,b,c,d,e,f,"==>",x,y)

    else:
        y=1.0*((e-a)*(a**2+b**2-c**2-d**2)-(c-a)*(a**2+b**2-e**2-f**2))/(2.0*(e-a)*(b-d)-2.0*(c-a)*(b-f))
        if e-a!=0:
            x=(2.0*(b-f)*y-a**2-b**2+e**2+f**2)/(2.0*(e-a))
        elif c-a!=0:
            x=(2.0*(b-d)*y-a**2-b**2+c**2+d**2)/(2.0*(c-a))
        else:
            print(a,b,c,d,e,f)
            exit()

    return x,y

xy.sort()

for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(i+2,n):
            #print(xy[i],xy[j],xy[k])

            gx,gy=gaishin(xy[i][0],xy[i][1],xy[j][0],xy[j][1],xy[k][0],xy[k][1])
            d=((1.0*(gx-xy[i][0]))**2+(1.0*(gy-xy[i][1]))**2)
            flag=0
            #print(gx,gy)
            for (x,y) in xy:
                if (x,y) != xy[i] and (x,y) != xy[j] and (x,y) != xy[k]:
                    if ((1.0*(gx-x))**2+(1.0*(gy-y))**2) >d+1:
                        flag=1
                        #print(((1.0*(gx-x))**2+(1.0*(gy-y))**2)**0.5,"-",d,"=",((1.0*(gx-x))**2+(1.0*(gy-y))**2)**0.5-d) 
                        break
            if flag==0:
                ans=min(ans,d**0.5)
                #print(">>>>",xy[i],xy[j],xy[k],d**0.5/2,gx,gy)

print(ans/2)







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

using namespace std;

int main()
{
	int m,f,r;
	while(true)
	{
		cin >> m >> f >> r;
		if(m==-1 and f==-1 and r==-1)break;
		if(m==-1 or f==-1)cout << "F" << endl;
		else if(m+f>=80)cout << "A" << endl;
		else if(m+f>=65)cout << "B" << endl;
		else if(m+f>=50)cout << "C" << endl;
		else if(m+f<30) cout << "F" << endl;
		else
		{
			if(r>=50)cout << "C" << endl;
			else cout << "D" << endl;
		}
	}
}


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

int main() {
  int N, K;
  int count = 0;
  cin >> N >> K;
  vector<int> vec(N);
  for (int i = 0; i < N; i++)
  {
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  for (int j = 0; j < K; j++)
  {
    count += vec.at(j);
  }
  cout << count << endl;
}

Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC112A
{
    class Program
    {
        static void Main(string[] args)
        {;
            int n = int.Parse(Console.ReadLine());

            if (n == 1)
            {
                Console.WriteLine("Hello World");
                Console.ReadKey();
                Environment.Exit(0);
            }

            int A = int.Parse(Console.ReadLine());
            int B = int.Parse(Console.ReadLine());

            if (n == 2)
                Console.WriteLine(A + B);

            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  string s;
  cin >> s;
  int start = 0, end = 0;

  int n = s.size();
  rep(i, 0, n) {
    if (s[i] == 'A') {
      start = i;
      break;
    }
  }

  repr(i, 0, n) {
    if (s[i] == 'Z') {
      end = i;
      break;
    }
  }

  cout << end - start + 1<< endl;
}


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

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

#define MAX 2000000

int main(){
    int N, M, X;
    cin >> N >> M >> X;
    vector<int> C(N);
    vector<vector<int>> A(N, vector<int>(M));
    
    for (int i = 0; i < N; i++) {
        cin >> C.at(i);
        for (int j = 0; j < M; j++) {
            cin >> A.at(i).at(j);
        }
    }

    vector<int> a;
    ll ans = MAX;

    for (int bit = 0; bit < (1 << N); ++bit) {
        ll tmp = 0;
        a = vector<int>(M, 0);
        for (int i = 0; i < N; i++) {
            if (bit & (1 << i)) {
                tmp += C.at(i);
                for (int j = 0; j < M; j++) {
                    a.at(j) += A.at(i).at(j);
                }
            }
        }
        bool flag = true;
        for (int i = 0; i < M; i++) {
            if (a.at(i) < X) flag = false;
        }
        if (flag) ans = min(ans, tmp);
    }
    if (ans == MAX) cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}


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

int main () {
  double A, B, H, M;
  cin >> A >> B >> H >> M;
  double PI=3.14159265358979323846;
  double x1, y1, x2, y2;
  x1 = A*sin(H*PI/6+M*PI/360);
  y1 = A*cos(H*PI/6+M*PI/360);
  x2 = B*sin(M*PI/30);
  y2 = B*cos(M*PI/30);
  double x, y;
  x = x1-x2;
  y = y1-y2;
  double ans2 = x*x + y*y;
  double ans = sqrt(ans2);
  cout << fixed << setprecision(12);
  cout << ans << endl;
}

Measured memory_bytes: 4028
# 2019-11-13 08:30:54(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 

def main():
    n, m = [int(x) for x in sys.stdin.readline().split()]

    l, r = [], []
    for _ in range(m):
        li, ri = [int(x) for x in sys.stdin.readline().split()]
        l.append(li)
        r.append(ri)
    
    print(min(r) - max(l) + 1 if min(r) >= max(l) else 0)



if __name__ == "__main__":
    main()


Measured memory_bytes: 11012
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(){
    int n; cin>>n;
    int ans=0;
    int enda=0,startb=0,both=0;
    vector<string> s(n);
    rep(i,n){
        string t; cin>>t;
        s.at(i)=t;
        rep(j,t.size()-1){
            if(t.at(j)=='A' && t.at(j+1)=='B') ans++;
        }
        if(t.at(0)=='B' && t.at(t.size()-1)=='A'){
            both++;
        }else if(t.at(0)=='B'){
            startb++;
        }else if(t.at(t.size()-1)=='A'){
            enda++;
        }
    }
    if(both==0) ans+=min(enda,startb);
    else{
        ans+=(both-1);
        if(enda>0){ans++; enda--;}
        if(startb>0){ans++; startb--;}
        ans+=min(enda,startb);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 768
import kotlin.math.abs

fun main() {
    nextInt()
    nextIntList().let {
        println(abs((it.max() ?: 0) - (it.min() ?: 0)))
    }
}
// # Utils
// ## Input
fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = next().split(" ").map(String::toInt)
fun nextLongList() = next().split(" ").map(String::toLong)
fun nextDoubleList() = next().split(" ").map(String::toDouble)
// ## Array
inline fun <reified T> sizedArray(size: Int, default: T) = Array(size) { default }
inline fun <reified T> sized2DArray(row: Int, column: Int, default: T) = Array(row) { Array(column) { default } }
// ## mod^-1
//    [NOTE] CANNOT use this for 0, mod, 2mod, 3mod ...(return wrong value)
fun modinv(num: Long, mod: Long): Long {
    var a = num
    var b = mod
    var u = 1L
    var v = 0L
    while (b > 0) {
        val t = a.div(b)
        a -= t * b
        a = b.also { b = a } // swap a and b
        u -= t * v
        u = v.also { v = u } // swap u and v
    }
    u %= mod
    if (u < 0) u += mod
    return u
}

fun gcd(x: Int, y: Int): Int {
    fun innerGcd(x: Int, y: Int): Int {
        return if (x % y == 0) y else innerGcd(y, x % y)
    }
    return if (x >= y) innerGcd(x, y) else innerGcd(y, x)
}

fun gcd(x: Long, y: Long): Long {
    fun innerGcd(x: Long, y: Long): Long {
        return if (x % y == 0L) y else innerGcd(y, x % y)
    }
    return if (x >= y) innerGcd(x, y) else innerGcd(y, x)
}

// classes
class UnionFindTree(val size: Int) {
    private val r = sizedArray(size, -1)
    fun root(x: Int): Int {
        if (r[x] < 0) return x
        return root(r[x])
    }

    fun unite(x: Int, y: Int) {
        var rx = root(x)
        var ry = root(y)
        if (rx == ry) return
        if (r[rx] > r[ry]) {
            rx = ry.also { ry = rx }
        }
        r[rx] += r[ry]
        r[ry] = rx
    }

    fun size(x: Int) = -r[root(x)]

    override fun toString(): String {
        return r.joinToString(separator = ", ")
    }
}

Measured memory_bytes: 37960
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


# a^n
def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a


inf = 10 ** 18
mod = 10 ** 9 + 7

n,m,k = lr()
a = lr()
b = lr()
a1 = [0]
b1 = [0]
for num in a:
    a1.append(a1[-1]+num)
for num in b:
    b1.append(b1[-1]+num)
def sumAreaA(l,r):
    return a1[r]-a1[l]
def sumAreaB(l,r):
    return b1[r]-b1[l]

ans = 0
dame = bisect.bisect_left(a1,k)
if dame < n+1:
    if a1[dame] == k:
        dame+=1
for i in range(dame):
    pre = i
    pretime = sumAreaA(0,i)
    time = k-pretime
    ind = bisect.bisect_left(b1,time)
    if ind == 0:
        ans = max(ans,pre)
    elif ind < m+1:
        if b1[ind] != time:
            ind-=1
        ans = max(ans,pre+ind)
    else:
        ans = max(ans, pre+m)
print(ans)

Measured memory_bytes: 137236
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (progn (ql:quickload '(:cl-debug-print :fiveam))
                 (shadow :run)
                 (use-package :fiveam)))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)

;; BEGIN_INSERTED_CONTENTS
(defmacro define-int-types (&rest bits)
  `(progn
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 2 4 7 8 15 16 31 32 62 63 64)

(defmacro println (obj &optional (stream '*standard-output*))
  `(let ((*read-default-float-format* 'double-float))
     (prog1 (princ ,obj ,stream) (terpri ,stream))))

(defconstant +mod+ 1000000007)

;; Hauptteil

(defun calc0 (a)
  (let* ((len (integer-length a))
         (res (make-array len :element-type 'bit :initial-element 0)))
    (dotimes (k len)
      (if (zerop k)
          (let ((rem (mod a 4)))
            (if (or (= rem 0) (= rem 3))
                (setf (aref res 0) 0)
                (setf (aref res 0) 1)))
          (let ((rem (mod a (expt 2 (+ k 1)))))
            (cond ((< rem (expt 2 k))
                   (setf (aref res k) 0))
                  ((evenp rem)
                   (setf (aref res k) 1))
                  (t
                   (setf (aref res k) 0))))))
    (loop for b across res
          for base = 1 then (ash base 1)
          sum (* b base))))

(defun main ()
  (let* ((a (read))
         (b (read)))
    (println
     (if (zerop a)
         (calc0 b)
         (logxor (calc0 b) (calc0 (- a 1)))))))

#-swank(main)


Measured memory_bytes: 22500
#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);

int main() {
    int A, B, H, M;
    cin >> A >> B >> H >> M;
    double ar = PI * (60 * H + M) / 360.0;
    double br = PI * M / 30.0;
    double x = A * cos(ar) -  B * cos(br);
    double y = A * sin(ar) -  B * sin(br);
    printf("%.15lf\n", sqrt(x*x + y*y));
    return 0;
}


Measured memory_bytes: 4092
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

signed main(){
	string s,t="KUPC";
	int d[4]={};
	cin>>s;
	int ans=1000;
	rep(i,0,s.size()){
		rep(j,0,4){
			if(s[i]==t[j]) d[j]++;
		}
	}
	rep(i,0,4) ans=min(ans,d[i]);
	cout<<ans<<endl;
}

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

 int a[3][10][4] = {0};
 int i, j, k;
 int n, p;
 int b, f, r, v; 
scanf("%d", &n);
 for(i=0; i<n; i++){
 scanf("%d%d%d%d", &b, &f, &r, &v);

 a[f-1][r-1][b-1] += v;
 }

 for(k=0; k<4; k++){
 for(i=0; i<3; i++){
 for(j=0; j<10; j++){
 if(a[i][j][k] == 0){
 printf(" 0");
 }else{
 printf(" %d", a[i][j][k]);
 }
 }
 printf("\n");
 }
 if(k != 3){
 printf("####################\n");
 }
 }

 return 0;
 }
 




Measured memory_bytes: 2104
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define hi cerr<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1
#define sysp system("pause")
#define PI acos(-1)
#define pf push_front
#define ins insert

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
unsigned XorShift(void){static unsigned x = 123456789;static unsigned y = 362436069;static unsigned z = 521288629;static unsigned w = 88675123;unsigned t;t = x ^ (x << 11);x = y; y = z; z = w;return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

//}

int a,b;

main(){
	cin>>a>>b;
	dump((3*a+b)/2);
}

Measured memory_bytes: 256
#include <iostream>
int n;

int search(int A[], int key){
	int left = 0;
	int right = n;
	int mid = (left+right)/2;
	while(left < right){
		if(A[mid] > key){
			right = mid;
			mid = (left+right)/2;
		}else if(A[mid] < key){
			left = mid+1;
			mid = (left+right)/2;
		}else{
			return 1;
		}
	}
	return A[mid] == key;
}

int main(){
	std::cin >> n;
	int a[n];
	for(int i = 0; i < n; i++){
		std::cin >> a[i];
	}
	int q;
	std::cin >> q;
	int b[q];
	for(int i = 0; i < q; i++){
		std::cin >> b[i];
	}
	int ans = 0;
	for(int i = 0; i < q; i++){
		if(search(a, b[i])) ans++;
	}

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

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

int main(){
    int h,w;
    cin >> h >> w;
    vector<vector<char>> a(h+1, vector<char>(w+1));
    for(int i=1; i<=h; i++){
        for(int j=1; j<=w; j++){
            cin >> a.at(i).at(j);
        }
    }

    for(int i=0; i<=h+1; i++){
        for(int j=0; j<=w+1; j++){
            if(i==0 || i==h+1 || j==0 || j==w+1) cout << '#';
            else cout << a.at(i).at(j);
        }
        cout << endl;
    }
}

Measured memory_bytes: 3612
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();

        long a = sc.nextLong();
        System.out.println(a + a*a + a*a*a);
    }
    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}

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

int main(){
    int n;
    int ans = 0;
    cin >> n;
    int array[n];
    for(int i=0; i<n; i++) cin >> array[i];

    while(true){
        bool breaker = false;
        for(int i=0; i<n; i++){
            if(array[i]%2 == 1) breaker = true;
        }
        if(breaker == true) break;

        
        for(int i=0;  i<n; i++) array[i] /= 2;
        ans++;

    }
    cout << ans << endl;
}

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

using namespace std;

const int nmax=100;
int n;
int dp[5][nmax+5];

int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        int key;
        cin>>key;
        dp[1][i]=dp[1][i-1]+key;
    }
    for(int i=1;i<=n;i++)
    {
        int key;
        cin>>key;
        dp[2][i]=max(dp[2][i-1],dp[1][i])+key;
    }
    cout<<dp[2][n];
    return 0;
}
/**
**/


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
const int MaxN = 1e5;
const long long M = 1e18;

int main()
{
	long long a,b,c,k;
	while(~scanf("%lld %lld %lld %lld",&a,&b,&c,&k))
	{
		if(k %2 == 0) printf("%d\n",a - b);
		else printf("%d\n",b - a);
	}
	return 0;
}

Measured memory_bytes: 128
from fractions import gcd

# 最小公倍数
def lcm(x, y):
    return (x * y) // gcd(x, y)

a, b, c, d = map(int, input().split())
# a以上なのでaを含む
a = a-1

# b以下の条件を満たす数
nb = b - b//c - b//d + b//lcm(c, d)
na = a - a//c - a//d + a//lcm(c, d)

print(nb - na)

Measured memory_bytes: 5076
import math
def main():
    a = list(map(int, input().split()))
    a.extend(list(map(int, input().split())))
    a.extend(list(map(int, input().split())))
    n = int(input())
    for _ in range(n):
        x = int(input())
        a = [True if i == x else i for i in a]
    a = [False if i != True else True for i in a]
    if all(a[0:3]) or all(a[3:6]) or all(a[6:]):
        print("Yes")
    elif all(a[0::3]) or all(a[1::3]) or all(a[2::3]):
        print("Yes")
    elif all(a[0::4]) or all(a[2:7:2]):
        print("Yes")
    else:
        print("No")
    

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
while True:
    a,op,b = input().split()
    if op == "?":
        break
    if op == "+":
        print(int(a)+int(b))
    if op == "-":
        print(int(a)-int(b))
    if op == "*":
        print(int(a)*int(b))
    if op == "/":
        print(int(a)//int(b))



Measured memory_bytes: 5596
data class Testify(val x: Int, val y: Boolean)
fun main(args: Array<String>) {
    val N = nextInt()
    val A = Array(N) { mutableListOf<Testify>() }
    repeat(N) {
        val a = it
        val n = nextInt()
        repeat(n) {
            val (x, y) = listOfInt()
            A[a].add(Testify(x - 1, y == 1))
        }
    }
    var ans = 0
    var bit = 0
    while (bit < (1 shl N)) {
        var v = BooleanArray(N)
        for (b in 0 until N) {
            v[b] = (bit and (1 shl b)) != 0
        }
        var ok = true
        for (n in 0 until N) {
            if (!v[n]) continue //★
            for (t in A[n]) {
                if (v[t.x] xor t.y) ok = false
            }
        }
        if (ok) ans = Math.max(ans, v.count { it })
        bit += 1
    }
    println(ans)
}
fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())
fun listOfString() = next().split(" ")
fun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }
fun printErr(value: Any) = System.err.println(value)


Measured memory_bytes: 42804
#include<stdio.h>
 
 
int main(void)
{
    int num, top;
    int train[1024];
    int i;
 
    top = 0;
 
    while (scanf("%d", &num) != EOF){
        if (num == 0){
            printf("%d\n", train[top - 1]);
            train[top - 1] = 0;
            top--;
        }
        else {
            train[top] = num;
            top++;
        }
    }
 
    return 0;
}

Measured memory_bytes: 1032
# -*- coding: utf-8 -*-
# input
a, b = map(int, input().split())
c = []
for i in range(b):
    c.append(list(map(int, input().split())))
p = list(map(int, input().split()))
out = 0
for j in range(1 << a):
    t = format(j, 'b').zfill(a)
    o = 0
    for k in range(b):
        s = 0
        for l in range(c[k][0]):
            s += int(t[(c[k][l+1]-1)])
        if s % 2 == p[k]:
            o += 1
    if b == o:
        out += 1
print(out)


Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <sstream>
#include <map>
#include<vector>

using namespace std;
typedef long long ll;

ll ans,mx,sum,mn=1e8,cnt;

ll idx0,idx1,idx2;
ll a0[5],a1[1],a2[2];

int main(){
	string s;
	cin>>s;
	ll a=s[0]-'0';
	ll b=s[1]-'0';
	ll c=s[2]-'0';
	ll d=s[3]-'0';
	if(a+b+c+d==7){
		cout<<a<<'+'<<b<<'+'<<c<<'+'<<d<<"=7";
	}
	else if(a-b-c-d==7){
		cout<<a<<'-'<<b<<'-'<<c<<'-'<<d<<"=7";
	}
	else if(a-b+c+d==7){
		cout<<a<<'-'<<b<<'+'<<c<<'+'<<d<<"=7";
	}
	else if(a+b-c+d==7){
		cout<<a<<'+'<<b<<'-'<<c<<'+'<<d<<"=7";
	}
	else if(a+b+c-d==7){
		cout<<a<<'+'<<b<<'+'<<c<<'-'<<d<<"=7";
	}
	else if(a-b-c+d==7){
		cout<<a<<'-'<<b<<'-'<<c<<'+'<<d<<"=7";
	}
	else if(a+b-c-d==7){
		cout<<a<<'+'<<b<<'-'<<c<<'-'<<d<<"=7";
	}
	else if(a-b+c-d==7){
		cout<<a<<'-'<<b<<'+'<<c<<'-'<<d<<"=7";
	}
}



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

int main(){
  int A,B;
  cin >> A >> B;
  if (A >= 13) cout << B << endl;
  else if (A >= 6 && A <= 12) cout << B / 2 << endl;
  else if (A <= 5) cout << 0 << endl;
}

Measured memory_bytes: 256
n = int(input())

evidences = [[] for _ in range(n)]
for i in range(n):
  a = int(input())
  for j in range(a):
    x,y = map(int, input().split())
    evidences[i].append((x-1, y))
    
result = 0
for i in range(1, 2**n):
  consistent = True
  for j in range(n):
    if (i >> j) & 1 == 0:
      continue
    for x,y in evidences[j]:
      if (i >> x) & 1 != y:
        consistent = False
        break
    if not consistent:
      break
  if consistent:
    result = max(result, bin(i)[2:].count('1'))
print(result)

Measured memory_bytes: 3064
n, m = map(int, input().split())
s = []
c = []
for i in range(m):
    S, C = map(int, input().split())
    s.append(S-1)
    c.append(str(C))

ans = -1

if n == 3:
    st, ed = 100, 1000
elif n == 2:
    st, ed = 10, 100
else:
    st, ed = 0, 10

for i in range(st, ed):
    t = list(str(i))
    for j in range(m):
        if t[s[j]] != c[j]:
            break
    else:
        ans = i
        break
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <string>
#include <map>

using namespace std;

int main(){
    long n;
    cin >> n;
    string s;
    map<string,long> map;
    long count = 0;
    
    for(long i = 0; i< n; i++){
        cin >> s;
        sort(s.begin(),s.end());
        map[s] ++;
        count += map[s] - 1;
    }

    cout << count << endl;

    return 0;
}

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

using namespace std;

long long a , b;

int main()
{
	cin >> a >> b;
	if((a == 0 || b == 0) || (a < 0 && b > 0))
	{
		cout << "Zero";
		return 0;
	}
	if(a > 0)
	{
		cout << "Positive";
		return 0;
	}
	if(b < 0)
	{
		if((abs(abs(a) - abs(b)) + 1) % 2)
		{
			cout << "Negative";
			return 0;
		}
		else
		{
			cout << "Positive";
			return 0;
		}
	}
	if(abs(a) % 2)
	{
		cout << "Negative";
		return 0;
	}
	else
	{
		cout << "Positive";
		return 0;
	}
}

Measured memory_bytes: 764
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const INF = 1 << 60

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N, W := sc.nextInt(), sc.nextInt()
	V := int(1e+5)
	w := make([]int, N)
	v := make([]int, N)
	for i := 0; i < N; i++ {
		w[i] = sc.nextInt()
		v[i] = sc.nextInt()
	}
	dp := make([][]int, N+1)
	for i := 0; i <= N; i++ {
		dp[i] = make([]int, V+1)
		for j := 0; j <= V; j++ {
			dp[i][j] = INF
		}
	}
	dp[0][0] = 0
	for i := 0; i < N; i++ {
		for j := 0; j <= V; j++ {
			if j >= v[i] {
				dp[i+1][j] = dp[i][j-v[i]] + w[i]
			}
			dp[i+1][j] = min(dp[i+1][j], dp[i][j])
		}
	}

	for i := V; i >= 0; i-- {
		if dp[N][i] <= W {
			fmt.Fprintln(wtr, i)
			break
		}
	}
	wtr.Flush()
}


Measured memory_bytes: 82432
var lines: string[] = [];
var reader: any = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on("line", function(line: string) {
  lines.push(line);
});
reader.on("close", function() {
  var valueN: number = Number(lines[0].split(" ")[0]);

  var listX: number[] = lines[1]
    .split(" ")
    .map(function(value: string): number {
      return Number(value);
    });
  var sortedList: number[] = new Array(valueN);
  listX.forEach(x => {
    sortedList.push(x);
  });
  sortedList.sort((n1, n2) => n1 - n2);

  var smallMedian: number = sortedList[valueN / 2 - 1];
  var largeMedian: number = sortedList[valueN / 2];

  for (var i: number = 0; i < valueN; i++) {
    if (listX[i] <= smallMedian) {
      console.log(largeMedian);
    } else {
      console.log(smallMedian);
    }
  }
});


Measured memory_bytes: 65968
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")

#pragma GCC target("avx,avx2")
using namespace std;



const int mod = 1000003;
struct Mod {
public:
	int num;
	Mod() : Mod(0) { ; }
	Mod(long long int n) : num((n % mod + mod) % mod) {
		static_assert(mod<INT_MAX / 2, "mod is too big, please make num 'long long int' from 'int'");
	}
	Mod(int n) : Mod(static_cast<long long int>(n)) { ; }
	operator int() { return num; }
};

Mod operator+(const Mod a, const Mod b) { return Mod((a.num + b.num) % mod); }
Mod operator+(const long long int a, const Mod b) { return Mod(a) + b; }
Mod operator+(const Mod a, const long long int  b) { return b + a; }
Mod operator++(Mod &a) { return a + Mod(1); }
Mod operator-(const Mod a, const Mod b) { return Mod((mod + a.num - b.num) % mod); }
Mod operator-(const long long int a, const Mod b) { return Mod(a) - b; }
Mod operator--(Mod &a) { return a - Mod(1); }
Mod operator*(const Mod a, const Mod b) { return Mod(((long long)a.num * b.num) % mod); }
Mod operator*(const long long int a, const Mod b) { return Mod(a)*b; }
Mod operator*(const Mod a, const long long int b) { return Mod(b)*a; }
Mod operator*(const Mod a, const int b) { return Mod(b)*a; }
Mod operator+=(Mod &a, const Mod b) { return a = a + b; }
Mod operator+=(long long int &a, const Mod b) { return a = a + b; }
Mod operator-=(Mod &a, const Mod b) { return a = a - b; }
Mod operator-=(long long int &a, const Mod b) { return a = a - b; }
Mod operator*=(Mod &a, const Mod b) { return a = a * b; }
Mod operator*=(long long int &a, const Mod b) { return a = a * b; }
Mod operator*=(Mod& a, const long long int &b) { return a = a * b; }
Mod operator^(const Mod a, const int n) {
	if (n == 0) return Mod(1);
	Mod res = (a * a) ^ (n / 2);
	if (n % 2) res = res * a;
	return res;
}
Mod mod_pow(const Mod a, const int n) {
	if (n == 0) return Mod(1);
	Mod res = mod_pow((a * a), (n / 2));
	if (n % 2) res = res * a;
	return res;
}
Mod inv(const Mod a) { return a ^ (mod - 2); }
Mod operator/(const Mod a, const Mod b) {
	assert(b.num != 0);
	return a * inv(b);
}
Mod operator/(const long long int a, const Mod b) {
	return Mod(a) / b;
}
Mod operator/=(Mod &a, const Mod b) {
	return a = a / b;
}

#define MAX_MOD_N mod

Mod fact[MAX_MOD_N], factinv[MAX_MOD_N];
void init(const int amax = MAX_MOD_N) {
	fact[0] = Mod(1); factinv[0] = 1;
	for (int i = 0; i < amax - 1; ++i) {
		fact[i + 1] = fact[i] * Mod(i + 1);
		factinv[i + 1] = factinv[i] / Mod(i + 1);
	}
}
Mod comb(const int a, const int b) {
	return fact[a] * factinv[b] * factinv[a - b];
}
    
void solve(){
  init();
  int Q;cin>>Q;
  while(Q--){
    Mod answer;
    int x,d,n;cin>>x>>d>>n;
    if(d==0){
      if(x==0)answer=0;
      else{
        answer=mod_pow(x,n);
      }
    }else{
      int to_max_num=Mod(mod-x)/Mod(d);
      if(to_max_num<=n-1){
        answer=0;
      }else{
        Mod x_div_d=Mod(x)/Mod(d);
        answer=fact[x_div_d.num+n-1]/fact[x_div_d.num-1];
        answer*=mod_pow(d,n);
        //x*(x+d)*(x+2d)*....*(x+(n-1)d)

        //d^n * (x/)
      }
    }
    cout<<answer.num<<endl;
  }
}

int main(void){
  solve();

  return 0;
}

Measured memory_bytes: 8704
#include<stdio.h>
#define MAX 100
#define INF 10000000
#define WHITE 0
#define GRAY 1
#define BLACK 2

void dijkstra();

int n,M[MAX][MAX];
int i,j;

int main()
{
  int k,c,u,v;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      M[i][j] = INF;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d%d",&v,&c);
      M[u][v] = c;
    }
  }

  dijkstra();

  return 0;
}

void dijkstra()
{
  int minv,u,v;
  int d[MAX],color[MAX];

  for(i=0;i<n;i++){
    d[i] = INF;
    color[i] = WHITE;
  }
  d[0]=0;
  color[0]=GRAY;
   
  while(1){
    minv = INF;
    u = -1;
    for(i=0;i<n;i++){
      if(minv > d[i] && color[i] != BLACK){
	u = i;
	minv = d[i];
      }
    }
    if(u == -1) break;
    color[u] = BLACK;
    for(v=0;v<n;v++){
      if(color[v]!=BLACK && M[u][v]!=INF){
	if(d[v] > d[u]+M[u][v]){
	  d[v] = d[u]+M[u][v];
	  color[v] = GRAY;
	}
      }
    }
  }
  for(i=0;i<n;i++){
    if(d[i] == INF) printf("%d %d\n",i,-1);
    else printf("%d %d\n",i,d[i]);
  }
}



Measured memory_bytes: 2040
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

#include <bits/stdc++.h>
using namespace std;

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

  string s,t;
  cin>>s>>t;
  
  int cnt=0;
  rep(i,s.size()){
    if(s[i]!=t[i]) cnt++;
  }
  
  cout<<cnt<<endl;

  return 0;
}

Measured memory_bytes: 3820
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <algorithm>
#include <functional>

using namespace std;

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

	int A, B;
	cin >> A >> B;

	if ((A + B) % 3 == 0 || A % 3 == 0 || B % 3 == 0)
	{
		cout << "Possible";
	}
	else
	{
		cout << "Impossible";
	}

	return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

int check(int a, int k){
    int res = 0;
    while(a<k){
        a *= 2;
        res++;
    }
    return res;
}
int main(int argc, const char * argv[]) {
    int n ,k;
    cin >> n >> k;
    double ans = 0;
    for(int i = 1; i <= n; i++){
        double p = check(i, k);
        //cout<<p<< endl;
        ans += (double)(pow(1.0/2.0, p)/(double)n);
    }
    printf("%0.10f\n",ans);
    return 0;
}


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

int main(){
    vector<int> tanka, tankb;
    for(int i = 1; i*i*i <= 151200; i++)    tanka.push_back(i*i*i);
    for(int j = 1; j*(j+1)*(j+2)/6 <= 151200; j++)  tankb.push_back(j*(j+1)*(j+2)/6);

    int n;
    while(cin >> n, n){
        int ans = 0;
        for(int i = 0; i < tanka.size(); i++){
            if(tanka[i] > n)    break;
            int add = 0;
            auto it = upper_bound(tankb.begin(), tankb.end(), n-tanka[i]);
            if(it != tankb.begin()){
                it--;
                add = *it;
            }
            ans = max(ans, add+tanka[i]);
        }
        for(int i = 0; i < tankb.size(); i++){
            if(tankb[i] > n)    break;
            int add = 0;
            auto it = upper_bound(tanka.begin(), tanka.end(), n-tankb[i]);
            if(it != tanka.begin()){
                it--;
                add = *it;
            }
            ans = max(ans, add+tankb[i]);
        }
        cout << ans << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3148
#include <iostream>

using namespace std;

int main() {
    int rooms[4][3][10];

    for (int i = 0; i < 4; i++)
        for (int j = 0; j < 3; j++)
            for (int k = 0; k < 10; k++)
                rooms[i][j][k] = 0;

    int n;
    cin >> n;
    for (int count = 0; count < n; count++) {
        int b, f, r, v;
        cin >> b >> f >> r >> v;
        rooms[b - 1][f - 1][r - 1] += v;
    }

    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 10; k++)
                cout << " " << rooms[i][j][k];
            cout << endl;
        }
        if (i < 3)
            cout << "####################" << endl;
    }

    return 0;
}



Measured memory_bytes: 3112
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
main(){
    string S;
    int index = 200010,mx = 0;
    cin >> S;
    for(int i = 0;i < S.length();i++){
        if(S[i]=='A')index = min(index,i);
        if(S[i]=='Z')mx = max(mx,i-index+1);
    }
    cout << mx << endl;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()

using namespace std;
using ll = long long;

const double PI = 3.14159265358979;

void solve()
{
  ll n;
  cin >> n;
  vector<ll> a(n);
  for(int i = 0; i < n; ++i)
  {
    cin >> a[i];
  }

  sort(RALL(a));
  ll ans = 0;
  for(int i = 0; i < n - 1; ++i)
  {
    if (a[i] == a[i + 1])
    {
      if (ans == 0) ans = a[i];
      else 
      {
        ans *= a[i];
        cout << ans;
        return;
      }
      i += 1;
    }
  }
  cout << 0;
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3988
#include <stdio.h>
#include <math.h>
struct Point{
	double x,y;
};
void koch(int n,struct Point a,struct Point b);

int main(void){
	struct Point a,b;
	int n;
	scanf("%d",&n);
	
	a.x=0;
	a.y=0;
	b.x=100;
	b.y=0;
	printf("%.8f %.8f\n",a.x,a.y);
	koch(n,a,b);
	printf("%.8f %.8f\n",b.x,b.y);
	return 0;
}

void koch(int n,struct Point a,struct Point b){
	if(n==0){
		return;
	}
	
	struct Point s,t,u;
	double th=M_PI*60/180;
	
	s.x=(2.0*a.x+1.0*b.x)/3;
	s.y=(2.0*a.y+1.0*b.y)/3;
	t.x=(1.0*a.x+2.0*b.x)/3;
	t.y=(1.0*a.y+2.0*b.y)/3;
	u.x=(t.x-s.x)*cos(th)-(t.y-s.y)*sin(th)+s.x;
	u.y=(t.x-s.x)*sin(th)+(t.y-s.y)*cos(th)+s.y;
	
	koch(n-1,a,s);
	printf("%.8f %.8f\n",s.x,s.y);
	koch(n-1,s,u);
	printf("%.8f %.8f\n",u.x,u.y);
	koch(n-1,u,t);
	printf("%.8f %.8f\n",t.x,t.y);
	koch(n-1,t,b);
}


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

using namespace std;

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

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

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main()
{
	int n;
	string s;
	cin>>n>>s;
	int pos=0;
	int ans=0;
	while(pos<n){
		if(pos!=n-1 && s[pos]!=s[pos+1]) ans++,pos+=2;
		else pos++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3300
import math

def pow(p,n):
    bin_n=bin(n)[2:][::-1]
    tmp=p;pn=1
    for i in range(len(bin_n)):
        if bin_n[i]=="1": pn=(pn*tmp)%mod
        tmp=tmp*tmp%mod
    return pn


mod=10**9+7
n,k=map(int,input().split())

ans=[0]*(k+1)
for i in range(k,0,-1):
    div=set()
    for x in range(1,int(i**0.5)+1):
        if i%x==0: div.add(x);div.add(i//x)
    ans[i]=pow(k//i,n)-sum([ans[j*i] for j in range(k//i,1,-1)])
    ans[i]%=mod

a=0
for i in range(k+1):
    a+=i*ans[i]
    a%=mod
print(a)

Measured memory_bytes: 81640
N = int(input())  # nは入力回数
num_list =  list(map(int, input().split()))
    
count = 0
actual_count = 0
w = 0
new_list = []
while (w == 0):
    count = 0
    for i in range(N):
        a = num_list[i]
        
        b = int(a) % 2 
        if (b == 0):
            count = count + 1
    if (count == N):
            new_list =[]
            for n in range(N):
                a = num_list[n]
                b = int(a) / 2
                new_list.append(b)
            num_list = []
            for l in range(N):
                a = new_list[l]
                num_list.append(a)
                
            
            actual_count += 1
    else:
        w = 1
        
        
print(actual_count)

Measured memory_bytes: 9212
import java.util.*;

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

       String str = sc.nextLine();
       char check;

       for(int i = 0;i < str.length();i++){
            check = str.charAt(i);
            if(check >= 'a' && check <= 'z')    System.out.print((char)(check - 32));
            else if(check >= 'A' && check <= 'Z')    System.out.print((char)(check + 32));
            else    System.out.print(check);
       }
       System.out.println();
    }
}


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

int main(){

    int r, c;
    cin >> r >> c;

    int A[r][c];
    for(int i=0; i<r; i++){
        for(int j=0; j<c; j++){
            A[i][j] = 0;
        }
    }

    for(int i=0; i<r; i++){
        for(int j=0; j<c; j++){
            int x;
            cin >> x;
            A[i][j] = x;
        }
    }

    int B[r+1][c+1];
    for(int i=0; i<r+1; i++){
        for(int j=0; j<c+1; j++){
            B[i][j] = 0;
        }
    }

    for(int i=0; i<r; i++){
        for(int j=0; j<c; j++) B[i][j] = A[i][j];
        }
    
    for(int j=0; j<c; j++){
    for(int i=0; i<r; i++){
        B[r][j] += A[i][j];
            }
    }
    for(int j=0; j<r; j++){
    for(int i=0; i<c; i++){
        B[j][c] += A[j][i];
            }
    }

    int sum = 0;
    for(int i=0; i<r; i++){
        for(int j=0; j<c; j++){
            sum += A[i][j];
        }
    }
    B[r][c] = sum;

    for(int i=0; i<r+1; i++){
        for(int j=0; j<c+1; j++){
            if(j==c) cout << B[i][j];
            else cout << B[i][j] << " ";
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3180
sx,sy,tx,ty = map(int,input().split())
dx = tx-sx
dy = ty-sy
print(dx*"R"+dy*"U"+dx*"L"+(dy+1)*"D"+(dx+1)*"R"+(dy+1)*"U"+"L"+"U"+(dx+1)*"L"+(dy+1)*"D"+"R")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long N,A,B;
  cin>>N>>A>>B;
  long long X=N%(A+B);
  if(X>=A){
    cout<<N/(A+B)*A+A<<endl;
  }
  else{
    cout<<N/(A+B)*A+X<<endl;
  }
}


Measured memory_bytes: 3600
#include<iostream>

using namespace std;

int main() {
	int a, b, c, d, e, ans = 0;
	cin >> a >> b >> c >> d >> e;
	if (a < 0) {
		if (b < 0) ans += (b - a)*c;
		ans +=-a*c+d;
		a = 0;
	}
	ans += (b-a)*e;

	cout << ans << endl;

	return 0;
}

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

int main(){
    int a, b, c;
    cin >> a >> b >> c;

    if(a+b==c || b+c==a || c+a==b){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3612