akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;


public class Main{
	
	static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    }
	public static void main(String[] args) 
	{
		OutputStream outputStream = System.out;
        FastReader sc = new FastReader();
        PrintWriter out = new PrintWriter(outputStream);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int h[] = new int[n];
        for(int i = 0; i < n; i++) h[i] = sc.nextInt();
        
        int dp[] = new int[n];
        
        dp[0] = 0;
        int min = Integer.MAX_VALUE;
        for(int i = 1; i < n; i++)
        {	
        	min = Integer.MAX_VALUE;
        	for(int j = 1; j <= k; j++)
        	{	
        		if(i-j >= 0)
        		{
        			min = Math.min(min,dp[i-j]+Math.abs(h[i]-h[i-j]));
        		}
        		else
        		{
        			break;
        		}
        	}
        	dp[i] = min;
        }
        
        out.println(dp[n-1]);
        out.close();
	}

}


Measured memory_bytes: 33032
scr s1 ss s n
  = s1 * n + ss * (n `div` s)

ans (l1:l2:l3:_) =
  let [h1,h2] = l1
      [k1,k2] = l2
      [a,b,c,d] = l3
      h = (scr a c 10 h1) + (scr b d 20 h2)
      k = (scr a c 10 k1) + (scr b d 20 k2)
  in
    if h == k
    then "even"
    else if h > k
         then "hiroshi"
         else "kenjiro"

main = do
  c <- getContents
  let i = map (map read) $ map words $ lines c :: [[Int]]
      o = ans i
  putStrLn o

Measured memory_bytes: 3688
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var n = ReadInt();
        long sum = 0;
        var numCounts = new SortedList<int, long>();
        foreach (var a in ReadInts())
        {
            if (!numCounts.ContainsKey(a))
            {
                numCounts.Add(a, 0);
            }

            numCounts[a] += 1;
            sum += a;
        }


        var q = ReadInt();
        var results = new List<long>();

        for (int i = 0; i < q; i++)
        {
            var inputs = ReadInts();
            var b = inputs[0];
            var c = inputs[1];

            if (numCounts.ContainsKey(b))
            {
                var hit = numCounts[b];

                var change = (c - b) * hit;
                sum += change;

                numCounts.Remove(b);
                if (!numCounts.ContainsKey(c))
                {
                    numCounts.Add(c, 0);
                }

                numCounts[c] += hit;
            }

            results.Add(sum);
        }

        foreach (var result in results)
        {
            Console.WriteLine(result);
        }
    }


    private static string Read() => Console.ReadLine();
    private static char[] ReadChars() => Array.ConvertAll(Read().Split(), a => a[0]);
    private static int ReadInt() => int.Parse(Read());
    private static long ReadLong() => long.Parse(Read());
    private static double ReadDouble() => double.Parse(Read());
    private static int[] ReadInts() => Array.ConvertAll(Read().Split(), int.Parse);
    private static long[] ReadLongs() => Array.ConvertAll(Read().Split(), long.Parse);
    private static double[] ReadDoubles() => Array.ConvertAll(Read().Split(), double.Parse);
}

Measured memory_bytes: 46008
N, M = map(int, input().split())
A = sorted([int(i) for i in input().split()])
C = sorted([[int(i) for i in input().split()] for i in range(M)], reverse = True, 
           key = lambda x: x[1])

cnt = 0
B = []
for i in range(M):
    if cnt > N:
        break
    B += [C[i][1]] * C[i][0]
    cnt += C[i][0]
    
B.sort(reverse = True)

x = min(N, len(B))

for i in range(x):
    A[i] = max(A[i], B[i])
    
print(sum(A))

Measured memory_bytes: 89880
#include<deque>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<cmath>
#include<cstring>
using namespace std;
int a[4],b[4],c[4][4]={};
int fn(int p,int q){
  int i;
  int ct=0;
  if(0){
  }else if(q==4){
    ct=1;
  }else if(c[q][p]){
    ct+=fn(p==3?0:p+1,p==3?q+1:q);
  }else{
    c[q][p]=-1;
    for(i=0;i<4;i++){
      if(0<=p+a[i]&&p+a[i]<4&&0<=q+b[i]&&q+b[i]<4&&c[q+b[i]][p+a[i]]==0){	
	c[q+b[i]][p+a[i]]=-1;
	ct+=fn(p==3?0:p+1,p==3?q+1:q);
	c[q+b[i]][p+a[i]]=0;
      }
    }
    c[q][p]=0;
  }
  return ct;
}
int main(){
  int i;
  for(;;){
    for(i=0;i<4;i++)
      cin>>a[i]>>b[i];
    if(a[0]>4)
      break;
    cout<<fn(0,0)<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
#define MAX 100005
#define MOD 1000000007
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define vi vector<int>
#define ii pair<int,int>
#define vii vector<ii>
#define si set<int>
#define mp map<ll,ll>
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int main()
{ 
	fast 
	ll n,a[MAX],b[MAX],c[MAX],dpa[MAX],dpb[MAX],dpc[MAX],i,j;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>a[i]>>b[i]>>c[i];
	}
	dpa[0]=a[0];
	dpb[0]=b[0];
	dpc[0]=c[0];
	for(i=1;i<n;i++)
	{
		dpa[i]=a[i]+max(dpb[i-1],dpc[i-1]);
		dpb[i]=b[i]+max(dpa[i-1],dpc[i-1]);
		dpc[i]=c[i]+max(dpa[i-1],dpb[i-1]);
	}
	ll ans=max(dpa[n-1],max(dpb[n-1],dpc[n-1]));
	cout<<ans;


}

Measured memory_bytes: 4992
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

class Main{
    public static void main(String[] args) throws IOException{
        final PrintWriter out = new PrintWriter(System.out);
        final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        final int n = Integer.parseInt(br.readLine());
        final String[] bCard = br.readLine().split(" ");
        final String[] sCard = new String[bCard.length];
        System.arraycopy(bCard, 0, sCard, 0, sCard.length);

        bubbleSort(bCard);
        out.print(bCard[0]);
        for(int i = 1; i<n; i++){
            out.print(' ');
            out.print(bCard[i]);
        }
        out.println();
        out.println("Stable");
        stableSort(sCard);
        out.print(sCard[0]);
        for(int i = 1; i<n; i++){
            out.print(' ');
            out.print(sCard[i]);
        }
        out.println();
        out.println(isSame(bCard, sCard) ? "Stable" : "Not stable");
        out.flush();
    }
    private static void bubbleSort(String[] a){
        final int n = a.length;
        for(int i = 0; i<n; i++){
            for(int j = n-1; j>i; j--){
                if(a[j].charAt(1)<a[j-1].charAt(1)){
                    final String t = a[j];
                    a[j] = a[j-1];
                    a[j-1] = t;
                }
            }
        }

    }
    private static void stableSort(String[] a){
        final int n = a.length;
        for(int i = 0; i<n; i++){
            int mini = i;
            for(int j = i+1; j<n; j++){
                if(a[j].charAt(1)<a[mini].charAt(1)) mini = j;
            }
            if(i!=mini){
                final String t = a[i];
                a[i] = a[mini];
                a[mini] = t;
            }
        }
    }
    private static boolean isSame(String[] a, String[] b){
        if(a.length!=b.length) return false;
        final int n = a.length;
        for(int i = 0; i<n; i++){
            if(a[i]!=b[i]) return false;
        }
        return true;
    }
}

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

using namespace std;

int main()
{
    int n, m, c;
    cin>>n>>m>>c;
    int b[m];
    for(int i=0; i<m; i++) cin>>b[i];
    int ans =0;
    for(int t=0; t<n; ++t){
        int cur=0;
        for(int i=0;i<m; i++){
            int x;
            cin>>x;
            cur+=(x*b[i]);
        }

        ans+=(cur+c > 0  ? 1 : 0);
    }
    cout<<ans;
    return 0;
}

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

int main()
{

    ll m, k;
    cin>>m>>k;


    if(k>((ll)(pow(2,m))+0.5)-1)
    {    cout<<-1;
        return 0;
    }
    else
    {
        if(m==1)
        {
            if(k==1)
            {
                cout<<-1;
                return 0;
            }
            else
                cout<<"0 0 1 1"<<endl;
        }
        else
        {
        ll a, b;

        ll e=(ll)(pow(2,m)+0.5)-1;
        for(int i=0;i<=e;i++)
        {
            if(i!=k)
            cout<<i<<" ";

        }
        cout<<k<<" ";
        for(int i=e;i>=0;i--)
        {
            if(i!=k)
            cout<<i<<" ";

        }
        cout<<k<<" ";
        }
    }
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll mod=1000000007;
ll MOD=998244353;
int inf=1000001000;
ll INF=100000000000000000;


int main() {
    int n;
    cin >> n;
    vector<int> a(n),b(n);
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];
    vector<pp> aa(n),bb(n);
    rep(i,n){
        aa[i]=mk(a[i],i);
        bb[i]=mk(b[i],i);
    }
    sort(all(aa));
    sort(all(bb));
    rep(i,n){
        if (aa[i].first>bb[i].first) {cout << "No" << endl;return 0;}
    }
    int e=n,x=0;
    vector<int> g(n),gg(n);
    rep(i,n) {
        g[aa[i].second]=i;
        gg[i]=bb[i].second;
    }
    while(true){
        // cout << x << endl;
        if (gg[g[x]]==0) break;
        x=gg[g[x]];
        e--;
    }
    if (e>1) {cout << "Yes" << endl;return 0;}
    rep(i,n-1){
        if (aa[i+1].first<=bb[i].first) {cout << "Yes" << endl;return 0;}
    }
    cout << "No" << endl;
}


Measured memory_bytes: 3328
/*
 *  Author : Jun_SH
 *  Solution for ABC 140 D
 */
#include<bits/stdc++.h>
#define int long long
#define sd(a) scanf("%lld",&a)
using namespace std;
const int inf=0x3f3f3f3f;
main(){
    int n,k;
    string s;
    cin>>n>>k;
    cin>>s;
    int beg=0;
    for(int i=0;i<s.length()-1;++i){
        int len=1;
        while(i<s.length()-1&&s[i]==s[i+1]){
            i++;
            len++;
        }
        beg+=len-1;
    }
    while(k--)
        beg+=2;
    cout<<min(beg,n-1)<<endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
typedef long long ll;
using namespace std;

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

    int N_ = N;
    vector<int> n;
    int p = 1000;
    for (int i=0; i<4; ++i) {
        n.push_back(N_ / p);
        N_ = N_ % p;
        p = p / 10;
    }

    
    int s = n.size() - 1;
    bool flag = false;
    string res;
    for (int bit=0; bit < (1<<s); ++bit) {
        int sum = n[0];
        vector<char> ans;
        for (int i=0; i<s; ++i) {
            if (bit & (1<<i)) {
                sum += n[i+1];
                ans.push_back('+');
            } else {
                sum -= n[i+1];
                ans.push_back('-');
            }
        }
        //cout << sum << endl;
        if (sum == 7) {
            res = n[0] + '0';
            for (int i=0; i<3; ++i) {
                res.push_back(ans[i]);
                res.push_back(n[i+1] + '0');
            }
            res += "=7";
            flag = true;
            break;
        }
    }
    
    if (flag) cout << res << endl;
}

Measured memory_bytes: 256
list_ab = []
n = int(input())
for i in range(n):
    list_ab.append(list(map(int, input().split())))

j = n - 1
ad = 0
while j >= 0:
    list_ab[j][0] += ad
    if list_ab[j][0] % list_ab[j][1] == 0:
        j -= 1
    else:
        ad += list_ab[j][1] * (list_ab[j][0] // list_ab[j][1] + 1) - list_ab[j][0]
        j -= 1
print(ad)


Measured memory_bytes: 31348
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define pb push_back

# define inOut(a,b) freopen(a,"r",stdin);freopen(b,"w",stdout);
# define RESET(a) memset(a,0,sizeof(a))
# define MEMO(a) memset(a,-1,sizeof(a))
# define DEBUG puts("Debug-Has-Come-Until-Here")


typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

int main(){
	cin.tie(NULL);

	int i,j;
	for (i=1; i<=9; i++){
		for (j=1; j<=9; j++){
			printf("%dx%d=%d\n", i,j, i*j);
		}
	}
	return 0;
}

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

int main(void){
  int r,g,b,k;

  cin >> r >> g >> b >> k;
  int temp1, temp2;
  int num = 0;
  for(int x=0;x<k+1;x++){
    if(x*r > k)
      continue;
    temp1 = k - r*x;
    for(int y=0;y<temp1+1;y++){
      if(y*g > temp1)
        continue;
      temp2 = temp1 - g*y;
      if (temp2 % b == 0){ 
          //cout << "x:"<<x<< " y:" << y << " z:" << z << endl;
          //cout << '\n';
          num++;
      }   
    }   
  }
  cout <<  num << endl;
}


Measured memory_bytes: 256
package main

import "fmt"

const nmax = 1000000
const mod = int(1e9) + 7

var fac, finv, inv [nmax]int

func comInit() {
	fac[0] = 1
	fac[1] = 1
	finv[0] = 1
	finv[1] = 1
	inv[1] = 1
	for i := 2; i < nmax; i++ {
		fac[i] = fac[i-1] * i % mod
		inv[i] = mod - inv[mod%i]*(mod/i)%mod
		finv[i] = finv[i-1] * inv[i] % mod
	}
}
func comGet(n, k int) int {
	if n < k {
		return 0
	}
	if n < 0 || k < 0 {
		return 0
	}
	return fac[n] * (finv[k] * finv[n-k] % mod) % mod
}

func main() {
	var X, Y int
	fmt.Scan(&X, &Y)
	ans := 0
	if (2*Y-X)%3 == 0 && (2*X-Y)%3 == 0 {
		// 整数解が存在する
		m := (2*Y - X) / 3
		n := (2*X - Y) / 3
		// fmt.Println("m", m, "n", n)
		// 片方の動かし方をm回、もう片方の動かし方をn回行う
		// m+nCm (%mod)を求める
		comInit()
		ans = comGet(m+n, m)
	}
	fmt.Println(ans)
}


Measured memory_bytes: 23936
N=int(input())

seq=[]

for i in range(N):
    a= int(input())
    seq.append(a)

import heapq

tmp=list(map(lambda x: x*(-1),seq))
heapq.heapify(tmp)

a=heapq.heappop(tmp)*(-1)
b=heapq.heappop(tmp)*(-1)

for j in range(N):
    if seq[j]==a:
        print(b)
    else:
        print(a)

Measured memory_bytes: 84516
package main

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

func main() {
	scan := bufio.NewScanner(os.Stdin)
	scan.Split(bufio.ScanWords)
	scan.Scan()
	s, _ := strconv.Atoi(scan.Text())

	a := s / 100
	b := s % 100
	if 0 < a && 0 < b && a <= 12 && b <= 12 {
		fmt.Println("AMBIGUOUS")
	} else if a <= 12 && a > 0 {
		fmt.Println("MMYY")
	} else if b <= 12 && b > 0 {
		fmt.Println("YYMM")
	} else {
		fmt.Println("NA")
	}
}


Measured memory_bytes: 640
# なんか適当にdpをこねくりまわす
# （どうしてできたんだろうね)

h = int(input())

dp = {}
dp[1] = 1


def f(x):
    if x in dp:
        return dp[x]
    if x == 1:
        return 1
    tmp = f(x // 2) + 1
    dp[x] = tmp
    tmp += tmp - 1
    return tmp


print(f(h))



Measured memory_bytes: 3060
#define _GLIBCXX_DEBUG
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
  ll a,b,c,d; cin >>a>>b>>c>>d;
  cout <<max(a*c,max(a*d,max(b*c,b*d)))<<endl;
}

Measured memory_bytes: 3632
#include <stdio.h>

int main(void) {
    int year, month, day;
    scanf("%d%*[-/]%d%*[-/]%d", &year, &month, &day);

    const int score = year * 10000
        + month * 100
        + day
        ;   

    printf(score <= 20190430 ? "Heisei" : "TBD");
    return 0;
}


Measured memory_bytes: 128
#include<algorithm>
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

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; }

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

    int X, Y;
    cin >> X >> Y;

    reple(i, 0, X)
    {
        if (Y == 2 * i + 4 * (X - i))
        {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3652
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
 Scanner sc = new Scanner(System.in);
 
for(int k=0;;k++){

 int H=sc.nextInt();
 int W=sc.nextInt();
 if(H==0&&W==0){
break;
 }
 for(int i=0;i<H;i++){

    if(i==0||i==H-1){
        for(int j=0;j<W;j++){
            System.out.print("#");
        }
    }else{
for(int j=0;j<W;j++){
    if(j==0||j==W-1){
        System.out.print("#");
    }else{
        System.out.print(".");
    }
}
 }
 System.out.println();
}

System.out.println();
}
 sc.close();
    }
}


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

typedef long long int ll;

ll M = 1000000007;

ll fac[2005];

/* Iterative Function to calculate (x^y)%p 
  in O(log y) */
ll power(ll x, ll y, ll p) 
{ 
    ll res = 1;      // Initialize result 
  
    x = x % p;  // Update x if it is more than or 
                // equal to p 
  
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x) % p; 
  
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x) % p; 
    } 
    return res%p; 
} 

// Returns n^(-1) mod p 
ll modInverse(ll n, ll p) 
{ 
    return power(n, p-2, p); 
} 
  
// Returns nCr % p using Fermat's little 
// theorem. 
ll nCrModPFermat(ll n, ll r, ll p) 
{ 
   // Base case 
   	if (r==0) 
      return 1; 

  	// cout << fac[n] << '\n';


	// Fill factorial array so that we 
	// can find all factorial of r, n 
	// and n-r 

	return (fac[n]* modInverse(fac[r], p) % p * 
	        modInverse(fac[n-r], p) % p) % p; 
} 

int main()
{
	ll i,j,k,l,m,n,t;

	ll u,v;

	fac[0] = 1; 
    for (ll i=1 ; i<=2001; i++)
    {
        fac[i] = fac[i-1]*i%M; 
        // cout << fac[i] << '\n';
    }

	cin >> n;

	ll ans = 0;

	for(i=1;i<=n/3;i++)
	{
		l = n-3*i;
		k = nCrModPFermat(l+i-1,i-1,M);

		// cout << l << " " << k << '\n';

		ans = ans%M + k%M;
		ans = ans%M;

	}

	cout << ans%M << '\n';

	

}

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

int main(){
    int x,y,z,k;
    cin>>x>>y>>z>>k;
    vector<ll>a(x),b(y),c(z);
    rep(i,x)cin>>a[i];
    rep(i,y)cin>>b[i];
    rep(i,z)cin>>c[i];
    vector<ll>sum;
    rep(i,x)rep(j,y){
        sum.push_back(a[i]+b[j]);
    }
    sort(sum.rbegin(),sum.rend());
    vector<ll>ans;
    rep(i,min(k,x*y)){
        rep(j,z){
            ans.push_back(sum[i]+c[j]);
        }
    }
    sort(ans.rbegin(),ans.rend());
    rep(i,k)cout<<ans[i]<<endl;
}

Measured memory_bytes: 44100
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                  as A
import qualified Data.Array.ST               as ST
import qualified Data.Array.Unboxed          as AU
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.Int
import qualified Data.IntMap                 as IM
import           Data.List
import qualified Data.Map                    as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Set                    as S
import           Data.Time
import qualified Data.Vector                 as V
import qualified Data.Vector.Mutable         as VM
import qualified Data.Vector.Unboxed         as VU
import qualified Data.Vector.Unboxed.Mutable as VUM

readInt :: IO [Int]
readInt = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

readInts :: Int -> IO [[Int]]
readInts n = replicateM n readInt

readInteger :: IO [Integer]
readInteger = map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine

readIntegers :: Int -> IO [[Integer]]
readIntegers n = replicateM n readInteger

readString :: IO [String]
readString = map BS.unpack . BS.words <$> BS.getLine

readStrings :: Int -> IO [[String]]
readStrings n = replicateM n <$> readString

toPair :: [a] -> (a, a)
toPair [x, y] = (x, y)

count :: Eq a => a -> [a] -> Int
count a as = length $ filter (== a) as

main = do
  [n, k] <- readInt
  let (a, b) = n `divMod` k
   in print $ min b (k - b)


Measured memory_bytes: 380
program Project1;
{$APPTYPE CONSOLE}
uses
  SysUtils;
var
  a,h,w,i,j,count,x,y,sw,m,n,b,c,soeji,sum,max,k,d:Integer;
  l:array of Integer;
  s,s123,s1,s2,s3:string;
  al:string = 'abcdefghijklmnopqrstuvwxyz';
  tf,tfl,tfr:Boolean;
begin
  try
    { TODO -oUser -cConsole メイン : ここにコードを記述してください }
    Read(a);
    Read(b);
    Read(c);
    Readln(d);
    tf:=True;

    if ((abs(b-a) <= d)and(abs(c-b) <= d))or(abs(c-a) <= d) then
      Writeln('Yes')
    else
      Writeln('No');

    Readln;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.


Measured memory_bytes: 128
//
//  D.cpp
//  CodeForcesProblems
//
//  Created by Jacob Murry on 1/6/20.
//  Copyright © 2020 Jacob Murry. All rights reserved.
//

//#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

//top down solution
struct Solution {
    vector<long long> &wt, &vals;
    Solution(vector<long long> &w, vector<long long> &v, long long W, long long N) : wt(w), vals(v) {
        vector<long long> memo_row(W+1, -1);
        vector<vector<long long> > memo(N+1, memo_row);
        long long answer = dp(memo, W, N);
        cout << answer << "\n";
    }
    
    //take nth item or not
    long long dp(vector<vector<long long> > &memo, long long W, long long N) {
        //base case negative weight or 0 items left
        if(W<=0)
            return 0;
        if(N<=-1)
            return 0;
        //see if subproblem has been solved
        if(memo[N][W]!=-1)
            return memo[N][W];
        //if nth item cant be included
        if(wt[N]>W)
            return dp(memo, W, N-1);
        //include Nth item or not
        long long included = dp(memo, W-wt[N], N-1)+vals[N];
        long long notincluded = dp(memo, W, N-1);
        long long result = max(included, notincluded);
        memo[N][W] = result;
        return result;
    }
    
};

int main(int argc, char * argv[]) {
    long N, W;
    cin >> N >> W;
    vector<long long> weights(N);
    vector<long long> values(N);
    for(long long i=0; i<N; ++i) {
        cin >> weights[i] >> values[i];
    }
    Solution sol(weights, values, W, N-1);
    
    return 0;
}


Measured memory_bytes: 79488
#include <bits/stdc++.h>
using namespace std;
	 
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define cout_precision cout.setf(ios::fixed); cout.precision(32);
#define clr(a) memset(a,0,sizeof(a))
#define umap unordered_map
#define uset unordered_set
#define fr first
#define sc second
#define pb push_back
#define M int(1e9+7)
#define endl '\n'	
#define largest(a,b,c) (a>b?(a>c? a:c):(b>c? b:c))
#define smallest(a,b,c) (a<b?(a<c? a:c):(b<c? b:c))	

using ll = int64_t; using vll = vector<ll>; using vvll = vector<vll>;
using pll = pair<ll, ll>; using vpll = vector<pll>; using vvpll = vector<vpll>;

 
int main(){
	fast_io; cout_precision;
	string str;	cin >> str;
	int count = 0;
	if(str[0] == 'R')	count++;
	for(int i=1; i<3; i++){
		if(str[i] == 'R'){
			if(str[i] != str[i-1])	count = 1;
			else	count++;
		}
	}
	cout << count <<endl;
	return 0;
}


Measured memory_bytes: 3636
import re

def solve(s, t):
    s = s.replace('?', '.')
    ls, lt = len(s), len(t)

    if(ls < lt):
        return 'UNRESTORABLE'

    ans = []
    for i in range(ls - lt + 1):
        result = re.match(s[i:i + lt], t)
        if result is None:
            continue
        ans.append((s[:i] + t + s[i + lt:]).replace('.', 'a'))

    if not ans:
        return 'UNRESTORABLE'
    return min(ans)

s = input()
t = input()

print(solve(s, t))

Measured memory_bytes: 3316
use strict;
use warnings;

my $str = <STDIN>;
chomp $str;

my $length      = length($str) ;
my @str_array   = split(q{}, $str);
my @str_reverse = reverse @str_array;

my $count = 0;

for (my $i = 0; $i < $length; $i++) {
    $count += 1 if $str_array[$i] ne $str_reverse[$i]
}

print $count/2;

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define int  long long int
int32_t main(){
int n;
cin>>n;
int arr[n];
for(int i=0;i<n;i++)
    cin>>arr[i];
int l[n];
int r[n];
for(int i=0;i<n;i++) {
			if(i==0) {
				l[0]=arr[0];
				r[n-1]=arr[n-1];
			}
			else {
				l[i]=l[i-1]+arr[i];
				r[n-i-1]=r[n-i]+arr[n-i-1];
			}
		}
		//display(l);
		//display(r);
		int minn=INT_MAX;
		for(int i=0;i<n-1;i++) {
			minn=min(minn,abs(l[i]-r[i+1]));
		}
			cout<<minn<<endl;
return 0;
		}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
char g[] = {97,102,107,112,117,122,98,103,108,113,118,46,99,104,109,114,119,63,100,105,110,115,120,33,101,106,111,116,121,32};
string s,a;
while(cin>>s,!cin.eof()){
a = "";
for(int i = 0;i < s.size();i += 2){
int l = s[i] - '0', r = s[i+1] - '0';
if(s.size() % 2 || l < 1 || r < 1 || l > 6 || r > 5){a = "NA";break;}
a += g[r * 6 + l - 7];
}
cout << a << '\n';
}	
}

Measured memory_bytes: 0
moji_lis = [[".",",","!","?"," "],["a","b","c"],["d","e","f"],["g","h","i"],["j","k","l"],["m","n","o"],["p","q","r","s"],["t","u","v"],["w","x","y","z"]]
n = int(input())
for i in range(n):
    N_lis = list(input())
    N_lis = list(map(int,N_lis))
    
    a_0 = N_lis[0]
    n_num = 1
    moji = ""
    for j in range(1,len(N_lis)):

        a_1 = N_lis[j]
        
        if a_0 == a_1:
            n_num += 1
        else:
            if a_0 == 1:
                moji += moji_lis[0][(n_num - 1) % 5]
                
            elif a_0 == 7 or a_0 == 9:
        
                moji += moji_lis[a_0 - 1][(n_num - 1) % 4]
           
                
            elif a_0 != 0:
  
                moji += moji_lis[a_0 - 1][(n_num - 1) % 3]
                
        a_0 = a_1
        if a_1 == 0:
            n_num = 1
    print(moji)

Measured memory_bytes: 7668
import sys
import re
import math
import collections
import decimal
import bisect
import itertools

import copy

# import heapq
# from collections import deque
# import decimal

# sys.setrecursionlimit(100001)
INF = sys.maxsize
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    n = ni()
    a = na()
    b = na()

    if sum(a) < sum(b):
        print(-1)
        exit(0)

    d = []
    for ai, bi in zip(a, b):
        d.append(ai - bi)

    d.sort()
    poor = 0
    ans_cnt = 0
    for di in d:
        if di < 0:
            ans_cnt += 1
            poor += di

    d.sort(reverse=True)
    for di in d:
        if poor < 0:
            poor += di
            ans_cnt += 1
        else:
            break

    print(ans_cnt)


if __name__ == '__main__':
    main()


Measured memory_bytes: 20244
def main():
    N = int(input())
    books = []
    for i in range(N):
        title, author, date = input().split()
        date = list(map(int, date.split('/')))
        books.append((title, author, date))

    Q = int(input())
    for i in range(Q):
        title, author, date_from, date_to = input().split()
        if date_from != '*':
            date_from = list(map(int, date_from.split('/')))
        if date_to != '*':
            date_to = list(map(int, date_to.split('/')))

        resp = books[:]
        resp = [book for book in resp if title == '*' or title in book[0]]
        resp = [book for book in resp if author == '*' or author in book[1]]
        resp = [book for book in resp if date_from == '*' or date_from <= book[2]]
        resp = [book for book in resp if date_to == '*' or date_to >= book[2]]

        for book in resp:
            print(book[0])

        if i+1 < Q:
            print()

main()



Measured memory_bytes: 5632
#include<stdio.h>
#include<string.h>

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(char ch){
  if(ch=='A') return 1;
  else if(ch=='C') return 2;
  else if(ch =='G') return 3;
  else if(ch=='T') return 4;
  else return 0;
}

long long getKey(char str[]){
  long long sum=0,p=1,i;
  for(i=0;i<strlen(str);i++){
    sum+= p*(getChar(str[i]));
    p*=5;
  }
  return sum;
}

int h1(int key){return key % M;}
int h2(int key){return 1+(key%(M-1));}

int find(char str[]){
  long long key,i,h;
  key=getKey(str);
  for(i=0;;i++){
    h=(h1(key)+i*h2(key))%M;
    if(strcmp(H[h],str)==0) return 1;
    else if(strlen(H[h])==0) return 0;
  }
  return 0;
}

int insert(char str[]){
  long long key,i,h;
  key=getKey(str);
  for(i=0;;i++){
    h=(h1(key)+i*h2(key))%M;
    if(strcmp(H[h],str)==0) return 1;
    else if(strlen(H[h])==0){
      strcpy(H[h],str);
      return 0;
    }
  }
  return 0;
}

int main(){
  int i,n,h;
  char str[L],com[9];
  for(i=0;i<M;i++) H[i][0]='\0';
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s %s",com,str);

    if(com[0]=='i'){
      insert(str);
    }else{
      if(find(str)){
	printf("yes\n");
      }else{
	printf("no\n");
      }
    }
  }
  return 0;
}

Measured memory_bytes: 14916
S = input()
months = [i for i in range(1, 13)]
left = int(S[:2])
right = int(S[2:])
if left in months and right in months:
    print('AMBIGUOUS')
elif left in months:
    print('MMYY')
elif right in months:
    print('YYMM')
else:
    print('NA')

Measured memory_bytes: 3060
#include <iostream>
#include <string>
using namespace std;
 
int main (){
 
  int h,w;
  cin >> h >> w;
 
  string a[101],ac[101];
 
  for(int i=0;i<h;i++) {
    cin >> a[i];
    ac[i] = a[i];
  }
 
  int b[101][101];
  for(int i=0;i<h;i++) 
    for(int j=0;j<w+1;j++) 
      b[i][j]  = -1;
 
  for(int i=0;i<=h;i++)
    for(int j=0;j<=w;j++) 
      if(a[i][j] =='c') b[i][j] = 0;
 
 
  for(int i=0;i<=h;i++) {
    for(int j=0;j<w;j++){
 
      for(int k=0;k < w;k++) if(a[i][k] == 'c' && b[i][k] == -1) b[i][k] = j;
 
      for(int k =1;k<=w;k++) a[i][k] = ac[i][k-1];
      a[i][0] = '.';
      ac[i] = a[i];
    }
  }
 
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++) {
      cout << b[i][j];
      if(j != w-1) cout << " ";
    }
    cout << endl;
  }
 
 
 
  return 0;
}

Measured memory_bytes: 1284
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
const ll N=1e3+2;
const ll md=1e9+7;
ll dp[N][N],n,m,ar[N][N];

int main(){
ll i,j,k;   char ch;
memset(dp,0,sizeof(dp));
cin>>n>>m;
for(i=1;i<=n;i++){
    for(j=1;j<=m;j++){
        cin>>ch;
        if(ch=='#')
            dp[i][j]=-1;
    }
}
dp[1][1]=1;
for(i=1;i<=n;i++){
    for(j=1;j<=m;j++){
        if(!(i==1 && j==1) && dp[i][j]!=-1)
            dp[i][j]=(dp[i-1][j]*(dp[i-1][j]!=-1)+dp[i][j-1]*(dp[i][j-1]!=-1))%md;
    }
}
cout<<dp[n][m]<<"\n";
    return 0;
}

Measured memory_bytes: 9856
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
class Main {
	public static void main(String...args)throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int times = Integer.valueOf(br.readLine());
		int[] result = new int[2];
		for(int i = 0; i < times; i++) {
			String[] animals = br.readLine().split(" ");
    		if(animals[0].compareTo(animals[1]) == 0) {
    			result[0] += 1;
    			result[1] += 1;
    		} else if(animals[0].compareTo(animals[1]) >= 1) {
    			result[0] += 3;
    		} else if(animals[0].compareTo(animals[1]) <= -1) {
    			result[1] += 3;
    		}
		}
		System.out.println(result[0] + " " + result[1]);
	}
}


Measured memory_bytes: 25536
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <deque>
using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;



int main(){
  int n;
  string s;
  cin >> n >> s;
  int animal[n+2];

  animal[0] = -1;
  animal[1] = -1;
  REP(i,n){
    if(s[i] == 'o'){
      animal[i+2] = animal[i+1] * animal[i];
    }else{
      animal[i+2] = animal[i+1] * animal[i] * -1;
    }
  }
  if(animal[0] == animal[n] && animal[1] == animal[n+1]){
    REP(i,n){
      if(animal[i+1] == 1) cout << "S";
      else cout << "W";
    }
    cout << endl;
    return 0;
  }

  animal[0] = 1;
  animal[1] = -1;
  REP(i,n){
    if(s[i] == 'o'){
      animal[i+2] = animal[i+1] * animal[i];
    }else{
      animal[i+2] = animal[i+1] * animal[i] * -1;
    }
  }
  if(animal[0] == animal[n] && animal[1] == animal[n+1]){
    REP(i,n){
      if(animal[i+1] == 1) cout << "S";
      else cout << "W";
    }
    cout << endl;
    return 0;
  }

  animal[0] = -1;
  animal[1] = 1;
  REP(i,n){
    if(s[i] == 'o'){
      animal[i+2] = animal[i+1] * animal[i];
    }else{
      animal[i+2] = animal[i+1] * animal[i] * -1;
    }
  }
  if(animal[0] == animal[n] && animal[1] == animal[n+1]){
    REP(i,n){
      if(animal[i+1] == 1) cout << "S";
      else cout << "W";
    }
    cout << endl;
    return 0;
  }

  animal[0] = 1;
  animal[1] = 1;
  REP(i,n){
    if(s[i] == 'o'){
      animal[i+2] = animal[i+1] * animal[i];
    }else{
      animal[i+2] = animal[i+1] * animal[i] * -1;
    }
  }
  if(animal[0] == animal[n] && animal[1] == animal[n+1]){
    REP(i,n){
      if(animal[i+1] == 1) cout << "S";
      else cout << "W";
    }
    cout << endl;
    return 0;
  }

  cout << -1 << endl;


  return 0;
}


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

int main() {

    int64_t X ;

    cin >> X ;

    int64_t ans;

    int64_t yen = 100;

    for (int64_t i = 0 ; i <X ; i++){

        yen = yen * 1.01;

        if(yen >= X){cout << i+1 << endl;
                     break;}

    }
}


Measured memory_bytes: 3624
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int mod = 998244353;
const int IMAX = 300300;
constexpr ll modpow(ll A, ll B) {
	ll kotae = 1;
	while (B > 0) {
		if (B & 1) kotae = kotae * A % mod;
		A = A * A % mod;
		B >>= 1;
	}
	return kotae;
}
class unko {
public:
	int fac[IMAX + 1], ifac[IMAX + 1], inv[IMAX + 1];
	constexpr unko() : fac(), ifac(), inv() {
		fac[0] = 1;
		rep1(i, IMAX) fac[i] = ll(fac[i - 1]) * i % mod;
		ifac[IMAX] = modpow(fac[IMAX], mod - 2);
		for (int i = IMAX; i > 0; i--) ifac[i - 1] = ll(ifac[i]) * i % mod;
		inv[0] = 1;
		rep1(i, IMAX) inv[i] = ll(ifac[i]) * fac[i - 1] % mod;
	}
	int comb(int A, int B) {
		return ll(fac[A]) * ifac[B] % mod * ifac[A - B] % mod;
	}
} f;

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


	ll N, A, B, K;
	scanf("%lld %lld %lld %lld", &N, &A, &B, &K);

	if (K == 0) {
		printf("1\n");
		return 0;
	}

	ll GCD = __gcd(A, B);
	if (K % GCD) {
		printf("0\n");
		return 0;
	}

	A /= GCD;
	B /= GCD;
	K /= GCD;

	if (A < B) swap(A, B);

	ll hajime = max(0ll, (K - N * B + A - 1) / A);
	ll owari = min(N, K / A);
	const int b = B;

	ll kotae = 0;
	K -= hajime * A;
	if (b != 1) {
		for (int i = hajime; i <= owari; i++) {
			if (K % b == 0) {
				int j = K / b;
				kotae += ll(f.ifac[N - i]) * f.ifac[i] % mod * f.ifac[N - j] % mod * f.ifac[j] % mod;
			}
			K -= A;
		}
	}
	else {
		for (int i = hajime; i <= owari; i++) {
			kotae += ll(f.ifac[N - i]) * f.ifac[i] % mod * f.ifac[N - K] % mod * f.ifac[K] % mod;
			K -= A;
		}
	}

	kotae %= mod;
	kotae *= f.fac[N];
	kotae %= mod;
	kotae *= f.fac[N];
	kotae %= mod;

	printf("%lld\n", kotae);

	Would you please return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
#define DEBUG if(1)
#define MAX INT_MAX
#define MAXLL INT_MAX
#define MAXU ULLONG_MAX
#define MIN -2000000
#define endl "\n"
#define INF INT_MAX
#define MOD 1000000007
#define s(n) scanf("%d", &n)
#define ss(a,b) scanf("%d %d",&a,&b)
#define pb push_back
#define mp make_pair
#define M_PI 3.14159265358979323846
#define sz(a) int(a.size())
#define lli long long int
#define rep(i,a,n) for (int i=a;i<n;i++)
#define ler(a,n,vec) for(int i=0;i<n;i++)s(a), vec.pb(a)
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> ii;
#define DEBUG if(1)
#define F first
#define S second
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
int ddx[] = {1, 0};
int ddy[] = {1, 1};
#define MAXN 200010
#define MAXL 20

int n;
vi vec;

lli pd[MAXN][2];

lli solve(int i, int last){
	if(i == sz(vec) - 1) return 0;

	lli &ans = pd[i][last];
	if(pd[i][last] != -1) return pd[i][last];

	lli a = INT_MAX, b = INT_MAX;
		a = solve(i+1, 1) + abs(vec[i] - vec[i+1]);

		if(i < sz(vec) - 2)
		b = solve(i+2, 2) + abs(vec[i] - vec[i+2]);

	return ans = min(a, b);
}

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

  cin >> n;
  for(int i=0;i<n;i++){
  	int a;
  	cin >> a;
  	vec.pb(a);
  }

  memset(pd, -1, sizeof pd);

  cout << solve(0, 0) << endl;

  return 0;
}

Measured memory_bytes: 8568
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<time.h>
#include<tuple>
#include<set>
#include<map>
#include<cctype>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
#define tget(a,b) get<a>(b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const int MAX_V = 100005;
string N; int ans = INF;
int main(void) {
	
	cin >> N;
	int n = N.length();
	
	
	FOR(i, 0, n - 2){
		
		int cur = int(N[i]-'0' ) * 100 + int(N[i+1]-'0' ) * 10 + int(N[i+2]-'0') ;
		ans = min(ans, abs(753 - cur));
	}
	ct(ans);
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
using namespace std;
int main(){
	int a, b, c, counter = 1;
	cin >> a >> b >> c;
	if(b != a){
		counter++;
	}
	if(c != a && c != b){
		counter++;
	}
	cout << counter << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b;
	scanf("%d %d",&a,&b);
	if(a<b){
		printf("a < b\n");
	}else if(a>b){
		printf("a > b\n");
	}else if(a==b){
		printf("a == b\n");
	}
	return 0;
}

Measured memory_bytes: 580
#include<bits/stdc++.h>
#define ll long long int
using namespace std;

int main()
{
    ll n,t,x,y,k,i,j,p,q;

    cin>>n;

    ll a[n+5];

    map<ll,ll>mp;

   ll  sum=0;

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

        sum+=a[i];

        mp[a[i]]++;
    }

    cin>>t;

    while(t--)
    {
        cin>>x>>y;

        sum+=(mp[x]*y-mp[x]*x);

        mp[y]=mp[y]+mp[x];

        mp[x]=0;

        cout<<sum<<endl;
    }
}


Measured memory_bytes: 10268
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

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;
}

signed main() {
  init();
  ll N;
  cin >> N;
  ll count_mod4 = 0;
  ll count_mod2 = 0;

  rep(i, N) {
    ll a;
    cin >> a;
    if (a % 4 == 0) {
      count_mod4++;
      continue;
    }
    if (a % 2 == 0) {
      count_mod2++;
      continue;
    }
  }

  ll count = count_mod4 + count_mod2 / 2;

  if (count >= N / 2) {
    COUT("Yes");
  } else {
    COUT("No");
  }

  return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define LINF 3e18+7
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

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; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const double PI = acos(-1.0);
const double EPS = 1e-10;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> A(N);
    REP(i,N) cin >> A[i];

    int ans = 0;
    REP(i,N){
        while(i+1 < N && A[i]==A[i+1]) i++;

        if(i+1 < N && A[i]<A[i+1]){
            while(i+1 < N && A[i]<=A[i+1]) i++;
        }

        else if(i+1 < N && A[i]>A[i+1]){
            while(i+1 < N && A[i]>=A[i+1]) i++;
        }
        ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 640
splitBy :: Char -> String -> [String]
splitBy _ [] = []
splitBy a x =
  let s = takeWhile (/= a) x
      x'= dropWhile (/= a) x
  in
    if x' == []
    then [s]
    else s:(splitBy a $ drop 1 x')

f :: Integer -> String -> Integer
f n ('n':'^':s) =
  let m = read s :: Integer
  in
    n ^ m

ans n t s =
  let a = splitBy '+' s
      v = (* t) $ sum $ map (f n) a
  in
    if v <= 1000000000 then show(v) else "TLE"

main = do
  nt <- getLine
  s  <- getLine
  let [n,t] = map read $ words nt :: [Integer]
      o     = ans n t s
  putStrLn o



Measured memory_bytes: 3920
import sys
import math
import collections
import bisect
import copy
import itertools

# import numpy as np

sys.setrecursionlimit(10 ** 7)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().split()))


# ===CODE===


def main():
    n = ni()
    a = [ni() for _ in range(n)]
    ans = 0

    if a[0] != 0:
        print(-1)
        exit(0)

    prev = -1
    for i, ai in enumerate(reversed(a)):
        if ai > n - i - 1:
            print(-1)
            exit(0)

        if i == 0:
            ans += ai
        else:
            if ai != prev - 1:
                if ai > prev - 1:
                    ans += ai
                else:
                    print(-1)
                    exit(0)
        prev = ai
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 83212
#include <stdio.h>
#include <math.h>

#define MIN 1E9
#define MAX -10e+9

long long int i,j;

int main(void){
    int n,a[1000100];
    scanf("%d",&n);
    if(n==0) puts("0");
    i=0;
    while(n!=0){
        a[i]=abs(n)%2;
        if(n<0&&a[i]==1){
            n-=1;
        }
        n/=(-2);
        i++;
    }
    for(j=i-1;j>=0;j--) printf("%d",a[j]);
    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(void)
{
	int n;
	int a[3],b,c;
	int i,j,temp;
	b=1;
	
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	if(n==2){
		if(a[0]<a[1]){
			temp=a[0];
			a[0]=a[1];
			a[1]=temp;
		}
		while(b!=a[1]){
			for(i=0;i<a[1];i++){
				if(a[0]%b==0 && a[1]%b==0){
					printf("%d\n",b);
				}
			b++;
			}
		break;
		}
	}
	else if(n==3){
		for(i=0;i<2;i++){
			for(j=i+1;j<3;j++){
				if(a[i]<a[j]){
					temp=a[i];
					a[i]=a[j];
					a[j]=temp;
				}
			}
		}
		while(b!=a[2]){
			for(i=0;i<a[2];i++){
				if(a[0]%b==0 && a[1]%b==0 && a[2]%b==0){
						printf("%d\n",b);
				}
			b++;
			}
		break;
		}
	}
	return 0;
}

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

using namespace std;
#define ll long long int
int const mod=1000000007;

int main()
{
    ll x,k,d;
    cin>>x>>k>>d;
    x=abs(x);
    ll y=x/d;
    if(k<y)
    {
        cout<<abs(abs(x)-k*d);
    }
    else
    {
            k-=y;
            if(k%2!=0)
                cout<<abs(x%d-d);
            else
                cout<<x%d;
    }
}


Measured memory_bytes: 3632