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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const int64 infll = (1LL << 61) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}


int main() {
  int N;
  int64 V;
  cin >> N >> V;
  vector< int64 > A(N), B(N), C(N), D(N);
  cin >> A >> B >> C >> D;

  vector< int64 > X, Y;
  X.reserve(N + N);
  Y.reserve(N + N);
  for(auto &p : A) for(auto &q : B) X.push_back(p + q);
  for(auto &p : C) for(auto &q : D) Y.push_back(p + q);
  sort(begin(Y), end(Y));
  int64 ret = 0;
  for(auto &p : X) {
    auto uku = equal_range(begin(Y), end(Y), V - p);
    ret += uku.second - uku.first;
  }
  cout << ret << endl;
}





Measured memory_bytes: 22748
s = input()
s += 'R'
n = len(s)
ans = []
now = 'R'
r = 1
l = 0
for i in range(1,n):
    if s[i] == now :
        if now == 'R':
            r += 1
        else :
            l += 1
    else :
        if now == 'R' :
            now = 'L'
            l += 1
        else :
            x = (r+l)//2
            if r%2 == 0:
                ans += [0]*(r-1) + [x] + [r+l-x] + [0]*(l-1)
            else :
                ans += [0]*(r-1) + [r+l-x] + [x] + [0]*(l-1)
            r = 1
            l = 0
            now = 'R'
print(*ans)

Measured memory_bytes: 49976
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
#include <cassert>
//#include <bits/stdc++.h>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()

typedef long long ll;

//const int MOD = 1000000007;
//const int INF = 1<<30;
using namespace std;

string yn(bool x){
    return x ? "YES" : "NO";
}

int main(){
    int n; cin >> n ;
    
    vi a(n);
    rep(i,n) cin >> a[i];
    
    Sort(a);
    
    int cnt = 0;
    int ans = 0;
    rep(i,n-1){
        if(a[i] == a[i+1]) cnt++;
        else{
            if(cnt%2 == 0) ans++;
            cnt = 0;
        }
    }
    
    if(cnt>0) ans += (cnt%2 == 0 ? 1 : 0);
    if(a[n-2] != a[n-1]) ans++;
    cout << ans << endl;
}






Measured memory_bytes: 640
import java.util.*;

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

    while(true){
      int n = s.nextInt();
      
      if(n==0){
        break;
      }

      int[] a = new int[n];
      for(int i=0;i<n;i++){
        a[i] = s.nextInt();
      }

      int ans = 1000000;
      Arrays.sort(a);

      for(int i=0;i<n-1;i++){
        int m = a[i+1] - a[i];
        if(ans > m){
          ans = m;
        }
      }

      System.out.println(ans);
    }

  }
}


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

void solve(long long N, string S){
    rep(i,1000){
        string z=to_string(i);
        if(i<10) z= "00" +z;
        else if(i<100) z="0"+z;
        int a=N,b=N,c=0,flaga=0,flagb=0;
        rep(j,N){
            if(S[j]==z[0]) {if(flaga==0){a=j;flaga=1;}}
            if(S[j]==z[1] and j>a) {if(flagb==0)b=j;flagb=1;}
            if(S[j]==z[2] and j>b) {c=1; break;}
        }
        if(c)ans++;
    }
    cout<<ans<<endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::cout<<std::fixed<<std::setprecision(10);//誤差小数10桁まで
    long long N;
    scanf("%lld",&N);
    string S;
    cin>>S;
    solve(N, S);
    return 0;
}


Measured memory_bytes: 512
import Control.Monad
import Data.List

dist :: [Double] -> Double
dist [xa,ya,_,xb,yb,_] = sqrt $ (xa-xb)^2 + (ya-yb)^2

solve :: [Double] -> String
solve all@[xa,ya,ra,xb,yb,rb]
  | dist all > ra+rb = "0"
  | (dist all + ra) < rb = "-2"
  | dist all + rb < ra = "2"
  | otherwise = "1"

main = do
  n <- readLn
  xs <- replicateM n getLine

  putStr $ unlines $ map (solve . map read . words) xs

Measured memory_bytes: 4208
# coding: utf-8
# Your code here!
a=[0,1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k=int(input())
print(a[k])


Measured memory_bytes: 38256
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	nums := insertionSort(scanNums(N), N)
	printNums(nums)
}

func insertionSort(nums []int, n int) []int {
	for i := 1; i < n; i++ {
		printNums(nums)
		v := nums[i]
		var j int
		for j = i - 1; j >= 0 && nums[j] > v; j-- {
			nums[j+1] = nums[j]
		}
		nums[j+1] = v

	}
	return nums
}

func scanNums(len int) (nums []int) {
	var num int
	for i := 0; i < len; i++ {
		fmt.Scan(&num)
		nums = append(nums, num)
	}
	return
}

func printNums(nums []int) {
	for k := 0; k < len(nums)-1; k++ {
		fmt.Printf("%d ", nums[k])
	}
	fmt.Println(nums[len(nums)-1])
}



Measured memory_bytes: 1204
#include <iostream>
#include <stdio.h>
#include <algorithm>
int main() {
    int N;
    int i,j;
    int h[100010];
    scanf("%d",&N);
    for(i=1;i<=N;i++)
        scanf("%d",& h[i]);
    int dp[100010];

    dp[0] = 0;
    dp[1] = h[1];
    dp[2] = abs(h[2] - h[1]);
    if(N>=3)
    dp[3] = std::min(dp[1]+abs(h[3]-h[2]), abs(h[3]-h[1]));
    for(i=4;i<=N;i++)
    {
        dp[i] = std::min((dp[i-1]+abs(h[i]-h[i-1])), (dp[i-2]+abs(h[i]-h[i-2])));
    }
    printf("%d", dp[N]);
    return 0;
}

Measured memory_bytes: 1024
/**
 *    author:  math2do
 *    created: 27.04.2020 22:16:51 IST
**/

#include <bits/stdc++.h>

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  unordered_set <string> st;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    st.insert(s);
  } 
  cout << (int) st.size() << endl;
  return 0;
}


Measured memory_bytes: 17748
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;


class Program
{
    public static long Read()
    {
        return long.Parse(Console.ReadLine());
    }

    public static long[] Reads()
    {
        return Console.ReadLine().Split().Select(long.Parse).ToArray();
    }
    
    public static void Main()
    {
        var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        var input = Reads();
        var n = input[0];
       var k= input[1];
        var count = 0;
        long l = 0;
        while (n>=l)
        {
            count++;
            l = (long)Math.Pow(k, count);
        }
        Console.WriteLine(count);

        Console.Out.Flush();
    }
}


Measured memory_bytes: 13396
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        int[][] nums=new int[n][2];
        int[][] en=new int[n][2];
        for(int i=0;i<n;i++){
            for(int j=0;j<2;j++){
                nums[i][j]=sc.nextInt();
            }
            en[i][0]=nums[i][0]+nums[i][1];
            en[i][1]=i;
        }
        Comp comp=new Comp();
        int ans=0;
        Arrays.sort(en,comp);
        int last=Integer.MIN_VALUE;
        for(int i=0;i<n;i++){
            if(last<=nums[en[i][1]][0]-nums[en[i][1]][1]){
                last=en[i][0];
                ans++;
            }
        }
        System.out.println(ans);
 
    }



}
class Comp implements Comparator {

    int index = 0;

    void set_index (int i) {
        index = i;
    }

    public int compare (Object a, Object b) {
        int[] int_a = (int[]) a;
        int[] int_b = (int[]) b;
        return (int_a[index] - int_b[index]);
    }

}

Measured memory_bytes: 93584
#include<bits/stdc++.h>
using namespace std;
#define MAXN 20000005
#define int long long
int n;
int a[MAXN],v[MAXN];
int resp=0LL;
int32_t main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin>>n;

    for(int i=0;i<n;i++){
        cin>>v[i];
        a[v[i]]++;
    }

    for(int i=1;i<=n;i++){

        resp+=a[i]*(a[i]-1)/2;

    }

    for(int i=0;i<n;i++){
        cout<<resp-a[v[i]]+1<<"\n";
    }


}

Measured memory_bytes: 8320
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define elif else if
int a,b,c;
string s;
signed main()
{
	cin>>a>>s>>b;
	rep(i,a){
		if(s[i]!=s[b-1]){
			cout<<'*';
		}else{
			cout<<s[i];
		}
	}
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str  = sc.nextLine();
        String[] astr = str.split(" "); //状況に合わせて
        int kuti = 1;
        int flag = 0;
        int[] in_data = Stream.of(astr).mapToInt(x->{
            try{
                return Integer.parseInt(x);
            }
            catch(Exception e){
                e.printStackTrace();
            }
            return 0;
        }).toArray();
        sc.close();
        int a = in_data[0];
        int b = in_data[1];


        while(kuti < b){
            kuti -= 1;
            kuti = kuti + a;
            flag += 1;
        }
        System.out.println(flag);
    }
}

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

struct res
{
    int length;
    int dest;
};

std::vector<res> lengths;
std::vector<std::vector<int>> neighbors;

std::vector<int> detect(int room, int length)
{
    std::vector<int> myNeighbor = neighbors[room];
    std::vector<int> nextVal;
    for(int i = 0; i < myNeighbor.size(); i++)
    {
        if(lengths[myNeighbor[i]].length == 0 || (length + 1) < lengths[myNeighbor[i]].length)
        {
            lengths[myNeighbor[i]].length = length + 1;
            lengths[myNeighbor[i]].dest = room;
            nextVal.push_back(myNeighbor[i]);
        }
    }
    return nextVal;
}

int d()
{
    int n, m;
    std::cin >> n >> m;
    
    lengths.resize(n + 1);
    neighbors.resize(n + 1);
    
    for(int i = 0; i < m; i++)
    {
        int a, b;
        std::cin >> a >> b;
        
        neighbors[a].push_back(b);
        neighbors[b].push_back(a);
    }
    
    std::vector<int> input;
    input.push_back(1);
    for(int i = 0; i < 1000000; i++)
    {
        std::vector<int> nextInput;
        for(int k = 0; k < input.size(); k++)
        {
            auto nextRooms = detect(input[k], i);
            for(int m = 0; m < nextRooms.size(); m++)
            {
                nextInput.push_back(nextRooms[m]);
            }
        }
        input.clear();
        input = nextInput;
        if(input.size() == 0)
        {
            break;
        }
    }
    
    std::cout << "Yes" << std::endl;
    for(int i = 2; i <= n; i++)
    {
        std::cout << lengths[i].dest << std::endl;
    }
    
    return 0;
}

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

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

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<string> S(n);
    copy_n(istream_iterator<string>(cin), n, S.begin());
    sort(S.begin(), S.end());
    
    cout << unique(S.begin(), S.end()) - S.begin() << endl;

}

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

int main() {
    long long N,K;
    cin >> N >> K;
    if ( K % 2 == 1){
        cout << (N/K)*(N/K)*(N/K);
        cout << endl;
    }
    else{
        cout << (N/K)*(N/K)*(N/K) + ((2*N/K+1)/2)*((2*N/K+1)/2)*((2*N/K+1)/2);
        cout << endl;
            }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>
#include <queue>
#include <stack>
#include <string.h>
#include <algorithm>
#include <math.h>
//#include <bits/stdc++.h>
#define ll long long
#define wtcl return
using namespace std;

inline int read()
{
	ll s = 0, f = 1;
	char ch = getchar();
	for(; ch < '0' || ch > '9'; ch = getchar()) if(ch == '-') f = - 1;
	for(; ch >= '0' && ch <= '9'; ch = getchar()) s = ((s << 3ll) + (s << 1ll) + (ch ^ 48ll));
	return s * f ;
}
inline void out(int x)
{
	if(x<0) putchar('-'),x=-x;
	if(x>9) out(x/10);
	putchar(x%10+'0');
}

int Decimal(int n)
{
	int result=0,k=1;
	int i;
	while(n){
		i=n%2;
		result = k*i + result;
		k = k*10;
		n = n/2;
	}
	return result;
}
const int mod = 1e9+7;
int main()
{
//	int lastans=0;
//	for(int k=1;k<=100;k++)
//	{
//		int ans = 0;
//		printf("%d ",Decimal(k));
//
//		for(int i=0;i<=k;i++)
//		{
//			for(int j=0;j<=k-i;j++)
//			{
//				if((i+j) == (i^j))
//				{
//					//printf("%d %d\n",i,j);
//					ans++;
//				}
//
//			}
//		}
//		printf("%d %d\n",ans,ans-lastans);
//		lastans = ans;
//		system("pause");
//	}
	string s;
	ll mil[100005];
	mil[0]=1;
	for(ll i=1; i<=100002; i++)
		mil[i] = (mil[i-1]*3)%mod;
	while(cin>>s)
	{
		ll ans = 0;
		ll l = s.length();
		ll k=1;
		for(int i=0; i<l; i++)
		{
			if(s[i]=='1')
			{
				ans = (ans + k * mil[l-i-1]) % mod; //带权幂次累加   权为2^n 
				k=(k*2)%mod;
			}
		}
		cout<<(ans+k)%mod<<endl;
	}
	wtcl 0;
}

Measured memory_bytes: 1280
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
count = 0

for i in range(N):
    if A[i] != 0 and B[i] != 0:
        k = min(A[i],B[i])
        A[i] -= k
        B[i] -= k
        count += k
    if A[i+1] != 0 and B[i] != 0:
        l = min(A[i+1],B[i])
        A[i+1] -= l
        B[i] -= l
        count += l

print(count)

Measured memory_bytes: 18624
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

readl= lambda: list(map(int, sys.stdin.readline().split()))
readt= lambda: tuple(map(int, sys.stdin.readline().split()))
read = lambda: sys.stdin.readline().rstrip()
readi = lambda: int(read())
readmi = lambda: map(int, sys.stdin.readline().split())
readms = lambda: map(str, sys.stdin.readline().split())

n = readi()
h = []
mx = 0
for i in range(n):
    x, y = readmi()
    heapq.heappush(h, (-y, -x))
    mx = max(mx, y)
while(h):
    y, x = heapq.heappop(h)
    x = -x
    y = -y
    if mx > y:
        mx = y
    mx -= x
    if mx < 0:
        print("No")
        exit()
print("Yes")

    

Measured memory_bytes: 32504
using System;
using System.Collections.Generic;
using System.Text;

class Program
{
    public void Proc()
    {
        int itemCount = int.Parse(Console.ReadLine());
        string[] inpt = Console.ReadLine().Split(' ');
        int[] numList = new int[itemCount];

        for(int i=0; i<inpt.Length; i++)
        {
            numList[i] = int.Parse(inpt[i]);
        }
        // ?´?????????????
        int convCount = 0;

        for (int i = 0; i < numList.Length; i++)
        {
            int minIdx = i;
            for(int j= i; j<numList.Length; j++)
            {
                if(numList[j] < numList[minIdx])
                {
                    minIdx = j;
                }
            }
            if(i!=minIdx)
            {
                int tmpVal = numList[i];
                numList[i] = numList[minIdx];
                numList[minIdx] = tmpVal;
                convCount++;
            }
        }


        StringBuilder ans = new StringBuilder();
        for(int i=0; i<numList.Length; i++)
        {
            if(ans.Length > 0)
            {
                ans.Append(" ");
            }
            ans.Append(numList[i]);
        }

        Console.WriteLine(ans.ToString());
        Console.WriteLine(convCount);
    }


    static void Main(string[] args)

    {

        Program prg = new Program();
        prg.Proc();

    }
}

Measured memory_bytes: 9024
#include <iostream>
#include <cstdio>
#define N 10005
using namespace std;

int n,s, a, b, c;
int main()
{
	int i;
	cin >> a >> b >> c;
	if (a == b) cout << c;
	else if (a == c) cout << b;
	else cout << a;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
const ll INF = 1LL<<60;
const ll M = 1000000007;
ll mpow(ll a,ll b){ll res=1;while(b!=0){if(b&1)res=res*a%M;a=a*a%M;b=b>>1;}return res;}
ll mcomb(ll n,ll k){if(k>n/2)return mcomb(n,n-k);ll res=1;for(ll i=0;i<k;i++){res=res*(n-i)%M;res=res*mpow(k-i,M-2)%M;}return res;}
/*template*/

int main()
{
  string s;cin>>s;
  ll ans=0;
  for(ll i=0;i<(s.length()+1)/2;i++){
    if(s[i]!=s[s.length()-1-i])ans++;
  }
  cout<<ans<<endl;
  return 0;
}


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

int main() {
  int n,k;
  cin>>n>>k;
  int ans=1;
  for(int i=0;i<n;i++){
    if(2*ans>=ans+k){
      ans+=k;
    }
    else{
      ans*=2;
    }
  }
  cout<<ans<< endl;
}

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

namespace ABC172_D
{
    class Program
    {
        static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());
            long A = 0;

            long[] list = new long[N + 1];

            for (int i = 1; i <= N; i++)
            {
                for (int j = 1; i * j <= N; j++)
                {
                    list[i * j]++;
                }
            }

            for (int i = 1; i <= N; i++)
            {
                A += i * list[i];
            }
            Console.WriteLine(A);
        }
    }
}


Measured memory_bytes: 105712
#include <iostream>

using namespace std;

int main() {
  string s;
  int ans = 0;
  cin >> s;
  
  for (int i = 0; i < s.size() / 2; ++i) {
	if (s[i] != s[s.size() - i - 1])
      ++ans;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include <climits>
#include<vector>
#include<list>
#include<numeric>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>
#include<map>
#include<stack>
#include<queue>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;


int partition(vector<pair<char,int>> &A, int p, int r) {
	int x = A[r].second;
	int i = p - 1;
	for (int j = p;j < r;j++) {
		if (A[j].second <= x) {
			i++;
			pair<char,int> tmp = A[i];
			A[i] = A[j];
			A[j] = tmp;
		}
	}
	pair<char,int> tmp = A[i + 1];
	A[i + 1] = A[r];
	A[r] = tmp;
	return i + 1;
}

void quickSort(vector<pair<char,int>> &A, int p, int r) {
	if (p < r) {
		int q = partition(A, p, r);
		quickSort(A, p, q - 1);
		quickSort(A, q + 1, r);
	}
}

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

	int n;
	cin >> n;
	vector<pair<char, int>> A(n);
	map<int, queue<char>> qu;
	REP(i, n) {
		cin >> A[i].first >> A[i].second;
		qu[A[i].second].push(A[i].first);
	}
	quickSort(A, 0, n - 1);
	bool stable = true;
	REP(i, n - 1) {
		if (A[i].first == qu[A[i].second].front()) qu[A[i].second].pop();
		else {
			stable = false;
			break;
		}
	}
	if (stable) cout << "Stable\n";
	else cout << "Not stable\n";
	REP(i, n) {
		cout << A[i].first << " " << A[i].second << "\n";
	}

	return 0;
}


Measured memory_bytes: 21636
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

import java.util.*;

public class Main{
  static final boolean DEBUG = true;

  public static void main(String[] args){
    FastScanner sc = new FastScanner();

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

    int sum = a + b + c;
    int m = Math.max(a, Math.max(b, c));
    int ans;
    if(sum % 2 == (3 * m) % 2){
      ans = ((3 * m) - sum) / 2;
    }
    else{
      ans = ((3 * (m + 1)) - sum) / 2;
    }

    System.out.println(ans);
  }
}

class FastScanner {
  private static final InputStream in = System.in;
  private static final PrintWriter out = new PrintWriter(System.out);
  private final byte[] buffer = new byte[2048];
  private int p = 0;
  private int buflen = 0;

  public FastScanner(){
  }

  private boolean hasNextByte() {
    if(p < buflen){
      return true;
    }
    p = 0;
    try{
      buflen = in.read(buffer);
    }catch (IOException e) {
      e.printStackTrace();
    }
    if(buflen <= 0){
      return false;
    }
    return true;
  }

  public boolean hasNext() {
    while(hasNextByte() && !isPrint(buffer[p])){
      p++;
    }
    return hasNextByte();
  }

  private boolean isPrint(int ch) {
    if(ch >= '!' && ch <= '~'){
      return true;
    }
    return false;
  }

  private int nextByte() {
    if(!hasNextByte()){
      return -1;
    }
    return buffer[p++];
  }

  public String next() {
    if(!hasNext()){
      throw new NoSuchElementException();
    }
    StringBuilder sb = new StringBuilder();
    int b = -1;
    while(isPrint((b = nextByte()))){
      sb.appendCodePoint(b);
    }
    return sb.toString();
  }

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

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

  public double nextDouble() {
    return Double.parseDouble(next());
  }
}


Measured memory_bytes: 23124
n, k = gets.split.map &:to_i
a = gets.split.map &:to_i

m_min = 10000000000000
[*0...n].combination(k) do |is|
  h_max = 0
  m = 0
  n.times do |i|
    h = a[i]
    if is.include? i
      if h_max >= h
        m += h_max - h + 1
        h = h_max + 1
      end
    end
    h_max = [h_max, h].max
  end
  m_min = [m_min, m].min
end

p m_min


Measured memory_bytes: 14292
def main():
    N = int(input())
    A = list(map(int, input().split()))

    cnt = {}
    for a in A:
        if a not in cnt:
            cnt[a] = 0
        cnt[a] += 1

    B = []
    for a, x in cnt.items():
        if x >= 2:
            B.append(a)

    B = sorted(B, reverse=True)
    if len(B) > 0 and cnt[B[0]] >= 4:
        print(B[0] ** 2)
    elif len(B) > 1:
        print(B[0] * B[1])
    else:
        print('0')


if __name__ == '__main__':
    main()


Measured memory_bytes: 17960
#include<iostream>
using namespace std;
long long a[100005];
int main()
{
	long long n,ans,nmax,num;
	cin>>n>>nmax;
	ans=0;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	for(int i=0;i<n;i++)
	{
		if(a[i]+a[i+1]>nmax)
		{
			num=a[i]+a[i+1]-nmax;
			ans+=(a[i]+a[i+1]-nmax);
			if(a[i+1]>=num)
			{
				a[i+1]-=num;
				
			}
			else
			{
				a[i+1]=0;
			}
		}
		
	 } 
	 cout<<ans<<endl;
	 return 0;
} 

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

typedef long long ll;

const int mx = 1e5 + 5;

int main() {

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

    ll n = 0;
    cin >> n;

    vector< pair<ll, ll> > v(n, make_pair(0, 0));
    ll temp = 0;
    for(int i = 0; i < n; i++) {
        cin >> temp;
        v[i] = make_pair(temp, i + 1);
    }

    sort(v.begin(), v.end());
    for(int i = 0; i < n; i++) {
        cout << v[i].second << " ";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 2432
M=2*10**5+9
n,c=gets.split.map(&:to_i)
programs=Array.new(c){Array.new}
imos=Array.new(M,0)
n.times{
  s,t,k=gets.split.map(&:to_i)
  programs[k-1]<<[s,t]
}
programs.each{|seq|seq.sort_by!(&:first)}
merged_programs=Array.new(c){Array.new}

programs.each_with_index{|seq,idx|
  mp=merged_programs[idx]
  seq.each{|s,t|
    if mp.empty?
      mp << [s,t]
    elsif mp.last.last==s
      mp.last[1]=t
    else 
      mp << [s,t]
    end
  }
}
merged_programs.each{|seq|
  seq.each{|s,t|
    imos[2*s-1]+=1
    imos[2*t]-=1
  }
}
(M-1).times{|i|
  imos[i+1]+=imos[i]
}

puts imos.max

Measured memory_bytes: 14200
package main

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

var sc = bufio.NewScanner(os.Stdin)

func stringLineScan() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, 1000000009)
	sc.Split(bufio.ScanWords)
	h, _ := strconv.Atoi(stringLineScan())
	w, _ := strconv.Atoi(stringLineScan())
	g := make([]string, h)
	for i := 0; i < h; i++ {
		g[i] = stringLineScan()
	}
	a := mk(h, w)
	b := mk(h, w)
	c := mk(h, w)
	d := mk(h, w)
	for i := 0; i < h; i++ {
		if string(g[i][0]) == "#" {
			a[i][0] = -1
		}
		for j := 1; j < w; j++ {
			if string(g[i][j]) == "#" {
				a[i][j] = -1
			} else {
				a[i][j] = a[i][j-1] + 1
			}
		}
	}
	for i := 0; i < h; i++ {
		if string(g[i][w-1]) == "#" {
			b[i][w-1] = -1
		}
		for j := w - 2; j >= 0; j-- {
			if string(g[i][j]) == "#" {
				b[i][j] = -1
			} else {
				b[i][j] = b[i][j+1] + 1
			}
		}
	}
	for j := 0; j < w; j++ {
		if string(g[0][j]) == "#" {
			c[0][j] = -1
		}
		for i := 1; i < h; i++ {
			if string(g[i][j]) == "#" {
				c[i][j] = -1
			} else {
				c[i][j] = c[i-1][j] + 1
			}
		}
	}
	for j := 0; j < w; j++ {
		if string(g[h-1][j]) == "#" {
			d[h-1][j] = -1
		}
		for i := h - 2; i >= 0; i-- {
			if string(g[i][j]) == "#" {
				d[i][j] = -1
			} else {
				d[i][j] = d[i+1][j] + 1
			}
		}
	}
	ans := 0
	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			x := a[i][j] + b[i][j] + c[i][j] + d[i][j] + 1
			if ans < x {
				ans = x
			}
		}

	}
	fmt.Println(ans)
}
func mk(h, w int) [][]int {
	x := make([][]int, h)
	for i := 0; i < h; i++ {
		y := make([]int, w)
		x[i] = y
	}
	return x
}


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

int main(){
  int n;
  cin >> n;
  vector<int>a(3*n);
  for(int i=0; i<3*n; i++)cin >> a[i];
  sort(a.begin(), a.end());
  long ret=0;
  for(int i=0; i<n; i++){
    ret+=a[n+2*i];
  }
  cout << ret;
  return 0;
}

Measured memory_bytes: 1408
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define MAX_N 100000
int ac[MAX_N+1] = {0};
int wa[MAX_N+1] = {0};

int main(){
  int n, m;
  int i, p, suc = 0, fai = 0;
  char s[3];

  scanf("%d %d", &n, &m);

  for(i=0; i<m; i++){
    scanf("%d %s", &p, s);
    if(strcmp(s, "AC") == 0){
      ac[p]++;
    }else{
      if(ac[p] <= 0){
        wa[p]++;
      }
    }
  }
  
  for(i=1; i<=n; i++){
    if(ac[i] > 0){
      suc++;
      if(wa[i] > 0){
        fai += wa[i];
      }
    }
  }
  
  printf("%d %d", suc, fai);
  return 0;
}


Measured memory_bytes: 896
//  aoj-1345  / 2015-11-28
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
using namespace std;
#define rep(i,j) for(int i=0 ;i<(j);i++)
#define repeat(i,j,k) for(int i=j ;i<(k);i++)
#define all(v) v.begin(),v.end()
int solve(vector<int> b,vector<int> t){
    if( accumulate(all(b),0) != accumulate(all(t),0)) return 1<<30;
    int ret = 0;
    rep(i,b.size()){
        repeat(j,i,b.size()){
            if(b[j] == t[i]){
                b.erase(b.begin()+j);
                b.insert(b.begin()+i,t[i]);
                ret += j-i;
                break;
            }
        }
    }
    return ret;
}

int main(){
    int n,m; cin >> n >> m;
    vector<int> b(n),p(m);
    rep(i,n) cin >> b[i];
    rep(i,m)cin>>p[i];
    vector<int> t[2];
    rep(i,2)t[i].resize(n,0);
    {
        int now =0;
        rep(i,m)rep(j,p[i]){
            if(i%2) t[0][now] = 1;
            else t[1][now] = 1;
            now++;
        }
    }

    cout << min(solve(b,t[0]),solve(b,t[1])) << endl;
    return 0;
}

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

namespace AtCoder.Abc
{
    public class QuestionA
    {
        public static void Main(string[] args)
        {
            // 文字列配列の入力
            string inputStrArray1 = Console.ReadLine();
            string inputStrArray2 = Console.ReadLine();
            string inputStrArray3 = Console.ReadLine();

            Console.WriteLine(inputStrArray1.Substring(0,1) + inputStrArray2.Substring(1, 1) + inputStrArray3.Substring(2, 1));
		}
    }
}

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

using namespace std;

#define ff(i, a, b) for(int i = (a); (i <= (b)); ++i)
#define FF(i, a, b) for(int i = (a); (i >= (b)); --i)
#define ll long long

const int M = 1000000000 + 7;
const int N = 200000 + 10;

struct re {
    int x, y;
};

int n, q, a[N];
bool kt[N];
vector<int> e[N];

void dfs(int u) {
    kt[u] = 1;
    for (int v : e[u])
    if (!kt[v]) {
        a[v] += a[u];
        dfs(v);
    }
}

int main() {
    //ios_base::sync_with_stdio(false); cin.tie(0);
    //freopen("", "r" , stdin);
    //freopen("", "w", stdout);
    cin >> n >> q;
    ff(i, 1, n - 1) {
        int u, v;
        cin >> u >> v;
        e[u].push_back(v);
        e[v].push_back(u);
    }

    while (q--) {
        int p, x;
        cin >> p >> x;
        a[p] += x;
    }

    dfs(1);
    ff(i, 1, n) cout << a[i] << " ";
}
//This code belongs to s34vv1nd


Measured memory_bytes: 20608
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;

int main(void){
	scanf("%d",&n);
	int cnt=0;
	for(int i=1;i<=n;i*=100){
		int v=min(i*10-1,n);
		cnt+=v-i+1;
	}
	printf("%d\n",cnt);
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main(void){
    int N,a[51];

    scanf("%d",&N);

    int i,j,swap;
    for(i=0;i<N-1;i++){
        scanf("%d ",&a[i]);
    }
        scanf("%d",&a[N-1]);

    for(j=0;j<N;j++){
        for(i=0;i<N-1-j;i++){
            if(a[i]>a[i+1]){
                swap = a[i];
                a[i] = a[i+1];
                a[i+1] = swap;
            }
        }
    }

    double temp=(double)a[0];

    for(i=0;i<N-1;i++){
        temp = (temp + (double)a[i+1])/2;
    }

    printf("%lf\n",temp);

    return 0;
}

Measured memory_bytes: 128
// Try AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
	let mut stdin = String::new();
    std::io::Read::read_to_string(
    	&mut std::io::stdin(),
        &mut stdin).unwrap();
	let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
    	($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let n = get!();
    if n == 1 {
    	println!("Hello World");
    } else {
    	let a = get!();
        let b = get!();
        let ans = a + b;
        println!("{}", ans);
    }
}

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

int main(){
	int i,j,k,n,m,l,f,x,y,z; string s;
	cin >> n;
	m = 0;
	if(n >= 64) m = 64;
	else if(n >= 32) m = 32;
	else if(n >= 16) m = 16;
	else if(n >= 8) m = 8;
	else if(n >= 4) m = 4;
	else if(n >= 2) m = 2;
	else m = 1;
	cout << m << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;

int N;
double A[100];

int main(){
    cin>>N;
    double sum=0;
    rep(i,N){
        double a;
        cin>>a;
        A[i]=1/a;
        sum+=A[i];
    }

    double ans=1/sum;

    cout<<setprecision(10)<<ans<<endl;
}

Measured memory_bytes: 256
// This code wrote by chtholly_micromaker(MicroMaker)
#pragma GCC optimize("Ofast,O3,inline")
#pragma GCC target("avx,avx2")
#include <bits/stdc++.h>
#define reg register
#define ALL(x) (x).begin(),(x).end()
#define mem(x,y) memset(x,y,sizeof x)
#define sz(x) (int)(x).size()
#define ln puts("")
#define lsp putchar(32)
#define pb push_back
#define MP make_pair
#define dbg(x) cerr<<">"<<__func__<<"\tLine: "<<__LINE__<<' '<<#x<<": "<<x<<endl
using namespace std;
const int MaxN=300050;
template <class t> inline void read(t &s){s=0;
reg int f=1;reg char c=getchar();while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
while(isdigit(c))s=(s<<3)+(s<<1)+(c^48),c=getchar();s*=f;return;}
template<class t,class ...A> inline void read(t &x,A &...a){read(x);read(a...);}
template <class t> inline void write(t x){if(x<0)putchar('-'),x=-x;
int buf[21],top=0;while(x)buf[++top]=x%10,x/=10;if(!top)buf[++top]=0;
while(top)putchar(buf[top--]^'0');return;}
inline void setIn(string s){freopen(s.c_str(),"r",stdin);return;}
inline void setOut(string s){freopen(s.c_str(),"w",stdout);return;}
inline void setIO(string s=""){setIn(s+".in");setOut(s+".out");return;}
template <class t>inline bool checkmin(t&x,t y){if(x>y){x=y;return 1;}return 0;}
template <class t>inline bool checkmax(t&x,t y){if(x<y){x=y;return 1;}return 0;}
inline int lowbit(int x){return x&(-x);}
int a[MaxN<<2];
#define lson (u<<1)
#define rson (u<<1|1)
inline void pushup(int u)
{
	a[u]=max(a[lson],a[rson]);
	return;
}
inline void modify(int u,int l,int r,int p,int k)
{
	if(l==r)
	{
		checkmax(a[u],k);
		return;
	}
	reg int mid=(l+r)>>1;
	p<=mid?modify(lson,l,mid,p,k):modify(rson,mid+1,r,p,k);
	pushup(u);
	return;
}
inline int query(int u,int l,int r,int ql,int qr)
{
	if(ql<=l&&r<=qr)
		return a[u];
	reg int mid=(l+r)>>1,res=0;
	if(ql<=mid)
		checkmax(res,query(lson,l,mid,ql,qr));
	if(mid<qr)
		checkmax(res,query(rson,mid+1,r,ql,qr));
	return res;
}
int f[MaxN],b[MaxN];
signed main(void)
{
	int n,k;read(n,k);
	for(int i=1;i<=n;++i)
		read(b[i]);
	for(int i=1;i<=n;++i)
		f[i]=query(1,0,300000,max(0,b[i]-k),min(b[i]+k,300000))+1,
		modify(1,0,300000,b[i],f[i]);
	write(*max_element(f+1,f+n+1)),ln;
	return 0;
}

/*
 * Check List:
 * 1. Input / Output File (USACO and OI and UVa)
 * 2. long long 
 * 3. Special Test such as n=1
 * 4. Array Size
 * 5. Memory Limit (OI) int is 4 and longlong is 8
 * 6. Mod (a*b%p*c%p not a*b*c%p  ,  (a-b+p)%p not a-b )
 * 7. Name ( int k; for(int k...))
 * 8. more tests , (T=2 .. more)
 * 9. blank \n after a case
*/






Measured memory_bytes: 10088
#include<iostream>
using namespace std;
int main(){
  int n,m,i,j,k,l;cin >> n >> m;bool ans = false,sans;
  char a[n][n],b[m][m];
  for(i=0;i<n;i++){
    for(j=0;j<n;j++) cin >> a[i][j];
  }
  for(i=0;i<m;i++){
    for(j=0;j<m;j++) cin >> b[i][j];
  }
  for(i=0;i<=n-m;i++){
    for(j=0;j<=n-m;j++){
      sans = true;
      for(k=0;k<m;k++){
        for(l=0;l<m;l++){
          if(a[i+k][j+l]!=b[k][l]) sans = false;
        }
      }
      if(sans) ans = true;
    }
  }
  cout << ((ans) ? "Yes":"No") << endl;
}

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


int main() {
  int n,m,a[100];
  cin>>n>>m;
  int popu=0; double sum_a=0;
  rep(i,n){
    int A;
    cin>>A;
    a[i]=A;
    sum_a+=a[i];
  }
  rep(i,n){
    if(a[i] >= sum_a/(4*m)){
      popu++;
    }
  }
  if(popu>=m){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 3600
#include<stdio.h>

int main(){
        int n, i, j;
        scanf("%d", &n);
        int d[n][2];
        for(i=0; i<n; i++){
                for(j=0; j<2; j++){
                        scanf("%d", &d[i][j]);
                }
        }
        int count=0;
        for(i=1; i<n-1; i++){
                if((d[i-1][0]==d[i-1][1])&&(d[i][0]==d[i][1])&&(d[i+1][0]==d[i+1][1])){
                        printf("Yes");
                        return 0;
                }
        }
        printf("No");
        return 0;
}


Measured memory_bytes: 1728
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
const ll INF=(ll)1e18+10;
const double PI=acos(-1);

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dy[]={-1,1,0,0};
int dx[]={0,0,-1,1};

int main() {
    int K,N;
    cin>>K>>N;

    vector<int> a(N);
    for (int i = 0; i < N; ++i) {
        cin>>a[i];
    }
    int ans=a[N-1]-a[0];
    //clock

    for (int i = 1; i < N; ++i) {
        ans=min(ans,K-(a[i]-a[i-1]));
    }

    //ans=min(ans,K-(K-a[N-1])-a[0]);
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define mem(a,n) memset(a,n,sizeof(a))
#define rep(i,a,n) for(int i=a;i<n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef unsigned long long ull;
const double eps=1e-6;
const int INF=0x3f3f3f3f;
const int mod=1e9+7;
const int N=1e3+5;
string s;
int main()
{
    int m;
    while(~scanf("%d",&m))
    {
        printf("%d\n",48-m);
    }
    return 0;
}


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

int main(){
  int tmp, i=0, a[3];
  while(cin >> tmp){
    a[i] = tmp;
    i++;
  }
  sort(a, a + 3);
  cout << a[0] + a[1] << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

typedef long long int ll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)

const ll MOD = 1000000007;

using namespace std;

ll A[300005];
int main()
{
	int N;
	cin >> N;
	REP(i, 3 * N)
	{
		cin >> A[i];
	}
	sort(A, A + N * 3, [](ll a, ll b) {return a > b; });
	ll ans = 0;
	for (int i = 1; i < 2 * N; i += 2)
	{
		ans += A[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define ll long long int
#define FASTIO std::ios::sync_with_stdio(false);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define inf 1e18
#define g(x) cout<<x<<" "<<endl;
#define gg(x,y) cout<<x<<" & "<<y<<" "<<endl
#define jam(t) cout<<"Case #"<<t<<": "
#define ggg(x,y,z) cout<<x<<" & "<<y<<" & "<<z<<" "<<endl
#define all(x) x.begin(),x.end()
#define input_from_file  freopen("input.txt", "r", stdin);
#define mod 1000000007ll
#define sz 400005
#define bitcnt(x) __builtin_popcountll(x)
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}



void solve(){
    ll n;
    cin >> n;
    ll an = 0;
    for(ll i=1;i<=n;i++){
        for(ll j=1;j<=n;j++){
            for(ll k=1;k<=n;k++){
                an += __gcd(i,__gcd(j,k));
            }
        }
    }
    g(an);
}
int main()
{
#ifndef ONLINE_JUDGE
input_from_file
#endif
 
    FASTIO
    cin.tie(NULL);
    fflush(stdout);
    ll t = 1;
    //cin >> t;
    for(ll tcase = 1;tcase <= t;tcase++){
        solve();
        
    }
return 0;
}

Measured memory_bytes: 3592
#include<cstdio>
using namespace std;
typedef long long ll;

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

int main(){
  int n,i,j;
  ll d[10],v[10],t[10];

  for(;;){
    scanf("%d",&n);
    if(!n)break;

    for(i=0;i<n;i++)scanf("%lld %lld",&d[i],&v[i]);
    t[0] = 1;
    for(i=1;i<n;i++){
      t[i] = t[i-1]*d[i-1]*v[i];
      for(j=0;j<i;j++)t[j] *= d[i]*v[i-1];
      ll T = t[0];
      for(j=1;j<=i;j++)T = gcd(T,t[j]);
      for(j=0;j<=i;j++)t[j]/=T;
    }

    for(i=0;i<n;i++)printf("%lld\n",t[i]);
  }
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
#include <utility>
#include <cstring>
#include <numeric>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define repll(i,n) for(long long int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
template <typename T_char>
char ToUpper (char cX) { return toupper(cX); }
//g++ -std=c++1z temp.cpp
//./a.exe
ll digit(ll a){
    ll count = 0;
    for (ll i = 0; i < a; i++)
    {   if (a == 0)
        {
            break;
        }else
        {
            a = a/10;
            count++;
        }
    }
    return count;
}

uintmax_t comb(unsigned int n, unsigned int r) {
  if ( r * 2 > n ) r = n - r;
  uintmax_t dividend = 1;
  uintmax_t divisor  = 1;
  for ( unsigned int i = 1; i <= r; ++i ) {
    dividend *= (n-i+1);
    divisor  *= i;
  }
  return dividend / divisor;
}
//桁数のカウント
//pow(x,n) == x^n
//sum = accumulate(v.begin(),v.end(),0);
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a,   b) * b;}




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

int a,b,c,d;
cin >> a >> b >> c >> d;

while(1){
  c = c-b;
  if(c <= 0){
    cout << "Yes" << endl;
    return 0;
  } 
  a = a-d;
  if(a <= 0) {
    cout << "No" << endl;
    return 0;
  }
}






//////////////////////////////////////////////////////
return 0;}


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

public class Main {
    public static void main(String args[]) throws IOException {
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	char charArray[] = br.readLine().toCharArray();
	if (charArray[0] == 'R' && charArray[1] == 'R' && charArray[2] == 'R') {
	    System.out.println(3);
	} else if (charArray[0] == 'R' && charArray[1] == 'R' || charArray[1] == 'R' && charArray[2] == 'R') {
	    System.out.println(2);
	} else if (charArray[0] == 'R' || charArray[1] == 'R' || charArray[2] == 'R') {
	    System.out.println(1);
	} else {
	    System.out.println(0);
	}
    }
}

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

using namespace std;
using ll = long long;
using ld = long double;

const int MOD = 1e9 + 7;
const int MX = 2e5 + 5;
const ll INF = 1e18;
const ld PI = acos((ld) -1);

int main () {
	ll sol = 0;
	int n;
	cin >> n;
	int ar[n];
	for (int i = 0; i < n; i++) {
		cin >> ar[i];
	}

	for (int i = 1; i < n; i++) {
		if (ar[i] < ar[i - 1]) {
			sol += ar[i - 1] - ar[i];
			ar[i] = ar[i - 1];
		}
	}

	cout << sol << '\n';
}


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

using ll = long long;

int main()
{
    int N; cin >> N;
    vector<ll> A(N); for (auto& e : A) cin >> e;

    vector<ll> s(N+1, 0);
    partial_sum(A.begin(), A.end(), s.begin()+1);

    ll ans = LLONG_MAX;
    for (int c = 2; c <= N-2; c++) {
        auto it_l = upper_bound(s.begin(), s.begin() + c + 1, s[c]/2);
        int l = max(1, (int)distance(s.begin(), it_l)-1);
        if (l + 1 != c) {
            ll d1 = abs(s[c] - s[l  ] - s[l  ]);
            ll d2 = abs(s[c] - s[l+1] - s[l+1]);
            if (d2 < d1) l++;
        }

        auto it_r = upper_bound(s.begin() + c + 1, s.end(), (s[c]+s.back())/2);
        int r = max(c+1, (int)distance(s.begin(), it_r)-1);
        if (r + 1 != N) {
            ll d1 = abs((s[r  ] - s[c]) - (s.back() - s[r  ]));
            ll d2 = abs((s[r+1] - s[c]) - (s.back() - s[r+1]));
            if (d2 < d1) r++;
        }
        vector<ll> pqrs = { s[l], s[c]   - s[l], s[r]   - s[c], s.back() - s[r] };
        ll a = *max_element(pqrs.begin(), pqrs.end()) - *min_element(pqrs.begin(), pqrs.end());

        ans = min(ans, a);
    }

    cout << ans << endl;
}

Measured memory_bytes: 3328
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <iomanip>
#include <bitset>
#include <unordered_map>
#include <stack>
#include <memory.h>
#include <list>
#include <numeric>
#include <functional>
#include <complex>
#include <cassert>
#include <regex>
#include <random>

#define ll long long
#define ld long double
#define ull unsigned ll
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pii pair<int,int> 
#define vi vector<int>
#define vpii vector<pii>
#define vvi vector<vector<int>>
#define forn(it,from,to) for(int (it)=from; (it)<to; (it)++)
const int  Inf = 2 * 1000 * 1000 * 1000;
ll LINF = (ll)4e18;
using namespace std;
#define M_PI       3.14159265358979323846   // pi

const int nax = 3005;

ld D[nax][2];
ld now[nax][2];

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
	//freopen("sum.in", "r", stdin);
	//freopen("sum.out", "w", stdout);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	vector<vector<ld>>a(n, vector<ld>(2));
	for (int i = 0; i < n; i++) {
		cin >> a[i][0];
		a[i][1] = 1.0 - a[i][0];
	}

	D[1][0] = a[0][0];
	D[0][1] = a[0][1];

	for (int i = 1; i < n; i++) {
		for (int j = 0; j < n; j++) {
			for (int k = 0; k < 2; k++) {
				now[j][0] += D[j][k] * a[i][1];
				now[j + 1][1] += D[j][k] * a[i][0];
			}
		}
		memcpy(D, now, sizeof(now));
		memset(now, 0, sizeof(now));
	}
	ld ans = 0.0;

	for (int j = (n + 1) / 2; j <= n; j++) ans += D[j][0] + D[j][1];
	cout << setprecision(10) << fixed << ans;
 	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include<queue>
#include <stack>
#include <string.h>
#include <algorithm>
using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	if ((a*b) % 2 == 1)cout << "Yes";
	else cout << "No";
	return 0;
}

Measured memory_bytes: 256
import sys
from collections import deque
def tsort(n,g,inc):
    s,tsl=deque(),[]
    s.extend([i for i,x in enumerate(inc) if x==0])
    while len(s)>0:
        x=s.popleft()
        tsl.append(x)
        for y in g[x]:
            inc[y]-=1
            if inc[y]==0:s.append(y)
    return tsl
def main():
    N,M=tuple(map(int,sys.stdin.readline().split()))
    lpl,inc,g=[0 for _ in range(N)],[0 for _ in range(N)],[[] for _ in range(N)]
    for _ in [0]*M:
        x,y=tuple(map(int,sys.stdin.readline().split()))
        inc[y-1]+=1
        g[x-1].append(y-1)
    tsl=tsort(N,g,inc)
    for t in tsl:
        for n in g[t]:lpl[n]=lpl[t]+1 if lpl[t]+1>lpl[n] else lpl[n]
    print(max(lpl))
if __name__=='__main__':main()

Measured memory_bytes: 94624
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<cmath>
#include<queue>
#include<limits>
#include<cassert>
#include<set>
#include<tuple>
#include<map>
#include<list>

#define PB push_back
#define ALL(a)  (a).begin(),(a).end()
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define mod 1000000007

using namespace std;
typedef long long ll;

int main() {
	int n;
	cin >> n;
	vector<int> a(n), b(n);
	REP(i, n) {
		cin >> a[i];
		b[i] = abs(i - (n - i - 1)); //n=7のとき (6 4 2 0 2 4 6)
	}
	sort(ALL(a)); //比べるためのソート
	sort(ALL(b));
	if (a != b) { //aとbの配列が異なる
		cout << 0 << endl;
		return 0;
	}
	ll ans = 1LL;
	REP(i, n / 2) { //2^(n / 2)
		ans *= 2;
		ans %= mod;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024