akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main(){
    vector<int> A(5);
    for(int i=0;i<5;i++)cin>>A[i];
    sort(A.begin(),A.end());
    int ans=10000000000000;
    vector<int> num(5);
    num={0,1,2,3,4};
    do{
        int tmp=0;
        for(int i=0;i<4;i++)tmp+=((A[num[i]]+9)/10)*10;
        tmp+=A[num[4]];
        ans=min(ans,tmp);
    }while(next_permutation(num.begin(),num.end()));
    cout<<ans<<endl;
}

Measured memory_bytes: 256
using System;
using static System.Console;
using static System.Int32;
using static System.Math;
using System.Linq;
using System.Collections.Generic;

class Solution
{
    static void Main()
    {
    lb:
        var n = Parse(ReadLine());
        var s = ReadLine();
        var rr = new int[n];
        var rg = new int[n];
        var rb = new int[n];
        {
            int nr = 0, g = 0, b = 0;
            for(int i = n - 1; 0 <= i; --i)
            {
                rr[i] = nr;
                rg[i] = g;
                rb[i] = b;
                switch (s[i])
                {
                    case 'R': ++nr; break;
                    case 'G': ++g; break;
                    case 'B': ++b; break;
                }
            }
        }
        int[] ary;
        long r = 0;
        for(int i = 0; i < s.Length; ++i)
        {
            char c = s[i];
            for(int j = i + 1; j < s.Length; ++j)
            {
                char c2 = s[j];
                if (c == c2) continue;
                if (c == 'R')
                {
                    ary = c2 == 'G' ? rb : rg;
                }
                else if (c == 'G')
                {
                    ary = c2 == 'R' ? rb : rr;
                }
                else
                {
                    ary = c2 == 'R' ? rg : rr;
                }
                r += ary[j];
                int k = j + j - i;
                if (k < s.Length)
                {
                    switch (s[k])
                    {
                        case 'R':
                            if (ary == rr) --r;
                            break;
                        case 'G':
                            if (ary == rg) --r;
                            break;
                        case 'B':
                            if (ary == rb) --r;
                            break;
                    }
                }
            }
        }
        WriteLine(r);
        //goto lb;
    }
}


Measured memory_bytes: 27488
N, M = map(int, input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]

for i in range(N - M + 1):
    for j in range(N - M + 1):
        flg = True
        for k in range(M):
            if A[i + k][j:j+M] == B[k]:
                continue
            else:
                flg = False
                break
        if flg:
            print('Yes')
            exit()
print('No')


Measured memory_bytes: 62580
fun main(args: Array<String>) {
    val n = readInputLine().toInt()
    val aList = readInputLine().split(" ").map { it.toInt() }.toList()
    val aSet = aList.toSet()

    if (aSet.size > 3) {
        println("No")
        return
    }

    if (aSet.size != 1 && n % 3 != 0) {
        println("No")
        return
    }
    
    if (aSet.size == 1) {
        if (!aSet.contains(0)) {
            println("No")
            return
        }
    }
    
    if (aSet.size == 2) {
        if (!aSet.contains(0)) {
            println("No")
            return
        }
        
        for (i in aSet) {
            if (i == 0) {
                continue
            }
            if (aList.count {it == i} != n * 2 / 3) {
                println("No")
                return
            }
        }
    }

    if (aSet.size == 3) {
        var calcedXor = 0
        for (i in aSet) {
            if (aList.count {it == i} != n / 3) {
                println("No")
                return
            }
            calcedXor = calcedXor xor i 
        }
        if (calcedXor != 0) {
            println("No")
            return
        }
    }

    println("Yes")
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 51740
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace _20170409_AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            string p = Console.ReadLine();
            string s2 = s + s;

            string result = "No";
            if (s2.Contains(p))
            {
                result = "Yes";
            }

            Console.WriteLine(result);
            
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 9752
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
#include <cmath>
#include <complex>
#include <map>
using namespace std;
 
#define rep(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second
 
static const double PI=6*asin(0.5);
typedef pair<int,int> P;
typedef complex<double> CP;
typedef long long ll;

int year,month,day;
ll sum;
char s[6][100]={"pre-meiji","meiji","taisho","showa","heisei"};
/*
s[0]="pre-meiji";
s[1]="meiji";
s[2]="taisho";
s[3]="showa";
s[4]="heisei";
*/


int main(){
	while(cin>>year>>month>>day){
		int a;
		sum=year*10000+month*100+day;
		if(sum<18680908) a=0;
		else if(sum<=19120729){
			a=1;
			year-=1867;
		}
		else if(sum<=19261224){
			a=2;
			year-=1911;
		}
		else if(sum<=19890107){
			a=3;
			year-=1925;
		}
		else{
			a=4;
			year-=1988;
		}
		cout<<s[a];
		if(a!=0) cout<<" "<<year<<" "<<month<<" "<<day<<endl;
		else cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1168
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <random>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if(a < b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(a > b){ a = b; return 1; } return 0; }
typedef long long ll;
ll rand26() {
  random_device rnd;
  mt19937 mt(rnd());
  uniform_real_distribution<> rand(0, 25);
  return (ll)rand(mt);
}
int main()
{
  ll D; cin >> D;
  vector<ll> c(26);
  rep(i,26) cin >> c[i];
  vector<vector<ll>> s(D, vector<ll>(26));
  vector<ll> t(D);  
  rep(i,D) {
    ll smax = -1;
    rep(j,26) {
      cin >> s[i][j];
      if(smax <= s[i][j]) {
	smax = s[i][j];
	t[i] = j;
      }
    }
  }

  
  ll m = 26*365*60;
  vector<ll> d(m), q(m);
  rep(k,60) {
    rep(i,26) {
      rep(j,365) {
	d[k*26*365 + i*365 + j] = j;
	q[k*26*365 + i*365 + j] = i;
      }
    }
  }
  
  vector<set<ll>> st(26);
  rep(i,26) {
    st[i].insert(-1);
    st[i].insert(D);    
  }
  rep(i,D) {
    st[t[i]].insert(i);
  }

  ll res = 0;
  // ペナルティ
  vector<ll> pen(26, 0);
  rep(i,26) {
    auto it = st[i].begin();
    it++;
    while(it != st[i].end()) {
      auto it2 = it;
      it2--;
      ll x = *it - *it2 - 1;
      res -= x * (x + 1) / 2 * c[i];
      pen[i] += x * (x + 1) / 2 * c[i];
      it++;
    }
  }
  rep(i,D) {
    res += s[i][t[i]];
  }

  rep(i,m) {
    ll oldres = res;
    ll old = t[d[i]];
    ll neww = q[i];
    set<ll> oldst1 = st[old];
    set<ll> oldst2 = st[neww];    
    ll oldpen1 = pen[old];
    ll oldpen2 = pen[neww];
    
    res += s[d[i]][neww] - s[d[i]][old];
    st[old].erase(d[i]);
    st[neww].insert(d[i]);    
    // old
    res += pen[old];
    pen[old] = 0;
    auto it = st[old].begin();
    it++;
    while(it != st[old].end()) {
      auto it2 = it;
      it2--;
      ll x = *it - *it2 - 1;
      res -= x * (x + 1) / 2 * c[old];
      pen[old] += x * (x + 1) / 2 * c[old];
      it++;
    }
    // new
    res += pen[neww];
    pen[neww] = 0;
    it = st[neww].begin();
    it++;
    while(it != st[neww].end()) {
      auto it2 = it;
      it2--;
      ll x = *it - *it2 - 1;
      res -= x * (x + 1) / 2 * c[neww];
      pen[neww] += x * (x + 1) / 2 * c[neww];
      it++;
    }

    if(oldres < res) {
      t[d[i]] = neww;
    }
    else {
      t[d[i]] = old;
      st[old] = oldst1;
      st[neww] = oldst2;
      pen[old] = oldpen1;
      pen[neww] = oldpen2;      
    }
  }

  rep(i,D) cout << t[i]+1 << "\n";
  
  return 0;
}


Measured memory_bytes: 12244
#pragma GCC optimize(3,"Ofast","inline")
#pragma GCC target("avx")
#include <bits/stdc++.h>
using namespace std;
#ifdef ONLINE_JUDGE
#define getchar gc
inline char gc(){
	static char buf[1<<16],*p1=buf,*p2=buf;
	if(p1==p2){
		p2=(p1=buf)+fread(buf,1,1<<16,stdin);
		if(p2==p1) return EOF;
	}
	return *p1++;
}
#endif
template<class t> inline t read(t &x){
    char c=getchar();bool f=0;x=0;
    while(!isdigit(c)) f|=c=='-',c=getchar();
    while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
    if(f) x=-x;return x;
}
template<class t> inline void write(t x){
    if(x<0) putchar('-'),write(-x);
    else{if(x>9) write(x/10);putchar('0'+x%10);}
}

const int N=2e5+5;
int num[N],n,un,a[N],tr[N],ans[N],tp[N][21],cur;
vector<int> g[N];

#define lowbit(x) (x&(-x))

void up(int x,int v){
	while(x<=un){
		tp[cur][++tp[cur][0]]=tr[x];
		tr[x]=max(tr[x],v);
		x+=lowbit(x);
	}
}

int que(int x){
	int res=0;
	while(x){
		res=max(res,tr[x]);
		x-=lowbit(x);
	}
	return res;
}

void reset(int x){
	int n=0;
	while(x<=un){
		tr[x]=tp[cur][++n];
		x+=lowbit(x);
	}
}

void dfs(int x,int fa){
	ans[x]=que(a[x]-1)+1;
	cur=x;
	up(a[x],ans[x]);
	for(int y:g[x]) if(y^fa) dfs(y,x);
	cur=x;
	reset(a[x]);
}

void pre(int x,int fa){
	ans[x]=max(ans[x],ans[fa]);
	for(int y:g[x]) if(y^fa) pre(y,x);
}

signed main(){
	read(n);
	for(int i=1;i<=n;i++) num[i]=read(a[i]);
	sort(num+1,num+1+n);
	un=unique(num+1,num+1+n)-num-1;
	for(int i=1;i<=n;i++) a[i]=lower_bound(num+1,num+1+un,a[i])-num;
	for(int i=1,x,y;i<n;i++){
		read(x);read(y);
		g[x].push_back(y);
		g[y].push_back(x);
	}
	dfs(1,0);
	pre(1,0);
	for(int i=1;i<=n;i++) write(ans[i]),puts("");
}

Measured memory_bytes: 44788
#include<iostream>
#include<math.h>
using namespace std;
int main(){
int a, b, c;
float s, t;
int u;
cin >> a >> b >> c;
s = (a + b + c)/2;
t = s * (s-a) * (s-b) * (s-c);
u = sqrt(t);
cout << u;
 
  
return 0;
  
}


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

const int MAXN = 200010;
long long a[MAXN], sum = 0;
long long delta(long long x, long long y) {
	long long d = x - y;
	return d>0?d:-d;
}
int main() {
	int n;
	cin>>n;
	for (int i=0; i<n; i++) {
		cin>>a[i];
		sum += a[i];
	}
	long long ans = sum, tmp = 0;
	for (int i=0; i<n-1; i++) {
		tmp += a[i];
		ans = min(ans, delta(tmp, sum-tmp));
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
int main()
{
    int n,t,c[1001],m[1001],min=1001,i;
    scanf("%d %d",&n,&t);
    for(i=0;i<n;i++)
    {
        scanf("%d %d",&c[i],&m[i]);
        if(m[i]>t) c[i]=1002;
        if(c[i]<min) min=c[i];
    }
    if(min!=1001) printf("%d",min);
    else printf("TLE");
    return 0;
}


Measured memory_bytes: 128
class Dice(object):
 
    def __init__(self, d):

        self.rows = [d[0], d[4], d[5], d[1]]
        self.cols = [d[0], d[2], d[5], d[3]]
 
    def move_next_rows(self):
        temp = self.rows.pop(0)
        self.rows.append(temp)
        self.__update(self.cols, self.rows)

    def move_prev_rows(self):
        temp = self.rows.pop(3)
        self.rows.insert(0, temp)
        self.__update(self.cols, self.rows)
    
    def move_next_cols(self):
        temp = self.cols.pop(0)
        self.cols.append(temp)
        self.__update(self.rows, self.cols)
 
    def move_prev_cols(self):
        temp = self.cols.pop(3)
        self.cols.insert(0, temp)
        self.__update(self.rows, self.cols)

    def __update(self, x, y):
        x[0] = y[0]
        x[2] = y[2]
 
class DiceChecker(object):

    def __init__(self, dice1, dice2):
        self.dice1 = dice1
        self.dice2 = dice2
        self.dice1_top = self.dice1.rows[0]
        self.dice1_front = self.dice1.rows[3]
        
    def check_same_dice(self):
        for _ in range(4):
            for _ in range(4):
                for _ in range(4):
                    is_same_element = self.dice1.rows == self.dice2.rows and self.dice1.cols == self.dice2.cols
                    if is_same_element: 
                        return True
                    self.__rot(self.dice2)
                self.dice2.move_next_rows()
            self.dice2.move_next_cols()
            
        return False
    
    def __rot(self, dice):
        temp = dice.rows[1]
        dice.rows[1] = dice.cols[3]
        dice.cols[3] = dice.rows[3]
        dice.rows[3] = dice.cols[1]
        dice.cols[1] = temp


j = int(input())
dice_list = []
src = []
for _ in range(j):
    d = list(map(int, input().split(" ")))
    dice_list.append(Dice(d))
    src.append(Dice(d))

is_diff = 0
for dice1 in dice_list:
    src.pop(0)
    for dice in src:
        dice_checker = DiceChecker(dice1, dice)
        if(dice_checker.check_same_dice()):
            is_diff += 1

if is_diff > 0:
    print("No")
else:
    print("Yes")



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

const int nmax = 8;
vector<vector<bool>> grahp(nmax, vector<bool>(nmax));
vector<bool> visited(nmax, true);

int dfs(int v, int N, vector<bool> visited) {

    bool all_visited = true;

    rep(i, N) {
        if(visited[i] == false) {
            all_visited = false;
        }
    }

    if (all_visited) {
        return 1;
    }

    int ret = 0;
    rep(i, N) {
        if(grahp[v][i] == false) continue;
        if(visited[i]) continue;

        visited[i] = true;
        ret+=dfs(i, N, visited);
        visited[i] = false;

    }

    return ret;
}

int main(void) {
    int N, M;
    cin >> N >> M;

    rep(i, M) {
        int x, y;
        cin >> x >> y;
        grahp[x-1][y-1] = grahp[y-1][x-1] = true;
    }

    vector<bool> visited(N, false);

    visited[0] = true;
    cout << dfs(0, N, visited) << endl;

    return 0;

}


Measured memory_bytes: 256
S = input()

count1 = 0
count2 = 0

n = 0
#10101010...にする
for c in S:
    if n % 2 == 0 and c == '0':
        count1 += 1
    if n % 2 == 1 and c == '1':
        count1 += 1
    n += 1

n = 0
#010101010...にする
for c in S:
    if n % 2 == 0 and c == '1':
        count2 += 1
    if n % 2 == 1 and c == '0':
        count2 += 1
    n += 1
print(min(count1,count2))

Measured memory_bytes: 3188
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner scanner = new Scanner(System.in);
        
        int app = scanner.nextInt();
        int app_pc = scanner.nextInt();
        
        long sum = (app * 3 + app_pc)/2; 
        System.out.println(sum);
    }
}


Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x))%modulo)
#define Inf 100000000000000000



int main(){
	int A,B,C;
	cin>>A>>B>>C;
	
	C-=(A-B);
	
	cout<<max(C,0)<<endl;
	
	
	
	
	
	return 0;
}




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

    const int MOD = 1000000007;
    const double PI = acos(-1); 

    //long long
    using ll = long long;

    //出力系
    #define print(x) cout << x << endl
    #define yes cout << "Yes" << endl
    #define YES cout << "YES" << endl
    #define no cout << "No" << endl
    #define NO cout << "NO" << endl
    
    // begin() end()
    #define all(x) (x).begin(),(x).end()

    //for
    #define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

    //最大公約数（ll）
    ll gcd(ll x, ll y) { return y ? gcd(y,x%y) : x;}

    //素因数分解
    vector<pair<ll, int>>factorize(ll n){
      vector<pair<ll, int>> res;
      for(ll i = 2; i * i <= n; ++i){
        if(n % i) continue;
        res.emplace_back(i, 0);
        while(n % i == 0){
          n /= i;
          res.back().second++;
        }
      }
    if(n != 1) res.emplace_back(n, 1);
    return res;
    }



  // // 二分探索(最小値を出す問題は疑う)
  // bool C(ll x){
  //     ll res = 0;
  //     for(int i = 0; i < N; ++i){
  // 		res += max(0ll, A[i]-x/F[i]);
  //     }
  //     return res <= K;
  // }

  //   ll binary_search(ll ok, ll ng){
  //     while(abs(ok - ng) > 1){
  //       ll mid = (ok + ng) / 2;
  //       if(C(mid)) ok = mid;
  //       else ng = mid;
  //     }
  //     return ok;
  //   }



  int main(){
    int N;
    cin >> N;
    string S;
    cin >> S;
    string S1 = "", S2 = "";
    if(N % 2 != 0){
      no;
      return 0;
    }else{
      REP(i, N){
        if(i + 1 <= N / 2){
          S1 += S.at(i); 
        }else{
          S2 += S.at(i);
        }
      }
    }
  if(S1 == S2) yes;
  else no;
  
  }

Measured memory_bytes: 256
int main(){
    int ohajiki,count;
    int i,jc,n,jiro[25]={0};
    while(1){
        scanf("%d",&n);
        if(n == 0){
            break;
        }
        count=1;
        ohajiki=32;
        jc=0;
        for(i=0;i<n;i++){
            scanf("%d",&jiro[i]);
        }
        while(1){
            if(ohajiki == 0){
                break;
            }
            if(count % 2 == 1){
                ohajiki=ohajiki - (ohajiki - 1) % 5;
            }
            else if(count % 2 == 0){
                if(jc >= n){
                    jc = 0;
                }
                ohajiki=ohajiki - jiro[jc];
                jc++;
            }
            count++;
            if(ohajiki < 0){
                ohajiki=0;
            }
            printf("%d\n",ohajiki);
        }
    }
    return (0);
}

Measured memory_bytes: 600
void main()
{
    long n = rdElem;
    Input[] input = n.rdCol!Input;

    foreach (x; 0 .. 101)
    {
        foreach (y; 0 .. 101)
        {
            long h;
            foreach (a; input)
            {
                if (a.h) h = a.h + abs(a.x-x) + abs(a.y-y);
            }
            bool ok = true;
            foreach (a; input)
            {
                if (a.h != max(0, h-abs(a.x-x)-abs(a.y-y)))
                {
                    ok = false;
                    break;
                }
            }
            if (ok)
            {
                 writeln(x, " ", y, " ", h);
                 return;
            }
        }
    }
}

struct Input
{
    long x, y, h;
}

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

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

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;

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

int main(){
    ll l,r;
    cin >> l >> r;
    vector<int> amari;
    int count = min(ll(2019),r - l+1);
    ll s = l;
    while(count--){
        amari.push_back(s%2019);
        s++;
    }
    int n = amari.size();
    int ans = 2018;
    for(int i = 0;i < n;i++){
        for(int j = i+1;j < n;j++){
            ans = min(ans,amari.at(i) * amari.at(j) % 2019);
        }
    }
    // rep(i,n) cout << amari.at(i) << endl;
    cout << ans << endl;
}

Measured memory_bytes: 3652
x,y = map(int,input().split())
ls1 = [1,3,5,7,8,10,12]
ls2 = [4,6,9,11]
ls3 = [2]
if x in ls1 and y in ls1:
    print("Yes")
elif x in ls2 and y in ls2:
    print("Yes")
elif x in ls3 and y in ls3:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
import collections
n,*a=map(int,open(0).read().split())
b=[0]*n
b[0]=a[0]
for i in range(1,n):
    b[i]=b[i-1]+a[i]
b.sort()    
b=[0]+b
ans=0
l=collections.Counter(b)
for i in l.values():
    ans+=i*(i-1)//2
print(ans)

Measured memory_bytes: 42200
s = input()
a = list("abcdefghijklmnopqrstuvwxyz")
if s == "zyxwvutsrqponmlkjihgfedcba":
    print(-1)
elif len(s) != 26:
    nokori = set(a) - set(s)
    nokori = sorted(nokori, key=a.index)
    print(s + nokori[0])
else:
    for i in range(1, 27):
        if s[-i] > s[-i - 1]:
            break
    s_ = sorted(s[-i:])
    for j in s_:
        if j > s[-i - 1]:
            break
    print(s[:-i - 1] + j)

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>

using namespace std;

static const int MMAX = 20;
static const int NMAX = 50000;
static const int INFTY = (1 << 29);

main() {
	int n, m;
	int C[21];
	int T[NMAX + 1];

	cin >> n >> m;

	for (int i = 1; i <= m; i++) {
		cin >> C[i];
	}

	for (int i = 0; i <= NMAX; i++)T[i] = INFTY;
	T[0] = 0;
	for (int i = 1; i <= m; i++) {
		for (int j = 0; j + C[i] <= n; j++) {
			T[j + C[i]] = min(T[j + C[i]], T[j] + 1);
		}
	}

	cout << T[n] << endl;

	return 0;
}


Measured memory_bytes: 3304
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
ll a,b,x;
int main() {
  cin>>a>>b>>x;
  if (a == 0) {
  	cout<<b/x+1<<endl;
  } else {
  	a--;
    cout<<b/x - a/x<<endl;
  }
	return 0;
}


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

ans = 0
for i in range(2**n):
    s = format(i, "b").zfill(n)
    flag = 1
    for j in range(len(s)):
        if s[j] == "1":
            for k in range(len(v[j])):
                if v[j][k][1] == 1 and s[v[j][k][0]-1] == "0":
                    flag = 0
                    break
                if v[j][k][1] == 0 and s[v[j][k][0]-1] == "1":
                    flag = 0
                    break
    """    else:
            for k in range(len(v[j])):
                if v[j][k][1] == 1 and s[v[j][k][0]-1] == "1":
                    flag = 0
                    break
                if v[j][k][1] == 0 and s[v[j][k][0]-1] == "0":
                    flag = 0
                    break"""
    if flag == 1:
        ans = max(ans, s.count("1"))

print(ans)


Measured memory_bytes: 3188
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>

using namespace std;

typedef long long ll;

ll ceil(ll a, ll x) {
  ll i = a;
  if(i%x != 0) i+=x-i%x;
  return i;
}

ll floor(ll a, ll x) {
  ll i = a;
  if(i%x) i-=i%x;
  return i;
}

int main() {
  long long a,b,x;
  cin >> a >> b >> x;
  long long cnt = 0;
  ll c,out;
  c = floor(b, x) - ceil(a, x);
  if (c < 0) out = 0;
  else out = c / x + 1;
  cout << out << endl;
  return 0;
}


Measured memory_bytes: 3580
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#include <cstring>
#include <string>
#include <bitset>
#include <stack>
#include <set>
#include <map>
#include <list>
#include <assert.h>
using namespace std;
#define e exp(1.0)
typedef long long ll;
#define MAXN 100005
#define mod 998244353
#define INF 0x3f3f3f3f3f3f3f
#define fe(i,st,en) for(i = (st);i <= (en);++i)
#define fne(i,st,en) for(i = (st);i < (en);++i)
#define ri register int
#define db double
int a[MAXN],ida[MAXN],b[MAXN],idc[MAXN], c[MAXN];
int tr[MAXN << 1], n, m, sz;
vector<int> vec;
void diperse() {
	for (int i = 1; i <= n; ++i) vec.push_back(a[i]);
	for (int i = 1; i <= m; ++i) vec.push_back(c[i]);
	sort(vec.begin(), vec.end());
	unique(vec.begin(), vec.end());
	for (int i = 1; i <= n; ++i) ida[i] = lower_bound(vec.begin(), vec.end(), a[i]) - vec.begin() + 1;
	for (int i = 1; i <= m; ++i) idc[i] = lower_bound(vec.begin(), vec.end(), c[i]) - vec.begin() + 1;
	sz = vec.size();
}
void solve() {
	for (int i = 1; i <= n; ++i) tr[ida[i]]++;
	int l = 1, sum = 0;
	for (int i = 1; i <= m; ++i) {
		while (l < idc[i] && sum <= b[i]) sum += tr[l], ++l;
		if (l < idc[i]) --l,tr[l] = sum - b[i], tr[idc[i]] += b[i];//sum > b[i]
		else if (sum <= b[i]) tr[idc[i]] += sum;//ida[l] > idc[i]
		else {//sum > b[i] && ida[l] > idc[i]
			--l;
			tr[l] = sum - b[i];
			tr[idc[i]] += b[i];
		}
		sum = 0;
	}
	ll ans = 0;
	for (int i = l; i <= sz; ++i) {
		ans = ans + (ll)vec[i - 1] * tr[i];
	}
	cout << ans << endl;
}
int main() {
	cin >> n >> m;;
	for (int i = 1; i <= n; ++i)scanf("%d", a + i);
	for (int i = 1; i <= m; ++i) scanf("%d%d", b+i, c+i);
	diperse();
	solve();
	return 0;
}

Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n, a;
	cin >> n;
	cin >> a;
	for(int i=0;i<=a;i++)
	{
		if((n-1*i)%500==0)
		{
			cout << "Yes" <<endl;
			return 0;
		}	
	}
	cout << "No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<set>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<deque>
#include<string>
#include<math.h>
using namespace std;
#define ll long long int 






int main() {
	

	int n;
	int k;
	cin >> k;
	cin >> n;

	int sum = 0;
	for (int i = 0; i < n; i++) {
		int val; cin >> val;
		sum += val;
	}

	if (sum > k) {
		cout << "-1" << endl;
	}
	else {
		cout << k - sum << endl;
	}

	return 0;
}

Measured memory_bytes: 3632
const binarySearch = (key, arr, N) => {
  let mid;
  let left = 0;
  let right = N;
  if (key < arr[0] || arr[N-1] < key) return 0;
  while (left < right) {
    mid = Math.floor((left + right) / 2);
    if (key < arr[mid]) right = mid;
    else if (key > arr[mid]) left = mid + 1;
    else return 1;
  }
  return 0;
}



let input = require('fs').readFileSync('/dev/stdin', 'utf8');
let Arr = (input.trim()).split("\n");
let N1 = Number(Arr[0]);
let arr1 = Arr[1].split(" ").map(Number);
// const N2 = Number(Arr[2]);
let arr2 = Arr[3].split(" ").map(Number);
console.log(arr2.map(e => binarySearch(e, arr1, N1)).reduce((a, b) => a + b, 0));




Measured memory_bytes: 34928
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ziyuutyou
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

            if (Math.Abs(N[0] - N[1]) < Math.Abs(N[0] - N[2]))
            {
                Console.WriteLine("A");
            }
            else
            {
                Console.WriteLine("B");
            }
        }
    }
}

Measured memory_bytes: 11092
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
#define ALL(X) X.begin(), X.end()
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef std::pair<LL,LL> PLL;//
typedef std::pair<int,int> PII;//
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)4e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	string strA,strB;
	cin >> strA >> strB;
	int sizeA = strA.size();
	int sizeB = strB.size();
	string ans = strA;
	for(int pos = sizeA-sizeB;pos>=0;--pos){
		bool flag = true;
		for(int i=0;i<sizeB;++i){
			//pos+i,i
			if( strA[pos+i] == '?' ){
				continue;
			}else if( strA[pos+i]==strB[i] ){
				continue;
			}else{
				flag = false;
				break;
			}
		}
		if( flag ){
			for(int i=0;i<sizeB;++i){
				ans[pos+i] = strB[i];
			}
			for(int i=0;i<sizeA;++i){
				if( ans[i] == '?' ){
					ans[i] = 'a';
				}
			}
			cout << ans << endl;
			return;
		}else{
			if( ans[pos+sizeB-1] == '?' ){
				ans[pos+sizeB-1] = 'a';
			}
		}
	}
	
	cout << "UNRESTORABLE" << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()

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

#define max 11

//qsort(d, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}

int main()
{
    int i, j, a, s[max];
    
    scanf("%d", &a);
    scanf("%s", s);
    
    if (a>=3200) {
        printf("%s", s);
    } else {
        printf("red");
    }

    return 0;
}




Measured memory_bytes: 128
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<cstring>
using namespace std;
inline long long read()
{
	long long x=0;int f=1;char ch=getchar();
	while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
	return x*f;
}
int stack[20];
inline void write(int x)
{
	if(x<0){putchar('-');x=-x;}
	if(!x){putchar('0');return;}
	int top=0;
	while(x)stack[++top]=x%10,x/=10;
	while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
long long A[200010],a[200010],c[200010];
int B[200010],b[200010];
int top,sta[200010];
int main()
{
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	int n=read(),p=0;long double ans=0.0;
	for(int i=1;i<=n;i++){A[i]=read();if(A[i]>=A[p])p=i;}
	for(int i=1;i<=n;i++)B[i]=read();
	for(int i=p;i<=n;i++)a[i-p]=A[i],b[i-p]=B[i];
	for(int i=1;i<=p;i++)a[n-p+i]=A[i],b[n-p+i]=B[i];
	c[0]=c[1]=0.0;
	for(int i=1;i<n;i++){c[i+1]=2*(c[i]-b[i])-c[i-1];a[i+1]+=c[i+1],ans-=c[i+1];}
	for(int i=0;i<=n;i++)
	{
		while(top>1 && (a[i]-a[sta[top]])*(sta[top]-sta[top-1])>(a[sta[top]]-a[sta[top-1]])*(i-sta[top]))top--;
		sta[++top]=i;
	}
	for(int i=2;i<=top;i++)
	{
		int l=sta[i-1],r=sta[i];
		ans+=1.0L*(a[l]-a[r])*(r-l-1)/2+a[r]*(r-l);
	}printf("%.12Lf\n",ans/n);
	return 0;
}

Measured memory_bytes: 8668
#include <bits/stdc++.h>
#define fin ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
#define ll long long
ll dp[3005][3005][2];
int a[3005];
int mod=1e9 +7;
#define MAX 1e18+5;
ll solve(int i,int j,int k)
{
  if(dp[i][j][k]!=-1)
    return dp[i][j][k];
  else if(i==j)
  {
    if(k==0)
      dp[i][j][k]=a[i];
    else
      dp[i][j][k]=-a[i];
  }
  else
  {
    if(k==0)
      dp[i][j][k]=max(a[i]+solve(i+1,j,!k),a[j]+solve(i,j-1,!k));
    else
      dp[i][j][k]=min(-a[i]+solve(i+1,j,!k),-a[j]+solve(i,j-1,!k));
  }
  return dp[i][j][k];
}
int main()
{
  fin;
  int n,i,j;
  cin>>n;
  for(i=0;i<n;i++)
    cin>>a[i];
  memset(dp,-1,sizeof(dp));
  cout<<solve(0,n-1,0);
}


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

int max(int x,int y,int z){
  int m = x;
  if(x <= y){
    m = y;
  }
  if(m <= z){
    m = z;
  }
  return m;
}

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  int k;
  cin >> k;
  int i,bi=1;
  for(i=0;i<k;i++){
    bi = 2*bi;
  }
  cout << (bi-1)*max(a,b,c) + a + b + c << "\n";
  return 0;
}


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

  mod=10**9+7
  ans=0

  for i in range(60):
      a=0
      for x in A:
          if x>>i&1:
              a+=1
      ans+=a*(N-a)*pow(2,i,mod)
      ans%=mod
  print(ans)
if __name__ == '__main__':
    main()


Measured memory_bytes: 51020
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back      
#define F first
#define S second
#define SS stringstream
#define sqr(x) ((x)*(x))
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define CC(x) cout << (x) << endl
#define pw(x) (1ll<<(x))
#define buli(x) __builtin_popcountll(x)
#define forn(i, n) for(int i = 0 ; (i) < (n) ; ++i)
#define M 1000000007
#define N 211111

#define TASK "1"

using namespace std;

int main(){
	#ifdef home
		freopen(TASK".in","r",stdin);	
		freopen(TASK".out","w",stdout);
	#endif		
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;

	int t = (n - m) * 100 + m * 1900;
	t *= pw(m);
	cout <<t << endl;
	return 0;
}

Measured memory_bytes: 256
'use strict'

function main(input) {
    input = input.split("\n");
    const N = parseInt(input[0]);
    const S = input[1];
    let ans = 0;
    for (let i = 0; i < N; i++) {
        let count = 0;
        let obj = {};
        for (let j = 0; j < i; j++) {
            obj[S[j]] = true;
        }
        for (let j = i; j < N; j++) {
            if (obj[S[j]]) {
                count++;
                delete obj[S[j]];
            }
        }
        if (count > ans)
            ans = count;
    }
    console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'));


Measured memory_bytes: 7372
N,K = map(int,input().split())
d = []
A = []
for i in range(K):
    d.append(int(input()))
    A.append(list(map(int,input().split())))


non_given =[]
for i in range(N):
    non_given.append(i+1)

for i in range(K):
    for j in range(len(A[i])):
        if(A[i][j] in non_given):
            non_given.remove(A[i][j])

print(len(non_given))


Measured memory_bytes: 9216
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
using namespace __gnu_pbds;
#define int long long int
#define pb push_back
#define vec vector<int>
#define fo(i, n) for (int i = 0; i < n; i++)
#define foo(i, a, b) for (int i = a; i < b; i++)
#define mp make_pair
#define deb(x) cout << #x << " --> " << x << endl;

#define deb1a(v)                  \
    cout << #v << "--->" << endl; \
    for (auto it : v)             \
        cout << it << " ";        \
    cout << endl;
#define deb2a(v)                  \
    cout << #v << "--->" << endl; \
    for (auto it : v)             \
    {                             \
        for (auto it1 : it)       \
        {                         \
            cout << it1 << " ";   \
        }                         \
        cout << endl;             \
    }
#define deb3a(v) cout << #v << "-->" << endl; for(auto it:v){\
cout << it.fi << " " << it.se << endl;}


#define mod 1000000007
#define so(v) sort(v.begin(),v.end())
#define fi first
#define se second
//#define endl "\n"
int power(int x, unsigned int y, int p){ int res = 1;x = x % p;while (y > 0)  { if (y & 1)res = (res*x) % p;y = y>>1;  x = (x*x)% p;} return res;}
int mI(int a, int m)  {return power(a, m - 2, m);}



int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int s, w;
    cin >> s >> w;
    if(w>=s){
        cout << "unsafe";
    }
    else{
        cout << "safe";
    }

   

}

Measured memory_bytes: 3636
import java.util.Scanner;

class Main {
    private static boolean isModuicSquare(int[][] table, int moduic) {
        int modulo = (table[0][0] + table[0][1] + table[0][2]) % moduic;
        for (int i = 1; i < 3; i++) {
            if ((table[i][0] + table[i][1] + table[i][2]) % moduic != modulo) {
                return false;
            }
        }
        for (int j = 0; j < 3; j++) {
            if ((table[0][j] + table[1][j] + table[2][j]) % moduic != modulo) {
                return false;
            }
        }
        if ((table[0][0] + table[1][1] + table[2][2]) % moduic != modulo) {
            return false;
        }
        if ((table[2][0] + table[1][1] + table[0][2]) % moduic != modulo) {
            return false;
        }
        return true;
    }

    private static int rec(int n, int[][] table, int moduic, boolean[] used) {
        int x = n / 3;
        int y = n % 3;
        int result = 0;
        if (n > 8) {
            for (int i = 1; i < 11; i++) {
                if (!used[i]) {
                    moduic = i;
                }
            }
            if (isModuicSquare(table, moduic)) {
                result = 1;
            } else {
                result = 0;
            }
        } else if (table[x][y] == 0) {
            for (int i = 1; i < 11; i++) {
                if (!used[i]) {
                    table[x][y] = i;
                    used[i] = true;
                    result += rec(n + 1, table, moduic, used);
                    table[x][y] = 0;
                    used[i] = false;
                }
            }
        } else {
            result = rec(n + 1, table, moduic, used);
        }
        return result;
    }
         
    private static void solve() {
        Scanner scanner = new Scanner(System.in);

        while (true) {
            int[][] table = new int[3][3];
            boolean[] used = new boolean[11];
            for (int i = 0; i < 3; i++) {
                for (int j = 0; j < 3; j++) {
                    table[i][j] = scanner.nextInt();
                }
            }
            int moduic = scanner.nextInt();
            if (moduic == -1) {
                break;
            }
            for (int i = 0; i < 3; i++) {
                for (int j = 0; j < 3; j++) {
                    used[table[i][j]] = true;
                }
            }
            used[moduic] = true;
            System.out.println(rec(0, table, moduic, used));
        }
    }

    public static void main(String... args) {
        solve();
    }
}

Measured memory_bytes: 0
/*		author:: ajeet  */
/*			*/

	#include<bits/stdc++.h>
	using namespace std;
	#define int long long int
	#define pb push_back
	const int mod=1e9+7;
	#define all(x) x.begin(),x.end()
	#define endl '\n'
	#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
	int32_t main(){
		IOS;
		int a,b,c,d;
		cin>>a>>b>>c>>d;
		int x=(a+d-1)/d;
		int y=(b+c-1)/b;
		if(x>=y)cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
		return 0;
	}


Measured memory_bytes: 3572
#include <algorithm>
#include <iostream>
#include <vector>
#include <set>

#include <string.h>

using namespace std;

typedef long long ll;

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

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

const int MAX_N = 3000;
const int MAX_T = 3000;

ll dp1[MAX_N + 2][MAX_T + 2];

void print_dp(int N, int T, ll dp[MAX_N + 2][MAX_T + 2]) {
    for (int n = 1; n <= N; n++) {
        for (int t = 1; t <= T; t++) {
            cout << dp[n][t] << " ";
        }
        cout << endl;
    }
}

/*
 * Based on solution 2.
 * ref. https://img.atcoder.jp/abc145/editorial.pdf
 */
int main(void) {
    int N, T;
    cin >> N >> T;
    
    vector<pair<int, int> > dishes(N);
    for (int i = 0; i < N; i++) {
        int a, b;
        cin >> a >> b;
        dishes[i] = {a, b};
    }
    sort(dishes.begin(), dishes.end(), [](const pair<int, int> &a, const pair<int, int> &b) {
            return a.first < b.first;
    });

    memset(dp1, 0, sizeof(ll) * (MAX_N + 2) * (MAX_T + 2));

    for (int n = 1; n <= N; n++) {
        for (int t = 1; t <= T; t++) {
            if (dishes[n - 1].first <= t) {
                dp1[n][t] = max(dp1[n - 1][t], dp1[n - 1][t - dishes[n - 1].first] + dishes[n - 1].second);
            } else {
                dp1[n][t] = dp1[n - 1][t];
            }
        }
    }

    ll max = 0;
    for (int i = 1; i <= N; i++) {
        auto max_remain = max_element(dishes.begin() + i, dishes.end(), [](const pair<int, int> &a, const pair<int, int> &b) {
                return a.second < b.second;
        });
        for (int j = 1; j <= T - 1; j++) {
            chmax(max, dp1[i][j] + ((max_remain != dishes.end()) ? max_remain->second : 0));
        }
    }

    // print_dp(N, T, dp1);
    // cout << endl;
    // print_dp(N, T, dp2);
    // cout << endl;

    cout << max << endl;

    return 0;
}


Measured memory_bytes: 70656
use std::cmp::*;
use std::io::*;
use std::str::FromStr;
use utils::*;

pub fn main() {
    let i = stdin();
    let mut o = Vec::new();
    run(i.lock(), &mut o);
    stdout().write_all(&o).unwrap();
}

fn run<R: BufRead, W: Write>(i: R, o: &mut W) {
    let mut i = CpReader::new(i);
    let n = i.read::<usize>();
    let a = i.read_vec::<usize>(n);

    writeln!(o, "{}", solve(a)).unwrap();
}
fn counts(a: &[usize]) -> Vec<usize> {
    let mut rs = Vec::with_capacity(a.len() + 1);

    rs.push(0);
    rs.push(0);

    let mut ss = ([0; 16], [0; 16]);
    let mut ss = (&mut ss.0, &mut ss.1);

    for c in 0..ss.0.len() {
        ss.0[c] = c;
    }

    for i in 1..a.len() {
        let mut d = 0isize;
        let mut a0 = a[i - 1];
        let mut a1 = a[i];
        while a0 < a1 {
            a0 *= 4;
            d += 1;
        }
        while a0 >= a1 * 4 {
            a1 *= 4;
            d -= 1;
        }
        for c in 0..ss.1.len() {
            let mut c_next = max(c as isize + d, 0) as usize;
            let mut r = c;
            if c_next >= ss.0.len() {
                let d = c_next - ss.0.len() + 1;
                r += i * d + ss.0.last().unwrap();
                for c in c..ss.1.len() {
                    ss.1[c] = r;
                    r += i + 1;
                }
                break;
            }
            ss.1[c] = r + ss.0[c_next];
        }
        rs.push(ss.1[0]);
        std::mem::swap(&mut ss.0, &mut ss.1);
    }
    rs
}
fn solve(mut a: Vec<usize>) -> usize {
    let cs0 = counts(&a);
    a.reverse();
    let cs1 = counts(&a);

    (0..a.len())
        .map(|x| cs0[x] * 2 + x + cs1[a.len() - x] * 2)
        .min()
        .unwrap()
}

mod utils {
    use super::*;

    pub struct CpReader<R: BufRead> {
        r: R,
        s: String,
    }

    macro_rules! fn_read {
        { $f:ident($($t:ident),*) } => {
            #[allow(dead_code)]
            pub fn $f<$($t: FromStr),*>(&mut self) -> ($($t),*) {
                let i = &mut self.read_line().split(' ');
                ($(read_next::<$t,_>(i)),*)
            }
        };
    }

    impl<R: BufRead> CpReader<R> {
        pub fn new(r: R) -> Self {
            CpReader {
                r: r,
                s: String::new(),
            }
        }
        pub fn read_line(&mut self) -> &str {
            self.s.clear();
            self.r.read_line(&mut self.s).unwrap();
            self.s.trim()
        }

        pub fn read<T: FromStr>(&mut self) -> T {
            self.read_line().parse().ok().unwrap()
        }
        fn_read! { read2(T1, T2) }
        fn_read! { read3(T1, T2, T3) }
        fn_read! { read4(T1, T2, T3, T4) }
        fn_read! { read5(T1, T2, T3, T4, T5) }

        pub fn read_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            self.read_line()
                .split(' ')
                .take(n)
                .map(|x| x.parse().ok().unwrap())
                .collect()
        }
    }
    fn read_next<'a, T: FromStr, I: Iterator<Item = &'a str>>(i: &mut I) -> T {
        i.next().unwrap().parse().ok().unwrap()
    }

}


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

#define int long long
#define rep(i, n) for (int i = 0; i < (int) (n); i++)
#define reps(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), end(x))
#define bit(n) (1LL << (n))
#define cdiv(a, b) (((a) - 1) / (b) + 1)
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr double PI = 3.1415926535897932384626433832795028;
constexpr int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

signed main() {
    int H, W, N;
    cin >> H >> W >> N;
    cout << cdiv(N, max(H, W)) << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N+1];
		for(int i = 0;i < N;i++) {
			A[i] = sc.nextInt();
		}
		sc.close();

		int[] L = new int[N+2];
		int[] R = new int[N+2];
		L[0] = 0;
		R[N+1] = 0;
		for(int i = 0;i < N;i++) {
			L[i+1] = gcd(L[i],A[i]);
		}
		for(int i = N;i > 0;i--) {
			R[i] = gcd(R[i+1],A[i]);
		}
		int[] M = new int[N+1];
		int max = 0;
		for(int i = 0;i < N;i++) {
			M[i] = gcd(L[i],R[i+1]);
			max = Math.max(max, M[i]);
		}
		System.out.println(max);
	}

	private static int gcd(int a, int b) {
		if(b == 0) {
			return a;
		}else if(a == 0) {
			return b;
		}
		return gcd(b,a%b);
	}
}


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

#define all(x) begin(x), end(x)

using i64 = int_fast64_t;
using u64 = uint_fast64_t;
using f64 = double;
using p64 = pair<i64, i64>;

constexpr i64 INF = INT_FAST64_MAX / 2;

void solve() {
    i64 n;
    cin >> n;
    vector<i64> h(n);
    for (auto& e : h) cin >> e;

    vector<i64> dp(n, INF);
    dp[0] = 0;
    for (i64 i = 0; i + 1 < n; i++) {
        dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i + 1] - h[i]));
        if (i + 2 < n) dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i + 2] - h[i]));
    }
    cout << dp[n - 1] << endl;
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


Measured memory_bytes: 4744
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
 
int main(){
int n;
cin >> n;
vi t;
int sum = 0;
REP(i,n){
int tmp;
cin >> tmp;
t.pb(tmp);
sum += tmp;
}
int m;
cin >> m;
REP(i,m){
int a,b;
cin >> a >> b;
cout << sum - t[a-1] + b << endl;
}
}

Measured memory_bytes: 256