akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

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

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

int main()
{
    int n, m;
    std::cin >> n >> m;
    
    std::vector<int> min_t(n, (1 << 29));
    for (int i = 0; i < m; i++) {
        int a;
        std::cin >> a;
        min_t[a - 1] = 0;
    }

    for (int i = 1; i < n; i++) {
        min_t[i] = std::min(min_t[i], min_t[i - 1] + 1);
    }

    for (int i = n - 2; i >= 0; i--) {
        min_t[i] = std::min(min_t[i], min_t[i + 1] + 1);
    }

    int ret = 0;
    for (int t : min_t) {
        ret = std::max(ret, t);
    }

    std::cout << ret << std::endl;
    
    return 0;
}

Measured memory_bytes: 3180
import sys
import numpy as np
import heapq as hp
from numba import njit

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

@njit('i8[:],i8[:],i8', cache=True)
def compute(A, B, X):
    """左からn番の人まで。AからX人とる。ときの最大スコアを返す。"""
    result = np.zeros(len(A), np.int64)
    result[X - 1] = A[:X].sum()
    q = []
    for i in range(X):
        q.append(A[i] - B[i])
    hp.heapify(q)
    for i in range(X, len(A)):
        x = result[i - 1] + A[i]  # とりあえず A をとる
        loss = hp.heappushpop(q, A[i] - B[i])  # ひとつ B に取り換えたときのロス
        result[i] = x - loss
    return result

@njit('(i8[:],i8,i8,i8)', cache=True)
def main(ABC, X, Y, Z):
    A = ABC[::3]
    B = ABC[1::3]
    C = ABC[2::3]
    ind = np.argsort(C - A)
    A, B, C = A[ind], B[ind], C[ind]
    q = [0] * 0

    q = [0] * 0
    dp1 = compute(A, B, X)
    dp2 = compute(C[::-1], B[::-1], Z)[::-1]
    x = dp1[X - 1:X + Y] + dp2[X:X + Y + 1]
    return x.max()

X, Y, Z = map(int, readline().split())
ABC = np.array(read().split(), np.int64)

print(main(ABC, X, Y, Z))

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

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i,n) {
		cin >> a[i];
	}
	sort(a.begin(),a.end(),greater<int>());
	int sum_a = 0;
	int sum_b = 0;
	for(int i = 0; i < n; i += 2) {
		sum_a += a[i];
		sum_b += a[i + 1];
	}
	int ans = sum_a - sum_b;
	cout << ans << endl;
}



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;
using P = pair<int, int>;
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(x) x.begin(),x.end()
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

int a,b,h,m;
double solve(){
   double ans=0;
   double angleH=h*M_PI/6+((double)M_PI/6)*((double)m/60);
   double angleM=m*M_PI/30;
   //cout<<angleH<<endl;
   //cout<<angleM<<endl;
   //cout<<(M_PI/6)*(m/60)<<endl;
   double diff=angleH-angleM;
   //cout<<diff<<endl;
   if(diff<0)diff=-diff;
   if(diff>M_PI)diff=2*M_PI-diff;
   // cout<<diff<<endl;
   // cout<<cos(diff)<<endl;
   ans=a*a+b*b-2*a*b*cos(diff);
  // cout<<ans<<endl;
   ans=sqrt(ans);
   return ans;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin>>a>>b>>h>>m;
    cout<<setprecision(15)<<solve()<<endl;
    return 0;
}

Measured memory_bytes: 4244
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <climits>
#include <vector>
#include <numeric>
#include <complex>
#include <map>
#include <bitset>
#include <stack>
#include <queue>
#include <set>
using namespace std;
    
#define __int64 long long
#define long __int64
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
const int Vec = 4;
const int Vecy[Vec] = {0,-1,0,1};
const int Vecx[Vec] = {1,0,-1,0};
const int Modd = 1000000007;


int main(){
    int x,a;
    cin >> x >> a;
    if(x < a){
        cout << 0 << endl;
    }else{
        cout << 10 << endl;
    }
}

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

using namespace std;

typedef long long ll;

int main()
{
    int n;

    cin >> n;

    if(n % 1000 == 0)
    {
        cout << 0 << endl;
    }
    else
    {
        int t = n / 1000;

        cout << (t + 1) * 1000 - n << endl;
    }

    return 0;
}


Measured memory_bytes: 3620
#include <stdio.h>

int main(void){
    int i;
    int count[2][4]={0};
    double eye[2]={0};
    while(scanf("%lf %lf",&eye[0],&eye[1])!=EOF){
        for(i=0;i<2;i++){
            if(eye[i]>=0.6){
                if(eye[i]>=1.1){
                    count[i][0]++;
                }
                else{
                    count[i][1]++;
                }
            }
            else{
                if(eye[i]<0.2){
                    count[i][3]++;
                }
                else{
                    count[i][2]++;
                }
            }
        }
    }
    for(i=0;i<4;i++){
        printf("%d %d\n",count[0][i],count[1][i]);
    }
    return 0;
}

Measured memory_bytes: 628
using System;
using static System.Console;
using static System.Math;

public class Hello{
    public static void Main(){
    string a = rstr();
    string b = rstr();
    string ans = "Yes";
    
    while(a.Length > 0){
        
        if(a.Length != b.Length){
            ans = "No";
            break;
        }
        
        for(int i=1;i<a.Length;i++){
            
            if(a[i] == a[0]){
                if(b[i] != b[0]){
                    ans = "No";
                    break;
                }
            }
            
        }

        a = a.Replace(a[0].ToString(),"");
        b = b.Replace(b[0].ToString(),"");
    }
    if(b.Length >0){
        ans = "No";
    }
    WriteLine(ans);
    
    
    
    
    }
    //各種読取
    static string rstr(){
        return ReadLine();
    }
    static int rint(){
        return int.Parse(ReadLine());
    }
    static string[] stra(){
        return ReadLine().Split(' ');
    }
    static int[] inta(){
        string[] read_str_array = ReadLine().Split(' ');
        int[] return_int_array = new int[read_str_array.Length];
        for(int countup_i=0;countup_i<read_str_array.Length;countup_i++){
            return_int_array[countup_i] = int.Parse(read_str_array[countup_i]);
        }
        return return_int_array;
    }
    static int[,] inta2(int num_array,int in_array){
        int[,] int_array2 = new int[num_array,in_array];
        for(int i=0;i<num_array;i++){
            int[] temp_array = inta();
            for(int j=0;j<in_array;j++){
                int_array2[i,j] = temp_array[j];
            }
        }
        return int_array2;
    }
}

Measured memory_bytes: 24280
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let d = read::<usize>();
    let c = read_vec::<i64>();
    let mut s = vec![vec![]; d];
    for i in 0..d {
        s[i] = read_vec::<i64>();
    }

    let mut t = vec![];

    for i in 0..d {
        t.push(read::<usize>() - 1);
    }

    let mut score = 0;
    let mut last = vec![0; 26];
    for i in 0..d {
        score += s[i][t[i]];
        last[t[i]] = i + 1;
        for qi in 0..26 {
            score -= c[qi] * (i as i64 + 1 - last[qi] as i64);
        }
        println!("{}", score);
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 2224
object Main extends App {
  val hn = scala.io.StdIn.readLine()
  val hnArray = hn.split(" ").map(_.toLong).toVector
  val h = hnArray(0)
  val n = hnArray(1)
  val a = scala.io.StdIn.readLine()
  val aArray = a.split(" ").map(_.toLong).toVector
  val aArraySum = aArray.sum

  println(if(aArraySum >= h) "Yes" else "No")
}

Measured memory_bytes: 46848
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#define rep(i,n) for (int i= 0;i<(n);++i)
using namespace std;
typedef long long ll;
#define MOD 1000000007
int main()
{   
    ll N ;
    cin >> N ;
    ll a[N] ;
    ll lv[9] ;
    for(ll j = 0 ; j < 9 ; j++ ){ 
        lv[j] = 0 ;
    }
    for(ll i = 0 ; i < N ; i++){
        cin >> a[i] ;
        if(a[i] < 400 ) lv[0]++ ;
        else if(a[i] < 800) lv[1]++ ;
        else if(a[i] < 1200) lv[2]++ ;
        else if(a[i] < 1600) lv[3]++ ;
        else if(a[i] < 2000) lv[4]++ ;
        else if(a[i] < 2400) lv[5]++ ;
        else if(a[i] < 2800) lv[6]++ ;
        else if(a[i] < 3200) lv[7]++ ;
        else lv[8]++ ;
    }
    
    ll ans = 0 ;
    for(ll j = 0 ; j < 8 ; j++){
        //cout << lv[j] << endl;
        if(lv[j] > 0){
          ans++ ;
        }
    }
    if(ans == 0){
        cout << 1 <<" "<< endl;
    }else{
    cout << ans << " " ;
    }
    ans += lv[8] ;
    
    cout << ans << endl;
    


    

    return 0;
}

Measured memory_bytes: 3632
import java.io.FileInputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.io.Reader;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Scanner;

public class Main {
	static int n;
	static double[] px, py;
	
	static int min;
	
	
	public static void main(String[] args)
	{
		
		Scanner sca = new Scanner(System.in);
		
		while(true)
		{
			n = sca.nextInt();
			if(n == 0) break;
			
			px = new double[n];
			py = new double[n];
			
			int i, j;
			for(i = 0;i < n;i++)
			{
				px[i] = sca.nextDouble();
				py[i] = sca.nextDouble();
			}
			
			min = 1;
			for(i = 0;i < n;i++)
			{
				for(j = i + 1;j < n;j++)
				{
					double dx = px[i] - px[j];
					double dy = py[i] - py[j];
					double dd = dx * dx + dy * dy;
					
					if(dd > 4) continue;
					
					// 中心を求める
					double d = Math.sqrt(dd);
					double xm = (px[i] + px[j]) / 2;
					double ym = (py[i] + py[j]) / 2;
					double l = d / 2;
					double e = Math.sqrt(1 - l * l);
					
					double center1x = xm + dy / d * e;
					double center1y = ym - dx / d * e;
					
					double center2x = xm - dy / d * e;
					double center2y = ym + dx / d * e;
					
					// 数える
					int count = 0, k;
					for(k = 0;k < n;k++)
					{
						dx = center1x - px[k];
						dy = center1y - py[k];
						dd = dx * dx + dy * dy;
						if(dd < 1 + 1e-10) count++;
					}
					if(min < count) min = count;
					
					count = 0;
					for(k = 0;k < n;k++)
					{
						dx = center2x - px[k];
						dy = center2y - py[k];
						dd = dx * dx + dy * dy;
						if(dd < 1 + 1e-10) count++;
					}
					if(min < count) min = count;
				}
			}
			
			System.out.println(min);
		}
	}
}

Measured memory_bytes: 51860
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ATheNumberOfEvenPairs solver = new ATheNumberOfEvenPairs();
        solver.solve(1, in, out);
        out.close();
    }

    static class ATheNumberOfEvenPairs {
        public void solve(int testNumber, Scanner sc, PrintWriter pw) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            pw.println(((a - 1) * a / 2) + (b - 1) * b / 2);
        }

    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(FileReader r) {
            br = new BufferedReader(r);
        }

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

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

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

    }
}



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

using namespace std;

int n, h[100000], dp[100000];

int main() {
	scanf("%d", &n);
	
	for(int i = 0; i < n; i++)
		scanf("%d", &h[i]);
		
	for(int i = 1; i < n; i++) {
		dp[i] = dp[i-1] + abs(h[i] - h[i-1]);
		if(i >= 2) 
			dp[i] = min(dp[i], dp[i-2] + abs(h[i] - h[i-2]));
	}
	
	printf("%d", dp[n-1]);
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)
using namespace std;
int main(){
    int n,cnt;
    string s;
    bool l=0,r=0;
    int a=-1;
    for(;;){
        cin>>n; 
        if(n==0)
            return 0;
        cnt=0;
        a=-1;
        rep(i,n){
            cin>>s;
            if(s=="lu"){
                l=1;
                if(a==2){
                    cnt++;
                }
                a=1;
            }else if(s=="ru"){
                r=1;
                if(a==1){
                    cnt++;
                }
                a=2;
            }else if(s=="ld"){
                l=0;
                if(a==4){
                    cnt++;
                }
                a=3;
            }else{//rd
                r=0;
                if(a==3){
                    cnt++;
                }
                a=4;
            }
        }
        cout<<cnt<<endl;
    }
    return 0;
}


Measured memory_bytes: 3160
def gcd(a, b)
  while (b != 0) do
    r = a % b;
    a = b;
    b = r;
  end

  return a;
end

until $stdin.eof?
  a, b = gets.split(' ').map(&:to_i)
  gcd = gcd(a, b)
  lcm = (a*b)/gcd
  puts "#{gcd} #{lcm}"
end

Measured memory_bytes: 6096
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

int N;
string S;

int main() {
  cin >> N >> S;
  int count = 0;
  //10*10*10で各桁を見たかどうか 11桁目は各桁を見尽くしたらtrueにする
  int a, b, c;
  vector<vector<vector<bool>>> check(11, vector<vector<bool>>(11, vector<bool>(11, false)));
  for(int i = 0; i < N; i++){
    a = S[i] - '0';
    //cout << "a:" << a <<endl;
    if(check[a][10][10] == true){
      //cout << 'h' <<endl;
      continue;
    }
    else{
      check[a][10][10] = true;
    }
    for(int j = i+1; j < N; j++){
      b = S[j] - '0';
      //cout << "b:" << b <<endl;
      if(check[a][b][10] == true){
        continue;
      }
      else{
        check[a][b][10] = true;
      }
      for(int k = j+1; k < N; k++){
        c = S[k] - '0';
        //cout << "c:" << c <<endl;
        if(check[a][b][c] == false){
          check[a][b][c] = true;
          count ++;
          //cout << a << " " << b << " " << c <<endl;
        }
      }
    }
  }
  cout << count <<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n; vector<int>v;
long long dp[100005];
long long solve(int i) {
	if (i >= n)return 1e18;
	if (i == n-2)return abs(v[i]-v[n-1]);
	if (i == n-3)return abs(v[i]-v[n-1]);
	long long& ret = dp[i];
	if (ret!=2e9)return ret;
	ret=min(solve(i + 1) + abs(v[i] - v[i + 1]),solve(i + 2) + abs(v[i] - v[i + 2]));
	return ret;
}
int main() {
	cin >> n; v.resize(n); 
	for (auto& t : v)cin >> t;
	fill(dp, dp + n, 2e9);
	cout << solve(0);
}

Measured memory_bytes: 3712
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

N,M,Q=get_i
abcd=array(Q)
Q.times do|i|
    abcd[i]=get_i
end
a_=(1..M).to_a.repeated_combination(N)
ans=0
a_.each do|arr|
  val=0
  abcd.each do|a,b,c,d|
    if (arr[b-1]-arr[a-1])==c
        val+=d
    end 
  end
  ans=max(val,ans)
end
puts ans

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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;

void Yes(bool Yes){cout << (Yes ? "Yes" : "No") << endl;};
void YES(bool YES){cout << (YES ? "YES" : "NO") << endl;};

int main(){

    string N; cin >> N;

    if(N[0]==N[1] && N[1] == N[2]){
        cout << "Yes" << endl;
    }else if(N[1]==N[2] && N[2] == N[3]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

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

#define ll long long

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin >> n;
    if (n & 1) {
        cout << 0 << '\n', exit(0);
    }

    ll ans = 0;
    n /= 2;
    while (n) {
        ans += n / 5;
        n /= 5;
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
# from math import factorial,sqrt
# from itertools import permutations as permus
# from fractions import gcd
# from collections import deque,Counter
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import scipy as scp

# 入力の受け取り
n = int(input())
arrP = list(map(int,input().split()))

ans = 0
for i in range(1,n-1):
    if arrP[i-1]<arrP[i]<arrP[i+1] or arrP[i-1]>arrP[i]>arrP[i+1]:
        ans += 1

print(ans)
# print("{:.10f}".format(ans))
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する



Measured memory_bytes: 2940
#include<cstdio>
#include<cstring>

typedef long long ll;
const int maxn = 2E+5 + 5;

int n;
ll S, ans, base;
int sum[2025];
char s[maxn];

int main() {
	scanf("%s", s + 1);
	n = std::strlen(s + 1);
	
	sum[0] = 1, base = 1;
	for(int i = n; i >= 1; --i) {
		S = (S + (s[i] - '0') * base) % 2019ll;
		ans += sum[S]++, base = base * 10 % 2019ll;
	}
	printf("%lld", ans);
}

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

//Merry Christmas
public class Main{

	int INF = 1<<29;
	
	@SuppressWarnings("unused")
	int[] bipartiteMatching(boolean[][] graph) {
		int n = graph.length;
		if(n==0)return new int[0];
		int m = graph[0].length;
		int[] match = new int[m];
		Arrays.fill(match, -1);
		int res = 0;
		for (int i = 0; i < n; i++) {
			boolean[] visited = new boolean[m];
			if (go(i,graph,visited,match)) res++;
		}
		return match;
	}
	boolean go(int v,boolean[][] graph,boolean[] visited,int[] match) {
		int m = graph[0].length;
		for (int i = 0; i < m; i++)  if (!visited[i] && graph[v][i] && match[i] == -1) {
			visited[i] = true;
			match[i] = v;
			return true;
		}
		for (int i = 0; i < m; i++) if (!visited[i] && graph[v][i]) {
			visited[i] = true;
			if (go(match[i],graph,visited,match)) {
				match[i] = v;
				return true;
			}
		}
		return false;
	}
	
	void run(){
		int[][] wf = new int[100][100];
		Scanner sc = new Scanner(System.in);
		for(;;){
			int n = sc.nextInt(), m = sc.nextInt(), L = sc.nextInt();
			if((n|m|L)==0)break;
			for(int i=0;i<n;i++)for(int j=0;j<n;j++)wf[i][j]=INF;
			while(m--!=0){
				int s = sc.nextInt(), t = sc.nextInt(), d = sc.nextInt();
				wf[s][t] = wf[t][s] = d;
			}
			for(int k=0;k<n;k++)for(int i=0;i<n;i++)for(int j=0;j<n;j++)wf[i][j]=Math.min(wf[i][j], wf[i][k]+wf[k][j]);
			boolean[][] e = new boolean[L][L];
			for(int i=0;i<L;i++)for(int j=0;j<L;j++)e[i][j]=false;
			int[] p = new int[L], t = new int[L];
			for(int i=0;i<L;i++){
				p[i] = sc.nextInt(); t[i] = sc.nextInt();
			}
			for(int i=0;i<L;i++)for(int j=0;j<L;j++){
				if(i==j)continue;
				if(p[i]==p[j]){
					if(t[i]<t[j])e[i][j]=true;
				}
				else if(t[i]+wf[p[i]][p[j]]<=t[j])e[i][j]=true;
			}
			int[] r = bipartiteMatching(e);
			int res = 0;
			for(int x:r)if(x!=-1)res++;
			System.out.println(L-res);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 17000
#include <cstdio>
#include <cstdlib>
typedef struct Node
{
	int key;
	struct Node* prev;
	struct Node* next;
} Node;

Node* head;

void initNode()
{
	head = (Node*)malloc(sizeof(Node));
	head->prev=head;
	head->next=head;
}

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

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

void deleteFirst()
{
	Node* t=head->next;
	head->next=t->next;
	t->next->prev=head;
	free(t);
}

void deleteLast()
{
	Node* t=head->prev;
	head->prev=t->prev;
	t->prev->next=head;
	free(t);
}

void deleteNode(int key)
{
	Node* t=listSearch(key);
	if(t==head) return;
	t->prev->next=t->next;
	t->next->prev=t->prev;
	free(t);
}

int main()
{
	initNode();
	int n;
	scanf("%d",&n);
	char com[20];
	int x;
	for(int i=0; i<n; i++)
	{
		scanf("%s",com);
		if(com[6]=='\0')
		{
			scanf("%d",&x);
			if(com[0]=='i')
			{
				insertFirst(x);
			}
			else if(com[0]=='d')
			{
				deleteNode(x);
			}
		}
		else
		{
			if(com[6]=='F')
			{
				deleteFirst();
			}
			else if(com[6]=='L')
			{
				deleteLast();
			}
		}
	}
	Node* temp=head->next;
	int isf=0;
	while(temp!=head)
	{
		if(isf++>0) printf(" ");
		printf("%d",temp->key);
		temp=temp->next;
	}
	printf("\n");
	return 0;
}

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

using namespace std;


int main() {
    int n;
    cin>>n;
    long long r=0,l=0;
    cin>>l>>r;
    for (int i = 1; i < n; ++i) {
        int ll,rr;
        cin>>ll>>rr;
        long ra = max(long((r + rr - 1) / rr), long((l + ll - 1) / ll));
        l=ll*ra;
        r=rr*ra;
    }
    cout<<r+l<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
/*
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, 
		   tree_order_statistics_node_update> oset;
*/

#define IO            ios::sync_with_stdio(false);cin.tie(0);
 
#define int           long long
#define pi            pair<int,int>
#define pii           pair<int,pi>
#define vi            vector<int>
#define vs            vector<string>
#define vb            vector<bool>
#define vii           vector<vector<int>>
#define vpi           vector<pi>
#define pb            push_back
#define mp            make_pair
#define eb            emplace_back
#define ff            first
#define ss            second
#define fo(i,val,n)   for(int i=val;i<n;i++)
#define rfo(i,val,j)  for(int i=val;i>=j;i--)
#define all(x)        x.begin(),x.end()
#define inf           0x3f3f3f3f3f3f3f3fLL
#define endl          '\n'
#define PI            acos(-1)

mt19937 rnd(time(0));

const int N=2e5+7;
//const int MOD=1e9+7;
const int MOD=998244353; 

int fastpow(int b,int p){
    //b %= MOD;
    //p %= (MOD - 1);
    int temp;
    if(p==0) return 1;
    if(p==1) return b;
    temp = fastpow(b , p/2);
    temp = temp * temp % MOD;
    if(p & 1){
        temp = temp * b % MOD;
    }
    return temp;
}

int32_t main(){
 	
	IO  

	int x;
	cin >> x;
	
	int n = 100 , cnt = 0;
	while(n < x){
		n += (n * 1) / 100;
		cnt++;
	}
	cout << cnt;

	return 0; 
}	
	
	


Measured memory_bytes: 3656
package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	var m, ans float64
	for {
		m, ans = 0, 0
		fmt.Scan(&n)
		if n == 0 {
			break
		}

		s := make([]float64, n)
		for i := 0; i < n; i++ {
			fmt.Scan(&s[i])
			m += s[i]
		}

		m /= float64(n)
		for i := 0; i < n; i++ {
			ans += math.Pow(s[i]-m, 2)
		}
		fmt.Println(math.Sqrt(ans / float64(n)))
	}
}



Measured memory_bytes: 1264
#include<bits/stdc++.h>
#define intt long long 
#define int long long 
using namespace std;
const int maxx = 2e7+1314;
int read(){int k;cin>>k;return k;}
int n,x,b[maxx],l[maxx],u[maxx]; 
struct XX{
	int b,l,r;
}A[maxx];
int get(XX a,int c){
	return (a.r)*(c-a.b);
}	
int get1(XX a,int c){
	return max(a.r*(c-a.b),a.l*(c-a.b));
}	
bool my(XX a,XX b){	
	return a.r*(x-a.b)+a.l*a.b> b.r*(x-b.b)+b.l*b.b;
}	
int s[maxx],v[maxx];
bool chick(intt val){	
	intt Ans=0;
	intt ans=1LL<<60;	
	intt C=val;
	int D=0;
	for(int i=1;i<=n;i++){	
		if(val>=x){	
			Ans+=get(A[i],x),val-=x;
			D=i;
		}
		else {	
			for(int k=i;k<=n;k++){	
				if(Ans+get1(A[k],val)>=s[n]-s[D]-v[k])return 1;
			}	
			break;
		}		
	}	
	intt W=Ans;
	if(D!=n)
	for(int i=1;i<=D;i++){	
		Ans=W;
		
		Ans-=get(A[i],x);
		
		Ans+=get1(A[i],val);
		
		Ans+=get(A[D+1],x);
		if(Ans>=s[n]-s[D+1]){
			return 1;
		}
	}	
	return 0;
}	
signed main(){	
	n=read();x=read();
	for(int i=1;i<=n;i++)A[i].b=read(),A[i].l=read(),A[i].r=read();
	sort(A+1,A+1+n,my);
	for(int i=1;i<=n;i++)v[i] = A[i].l*A[i].b;
	for(int i=1;i<=n;i++)s[i]=s[i-1]+v[i];
	int ls = 0,rs=n*x;
	while(ls+1<rs){	
		int mid = ls+rs>>1;
		if(chick(mid))rs=mid;
		else ls=mid;
	}	
	if(chick(ls))cout<<ls<<endl;
	else  
	cout<<rs<<endl;
	return 0;
}	

Measured memory_bytes: 7168
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
vector <int> n;

int main(){
	int n;
	long long ans=0;
	cin>>n;
	for(int i=1;i<=n;i++){
		if(i%3!=0&&i%5!=0){
			ans+=i;
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

#define fastio 

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define ld long double
#define forn(low,high,i) for(i = low; i < high; i++)
#define forrev(high,low,i) for(i = high; i >= low; i--)
#define all(v) v.begin(),v.end()
#define decimal_digits cout << fixed << setprecision(15);

string to_string(string s) { return '"' + s + '"';}
string to_string(char s) { return string(1, s);}
string to_string(const char* s) { return to_string((string) s);}
string to_string(bool b) { return (b ? "true" : "false");}
template <typename A> string to_string(A);
template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}
template <typename A> string to_string(A v) {bool f = 1; string r = "{"; for (const auto &x : v) {if (!f)r += ", "; f = 0; r += to_string(x);} return r + "}";}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {cerr << " " << to_string(H); debug_out(T...);}
#define pr(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

const int inf = 1e9;
const long long INF = 1e18;
const int mod = 1e9 + 7;
const int bit32 = log2(inf) + 3;
const int bit64 = log2(INF) + 3;

inline int add(long long a, long long b){a += b; if(a >= mod) a -= mod; return a;}
inline int sub(long long a, long long b){a -= b; if(a < 0) a += mod; return a;}
inline int mul(long long a, long long b){a %= mod; b %= mod; return (int)((long long) a * b % mod);}
inline int modexpo(long long a, long long b){int res = 1; while(b > 0){ if(b & 1) res = mul(res, a); a = mul(a, a); b /= 2;} return res;}
inline int divide(long long a, long long b){return mul(a, modexpo(b, mod - 2));}
inline int inv(long long a){return modexpo(a, mod - 2);}

clock_t time_p = clock();

void ktj(){
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (float)(time_p)/CLOCKS_PER_SEC << "\n";
}

void pre(){ // Reset each global variable (esp. for graphs)
  
}

void solve(){
  int n, i, j, k;
  cin >> n;
  long long ans = 0;
  for(i = 1; i <= n; i++){
    for(j = 1; j <= n; j++){
      for(k = 1; k <= n; k++){
        ans += __gcd(i, __gcd(j, k));
      }
    }
  }

  cout << ans << '\n';
}

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

  pre();

  int t = 1, T;
  // cin >> t;
  T = t;
  while(t--){
    // cout << "Case #" << T - t << ": ";
    solve();
  }

  ktj();
}


Measured memory_bytes: 3852
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<long long> x(n);
    long long sum = 0;
    for(int i = 0; i < n; i++){
        cin >> x[i];
        sum += x[i];
    }
    long long ave = sum / n;
    long long v1 = 0, v2 = 0, v3 = 0;
    for(int i = 0; i < n; i++){
        v1 += (ave - x[i]) * (ave - x[i]);
    }
    for(int i = 0; i < n; i++){
        v2 += (ave - x[i] - 1) * (ave - x[i] - 1);
    }
    for(int i = 0; i < n; i++){
        v3 += (ave - x[i] + 1) * (ave - x[i] + 1);
    }
    cout << min(v1, min(v2, v3));
    return 0;
}

Measured memory_bytes: 256
strings = input()

q = int(input())

for i in range(q):
    order = list(input().split())
    a, b = map(int, order[1:3])
    if order[0] == 'print':
        print(strings[a:b+1])
    elif order[0] == 'reverse':
        re_strings = strings[a:b+1]
        strings = strings[:a] + re_strings[::-1] + strings[b+1:]
    else:
        strings = strings[:a] + order[3] + strings[b+1:]


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

const int N = 1e3;

int n, ans, a[N], b;

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < n; i++) {
		cin >> b;
		ans += max(0, a[i] - b);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int MOD = 1000000007;
const int INF = 1e14;
using Graph = vector<vector<int>>;

signed main(){
  int H, W, M;
  cin >> H >> W >> M;

  map<int, int> Hcnt;
  map<int, int> Wcnt;
  set<pair<int, int>> num;
  for( int i = 0; i < M; i++ ){
    int h, w;
    cin >> h >> w;
    num.insert({h, w});
    Hcnt[h]++;
    Wcnt[w]++;
  }

  //HとWの最大値をそれぞれ調べる
  int Hmax = 0;
  for( auto p : Hcnt ){
    if( p.second > Hmax ) Hmax = p.second;
  }
  int Wmax = 0;
  for( auto p : Wcnt ){
    if( p.second > Wmax ) Wmax = p.second;
  }

  vector<int> H_kouho;
  for( auto p : Hcnt ){
    if( p.second == Hmax ) H_kouho.push_back(p.first);
  }
  vector<int> W_kouho;
  for( auto p : Wcnt ){
    if( p.second == Wmax ) W_kouho.push_back(p.first);
  }

  for( int i = 0; i < H_kouho.size(); i++ ){
    for( int j = 0; j < W_kouho.size(); j++ ){
      if( !num.count({H_kouho[i], W_kouho[j]}) ){
        cout << Hmax+Wmax << endl;
        return 0;
      }
    }
  }
  cout << Hmax+Wmax-1 << endl;


}

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

int main() {
  int K; cin >> K;
  cout << 1 << endl;
  auto S = [](ll x) {
    ll res = 0;
    while (x) res += x % 10, x /= 10;
    return res;
  };
  ll x = 1, sx = 1;
  while (--K) {
    ll n = x + sx;
    ll m = x + sx * 10;
    if (S(m) * (n) > S(n) * (m)) sx *= 10;
    x += sx;
    cout << x << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long a, v, b, w, t;
  cin >> a >> v >> b >> w >> t;
  long long d = abs(a - b);
  if (v > w && d <= (v - w) * t) {
    cout << "YES" << '\n';
  } else {
    cout << "NO" << '\n';
  }
  return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<limits>
#include<bitset>
#include<functional>
#include<type_traits>
#include<queue>
#include<stack>
#include<array>
#include<random>
#include<utility>
#include<cstdlib>
#include<ctime>

using namespace std;

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;}

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

long long INF = 1LL<<60;
long long dp[100010];
int h[100010];
int x[10],y[10];
double dist(int i,int j){
double dx = x[i]-x[j];
double dy = y[i]-y[j];
return pow(dx*dx+dy*dy,0.5);
}
int main(){
    int n;
    cin>>n;
    vector<int> v(n);
    for(int i=1;i<=n;i++){
        cin>>x[i]>>y[i];
    }
    rep(i,n)
        v.at(i)=i+1;
    double sum=0.0;
    do
    {
        for(int i=0;i<(n-1);i++){
            sum+=dist(v[i],v[i+1]);
        }
    } while (next_permutation(v.begin(),v.end()));
    int factorial = 1;
    for(int i=2;i<=n;i++)factorial*=i;
    cout<< fixed<<setprecision(10)<<sum/factorial<<endl;
    return 0;
}




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

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();

        int n = sc.nextInt();
        int[] a = {-2, -1, 0, 1, 2};

        int base = n * 100 / 108;
        for (int i : a) {
            int tmp = base + i;
            if (Math.floor(tmp*1.08) == n) {
                System.out.println(tmp);
                return;
            }
        }

        System.out.println(":(");
    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }

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

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

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

int main() {
	while(true){
	int n,m,h,k;
	multimap<int,int> bar;
	int nowPoint[1001],point[1001],barC[100000][2],me[1001];
	int now=0;
	int x,y;
	cin >> n >> m >> h >> k;
	if(n==0)
	break;
	for(int i=1;i<=n;i++){
		cin >> point[i];
		nowPoint[i]=i;
		me[i]=i;
	}
	for(int i=0;i<m;i++){
		cin >> x >> y;
		bar.insert(multimap<int,int>::value_type(y,x));
	}
	multimap<int,int>::iterator it=bar.begin();
	while(it !=bar.end())
	{
		barC[now][0]=nowPoint[(*it).second];
		barC[now][1]=nowPoint[(*it).second+1];
		me[barC[now][0]]++;
		me[barC[now][1]]--;
		now++;
		int r=nowPoint[(*it).second];
		nowPoint[(*it).second]=nowPoint[(*it).second+1];
		nowPoint[(*it).second+1]=r;
		
		++it;
	}
	int sum=0;
	for(int i=1;i<=k;i++){
	sum+=point[me[i]];
	}
	int miner=sum;
	for(int i=0;i<m;i++){
		int newS=sum;
		if(barC[i][0] <= k && barC[i][1] > k)
		newS=sum+point[me[barC[i][1]]]-point[me[barC[i][0]]];
		else if(barC[i][1] <= k && barC[i][0] > k)
		newS=sum-point[me[barC[i][1]]]+point[me[barC[i][0]]];
		miner=min(miner,newS);
	}
	cout << miner << endl;
	}
	
	return 0;
}

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

int A[3005];

int main() {
    int N, a ,ans;
    ans = 0;
    scanf("%d", &N);
    for (int i = 0; i < N; i++) {
        scanf("%d", &a);
        ans += a - 1;
    }

    printf("%d\n", ans);
    return 0;
}

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


int main(){
    cout<<fixed<<setprecision(10);

    
    ll H,W;cin>>H>>W;
    
    while(H>0 || W>0){
        rep(i,H){
            rep(j,W){
                if((i+j)%2 == 0) cout<<'#';
                else cout<<".";
            }
            cout<<endl;
        }    
        cout<<endl;
        cin>>H>>W;
    }
    

    

    return 0;
}






Measured memory_bytes: 3084
import java.util.*;

import java.lang.*;

import java.math.*;



public class Main {

	Scanner sc = new Scanner(System.in);



	void run() {

		String buffer = sc.nextLine();

		Scanner in = new Scanner(buffer.replace(',', ' ').replace('.', ' '));

		String ans = "";

		for (; in.hasNext();) {

			String tango = in.next();

			if (tango.length() < 3)

				continue;

			if (tango.length() > 6)

				continue;

			ans+=tango+" ";

		}

		System.out.println(ans.trim());

		

	}



	public static void main(String[] args) {

		Main m = new Main();

		m.run();

	}

}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
using namespace std;
const long long maxn=1e5+5;
const long long inf=0x3f3f3f3f;
const long long mod=1e9+7;
long long quick_pow(long long a,long long b)
{
	long long res=1;
	while(b)
	{
		if(b&1)
			res=res*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return res;
}
long long fac[maxn],inv[maxn];
long long C(long long n,long long m)
{
	return fac[n]*inv[m]%mod*inv[n-m]%mod;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
    fac[0]=1;
    for(long long i=1;i<2005;i++)
    	fac[i]=(fac[i-1]*i)%mod;
    inv[2005-1]=quick_pow(fac[2005-1],mod-2);
    for(long long i=2005-2;i>=0;i--)
    	inv[i]=(inv[i+1]*(i+1))%mod;
    long long sum,ans=0;
    cin>>sum;
    if(sum>=3)
    	ans++;
   // cout<<ans<<endl;
    for(long long i=1;i<=sum/3;i++)
    {
    	long long x=sum-(i+1)*2-1;
    	if(x<i)
    		break;
   // 	cout<<"i:"<<i<<" x:"<<x<<endl;
    	ans+=C(x,i);
   // 	cout<<ans<<endl;
    	ans%=mod;
	}
	ans%=mod;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3688
#include<bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
const int MAX_N = 200000;
int N,BIT[MAX_N+1] = {};//1-indexed
void add(int i,int x){
  while(i <= N){
    BIT[i] += x;
    i += i&(-i);
  }
}
int sum(int i){
  int s = 0;
  while(i){
    s += BIT[i];
    i -= i&(-i);
  }
  return s;
}
int main(){
  int i;scanf("%d",&N);
  int a[N];vector<int> v;
  for(i=0;i<N;i++){
    scanf("%d",&a[i]);
    v.emplace_back(a[i]);
  }
  sort(v.begin(),v.end());
  v.erase(unique(v.begin(),v.end()),v.end());
  for(i=0;i<N;i++) a[i] = lower_bound(v.begin(),v.end(),a[i])-v.begin()+1;
  ll ans = 0;
  for(i=0;i<N;i++){
    ans += i-sum(a[i]);
    add(a[i],1);
  }
  printf("%lld\n",ans);
}


Measured memory_bytes: 5444
//File Name: agc001_a.cpp
  //Created Time: 2017年12月04日 星期一 16时11分07秒
                                   
#include <bits/stdc++.h>
#define LL long long
using namespace std;
const int MAXN = 202;
int a[MAXN];

int main(){
    int n;
    cin >> n;
    n += n;
    for(int i(0);i<n;++i)
        cin >> a[i];
    sort(a,a + n);
    int ans(0);
    for(int i(0);i+1<n;i+=2)
        ans += a[i];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll= long long;
using vi= vector<int>;
using vvi= vector<vi>;
using vd= vector<double>;
using vvd= vector<vd>;
using vc= vector<char>;
using vb= vector<bool>;
using vl= vector<ll>;
using vs= vector<string>;
#define rep(i,x,n) for(int i=x; i<n; i++)
#define all(x) x.begin(), x.end()

int main(){
  int n,ans=0;
  cin >>n;
  vvi a(n, vi(3));
  vvi dp(n, vi(3,0));
  rep(i,0,n)rep(j,0,3)cin>>a[i][j];

  rep(i,0,3)dp[0][i]=a[0][i];
  rep(i,1,n){
    rep(j,0,3){
      rep(k,0,3){
        if(j==k)continue;
        dp[i][j]= max(dp[i][j], dp[i-1][k]);
      }
      dp[i][j]+= a[i][j];
    }
  }
  rep(i,0,3){
    //cout << dp[n-1][i] << ",";
    ans= max(ans, dp[n-1][i]);
  }
  /*
  rep(i,0,n){
    rep(j,0,3){
      cout << dp[i][j] << ",";
    }
    cout << endl;
  }*/
  cout << ans;
  
}


Measured memory_bytes: 11136
s = raw_input()
n = input()
result = []
for i in xrange(n):
    c = raw_input().split()
    a = int(c[1])
    b = int(c[2])+1

    if c[0] == 'print' :
        result.append(s[a:b])
    elif c[0] == 'reverse':
        d = s[a:b]
        s = s.replace(d,d[::-1])
    elif c[0] == 'replace':
        s = s[:a] + c[3] + s[b:]

for i in result:
    print i

Measured memory_bytes: 6464
#include <iostream>
#include <string>
#include <vector>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

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

  if (A > 8 || B > 8) cout << ":(" << endl;
  else cout << "Yay!" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
int main(void){
    int i,n,m,q,ans=0,num=0;
    scanf("%d %d %d\n",&n,&m,&q);
    int a[50],b[50],c[50],d[50],A[10];
    for(i=0; i<q; i++){
        scanf("%d %d %d %d\n",&a[i],&b[i],&c[i],&d[i]);
    }
    for(A[0]=1; A[0]<=m; A[0]++){
        for(A[1]=A[0]; A[1]<=m; A[1]++){
            for(A[2]=A[1]; A[2]<=m; A[2]++){
                for(A[3]=A[2]; A[3]<=m; A[3]++){
                    for(A[4]=A[3]; A[4]<=m; A[4]++){
                        for(A[5]=A[4]; A[5]<=m; A[5]++){
                            for(A[6]=A[5]; A[6]<=m; A[6]++){
                                for(A[7]=A[6]; A[7]<=m; A[7]++){
                                    for(A[8]=A[7]; A[8]<=m; A[8]++){
                                        for(A[9]=A[8]; A[9]<=m; A[9]++){
                                            num=0;
                                            for(i=0; i<q; i++){
                                                if(A[b[i]-1]-A[a[i]-1]==c[i]){
                                                    num += d[i];
                                                }
                                            }
                                            if(num>ans){
                                                ans=num;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 1736
#define _DEBUG 1
#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>
using namespace std;

using ll = long long;

#ifdef _DEBUG
#define dump(x) cerr << #x << "=" << x << endl
#define dump2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define dump3(x, y, z)                                                         \
  cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z     \
       << endl
#define check(s) cerr << s << endl
#else
#define dump(x)
#define dump2(x, y)
#define dump3(x, y, z)
#define check(s)
#endif

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

const ll LINF = 2e18;
const int INF = 1e9;

void solve(ll A, ll B, ll C, ll X, ll Y) {
  ll result = 0;

  if (A + B >= 2 * C) {
    if (X >= Y) {
      if (A <= 2 * C) {
        result += (2 * C) * Y;
        result += A * (X - Y);
      } else {
        result += 2 * C * X;
      }
    } else {
      if (B <= 2 * C) {
        result += (2 * C) * X;
        result += B * (Y - X);
      } else {
        result += 2 * C * Y;
      }
    }
  } else {
    result += A * X + B * Y;
  }

  cout << result << endl;
}

int main() {
  ll A;
  scanf("%lld", &A);
  ll B;
  scanf("%lld", &B);
  ll C;
  scanf("%lld", &C);
  ll X;
  scanf("%lld", &X);
  ll Y;
  scanf("%lld", &Y);
  solve(A, B, C, X, Y);
  return 0;
}


Measured memory_bytes: 256
import sys

# sys.stdin = open('c1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def main():
    n = read_int()
    a = read_int_list()
    res = 10 ** 20
    s = sum(a)
    x = 0
    y = s
    for i in range(n - 1):
        x += a[i]
        y -= a[i]
        t = abs(x - y)
        if res > t:
            res = t
    print(res)

main()


Measured memory_bytes: 23800
#include <iostream>
#include <string>
#include <vector>
#include <cassert>
#include <algorithm>
#include <math.h> 
#include <set>
#include <map>
#include <deque>
#include <queue>


using namespace std;

#define ll long long int
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repp(i, n) for(int i = 1; i <= n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define riverse(v) reverse((v).begin(), (v).end())
#define pb push_back
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<ll>;
using vvi = vector<vi>;
const ll MOD = 1e9 + 7;

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

ll lcm(ll a, ll b) {
	return (a / gcd(a, b))*b;
}


int main() {
	int N;
	cin >> N;
	vll T(N);
	rep(i, N) cin >> T[i];
	ll ans = 1;
	rep(i, N) {
		ans = lcm(ans, T[i]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int h,w;
  int n;
  int x,y;
  int mas[20][20];
  int d[20][20];
  while(1){
    cin>>w>>h;
    if(w==0 && h==0) break;
    for(int i=0;i<=h;i++){
      for(int j=0;j<=w;j++){
	mas[i][j]=0;
	d[i][j]=0;
      }
    }
    cin>>n;
    for(int i=0;i<n;i++){
      cin>>x>>y;
      mas[y][x]=1;
    }
    d[1][1]=1;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	if(mas[i+1][j+1]==0 && j+i!=0){
	  d[i+1][j+1]=d[i][j+1]+d[i+1][j];
	}
      }
    }
    cout<<d[h][w]<<endl;
  }
}

Measured memory_bytes: 1164
import java.io.BufferedReader;
import java.io.InputStreamReader;
class Main {
    public static void main(String[] args) throws Exception{
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));// ??\????????????????????????
            String line = null;
            hoge:while((line = br.readLine()) != null){
            	String lines[] = line.split(" ");
            	int x = Integer.parseInt(lines[0]);
            	String op = lines[1];
            	int y = Integer.parseInt(lines[2]);
            	switch(op){
            	case "+":
            		System.out.println(x + y);
            		break;
            	case "-":
            		System.out.println(x - y);
            		break;
            	case "*":
            		System.out.println(x * y);
            		break;
            	case "/":
            		System.out.println(x / y);
            		break;
            	case "?":
            		break hoge;
            	}
            }
    }
}

Measured memory_bytes: 24304
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
    int d[2005]; // d[i]:= 最短距離がiである二頂点の組み合わせの数.
    for(int i=0;i<2005;i++) d[i] = 0;
    int n,x,y; cin >> n >> x >> y;
    for(int i=1;i<n;i++){
        for(int j=i+1;j<=n;j++){
            int dist = min({j-i, abs(x-i) + 1 + abs(y-j), abs(y-i) + 1 + abs(x-j)});
            d[dist]++;
        }
    }
    for(int k=1;k<=n-1;k++) cout << d[k] << "\n";
    return 0;
}

Measured memory_bytes: 256