akhauriyash/Code-Regression huggingface dataset:
from sys import stdin, setrecursionlimit
from collections import defaultdict
from math import gcd

setrecursionlimit(10 ** 9)
INF = 1 << 60


def input():
    return stdin.readline().strip()


MOD = 1000000007
N = int(input())
d = defaultdict(int)
zeros = 0
for i in range(N):
    a, b = map(int, input().split())
    if a == 0 and b == 0:
        zeros += 1
    else:
        g = gcd(a, b)
        a //= g
        b //= g
        if a < 0:
            a *= -1
            b *= -1
        d[(a, b)] += 1


ans = 1
free = 0
keys = sorted(d.keys())
for a, b in keys:
    n = d[(a, b)]
    if a != 0 and b != 0:
        if b > 0:
            if (b, -a) in d:
                m = d[(b, -a)]
                ans = ans * (pow(2, n, MOD) + pow(2, m, MOD) - 1) % MOD
            else:
                free += n
        else:
            if (-b, a) not in d:
                free += n
x, y, z = d[(0, 1)], d[(1, 0)], d[(0, -1)]
ans = ans * (pow(2, x + z, MOD) + pow(2, y, MOD) - 1) % MOD
ans = (ans * pow(2, free, MOD) + zeros - 1) % MOD
print(ans)


Measured memory_bytes: 50408
#[test]
fn test_solve() {
   assert_eq!(solve("erasedreamdreamererasereraserdreamerdreameraseerase\n"), "YES\n");
   assert_eq!(solve("dreameraser\n"), "YES\n");
   assert_eq!(solve("eraserase\n"), "NO\n");
}
fn solve(src: &str) -> String {
    let mut sc = Scanner::from_str(src);

    let s = sc.get();
    let lst = ["dream", "dreamer", "erase", "eraser"];

    let mut i = s.len();
    'lp: while i > 0 {
        let s = &s[..i];
        for &p in &lst {
            if s.ends_with(p) {
                i -= p.len();
                continue 'lp;
            }
        }
        return "NO\n".to_string();
    }

    "YES\n".to_string()
}
fn main() {
    let mut buf = String::new();
    use std::io::{Read, Write};
    std::io::stdin().read_to_string(&mut buf).unwrap();
    std::io::stdout().write_all(solve(&buf).as_bytes()).unwrap();
}
struct Scanner<'a>(std::str::SplitWhitespace<'a>);
impl<'a> Scanner<'a> {
    fn from_str(src: &str) -> Scanner {
        Scanner(src.split_whitespace())
    }
    fn get(&mut self) -> &str {
        self.0.next().unwrap()
    }
    fn read<T: std::str::FromStr>(&mut self) -> T {
        self.get().parse().ok().unwrap()
    }
}

Measured memory_bytes: 4352
#include<iostream>
using namespace std;
int main()
{
  int s;
  int a,b,c;
  cin>>a>>b;
  s=6-(a+b);;
  if(s==3)
  cout<<3;
  else if(s==2)
    cout<<2;
  else
    cout<<1;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int issq(int dist){
  int i;
  int ans=0;
  for(i=0;i<128;i++){
    if(dist==i*i) ans=1;
  }
  return ans;
}

int main()
{
  int i, j, k, n, d;
  int x[10][10];
  scanf("%d%d", &n, &d);
  for(i=0; i<n; i++){
    for(j=0; j<d; j++){
      scanf("%d", &x[i][j]);
    }
  }
  int dist;
  int count=0;
  for(i=0; i<n; i++){
    for(j=i+1; j<n; j++){
      dist=0;
      for(k=0; k<d; k++){
        dist+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
      }
      if(issq(dist)) count++;
    }
  }
  printf("%d\n", count);
  return 0;
}

Measured memory_bytes: 128
import java.io.*;
import java.util.*;

class Main {
    
    private static int cnt = 0;
    
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(reader.readLine());
        int[] arr = new int[n];
        StringTokenizer st = new StringTokenizer(reader.readLine());
        for (int i = 0; i < n; i++) {
            arr[i] = Integer.parseInt(st.nextToken());
        }
        reader.close();
        
        mergeSort(arr, 0, n-1);
        System.out.print(arr[0]);
        for (int i = 1; i < n; i++) {
            System.out.print(" " + arr[i]);
        }
        System.out.println();
        System.out.println(cnt);
    }
    
    private static void mergeSort(int[] arr, int floor, int ceiling) {
        if (floor < ceiling) {
            int mid = floor + (ceiling - floor) / 2;
            mergeSort(arr, floor, mid);
            mergeSort(arr, mid+1, ceiling);
            merge(arr, floor, mid, ceiling);
        }
    }
    
    private static void merge(int[] arr, int floor, int mid, int ceiling) {
        int n1 = mid - floor + 1;
        int n2 = ceiling - mid;
        int[] L = new int[n1+1];
        int[] R = new int[n2+1];
        for (int i = 0; i < n1; i++) L[i] = arr[floor + i];
        for (int i = 0; i < n2; i++) R[i] = arr[mid + 1 + i];
        L[n1] = Integer.MAX_VALUE;
        R[n2] = Integer.MAX_VALUE;
        int i = 0;
        int j = 0;
        for (int k = floor; k <= ceiling; k++) {
            cnt++;
            if (L[i] < R[j]) {
                arr[k] = L[i++];
            } else {
                arr[k] = R[j++];
            }
        }
    }
}



Measured memory_bytes: 124904
from __future__ import print_function
# import numpy as np
# import numpypy as np
import sys
input = sys.stdin.readline

def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

import math
import string
import fractions
from fractions import Fraction
from fractions import gcd

def lcm(n,m):
    return int(n*m/gcd(n,m))

import re
import array
import copy
import functools
import operator

import collections
import itertools
import bisect
import heapq


from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace

from queue import PriorityQueue as pq

def reduce(p, q):
    common = fractions.gcd(p, q)
    return (p//common , q//common )
# from itertools import accumulate
# from collections import deque

import random


def main():
    S = input().strip()
    if S=="SUN":
        print(7)
    elif S=="MON":
        print(6)
    elif S=="TUE":
        print(5)
    elif S=="WED":
        print(4)
    elif S=="THU":
        print(3)
    elif S=="FRI":
        print(2)
    elif S=="SAT":
        print(1)
    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 67436
import org.omg.Messaging.SYNC_WITH_TRANSPORT;

import javax.management.monitor.CounterMonitor;
import java.lang.reflect.Array;
import java.math.BigDecimal;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        //
        //Euclid e1=new Euclid();//ユークリッドの互除法
        //Compute c1=new Compute();//累積和，
        //変数
        int count = 0;
        boolean sw = false;
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        double dMax = Double.MIN_VALUE;
        double dMin = Double.MAX_VALUE;
        int answer = 0;
        //String answer="Yes";
        //StringBuilder answer=new StringBuilder();
        //List<Integer> list = new ArrayList<>();
        //int array[] = new int[];

        //入力
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();

        int a=N/K;
        int b=N%K;
        int c=a+b;
        answer=c-a;
        //出力
        //BigDecimal bd = new BigDecimal(answer);
        //System.out.println(bd.setScale(12,BigDecimal.ROUND_DOWN));
        //System.out.println(String.format("%.0f",answer));
        System.out.println(answer);
    }
}

Measured memory_bytes: 21844
#include <iostream>
int main(){
	int d, n;
	std::cin >> d >> n;
	int ans = 1;
	for (int i = 0; i < d; i++){
		ans *= 100;
	}
	if (n==100){
		ans *= 101;
	}else{
		ans *= n;
	}
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 1e-5
#define LONG_INF 1e18
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL
#define MOD 998244353LL
#define seg_size 262144*4
#define REP(a,b) for(long long a = 0;a < b;++a)
int grid[400][400] = {};
int bad[400] = {};
long long powing(long long a, long long b) {
	long long ans = 1;
	while (b != 0) {
		if (b % 2 == 1) {
			ans *= a;
			ans %= MOD;
		}
		a *= a;
		a %= MOD;
		b /= 2;
	}
	return ans;
}
int main() {
	int n, m;
	cin >> n >> m;
	REP(i, n) {
		REP(q, m) {
			cin >> grid[i][q];
		}
	}
	long long rank = 0;
	for (int i = 0; i < n; ++i) {
		int itr = -1;
		for (int q = 0; q < m; ++q) {
			if (bad[q] == 1) continue;
			if (grid[i][q] == 1) {
				itr = q;
				break;
			}
		}
		if (itr == -1) continue;
		for (int q = 0; q < m; ++q) {
			if (grid[i][q] == 1 && q != itr) {
				for (int j = 0; j < n; ++j) {
					grid[j][q] += grid[j][itr];
					grid[j][q] %= 2;
				}
			}
		}
		bad[itr] = 1;
		rank++;
	}
	cout << (powing(2, n + m - 1) - powing(2, n + m - 1 - rank) + MOD) % MOD << endl;
}

Measured memory_bytes: 1016
def main():
    L, R = map(int, input().split())
    if R // 2019 > L // 2019:
        print(0)
        return
    retval = 2019
    for i in range(L, R):
        for j in range(i+1, R+1):
            retval = min(retval, (i % 2019 * j % 2019) % 2019)
            if retval == 0:
                print(0)
                return
            
    print(retval)
    return
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;

alias sread = () => readln.chomp();
ulong bignum = 1_000_000_007;
alias Pair = Tuple!(long, "number", long, "times");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void main()
{
    auto s = sread();
    long[dchar] count;
    foreach (e; s)
    {
        count[e]++;
    }
    long remove;
    if ('0' in count && '1' in count)
        remove = min(count['0'], count['1']);

    writeln(remove * 2);
}

Measured memory_bytes: 508
//D.cpp
#include<bits/stdc++.h>

#include <unordered_map>
using namespace std;

int main(){
	int n;
	int w;
	cin >> n >> w;
	vector< vector<int> > warr(n, vector<int>(2, 0));
	for(int i = 0; i < n; i++){
		cin >> warr[i][0] >> warr[i][1];
	}
	int ans = 0;
	vector<vector<long long int> >dp_arr(n+1, vector<long long int>(w+1, 0));
	for(int i = 1; i <= n; i++){
		//cout << i << endl;
		for(int ww = 0; ww <= w; ww++){
			//cout << " " << ww << endl; 
			dp_arr[i][ww] = max(dp_arr[i-1][ww], ww - warr[i-1][0] >= 0 ? dp_arr[i-1][ww - warr[i-1][0]] + warr[i-1][1]:0);
		}
	}

	cout << dp_arr[n][w] << endl;
	return 0;
		
}

Measured memory_bytes: 83092
#include <iostream>

using namespace std;

typedef long long int ll;

int main(){
	ll x, y;
	cin >> x >> y;

	ll a = x;
	int cnt = 0;
	while(a <= y){
		cnt += 1;
		a *= 2;
	}
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 256
import sys;input=sys.stdin.readline;N=int(input());A=[-1]*N;B=[-1]*N
for i in range(N):
    A[i],B[i]=map(int,input().split())
ans=min(sum(A),sum(B));temp=[(A[i],i) for i in range(N)]+[(B[i],i) for i in range(N)];temp.sort();data=[0]*N
for i in range(N):data[temp[i][1]]+=1
S=sum(temp[i][0] for i in range(N))
if max(data)==2:
    print(S)
else:
    for i in range(N):ans=min(ans,S+max(A[i],B[i])-temp[N-1-(temp[N-1][1]==i)][0]);
    print(ans)


Measured memory_bytes: 91664
#include<stdio.h>
#include<string>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<string.h>
#include<map>
#include<queue>

using namespace std;

typedef pair<int,int> pii;

#define rep(i,j) for(int i=0;i<(j);i++)
#define reps(i,j,k) for(int i=j;i<=k;i++)
#define in(i,j,k) ((i)>=(j)&&(i)<=(k))


int main(){
	char s[101],t[101];
	int cnt=0;
	while(~scanf("%s",s)){
		strcpy(t,s);
		reverse(t,t+strlen(t));
		cnt+=strcmp(s,t)==0;
	}
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 1144
N = int(input())
A = list(map(int, input().split()))
num_list = [0] * 100
P = 10 ** 9 + 7
for i in A:
    tmp = i
    for j in range(len(bin(i)) - 2):
        num_list[j] += (tmp & 1)
        tmp = tmp >> 1
ans = 0


def func(N, n):
    return (N - n) * n


for i in range(100):
    ans = (ans + func(N, num_list[i]) * 2 ** i) % P
print(ans)


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

int main() {
    string S;
    cin >> S;
    
    int N = S.size();
    bool flg = true;
    
    if ( S[0] != 'A' ) flg = false;
    int count = 0;
    for ( int i = 2; i < N-1; ++i){
        if ( S[i] == 'C' ) ++count;
    }
    if ( count != 1 ) flg = false;
    
    for ( int i = 1; i < N; ++i){
        int x = S[i] - 'a';
        if ( S[i] != 'C' ) {
            if ( x < 0 or x >= 26 ) flg = false;
        }
    }
    
    if ( flg ) {
        cout << "AC" << endl;
    } else {
        cout << "WA" << endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 3636
import Data.List (sortOn)

countMaxAscendings [_] _ maxC = maxC
countMaxAscendings (q0:q1:qs) c maxC
  | q0<q1 = countMaxAscendings (q1:qs) (c+1) $ max maxC (c+1)
  | otherwise = countMaxAscendings (q1:qs) 1 maxC

main :: IO ()
main = do
  n <- read <$> getLine :: IO Integer
  ps <- map read.lines <$> getContents :: IO [Integer]
  let qs = sortOn snd $ zip [1..] ps
  print $ n - countMaxAscendings (map fst qs) 1  1


Measured memory_bytes: 66812
#include <iostream>
#include <vector>

bool dfs(unsigned v,
         unsigned N,
         std::vector<bool> &path,
         const std::vector<std::vector<unsigned>> &edges,
         std::vector<bool> &used) {
  used[v] = true;
  for (auto &i : edges[v]) {
    if (i == N) {
      path[v] = true;
      return true;
    } else {
      if (!used[i]) {
        auto b = dfs(i, N, path, edges, used);
        if (b) {
          path[v] = true;
          return true;
        }
      }
    }
  }
  return false;
}

unsigned cnt(unsigned v,
             unsigned long long &ans,
             const std::vector<bool> &path,
             const std::vector<std::vector<unsigned>> &edge,
             std::vector<bool> &used) {
  unsigned ret = v;
  if (!used[v]) { ++ans; }
  used[v] = true;
  for (auto &i : edge[v]) {
    if (!path[i] && !used[i]) {
      cnt(i, ans, path, edge, used);
    } else if (path[i] && !used[i]) {
      ret = i;
    }
  }
  return ret;
}

int main() {
  unsigned N;
  std::cin >> N;
  std::vector<std::vector<unsigned>> edge(N + 1);
  for (unsigned i = 0; i < N - 1; ++i) {
    unsigned a, b;
    std::cin >> a >> b;
    edge[a].push_back(b);
    edge[b].push_back(a);
  }
  std::vector<bool> path(N + 1, false);
  std::vector<bool> used(N + 1, false);
  path[N] = true;
  dfs(1, N, path, edge, used);
  std::fill(used.begin(), used.end(), false);
  unsigned long long fen = 0;
  unsigned long long snuke = 0;
  unsigned vf = 1;
  unsigned vs = N;
  for (unsigned i = 0; i < N - 2; ++i) {
    if (i % 2) {
      vs = cnt(vs, snuke, path, edge, used);
    } else {
      vf = cnt(vf, fen, path, edge, used);
    }
  }
  std::cout << (fen > snuke ? "Fennec" : "Snuke") << std::endl;
  return 0;
}

Measured memory_bytes: 13568
import java.util.*;
import java.io.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    int a = scan.nextInt();
    int b = scan.nextInt();
    int siguma = 0;

    for(int i = 1; i <= n; i++){
      int sum = 0;
      int j = i;
      while(j > 0){
        sum += j%10;
        j /= 10;
      }
      if(a <= sum && sum <= b)
        siguma += i;
    }
    System.out.println(siguma);
  }
}


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

int dp[1100][1100];

int solve(string s, string t) {
  for (int i = 0; i < 1100; i++) {
    for (int j = 0; j < 1100; j++) {
      dp[i][j] = 0;
    }
  }
  for (int i = 1; i <= s.size(); i++) {
    for (int j = 1; j <= t.size(); j++) {
      if (s[i - 1] == t[j - 1]) {
        dp[i][j] = dp[i - 1][j - 1] + 1;
      }
      else {
        dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
      }
    }
  }
  return dp[s.size()][t.size()];
}

int main() {
  int q;
  cin >> q;
  vector<int> ans;
  for (int i = 0; i < q; i++) {
    string X, Y;
    cin >> X;
    cin >> Y;
    ans.push_back(solve(X, Y));
  }
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 7936
import sys
def input():
    return sys.stdin.readline()[:-1]
M,N=map(int,input().split())
X=list(map(int,input().split()))
X.sort()
l=[None]*(N-1)
for i in range(N-1):
    l[i]=X[i+1]-X[i]
l.sort()
if N>M:
    print(sum(l[:N-M]))
else:
    print(0)

Measured memory_bytes: 13960
#include <bits/stdc++.h>
using namespace std;
using lli = long long int;
using ulli = unsigned long long int;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl


namespace atcoder {
	template<typename T>
	T ncr(T left, T right) {
		right = min(left - right, right);
		T ans = 1;
		for (T i = 1; i <= right; i++) {
			ans = ans * (left - right + i) / i;
		}
		return ans;
	}

	const int LIMIT = 1000000007;
	const int tenfive = 100000;
}

using namespace atcoder;

int main() {
	string s;
	cin >> s;
	int year = stoi(s.substr(0, 4));
	int month = stoi(s.substr(5, 2));
	int day = stoi(s.substr(8, 2));
	bool isH = true;
	if (year > 2019) {
		isH = false;
	}
	else if (year == 2019) {
		if (month > 4) {
			isH = false;
		}
	}
	cout << (isH ? "Heisei" : "TBD") << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		for (int i = 0; i < n; i++) {
			h -= sc.nextInt();
		}
		sc.close();
		if (h <= 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 57640
#include<iostream>
#include<algorithm>
using namespace std;
int n; long double l, u[86400];
bool solve(long double q) {
	long double T = l;
	for (int i = 0; i < 86400; i++) {
		T -= u[i % 86400]; T += q; if (T > l)T = l;
		if (T < 0)return false;
	}
	long double U = T;
	for (int i = 0; i < 86400; i++) {
		T -= u[i % 86400]; T += q; if (T > l)T = l;
		if (T < 0)return false;
	}
	if (T < U - 0.000001)return false;
	return true;
}
int main() {
	while (true) {
		cin >> n >> l; if (n == 0)break;
		for (int i = 0; i < 86400; i++)u[i] = 0;
		for (int i = 0; i < n; i++) {
			int s, t; long double v; cin >> s >> t >> v;
			for (int j = s; j < t; j++)u[j] = v;
		}
		long double L = 0, R = 1234567, M;
		for (int i = 0; i < 80; i++) {
			M = (L + R) / 2;
			if (solve(M) == true)R = M;
			else L = M;
		}
		printf("%.13Lf\n", M);
	}
	return 0;
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> pipii;
typedef pair<pii, pii> piipii;

#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define eb emplace_back

int a[300005];
ll dp1[300005], dp2[300005];
int main(){
    int n;
    scanf("%d", &n);
    for(int i=1;i<=3*n;i++) scanf("%d", &a[i]);
    priority_queue<int> pq;
    ll sum = 0;
    for(int i=1;i<=n;i++) pq.push(-a[i]), sum += a[i];
    dp1[n] = sum;
    for(int i=n+1;i<=2*n;i++){
        sum += a[i];
        pq.push(-a[i]);
        sum -= -pq.top();
        pq.pop();
        dp1[i] = sum;
    }
    sum = 0;
    while(!pq.empty()) pq.pop();
    for(int i=3*n;i>=2*n+1;i--) pq.push(a[i]), sum += a[i];
    dp2[2*n+1] = sum;
    for(int i=2*n;i>=n+1;i--){
        sum += a[i];
        pq.push(a[i]);
        sum -= pq.top();
        pq.pop();
        dp2[i] = sum;
    }
    ll ans = -1e18;
    for(int i=n;i<=2*n;i++) ans = max(ans, dp1[i] - dp2[i+1]);
    printf("%lld\n", ans);
}

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

int main(void){
    long long a,b,k;
    cin>>a>>b>>k;
    if((a+b-k)<0){
        cout<<"0 0"<<endl;
    }else if(a-k<0){
        cout<<"0 "<<b+(a-k)<<endl;
    }else{
        cout<<a-k<<" "<<b<<endl;
    }
}


Measured memory_bytes: 256
from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    N = int(input())
    C = []
    S = []
    F = []
    for i in range(N-1):
        s1, s2, s3 = (int(_) for _ in input().split())
        C.append(s1)
        S.append(s2)
        F.append(s3)
    ans = []
    for h in range(N-1):
        time = 0
        for i in range(h,N-1):
            if i ==h:
                time=S[i]+C[i]
                continue
            if time <= S[i]:
                time=S[i]+C[i]
            else:
                tmp_t = S[i]
                while time > tmp_t:
                    tmp_t += F[i]
                time = tmp_t +C[i]
        ans.append(time)
    print('\n'.join(str(_) for _ in ans))
    print(0)
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 41808
gokei=0
m=0
N=int(input())


a_i=list(map(int,input().split())) #N回まで要素をいれると次にいくようにしたい。

for i in range(N):  
  gokei=gokei+a_i[m]
  m=m+1               #gokei=sum(a_i)でも
#合計値 list[0]+list[1]+...+list[N]  #Nは定数

#最小値、最大値の比較→それぞれソート
saidai=max(a_i)
saitei=min(a_i)
print(saitei,saidai,gokei)

Measured memory_bytes: 8624
#include<stdio.h>
int f[200008],resx[200008],resy[200008];
int Mana(int x)
{
    if(x==f[x])return x;
    return f[x]=Mana(f[x]);
}
int main()
{
    long long sum=0;
    int u,v,n;
    scanf("%d",&n);
    for(int i=0;i<=200001;i++)f[i]=i;
    for(int i=0;i<n;i++)
    {
        scanf("%d%d",&u,&v);
        f[Mana(u)]=Mana(v+100000);
    }
    for(int i=1;i<=100000;i++)resx[Mana(i)]+=1;
    for(int i=100001;i<=200000;i++)resy[Mana(i)]+=1;
    for(int i=1;i<=200000;i++)sum+=(long long)resx[i]*(long long)resy[i];
    printf("%lld\n",sum-n);
}

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

int dp[3005][3005];
string s1,s2;

string generate()
{
	int i=s1.length(),j=s2.length();
	string str="";
	while(i>0&&j>0)
	{
		if(s1[i-1]==s2[j-1])
        {
        	str=s1[i-1]+str;
         	i--;j--;
    	}
    	else if(dp[i-1][j]>=dp[i][j-1])
    	i--;
    	else
    	j--;	
	}
	return str;
}

ll func()
{
	int i,j;
	for(i=0;i<=s1.length();i++)
	dp[i][0]=0;
	for(i=0;i<=s2.length();i++)
	dp[0][i]=0;
	
	for(i=1;i<=s1.length();i++)
	{
		for(j=1;j<=s2.length();j++)
		{
			if(s1[i-1]==s2[j-1])
			dp[i][j]=dp[i-1][j-1]+1;
			else
			dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
		}
	}
	return dp[s1.length()][s2.length()];
}

int main()
{
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
    cin>>s1>>s2;
    func();
    cout<<generate();
}

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

int main()
{
	int n, a[1000000], max=0, maxi=0, max2i=0;
	cin>>n;
	for(int i =0;i<n;++i){
		cin>>a[i];
		if(a[i]>max){
			maxi=i;
			max=a[i];
		}
	}
	max=0;
	for(int i =0;i<n;++i){
		if(i==maxi)continue;
		if(a[i]>max){
			max2i=i;
			max=a[i];
		}
	}
	for(int i =0;i<n;++i){
		if(i!=maxi)cout << a[maxi] << endl;
		else cout << a[max2i] << endl;
	}
}

Measured memory_bytes: 4096
#include <iostream>

using namespace std;

int main(int argc, char *argv[]) {
	int H, W, N;
	cin >> H >> W >> N;

	int C[100][100] = {};
	int x = 0, y = 0;
	for (int i = 0; i < N; i++) {
		int Ai;
		cin >> Ai;


		for (int j = 0; j < Ai; j++) {
			C[x][y] = i + 1;

			if (y % 2 == 0) x++;
			else x--;
			if (x < 0) { x = 0; y++; }
			if (x >= W) { x = W - 1; y++; }
		}
	}

	for (int y = 0; y < H; y++) {
		for (int x = 0; x < W; x++) {
			cout << C[x][y] << " ";
		}
		cout << endl;
	}

	return 0;
}

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

public class Main {

    int N;
    int[] A,B;

    public void solve() {
        N = nextInt();
        A = new int[N];
        B = new int[N];

        for(int i = 0;i < N;i++){
            A[i] = nextInt();
            B[i] = nextInt();
        }

        long ans = 0;
        for(int i = N-1;i >= 0;i--){
            long AA = A[i] + ans;
            long M = AA % B[i];
            if (M > 0) {
                ans += B[i] - M;
            }
        }

        out.println(ans);
    }

    public static void main(String[] args) {
        out.flush();
        new Main().solve();
        out.close();
    }

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[2048];
    private int p = 0;
    private int buflen = 0;

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

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

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

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

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

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

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

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

Measured memory_bytes: 44556
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#include<functional>
#include<queue>
#include<stack>
using namespace std;
int main(){
    int n;
    cin>>n;
    int s[1919]={};
    for(int i=1;i<=n;i++){
        int k=i;
        for(int j=2;j<=i;j++){
            if(k%j==0){
                s[j]++;
                k/=j;
                j--;
            }
        }
    }
    long long int ans=1;
    for(int i=0;i<=1000;i++){
        if(s[i]!=0){
            ans*=s[i]+1;
        }
        if(ans>=1000000007){
            ans=ans%1000000007;
        }

    }
    cout<<ans<<endl;
}   




Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <iterator>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;

#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define MIN(vec) min_element(vec.begin(), vec.end())  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(vec.begin(), vec.end())
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(vec.begin(), vec.end(), 0LL)  // 0 は初期値

int main() {
    // input
    ll N, K;
    cin >> N >> K;
    
    // calculation
    if (N == 1) {
        // (1, 1, 1) のみ
        if (2%K == 0) {
            cout << 1 << "\n";
        } else {
            cout << 0 << "\n";
        }
    } else {
        // (a, b, c) をKで割った余りの和が，
        // 0: 全て K の倍数のとき
        // K: (2, 8) 2%5 = 2, 8%5 = 3, (2+3) = 5
        ll res = 0;
        
        // a, b, c 全てが K の倍数の時
        // N=9, K=3, (3, 3, 3), (6, 6, 6), (9, 9, 9) 
        // 余りの和が K のとき
        // K が奇数の時：
        
        if (K%2 != 0) {
            // K が奇数の時
            res += pow((N/K), 3);
        } else {
            // K が偶数の時
            res += pow((N/K), 3);
            ll sum = 0;
            for (ll i = 1; i <= N; ++i) {
                if (i%K == K/2) {
                    sum++;
                }
            }
            
            if (sum != 0) res += pow(sum, 3);
        } 
        
        cout << res << "\n";
    }
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>

using namespace std;
char c[110][110];
int main(){
    int h,w;
    cin>>h>>w;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++)cin>>c[i][j];
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++)cout<<c[i][j];
        cout<<endl;
        for(int j=0;j<w;j++)cout<<c[i][j];
        cout<<endl;
    }
    
}

   


Measured memory_bytes: 256
N=int(input())
A,B=map(int,input().split())
P=list(map(int,input().split()))
C=[0]*3
for i in range(N):
  if(P[i]<=A):
    C[0]+=1
  elif(P[i]<=B):
    C[1]+=1
  else:
    C[2]+=1
C.sort()
print(C[0])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
typedef tree<int, null_type, less<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;
 
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define pb push_back
#define pf push_front
#define pii pair<int,int>
#define mp make_pair
#define vi vector<int>
#define vip vector<pair<int,int> >
#define ff first
#define ss second
#define int long long
#define SIZE 200010
#define mod 1000000007
#define BIG 998244353
#define s(t) scanf("%d",&t)
#define p(t) printf("%d\n",t)
#define mii map<int,int>
#define MSET(table,i) memset(table, i, sizeof(table))
#define endl '\n'
#define tc int t;cin>>t;while(t--)
#define pi  3.1415926358
#define print(x) for(auto el: x) cout<<el<<" ";cout<<endl
#define bits(x) __builtin_popcount(x)
#define minimum(a,n) min_element(a,a+n)-a
#define maximum(a,n) max_element(a,a+n)-a
#define pqbig priority_queue<int>
#define pqsmall priority_queue<int,vector<int>,greater<int> >
#define all(v) v.begin(),v.end()
#define sitr set<int>:: iterator
#define mitr map<int,int>:: iterator
 
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
 
const int N=2e5+5;
vi adj[N];
int n,q;
int ans[N];
int cnt;

void dfs(int node,int pt)
{
    int prev=ans[node];
    ans[node]+=cnt;
    cnt+=prev;
    for(int i=0;i<adj[node].size();i++)
    {
        if(adj[node][i]!=pt)
            dfs(adj[node][i],node);
    }
    cnt-=prev;
}

int32_t main()
{
    fast;
    cin>>n>>q;
    for(int i=1;i<n;i++)
    {
        int x,y;cin>>x>>y;
        adj[x].pb(y);
        adj[y].pb(x);
    }
    for(int i=0;i<q;i++)
    {
        int x,y;cin>>x>>y;
        ans[x]+=y;
    }
    dfs(1,0);
    for(int i=1;i<=n;i++)
        cout<<ans[i]<<' ';
}

Measured memory_bytes: 27392
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    string s;
    cin>>s;
    ll n=s.size();
    rep(i,n/2){
        if(s[i]!=s[n-i-1]){
            cout<<"No"<<endl;
            return 0;
        }
    }
    rep(i,(n-1)/4){
        if(s[i]!=s[(n-1)/2-i-1]){
            cout<<"No"<<endl;
            return 0;
        }
    }
    for(ll i=(n+3)/2-1;i<n;i++){
        if(s[i]!=s[n-i-1]){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main(){
    int N;
    cin >> N;
    bool ok=false;
    for(int i=1;i<10;++i){
        for(int j=1;j<10;++j){
            if(i*j == N){
                cout << "Yes" << endl;
                ok = true;
                break;
            }
            
        }
        if (ok == true) break;
    }
    if(ok == false) cout << "No" << endl;

    return 0;

}

Measured memory_bytes: 256
bingo = [list(map(int,input().split())) for i in range(3)]
n =  int(input())
num = [int(input()) for l in range(n)]
arr = [[],[],[]]

for number in num:
    cnt = 0
    for b in bingo:
        if number in b:
             arr[cnt].append(b.index(number))
        cnt  = cnt + 1

if len(arr[0]) == 3 or len(arr[1]) == 3 or len(arr[2]) == 3:
    print("Yes")
elif 0 in arr[0] and 1 in arr[1] and 2 in arr[2]:
    print("Yes")
elif 2 in arr[0] and 1 in arr[1] and 2 in arr[0]:
    print("Yes")
elif 0 in arr[0] and 0 in arr[1] and 0 in arr[2]:
    print("Yes")
elif 1 in arr[0] and 1 in arr[1] and 1 in arr[2]:
    print("Yes")
elif 2 in arr[0] and 2 in arr[1] and 2 in arr[2]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9184
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e15)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define arrdump(n,a) for(int i=0;i<n;i++) {cout<<((i>0)? " ":"")<<a[i];}cout<<"\n";


typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://atcoder.jp/contests/abc097/tasks/abc097_b

int main() {
    int X; cin >> X;
    vector<int> expo(X+1);
    expo[1] = 1;

    for (int i = 2; i < X; i++) {
        int v = i*i;
        while(v <= X) {
            expo[v] = 1;
            v *= i;
        }
    }

    for (int i = X; i >= 0 ; i--) if (expo[i]){
            cout << i << "\n";
            return 0;
    }

    return 0;
}


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

using namespace std;
using ll=long long;
using vi=vector<int>;
using vl=vector<ll>;
using vs=vector<string>;
using li=list<int>;
using lil=list<ll>;
using lis=list<string>;
using fli=forward_list<int>;
using fll=forward_list<ll>;
using fls=forward_list<string>;
using si=stack<int>;
using sl=stack<ll>;
using ss=stack<string>;
using qi=queue<int>;
using ql=queue<ll>;
using qs=queue<string>;
using pqi=priority_queue<int>;
using pql=priority_queue<ll>;
using pqs=priority_queue<string>;
using dqi=deque<int>;
using dql=deque<ll>;
using dqs=deque<string>;

#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep2(i, a, n) for(int i = (a); i < (n); i++)
#define repr(i, n) for(int i = (n); i >= 0; i--)
#define repr2(i, a, n) for(int i = (n); i >= (a); i--)

template<typename T,typename U>
void Inparray(T &f,U n){
  for(int i=0;i<n;i++) cin>>f[i];
}

template<typename T,typename U>
void Printarray(T f,U n){
  for(int i=0;i<n;i++) i!=n ? cout<<f[i]<<" " : cout<<f[i];
}

template<typename T,typename U>
void Printarray2(T f,U n){
  for(int i=0;i<n;i++) cout<<f[i]<<endl;
}

void flagfunc(bool flag,string A,string B){
  flag ? cout<<A<<endl : cout<<B<<endl;
}

void flag2func(bool flag){
  flag ? cout<<"Yes"<<endl : cout<<"No"<<endl;
}

void flag3func(bool flag){
  flag ? cout<<"YES"<<endl : cout<<"NO"<<endl;
}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int n,num,hoge,ans=0;cin>>n;
  rep2(i,1,n+1){
    num=0;
    hoge=i;
    while(hoge>0){
      hoge/=10;
      num++;
    }
    //cout<<i<<" "<<num<<endl;
    if(num%2==1)ans++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
#define FAST  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define ll long long int 
#define ar array
#define pb push_back
#define fi(a,b) for(ll i=a;i<(b);i++)
#define fj(a,b) for(ll j=a;j<(b);j++)
#define fk(a,b) for(ll k=a;k<(b);k++)

const int mod=998244353;
const int mxn=2e5+2;
int n,k;
vector<int> dp(mxn);
struct node
{
	ll s,m,lz;
} st[1<<19];


void update(int index,int val,int l2=0,int r2=n-1,int ci=0)
{
	if(l2==r2)
	{
		//st[ci].m=val;
		st[ci].s=val;
		return ;
	}
	int mid=(l2+r2)/2;
	if(index<=mid)
		update(index,val,l2,mid,2*ci+1);
	else
	{
		update(index,val,mid+1,r2,2*ci+2);
	}
	st[ci].s=(st[2*ci+1].s+st[2*ci+2].s)%mod;
	st[ci].m=min(st[2*ci+1].m,st[2*ci+2].m);
}
	
int query(int l1,int r1,int l2=0,int r2=n-1,int ci=0)
{
	if(l1<=l2&&r1>=r2)
	{
		return st[ci].s;
	}
	if(l2>r1||r2<l1)
	{
		return 0;
	}
	int mid=(l2+r2)/2;
	
	//return min(query(l1,r1,l2,mid,2*ci+1),query(l1,r1,mid+1,r2,2*ci+2));
	return (query(l1,r1,l2,mid,2*ci+1)+query(l1,r1,mid+1,r2,2*ci+2))%mod;
}

int main()
{
	FAST;
	//#ifndef ONLINE_JUDGE
		//freopen("input.txt","r",stdin);
		//freopen("output.txt","w",stdout);
	//#endif
	//int tt;
	//cin>>tt;
	//while(tt--)
	{
		cin>>n>>k;
		dp=vector<int> (n+1);
		dp[0]=1;
		update(0,1);
		vector<pair<int,int>> pairs;
		fi(0,k)
		{
			int l,r;
			cin>>l>>r;
			pairs.pb({l,r});
		}
		//sort(pairs.begin(),pairs.end());	
		fi(1 ,n)
		{
			fj(0,k)
			{
				if(i<pairs[j].first) continue;
				int left=max(0LL,(i-pairs[j].second));
				int right=(i-pairs[j].first);
				dp[i]=(dp[i]+query(left,right))%mod;
				update(i,dp[i]);
			}
		}
		cout<<dp[n-1];
		
	}		
}


Measured memory_bytes: 16364
#include <bits/stdc++.h>
#include <string>
using namespace std;
int intinput() {
	int x;
	cin >> x;
	return x;
}
vector<int> forintinput(int n) {
	vector<int> x(100000);
	for(int i = 0;i < n;i++) cin >> x[i];
	return x;
}
int main(){
	int a,b;
	a = intinput();
	b = intinput();
	cout << a * b << endl;
}

Measured memory_bytes: 3636
#include<stdio.h>

int main(){
    int b,f,r,v;
    int i,j,n,k;
    int a[4][3][10];
    for (i=0;i<4;i++){
        for (j=0;j<3;j++){
            for (k=0;k<10;k++){
                a[i][j][k]=0;
            }
        }
    }
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d %d %d %d",&b,&f,&r,&v);
        a[b-1][f-1][r-1]+=v;
    }
    for(i=0;i<4;i++){
        for(j=0;j<3;j++){
            for(k=0;k<10;k++){
                printf(" %d",a[i][j][k]);
            }
            printf("\n");
        }
        if(i<3)
        printf("####################\n");
    }
    return 0;
}

Measured memory_bytes: 1828
#include<cstdio>
#include<cstdlib>
#include<cstring>

struct Node {
  int key;
  Node *next, *prev;	
};

Node *nil;

Node* listSearch(int key) {
	Node *cur = nil->next;
	while (cur != nil && cur->key != key) {
		cur = cur->next;
	}
    return cur;
}

void init() {
	nil = (Node *)malloc(sizeof(Node));
	nil->next = nil;
	nil->prev = nil;
}

void printList() {
	Node *cur = nil->next;
	int isf = 0;
	while(1) {
		if (cur == nil) break;
		if (isf++ > 0) printf(" ");
		printf("%d", cur->key);
		cur = cur->next;
	}
	printf("\n");
}

void deleteNode(Node *t) {
	if(t==nil) return;
	t->prev->next = t->next;
	t->next->prev = t->prev;
	free(t);
}

void deleteFirst() {
	deleteNode(nil->next);
}

void deleteLast() {
	deleteNode(nil->prev);
}

void deleteKey(int key) {
	deleteNode(listSearch(key));
}

void insert(int key) {
    Node *x = (Node *)malloc(sizeof(Node));
	x->key = key;
	x->next = nil->next;
	nil->next->prev = x;
	nil->next = x;
    x->prev = nil;	
}

int main() {
	int key, n, i;
	int size = 0;
	char com[20];
    int np = 0, nd = 0;
	scanf("%d", &n);
	init();
	for(i=0; i<n; i++) {
		scanf("%s%d", &com, &key);
		if(com[0] == 'i') {
			insert(key);
			np++;
			size++;
		} else if(com[0] == 'd'){
			if(strlen(com) > 6) {
				if(com[6] == 'F') deleteFirst();
				else if (com[6] == 'L') deleteLast(); 
			} else {
				deleteKey(key);
			}
			nd++;
			size++;
		}
	}
	
	printList();
    
	return 0;	
	
}

Measured memory_bytes: 33816
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define outl(x) cout<< (x) << '\n'
using ll = long long;
static constexpr int INF = 0x3f3f3f3f;


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

    ll N, M;
    vector<int> div;

    cin >> N >> M;
    for(int i= 1; i*i <= M; ++i) {
        if (M % i == 0) {
            div.push_back(i);
            div.push_back(M / i);
        }
    }

    sort(div.rbegin(), div.rend());
    for(ll e: div) {
        if (e*N <= M) { outl(e); return 0; }
    }

    return 0;
}



Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {

//    	File file = new File("test.txt");
//    	Scanner sc = new Scanner(file);
    	Scanner sc = new Scanner(System.in);
    	int N = sc.nextInt();
    	int M = sc.nextInt();
    	int[] ary = new int[M];
    	int[] ary2 = new int[M-1];
    	for(int i = 0; i < M; i++){
    		ary[i] = sc.nextInt();
    	}
    	sc.close();
    	Arrays.sort(ary);
    	for(int i = 0; i < M-1; i++){
    		ary2[i] = Math.abs(ary[i] - ary[i+1]);
    	}
    	Arrays.sort(ary2);
    	int ans = 0;
    	for(int i = 0; i < (M - N); i++){
    		ans += ary2[i];
    	}
    	System.out.println(ans);
    }
}


Measured memory_bytes: 57596
using System;
// using System.Collections.Generic;
// using System.Linq;

class Program
{
    static void Main()
    {
        long N = long.Parse(Console.ReadLine());
        Console.WriteLine(calc(1L, N) - calc(3L, N) - calc(5L, N) + calc(15L, N));
        return;
    }

    static long calc(long n, long N)
    {
        return (n + N / n * n) * (N / n) / 2;
    }
}

Measured memory_bytes: 27448
def solve():
  a,b,c = (int(i) for i in input().split())
  queue = [[a,b,c]] #mugencheck
  ct = 0
  while ct <100000000:
    if a%2 ==1 or b%2 ==1 or c%2 == 1: break
    #とりあえず交換simluration
    tmpa = a//2
    tmpb = b//2
    tmpc = c//2
    a = tmpb+tmpc
    b = tmpa+tmpc
    c = tmpa+tmpb
    if [a,b,c] in queue: 
      return -1
    else:
      ct += 1
      queue.append([a,b,c])
      #print(queue)
  return ct
                   
  
if __name__ == '__main__':
  print(solve())

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

using namespace std;
int joy=0, n;

int main() {
    cin >> n;
    int t = n / 500;
    joy += t * 1000;
    n -= t * 500;
    joy += (n / 5) * 5;
    printf("%d\n", joy);
}

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

int c[100000]{};
int main() {
	int a, b;
	scanf("%d%d", &a, &b);
	for (int d = 0; d<a; d++) { int e; scanf("%d", &e); c[d] = e; }
	int f[100000]{};
	int h = 0;
	for (int g = a - 2; g != -1; g--) {
		h = max(h, c[g + 1]);
		f[g] = h;
	}
	map<int, int>s;
	for (int r = 0; r < a - 1; r++) {
		s[f[r] - c[r]]++;
	}
	auto l = s.end();
	l--;
	cout << l->second << endl;
}

Measured memory_bytes: 5760
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <tuple>
#include <cmath>
#include <map>
#include <climits>
#include <deque>
#include <numeric>
using namespace std;
using Int = long long;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n,m) for(int i=n;i<m;i++)
int main()
{
    int R, G; cin >> R >> G;
    cout << 2 * G - R << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<long long> a(n), b(n);
    for(auto&& i : a){
        cin >> i;
    }
    for(auto&& i : b){
        cin >> i;
    }
    long long canmove = accumulate(begin(b), end(b), 0ll) - accumulate(begin(a), end(a), 0ll);
    long long aAdd = 0, bAdd = 0;
    for(int i = 0; i < n; i++){
        if(b[i] < a[i]){
            bAdd += a[i] - b[i];
            if(canmove < bAdd){
                cout << "No\n";
                return 0;
            }
        }
        else if(a[i] < b[i]){
            aAdd += (b[i] - a[i]) / 2 + (b[i] - a[i]) % 2;
            if(canmove < aAdd){
                cout << "No\n";
                return 0;
            }
        }
    }
    cout << "Yes\n";
}

Measured memory_bytes: 384
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
using namespace std;
#define DEBUG(x) cout<<#x<<"="<<x<<endl
#define DEBUG2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
typedef long long ll;
// #define LOCAL
const int MAXN=1e5+10;
int N,M;
vector<int>G[MAXN];
void read()
{
    ios::sync_with_stdio(false);
    cin>>N>>M;
    for(int u=1;u<=M;u++){
        int a,b;
        cin>>a>>b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
}
int signpost[MAXN];
int vis[MAXN];
int inq[MAXN];
void dfs(int rt,int fa)
{
    vis[rt]=true;
    signpost[rt]=fa;
    for(int v:G[rt]){
        if(vis[v])continue;
        dfs(v,rt);
    }
}
void bfs(int rt)
{
    queue<int>q;
    q.push(rt);
    inq[rt]=true;
    while(!q.empty()){
        int t=q.front();
        q.pop();
        for(int v:G[t]){
            if(inq[v])continue;
            signpost[v]=t;
            inq[v]=true;
            q.push(v);
        }
    }
}
void solve()
{
    read();
    bfs(1);
    for(int u=2;u<=N;u++){
        if(signpost[u]==0){
            cout<<"No";
            return;
        }
    }
    cout<<"Yes\n";
    for(int u=2;u<=N;u++){
        cout<<signpost[u]<<"\n";
    }
}
int main()
{
#ifdef LOCAL
    freopen("in.txt","r",stdin);
#endif
    solve();   
}

Measured memory_bytes: 10860