akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};

class UnionFind {
public:
    vector<int> data;
    UnionFind(int size) : data(size, -1) { }
    bool connect(int x, int y) {
        x = root(x); y = root(y);
        if (x != y) {
            if (data[y] < data[x]) swap(x, y);
            data[x] += data[y]; data[y] = x;
        }
        return x != y;
    }
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    int root(int x) {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }
    int size(int x) {
        return -data[root(x)];
    }
};


int main(){
   int h,w;
   while(cin >> w >> h){
       if(h == 0 && w == 0)return 0;
       UnionFind Uni(h*w);
       vector<string> field;
       for(int i = 0;i < h;i++){
           string s;cin >> s;
           field.push_back(s);
       }
       pair<int,int> at;
       for(int i = 0;i < h;i++){
           for(int j = 0;j < w;j++){
      //         cout<<i<<" "<<j<<endl;
               if(field.at(i).at(j) == '#')continue;
               if(field.at(i).at(j) == '@'){
                   at = make_pair(i, j);
                   field.at(i).at(j) = '.';
               }
               if(i != 0){
                   if(field.at(i-1).at(j) == '.')Uni.connect(i*w+j,(i-1)*w+j);
               }
               if(j != 0){
                   if(field.at(i).at(j-1) == '.')Uni.connect(i*w+j,i*w+j-1);
               }
           }
       }
       cout<<Uni.size(at.first*w+at.second)<<endl;
   }
}



Measured memory_bytes: 3000
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.stream.Stream;

public class Main {

	public static void main(String[] args) {
		try (Stream<String> lines = new BufferedReader(new InputStreamReader(System.in)).lines()) {
			new Main().exec(lines.toArray(String[]::new));
		}
	}

	void exec(String[] args) {
		int N = Integer.parseInt(args[0].split(" ")[0]);
		System.out.println(bi(10).pow(N).subtract(bi(9).pow(N).multiply(bi(2))).add(bi(8).pow(N)).remainder(bi(10).pow(9).add(bi(7))));
	}

	BigInteger bi(int n) {
		return new BigInteger(String.valueOf(n));
	}

}


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

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

    int n,c=0;
    cin>>n;
    string s;
    cin>>s;
    char key=s[0];
    for(int i=1;i<n;i++)
    {
//      for(int j=i;j<n;j++)
//      {
//          if(s[i]!=s[j])
//          {
//              c++;
//              i=j-1;
//              break;
//          }
//      }
        if(key!=s[i])
        {
            c++;
            key=s[i];
        }
    }
    cout<<c+1<<endl;
return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
  #include <vector>
  #include <math.h>
  #include <string>
  #include <algorithm>
  #include <stack>
  #include <queue>
  #include <ctype.h>
  #include <unordered_map>
  #include <set>
  #include <iterator>
  #include <deque>
  #include <string.h>
  using namespace std;

  typedef long long int lli;


  #define MOD (lli)(1e9+7)
  #define endl "\n"
  #define pb push_back
  #define TEST_CASES  lli t;cin >> t;while(t--)
  #define forn(i,n) for (int i = 0; i < n; ++i)
  
  int pow(lli x,lli y){
    
    lli res = 1;
    while(y > 0){
      if(y & 1)
        res = (res*x);
      x = (x*x);
      y = y>>1;
    }
    return res;
  }

  

  int main()
  {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m;
    cin>>n>>m;
    int sum =0;
   forn(i,m){
    int x;
    cin>>x;
    sum +=x;
   }
   if(sum > n)
    cout<<-1<<endl;
   else
    cout<<n-sum<<endl;


    
  }


Measured memory_bytes: 3648
#include <iostream>

using namespace std;

int main (){
    
    int a,b;
    
    cin >> a >> b ;
    
    if (a < b){
        cout << "a < b" << endl;
    }
    
    if (a > b){
        cout << "a > b" << endl;
    }
    
    if (a == b){
        cout << "a == b" << endl;
    }
    return 0;
}


Measured memory_bytes: 3092
#include<stdio.h>
int main(void){
	int i,t,gougou,gou,a,b,ab[100][100]={{0}};
	gou=0,gougou=0;
	scanf("%d %d",&a,&b);
	for(i=0;i<a;i++){
		for(t=0;t<b;t++){
			scanf("%d",&ab[i][t]);
		}
	}
	
	for(i=0;i<a;i++){
		
		for(t=0;t<b;t++){
			printf("%d ",ab[i][t]);
			gou+=ab[i][t];
			if(0==t+1-b){
				printf("%d",gou);
				gougou+=gou;
				gou=0;
			}
			
			
		}
		
				printf("\n");
}
	for(i=0;i<b;i++){
		
		for(t=0;t<a;t++){
			
			gou+=ab[t][i];
			if(0==t+1-a){
				printf("%d ",gou);
				
				gou=0;
			}
			
			
		}
}
	printf("%d\n",gougou);
	return 0;
}

Measured memory_bytes: 2744
#include<iostream>
#include<algorithm>
using namespace std;
int*t,n,m,d,i,s[99999];
main(){
	for(;cin>>d>>n>>m;cout<<i<<'\n'){
		for(s[i=n]=d;--i;)
			cin>>s[i];
		for(sort(s,s+n);m--;t=upper_bound(s,s+n,d),i+=min(*t-d,d-t[-1]))
			cin>>d;
	}
}

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

typedef long long lint;
#define REP(i, x, n) for(lint i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(lint i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())

const int IINF = 1e9 + 10;
const lint LLINF = (lint)1e18 + 10;
const lint MOD = (lint)1e9 + 7;
const lint inv = MOD - 2;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

int main(){
    int n;
    cin >> n;
    int dp[5][110] = {{0}};  // dp[i][j] (i, j)を目的地とした時に回収できる最大の個数
    REP(i, 1, 3){
        REP(j, 1, n+1){
            cin >> dp[i][j];
        }
    }
    REP(i, 1, 3){
        REP(j, 1, n+1){
            dp[i][j] += max(dp[i-1][j], dp[i][j-1]);
        }
    }
    cout << dp[2][n] << endl;
    return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	stdin := bufio.NewScanner(os.Stdin)
	stdin.Scan()
	_ = stdin.Text()
	stdin.Scan()
	in := stdin.Text()
	out, _ := do(in)
	fmt.Println(out)

}

func do(in string) (string, error) {
	s := strings.Split(in, " ")
	var nums = make([]int, 0, len(s))
	for _, n := range s {
		num, err := strconv.Atoi(n)
		if err != nil {
			return "", err
		}
		nums = append(nums, num)
	}

	var are = false
	var i = 0
	for ; !are; i++ {
		are = true
		var nums1 = make([]int, 0, len(nums))
		for _, n := range nums {
			if n%2 == 1 {
				return strconv.Itoa(i), nil
			}
			nums1 = append(nums1, n/2)
		}
		are = false
		nums = nums1
	}
	return "e", errors.New("error")
}


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


int atechocorate(int, int);
int main() {
	int n, d, x, ans = 0, a;
	cin >> n >> d >> x;
	for (int i=0; i < n; i++) {
		cin >> a;
		ans += atechocorate(a, d);
	}
	ans += x;
	cout << ans;
	return 0;

}

int atechocorate(int A, int D) {
	int ans = (D - 1) / A + 1;
	return ans;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
like = [0] * (M + 1)
for _ in range(N):
  a = list(map(int, input().split()))
  for i in range(1, a[0] + 1):
    like[a[i]] += 1

cnt = 0
for i in range(1, M + 1):
  if like[i] == N:
    cnt += 1
    
print(cnt)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const ll INF = 2e15;
template<class T> void print(const T& t){ cout << t << endl; }
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; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int main(){
  ll n;
  cin >> n;
  vl a(n+2);
  a[0] = 0;
  a[n + 1] = 0;
  ll total = 0;
  for (ll i = 1; i <= n; i++){
    cin >> a[i];
    total += abs(a[i] - a[i - 1]);
  }
  total += abs(a[n + 1] - a[n]);
  for (ll i = 1; i <= n; i++)
  {
    if((a[i]<=a[i-1]&&a[i]>=a[i+1])||(a[i]>=a[i-1]&&a[i]<=a[i+1])){
      print(total);
    }
    else{
      print(total - 2 * min(abs(a[i+1]-a[i]),abs(a[i] - a[i - 1])));
    }
  }
}


Measured memory_bytes: 4052
#ifdef _WIN32
#include "stdc++.h"
#else
#include <bits/stdc++.h>
#endif

// 継承可能な型
template <class Type>
struct IN : Type
{
	IN()
	{
		std::cin >> *this;
	}
};

// 継承不可能な型
template <class Type>
struct IN_
{
	Type val;

	IN_()
	{
		std::cin >> val;
	}

	operator Type&()
	{
		return val;
	}

	IN_<Type>& operator=(const Type& _value)
	{
		val = _value;
		return *this;
	}
};

template <class Char, class Type>
std::basic_ostream<Char>& operator <<(std::basic_ostream<Char>& os, const IN_<Type>& value)
{
	return os << value.val;
}

template <class Char, class Type>
std::basic_istream<Char>& operator >>(std::basic_istream<Char>& is, IN_<Type>& value)
{
	return is >> value.val;
}

template <class Type>
void OUT(const Type& value)
{
	std::cout << value << std::endl;
}

template <class Type, class ... Args>
void OUT(const Type& value, const Args& ... args)
{
	std::cout << value << ' ';
	OUT(args...);
}

void Yes()
{
	OUT("Yes");
}
void No()
{
	OUT("No");
}

using ll = long long;
using inll = IN_<ll>;
using vll = std::vector<ll>;
using setll = std::set<ll>;
using msetll = std::multiset<ll>;
using instr = IN<std::string>;

#define FOR(i, m, n) for (ll (i) = (m); (i) < (n); ++(i))
#define REP(i, n) for (ll (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for (ll (i) = (n); (i) >= 0; --(i))
#define ITRREP(it, v) for (auto (it) = (v).begin(); (it) != (v).end(); ++(it))
#define ITRREPR(it, v) for (auto (it) = (v).rbegin(); (it) != (v).rend(); ++(it))
#define DIVUP(a, b) (((a) + (b) - 1) / (b))

void Main();

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

	Main();

#ifdef _DEBUG
	system("pause");
#endif

	return 0;
}

using namespace std;

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

void Main()
{
	inll n, d, x;

	ll res = x;

	//vll a;
	REP(i, n)
	{
		inll a;
		//a.push_back(a_);
		for (int j = 1; j <= d; j += a)
			res++;
	}

	return OUT(res);
}


Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		int res = s.length;
		for(int i = 0; i < s.length-1; i++){
			if(s[i] == s[i+1]){
				res--; i+=2;
			}
		}
		System.out.println(res);
	}

}


Measured memory_bytes: 26396
s = input()
length = len(s)
cnt = 0

if s[0] != 'A':
    print('WA')
    exit()

if length == 4:
    if s[2] == 'C':
        cnt = 1
else:
    for i in range(2, length-1):
        cnt += 1 if s[i] == 'C' else 0

if cnt != 1:
    print('WA')
    exit()

up_cnt = 0
for c in s:
    if c.isupper():
        up_cnt += 1

if up_cnt != 2:
    print('WA')
    exit()

print('AC')


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define MOD (int) (1e9+7)
#define INF (int) 2e9
#define LLINF (ll) 2e18

int main(){
    int n, k;
    cin >> n >> k;
    double p[n];
    rep(i, n){
        cin >> p[i];
        p[i] = (p[i]+1)/2;
    }

    double MAX;

    double tmp = 0;
    rep(i, k){
        tmp += p[i];
    }
    MAX = tmp;

    rep(i, n-k+1){
        tmp = tmp-p[i]+p[i+k];
        chmax(MAX, tmp);
    }

    // cout << MAX << endl;
    printf("%lf\n", MAX);
    return 0;
}

Measured memory_bytes: 1792
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

N, M = list(map(int, sys.stdin.buffer.readline().split()))
A = list(map(int, sys.stdin.buffer.readline().split()))

A = np.array([0] + A, dtype=int)
cum = A.cumsum() % M
mods = Counter(cum)


def test():
    N = len(A)
    ans = 0
    for l in range(1, N):
        for r in range(l + 1, N + 1):
            ans += sum(A[l:r]) % M == 0
    print(ans)


# test()
ans = 0
for c in mods.values():
    # c から2選ぶ
    ans += c * (c - 1) // 2
print(ans)


Measured memory_bytes: 22488
import math
n,m = map(int,input().split())
if n==1:
    print(m)
    exit()
mm = int(math.sqrt(m))
a = []
for i in range(1,mm):
    if m%i == 0:
        a.append(i)
        a.append(m//i)
ans = 1
for D in a:
    if m - (n-1)*D >= D:
        ans = max(ans,D)
print(ans)


Measured memory_bytes: 3060
#include<stdio.h>
#define LBOUND -1001
#define ST_SIZE ((1 << 18) - 1)
typedef long long int LL;
LL dat[ST_SIZE];
LL input(void);
void update(LL a, LL b, LL x, LL k, LL l, LL r);
LL sum(LL a, LL b, LL k, LL l, LL r);
int main (void) {
  int command, x;
  LL i, n, q, s, t;
  n = input();
  q = input();
  for (i = 0; i < q; i++) {
    command = input();
    if (!command) {
      s = input();
      t = input();
      x = input();
      update(s, t + 1, x, 0, 0, n);
    } else {
      s = input();
      t = input();
      printf("%lld\n", sum(s, t + 1, 0, 0, n));
    }
  }
}
LL input(void)
{
  LL n = 0;
  int c = getchar_unlocked();
  if (c == '-') {
    c = getchar_unlocked();
    do {
      n = 10 * n + c - '0';
      c = getchar_unlocked();
    } while (c >= '0' && c <= '9');
    return -n;
  } else {
    do {
      n = 10 * n + c - '0';
      c = getchar_unlocked();
    } while (c >= '0' && c <= '9');
    return n;
  }
}
void update(LL a, LL b, LL x, LL k, LL l, LL r)
{
  LL m = (l + r) / 2;
  if (a >= r || b <= l) return;
  else if (a <= l && b >= r) dat[k] = x;
  else {
    if (dat[k] != LBOUND) {
      dat[k*2+1] = dat[k*2+2] = dat[k];
      dat[k] = LBOUND;
    }
    update(a, b, x, k * 2 + 1, l ,m);
    update(a, b, x, k * 2 + 2, m, r);
  }
}
LL sum(LL a, LL b, LL k, LL l, LL r)
{
  LL m = (l + r) / 2;
  if (a >= r || b <= l) return 0;
  else {
    if (dat[k] != LBOUND) return ((b < r ? b : r) - (a > l ? a : l)) * dat[k];
    else {
      LL vl, vr;
      vl = sum(a, b, k * 2 + 1, l, m);
      vr = sum(a, b, k * 2 + 2, m, r);
      return (vl + vr);
    }
  }
}


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

int main (){
	int w,h,x,y,r;
	cin >> w >> h >> x >> y >> r;
	if((x - r) >= 0 && (x + r) <= w && (y - r) >= 0 && (y + r) <= h){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
return 0;
}

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#define Max 100000
using namespace std;
int n,k;
long long a[Max];
int check(long long p)
{
    int i=0;
    for(int j=0;j<k;j++)
    {
        long long s = 0;
        while(s+a[i] <= p)
        {
            s = s+a[i++];
            if(i == n)
                return n;
        }
    }
    return i;
}
int solve()
{
    long long left = 0;
    long long right = 100000*10000;
    long long mid;
    while(left+1 < right)
    {
        mid = (left + right)/2;
        int v = check(mid);
        if(v>=n)
            right = mid;
        else
            left = mid;
    }
    return right;
}
int main()
{
    int i;
    scanf("%d%d",&n,&k);
    for(i=0;i<n;i++)
        scanf("%d",&a[i]);
    int res = solve();
    printf("%d\n",res);
    return 0;
}

Measured memory_bytes: 3976
#include<iostream>
#include<math.h>
#include<string>
using namespace std;

#define rep(i,n) for(i=0;i<n;i++)
int main(){
    int i,j,k;
    int bg[3][3];
    int ans[3][3]={0};
    rep(i,3){
        rep(j,3){
            cin>>bg[i][j];
        }
    }
    int N;
    cin>>N;
    int b[N];
    rep(i,N){
        cin>>b[i];
    }
    rep(i,N){
        rep(j,3){
            rep(k,3){
                if(b[i]==bg[j][k]){
                    ans[j][k]=1;
                }
            }
        }
    }
    //横
    rep(i,3){
        int sum=0;
        rep(j,3){
            if(ans[i][j]==1)
                sum++;
        }
        if(sum==3){
            cout<<"Yes";
            return 0;
        }
    }
    rep(i,3){
        int sum=0;
        rep(j,3){
            if(ans[j][i]==1)
                sum++;
        }
        if(sum==3){
            cout<<"Yes";
            return 0;
        }
    }
    if((ans[0][0]+ans[1][1]+ans[2][2])==3){
        cout<<"Yes";
    }else if((ans[0][2]+ans[1][1]+ans[2][0])==3){
        cout<<"Yes";
    }else{
        cout<<"No";
    }
}


Measured memory_bytes: 3612
package main

import "fmt"

func main() {
	var s string
	fmt.Scanln(&s)

	if logic(s) {
		fmt.Println("Yes")
		return
	}

	fmt.Println("No")
}

func logic(s string) bool {
	for i, c := range s {
		str := string(c)
		if i%2 != 0 && !(str == "L" || str == "U" || str == "D") {
			return false
		}
		if i%2 == 0 && !(str == "R" || str == "U" || str == "D") {
			return false
		}
	}
	return true
}

Measured memory_bytes: 512
import sys
input = sys.stdin.readline
from collections import defaultdict
from bisect import bisect_right

def main():
    s = input()
    t = input()
    dictPos = defaultdict(list)
    N = len(s) - 1
    for i in range(N):
        ch = s[i]
        dictPos[ch].append(i+1)
    countLoop = 0
    lastPos = -1
    M = len(t) - 1
    for i in range(M):
        ch = t[i]
        listPos = dictPos[ch]
        if len(listPos) == 0:
            print(-1)
            exit()
        if listPos[-1] <= lastPos:
            lastPos = listPos[0]
            countLoop += 1
        else:
            lastPos = listPos[bisect_right(listPos, lastPos)]
    ans = N * countLoop + lastPos
    print(ans)

if __name__ == '__main__': main()

Measured memory_bytes: 8048
H,W,K = map(int,input().split())
s = [input() for i in range(H)]
a = [["."]*W for i in range(H)]
tag = 1
for h in range(H):
    l = 0
    for w in range(W):
        if s[h][w]=="#":
            a[h][l:w+1] = [tag]*(w+1-l)
            l = w+1
            tag+=1
    if l!=0 and l!=W:
        a[h][l-1:W] = [tag-1]*(W-l+1)
for h in range(H):
    for w in range(W):
        if a[h][w]==".":
            for k in range(h,H):
                if a[k][w]!=".":
                    a[h][w]=a[k][w]
                    break
            if a[h][w]==".":
                for k in range(h,-1,-1):
                    if a[k][w]!=".":
                        a[h][w]=a[k][w]
                        break
for b in a:print(*b)

Measured memory_bytes: 7552
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi M_PI
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

#define mod 1000000007

ll add(ll x, ll y){
    return (x+y)%mod;
}

ll mul(ll x, ll y){
    return (x%mod)*(y%mod)%mod;
}

ll powll(ll x, ll y){
    ll res = 1LL;
    while(y){
        if (y & 1LL)
            res *= x;
        res %= mod;
        x = (x*x) % mod;
        y >>= 1LL;
    }
    return res;
}

ll nPr(ll n, ll r){
    ll res = 1LL;
    FOR(i,1,r){
        res = (res * ((n-i+1) % mod)) % mod;
    }
    return res;
}

ll nCr(ll n, ll r){
    ll res = nPr(n,r);
    FOR(i,1,r){
        res = (res * powll(i,mod-2)) % mod;
    }
    return res;
}

int main() {
    int h, w, a, b;
    cin >> h >> w >> a >> b;

    ll ans = 0;
    ll n = h-a-1+b, m = w-b-1+a;
    ll x = nCr(n,b), y = nCr(m,a);
    while (a < h && b < w){
        ans = add(ans,mul(x,y));
        x = mul(mul(x, n-b), powll(b+1, mod-2));
        y = mul(mul(y, m-a), powll(a+1, mod-2));
        a++;
        b++;
    }

    cout << ans << endl;
    return 0;
}


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

int main() {
	int N;
	cin>>N;
	
	vector<int> a(N);
	for(int i=0;i<N;i++) cin>>a[i];
	
	sort(a.begin(),a.end());
	
	
	int p=0;
	for(int i=0;i<a.size();i++){
	    int num=1;
	    int j=1;
	    while(a[i]==a[i+j]){
	        num++;
	        j++;
	    }
	    
	    if(num<a[i]){
	        p+=num;
	    }else if(num>a[i]){
	        p+=num-a[i];
	    }
	    
	    i+=num-1;
	}
	
	cout<<p<<endl;
}

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

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

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

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

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

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    int n = sc.nextInt();
    int t = sc.nextInt();
    int min = Integer.MAX_VALUE;
    while (n-- > 0) {
      int c = sc.nextInt();
      int ti = sc.nextInt();
      if (ti > t) continue;
      min = Math.min(min, c);
    }
    if (min == Integer.MAX_VALUE) {
      System.out.println("TLE");
    } else {
      System.out.println(min); 
    }
  }
}

Measured memory_bytes: 21332
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
 
using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
//const double pi = acos(-1.);
//printf(%.12lf\n,mid);
// __builtin_popcount(int) count 1's in binary
//istringstream iss(sentence);
long long mod = 998244353;
 
// 32 mil = ~1 sec 
long long mymod(long long num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}
  
const int biggg = 2000000000;
const long long bigggest = 1000000000000000000LL;
const double eps = .0000000001;

int main(){
    prep();
    int n;
    cin >> n;
    int num = n%10;
    int arr[5] = {2, 4, 5, 7, 9};
    for (int i=0; i<5; i++){
        if (arr[i] == num){
            cout << "hon";
            return 0;
        }
    }
    if (num == 3){
        cout << "bon";
        return 0;
    }
    cout << "pon";
}

Measured memory_bytes: 3640
from collections import deque
k=int(input())
dist=[1000000000 for i in range(k)]
dist[1]=0
dq=deque()
dq.append(1)
while len(dq)>0:
    it=dq.pop()
    if dist[(it+1)%k]>dist[it]+1:
        dist[(it+1)%k]=dist[it]+1
        dq.appendleft((it+1)%k)
    if dist[(it*10)%k]>dist[it]:
        dist[(it*10)%k]=dist[it]
        dq.append((it*10)%k)
print(dist[0]+1)

Measured memory_bytes: 46320
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define dump(x)  cerr << #x << " = " << (x) << endl;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL; 

 

//ここから書き始める
int main(int argc, char const *argv[])
{
	LL N,K;
	cin >> N >> K;
	LL a[N];
	REP(i,N) cin >> a[i];

	LL ans;
	//ans = (N - K) / (K - 1) + 1
	ans = ((N-K) + (K - 2)) / (K-1) + 1;
	cout << ans << endl;




}


Measured memory_bytes: 1024
a=list(input())
n=[]
for i in range(1,len(a)+1):
    if i%2==0:
        n.append(0)
    else:
        n.append(1)
m=[]
for i in range(1,len(a)+1):
    if i%2==0:
        m.append(1)
    else:
        m.append(0)
ans1=0
for i in range(len(a)):
    if n[i]!=int(a[i]):
        ans1+=1
ans2=0
for i in range(len(a)):
    if m[i]!=int(a[i]):
        ans2+=1
print(min(ans1,ans2))

Measured memory_bytes: 90420
import java.util.*;

public class Main {
	public static void main(String[] args)  {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		String X = "";
		String a[] = new String[H];
		for(int i = 0; i < H; i++){
			a[i] = sc.next();
		}
		for(int x =0; x < W; x++){
			 X += "#" ;
		}
		System.out.println("#" + X + "#");
		for(String j : a){
			System.out.println("#" + j + "#");
		}
		System.out.println("#" + X + "#");
	}
}


Measured memory_bytes: 23764
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ENDL '\n'
#define print(i) std::cout << (i) << '\n'

#define int long long // at least int64 > 9*10^18
#define all(v) (v).begin(), (v).end()
/* libraries */

signed main() {
	int n,m;
	std::cin >> n >> m;
	std::priority_queue<int> pq;
	rep(i,n) {
		int a;
		std::cin >> a;
		pq.emplace(a);
	}
	rep(i,m) {
		int x = pq.top(); pq.pop();
		pq.emplace(x/2);
	}
	int sum = 0;
	rep(i,n) {
		int x=pq.top();pq.pop();
		sum+=x;
	}
	print(sum);
	return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int h,w;
string f[1005];
ll dp[1005][1005];
ll rec(int x,int y){
	if(dp[x][y] >= 0) return dp[x][y];
	if(x == h-1 && y == w-1) return dp[x][y] = 1;
	dp[x][y] = 0;
	if(x != h-1 && f[x+1][y] == '.') dp[x][y] += rec(x+1,y);
	if(y != w-1 && f[x][y+1] == '.') dp[x][y] += rec(x,y+1);
	return dp[x][y] =(dp[x][y]%mod+mod)%mod;
}
int main(){
	cin>>h>>w;
	for(int i=0;i<h;i++) cin>>f[i];
	rep(i,h)rep(j,w) dp[i][j]=-1;
	cout<<rec(0,0)<<endl;
}

Measured memory_bytes: 9216
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

fun <T> Array<Array<T>>.print() {
    this.forEach {
        println(it.joinToString(" "))
    }
}

fun main(args: Array<String>) {
    val S = readString()
    val mod = 1000000007L
    val dp = Array(13) { Array(S.count() + 1) { 0L } }

    dp[0][0] = 1L

    for (i in 0 until S.count()) {
        for (j in 0..12) {
            if (S[i] == '?') {
                for (k in 0..9) {
                    dp[(10 * j + k) % 13][i + 1] += dp[j][i]
                    dp[(10 * j + k) % 13][i + 1] %= mod
                }
            } else {
                val num = S[i].toString().toInt()
                dp[(10 * j + num) % 13][i + 1] += dp[j][i]
                dp[(10 * j + num) % 13][i + 1] %= mod
            }
        }
    }

    println(dp[5][S.count()])
}

Measured memory_bytes: 155460
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(18);
}
signed main(){
  init_io();
  ll n,m,sum=0;
  cin >> n >> m;
  vector<ll> a(m);
  for(int i=0;i<m;i++){
    cin >> a[i];
    sum += a[i];
  }
  if(sum>n){
    cout << -1<<endl;
  }else{
    cout << n-sum<<endl;
  }
}


Measured memory_bytes: 3668
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;

int main() {
    ll n, m;
    cin >> n >> m;
    dsu d(n);
    for (ll i = 0;i < m;++i) {
        ll a, b;
        cin >> a >> b;
        d.merge(a - 1, b - 1);
    }

    cout << d.groups().size() - 1 << endl;
}

Measured memory_bytes: 9104
#include <bits/stdc++.h>
using namespace std;
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
constexpr int INF=1000000000;
int h,w,k,stx,sty,gox,goy;
vector<vector<char>>c;
vector<vector<int>>U,D,L,R,d;
void init_table(){
    rep(j,w){
        if(c[0][j]=='@')U[0][j]=-1;
        rep(i,h-1){
            if(c[i+1][j]=='@')U[i+1][j]=-1;
            else U[i+1][j]=U[i][j]+1;
        }
    }
    rep(j,w){
        if(c[h-1][j]=='@')D[h-1][j]=-1;
        for(int i=h-2;i>=0;i--){
            if(c[i][j]=='@')D[i][j]=-1;
            else D[i][j]=D[i+1][j]+1;
        }
    }
    rep(i,h){
        if(c[i][0]=='@')L[i][0]=-1;
        rep(j,w-1){
            if(c[i][j+1]=='@')L[i][j+1]=-1;
            else L[i][j+1]=L[i][j]+1;
        }
    }
    rep(i,h){
        if(c[i][w-1]=='@')R[i][w-1]=-1;
        for(int j=w-2;j>=0;j--){
            if(c[i][j]=='@')R[i][j]=-1;
            else R[i][j]=R[i][j+1]+1;
        }
    }
}
struct si{int x,y,cost;};
void BFS(){
    queue<si>q;
    q.push({stx,sty,0});
    d[stx][sty]=0;
    while(!q.empty()){
        si p=q.front();
        q.pop();
        int x=p.x,y=p.y;
        if(d[x][y]!=p.cost)continue;
        for(int i=x-1;i>=max(0,x-min(k,U[x][y]));i--){
            if(d[i][y]>d[x][y]+1){
                d[i][y]=d[x][y]+1;
                q.push({i,y,d[i][y]});
            }
            else if(d[i][y]<=d[x][y])break;
        }
        for(int i=x+1;i<=min(h-1,x+min(k,D[x][y]));i++){
            if(d[i][y]>d[x][y]+1){
                d[i][y]=d[x][y]+1;
                q.push({i,y,d[i][y]});
            }
            else if(d[i][y]<=d[x][y])break;
        }
        for(int j=y-1;j>=max(0,y-min(k,L[x][y]));j--){
            if(d[x][j]>d[x][y]+1){
                d[x][j]=d[x][y]+1;
                q.push({x,j,d[x][j]});
            }
            else if(d[x][j]<=d[x][y])break;
        }
        for(int j=y+1;j<=min(w-1,y+min(k,R[x][y]));j++){
            if(d[x][j]>d[x][y]+1){
                d[x][j]=d[x][y]+1;
                q.push({x,j,d[x][j]});
            }
            else if(d[x][j]<=d[x][y])break;
        }
    }
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    cin>>h>>w>>k;
    c.resize(h,vector<char>(w,'.'));
    U.resize(h,vector<int>(w,0));
    D.resize(h,vector<int>(w,0));
    L.resize(h,vector<int>(w,0));
    R.resize(h,vector<int>(w,0));
    d.resize(h,vector<int>(w,INF));
    cin>>stx>>sty>>gox>>goy;
    stx--,sty--,gox--,goy--;
    rep(i,h){
        rep(j,w){
            cin>>c[i][j];
        }
    }
    init_table();
    BFS();
    if(d[gox][goy]==INF)puts("-1");
    else cout<<d[gox][goy]<<endl;
    return 0;
}

Measured memory_bytes: 27772
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashSet;

public class Main {
	enum marks {
		S, H, C, D;
	}

	public static void main(String[] args) {
		try {
			BufferedReader br = new BufferedReader(new InputStreamReader(
					System.in));
			int n = Integer.parseInt(br.readLine());
			HashSet<String> strSet = new HashSet<String>();

			for (marks mark : marks.values()) {
				for (int i = 1; i <= 13; i++) {
					strSet.add(mark + " " + i);
					//cardSet.add(mark + " " + i);
				}
			}

			for (int i = 0; i < n; i++) {
				strSet.remove(br.readLine());
			}
			
			String[] strs = (String[]) strSet.toArray(new String[0]);
			
			Arrays.sort(strs, new Comparator<String>() {
				@Override
				public int compare(String o1, String o2) {
					int flg;
					flg = marks.valueOf(o1.split("\\s")[0]).compareTo(
							marks.valueOf(o2.split("\\s")[0]));
					if (flg == 0) {
						return Integer.parseInt(o1.split("\\s")[1])
								- Integer.parseInt(o2.split("\\s")[1]);
					} else {
						return flg;
					}
				}		
			});
			
			for (String str : strs){
				System.out.println(str);
			}
			
			br.close();
		} catch (Exception e) {
			System.err.println(e);
		}
	}
}

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

using namespace std;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)((x).size()))

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef long long int64;
typedef unsigned int uint;
typedef unsigned long long uint64;

#define gi(x) ((x) = F())
#define gii(x, y) (gi(x), gi(y))
#define giii(x, y, z) (gii(x, y), gi(z))

int F()
{
	char ch;
	int x, a;
	while (ch = getchar(), (ch < '0' || ch > '9') && ch != '-');
	if (ch == '-') ch = getchar(), a = -1;
	else a = 1;
	x = ch - '0';
	while (ch = getchar(), ch >= '0' && ch <= '9')
		x = (x << 1) + (x << 3) + ch - '0';
	return a * x;
}

const int mod = 1e9 + 7;

int n, m, k, ans;

int f[2][2010][2], sum[2010];

int main()
{
	giii(n, m, k);
	--m, --k;
	for (int i = 1; i <= k; ++i) f[0][i][1] = 1;
	f[0][0][0] = 1;
	for (int i = 0; i <= n; ++i) 
		if (k - i <= m && i % k == n % k && (k - i) % k == m % k) ans = (ans + f[0][i][1]) % mod;
	int now = 0;
	for (int i = 2; i <= max(n, m) * 2; ++i)
	{
		now ^= 1;
		for (int j = 0; j <= n; ++j) sum[j + 1] = (sum[j] + (f[now ^ 1][j][0] + f[now ^ 1][j][1]) % mod) % mod;
		for (int j = 0; j <= n; ++j)
		{
			f[now][j][0] = (sum[j + 1] - sum[j] + mod) % mod;
			f[now][j][1] = (sum[j] - sum[max(0, j - k)] + mod) % mod;
		}
		for (int j = 0; j <= n; ++j)
			if (k * i - j <= m && j % k == n % k && (k * i - j) % k == m % k) ans = (ans + f[now][j][1]) % mod;
		//cerr << ans << endl;
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 384
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;

vector<int> g[100000+10];
int parentOf[100000+10];
int color[100000+10];


int main(void) {
  memset(parentOf, -1, sizeof parentOf);
  memset(color, -1, sizeof color);
  int n;
  scanf("%d", &n);
  REP(i, n-1) {
    int a, b;
    scanf("%d%d", &a, &b);
    --a;
    --b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  queue<int> q;
  q.push(0);
  parentOf[0] = 0;
  while(!q.empty()) {
    int u = q.front(); q.pop();
    REP(i, g[u].size()) {
      int v = g[u][i];
      if(parentOf[v] < 0) {
        parentOf[v] = u;
        q.push(v);
      }
    }
  }
  // REP(i, n) {
  //   cerr  << "parent of " << i+1 << " is " << parentOf[i]+1 << endl;
  // }
  deque<int> path;
  for(int cur = n-1; cur != 0; cur = parentOf[cur]) {
    path.push_front(cur);
  }
  path.push_front(0);

  for(int turn = 0; !path.empty(); turn ^= 1) {
    int v;
    if(turn == 0) {
      v = path.front(); path.pop_front();
    } else {
      v = path.back(); path.pop_back();
    }
    color[v] = turn;
    q.push(v);
  }
  while(!q.empty()) {
    int u = q.front(); q.pop();
    REP(i, g[u].size()) {
      int v = g[u][i];
      if(color[v] == -1) {
        color[v] = color[u];
        q.push(v);
      }
    }
  }
  // REP(i, n) {
  //   cerr  << "color of " << i+1 << " is " << color[i] << endl;
  // }
  int cnt[2] = {};
  REP(i, n) {
    assert(color[i] >= 0);
    cnt[color[i]]++;
  }
  puts(cnt[0] <= cnt[1] ? "Snuke" : "Fennec");
  return 0;
}


Measured memory_bytes: 6912
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    bool flag = false;
    if (isupper(s[1]) || isupper(s[s.size()-1])){cout << "WA" << endl; return 0;}
    for (int i = 0; i < s.size(); i++){
        if (i == 0 && s[i] != 'A'){cout << "WA" << endl; return 0;}
        if (s[i] == 'C'){
            if (flag){cout << "WA" << endl; return 0;}
            else{flag = true;}
        }
    }
    if (flag){cout << "AC" << endl;}
    else{cout << "WA" << endl;}
    return 0;
}

Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace ConsoleApplication32
{
    class Program
    {  
      static void Main(){
		  int[] a = new int[4];
		  int c,d,f;
		  d=c=f=0;
		  for (int b =0;b<4;b++)
		  {
			  a[b] = int.Parse(Console.ReadLine());
			  
		  }
		  for(int e =0;e<4;e++)
		      c+=a[e];
		      d+=c/60;
		      f+=c%60;
              Console.WriteLine(d);
              Console.WriteLine(f);		      
		  }}}
      
      

Measured memory_bytes: 9100
// include
//------------------------------------------
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

// conversion
//------------------------------------------
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T> inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

// math
//-------------------------------------------
template <class T> inline T sqr(T x) { return x * x; }

// typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

// container util
//------------------------------------------
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i, c)                                                             \
  for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

// repetition
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

// constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

// clear memory
#define CLR(a) memset((a), 0, sizeof(a))

// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x)                                                               \
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")"                       \
       << " " << __FILE__ << endl;

int main() {
  int n;
  cin >> n;
  int a[n], b[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
  }
  pair<LL, LL> ans;
  ans.first = a[0];
  ans.second = b[0];

  for (int i = 1; i < n; i++) {
    pair<LL, LL> tmp;
    tmp.first = (ans.first + a[i] - 1) / a[i];
    tmp.second = (ans.second + b[i] - 1) / b[i];
    if (tmp.first > tmp.second) {
      ans.first = a[i] * tmp.first;
      ans.second = b[i] * tmp.first;
    } else {
      ans.first = a[i] * tmp.second;
      ans.second = b[i] * tmp.second;
      dump(tmp.first);
      dump(tmp.second);
      dump(ans.first);
      dump(ans.second);
    }
  }
  cout << ans.first + ans.second;
  return 0;
}


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

int main()
{
    int a, b;
    cin >> a >> b;
    double d;
    d = (1.0*a) / b;

    cout << a/b << ' ' << a%b << ' ';
    printf("%.8lf\n",d);

    return 0;
}


Measured memory_bytes: 3224
import itertools
import math
import collections
def main():
    n = int(input())
    s = int(math.sqrt(n))
    a = list(itertools.product(range(1,s),repeat=3))
    ans = []
    for i in range(len(a)):
        t = a[i][0] ** 2 + a[i][1] ** 2 + a[i][2] ** 2 + a[i][0] * a[i][1] + a[i][1] * a[i][2] + a[i][2] * a[i][0]
        ans.append(t)
        # print(ans)
    c = collections.Counter(ans)
    for i in range(1,n+1):
        print(c[i])
        
        
main()

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

int main(){
    string s, t;
    cin >> s;
    cin >> t;

    string ans = "UNRESTORABLE";
    for(int i = s.length()-t.length(); i >= 0; i--){
        bool flag = true;
        for(int j = 0; j < t.length(); j++){
            if(s[i+j] != '?' && t[j] != s[i+j]) flag = false;
        }

        if(flag){
            ans = s;
            for(int j = 0; j < t.length(); j++) ans[i+j] = t[j];
            break;
        }
    }

    if(ans != "UNRESTORABLE"){
        for(int i = 0; i < ans.length(); i++){
            if(ans[i] == '?') ans[i] = 'a';
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#ifndef debug_on
#define debug_on 0
#endif

#define dbg \
    if(debug_on) cerr << "DEBUG:"
#define ast(cond)           \
    do {                    \
        if((cond) == false) \
        {                   \
            if(debug_on)    \
            cerr << "ASSERT" << #cond " failed at line:" << __LINE__ << endl;   \
            exit(1);        \
        }                   \
    }while(0)


int main(int, char *[])
{
    int N;
    cin >> N;
    unordered_map<int64_t, int> counts;
    counts[0] = 1;
    int64_t sum = 0;
    for(int i = 1; i <= N; ++i)
    {
        int v;
        cin >> v;
        sum += v;
        dbg << "i:" << i << " sum:" << sum << " " << counts[sum] << endl;
        ++counts[sum];
    }
    uint64_t num_pats = 0;
    for(auto &loc : counts)
    {
        if(loc.second <= 1)
            continue;
        num_pats += static_cast<uint64_t>(loc.second) * (loc.second - 1) / 2;
    }

    cout << num_pats << endl;
    return 0;
}


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

int main() {
  // ここにプログラムを追記
  int  s;
  cin >> s;
  int s1, s2, s3;
  s1 = s / 100;
  s2 = (s - s1 * 100) / 10;
  s3 = s - s1 * 100 - s2 * 10;
  cout << s1 + s2 + s3 << endl;
}

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

int main() {
	
	int n;
	cin >> n;
	priority_queue<int> a;
	rep(i, n){
		int t;
		cin >> t;
		a.push(t);
	}
	int alice = 0, bob = 0;
	rep(i, n){
		if(i % 2 == 0){
			alice += a.top();
			a.pop();
		}else{
			bob += a.top();
			a.pop();
		}
	}
	cout << alice - bob << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int n,m;
   cin >> n >> m;
   int sm = 0;
   vector<int> a(n);
   f(i,0,n){
      cin >> a[i];
      sm += a[i];
   }
   sort(all(a));
   reverse(all(a));
   int cut = sm/(4*m);
   int ans = 0;
   f(i,0,n){
      if(a[i]*4*m>=sm){
         ans++;
      }
   }
   if(ans >= m){
      cout << "Yes\n";
   }else{
      cout << "No\n";
   }
   return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Integer> b = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            b.add(sc.nextInt() - 1);
        }

        List<Integer> ans = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            int pivot = -1;
            for (int j = b.size() - 1; j >= 0; j--) {
                if (b.get(j) == j) {
                    pivot = j;
                    break;
                }
            }
            if (pivot == -1) {
                System.out.println(-1);
                return;
            }
            ans.add(pivot + 1);
            b.remove(pivot);
        }
        for (int i = n - 1; i >= 0; i--) {
            System.out.println(ans.get(i));
        }
    }
}


Measured memory_bytes: 23764
#! usr/bin/env python
# -*- coding: utf-8 -*-

from collections import deque
import heapq
import math
import bisect


def main():
    A, B = map(int, input().split())

    if B % A == 0:
        print(A+B)
    else:
        print(B-A)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3700
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ll> pll;
const int INF=1e9;
const ll MOD=1e9+7;

ll gcd(ll x,ll y){
    if(y==0) return 0;
    return gcd(y,x%y);
}

int dis2(int x1,int y1,int x2,int y2){
    return (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
}
ll se=0;
ll sume(vector<int> a,int n){

}
int main(){
    int n;cin>>n;
    int a[n],b[n];
    int m=0,im=0;
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
        if(a[i]>m){
            m=a[i];
            im=i;
        }
    }
    cout<<a[im]+b[im]<<endl;
    return 0;
}

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

int main()
{
    int N, K; cin >> N >> K;
    vector<pair<int, int>> xy(N); for (auto& p : xy) cin >> p.first >> p.second;
    sort(xy.begin(), xy.end());

    ll ans = LLONG_MAX;
    for (int i = 0; i < N-1; i++) {
        for (int j = i + K - 1; j < N; j++) {
            ll dx = xy[j].first - xy[i].first;
            vector<int> y;
            for (int m = i; m <= j; m++) {
                y.push_back(xy[m].second);
            }
            sort(y.begin(), y.end());
            for (int m = 0; m + K - 1 < y.size(); m++) {
                int n = m + K - 1;
                ll a = dx * (y[n] -y[m]);
                if (a < ans) ans = a;
            } 
        }
    }
    cout << ans << endl;
}

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

using ll = long long;
// dp[i] = TRUE if  first player wins if i stones remaining

int main(){
	int n,k;
	cin >> n >> k;
	
	vector<int> v(n);
	for(int i=0;i<n;i++){
		cin >> v[i];
	}

	vector<bool>dp(k+1);
	for(int stones = 0;stones <= k; stones++){
		for(int j=0;j<n;j++){
			if(stones >= v[j] && !dp[stones-v[j]]){
				dp[stones] = true;
			}
		}
	}
	
	puts(dp[k] ? "First" : "Second");
	return 0;
}

Measured memory_bytes: 256