akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.util.Scanner;

public class Main {

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

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			if (n == 0)
				break;
			boolean[][] map = new boolean[21][21];
			for (int i = 0; i < n; i++) {
				int x = scanner.nextInt();
				int y = scanner.nextInt();
				map[y][x] = true;
			}
			int m = scanner.nextInt();
			int x = 10;
			int y = 10;
			while (m-- > 0) {
				char d = scanner.next().charAt(0);
				int num = scanner.nextInt();
				while (num-- > 0) {
					y += (d == 'N' ? 1 : 0) - (d == 'S' ? 1 : 0);
					x += (d == 'E' ? 1 : 0) -( d == 'W' ? 1 : 0);
					if (map[y][x]) {
						n--;
						map[y][x] = false;
					}
				}
			}
			System.out.println(n == 0 ? "Yes" : "No");
		}
	}
}

Measured memory_bytes: 38060
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::Integer;
#[allow(unused_imports)]
use proconio::derive_readable;
use proconio::fastout;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp;
#[allow(unused_imports)]
use std::collections::*;

#[fastout]
fn main() {
    input! {
        x: i64,
        k: i64,
        d: i64,
    }
    let x = x.abs();
    let min = x - k.checked_mul(d).unwrap_or(1 << 60);
    let mut ans = min.abs();
    let rem = (x + (k % 2) * d) % (2 * d);
    if rem >= min {
        ans = cmp::min(ans, rem);
    }
    let neg = rem - 2 * d;
    if neg >= min {
        ans = cmp::min(ans, neg.abs());
    }

    println!("{}", ans);
}


Measured memory_bytes: 2160
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

vector<ll> to[200000];

int main(void){
  ll n;
  cin >> n;
  REP(i, n-1){
    ll a;
    cin >> a;
    a--;
    to[a].emplace_back(i+1);
  }
  REP(i, n) cout << to[i].size() << endl;
  return 0;
}

Measured memory_bytes: 14468
#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;
using ll = long long;
using P = pair<int,int>;
using G = vector<vector<int>>;
const long long INF = 1LL << 60;

template<class T> inline bool chmin(T& a,T b) {
    if(a > b) {
        a = b;
    }
    return false;
}

template<class T> inline bool chmax(T& a, T b){
    if(a < b){
        a = b; 
        return true;
    }
    return false;
}

int main(){
  int n,w;
  cin >> n >> w;
  vector<int> weight(n,0);
  vector<int>  value(n,0);
  vector<vector<ll>> dp(n+1,vector<ll>(w+1,0));
  rep(i,n) cin>> weight[i] >> value[i];
  dp[0][0] = 0;
  for(int i=0;i<n;i++){
      for(int j=0;j<=w;j++){//ある時点での上限
          if(j - weight[i] >= 0){
              dp[i+1][j] = max(dp[i+1][j] ,dp[i][j-weight[i]] + value[i]);
          }
          chmax(dp[i+1][j], dp[i][j]);
      }
  }  
  cout << dp[n][w] << endl;
}

Measured memory_bytes: 80256
n,k,q = map(int, input().split())
a = []
for _ in range(q):
    a.append(int(input()))

suc = [0]*n
for aa in a:
    suc[aa-1]+=1

for i in range(n):
    if k - (q - suc[i]) > 0:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 8592
#include <cmath>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <queue>
#include <map>
#include <bitset>
#include <set>
const int maxlongint=2147483647;
const int mo=1e9+7;	
const int N=100005;
using namespace std;
int n,a[N];
int main()
{
	//freopen("agc002e.in","r",stdin);
	//freopen("agc002e.out","w",stdout);
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	for(int i=n,x=0;i>=1;i--)
	{
		x++;
		if(x>=a[i-1])
		{
			if((a[i]-x)&1)
				printf("First\n");
			else
				for(int j=i;j>=0;j--)
					if(x>=a[j-1]+1)
					{
						if((j-i)&1)
							printf("First\n");
						else
							printf("Second\n");
						break;
					}
			return 0;
		}
	}
}

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

namespace ABC064
{
    class ProblemA
    {
        static void Main(string[] args)
        {
            string[] inputs = Console.ReadLine().Split();
            int number = int.Parse(String.Join("", inputs));

            if(number % 4 == 0)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
            
        }
    }
}


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

public class Main {
    public static void main(String[] args) {
        try {
            // 標準入力
            InputStreamReader isr = new InputStreamReader(System.in);
            BufferedReader br = new BufferedReader(isr);
            String str = br.readLine();
            int count = 0;
            for (int i = 0; i < str.length(); i++) {
                char ch = str.charAt(i);
                if (ch == '1') {
                    count++;
                }
            }
            System.out.println(count);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}


Measured memory_bytes: 21204
import sys
from bisect import bisect_left
from collections import deque


def main():
    input = sys.stdin.buffer.readline
    n = int(input())
    a = [int(input()) for _ in range(n)]
    pile = deque()
    for i in range(n):
        index = bisect_left(pile, a[i])
        if index == 0:
            pile.appendleft(a[i])
        else:
            pile[index - 1] = a[i]
    print(len(pile))


if __name__ == "__main__":
    main()


Measured memory_bytes: 13776
#include <bits/stdc++.h>
#define itn int
#define gI gi

using namespace std;

typedef long long ll;

inline int gi()
{
	int f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

inline ll gl()
{
	ll f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

int n, m, f[5];

int main()
{
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	n = gi(), m = gi();
	f[n] = 1, f[m] = 1;
	for (int i = 1; i <= 3; i+=1) if (f[i] == 0) {cout << i << endl; return 0;}
	return 0;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;
#define N 1024
#define MOD 1000000007LL

long long d[N][N];
int a[N][N],i,j,n,m;
char c;
int main()
{
    cin >> n >> m;
    for (i = 0; i < n; ++i)
    for (j = 0; j < m; ++j){
        cin >> c;
        if (c == '#')
            a[i][j] = 1;
        if (c == '.')
            a[i][j] = 0;
    }
    for (i = 0; i < m && !a[0][i]; ++i)
        d[0][i] = 1;
    for (i = 0; i < n && !a[i][0]; ++i)
        d[i][0] = 1;
    ++n;
    ++m;
    for (i = 1; i < n; ++i)
    for (j = 1; j < m; ++j){
        if (!a[i][j])
            d[i][j] = (d[i - 1][j] + d[i][j - 1]) % MOD;
    }
    cout << d[n - 2][m - 2];
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> h(n + 1);
  for (int i = 0; i < n; i++) {
    cin >> h[i + 1];
  }
  int r = 0;
  for (int i = 0; i < n; i++) {
    r += max(0, h[i + 1] - h[i]);
  }
  cout << r << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll MOD=1000000007;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
long long gcd(long long a,long long b){
    ll gcdmax=max(a,b);
    ll gcdmin=min(a,b);
    while(true){
        if(gcdmax%gcdmin==0)break;
        else gcdmax%=gcdmin;
        swap(gcdmin,gcdmax);
    }
    return gcdmin;
}
ll powerup(ll N,ll P,ll M){
    if(P==0)return 1;
    else if(P%2==0){
        ll t=powerup(N,P/2,M);
        return t*t%M;
    }
    else return N*powerup(N,P-1,M)%M;
}
int main()
{
  ll N;
  cin>>N;
  vector<ll> D(N-1);
  vector<ll> OP(N-1);
  vector<ll> C(N-1);
  vector<ll> T(N);
  rep(i,N-1)cin>>D.at(i)>>OP.at(i)>>C.at(i);
  rep(i,N-1){
    T.at(i)=OP.at(i);
    for(ll j=i;j<N-1;j++){
      if(j==i)T.at(i)+=D.at(i);
      else T.at(i)=D.at(j)+max((T.at(i)+C.at(j)-1)/C.at(j)*C.at(j),OP.at(j));
    }
  }
  rep(i,N)cout<<T.at(i)<<endl;
}

Measured memory_bytes: 256
import sys
import math
def get_array(): return list(map(int, sys.stdin.readline().strip().split()))
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def input(): return sys.stdin.readline().strip()
n=int(input())
l=get_array()
ans=0
for x in range(n):
    for y in range(x+1,n):
        for z in range(y+1,n):
            if l[x]!=l[y] and l[y]!=l[z] and l[x]!=l[z]:
                if l[y]+l[z]>l[x] and l[x]+l[y]>l[z] and l[x]+l[z]>l[y]:
                    ans+=1
print(ans)





Measured memory_bytes: 68256
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        int n, a, b, ai = 0, bi = 0, aj, bj, ansi = 0, ansj = 0;
        int[] label;
        Scanner sc = new Scanner(System.in);
        label = new int[6];
        for (int i = 0; i < 6; i++)
            label[i] = sc.nextInt();
        n = sc.nextInt();

        for (int i = 0; i < n; i++) {
            a = sc.nextInt();
            b = sc.nextInt();
            for (int j = 0; j < 6; j++) {
                if (a == label[j]) {
                    ai = j;
                    break;
                }
            }
            for (int j = 0; j < 6; j++) {
                if (b == label[j]) {
                    bi = j;
                    break;
                }
            }

            if (ai > 2) {
                aj = 5 - ai;
            } else {
                aj = ai;
            }
            if (bi > 2) {
                bj = 5 - bi;
            } else {
                bj = bi;
            }
            ansj = 3 - aj - bj;
            switch (ansj) {
            case 0:
                if (aj == 1 && bj == 2) {
                    ansi = ansj;
                } else {
                    ansi = 5 - ansj;
                }
                break;
            case 1:
                if (aj == 2 && bj == 0) {
                    ansi = ansj;
                } else {
                    ansi = 5 - ansj;
                }
                break;
            case 2:
                if (aj == 0 && bj == 1) {
                    ansi = ansj;
                } else {
                    ansi = 5 - ansj;
                }
                break;
            }
            if ((ai > 2 && bi <= 2) || (ai <= 2 && bi > 2)) 
                    ansi = 5 - ansi;
            System.out.println(label[ansi]);
        }
    }
}


Measured memory_bytes: 26132
def ra(a): #圧縮された要素を非保持
    ll,l=[],1
    for i in range(len(a)-1):
        if a[i]==a[i+1]:
            l+=1
        else:
            ll.append(l)
            l=1
    ll.append(l)
    return ll

n=int(input())
print(sum([i*(i-1)//2 for i in ra(sorted([''.join(sorted(i)) for i in [input() for i in range(n)]]))]))

Measured memory_bytes: 23348
#include<bits/stdc++.h>
#include<vector>
#include<iostream>
#include<sstream>
#include<fstream>
#include<list>
#include<deque>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cctype>
#include<cmath>
#include<ctime>
#include<iomanip>
using namespace std;
/*freopen{"input.txt","r",stdin};
freopen{"output.txt","w",stdout};*/
#define mp make_pair
#define pb push_back
const int INF=1000*1000*1000;
const int maxn=2e5; 
typedef long long ll;
typedef long double ld;
typedef pair<int,int>PII;
//priority_queue <int,vector<int>,greater<int> > q1;  //从小到大 
//priority_queue <int,vector<int>,less<int> >q2;  //从大到小 

//set multiset vector queue priority_queue map multimap pair string structure 

//枚举 思维 贪心 搜索 模拟 预处理 二分 排序 
double a[maxn];
priority_queue <double,vector<double>,greater<double> > q;
int main(){
	//ios_base::sync_with_stdio(0);
    //cin.tie(0);
    //cout.tie(0);
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		q.push(a[i]);
	}
	for(int i=0;i<n-1;i++){
		double t=q.top();
		q.pop();
		double s=q.top();
		q.pop();
		q.push((s+t)/2);
	}
	cout<<q.top();
	
	
	
	
	
	
	return 0;
}



Measured memory_bytes: 256
fun main(args: Array<String>) {
    val l = arrayOf<Long>(3, 5, 7).toMutableSet()
    var new_l = arrayOf<Long>().toMutableSet()
    var n = readLine()!!.toLong()
    var left = 1
    while (left < n){
        new_l = arrayOf<Long>().toMutableSet()
        left *= 10
        l.map{ it -> new_l.add(it * 10 + 3)}
        l.map{ it -> new_l.add(it * 10 + 5)}
        l.map{ it -> new_l.add(it * 10 + 7)}
        l += new_l.sorted()
    }
    println(l.filter{it -> it.toString().contains("3") && it.toString().contains("5") && it.toString().contains("7") }.filter{ it -> it <= n}.count())
}

Measured memory_bytes: 64820
// ProblemURL : https://atcoder.jp/contests/abc064/tasks/abc064_d
// ---------------------------------------------
package main

import (
	"fmt"
	"strings"
)

func main() {
	var n int
	var s string
	fmt.Scan(&n, &s)

	sta := 0
	ct := 0
	for i := range s {
		if s[i] == '(' {
			sta++
		} else {
			if sta == 0 {
				ct++
			} else {
				sta--
			}
		}
	}

	addLeft := strings.Repeat("(", ct)
	addRight := strings.Repeat(")", sta)
	fmt.Println(addLeft + s + addRight)
}


Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main(){
int N,t,ans,time,i;
int C[1001];
int T[1001];
	cin >> N >> t;
for (i = 0; i < N; i++)cin >> C[i] >> T[i];
ans = C[0];
time = T[0];
for (i = 0; i < N; i++) {
	if (C[i] < ans && T[i] <= t)ans = C[i];
		; if (T[i] <= time)time = T[i];
}
if (time <= t)cout << ans;
else cout << "TLE";
return 0;
}

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

int main() {
	int A, B;
	cin >> A >> B;

	if (A == B) {
		cout << A + B << endl;
		return 0;
	}

	int tmp;
	tmp = max(A, B);
	cout << tmp * 2 - 1 << endl;


	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define int long long
//#define PI 3.14159265358979

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(11);
	}
};
initializer _____;

int dfs(vector< vector< int > > &G, vector< int > &level, int x) {
	if (level[x] != -1)
		return level[x];
	int ret = -1;
	rep(i, G[x].size()) {
		int j = G[x][i];
		chmax(ret, dfs(G, level, j));
	}
	return level[x] = ret + 1;
}

int N, M, K, T, Q;
signed main() {
	cin >> N >> M;
	vector< vector< int > > G1(N), G2(N);
	rep(i, N - 1 + M) {
		int a, b;
		cin >> a >> b;
		--a;
		--b;
		G1[a].push_back(b);
		G2[b].push_back(a);
	}
	vector< int > level(N, -1);
	rep(i, N) dfs(G2, level, i);
	vector< int > ans(N);
	rep(i, N) {
		if (G2[i].size() == 0)
			ans[i] = 0;
		else if (G2[i].size() == 1)
			ans[i] = 1 + G2[i][0];
		else {
			int maxl = 0, maxli = -1;
			rep(j, G2[i].size()) {
				int k = G2[i][j];
				if (level[k] > maxl) {
					maxl = level[k];
					maxli = k;
				}
			}
			ans[i] = maxli + 1;
		}
	}
	rep(i, N) cout << ans[i] << endl;
	return 0;
}

Measured memory_bytes: 17280
#include <bits/stdc++.h>
#define ll long long int
#define ulli unsigned long long int 
#define pb push_back
using namespace std;
ll BS(ll s[],ll q,ll n)
{
    ll beg = 0,last = n;
    while(beg<=last)
    {
        ll mid = (beg+last)/2;
        if (s[mid+1]>=q && s[mid]<q)
            return mid+1;
        else if (s[mid]<q)
            beg = mid+1;
        else 
            last = mid-1;
    }
    return 0;
}
bool isprime(ll n) 
{
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
    for (ll i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
    return true; 
} 
int main()
{  
   ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
   //while(!cin.eof())
   int t; t=1;
   while(t--)
   {
       string t,s;
       cin>>s>>t;
       int l1=s.length(),l2=t.length(),cnt,mini=1000;
       for(int i=0;i<=l1-l2;i++)
       {
           cnt=0;
           for(int j=i;j<i+l2;j++)
           {
               if(s[j]!=t[j-i]) cnt++;
               
           }
           mini=min(cnt,mini);
       }
       cout<<mini;
   }
   return 0;
}

Measured memory_bytes: 3660
#!/usr/bin/env pypy
from __future__ import division, print_function

import os
import sys
from __builtin__ import xrange as range
from cStringIO import StringIO
from future_builtins import ascii, filter, hex, map, oct, zip
from io import IOBase
from collections import defaultdict

import __pypy__


def main():
    n = int(input())
    a = [int(i) for i in input().split(" ")]
    s = defaultdict(int)
    ans = 0
    for i in xrange(n):
        ans += s[a[i]-i]
        s[-i-a[i]] += 1
    print(ans)


# region fastio

BUFSIZE = 8192


class FastI(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = StringIO()
        self.newlines = 0

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count("\n") + (not b)
            ptr = self._buffer.tell()
            self._buffer.seek(0, 2), self._buffer.write(b), self._buffer.seek(ptr)
        self.newlines -= 1
        return self._buffer.readline()


class FastO(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = __pypy__.builders.StringBuilder()
        self.write = lambda s: self._buffer.append(s)

    def flush(self):
        os.write(self._fd, self._buffer.build())
        self._buffer = __pypy__.builders.StringBuilder()


def print(*args, **kwargs):
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


sys.stdin, sys.stdout = FastI(sys.stdin), FastO(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


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

using namespace std;

int main(){
    long N;
    cin>>N;
    vector<long> A(N);
    long sum = 0;
    for(int i=0; i<N; ++i){
        cin>>A[i];
        sum += A[i];
    }

    long ans = 0;
    long x = 0;
    for(int i=0; i<N; ++i){
        x += A[i];
        if (x > sum / 2.0){
            // cout<<x - sum/2.0<<" "<<sum/2.0 - (x-A[i-1])<<endl;
            ans = 2*(min(x - sum/2.0, sum/2.0 - (x-A[i])));
            break;
        }
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 1792
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;
#include <vector>
#define rep(i,n) for (ll i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

// #include <iomanip>
//  cout << fixed << setprecision(15) << y << endl;

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll A;
ll B;
ll C;
ll N;
ll M;
ll K;

ll ltmp;
string stmp;
double dtmp;

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> A;
    cin >> B;

    if(A<=5) cout << 0 << endl;
    else if(A<=12) cout << B/2 << endl;
    else cout << B << endl;
}

Measured memory_bytes: 3596
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
using ll = long long;
const ll mod = 1e09+7;
class mint {
    long long x;
public:
    mint(long long x=0) : x((x%mod+mod)%mod) {}
    mint operator-() const { 
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }
 
    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};
 
int main(){
  int n, k; cin >> n >> k;
  
  vector<mint> cnt(100005);
  mint ans = 0;
  for(int i=k; i>0; i--){
    cnt[i] =  mint(k/i).pow(n);
    for(int j=i; j<=k; j += i){
      if(j==i) continue;
      cnt[i] -= cnt[j];
    }
    ans += cnt[i]*i;
  }
  
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4028
def f(n):
  if n % 2 == 0:
    return n // 2
  else:
    return 3 * n + 1

a = int(input())
A = [a]
m = 1
while True:
  m += 1
  a = f(a)
  A.append(a)
  if len(A) > len(set(A)):
    break
print(m)

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

const int NIL = -1;
const int MAX = 100005;
int cnt;

typedef struct{ int parent, left, right;}Node;
Node T[MAX];

void preParse(int u){
    if (u == NIL) return;
    cnt--;
    if (cnt != 0) cout << " " << u;
    else cout << " " << u << endl;
    preParse(T[u].left);
    preParse(T[u].right);
}
void inParse(int u){
    if (u == NIL) return;
    inParse(T[u].left);
    cnt--;
    if (cnt != 0) cout << " " << u;
    else cout << " " << u << endl;
    inParse(T[u].right);
}
void postParse(int u){
    if (u == NIL) return;
    postParse(T[u].left);
    postParse(T[u].right);
    cnt--;
    if (cnt != 0) cout << " " << u;
    else cout << " " << u << endl;
}

int main(void)
{
    int n;
    cin >> n;
    rep(i,n) {T[i].parent = T[i].left = T[i].right = NIL;}
    rep(i,n){
        int id, r, l;
        cin >> id >> l >> r;
        T[id].left = l;
        T[id].right = r;

        if (l != NIL) T[l].parent = id;
        if (r != NIL) T[r].parent = id;
    }

    int root_id;
    rep(i,n){
        if (T[i].parent == NIL) root_id = i;
    }

    /* 表示 */
    cout << "Preorder" << endl; cnt = n;
    preParse(root_id);
    cout << "Inorder" << endl; cnt = n;
    inParse(root_id); 
    cout << "Postorder" << endl; cnt = n;
    postParse(root_id); 

    return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < int , int >
#define F first
#define S second
#define endl '\n'
#define int long long
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#define kill(x) return cout<<x<<'\n', 0;
using namespace std;
const int N=2e5+100;
ll mod=998244353;
ll lazy[N*4],seg[N*4];
ll power(ll n,ll k){
    if (k==0) return 1;
    if (k%2==1){
        ll x=power(n,k/2);
        return x*x%mod*n%mod;
    }
    ll x=power(n,k/2);
    return x*x%mod;
}
void shift(ll nod){
    seg[nod*2]*=lazy[nod];
    seg[nod*2]%=mod;
    lazy[nod*2]*=lazy[nod];
    lazy[nod*2]%=mod;
    seg[nod*2+1]*=lazy[nod];
    seg[nod*2+1]%=mod;
    lazy[nod*2+1]*=lazy[nod];
    lazy[nod*2+1]%=mod;
    lazy[nod]=1;
}
void upd(ll nod,ll l,ll r,ll L,ll R,ll val){
    if (l>=R || L>=r) return ;
    if (l>=L && r<=R){
        lazy[nod]*=val;
        seg[nod]*=val;
        lazy[nod]%=mod;
        seg[nod]%=mod;
        return ;
    }
    ll mid=(r+l)/2;
    shift(nod);
    upd(nod*2,l,mid,L,R,val);
    upd(nod*2+1,mid,r,L,R,val);
    seg[nod]=seg[nod*2]+seg[nod*2+1];
    seg[nod]%=mod;
}
void add(ll nod,ll l,ll r,ll id){
    if (r-l==1){
        seg[nod]=1;
        return ;
    }
    ll mid=(r+l)/2;
    shift(nod);
    if (mid>id) add(nod*2,l,mid,id);
    else add(nod*2+1,mid,r,id);
    seg[nod]=seg[nod*2]+seg[nod*2+1];
    seg[nod]%=mod;
}
ll get(ll nod,ll l,ll r,ll L,ll R){
    if (l>=R || L>=r) return 0;
    if (l>=L && r<=R) return seg[nod];
    shift(nod);
    ll mid=(r+l)/2;
    return get(nod*2,l,mid,L,R)+get(nod*2+1,mid,r,L,R);
}
ll fen[N];
void ad(ll idx,ll val){
    for (;idx<N;idx+= idx & (-idx)) fen[idx]+=val;
}
ll ge(ll idx){
    ll s=0;
    for (;idx;idx-= idx & (-idx)) s+=fen[idx];
    return s;
}
ll a[N];
int32_t main(){
    sync;
    for (int i=0;i<N*4;i++){
        lazy[i]=1;
    }
    ll n,k;
    cin >> n >> k;
    for (int i=1;i<=n;i++){
        cin >> a[i];
    }
    ll ans=(k-1)*k/2;
    ans%=mod;
    ans*=power(2,mod-2);
    ans%=mod;
    ll z=(k-1)*power(k,mod-2)%mod;
    for (int i=1;i<=n-k;i++){
        ll cnt=n-i;
        ll zz=power(z,i);
        ans+=cnt*zz%mod*power(2,mod-2)%mod;
        ans%=mod;
    }
    for (int i=1;i<=k;i++){
        add(1,1,n+1,a[i]);
        ad(a[i],1);
    }
    for (int i=k+1;i<=n;i++){
        upd(1,1,n+1,1,n+1,z);
        ll y=get(1,1,n+1,a[i],n+1);
        y%=mod;
        ll e=ge(N-1)-ge(a[i])+mod;
        e%=mod;
        //cout << e << endl;
        ans+=e-y;
        ans+=mod;
        ans%=mod;
        add(1,1,n+1,a[i]);
        ad(a[i],1);
    }
    cout << ans%mod << endl;
}


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

int main()
{
    int n;scanf("%d",&n);
    ll tmp;
    scanf("%llu",&tmp);
    for(int i=1;i<n;i++)
    {
        ll a;scanf("%lld",&a);
        tmp = a/__gcd(tmp,a)*tmp;
    }
    printf("%llu\n",tmp);
    return 0;
}

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

int main(){
	int N;
	cin >> N;
	vector<int> botton(N);
  
  	for(int i=0;i<N;i++){
     cin >> botton.at(i);    
    }
  
  	int light = 1, cnt;
  	for(int i=0;i<N;i++){
      light = botton.at(light - 1);
      cnt++;
      if(light == 2)
        break; 
    }
  
  	if(light == 2){
      cout << cnt << endl;
    }else {
      cout << -1 << endl;
    }
}

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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    vector<int> w(n), sum(n);
    for (int i = 0; i < n; i++)
        cin >> w[i];
    for (int i = 0; i < n; i++)
    {
        if (i == 0)
            sum[i] = w[i];
        else
            sum[i] = sum[i - 1] + w[i];
    }
    int ret = INF;
    for (int i = 0; i < n - 1; i++)
    {
        int dif = abs(sum[i] - (sum[n - 1] - sum[i]));
        ret = min(ret, dif);
    }
    cout << ret << endl;
}


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

#define IN(i,l,r) (l<i&&i<r)
#define LINR(i,l,r) (l<=i&&i<=r)
#define LIN(i,l,r) (l<=i&&i<r)
#define INR(i,l,r) (l<i&&i<=r)

#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define FFE(i,L,R) for (int i = L; i >= R; i--)

#define wez(n) int (n); cin >> n
#define wez2(n,m) int (n),(m); cin >> n >> m
#define wez3(n,m,k) int (n),(m),(k); cin >> n >> m >> k

#define whileZ int T; cin >> T; while(T--)

#define ALL(c) (c).begin(),(c).end()
#define ll long long 
#define ull unsigned long long
#define ld long double

#define fi first
#define se second

// for debug
#define printA(a,L,R) FE(i,L,R) cout << a[i] << (i==R?'\n':' ')
#define printV(a) if(a.size()) printA(a,0,a.size()-1)

#define pb push_back
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int,int> ii;
//  priority_queue <int, vector<int>, greater<int> > pq; // min heap


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    wez3(d,t,s);

    cout << ( s*t >= d  ? "Yes\n" : "No\n" );
    
    return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <queue>
#include <functional>
#include <algorithm>
#include <cmath>
using namespace std;

long long n, q, p1, p2, p3, a[200009], b[200009], sum, cnt;
priority_queue<pair<long long, int>, vector<pair<long long, int>>, greater<pair<long long, int>>>Q;

int main() {
	cin >> n >> q;
	for (int i = 1; i <= 2 * n; i++) cin >> a[i];
	for (int i = 1; i <= 2 * n; i++) cin >> b[i];
	for (int i = 1; i <= 2 * n; i++) {
		if (i == 1)b[i] = -(1LL << 60); if (i == 2 * n) b[i] = -(1LL << 60);
		sum += max(a[i], b[i]);
		if (a[i] < b[i]) cnt++;
		Q.push(make_pair(max(a[i], b[i]) - min(a[i], b[i]), i));
	}
	for (int i = 1; i <= q; i++) {
		cin >> p1 >> p2 >> p3; if (p1 == 1) p3 = -(1LL << 60); if (p1 == 2 * n) p3 = -(1LL << 60);
		if (a[p1] < b[p1]) cnt--;
		sum -= max(a[p1], b[p1]);
		a[p1] = p2; b[p1] = p3;
		if (a[p1] < b[p1]) cnt++;
		sum += max(a[p1], b[p1]);
		Q.push(make_pair(abs(a[p1] - b[p1]), p1));
		while (!Q.empty()) {
			long long cost = Q.top().first, to = Q.top().second;
			long long V = abs(a[to] - b[to]);
			if (V != cost) Q.pop();
			else break;
		}
		if (cnt % 2 == 0) cout << sum << endl;
		else cout << sum - Q.top().first << endl;
	}
	return 0;
}

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

int main(void){
    vector<int> nums(3);
    int k;
    for (int i=0; i<3; i++) cin >> nums[i];
    sort(nums.begin(), nums.end());
    cin >> k;
    for (int i=0; i<k; i++) nums[2] *= 2;
    cout << accumulate(nums.begin(), nums.end(), 0) << endl;
    return 0;
}

Measured memory_bytes: 3624
#include<stdio.h>
int main(void)
{
    int a[13],b[12];
    int i,n;
    int sa=0;
    int count=1;
for(;;){
    scanf("%d",&n);
    if(n == 0)break;
    for(i = 0;i < 12; i++){
        scanf("%d",&a[i]);
        scanf("%d",&b[i]);
    }
    for(i = 0;; i++){

        sa = a[i]-b[i];
        n-=sa;
        if(count > 12){
            printf("NA\n");
            break;
        }
        else if(n <= 0){
            printf("%d\n",count);
            break;
        }
        else count++;
    }
    count = 1;
}
return 0;
}

Measured memory_bytes: 612
import sys


def main():
    N = int(sys.stdin.readline().rstrip())
    S = sys.stdin.readline().rstrip()

    cnt = 0
    for i in range(10):
        pos_1 = S.find(str(i))
        if pos_1 == -1 or pos_1 > N - 3:
            continue

        for j in range(10):
            pos_2 = S[pos_1 + 1:].find(str(j))
            if pos_2 == -1 or pos_2 > N - 2:
                continue

            for k in range(10):
                pos_3 = S[pos_1 + 1 + pos_2 + 1:].find(str(k))
                if pos_3 != -1:
                    cnt += 1

    print(cnt)


main()


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

#undef int
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
#define int long long int
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int t = 1;
	//cin >> t;
	while (t--) {
		string s, p;
		cin >> s >> p;
		int flag = 0, i;
		for (i = 0; i < s.length(); i++) {
			if (s[i] == p[i])
				continue;
			else flag = 1;
		}
		if (flag == 0) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	return 0;
}

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


#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

using namespace std;

inline bool isvowel (char c) {
	c = tolower(c);
    if (c == 'a' || c == 'e' || c == 'i' || c == 'y' || c == 'o' || c == 'u') return 1;
    return 0;
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n, m, k;
int cnt[N];
string s;
int a[N];
vector < int > g[N];
int u[N];
int ans, res;
int cur;

int main () {
	cin >> n >> m;
	int h, w;
	cin >> h >> w;
	cout << (n - h) * (m - w);
	return Accepted;
}

// B...a

Measured memory_bytes: 18688
using System;
using System.Collections.Generic;
using System.Globalization;

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

			Dictionary<string, int> dic = new Dictionary<string, int>();

			long cnt = 0L;

			for (int i = 0; i < n; i++)
			{
				char[] arr = Console.ReadLine().ToCharArray();
				Array.Sort(arr);
				string str = new string(arr);
				if (dic.ContainsKey(str))
				{
					dic[str]++;
				}
				else
				{
					dic.Add(str, 0);
				}
			}

			foreach (string s in dic.Keys)
			{
				long num = dic[s];
				cnt += num * (num + 1) / 2;
			}
			Console.WriteLine(cnt);
		}
	}

}

Measured memory_bytes: 31192
#include<stdio.h>
#include<string.h>
int main(void)
{
  int n;
  int len,flg=0;
  char s[100000];
  
  scanf("%d %s",&n,s);
  if(n%2==1){
    printf("No\n");
    return 0;
  }
  for(int i=0;i<n/2;i++){
    if(s[i]!=s[n/2+i]){
      flg=1;
      break;
    }
  }
  if(flg==1){
    printf("No\n");
  }
  else{
    printf("Yes\n");
  }
  return 0;
}

Measured memory_bytes: 128
//vecを広義単調減少に並び替える
#include<bits/stdc++.h>
using namespace std;

int main(){
  int N,n;
  cin >> N;
  vector<int>vec(N);
  vector<int>vec_2(0);
  vector<int>vec_count(0);
  int count,count_2,c;

  for (int i_1 = 0; i_1 < N; i_1 ++) cin >> vec.at(i_1);

  for (int i_2 = 0; i_2 < N; i_2 ++){
    n = vec.at(0);
    count_2 = 0;
    for (int j_2_1 = 0; j_2_1 < N; j_2_1 ++){
      if (n < vec.at(j_2_1)) {
        n = vec.at(j_2_1);
        vec_count.push_back(j_2_1);//見つけた時の添字の値をログ
        count ++;
        count_2 ++;
      }
    }

    vec_2.push_back(n);//広義単調減少の順に並び替えたvec
    if(count_2 != 0){
      c = vec_count.at(count-1);//ログの最後の値を知りたい
      vec.at(c) = 0;
    }
    else vec.at(0) = 0;
  }

  //for (int i_3 = 0; i_3 < N; i_3 ++) cout << vec_2.at(i_3)<<" ";
  //cout << endl;

  int a,b;
  if (N % 2 == 0) a = N / 2;
  else a = N / 2 + 1;
  b = N - a;
  int A=0,B=0;

  for (int i_4 = 0; i_4 < a; i_4 ++) A += vec_2.at(i_4*2);
  for (int i_5 = 0; i_5 < b; i_5 ++) B += vec_2.at(i_5*2+1);

  cout <<A-B<<endl;

}



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

#define SQ(a) (a)*(a)

#define F0R(i, a) for(int i = 0; i < (a); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define R0F(i, a) for(int i = (a) - 1; i >= 0; i--)
#define ROF(i, a, b) for(int i = (b) - 1; i >= (a); i--)

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define UB upper_bound
#define LB lower_bound
#define X real()
#define Y imag()
#define MAXN 100000

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<ld> point;

int n, a[MAXN];
int numReach[100000];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    F0R(i, n) {
        cin >> a[i];
        numReach[a[i]]++;
        if(a[i] + 1 < 100000) numReach[a[i] + 1]++;
        if(a[i] - 1 >= 0) numReach[a[i] - 1]++;
    }
    int best = 0;
    F0R(i, 100000) {
        best = max(best, numReach[i]);
    }
    cout << best << "\n";
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main() {
    int N, A, B;
    cin >> N >> A >> B;

    int ans = 0;
    for (int i = 1; i <= N; ++i) {
        string s = to_string(i);
        int digit = 0;
        for (int j = 0; j < s.size(); ++j) {
            digit += s[j] - '0';
        }

        if (A <= digit && digit <= B) {
            ans += i;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String blank = sc.nextLine();
    String s = sc.nextLine();
    Set<String> front_set = new HashSet<>();
    Set<String> back_set = new HashSet<>();
    int max = 0;


    for(int i = 0; i < s.length()-1; i++){
      front_set.clear();
      back_set.clear();
      int cnt = 0;

      String front_str = s.substring(0, i+1);
      char[] front_ary = front_str.toCharArray();
      for(char c1 : front_ary){front_set.add(String.valueOf(c1));}
      /*//デバッグ
      System.out.println("front_ary:" + front_ary);
      for(String db1 : front_set){
        System.out.print(db1);
      }
      System.out.println("");*/


      String back_str = s.substring(i+1, s.length());
      char[] back_ary = back_str.toCharArray();
      for(char c2 : back_ary){back_set.add(String.valueOf(c2));}
      //デバッグ
      /*System.out.println("back_ary:" + back_ary);
      for(String db2 : back_set){
        System.out.print(db2);
      }
      System.out.println("");*/


      if(front_set.size() < back_set.size()){
        for(String ss : front_set){
          if(back_set.contains(ss)){cnt++;}
        }
      }else{
        for(String ss : back_set){
          if(front_set.contains(ss)){cnt++;}
        }
      }


      max = Math.max(max, cnt);
      /*System.out.println(max);
      System.out.println("-------------------------");*/
    }

    System.out.println(max);
  }
}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ll mod2 = 998244353;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

using mint = modint998244353;
mint pw[200050];
mint pwsum[200050];
struct S {
  mint val;
  int size;
};
struct F {
  mint n;
};
S op(S a, S b) {
  return S{a.val*pw[b.size]+b.val, a.size+b.size};
}
S e() {
  return S{0, 0};
}
S mapping(F f, S x) {
  if(f.n == 0) return x;
  else return S{pwsum[x.size]*f.n, x.size};
}
F composition(F f, F g) {
  return (f.n == 0 ? g : f);
}
F id() {
  return F{0};
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  rep(i, 200050) {
    if(i == 0) pw[i] = 1;
    else pw[i] = pw[i-1] * 10;
  }
  rep(i, 200050) {
    if(i!=200049) pwsum[i+1] = pwsum[i] + pw[i];
  }
  int n, q; cin >> n >> q;
  vector<S> init(n, S{1, 1});
  lazy_segtree<S, op, e, F, mapping, composition, id> seg(init);
  rep(_, q) {
    int l, r, d; cin >> l >> r >> d;
    l--;
    seg.apply(l, r, F{d});
    cout << seg.prod(0, n).val.val() << endk;
  }
  return 0;
}


Measured memory_bytes: 11384
#pragma GCC optimize "-O3"
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pip pair<int, pii >
#define F first
#define S second
#define pb push_back
#define pp pop_back

const int P = 1000000007;

using namespace std;

int main(){

	int x, y;
	cin >> x >> y;
	int mi = x*2, ma = x*4;
	bool ans = 1;
	if(y<mi) ans = 0;
	if(y>ma) ans = 0;
	if(y&1) ans = 0;

	if(ans) cout << "Yes\n";
	else cout << "No\n";

	return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int N, arr[100005], sum, answer;
int main(){
 cin >> N;
 for(int i = 1; i <= N + 1; i++){
  if(i != N + 1) cin >> arr[i];/*i==nの時は入力はない*/
	sum += abs(arr[i] - arr[i-1]);
 }

 for(int i = 1; i <= N; i++){
  answer = sum;
  answer -= abs(arr[i-1] - arr[i]) + abs(arr[i] - arr[i+1]); 
	answer += abs(arr[i-1] - arr[i+1]);
  cout << answer << endl;
 }

 return 0; 

};




Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef string str;
const long long INF = INT64_MAX / 2;

#define REP(i, n) for(ll i=0;i<n;i++)
#define ASC(v) sort((v).begin(), (v).end())
#define DESC(v) sort((v).rbegin(), (v).rend())
#define UNIQ(v) ASC(v);v.erase(unique(v.begin(), v.end()), v.end())
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);

void solve() {
    ll N, T;
    cin >> N >> T;
    ll t0;
    cin >> t0;
    ll ans = 0;
    for(int i = 0; i < N - 1; i++) {
        ll t;
        cin >> t;
        ans += T - max(0LL, T - (t - t0));
        t0 = t;
    }
    cout << ans + T << endl;
}

int main() {
    FIO;
    solve();
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
int main() {
	int A, B;
	std::cin >> A >> B;
	if (A < B) {
		std::cout << "a < b" << std::endl;
	}
	if (A > B) {
		std::cout << "a > b" << std::endl;
	}
	if (A == B) {
		std::cout << "a == b" << std::endl;
	}
}


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

using namespace std;

int main(void) {
    int H, W, N;
    cin >> H >> W >> N;
    int a[N];
    for (int i = 0; i < N; ++i) {
        cin >> a[i];
    }

    vector<int> color;
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < a[i]; ++j) {
            color.push_back(i + 1);
        }
    }

    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            if (j != 0) cout << " ";
            if (i % 2 == 0) {
                cout << color[i * W + j];
            } else {
                cout << color[i * W + W - 1 - j];
            }
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
    int k;
    cin>>k;
    int even=0,odd=0;
    for(int i=1;i<=k;i++){
        if(i%2==0)even++;
        else odd++;
    }
    cout<<even*odd<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    int n, m;
    cin >> n;
    vector<int> arr(n, 0);
    for(int& val: arr) {
        cin >> val;
    }
    int acc = accumulate(arr.begin(), arr.end(), 0);
    int p, x;
    cin >> m;
    while(m--) {
        cin >> p >> x;
        cout << acc - arr[p-1] + x << endl;
    }

    return 0;
}



Measured memory_bytes: 256
/*
g++ -std=c++11 -Wall -O2 -o main.exe main.cpp
main.exe
*/

#include <cstdlib>
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <map>
#include <functional>
#include <algorithm>
#include <complex>
#include <numeric>
//最大公約数: gcd()
//最小公倍数: lcm()

#define ll long long int

using namespace std;

template <typename T>
string itos(T val){ //数値を文字列(string)に変換
	stringstream ss;

	ss << val;
	return ss.str();
}

int stoi(string s){ //文字列(string)を数値に変換
	stringstream ss;
	int val = 0;

	ss << s;
	ss >> val;
	return val;
}

template <typename T>
void sortasc(vector<T> &v){ //vectorを昇順にソート
    sort(v.begin(), v.end(), std::less<T>());
    return;
}

template <typename T>
void sortdesc(vector<T> &v){ //vectorを降順にソート
    sort(v.begin(), v.end(), std::greater<T>());
    return;
}

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

int main(){
	int n, sum = 0;
	cin >> n;

	vector<int> l(2 * n);
	for(int i = 0; i < l.size(); i++) cin >> l[i];

	sortasc(l);

	for(int i = 0; i < l.size(); i += 2){
		sum += l[i];
	}

	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>

using namespace std;

int N, K;
vector<int> x;
int ans = numeric_limits<int>::max();

//必要な最小距離を計算
int calc(int left, int right) {
	int length = 0;
	if (abs(x[left]) > abs(x[right])) length = abs(x[right]);
	else length = abs(x[left]);

	return length + x[right] - x[left];
}

int main() {

	cin >> N >> K;

	for (int i = 0; i < N; i++) {
		int tmp;
		cin >> tmp;
		x.push_back(tmp);
	}

	auto startP = lower_bound(x.begin(), x.end(), 0);

	int left;
	left = (startP - x.begin() - K > 0) ? startP - x.begin() - K : 0;
	for (; left + K <= N; left++) {
		if (ans > calc(left, left + K - 1))
			ans = calc(left, left + K - 1);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 892
n, a, b  = map(int, input().split())

M = 10**9+7

def ncr(n, r, mod=M):
    upp, low = 1, 1
    for i in range(r):
        upp = upp * (n-i) % mod
        low = low * (r-i) % mod
    return upp * pow(low, mod-2, mod) % mod

all_p = (pow(2, n, M) - 1) % M

print((all_p - ncr(n, a, M) - ncr(n, b, M)) % M)


Measured memory_bytes: 38640