akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <iomanip>

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

#define ALL(a) (a).begin(),(a).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdbl vector<double>
#define vstr vector<string>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

	int N,M;
	cin >> N >> M;

	vint g[N];
	rep(i,M){
		int a,b;
		cin >> a >> b;
		a--;
		b--;

		g[a].push_back(b);
		g[b].push_back(a);
	}

	rep(i,N){
		cout << g[i].size() << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int sx,sy,tx,ty;
void r1(){
    for(int j = 0;j<4;j++){
        if(j>=2){
            cout << (j%2==0?'D':'U');
        }
        int k = (j>=2?1:0);
        for(int i= 0;i<tx-sx+k;i++){
            cout << (j%2==0?'R':'L');
        }
        
        for(int i= 0;i<ty-sy+k;i++){
            cout << (j%2==0?'U':'D');
        }
        
        if(j>=2){
            cout << (j%2==0?'L':'R');
        }
    }
}




int main(){
    cin >> sx >> sy >> tx >> ty;
    r1();
    
    
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int A, B, C, s;
int main()
{
    scanf("%d%d%d",&A,&B,&C);
    s = (A+B+C)/2;
    int area = sqrt(s*(s-A)*(s-B)*(s-C));
    printf("%d\n",area);
    return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;
int n, c, k, a[100005], sum;
int main(){
	int l = 1 , r = 0;
	scanf("%d%d%d", &n , &c, &k);
	for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
	sort(a + 1, a + n + 1);
	for(int i = 1; i <= n; i++){
		r++;
		if(r - l + 1 > c || a[r] - a[l] > k){
			sum++;
			l = r;
			if(i == n);
		}
	}
	sum++;
	printf("%d", sum);
}





Measured memory_bytes: 512
# https://atcoder.jp/contests/abc155/submissions/10157837
# 写経

def main():
    a = [0]
    a += map(int, input())
    a.reverse()

    n = len(a)
    b = a.copy()

    for i in range(n):
        if b[i] > 5 or (b[i] == 5 and b[i + 1] >= 5):
            b[i] = 0
            b[i + 1] += 1

    cnt = sum(b)
    for i in range(n):
        if a[i] > b[i]:
            b[i] += 10
            b[i + 1] -= 1
        cnt += b[i] - a[i]
    print(cnt)


if __name__ == '__main__':
    main()


Measured memory_bytes: 20464
#include <bits/stdc++.h>
#define rep(i, z, n) for(int64_t i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
//const int64_t INF = 1LL << 60;
//const int INF = 1 << 29;
//const int MODINF = 1000000007;
//const int64_t INF = 998244353;
using namespace std;
int main(){
    int K;
    cin >> K;
    string S;
    cin >> S;
    int x = S.size();
    if (x > K){
        S = S.substr(0, K) + "...";
    }
    cout << S << endl;
}

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

using ll=long long; 

void solve(){
	int n,m;
	cin>>n;
	vector<string>s(n);
	for(auto&ei:s)cin>>ei;
	cin>>m;
	vector<string>t(m);
	for(auto&ei:t)cin>>ei;
	int maxi=0;
	for(auto&ei:s){
		int cnt=0;
		for(auto&ej:s){
			if(ei==ej){
				cnt++;
			}
		}
		for(auto&ej:t){
			if(ei==ej){
				cnt--;
			}
		}
		maxi=max(maxi, cnt);
	}
	cout<<maxi<<endl;
}

signed main(){
	//while(1)
	solve();
}


Measured memory_bytes: 256
def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))

    mindex = a.index(1)

    min_t = 10000000
    for i in range(mindex-k+1, mindex+1):
        if i >= 0:
            t = 1 + (i+k-2) // (k-1) + (len(a)-(i+k-1)-1+k-2) // (k-1)
            min_t = min(t, min_t)

    print(min_t)


if __name__ == '__main__':
    main()


Measured memory_bytes: 14008
#include <stdio.h>

int main()
{
    int n,k,x,y,ans = 0;

    scanf("%d %d %d %d",&n,&k,&x,&y);

    if (n > k)
    {
        ans = k * x + (n - k) * y;
    }
    else
    {
        ans = n * x;
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

int main() {
    vector<int> A(5);
    int ans = 0;
    int r = 10;
    for (int i = 0; i < 5; i++) {
        cin >> A[i];
        if (A[i] % 10 != 0) {
            if (r > A[i] % 10) {
                r = A[i] % 10;
            }
            A[i] = (A[i] / 10 + 1) * 10;
        }
        ans += A[i];
    }
    cout << ans + r - 10 << endl;
}




Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int x=0,y=0,a=0,b=0,i=0;
	while(scanf("%d,%d",&x,&y)!=EOF){
		a=a+x*y;
		b=b+y;
		i++;
	}
	printf("%d\n%d\n",a,(b+1)/i);
return 0;
}

Measured memory_bytes: 592
#!/usr/bin/python3

def set_color(i, ci, e, color):
    color[i] = ci
    next_i = set(e[i])
    while len(next_i):
        s = next_i.pop()
        if color[s] != ci:
            color[s] = ci
            next_i.update(e[s])


n, m = map(int, input().split())

e = [set() for i in range(n)]
color = [None] * n

for i in range(m):
    s, t = map(int, input().split())
    e[s].add(t)
    e[t].add(s)

ci = 0
for i in range(n):
    if color[i] == None:
        set_color(i, ci, e, color)
        ci += 1

q = int(input())
for i in range(q):
    s, t = map(int, input().split())
    if color[s] == color[t]:
        print('yes')
    else:
        print('no')

Measured memory_bytes: 40564
# input
n = int(input())
A = list(map(int, input().split()))

ans1 = sum(A) // n + (sum(A) % n != 0)
ans2 = ans1 - 1

cost1 = 0
cost2 = 0

for i in range(n):
    cost1 += (A[i] - ans1) ** 2
    cost2 += (A[i] - ans2) ** 2

print(min(cost1, cost2))

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

int gcd(int a, int b);
int gcd(std::vector<int> a);

int main() {
	int n;

	std::cin >> n;

	std::vector<int> v(n);
	for (int& x : v) {
		std::cin >> x;
	}

	

	std::cout << gcd(v) << std::endl;

	return 0;
}

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


int gcd(std::vector<int> a) {
	int ans = a[0];
	for (int i = 0; i < a.size(); i++) {
		ans = gcd(ans, a[i]);
	}
	return ans;
}


Measured memory_bytes: 1024
import java.util.Scanner;

/*
 * Blake Miller
 * Longest Common Subsequence
 * AIZU 
 * 28 Sep 2018
 */
public class Main {
	static int lcs(String a, String b,int i, int j) {
		//based off yye lab instructions
		if (a.charAt(i) != b.charAt(j)) { //if not match
			if (i==0 && j==0) {
				return 0;
			}
			else if (i==0) {
				return(lcs(a,b,i, j-1));
			}
			else if (j==0) {
				return(lcs(a,b,i-1,j));
			}
			else if (i>0 && j>0) { //prevents out of bounds
				return (Math.max(lcs(a,b, i,j-1),
						lcs(a,b,i-1,j)));
			}
			else return 0;
		}
		else {
			if (i == 0 && j == 0) {
				return 1;
			}
			else if (i>0 && j>0) {
				return 1+(lcs(a,b,i-1,j-1));
			}
			else return 1;
		}
	}
	//Dynamic programming
	
	static int lcser(String a,String b) {
		int[][] d = new int[a.length()+1][b.length()+1]; //must be greater
		// the 1,1 position is the comparison between 0 of a and 0 of b
		for(int i=0; i<= a.length(); i++) {
			for (int j=0; j<= b.length(); j++) {
				d[i][j] = 0;
			}
		}
		for(int i=1; i <= a.length(); i++) {
			for(int j=1; j<=b.length(); j++) {
				if (a.charAt(i-1) != b.charAt(j-1)) {
					d[i][j] = Math.max(d[i-1][j], d[i][j-1]);
				}
				else {
					d[i][j] = 1 + d[i-1][j-1];
				}
			}
		}
		return d[a.length()][b.length()];
	}
	
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int inputs = in.nextInt();
		String a;
		String b;
		for (int i = 0; i < inputs; i++) {
			a = in.next();
			b = in.next();
			System.out.println(lcser(a,b));
		}
	}
}



Measured memory_bytes: 65260
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i[] = (s); i < (int)(n); i++)
using ll = long long;
using vec = vector<ll>;
using vec2 = vector<vector<ll>>;

int main()
{
    ll n;
    cin >> n;
    ll k;
    cin >> k;
    vec high(n, 0);
    rep(i, n)
    {
        cin >> high[i];
    }
    vec cost(n,10000000000);
    cost[0] = 0;

    for (int i = 0; i < n; i++)
    {
        for (int j = 1; j <= k && i + j < n; j++)
        {
            cost[i + j] = min(cost[i + j],abs(high[i + j] - high[i]) + cost[i]);
        }
    }
    cout << cost[n - 1] << endl;
}


Measured memory_bytes: 4636
#include<stdio.h>

int main(void){
    int data[9], n, b;
    for(int i = 0; i < 9; i++){
        scanf("%d", &data[i]);
    }
    scanf("%d", &n);
    for(int i = 0; i < n; i++){
        scanf("%d", &b);
        for(int j = 0; j < 9; j++){
            if(data[j] == b){
                data[j] = 0;
                break;
            }
        }
    }
    if(data[0] == 0){
        if( (data[1] == 0 && data[2] == 0) || (data[3] == 0 && data[6] == 0) || (data[4] == 0 && data[8] == 0)){
            printf("Yes\n");
            return 0;
        }
    }else if(data[4] == 0){
        if( (data[3] == 0 && data[5] == 0) || (data[1] == 0 && data[7] == 0)  || (data[2] == 0 && data[6] == 0 )){
            printf("Yes\n");
            return 0;
        }
    }else if(data[8] == 0){
        if( (data[7] == 0 && data[6] == 0) || (data[5] == 0 && data[2] == 0) ){
            printf("Yes\n");
            return 0;
        }
    }
    printf("No\n");
    return 0;
}


Measured memory_bytes: 128
<?php

$string = trim(fgets(STDIN));

$parts = explode(" ", $string);

$N = (int) $parts[0];

$begin = (int) $parts[1];

$end = (int) $parts[2];

$min = (int) $parts[3];

$max = (int) $parts[4];

$range_min = $begin;
$range_max = $begin;

for ($i = 0; $i < ($N - 1); $i++)
{


    if (($range_min + $range_max) / 2 >= $end)
    {

        //need to move down
        $range_min -= $max;
        $range_max -= $min;
    } else
    {

        //need to move up
        $range_min += $min;
        $range_max += $max;
    }
 //   echo $range_min . " <--> " . $range_max . "           (" . ($range_max -$range_min) .")\n";
}



if (($end >= $range_min) && ($end <= $range_max))
{
    echo "YES\n";
} else
{
    echo "NO\n";
}

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

vector<int> dp(100005,-1);
vector<vector<int>> g(100005);


int dfs(int t){
  if (dp[t]!=-1)return dp[t];
  dp[t]=0;
  for(int to:g[t]){
    dp[t]=max(dp[t],(dfs(to)+1));
  }
  return dp[t];

}

int main(){
  int n,m;
  cin>>n>>m;
  rep(i,m){
    int x1,y1;
    cin>>x1>>y1;
    x1--;y1--;
    g[x1].push_back(y1);
  }
rep(i,n)dfs(i);
int ans=0;
rep(i,n){
  ans=max(ans,dp[i]);
//  cout<<ans<<endl;
}
cout<<ans;

}


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

int main() {
  string s;
  cin>>s;
  for(int i=0;i<s.size();i++){
    if(s[i]=='?'){
      s[i]='D';
    }
      cout<<s[i];
  }
  cout<<endl;
}

Measured memory_bytes: 3724
sd = input()
t = input()
lsd = len(sd)
lt = len(t)
for i in range(lsd-lt,-1,-1):
  for j in range(lt):
    if sd[i+j] != "?" and sd[i+j] != t[j]:
      break
  else:
      print((sd[:i]+t+sd[i+lt:]).replace("?","a"))
      break
else:
  print("UNRESTORABLE")


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

using namespace std;
#define sz(x) (int)((x).size())
#define forn(i,n) for (int i=0; i < n; i++)
#define forse(i,s,e) for (int i=s; i < e; i++)
#define pb push_back
#define pf push_front
#define rb pop_back
#define rf pop_front
#define mp make_pair
#define fi first
#define se second
#define all(vec) vec.begin(), vec.end()
#define time() ((double)clock() / CLOCKS_PER_SEC)

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

double PI=3.141592653589793;

void solve(){
	double a,b,h,m;
	cin >> a >> b >> h >> m;
	double tem=abs(30*h-5.5*m);
	tem=min(tem,360-tem);
	cout << fixed << setprecision(12);
	cout << pow(a*a+b*b-2*a*b*cos(tem*PI/180),0.5);
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); 
	int T=1;
//	cin >> T;
	forn(c,T){
//		cout << "Case #" << c+1 << ": ";
		solve();
	}
}


Measured memory_bytes: 4372
import Data.Int
import Data.Ratio

main = do
  [n,m] <- map read.words<$>getLine
  as <- map read.lines<$>getContents
  print $ solve (Mod n) (map Mod as)

solve :: ModInt -> [ModInt] -> ModInt
solve n as = ans where
  (_,ans) = foldl f (0,1) stair
  f (pp, p) s = (p, s*(pp+p))
  stair = go 1 as where
    go s [] = replicate (fromEnum$n-s+1) 1
    go s (a:as)
      | s == a = 0 : go (s+1) as
      | otherwise = 1 : go (s+1) (a:as)
      
modulo = 10^9+7

newtype ModInt = Mod Int deriving (Eq)

instance Show ModInt where
  show (Mod a) = show a
instance Bounded ModInt where
  maxBound = Mod $ modulo - 1
  minBound = 0
-- Caution! If (value>=modulo), this does not work.
instance Enum ModInt where
  toEnum a = Mod $ mod a modulo
  fromEnum (Mod a) = a
instance Num ModInt where
  (Mod a) + (Mod b) = Mod $ mod (a+b) modulo
  (Mod a) * (Mod b) = Mod $ mod (a*b) modulo
  abs = id
  signum = const 1
  fromInteger a = Mod $ fromIntegral $ mod a $ fromIntegral modulo
  negate 0 = 0
  negate (Mod a) = Mod $ modulo - a
instance Fractional ModInt where
  recip a = a ^ (modulo-2)
  fromRational r = Mod (n * signum d) / Mod (abs d) where
    [n,d] = [fromIntegral] <*> ( [numerator,denominator] <*> [r] )


Measured memory_bytes: 11772
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;

class main{
    public static void Main(){
        int x = int.Parse(ReadLine());
        var nlist = new List<int>(Console.ReadLine().Split(' ').Select(int.Parse).ToArray());
        var minlist = new List<int>();
        int add;
        for(int i = nlist.Min();i<=nlist.Max();i++){
            add=0;
            foreach(var a in nlist){
                add += (a-i)*(a-i);
            }
            minlist.Add(add);
        }
        WriteLine(minlist.Min());
    }
}

Measured memory_bytes: 13396
def resolve():
  a, b = [int(item) for item in input().split()]
  
  ab = int(str(a) + str(b))
  
  i=1
  while i**2 <= ab:
    if i**2 == ab:
      print("Yes")
      return 
    i = i+1
  print("No")
resolve()

Measured memory_bytes: 3060
#include<cstdio>
#include<queue>
#include<iostream>
#include<cstring>
using namespace std;
int H,W,N;
char map[1001][1001];
int visit[1001][1001];
struct node{
	int x,y,ph,time;
}s;
void bfs(){
	queue<node>q;
	while(!q.empty())q.pop();
	q.push(s);
	int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
	while(!q.empty()){
		node ne=q.front();q.pop();
		for(int i=0;i<4;i++){
			node no;
			no.x=ne.x+dx[i];
			no.y=ne.y+dy[i];
			no.time=ne.time;
			no.ph=ne.ph;
			if(no.x>=0&&no.x<H&&no.y>=0&&no.y<W&&map[no.x][no.y]!='X'){
				no.time++;
				//printf("map[%d][%d],time=%d\n",no.x,no.y,no.time);				
				if((int)map[no.x][no.y]==s.ph+48){
					s.x=no.x;
					s.y=no.y;
					s.ph++;
					s.time=no.time;
					return ;					
				}
				if(map[no.x][no.y]=='.'){
					map[no.x][no.y]='X';
					visit[no.x][no.y]=1;
				}
				q.push(no);
			}
		}
	}
}
int main(void){
	while(scanf("%d",&H)!=EOF&&scanf("%d%d",&W,&N)){
		for(int i=0;i<H;i++)
		for(int j=0;j<W;j++){
			cin>>map[i][j];
			if(map[i][j]=='S'){
				s.x=i,s.y=j,s.ph=1,s.time=0;
			}
		}
		for(int i=0;i<N;i++){
			memset(visit,0,sizeof(visit));
			bfs();
				for(int i=0;i<H;i++)
				for(int j=0;j<W;j++)
				if(visit[i][j])map[i][j]='.';	
		}
		printf("%d\n",s.time);
	}
}

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

int solve(int x, int k)
{
    if(x % k == 0)
        return x / k;
    
    int num = x % k;
    int den = (x + k - 1) / k;

    int a = (num + den - 1) / den;

    return solve(x - den * a, k);
}

int main() {

    ios::sync_with_stdio(0);
    cin.tie(NULL), cout.tie(NULL);

    int N;
    cin >> N;

    int ans = 0;

    while(N--)
    {
        int x, k;
        cin >> x >> k;

        ans ^= solve(x, k);
    }

    if(ans)
        cout << "Takahashi\n";
    else
        cout << "Aoki\n";

    return 0;
}


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


int main()
{
    ll n;
    while(cin>>n)
    {
        ll a=100;
        int i;
        for(i=0;a<n;i++)
        {
            a*=1.01;
        }

        cout<<i<<endl;
    }
    return 0;
}


Measured memory_bytes: 3636
time=[]
a,b=map(int,input().split())
N=int(input())
for i in range(N):
  s,f=map(int,input().split())
  for i in range(s,f):
    time.append(i)
#print(time)
for i in range(a,b):
  #print(i)
  if i in time:
    print(1)
    break
  elif i==b-1:
    print(0)


Measured memory_bytes: 5608
#include "bits/stdc++.h"
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << endl

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  int n;
  cin>>n;
  int m;
  cin>>m;

  vector<int>h(n+1);
  vector<bool>isgood(n+1,true);
  for(int i=1;i<=n;i++)cin>>h[i];

  for(int i=0;i<m;i++){
    int a,b;
    cin>>a>>b;
    if(h[a]==h[b]){
      isgood[a]=false;
      isgood[b]=false;
    }
    else if(h[a]>h[b])
      isgood[b]=false;

  else  isgood[a]=false;

  }

  int ans=0;

  for(int i=1;i<=n;i++){
    if(isgood[i])
    ans++;
  }
  cout<<ans<<endl;


     
  return 0;
}


Measured memory_bytes: 3644
while True:
    
    n, x = map(int, input().split())
    if n == 0 and x == 0:
        break
    c = 0
    for i in range(1,n+1):
        for y in range(i+1,n+1):
            for z in range(y+1,n+1):
                if i+y+z == x:
                    c += 1
        
    print (c)


Measured memory_bytes: 5596
using System;
class Program
{
    public static void Main()
    {
        
        int[] line = Array.ConvertAll(System.Console.ReadLine().Split(' '),int.Parse);
        int W = line[0];
        int H = line[1];
        int x = line[2];
        int y = line[3];
        int r = line[4];
        
        string rlt;
        
        if ( 0 <= x - r && x + r <= W && 0 <= y - r && y + r <= H)
            rlt = "Yes";
        else
            rlt = "No";
            
        System.Console.WriteLine("{0}",rlt);
    } 
}




Measured memory_bytes: 19988
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (int64_t)(n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

#define chmax(a, b) (a) = max(a, b)
#define chmin(a, b) (a) = min(a, b)

int main() {
  int K, S;
  cin >> K >> S;

  int cnt = 0;
  irep(x, min(K, S)) irep(y, min(K, S - (int)x)) {
    int z = S - x - y;
    if (z >= 0 && z <= K) {
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 3532
#include <cmath>
#include <ctime>
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <bitset>
#include <functional>
#include <numeric>
#include <utility>
#include <iomanip>
#include <cstdio>
#include <cctype>
#include <queue>
#include <complex>
#include <climits>

typedef long long ll;

using namespace std;

int a[100010] = {0};

int main(void){
	int N, L, num = 0;
	ll sum = 0, Max = 0;
	cin >> N >> L;

	cin >> a[1];
	for(int i=1; i<=N; ++i){
		if(i < N) cin >> a[i+1];
		num++;
		sum += a[i];
		if((a[i]-a[i-1] < 0 && a[i+1]-a[i] >= 0) || (a[i]-a[i-1] > 0 && a[i+1]-a[i] <= 0) || i == N){
			Max = max(Max, (ll)num*L - sum);
			num = 1;
			sum = a[i];
		}
	}

	cout << Max << endl;

	return 0;
}

Measured memory_bytes: 1544
#include<bits/stdc++.h>
using namespace std;
#define PB push_back
#define ll long long
const int mod=1e9+7;

int main(){
#ifndef ONLINE_JUDGE
	freopen("C:\\Users\\User\\Documents\\input.txt","r",stdin);
#endif
	int T,i,j;
	int n,m;
	cin>>n>>m;
	string s[n];

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

	vector<vector<int> > dp(n,vector<int>(m) );

	dp[0][0]=1;
	int dr[]={0,1};
	int dc[]={1,0};

	for(i=0;i<n;i++){
		for(j=0;j<m;++j){
		    if(s[i][j]=='#') continue;
		    for(int k=0;k<2;k++){
		    	int r=dr[k]+i,c=dc[k]+j;
		    	if(r<n && c<m) dp[r][c]=(dp[r][c]+dp[i][j])%mod;
		    }
		}
	}
	printf("%d\n",dp[n-1][m-1]);


	return 0;
}

Measured memory_bytes: 9520
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# 問題：https://atcoder.jp/contests/abc128/tasks/abc128_d

n, k = map(int, input().strip().split())
value = list(map(int, input().strip().split()))
res = 0
for l in range(k+1):
    for r in range(k-l+1):
        if l + r > n:
            continue
        d = k - l - r
        now = 0
        s = []
        for i in range(l):
            now += value[i]
            s.append(value[i])
        for i in range(r):
            now += value[n-i-1]
            s.append(value[n-i-1])
        s.sort()
        for i in range(d):
            if i >= len(s):
                break
            if s[i] > 0:
                break
            now -= s[i]
        res = max(res, now)

print(res)



Measured memory_bytes: 9220
ans = 0
to = []

def main():
    global to
    n, m = map(int, input().split())
    to = [[] for i in range(n)]
    for i in range(m):
        a, b = map(int, input().split())
        a, b = a - 1, b - 1
        to[a].append(b)
        to[b].append(a)
    #print(f'{to = }')
    solve(n, m)
    print(ans)

def dfs(pos, arrived):

    global ans

    #print(f'{pos = }')
    ##print(f'{to[pos] = }')

    arrived[pos] = True

    #全部到達した
    if all(arrived):
        #print('arrived')
        ans += 1
        return

    for nt in to[pos]:
        if arrived[nt] == False:
            dfs(nt, [i for i in arrived])

def solve(n, m):
    arrived = [False for i in range(n)]
    dfs(0, arrived)
    return


if __name__ == '__main__':
    main()

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

mt19937 rnd;
uniform_real_distribution<> dist01(0.0, 1.0);
double rnd01(){ return dist01(rnd);}

const double TIME_LIMIT = 1950;
double elapsed;
chrono::system_clock::time_point t_start;
void update_time(){
    auto t_now = chrono::system_clock::now();
    elapsed = chrono::duration_cast<chrono::milliseconds>(t_now - t_start).count();
}
bool timeover(){ return (elapsed > TIME_LIMIT);}

const int D = 365, T = 26;
int C[T], S[D][T];
int CS[D+2][T];

set<int> st[T];

int ans[D];
int opt = -1e9;

int calc_score(){
    int last[T];
    for(int i=0; i<T; i++) last[i] = -1;
    int res = 0;
    for(int i=0; i<D; i++){
        res += S[i][ans[i]];
        last[ans[i]] = i;
        for(int j=0; j<T; j++) res -= C[j] * (i-last[j]);
    }
    return res;
}

int calc_diff(int t, int bef, int aft){
    int res = opt + S[t][aft] - S[t][bef];
    {
        auto it = st[bef].lower_bound(t);
        int d1 = *next(it) - t, d2 = t - *prev(it);
        res -= CS[d1+d2][bef] - CS[d1][bef] - CS[d2][bef];
        st[bef].erase(it);
    }
    {
        st[aft].insert(t);
        auto it = st[aft].lower_bound(t);
        int d1 = *next(it) - t, d2 = t - *prev(it);
        res += CS[d1+d2][aft] - CS[d1][aft] - CS[d2][aft];
    }
    return res;
}

void try_update(){
    // pick random & update
    int t = rnd() % D;
    int bef = ans[t], aft = rnd() % T;
    ans[t] = aft;

    // calculate
    int score = calc_diff(t, bef, aft);
    const int T = 4000;
    double temp = T * (1 - elapsed/TIME_LIMIT);
    double prob = exp((score - opt) / temp);
    if(rnd01() < prob){
        opt = score;
    }else{
        // rollback
        ans[t] = bef;
        st[aft].erase(t);
        st[bef].insert(t);
    }
}

int main(){
    t_start = chrono::system_clock::now();
    // get input & initialize
    int _; cin >> _;
    for(int j=0; j<T; j++) cin >> C[j];
    for(int i=0; i<D; i++) for(int j=0; j<T; j++) cin >> S[i][j];
    for(int i=0; i<=D+1; i++) for(int j=0; j<T; j++) CS[i][j] = i*(i-1)/2*C[j];

    for(int i=0; i<D; i++) for(int j=0; j<T; j++) if(S[i][ans[i]] < S[i][j]) ans[i] = j;
    opt = calc_score();
    cerr << "before score: " << opt << endl;
    for(int i=0; i<D; i++) st[ans[i]].insert(i);
    for(int j=0; j<T; j++){
        st[j].insert(-1);
        st[j].insert(D);
    }

    // iterate
    int iter = 0;
    while(!timeover()){
        iter++;
        try_update();
        if(iter % 1000 == 0) update_time();
    }

    // output result
    for(int i=0; i<D; i++) cout << ans[i]+1 << endl;


    // output debug
    cerr << "score: " << opt << endl;
    cerr << "iter: " << iter << endl;
    update_time();
    cerr << "elapsed: " << elapsed << endl;
    return 0;
}


Measured memory_bytes: 4548
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
 
using namespace std;
 
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define forab(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ford(i, n) for (int i = int(n) - 1; i >= 0; --i)
#define sz(c) int((c).size())
#define all(c) (c).begin(), (c).end()
#define mp(x, y) make_pair(x, y)
#define pb push_back
#define fst first
#define snd second
 
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;
using vvi = vector<vi>;
using vii = vector<pii>;

#ifdef LOCAL
#define eprintf(args...) fprintf(stderr, args), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define FILE_NAME "a"
 
string s;
 
bool read() {
    if (!(cin >> s)) {
        return 0;
    }
    return 1;
}
 
string solve() {
     for (char ch = 'a'; ch <= 'z'; ch++)
     {
         if (!count(all(s), ch))
             return s + ch;
     }

     ford (k, sz(s) - 1)
     {
         set<char> can;
         for (char ch = 'a'; ch <= 'z'; ch++)
             can.insert(ch);

         forn (i, k)
             can.erase(s[i]);

         if (s[k] == *can.rbegin())
            continue;

         s[k] = *can.upper_bound(s[k]);
         s.resize(k + 1);
         return s;
     }

     return "-1";
}
 
int main() {
#ifdef LOCAL
    freopen(FILE_NAME ".in", "r", stdin);
    freopen(FILE_NAME ".out", "w", stdout);
#endif

    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
 
    while (read()) {
        string ans = solve();
        cout << ans << endl;
    }
 
    return 0;
}


Measured memory_bytes: 256
L,R = list(map(int,input().split()))
if R-L >= 2019:
    print(0)
    exit()
MIN = float('inf')
for i in range(L,R+1):
    for j in range(L,R+1):
        if i == j: continue
        MIN = min(MIN,(i*j)%2019)
print(MIN)

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

typedef struct
{
	// direction
	// if 0 then go left
	// el 1 then go right
	int d;
	// position
	double p;
	// in
	// hool
	// if h is true then ant in hool
	// el h is false then ant go out
	bool h;
} ant;

	int
main (void)
{
	while (1)
	{
		int n, l;
		cin >> n >> l;
		if (n == 0)
			break;
		ant a[n];
		for (int i = 0; i < n; i++)
		{
			char d;
			cin >> d >> a[i].p;
			if (d == 'L')
				a[i].d = 0;
			else
				a[i].d = 1;
			a[i].h = true;
		}

		int ants = n;
		bool flag = false;

		for (int t = 1; ; t++)
		{
			// ありの動きを更新
			for (int i = 0; i < n; i++)
			{
				// left
				if (!a[i].d)
					a[i].p -= 1;
				// right
				else
					a[i].p += 1;
			}
			// 出て行ったやつの更新
			for (int i = 0; i < n; i++)
			{
				if (a[i].h)
				{
					// 左から
					if (a[i].p < 0)
					{
						a[i].h = false;
						ants--;
					}
					// 右から
					else if (l < a[i].p) 
					{
						a[i].h = false;
						ants--;
					}
				}
			}

			// ぶつかった時
			for (int i = 0; i < n; i++)
			{
				for (int j = i+1; j < n; j++)
				{
					if (a[i].p == a[j].p)
					{
						if (a[i].d)
						{
							a[i].d = 0;
							a[j].d = 1;
						}
						else
						{
							a[i].d = 1;
							a[j].d = 0;
						}
					}
				}
			}
			// DEBUG
			{
#ifdef D
				cout << "time:" << t << endl;
				cout << "ants:" << ants << endl;
				for (int i = 0; i < n; i++)
				{
					cout << i << endl;
					cout << " " << "d:" << a[i].d << endl;
					cout << " " << "p:" << a[i].p << endl;
					cout << " " << "h:" << a[i].h << endl;
				}
				cout << endl;
				cout << "------------------"<< endl;
#endif
			}
			if (ants == 2)
			{
				int start, end;
				start = end = -1;
				for (int i = 0; i < n; i++)
				{
					if (a[i].h)
					{
						if (a[i].p == 0)
						{
							start = i;
						}
						if (a[i].p == l)
						{
							end = i;
						}
					}
				}
				if (-1 < start && -1 < end)
				{
					cout << t << " " << start + 1 << endl;
					flag = true;
				}
				/*
				else if (end)
				{
					cout << t << " " << end + 1 << endl;
					flag = true;
				}
				*/

			}
			else if (ants == 1)
			{
				for (int i = 0; i < n; i++)
					if (a[i].h)
					{
						if (a[i].p == 0 || a[i].p == l)
						{
							cout << t << " " << i + 1 << endl;
							flag = true;
						}
					}
			}
			if (flag)
				break;
		}
	}
	return 0;
}



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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"
*/

const ll INF = pow(10, 10);
int cnt = 0;

void merge(vector<ll> &A, int left, int mid, int right){
    int n1 = mid - left;
    int n2 = right - mid;
    ll L[n1 + 1], R[n2 + 1];
    rep(i, n1) L[i] = A[left + i];
    rep(i, n2) R[i] = A[mid + i];
    L[n1] = INF; R[n2] = INF;
    int i=0, j=0;   // 比較のためにそれぞれの次元引数を初期化
    for(int k=left; k<right; k++){
        cnt += 1;
        if(L[i] <= R[j]){
            A[k] = L[i];
            i += 1;
        }else{
            A[k] = R[j];
            j += 1;
        }
    }
}

void mergeSort(vector<ll> &A, int left, int right){
    if(left+1 < right){
        int mid = (left+right) / 2;
        mergeSort(A, left, mid);
        mergeSort(A, mid, right);
        merge(A, left, mid, right);
    }
}

int main()
{
    int n; cin >> n;
    vector<ll> A(n);
    rep(i, n){
        ll Ai; cin >> Ai;
        A[i] = Ai;
    }
    mergeSort(A, 0, n);
    rep(i, n){
        cout << A[i];
        if(i != n-1) cout << " ";
    }
    cout << endl;
    cout << cnt << endl;
}


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

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#else
#define debug(x)
#endif

#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = ((a)-1); i >= (b); i--)
#define pb push_back
#define sz(a) int((a).size())

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;

static constexpr ll LL_INF = 1LL << 60;
static constexpr int I_INF = 1 << 28;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);

int main(int argc, char* argv[]) {
  std::string S;
  std::cin >> S;
  S += 'R';

  char search = 'L';
  int cur_pos = 0;

  vector<ll> ans(sz(S));
  rep(i, 0, sz(S)) {
    if (search != S[i]) continue;
    if (S[i] == 'L') {
      int diff = 1;
      rrep(j, i, cur_pos) {
        ans[i - diff]++;
        diff ^= 1;
      }
    }

    if (S[i] == 'R') {
      int diff = 0;
      rep(j, cur_pos, i) {
        ans[cur_pos - diff]++;
        diff ^= 1;
      }
    }
    cur_pos = i;
    search = (search == 'L' ? 'R' : 'L');
  }

  string s;
  ans.pop_back();
  for (ll val : ans) {
    s += to_string(val) + " ";
  }

  s.pop_back();
  cout << s << endl;
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

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

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

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}


Measured memory_bytes: 1728
// Radewoosh's solution
#include <bits/stdc++.h>
#define ll long long
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define endl "\n"
#define mod 1000000007

using namespace std;

int main()
{
	int n;
	vector<int> v,v1,v2;
	cin>>n;
	for(int y=0;y<n;y++)
	{
		int j;
		cin>>j;
		v1.push_back(j);
	}
	for(int y=0;y<n;y++)
	{
		int j;
		cin>>j;
		v2.push_back(j);
	}
	for(int y=0;y<n;y++)
	{
		v.push_back(v1[y]-v2[y]);
	}
	sort(v.begin(),v.end());
	int ans=0;
	for(int y=0;y<n;y++)
	{
		int temp=0;
		temp=max(0,v[y]);
		ans+=temp;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n, k, x, y;
char c;
int s[4020][4020];
int S(int x, int y) {
	return s[x][y] - s[x][y - k] - s[x - k][y] + s[x - k][y - k];
}
int main() {
	scanf("%d%d", &n, &k);
	for (int i = 0; i < n; i++) {
		scanf("%d%d %c", &x, &y, &c);
		x %= 2 * k;
		y %= 2 * k;
		if (c == 'W') {
			x += k;
			x %= 2 * k;
		}
		x++;
		y++;
		s[x][y]++;
		s[x][y + 2 * k]++;
		s[x + 2 * k][y]++;
		s[x + 2 * k][y + 2 * k]++;
	}
	for (int i = 0; i < 4 * k; i++) {
		for (int j = 0; j < 4 * k; j++) {
			s[i + 1][j + 1] += s[i + 1][j] + s[i][j + 1] - s[i][j];
		}
	}
	int z = 0;
	for (int i = 2 * k; i <= 4 * k; i++) {
		for (int j = 2 * k; j <= 4 * k; j++) {
			z = max(z, S(i, j) + S(i - k, j - k));
		}
	}
	printf("%d\n", z);
	return 0;
}

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



namespace Test1 {

    class ClassMain {

        static int[] cheapestTable = new int[51];
        public static void Main(String[] args) {
            int amount;
            while ((amount=int.Parse(Console.ReadLine()))!=0) {
                initTable();
                int cheapest = cheapestTable[amount/100];
                
                Console.WriteLine(cheapest);                
            }
        }

        private static void initTable() {
            cheapestTable[0] = 0;
            cheapestTable[1] = 999999;
            cheapestTable[2] = 380;
            cheapestTable[3] = 550;
            cheapestTable[4] = 380 * 2;
            cheapestTable[5] = 850;
            for (int i = 6; i <= 9; i++) {
                cheapestTable[i] = Math.Min(380 + cheapestTable[i - 2], Math.Min(550 + cheapestTable[i - 3], 850 + cheapestTable[i - 5]));
            }
            cheapestTable[10] = 1520;
            cheapestTable[11] = Math.Min(380 + cheapestTable[9], Math.Min(550 + cheapestTable[8], 850 + cheapestTable[6])); 
            cheapestTable[12] = 1870;
            cheapestTable[13] = Math.Min(1520+550,Math.Min(380 + cheapestTable[11], Math.Min(550 + cheapestTable[10], 850 + cheapestTable[8])));
            cheapestTable[14] = Math.Min(1870+380,Math.Min(1520 + cheapestTable[4], Math.Min(380 + cheapestTable[12], Math.Min(550 + cheapestTable[11], 850 + cheapestTable[9]))));
            cheapestTable[15] = 2244;
            for (int i = 16; i <= 50; i++) {
                cheapestTable[i] = Math.Min(2244 + cheapestTable[i-15], 
                    Math.Min(1870 + cheapestTable[i-12], 
                    Math.Min(1520 + cheapestTable[i-10],
                    Math.Min(380 + cheapestTable[i-2], 
                    Math.Min(550 + cheapestTable[i-3], 
                    850 + cheapestTable[i-5])))));
            }

        }
        
    }
}

Measured memory_bytes: 5608
#include<stdio.h>

#define MAX 100

int main(){
  int i,flag,n,count,A[MAX + 1];

  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&A[i]);

  count = 0;
  flag = 1;

  while(flag){
    flag = 0;
    for(i=n-1;i>=0;i--){
      if(A[i] < A[i - 1]){
	A[n] = A[i];
	A[i] = A[i - 1];
	A[i - 1] = A[n];
	count++;
	flag = 1;
      }
    
    }

  }
  for(i=0;i<n;i++){
    if(i < n - 1)printf("%d ",A[i]);
    else printf("%d\n%d\n",A[i],count);
  }

  return 0;
}

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

using namespace std;

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

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

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

#define MP make_pair
#define EACH(i,c) for(auto i: c)
#define SORT(c) sort((c).begin(),(c).end())

#define ALL(a)  (a).begin(),(a).end()

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	LL N;
	cin >> N;

	LL ret = 0;
	LL a = sqrt(N);
	FOR(i, 1, a + 1){
		LL tmp = (N - i) / i;
		if(tmp && N / tmp == N % tmp)
		ret += tmp;
		// if(ret == 2499686339916LL)
		// cerr << i << endl;
	}

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String S = sc.next();
        int cnt = 0;
        int max = 0;
        for(int i = 0; i < N; i++){
            char c = S.charAt(i);
            if(c == 'I'){
                cnt++;
                max = Math.max(max,cnt);
            }else{
                cnt--;
            }
        }
        System.out.println(max);
    }
}

Measured memory_bytes: 21844
N = int(input())
S = input()

num_of_white = 0
num_of_black = 0

for i in range(1, N):
  if S[i] == '.':
    num_of_white += 1

result = num_of_white

for i in range(1, N):
  if S[i-1] == '#':
    num_of_black += 1
  if S[i] == '.':
    num_of_white -= 1
  
  if result > (num_of_black + num_of_white):
    result = num_of_black + num_of_white

print(result)


Measured memory_bytes: 3500
#include <iostream>
#include <string>

using namespace std;

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

	string S;
	cin >> S;
	int ans=700;
	if(S[0] == 'o') ans += 100;
	if(S[1] == 'o') ans += 100;
	if(S[2] == 'o') ans += 100;
	cout << ans;
}


Measured memory_bytes: 256
// #pragma GCC optimize ("O3")
// #pragma GCC target ("sse4")

#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 29;
const int NINF = -1*INF;
const long long LLINF = 1ll << 60;
const long long LLNINF = -1*LLINF;

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
	return os << "[ " << p.first << ", " << p.second << "]" ;
}

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<ld> vld;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
typedef vector<vector<int>> vvi;
typedef vector<vll> vvll;
typedef vector<vd> vvd;
typedef vector<vld> vvld;
 
#define mp make_pair
#define pb push_back
#define pf push_front
#define all(x) x.begin(), x.end()
#define revAll(x) x.rbegin(), x.rend()
#define gcd(a, b) __gcd(a, b)
#define popcount(x) __builtin_popcount(x)
#define isize(x) (int)(x.size())
#define rep(i,n) for(int i = 0; i < n; i++)
#define umap unordered_map
#define uset unordered_set
#define pq priority_queue

const ll MOD = 1e9 + 7;

struct Point {
	ll x, y;
	Point(ll xval, ll yval):x(xval), y(yval){};
};

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);
	int n; cin >> n;
	vector<Point> pts = vector<Point>();
	rep(i, n) {
		int x, y; cin >> x >> y;
		pts.pb(Point(x, y));
	}
	ll ans = 0;
	auto cmp = [](Point a, Point b) {
		return (a.x + a.y) <= (b.x + b.y);
	};
	auto cmp2 = [](Point a, Point b) {
		return (a.x - a.y) <= (b.x - b.y);
	};
	Point minA = *min_element(all(pts), cmp);
	Point maxA = *max_element(all(pts), cmp);
	ans = max(ans, abs(maxA.x - minA.x) + abs(maxA.y - minA.y));

	Point minB = *min_element(all(pts), cmp2);
	Point maxB = *max_element(all(pts), cmp2);
	ans = max(ans, abs(maxB.x - minB.x) + abs(maxB.y - minB.y));
	cout << ans;
}

Measured memory_bytes: 7432
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
    long long a=1;
    long long b=1e9+7;
    int sum;
    cin>>sum;
    for(int i=1;i<=sum;i++)
    {
        a*=i;
        a%=b;
    }
    cout<<a;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
   int n;
   cin>>n;
   vector<int> g[n];
   for(int i=0;i<n;i++){
       int a,b,c;
       cin>>a>>b>>c;
       g[i]={a,b,c};
   }
   vector<vector<int>> ans(n,vector<int> (3,0));
   for(int i=0;i<3;i++){
       ans[0][i]=g[0][i];
   }
   for(int i=1;i<n;i++){
       ans[i][0]=g[i][0]+max(ans[i-1][1],ans[i-1][2]);
       ans[i][1]=g[i][1]+max(ans[i-1][0],ans[i-1][2]);
       ans[i][2]=g[i][2]+max(ans[i-1][1],ans[i-1][0]);
   }
   cout<<max(ans[n-1][0],max(ans[n-1][1],ans[n-1][2]));
}


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

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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

//INT_MAX	2,147,483,647 = 2*1.0e9

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

    int ans = 1;
    for(int i = 2; i * i <=X; i++){
        int j = i;
        while(j * i <= X) j*=i;
        ans = max(ans, j);
    }

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


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:https://agc002.contest.atcoder.jp/tasks/agc002_b>
問題文============================================================
 N 個の箱があります。 箱は 1 から N まで番号が振られています。
 最初、1 番目の箱には赤いボールが 1 個入っています。
 また、2～N 番目の箱には白いボールが 1 個ずつ入っています。
 
 高橋君は M 回の操作を順に行います。
 i 回目の操作では、xi 番目の箱から適当なボールを 1 個選び、それを yi 番目の箱へ移します。
 
 高橋君がすべての操作を終えた後、赤いボールが入っている可能性のある箱は何個か求めてください。
=================================================================

解説=============================================================

 単純に、箱に等しい数の配列を持っておき、その配列に{箱に入っているボールの数、赤いボールが入っている可能性があるか}
 で情報を持てば良い
 赤いボールが入っている可能性に関しては、その可能性がある箱からボールを移すときはその可能性を必ず移行し、
 箱に入っているボールの数が０の時に可能性が０となる
 
================================================================
*/
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    ll N,M; cin >> N >> M;
    vector<pll> B(N,pll(1,0));
    B[0].second = 1;
    for(int i = 0; i < M;i++){
        ll x,y; cin >> x >> y;
        x--; y--;
        if(B[x].second == 1){
            B[y].second = 1;
        }
        B[y].first++;
        B[x].first--;
        if(B[x].first == 0) B[x].second = 0;
    }
    ll ans = 0;
    for(int i = 0; i < N;i++) ans += B[i].second;
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <string>
#include<vector>

using namespace std;

int main() {
    int n, c = 0, A = 0, B = 0;
    cin >> n;
    int a[105];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        c += a[i];
    }
    sort(a, a + n);
    for (int i = 0; i < n; i+=2) {
        if (n % 2 == 1)A += a[i];
        else B += a[i];
    }
    if (n % 2 == 1) {
        B = c - A;
        cout << A - B << endl;
    }
    else {
        A = c - B;
        cout << A - B << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


int main() {
ll a,b,ans;
cin >> a >> b;
for(int i=1;i<=b;i++) {
  if(i*a%b==0) {
    ans = i*a;
    break;
  }
}
cout << ans << endl;
return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long LL;
typedef pair<int, int> PI;
typedef vector<int> VI;
VI G[100000];
int par[100000];
int cnt[100000];
bool vis[100000];
int build(int x,int p) {
	vis[x] = 1;
	par[x] = p;
	rep(i, G[x].size()) {
		if (!vis[G[x][i]]) cnt[x] += build(G[x][i], x);
	}
	return cnt[x] + 1;
}
int main() {
	int N;
	cin >> N;
	rep(i, N-1) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	build(0, -1);
	int cur = N - 1, L = 0;
	while (cur != 0) {
		cur = par[cur];
		L++;
	}
	cur = N - 1;
	rep(i, (L - 1) / 2) {
		cur = par[cur];
	}
	if ((N - 2) <= 2 * cnt[cur]) {
		cout << "Snuke" << endl;
	}
	else {
		cout << "Fennec" << endl;
	}
}

Measured memory_bytes: 11264
// 2012/08/08 Tazoe

#include <iostream>
using namespace std;

void conv(int n, int p)
{
	if(p==0)
		return;

	conv(n/2, p-1);

	if(p==9){
		cout << '.';
	}
	cout << n%2;
}

int main()
{
	while(true){
		double n;
		cin >> n;

		if(n<0.0)
			break;

		int n16 = (int)(n*16.0);
		if(n*16.0!=(double)n16||n16>=4096){
			cout << "NA" << endl;
			continue;
		}

		conv(n16, 12);
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 0