akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int H,W,K;
  cin >> H >> W >> K;
  char S[H][W];
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> S[i][j];
    }
  }
  int ans = 9999999;
  int divide[H];
  int num[H];
  for (int bit = 0; bit < (1 << H-1); bit++) {
    memset(divide,0,sizeof(divide));
    memset(num,0,sizeof(num));
    int cnt = 0;
    int res = 0;
    
    divide[0] = 0;
    for (int i = 0; i < H-1; i++) {
      if (bit & (1 << i)) {
        cnt++;
      }
      divide[i+1] = cnt;
    }
    res += cnt;
    //{0,0,0,1,1,1,2,2}で割れ目を表現
    int roop = 0;
    for (int i = 0; i < W; i++) {
      roop++;
      bool can = true;
      for (int j = 0; j < H; j++) {
        if (S[j][i] == '1') {
          num[divide[j]]++;
        }
      }
      for (int j = 0; j < H; j++) {
        if (num[j] > K) {
          can = false;
        }
      }
      if (!can) {
        i--;
        res++;
        memset(num,0,sizeof(num));
      }
      if (roop > W * 10) {
        res = 9999999;
        break;
      }
    }
    ans = min(ans,res);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<numeric>
//#include <boost/math/common_factor.hpp> 
#define int long long
#define ld long double
#define all(x) x.begin(),x.end()
const int maxn=1000000;
#define what_is(x) cerr << #x << " is " << x << endl;
const int MOD = 1e9 + 7;
using namespace std;
string abc="abcdefghijklmnopqrstuvwxyz";
int powmod(int a, int b, int MOD = MOD){
    if(!a and !b)    return 1ll;
    if(!a)    return a;
    int res = 1ll;
    b %= (MOD - 1ll), a %= MOD;
    while(b){
        if(b%2 == 1)    res = (res * a) % MOD;
        a = (a * a) % MOD;
        b /= 2;
    }
    return res;
}
int popcount(uint32_t n)
{
    n = n - ((n >> 1) & 0x55555555);
    n = (n & 0x33333333) + ((n >> 2) & 0x33333333);
    return ((n + (n >> 4) & 0xF0F0F0F) * 0x1010101) >> 24;
}
bool check(int n) {return (((double)sqrt(n)-floor((double)sqrt(n)))==0);}
vector<bool> sieve(maxn + 1, true);
void fillprime() {
    sieve[0] = sieve[1] = false;
    for (int i = 2; i <= maxn; ++i) {
        if (sieve[i] && (int) i * i <= maxn) {
            for (int j = i * i; j <= maxn; j += i) {
                sieve[j] = false;
            }
        }
    }
}
const int nn=1e5+5;
void solve() {
    int a,b,c;
    cin>>a>>b>>c;
    int arr[3]={a,b,c};
    sort(arr,arr+3);
    cout<<arr[0]+arr[1];
    
    
}
int32_t main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    //fillprime();
    //int t;cin>>t;while(t--)
    solve();
}

Measured memory_bytes: 3760
import math
N, D = map(int,input().split())
X = [[int(i) for i in input().split()] for _ in range(N)]
 
ans = 0
for i in range(N):
    for j in range(i+1, N):
        yz = [(y - z)**2 for y, z in zip(X[i], X[j])]
        v = math.sqrt(sum(yz))
        if v == int(v):
            ans += 1
            
print(ans)

Measured memory_bytes: 3064
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        a: i32, _b: i32, _c: i32, _d: i32, e: i32, k: i32
    }

    println!("{}", if (e - a) > k {":("} else {"Yay!"});
}



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

int main() {
  int N, W;
  cin >> N;
  cin >> W;
  vector<int> w(N);
  vector<int> v(N);
  vector<long long int> dp(W + 1, 0);
  for (int i = 0; i < N; ++i) {
    cin >> w[i];
    cin >> v[i];
  }
  for (int i = 0; i < N; ++i) {
    for (int j = W - w[i]; j >= 0; --j) {
      dp[j + w[i]] = max(v[i] + dp[j], dp[j + w[i]]);
    }
  }
  cout << dp[W];
}

Measured memory_bytes: 1024
/* Dedication has no limitation 
*/
// 22 June 2019
// Location: Japan
#include <bits/stdc++.h>
using namespace std;
int main()
{

  vector<float> v1;
  int n; cin >> n;
  float t,a;
  cin >> t >> a;
  // the  temperature is  t - (x * 0.006)
  // it should be closest to a;
  for(int i=0; i<n; i++){
    float h; cin >> h; // each h is value of height
    float temp = t - (h*0.006); // temp is the temperatire
    v1.push_back(abs(a-temp));
}

map<float,int> m;
for(int i=1; i<=n; i++){
  m[v1[i-1]]=i;
}

sort(v1.begin(), v1.end());

cout << m[v1[0]];


 }
   
   







Measured memory_bytes: 256
import java.util.*

fun main(args : Array<String>) {
    val (n, k) = readLine()!!.split(" ").map { it.toLong() }
    val aa = readLine()!!.split(" ").map { it.toInt()-1 }

    val dfs = ArrayDeque<Int>()
    dfs.addLast(0)

    var seen = BooleanArray(n.toInt()) {false}
    seen[0] = true

    val route = mutableListOf<Int>()
    var rep = 0

    while (dfs.isNotEmpty()) {
        val idx = dfs.removeFirst()
        val a = aa[idx]

        if (seen[a]) {
            if (a != 0) {
                rep = route.size - route.indexOf(a)
            } else {
                route.add(a)
                rep = route.size
            }
            break
        }

        seen[a] = true
        route.add(a)
        dfs.addLast(a)
    }

    if (k <= route.size) {
        println(route[k.toInt()-1]+1)
    } else {
        val pre = route.size-rep
        var idx = ((k - pre) % rep).toInt() - 1
        if (idx < 0) idx = rep-1
        println(route[pre+idx]+1)
    }
}

Measured memory_bytes: 72832
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

vector<int> times;

int dif(int a, int b){
    int d=abs(a-b);
    return min(d,24-d);
}

int check(int x){
    int d=INF;
    for(auto& t:times){
        d=min(d,dif(x,t));
    }
    return d;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;
    cin>>N;
    
    map<int,int> nums;
    rep(i,N){
        int x; cin>>x;
        nums[x]++;
    }
    
    times.push_back(0);
    int mn=INF;
    for(auto& a:nums){
        int t=a.first;
        int n=a.second;
        if(n>=3){
            mn=0;
            break;
        }else if(n==2){
            mn = min(mn,check(t));
            times.push_back(t);
            mn = min(mn,check(24-t));
            times.push_back(24-t);
        }else{
            int a=check(t);
            int b=check(24-t);
            if(a<b){
                a=b;
                t=24-t;
            }
            mn = min(mn,a);
            times.push_back(t);
        }
    }
    cout1(mn);
}

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

using namespace std;
typedef long long ll;
typedef vector<ll> vl ;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;

#define rep(i,N) for(int i=0; i < (int)N; i++)
#define all(v) (v).begin(),(v).end()

const ll INF = (ll) 1e18 + 5;

int main(){
	int n, m, x; cin >> n >> m >> x;
	vl c(n);
	vector<vl> a(n, vl(m));
	rep(i,n) {
		cin >> c[i];
		rep(j,m) cin >> a[i][j];
	}
	ll ans = INF;
	for (ll k = 0; k < (1<<n); k++){
		ll tot = 0;
		vl sum(n);
		rep(i, n){
			if(k >> i & 1){
				tot += c[i];
				rep(j, m){
					sum[j] += a[i][j];
				}
			}
		}
		bool ok = true;
		rep(i, m){
			if(sum[i] < x) ok = false;
		}
		if(ok) ans = min(ans, tot);

	}

	cout << (ans == INF ? -1 : ans) << endl;

}

Measured memory_bytes: 3632
X, Y, Z, K = gets.split(' ').map(&:to_i)
score = []
score2 = []

a = gets.split(' ').map(&:to_i).sort.reverse
b = gets.split(' ').map(&:to_i).sort.reverse
c = gets.split(' ').map(&:to_i).sort.reverse

a.slice(0..(K + 3/ 3)).each do |i|
  b.slice(0.. (K + 3/ 3)).each do |j|
    score.push(i + j)
  end
end

score = score.sort.reverse

score.slice(0..K).each do |i|
  c.each do |j|
    score2.push(i + j)
  end
end

score2 = score2.sort.reverse

K.times do |i|
  puts score2[i]
end

Measured memory_bytes: 107248
n=int(input())
s=[list(map(int, input().split())) for i in range(n)]
z=0
p=s[0][0]-abs(s[0][1])-abs(s[0][2])
if p>=0 and p%2==0:
        pass
else:
    print('No')
    exit()
    
for i in range(1,n):
    z=s[i][0]-s[i-1][0]-abs(s[i][1]-s[i-1][1])-abs(s[i][2]-s[i-1][2])
    if z>=0 and z%2==0:
        pass
    else:
        print('No')
        exit()
print('Yes')

Measured memory_bytes: 27300
mod=2019
L,R = map(int,input().split())

ls =[]

if R-L>=mod-1:
    print(0)
    exit()
else:
    for i in range(R-L+1):
        ls.append((L+i)%mod)

ans=10000
for i in range(len(ls)-1):
    for j in range(i+1,len(ls)):
        ans = min(ans,(ls[i]*ls[j])%mod)

print(ans)

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

int n, cnt[100010], ans = 1;

int main(){
	scanf("%d", &n);
	for(int i = 0, x; i < n; i++){
		scanf("%d", &x);
		cnt[x]++;
	}
	for(int i = n - 1; i >= -n + 1; i -= 2) cnt[abs(i)]--;
	for(int i = 0; i < n / 2; i++) ans = ans * 2 % 1000000007;
	printf("%d\n", (count(cnt, cnt + n, 0) == n) * ans);
}

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

void print(std::vector<int>& readVec){
    int n = readVec.size();
    for(int i = 0; i < n; ++i){
        std::cout << readVec.at(i);
        if(n - 1 != i){
            std::cout << " ";
        }else{
            std::cout << std::endl;
        }
    }
}

int insertionSort(std::vector<int>& readVec, int span = 1){
    int n = readVec.size(), count = 0;
    for(int i = span; i < n; ++i){
        int val = readVec.at(i), j = i - span;
        while(0 <= j && val < readVec.at(j)){
            readVec.at(j + span) = readVec.at(j);
            j -= span;
            ++count;
        }

        readVec.at(j + span) = val;
    }

    return count;
}

int shellSort(std::vector<int>& readVec){
    int n = readVec.size();
    std::vector<int> spans;
    while(0 != n){
        spans.push_back(n);
        n /= 2;
    }

    int m = spans.size();
    std::cout << m << std::endl;
    print(spans);

    int count = 0;
    for(int i = 0; i < m; ++i){
        count += insertionSort(readVec, spans.at(i)); 
    }

    return count;
}

int main(){
    int n;
    std::cin >> n;

    std::vector<int> a(n);
    for(int i = 0; i < n; ++i){
        std::cin >> a.at(i);
    }

    std::cout << shellSort(a) << std::endl;

    for(int i = 0; i < n; ++i){
        std::cout << a.at(i) << std::endl;
    }

    return 0;
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < n; ++i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define stl_repr(itr, x) for (auto itr = x.rbegin(); itr != x.rend(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

using llong = long long int;

const static int MOD = 1000000000 + 7;
const static int inf = INT_MAX / 2;
const static llong INF = 1LL << 31;
const static int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

vector< int > divisor(int n) {
  vector< int > ret;
  for(int i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<int> A(n);
    rep(i, n) cin >> A[i];

    int m = 0;
    vector<int> balls(n, 0), ans(n, 0);
    for (int i = n - 1; i >= 0; --i) {
        if (A[i] != (balls[i] % 2)) {
            ans[i] = 1;
            ++m;
            vector<int> res = divisor(i + 1);
            rep(j, (int)res.size()) {
                ++balls[res[j] - 1];
            }
        }
    }

    cout << m << endl;
    rep(i, n) {
        if (ans[i]) cout << i + 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
void start()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
}
signed main()
{
	start();
	int arr[5],ans=0;
	for(int i=0;i<5;i++)
	{
		cin>>arr[i];
		if(arr[i]==0)
			ans=i+1;
	}
	cout<<ans<<"\n";
	return 0;
}


Measured memory_bytes: 3536
#include<cstdio>
#include<cmath>
#include<set>
#define rep(i, a, b) for (register int i=(a); i<=(b); ++i)
#define per(i, a, b) for (register int i=(a); i>=(b); --i)
void add(int &x, int y, int P){x=(x+y)%P;}
using namespace std;
const int N=10005;
int vis[N], p[N], sum[N], a[N], cnt, n;
set<int> ans;

inline int read()
{
    int x=0,f=1;char ch=getchar();
    for (;ch<'0'||ch>'9';ch=getchar()) if (ch=='-') f=-1;
    for (;ch>='0'&&ch<='9';ch=getchar()) x=(x<<1)+(x<<3)+ch-'0';
    return x*f;
}

void sieve(int n)
{
	rep(i, 2, n)
	{
		if (!vis[i]) p[++cnt]=i;
		for (int j=1; j<=cnt && p[j]*i<=n; j++)
		{
			vis[p[j]*i]=1;
			if (!(i%p[j])) break;
		}
	}
}

int gcd(int a, int b){return b?gcd(b, a%b):a;}

void factor(int x)
{
	for (int i=2; i*i<=x; i++) 
		while (x%i==0) x/=i, ans.insert(i);
	if (x>1) ans.insert(x);
}

void check(int p)
{
	rep(i, 0, p-2) sum[i]=0;
	rep(i, 0, n) add(sum[i%(p-1)], a[i], p);
	rep(i, 0, p-2) if (sum[i]) return; 
	ans.insert(p);
}

int main()
{
	n=read(); sieve(n); int g=0; 
	per(i, n, 0) 
	{
		a[i]=read();
		if (a[i]) g=gcd(g, abs(a[i]));
	}
	factor(g); 
	rep(i, 1, cnt) if (a[0]%p[i]==0) check(p[i]);
	for (int x: ans) printf("%d\n", x);
	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
string util(string s,string t)
{
  int m=s.length(),n=t.length();
  int dp[m+1][n+1],index[m+1][n+1];
  for(int i=0;i<=m;i++)
  dp[i][0]=0,index[i][0]=-1;
  for(int j=0;j<=n;j++)
  dp[0][j]=0,index[0][j]=-1;
  for(int i=1;i<=m;i++)
  {
    for(int j=1;j<=n;j++)
    {
      if(s[i-1]==t[j-1])
      dp[i][j]=dp[i-1][j-1]+1,index[i][j]=2;
      else
      {
        dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        if(dp[i-1][j]>=dp[i][j-1])
        index[i][j]=0;
        else
        index[i][j]=1;
      }
    }
  }
  string ans="";
  int i=m,j=n;
  while(i>0&&j>0)
  {
    if(index[i][j]==2)
    {
      ans=s[i-1]+ans;
      i--,j--;
    }
    else if(index[i][j]==1)
    j--;
    else
    i--;
  }
  return ans;
}
int main()
{
  string s,t;
  cin>>s>>t;
  string ans=util(s,t);
  cout<<ans<<endl;
  return 0;
}


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

public class Main {
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		System.out.println(Math.min(n*a, b));
	}
}

Measured memory_bytes: 21460
module Main where

import Control.Applicative
import Text.Printf

main :: IO ()
main = do
  { [a,b,c] <- getInts
  ; print(count 0 a b c)
  }

count :: Int -> Int -> Int -> Int -> Int
count n x y z
  | x > y          = n
  | z `mod` x == 0 = count (n+1) (x+1) y z
  | otherwise      = count n     (x+1) y z

--

getInts :: IO[Int]
getInts = map read . words <$> getLine

putInts :: [Int] -> IO ()
putInts = putStrLn . unwords . map show




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

typedef long long ll;

int main()
{
    ll i,j;
    ll n;
    cin >> n;
    vector<ll> a(n);
    for(i = 0;i < n;++i){
        cin >> a.at(i);
    }
    vector<ll> b = a;
    sort(a.begin(), a.end());
    vector<pair<ll,ll>> d;
    ll tmp = a.at(0);
    ll num = 1; 
    for(i = 1;i < n;++i){
        if(a.at(i) == tmp){
            ++num;
        }else{
            d.emplace_back(tmp,num);
            tmp = a.at(i);
            num = 1;
        }
    }
    d.emplace_back(tmp,num);

    vector<ll> e;
    for(i = 0;i < d.size();++i){
        tmp = d.at(i).second;
        e.push_back(tmp*(tmp-1)/2);
    }
    vector<ll> f;
    for(i = 0;i < d.size();++i){
        tmp = d.at(i).second;
        //cout << tmp << endl;
        f.push_back((tmp-1)*(tmp-2)/2);
    }
    ll sum = 0;
    for(i = 0;i < e.size();++i){
        sum += e.at(i);
    }

    unordered_map<ll,ll> ue;
    for(i = 0;i < e.size();++i){
        ue[d.at(i).first] = e.at(i);
    }
    unordered_map<ll,ll> uf;
    for(i = 0;i < f.size();++i){
        uf[d.at(i).first] = f.at(i);
    }
    for(i = 0;i < n;++i){
        ll ans = sum - ue.at(b.at(i)) + uf.at(b.at(i));
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 21616
#include <bits/stdc++.h>
using namespace std;
int main() {
    #ifdef DEBUG
    std::ifstream in("/home/share/inputf.in");
    std::cin.rdbuf(in.rdbuf());
    #endif
    vector<int> x(100, 0);
    for(int i = 0; i < 3; i++) {
        int tmp;
        cin >> tmp;
        x[tmp]++;
    }
    cout << ((x[5] == 2 && x[7] == 1) ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 256
def primeFacter(x):
    i = 1
    cnt = 0
    while i <= 200:
        if x % i == 0:
            cnt +=1
        i += 1
    return cnt
n = int(input())
cnt = 0
for i in range(1,n+1,2):#1~n
    if primeFacter(i) == 8:
        cnt += 1
print(cnt)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll= long long ;
using P = pair<ll,ll>;
#define rep(i,n) for (ll i = 0; i<(ll)(n); i++)
#define mod 1000000007
#define pi 3.141592653589793
typedef vector<ll> vcl;

ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a, ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t =rep_jijo(n,x/2);
        return t*t%mod;
  }
  return n*rep_jijo(n,x-1)%mod;
}
ll c2(ll n){
    return n*(n-1)/2;
}

int main() {
    int n;
    cin>>n;
    vcl a(n+1);
    for(int i=1;i<=n;i++)cin>>a[i];
    map<ll,ll> mp;
    ll ans=0;
    for(int i=1;i<=n;i++){
        int sa =i-a[i];
        ans+=mp[sa];
        int wa=a[i]+i;
        mp[wa]++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 27544
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    sc.close();
    System.out.println(solve(n - 1));
  }

  static int solve(int n){
    if(n == 1) {
      return 1;
    }
    int ans = 0;
    for(int i = 1; i <= n; i++){
      ans += n / i;
    }
    return ans;
  }
}

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

const ll MAXN = 200000;
const ll INF = 1001001001;
const ll MOD = 1000000007;

ll N, ans=0, tmp=0, tmp1=0, tmp2=0;
string S, T;
vector<ll> A, B;

signed main(){
    cin >> S >> T >> N;
    A.resize(S.size()+1, 0);
    B.resize(T.size()+1, 0);
    for(int i=0;i<S.size();i++) {
        if(S[i]=='B') A[i+1]++;
    }
    for(int i=0;i<S.size();i++) {
        A[i+1] = A[i] + A[i+1];
        //cout << A[i+1] << " ";
    }
    //cout << endl;
    for(int i=0;i<T.size();i++) {
        if(T[i]=='B') B[i+1]++;
    }
    for(int i=0;i<T.size();i++) {
        B[i+1] = B[i] + B[i+1];
        //cout << B[i+1] << " ";
    }
    //cout << endl;
    for(int i=0;i<N;i++) {
        ll a, b, c, d;
        cin >> a >> b >> c >> d;
        a--;
        b--;
        c--;
        d--;
        tmp1 = b-a+1+A[b+1]-A[a];
        //cout << A[b+1] << " "  << A[a] << endl;
        tmp2 = d-c+1+B[d+1]-B[c];
        //cout << B[d+1] << " "  << B[c] << endl;
        //cout << tmp1 << " " << tmp2 << endl;
        tmp = abs(tmp1-tmp2);
        if(tmp%3==0) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 5068
#include "bits/stdc++.h"
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2151&lang=jp
using namespace std;
typedef long long ll;
#define INF 1<<30
#define LINF 1LL<<62

struct edge {
	int from, to;
	int dist, cost;
	edge() {}
	edge(int from, int to, int dist, int cost) :from(from), to(to), dist(dist), cost(cost) {}
};

int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	ll N, M, L;
	while (cin >> N >> M >> L, N | M | L) {
		vector<vector<edge>> G(N);
		for (int i = 0; i < M;i++) {
			ll A, B, D, E; cin >> A >> B >> D >> E;
			A--; B--;
			G[A].push_back(edge(A, B, D, E));
			G[B].push_back(edge(B, A, D, E));
		}

		/*                         hotel          balance */
		vector<vector<ll>> Assasin(N, vector<ll>(L + 1, INF));
		/*             hotel, balance*/
		using Key = tuple<ll, ll>;
		queue<Key> q;
		q.push(Key(0, L));
		Assasin[0][L] = 0;
		while (!q.empty()) {
			ll hotel, balance;
			tie(hotel, balance) = q.front(); q.pop();
			//cout << hotel << " " << balance << endl;
			for (auto e : G[hotel]) {
				if (e.dist <= balance) {
					if (Assasin[e.to][balance - e.dist] > Assasin[hotel][balance]) {
						Assasin[e.to][balance - e.dist] = Assasin[hotel][balance];
						q.push(Key(e.to, balance - e.dist));
					}
				}
				if (Assasin[e.to][balance] > Assasin[hotel][balance] + e.cost) {
					Assasin[e.to][balance] = Assasin[hotel][balance] + e.cost;
					q.push(Key(e.to, balance));
				}
			}
		}
		ll Ans = INF;
		for (int i = 0; i <= L;i++) {
			Ans = min(Ans, Assasin[N - 1][i]);
		}
		cout << Ans << endl;
	}
}

Measured memory_bytes: 3408
import sys
input = sys.stdin.readline
n = int(input())
w = list(map(int, input().split()))

ans = float('inf')
for i in range(n):
    s1 = sum(w[:i+1])
    s2 = sum(w[i+1:])
    dif = abs(s1 - s2)
    if ans > dif:
        ans = dif
print(ans)

Measured memory_bytes: 3064
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

class Main {

	static List<Long> orthometric = new LinkedList<Long>();
	static Map<Long,List<Integer>> seaLevel = new TreeMap<Long,List<Integer>>();

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)){
			int len = sc.nextInt();
			long now = 0l;
			for (int i=0; i<len; i++) {
				long a = sc.nextLong();
				if (a != now) {
					orthometric.add(a);
					if (!seaLevel.containsKey(a)) {
						List<Integer> list = new LinkedList<Integer>();
						list.add(orthometric.size()-1);
						seaLevel.put(a, list);
					} else seaLevel.get(a).add(orthometric.size()-1);
					now = a;
				}
			}
			if (orthometric.size()>0) {
				int max = findLand();
				System.out.println(max);
			} else System.out.println("0");  //全部0だったら
		}
	}

	public static int findLand() {
		int max = 0;
		Long[] oArray = new Long[orthometric.size()];
		orthometric.toArray(oArray);
		int count = 1;
		for (List<Integer> l : seaLevel.values()) {
			for (int i : l) {
				if ((i!=0)&&(i!=oArray.length-1)) {
					if ((oArray[i-1]!=-1)&&(oArray[i+1]!=-1)) count++;
					else if ((oArray[i-1]==-1)&&(oArray[i+1]==-1)) count--;
				} else if ((i==0)&&(i!=oArray.length-1)) {
					if (oArray[i+1]==-1) count--;
				} else if ((i!=0)&&(i==oArray.length-1)) {
					if (oArray[i-1]==-1) count--; 
				}
				oArray[i] = -1l;
			}
			max = Math.max(max, count);
		}
		return max;
	}
}


Measured memory_bytes: 84804
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_LOG_MAX		200000									// 最大丸太数

// 内部変数
static FILE *szpFpI;											// 入力
static int si1Log[D_LOG_MAX];									// 丸太
static int siLCnt;												// 丸太数

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
	static int siTNo;
#endif

// １行出力
int
fOutLine(
	char *pcpLine				// <I> １行
)
{
	char lc1Buf[1024];

#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, pcpLine)) {
		siRes = -1;
	}
#else
	printf("%s", pcpLine);
#endif

	return 0;
}

// 最大値 - 取得
int
fGetMaxI(
	int piVal1					// <I> 値１
	, int piVal2				// <I> 値２
)
{
	if (piVal1 > piVal2) {
		return piVal1;
	}
	else {
		return piVal2;
	}
}

// カット回数 - 取得
long long
fGetCCnt(
	int piLen					// <I> 丸太長さ
)
{
	int i;

	long long llCCnt = 0;
	for (i = 0; i < siLCnt; i++) {
		llCCnt += si1Log[i] / piLen;
		if (si1Log[i] % piLen == 0) {
			llCCnt--;
		}
	}

	return llCCnt;
}

// 実行メイン
int
fMain(
)
{
	int i;
	char lc1Buf[1024];

	// 丸太数・最大カット回数 - 取得
	long long llMCnt;
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%d%lld", &siLCnt, &llMCnt);

	// 丸太 - 取得
	int liMax = 0;
	for (i = 0; i < siLCnt; i++) {
		fscanf(szpFpI, "%d", &si1Log[i]);
		liMax = fGetMaxI(liMax, si1Log[i]);
	}
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);

	// 範囲を絞る
	int liMin = 1;
	int liLen = liMax;
	while (liMin <= liMax) {
		int liAvg = (liMin + liMax) / 2;

		// カット回数 - 取得
		long long llCCnt = fGetCCnt(liAvg);
		if (llCCnt > llMCnt) {
			liMin = liAvg + 1;
		}
		else {
			liMax = liAvg - 1;
			liLen = liAvg;
		}
	}

	return liLen;
}

// １回実行
int
fOne(
)
{
	int liRet;
	char lc1Buf[1024];

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", siTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", siTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 実行メイン
	liRet = fMain();

	// 出力
	if (liRet == 0) {
		sprintf(lc1Buf, "Yes\n");
	}
	else {
		sprintf(lc1Buf, "No\n");
	}
	sprintf(lc1Buf, "%d\n", liRet);
	fOutLine(lc1Buf);

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", siTNo);
	}
	else {
		printf("NG %d\n", siTNo);
	}
#endif

	return 0;
}

// プログラム開始
int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		siTNo = i;
		fOne();
	}
#else
	fOne();
#endif

	return 0;
}



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

void chmax(int&a, int b) {
  if (a < b) a = b;
}

int main() {
  int H, W;
  cin >> H >> W;
  
  char c[2010][2010];
  int column[2010][2010] = {0}, row[2010][2010] = {0};
  
  for (int i = 1; i <= H; i++) {
    for (int j = 1; j <= W; j++) {
      cin >> c[i][j];
    }
    c[i][W+1] = '#';
  }
  
  for (int j = 1; j <= W; j++){
    c[H+1][j] = '#';
  } 
  
  // column 作成
  for (int i = 1; i <= H; i++) { // 各行に対して
    int ind = 1;
    int count = 0;
    for (int j = 1; j<=W+1; j++) {
       if (c[i][j] =='.') {
         count++;
         continue;
       } else {
         while(ind < j) {
           column[i][ind] = count;
           ind++;
         }
         ind++;
         count = 0;
       }
    }
  } 
  

  // row 作成
  for (int j = 1; j <= W; j++) { // 各列に対して
    
    int ind = 1;
    int count = 0;
    for (int i = 1; i<= H+1; i++) {
       if (c[i][j] =='.') {
         count++;
         continue;
       } else {
         while(ind < i) {
           row[ind][j] = count;
           ind++;
         }
         ind++;
         count = 0;
       }
    }
  } 

    

  
  // それぞれのマスでいくつ照るのかチェック
  int ans = 0;
  for (int i = 1; i <= H; i++) {
    for (int j = 1; j<= W; j++) {
      if (c[i][j] == '.') {
        chmax(ans, row[i][j] + column[i][j]-1);
      }
    }
  }
  
  cout << ans << endl;
}

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




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

int n;
cin >> n;
vector<tuple<string,int,int>> a;

for(int i = 1;i <= n;++i){
    string s;
    int p;
    cin >> s >> p;
    p *= -1;
    a.push_back(tie(s,p,i));
}

sort(all(a));
for(int i = 1;i <= n;++i) cout << get<2>(a[i-1]) << endl;




return 0;
}

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

#define ll long long

#define all(a) (a).begin(),(a).end()
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m) for(int i=(int)(n);i<=(int)(m);i++)
#define output_s(a) printf("%s\n",(a).c_str())

//library----------------------------------------------


int main(){
    int n;cin>>n;
    printf("%d\n",n*n*n);
    return 0;
}

Measured memory_bytes: 256
n=int(input())
p=[int(x) for x in input().split()]
count=0
b=2
while b<n:
    x=min(p[b],p[b-1],p[b-2])
    y=max(p[b],p[b-1],p[b-2])
    if p[b-1]!=x and p[b-1]!=y:
        count+=1
    b+=1
print(count)

Measured memory_bytes: 3064
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
#define INF (1ll<<60)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;

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

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

using namespace std;

// gcd
int gcd(int a, int b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}
// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);

    return result;
}

// sort big to small
// sort(A,A+N, greater<int>());

// v.front() = -BOUND;
// v.back() = BOUND;

// Iterator
// v.begin
// v.end

int main() {
    int A,B,C;
    cin >> A >> B>>C;
    cout << A*B/2 <<endl;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<queue>
#include<deque>
#include<vector>
#include<cstring>
using namespace std;
long long modpow(long long a, long long n, long long mod);
long long modinv(long long a, long long mod);
int main() {

	//A
	/*int n;
	cin >> n;
	if (n >= 30) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
	*/

	//B
	/*int n;
	int i;
	int counter = 0;
	long long int x, y;
	long long int d;
	cin >> n >> d;
	for (i = 0; i < n; i++) {
		cin >> x >> y;
		if (x * x + y * y <= d * d)counter++;
	}
	cout << counter << endl;
	return 0;
	*/

	//C
	/*int k;
	cin >> k;

	if (7 % k == 0) {
		cout << 1 << endl;
		return 0;
	}
	if (k % 7 == 0)k = k / 7;
	if (k % 2 == 0 || k % 5 == 0) {
		cout << -1 << endl;
		return 0;
	}
	if (k == 3) {
		cout << 3 << endl;
		return 0;
	}
	else if (k == 9) {
		cout << 9 << endl;
		return 0;
	}


	int i = 0;
	int j = 1;
	while (1) {
		i++;
		j = j * 10;
		j = j % k;
		if (j == 1) {
			if (k % 9 == 0) {
				i = i * 9;
			}
			else if (k % 3 == 0) {
				i = i * 3;
			}
			cout << i << endl;
			return 0;
		}

	}*/

	//D
	/*int n;
	string c;
	cin >> n;
	cin >> c;
	int sum = 0;
	int i, j;
	int s = 0;
	i = 0; j = n - 1;
	while (i < j) {
		if (c[i] == 'W') {
			if (c[j] == 'R') {
				c[i] = 'R';
				c[j] = 'W';
				i++;
				j--;
				sum++;
			}
			else {
				while (c[j] != 'R') {
					j--;
					if (j < 0 || j <= i) {
						cout << sum << endl;
						return 0;
					}
				}
				c[i] = 'R';
				c[j] = 'W';
				i++;
				j--;
				sum++;
			}
		}
		else {
			while (c[i] != 'W') {
				i++;
				if (i >= n || i >= j) {
					cout << sum << endl;
					return 0;
				}
			}
			if (c[j] == 'R') {
				c[i] = 'R';
				c[j] = 'W';
				i++;
				j--;
				sum++;
			}
			else {
				while (c[j] != 'R') {
					j--;
					if (j < 0 || j <= i) {
						cout << sum << endl;
						return 0;
					}
				}
				c[i] = 'R';
				c[j] = 'W';
				i++;
				j--;
				sum++;
			}
		}
	}

	cout << sum << endl;
	return 0;
	*/

	//E
	//二分探索
	int n, k;
	cin >> n >> k;
	int a[200000];
	int i;
	for (i = 0; i < n; i++) {
		cin >> a[i];
	}
	int sum = 0;
	int left = 0, right = 1000000000, mid = (int)((right + left) / 2);
	while (right - left > 1) {
		sum = 0;
		for (i = 0; i < n; i++) {
			sum = sum + (int)(a[i] / mid);
			if (a[i] % mid == 0)sum--;
		}
		if (sum <= k) {
			right = mid;
		}
		else {
			left = mid;
		}
		mid = (int)((right + left) / 2);
		

	}
	cout << right << endl;
	return 0;
	
	return 0;


}

// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

// a^{-1} mod を計算する
long long modinv(long long a, long long mod) {
	return modpow(a, mod - 2, mod);
}


Measured memory_bytes: 4372
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <cstring>
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef unsigned long long ll;


int main(){
ll N,K; cin >> N >> K;
ll a,b,ans;
a = N / K;
b = N % K;

if(b == 0 || b == 1){
	ans = b;
}
else{
	ll c = (K * (a+1)) - N;
	ans = min(c,b);
	
}
	cout << ans  << endl;
}

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

int main() {
  int N;
  cin >> N;
  
  for (int i = 0; i < N; i++) {
    string C;
    cin >> C;
    
    if (C == "Y") {
      cout << "Four" << endl;
      break;
    }
    if (i + 1 == N) {
      cout << "Three" << endl;
    }
    
  }
  
}

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

typedef long long ll;
#define repd(i,a,b) for (ll i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)

ll mod=1e9+7;

using namespace std;


ll inputValue(){
	ll a;
	cin >> a;
	return a;
};

void inputArray(int * p, ll a){
	rep(i, a){
		cin >> p[i];
	}
};

template<typename T>
void inputVector(vector<T>& p, ll a){
	rep(i, a){
		T input;
		cin >> input;
		p.emplace_back(input);
	}
}


template <typename T>
void output(T a) {
    cout << a << "\n";
}

int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
	// source code
    
    ll n;
    vector<ll> w;
    ll s1,s2;
    ll diff=mod;
    cin >> n;
    inputVector<ll>(w,n);
    
    for(ll t=0; t<n;t++){
        s1=accumulate(w.begin(),next(w.begin(),t),0LL);
        s2=accumulate(next(w.begin(),t),w.end(),0LL);
        diff=min<ll>(abs<ll>(s1-s2),diff);
    }

    cout << diff << endl;

	return 0;
}


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

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


Measured memory_bytes: 3100
#include <iostream>
#include <vector>
template <class T> using vector_t = std::vector<T>;
 
int main() {
	int N,M,a,b;
	std::cin>>N>>M;
	vector_t<int> bs(N+1,N+1);
	for(int i=0;i<M;++i)
	{
		std::cin>>a>>b;
        if(bs[a]>b)bs[a]=b;
	}
	int count=0;
	int minb=N+1;
	for(int i=0;i<N;++i){
		if(minb==i)
		{
			++count;
			minb=bs[i];
		}else if(minb>bs[i])
			minb=bs[i];
	}
	if(minb!=N+1)
		++count;
	std::cout<<count<<std::endl;
 
	return 0;
}

Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <memory>
#include <string>

#include <algorithm>
#include <complex>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#include <bitset>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
#define strtok_r strtok_s
#endif

#define ITER(c)             __typeof__((c).begin())
#define FOREACH(it, c)      for (ITER(c) it=(c).begin(); it != (c).end(); ++it)
#define RITER(c)            __typeof__((c).rbegin())
#define RFOREACH(it, c)     for (RITER(c) it=(c).rbegin(); it != (c).rend(); ++it)
#define REP(i, n)           REPEAT(i, 0, n)
#define RREP(i, n)          RREPEAT(i, 0, n);
#define REPEAT(i, k, n)     for(int i = (k); i < (k+n); ++i)
#define RREPEAT(i, k, n)    for(int i = (k)+(n)-1; i >= (k); ++i)
#define ALL(c)              (c).begin(), (c).end()
#define LLPOW(p1,p2)        ((ll)pow((double)(p1), (int)p2))
#define ESIZEOF(A)          (sizeof(A)/sizeof((A)[0]))
#define MIN(p1,p2)          (((p1)<(p2))?(p1):(p2))
#define MAX(p1,p2)          (((p1)>(p2))?(p1):(p2))
#define CIN_NO_SYNC         do { cin.tie(0); ios_base::sync_with_stdio(false); } while(0)
#define GETSTR(p)           fgets((p), sizeof(p), stdin)
#define CHOMP(p)            do{ char *_q = (p) + strlen(p)-1; if(*_q == '\n' || *_q == '\r') *_q = 0; } while(0)
#define mp                  make_pair
#define pb                  push_back

typedef long long ll;
typedef unsigned long long ull;

#define X real()
#define Y imag()
typedef double D;
typedef complex<D> P;
#define EPS (1e-9)

#ifdef _DEBUG
#define pf printf
#define pr(n) do { cout << #n " = " << (n) << endl; } while(0)
#else
#define pf(...) /* */
#define pr(...) /* */
#endif

void solve(vector< vector<int> > &vvi){
    int h = vvi.size();
    int w = (h+1)/2;
    pr(w);
    pr(h);

    REP(i,w-1){
        vector<int> v1(vvi[i+1].size());
        vector<int> v2(vvi[h-i-2].size());
        REP(j,i+1){
            v1[j+0] = MAX(v1[j+0], vvi[i][j]);
            v1[j+1] = MAX(v1[j+1], vvi[i][j]);
            v2[j+0] = MAX(v2[j+0], vvi[h-i-1][j]);
            v2[j+1] = MAX(v2[j+1], vvi[h-i-1][j]);
        }
        REP(j,vvi[i+1].size()){
            vvi[i+1][j] += v1[j];
            vvi[h-i-2][j] += v2[j];
        }
    }
    int max = 0;
    REP(i,vvi[w-1].size()){
        max = MAX(max, vvi[w-1][i]);
    }
    cout << max << endl;
}

int main(){
    string s;
    vector< vector<int> > vvi;
    while(getline(cin,s)){
        FOREACH(it, s){
            if(*it == ',') *it = ' ';
        }
        stringstream ss(s);
        vector<int> vi;
        int n;
        while(ss >> n) vi.pb(n);
        vvi.pb(vi);
    }

    solve(vvi);
    return 0;
}

Measured memory_bytes: 1268
import java.lang.reflect.Array;
import java.util.*;
import java.io.*;
import java.lang.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        int[] arr = {a,b,c};
        Arrays.sort(arr);

        if ((arr[0]==arr[1] && arr[0]!=arr[2]) || (arr[1]==arr[2] && arr[0]!=arr[1]))
            System.out.println("Yes");
        else
            System.out.println("No");

    }
}


Measured memory_bytes: 35444
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin >> n >> m;
  int a[n],b[n],c[m],d[m];
  for(int i=0; i<n; i++){
    cin >> a[i] >> b[i];
  }
  for(int i=0; i<m; i++){
    cin >> c[i] >> d[i];
  }
  int shu;
  for(int i=0; i<n; i++){
    long long int man = 9999999999;
    for(int j=0; j<m; j++){
      if(man > abs(a[i]-c[j])+abs(b[i]-d[j])){
        man = abs(a[i]-c[j])+abs(b[i]-d[j]);
        shu = j;
      }
    }
    cout << shu+1 << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

const ll INF = 1e17;
// https://atcoder.jp/contests/abc143/submissions/8034843

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

    if (A < 1 || 9 < A) 
    {
      cout << -1 << endl;
      return 0;
    }
    if (B < 1 || 9 < B)
    {
      cout << -1 << endl;
      return 0;
    }    

    cout << A*B << endl;

    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;

#define PrintLn(X) cout << X << endl
#define Rep(i, n) for(int i = 0; i < (int)(n); ++i)

int x[100000] = {0};
int main(void)
{
	int N, M;
	cin >> N >> M;
	Rep(i, M){
		int a, b;
		cin >> a >> b;
		x[a - 1]++;
		x[b - 1]++;
	}
	Rep(i, N){
		if(x[i] % 2){
			PrintLn("NO");
			return 0;
		}
	}
	PrintLn("YES");
	return 0;
}


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

void elim(vector<int> *tmp,int cnt){
  vector<int>::iterator ite=tmp->begin();
  for(int i=0;i<cnt;i++){
    ite++;
  }
  tmp->erase(ite);
}

int main(){
  int n;
  while(cin>>n){
    if(n==0)break;
    int tmp;
    vector<int> a,b;
    for(int i=0;i<n;i++){
      cin>>tmp;
      a.push_back(tmp);
    }
    sort(a.begin(),a.end());
    int cnt=0;
    for(int i=1;i<=2*n;i++){
      if(a[cnt]!=i){
	b.push_back(i);
      }else{
	cnt++;
      }
    }
    int num=0;
    bool flg=false;
    while(a.empty()!=true && 
	  b.empty()!=true){
      cnt=0;
      for(int i:a){
	if(i>num){
	  num=i;
	  //cout << "a :"<< i << endl;
	  elim(&a,cnt);
	  flg=true;
	  break;
	}
	cnt++;
      }
      if(flg==false)num=0;
      if(a.size()==0)break;
      flg=false;
      cnt=0;
      for(int i: b){
	if(i>num){
	  num=i;
	  //cout << "b :"<< i << endl;
	  elim(&b,cnt);
	  flg=true;
	  break;
	}
	cnt++;
      }
      if(flg==false)num=0;
      flg=false;
    } 
    // for(int i:a)cout << i<<" ";
    // cout << endl;
    // for(int i:b)cout << i<<" ";
    // cout << endl;
    cout << b.size() << endl;
    cout << a.size() << endl;
  }
  return 0;
}

Measured memory_bytes: 1212
#include<iostream>
using namespace std;
int main()
{
  int a,b;
  cin>>a>>b;
  a=(a+11)%13;
  b=(b+11)%13;
  if(a>b)
    cout<<"Alice";
  if(a==b)
    cout<<"Draw";
  if(a<b)
    cout<<"Bob";
  system ("pause"); 
  return 0;
} 

Measured memory_bytes: 504
#include <bits/stdc++.h>
#include <unordered_map>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll A,B;
    cin >> A >> B;
    string S;
    cin >> S;
    if(S[A] == '-'){
        bool ok = true;
        rep(i,0,A+B+1){
            if(i == A) continue;
            if(S[i] == '-') ok = false;
        }
        if(ok){
            print("Yes");
            return 0;
        }
    }
    print("No");

}

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


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int[] abc = new int[3];
		for (int i = 0; i < 3; i++) {
			abc[i] = sc.nextInt();
		}
		Arrays.sort(abc);

		int k = sc.nextInt();

		abc[2] <<= k;

		pr.println(abc[2] + abc[1] + abc[0]);
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(INPUT == null ? System.in : new ByteArrayInputStream(INPUT.getBytes()));
		pr = new Printer(System.out);

		solve();

//		pr.close();
		pr.flush();
//		sc.close();
	}

	static String INPUT = null;

	private static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 23636
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
int stack[20001];
int sp = 0;
 
int main(void) {
    char temp[20010];
    int i, j, len, c, t;
    scanf("%s", temp);
    len = strlen(temp);
    for (i = 0; i < len; i++) {
        switch (temp[i]) {
        case '\\':
            stack[sp] = -i;
            sp++;
            break;
        case '/':
            c = 0;
            for (j = sp - 1; j >= 0; j--) {
                if (stack[j] > 0) {
                    c += stack[j];
                } else {
                    c += i + stack[j];
                    break;
                }
            }
            if (j >= 0) {
                stack[j] = c;
                sp = j + 1;
            }
            break;
        }
    }
    c = 0;
    t = 0;
    for (i = 0; i < sp; i++) {
        if (stack[i] > 0) {
            t += stack[i];
            c++;
        }
    }
    printf("%d\n%d", t, c);
    for (i = 0; i < sp; i++) {
        if (stack[i] > 0) {
            printf(" %d", stack[i]);
        }
    }
    puts("");
    return 0;
}



Measured memory_bytes: 2148
from sys import stdin

INFTY = 1 << 21
WHITE = 0
GRAY = 1
BLACK = 2

n = int(stdin.readline())
M = [[INFTY for i in range(n)] for j in range(n)]

for u in range(n):
    U = list(map(int, stdin.readline().split()[2:]))
    for j in range(0, len(U), 2):
        M[u][U[j]] = U[j+1]

d = [INFTY for i in range(n)]
color = [WHITE for i in range(n)]

def dijkstra():
    global n
    d[0] = 0
    color[0] = GRAY
    while(1):
        minv = INFTY
        u = -1
        for i in range(n):
            if (minv > d[i] and color[i] != BLACK):
                u = i
                minv = d[i]
        if (u == -1):
            break
        color[u] = BLACK
        for v in range(n):
            if (color[v] != BLACK and M[u][v] != INFTY):
                if(d[v] > d[u] + M[u][v]):
                    d[v] = d[u] + M[u][v]
                    color[v] = GRAY
    for i in range(
n):
        print(i, (-1 if d[i] == INFTY else d[i]))
dijkstra()

Measured memory_bytes: 5884