akhauriyash/Code-Regression huggingface dataset:
// https://atcoder.jp/contests/abc129/tasks/abc129_e
//
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

#[allow(unused_macros)]
macro_rules! dvec {
    ($t:expr ; $len:expr) => {
        vec![$t; $len]
    };

    ($t:expr ; $len:expr, $($rest:expr),*) => {
        vec![dvec!($t; $($rest),*); $len]
    };
}

#[allow(unused_macros)]
macro_rules! ifv {
    ($t:expr, $a:expr, $b: expr) => {
        if $t { $a } else { $b }
    }
}

#[allow(unused_macros)]
macro_rules! fill {
    ($t:expr, $v:expr) => {
        for i in 0..$t.len() {
            $t[i] = $v;
        }
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

const MOD: i64 = 1e9 as i64 + 7;

fn main() {
    input! {
        l: chars
    };
    let mut l = l;
    l.reverse();
    let n = l.len();
    let mut dp = dvec!(0; n+1, 2);
    dp[n][0] = 1;
    for i in (1..n+1).rev() {
        for f in 0..2 {
            let base = dp[i][f];
            if base == 0 {
                continue;
            }
            for a in 0..2 {
                for b in 0..2 {
                    if a + b == 2 {
                        continue;
                    }
                    if f == 0 && a + b == 1 && l[i-1] == '0' {
                        continue;
                    }
                    let mut tf = f;
                    if a + b == 0 && l[i-1] == '1' {
                        tf = 1;
                    }
                    dp[i-1][tf] += base;
                    dp[i-1][tf] %= MOD;
                }
            }
        }
    }
    // debug!(dp);

    println!("{}", (dp[0][0] + dp[0][1]) % MOD);
}


Measured memory_bytes: 10492
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<queue>
#include<time.h>
using namespace std;
int main()
{
long long int a,b,x;
scanf("%lld%lld%lld",&a,&b,&x);
long long int s=(b/x-a/x);
if(a%x==0)s++;
printf("%lld\n",s);
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//List<String> list= new ArrayList<String>(Arrays.asList(s.split("")));
		//List<Integer> list=new ArrayList<Integer>();
		//Integer[] array = new Integer[m];
		int n = sc.nextInt();
		int count=0;
		if(n<105) {
			System.out.println(0);
			System.exit(0);
		}
		else {
			for(int i=105;n+1>i;i=i+2) {
				int how =0;
				for(int j=1;i+1>j;j++) {
					if(i%j==0)
						how++;
				}
				if(how==8) {
					count++;
				}
				//System.out.println(how);
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 23508
A = int(input())
B = int(input())

if A == 1:
    if B == 2:
        print(3)
    if B == 3:
        print(2)

if A == 2:
    if B == 1:
        print(3)
    if B == 3:
        print(1)

if A == 3:
    if B == 1:
        print(2)
    if B == 2:
        print(1)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){int k,n,d,ok=1,i;
cin>>n;
int t[n+1],x[n+1],y[n+1];
t[0]=x[0]=y[0]=0;
for(i=1;i<=n;i++){cin>>t[i];
    cin>>x[i];
    cin>>y[i];
}
        for(i=1;i<=n;i++){
            k=t[i]-t[i-1];
            d=abs(x[i]-x[i-1])+abs(y[i]-y[i-1]);
            if(d>k||d%2!=k%2)ok=0;
        }
        if(ok){cout<<"Yes";}
        else{cout<<"No";}
    return 0;}

Measured memory_bytes: 4704
#include <iostream>
#include <iomanip>
#include <string>
#include <unordered_map>
#include <cmath>
#include <algorithm>

typedef long long ll;
typedef long double ld;

using namespace std;
int main()
{
  ll n, k, s = 0;
  cin >> n >> k;
  while (n >= (ll)pow(k, s)) ++s;
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  ll N, M, S=0;
  cin >> N >> M;
  vector<ll> A(N);
  multimap<ll, ll> mp;
  for(int i=0;i<N;i++) std::cin >> A[i];
  for(int i=1;i<N;i++){
    S+=A[i]-A[i-1] + (A[i]>A[i-1]?0:M);
    mp.emplace((A[i-1]==M-1?M:A[i-1]+1), 1);
    mp.emplace(A[i], -(A[i]-(A[i-1]+1)+M)%M);
  }
  ll now = 0, ma = 0, num = 0;
  for(int i=1;i<N;i++){
    ll a = A[i]-A[i-1]+(A[i]>A[i-1]?0:M);
    ll b = A[i];
    if(a >= b) ma += a - b, num++;
  }
  //std::cout << ma << " " << num << '\n';
  auto itr = mp.begin();
  for(int i=1;i<=M;i++){
    if(i!=1) now += num;
    else now = ma;
    ma = max(ma, now);
    //std::cout << now << " " << ma << '\n';
    while(itr!=mp.end()&&(*itr).first==i){
      if((*itr).second==1) num++;
      else now += (*itr).second, num--;
      itr++;
    }
  }
  std::cout << S - ma << '\n';
  return 0;
}


Measured memory_bytes: 13568
#include<bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;

#define FOR(i,a,b) for (int i = a; i < b; ++i)
#define FORR(i,a,b) for (int i = b - 1; i >= a; --i)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) FORR(i,0,n)

int K;

int main() {
  scanf("%d", &K);
  int even, odd;
  even = K / 2;
  if (K % 2 == 0) odd = even;
  else odd = even + 1;
  printf("%d\n", even * odd);
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**6)
INF = 10 ** 9 + 1  # sys.maxsize # float("inf")
MOD = 10 ** 9 + 7


def debug(*x):
    print(*x, file=sys.stderr)


def solve(N):
    ret = N - 1
    for i in range(2, N + 1):
        ret += (N - 1) // i
    return ret


def main():
    # parse input
    N = int(input())
    print(solve(N))


# tests
T1 = """
3
"""
TEST_T1 = """
>>> as_input(T1)
>>> main()
3
"""

T2 = """
100
"""
TEST_T2 = """
>>> as_input(T2)
>>> main()
473
"""

T3 = """
1000000
"""
TEST_T3 = """
>>> as_input(T3)
>>> main()
13969985
"""


def _test():
    import doctest
    doctest.testmod()
    g = globals()
    for k in sorted(g):
        if k.startswith("TEST_"):
            doctest.run_docstring_examples(g[k], g, name=k)


def as_input(s):
    "use in test, use given string as input file"
    import io
    f = io.StringIO(s.strip())
    g = globals()
    g["input"] = lambda: bytes(f.readline(), "ascii")
    g["read"] = lambda: bytes(f.read(), "ascii")


input = sys.stdin.buffer.readline
read = sys.stdin.buffer.read

if sys.argv[-1] == "-t":
    print("testing")
    _test()
    sys.exit()

main()


Measured memory_bytes: 62972
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (1e9)
#define INFL (1e18)
 
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template<class T>using arr=vector<vector<T>>;
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} cout << a[a.size()-1] << endl;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
 
int main()
{
    ll n, k; cin >> n >> k;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    rep(i, n) a[i]--;
    ll cnt=0;
    ll pos=0;
    vector<ll> seen(n, -1);
    ll prd;
    while(1){
        if(seen[pos]>0){
           prd = cnt - seen[pos];
           k -= seen[pos];
           k %= prd;
           rep(i, k) pos = a[pos];
           pr(pos+1);
           return 0;
        }
        if(cnt==k){
            pr(pos+1);
            return 0;
        }
        seen[pos] = cnt;
        pos = a[pos];
        cnt++;
    }
    return 0;}

Measured memory_bytes: 6424
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;

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

	ll n, a, b;
	cin >> n >> a >> b;

	if((b - a) % 2 == 0){
		cout << (b - a) / 2 << endl;
	}else{
		ll ans = a + (b - a - 1) / 2;
		ans = min(ans, n - b + 1 + (n - (a + n - b + 1)) / 2);
		cout << ans << endl;
	}
}


Measured memory_bytes: 256
#include <stdio.h>
int I[101],J[101][101];
int main(){
  int i,j,k,n,l,p,seki;

  scanf("%d",&n);
  /*
  for(i=1;i <=n;i++){
    J[i][i]=0;
    }*/

  for(i=1; i <=n ;i++){
    scanf("%d %d",&I[i-1],&I[i]);
  }

  for(i=1;i <=n;i++){
    J[i][i]=0;
  }
  
  
  for(k=2; k <= n;k++){
    for(l=1; l <=n-k+1; l++){
      
      j=k+l-1;

      J[l][j]=(1<<19);

      for(p=l; p < j;p++){
        seki=J[l][p]+J[p+1][j]+ (I[l-1]*I[j]*I[p]);

        if(seki < J[l][j]){
          J[l][j]=seki;
        }
      }
    }
  }
        printf("%d",J[1][n]);
        printf("\n");
      
        return 0;
      }



Measured memory_bytes: 2044
#include <cstdio>
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <sstream>
#include <string.h>
#define ll long long
#define pb push_back
using namespace std;
int main(){
int a,b,c;
cin>>a>>b>>c;
if (b>=c-a and c-a>=0)
cout<<"YES";
else
cout<<"NO"; 
system ("pause");
return 0;
} 

Measured memory_bytes: 504
N, X = gets.chomp.split.map(&:to_i)
L = gets.chomp.split.map(&:to_i)

cnt = 0
d = 0
N.times do |i|
  if d <= X
    cnt += 1
  end
  # p "d[#{i}]: #{d}"
  d = d + L[i]
end
# p "d[#{N}]: #{d}"
  
if d <= X
  cnt += 1
end

p cnt


Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <cstdio>
#include <set>
#include <algorithm>
#include <cmath>
#define ll long long
using namespace std;
set <int> st;
    vector <ll> vec;
ll qkpow(ll x, ll n)
{
    ll res=1;
    while(n>0)
    {
        if(n&1)
            res=res*x;
        x=x*x;
        n>>=1;
    }
    return res;
}
int main(void)
{

    ll n,y;
    cin>>n>>y;
    ll a=10000,b=5000,c=1000;
    int i,j;
    for(i=0;i<=2000;i++)
    {
        for(j=0;j<=2000;j++)
        {
            if((a-c)*i+(b-c)*j+c*n==y&&n-i-j>=0)
            {
                cout<<i<<" "<<j<<" "<<n-i-j<<endl;
                return 0;
            }
        }
    }
    cout<<"-1 -1 -1"<<endl;
    return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef int LL;
inline LL Read(){
	LL x(0),f(1); char c=getchar();
	while(c<'0' || c>'9'){
		if(c=='-') f=-1; c=getchar();
	}
	while(c>='0' && c<='9'){
		x=(x<<3)+(x<<1)+c-'0'; c=getchar();
	}return x*f;
}
LL T,n,ans;
int main(){
	n=Read();
	for(LL i=1;i<=n;++i){
		LL x(i),tot(0);
		while(x){
			x/=10; ++tot;
		}
		if(tot&1) ++ans;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
from sys import stderr
from math import ceil

a_takahashi_hp, b_takahashi_attack, c_aoki_hp, c_aoki_attack = map(int, input().split())

takahashi_died_turn_at = ceil(a_takahashi_hp / c_aoki_attack) * 2
aoki_died_turn_at = ceil(c_aoki_hp / b_takahashi_attack) * 2 - 1

print(takahashi_died_turn_at, aoki_died_turn_at, file=stderr)

print('Yes' if takahashi_died_turn_at > aoki_died_turn_at else 'No')


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

int main()
{
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int x = 1;
  while(a > 0 && c > 0)
  {
    if(x) c -= b;
    else a -= d;
    x^=1;
  }
  if(c <= 0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3596
a=input()
b=a.split()
c=input()
d=c.split()
N=int(b[0])
K=int(b[1])
p=[]
for i in range(len(d)):
    p.append(int(d[i]))
p.sort()
ans=0
for i in range(K):
    ans=ans+p[i]
print(ans)

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

#define fi       first
#define se       second
#define pf       printf
#define mp       make_pair
#define pb       push_back
#define si(x)    scanf("%d", &x)
#define pi(x)    printf("%d\n", x)
#define sl(x)    scanf("%lld", &x)
#define pl(x)    printf("%lld\n", x)
#define all(x)   x.begin(), x.end()
#define READ(f)  freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef map<ll, ll> mll;
typedef pair<ll, ll> pll;
typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef map<char, int> mci;
typedef map<char, char> mcc;
typedef pair<char, int> pci;
typedef unsigned long long ull;

const ll MAX = 100005;
const ll MOD = 1000000007;
const ll INF = 1000000000000000;
const double PI = 2 * acos(0.0);
const double EPS = 0.00000000001;

int main() {
    int n, t, x, y;
    si(n), si(t);

    int cost = INT_MAX;
    for (int i = 0; i < n; i++) {
        si(x), si(y);
        if (y <= t) cost = min(cost, x);
    }

    if (cost == INT_MAX) pf("TLE\n");
    else pi(cost);

    return 0;
}


Measured memory_bytes: 256
kingaku, n = input().split()
no_num = input().split()
ok_num = [str(i) for i in range(10) if not str(i) in no_num]
result = []
 
for i in kingaku:
    for j in ok_num:
        if i == j:
            result.append(j)
            break
        elif i < j:
            result.append(j)
            print("".join(result).ljust(len(kingaku), ok_num[0]))
            exit()
            break
    else:
        n = 1 if ok_num[0] == '0' else 0
        print(ok_num[n].ljust(len(kingaku)+1, ok_num[0]))
        exit()
 
print(''.join(result))

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

using namespace std;

void delete_edge(int parent, int target, vector<vector<int>> &child){
  int itr;
  for(itr = 0; itr < child[parent].size(); itr++){
    if(child[parent][itr] == target){
      break;
    }
  }
  child[parent].erase(child[parent].begin() + itr);
}

void make_tree(int parent, vector<vector<int>> &child){
  for(int i = 0; i < child[parent].size(); i++){
    int child_node = child[parent][i];
    delete_edge(child_node, parent, child);
    make_tree(child_node, child);
  }
}

void count(int parent, vector<int> &counter, vector<vector<int>> &child){
  int c = counter[parent];
  for(int i = 0; i < child[parent].size(); i++){
    int child_node = child[parent][i];
    counter[child_node] += c;
    count(child_node, counter, child);
  }
}    

int main(){
  int n, q;
  cin >> n >> q;
  
  vector<vector<int>> v_child(n);
  vector<int> v_counter(n, 0);
  
  for(int i = 0; i < n - 1; i++){
    int a, b;
    cin >> a >> b;
    v_child[a - 1].push_back(b - 1);
    v_child[b - 1].push_back(a - 1);
  }
  
  make_tree(0, v_child);
  
  for(int i = 0; i < q; i++){
    int p, x;
    cin >> p >> x;
    v_counter[p - 1] += x;
  }
  
  count(0, v_counter, v_child);
  
  for(int i = 0; i < n - 1; i++){
    cout << v_counter[i] << " ";
  }
  cout << v_counter[n - 1] << endl;
  
  return 0;
}


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


int main() {

    string a, b, c;
    cin >> a >> b >> c;
    if (a[a.length()-1] == b[0] && b[b.length()-1] == c[0]) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO.Pipes;
using System.Linq;
using System.Security.Cryptography;
using System.Text;

namespace cswork
{
    class Program
    {
        class Scanner
        {
            string[] s;
            int i;

            char[] cs = new char[] { ' ' };

            public Scanner()
            {
                s = new string[0];
                i = 0;
            }

            public string next()
            {
                if (i < s.Length) return s[i++];
                string st = Console.ReadLine();
                while (st == "") st = Console.ReadLine();

                s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
                i = 0;
                return next();
            }

            public int nextInt()
            {
                return int.Parse(next());
            }

            public long nextLong()
            {
                return long.Parse(next());
            }

            public double nextDouble()
            {
                return double.Parse(next());
            }
        }

        public Program() { }

        static void Main(string[] args)
        {
            new Program().Omame();
        }

        Scanner cin;
        const int MAXIN = 1024;
        bool[] used = new bool[MAXIN];
        int[] perm = new int[MAXIN];

        List<int[]> permList = new List<int[]>();

        public void Permutation(int pos, int n, int length)
        {
            if (pos == n)
            {
                permList.Add((int[])perm.Clone());
            }

            for (int i = 0; i < n; i++)
            {
                if (!used[i])
                {
                    perm[pos] = i;
                    used[i] = true;
                    Permutation(pos + 1, n, length);
                    used[i] = false;
                }
            }
        }

        void Omame()
        {
            cin = new Scanner();

            decimal A = Decimal.Parse(cin.next());
            decimal B = Decimal.Parse(cin.next());
            decimal ans = A * B;
            Console.WriteLine(Decimal.Floor(ans));
        }
    }
}


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

int n, a[1010100];

bool Solve(int x) {
  if(x > n) return 1;
  if(a[x] == x) return Solve(x + 1);
  int y = x;
  for(; y + 2 <= n; y += 2) {
    if(a[y + 1] != y + 1) break;
    if(a[y + 2] == y + 2) break;
  }

  int mi = 1e9, mx = 0;
  for(int i = x; i <= y; i++)
    mi = min(mi, a[i]), mx = max(mx, a[i]);
  if(mi != x || mx != y) return 0;

  vector<int> le, ri;
  for(int i = x; i <= y; i += 2) {
    if(a[i] > i) le.push_back(a[i]);
    else ri.push_back(a[i]);
  }
  for(int i = 1; i < le.size(); i++)
    if(le[i] < le[i - 1]) return 0;
  for(int i = 1; i < ri.size(); i++)
    if(ri[i] < ri[i - 1]) return 0;
  return Solve(y + 1);
}

int main(void) {
  scanf("%d", &n);
  for(int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  puts(Solve(1) ? "Yes" : "No");
}


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

int main(){
  int N;
  int a = 0, u = 0;

  cin>>N;

  for(int i = 0; i < N; i++){
    string s;

    cin>>s;

    if(s == "A") {
      a++;
    } else {
      u++;
    }

    if(a<u) {
      cout<<"NO"<<endl;
      return 0;
    }
  }

  if(a == u) {
    cout<<"YES"<<endl;
  } else {
    cout<<"NO"<<endl;
  }
}



Measured memory_bytes: 3152
/*
 * Distance2.c
 *
 *  Created on: 2015/02/13
 */
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void) {
	int N,n;
	int X[101],Y[101];
	double p;
	scanf("%d\n",&N);
	for(n=0;n<N;n++)
		scanf("%d",&X[n]);
	for(n=0;n<N;n++)
		scanf("%d",&Y[n]);

	p=0;
	for(n=0;n<N;n++) {
		p = p + abs(X[n]-Y[n]);
	}
	printf("%.6lf\n",p);

	p=0;
	for(n=0;n<N;n++) {
		p += (X[n]-Y[n])*(X[n]-Y[n]);
	}
	printf("%.6lf\n",sqrt(p));

	p=0;
	for(n=0;n<N;n++) {
		p = p + abs(X[n]-Y[n])*(X[n]-Y[n])*(X[n]-Y[n]);
	}
	printf("%.6lf\n",pow(p,((double)1.0/3)));

	p=0;
	for(n=0;n<N;n++) {
		double a = abs(X[n]-Y[n]);
		if (a>p)
			p=a;
	}
	printf("%.6lf\n",p);

	return 0;
}

Measured memory_bytes: 680
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define INF 999999999
#define rep(i,n) for(int i=0;i<n;i++)
const int MOD = 1000000007;
ll cnt =0,ans=0;
bool graph[8][8];
 
const int NUMBER_OF_SAMPLES = 100000000;
int main(){
    int n;  cin >> n;
    ll h[n];
    for(int i=0;i<n;i++){
        cin >> h[i] ;
    }

    int r,l;
    while(1){
        ll all=0;
        for(int i=0;i<n;i++){
            all += h[i];
        }
        if(all ==0){
            break;
        }

        for(int i=0;i<n;i++){
            if(h[i] != 0){
                l = i;
                for(int j=i;j<n;j++){
                    if(j == n-1 || h[j+1] == 0){
                        r = j ;
                        break;
                    }
                }break;
            }
        }

        //cout << l << " " << r << endl;
         cnt =INF;
        for(int i=l;i<=r;i++){
            cnt = min(cnt , h[i]);
        }
        for(int i=l;i<=r;i++){
            h[i] -= cnt;
        }
        ans+=cnt ;
        
        
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/reversed.hpp>
using namespace std;
constexpr char nl = '\n';
using ll = long long;
using boost::irange;
using boost::adaptors::reversed;
struct init_ { init_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } init_;

template<class C> auto operator>>(istream& in, C& c) -> typename enable_if<!is_void<decltype(c.begin())>::value && !is_same<C, string>::value, istream&>::type {
    for (auto& v : c) { in >> v; } return in; }
template<class C> auto operator<<(ostream& out, const C& c) -> typename enable_if<!is_void<decltype(c.begin())>::value && !is_same<C, string>::value, ostream&>::type {
    int i = 0; for (const auto& v : c) { if (i++) { out << ' '; } out << v; } return out; }
template<size_t N, class T, class R> using when_last = typename enable_if<N == tuple_size<remove_reference_t<T>>::value - 1, R>::type;
template<size_t N, class T, class R> using when_init = typename enable_if<N != tuple_size<remove_reference_t<T>>::value - 1, R>::type;
template<size_t N = 0, class T> auto operator>>(istream& in, T&& t) -> when_last<N, T, istream&> { return in >> get<N>(t); }
template<size_t N = 0, class T> auto operator>>(istream& in, T&& t) -> when_init<N, T, istream&> { return operator>><N + 1>(in >> get<N>(t), forward<T>(t)); }
template<size_t N = 0, class T> auto operator<<(ostream& out, const T& t) -> when_last<N, T, ostream&> { return out << get<N>(t); }
template<size_t N = 0, class T> auto operator<<(ostream& out, const T& t) -> when_init<N, T, ostream&> { return operator<<<N + 1>(out << get<N>(t) << ' ', t); }

#ifdef LOCAL
template<class T> void trace_(const char* s, const T& v) { cerr << s << "=" << v; }
template<class T, class... Ts> void trace_(const char* s, const T& v, const Ts&... vs) { for (; *s != ','; ++s) { cerr << *s; } cerr << "=" << v << ","; trace_(++s, vs...); }
#define TRACE(...) (cerr << "\033[2m\033[33m", trace_(#__VA_ARGS__, __VA_ARGS__), cerr << "\033[0m\n")
#else
#define TRACE(...)
#endif

constexpr int mod = 1e9+7;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    cin >> a;
    sort(a.begin(), a.end());
    for (int i : irange(0, n)) {
        int x = (n % 2 == 0) ? i / 2 * 2 + 1 : (i+1) / 2 * 2;
        TRACE(a[i], x);
        if (a[i] != x) {
            cout << 0 << nl;
            return 0;
        }
    }
    ll ans = 1;
    for (int i : irange(0, n / 2)) {
        ans *= 2;
        ans %= mod;
    }
    cout << ans << nl;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <utility>
#include <deque>
#include <stack>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<ll> vl;
typedef queue<int> qi;
typedef queue<ll> ql;
typedef pair<ll,ll> pll;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
#define rep(i,n) for (int i=0;i<n;i++)
#define mp make_pair
#define pb push_back
#define pf push_front
#define F first
#define S second
#define INF 200000009
double dp[305][305][305];
int n;
inline double dfs(int a,int b,int c){
	if (a==0&&b==0&&c==0) return 0;
	if (dp[a][b][c]>0) return dp[a][b][c];
	double res=1;
	if (a>0) res+=dfs(a-1,b,c)*a/n;
	if (b>0) res+=dfs(a+1,b-1,c)*b/n;
	if (c>0) res+=dfs(a,b+1,c-1)*c/n;
	if (a+b+c<n) res*=1.0*n/(a+b+c);
	return dp[a][b][c]=res;
}
int main(){
	ios::sync_with_stdio(false);
	cin>>n;
	int a=0,b=0,c=0;
	for (int i=1;i<=n;++i){
		int x;cin>>x;
		switch(x){
			case 1:++a;break;
			case 2:++b;break;
			case 3:++c;break;
		}
	}
	printf("%0.14lf",dfs(a,b,c));
	return 0; 
}

Measured memory_bytes: 219392
#include<bits/stdc++.h>
#define pb push_back
#define PI acos(-1)
#define mp make_pair
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define F first
#define sd(x) scanf("%d",&x)
#define sd2(x,y) scanf("%d%d",&x,&y)
#define sdl(x) scanf("%lld",&x)
#define sd2l(x,y) scanf("%lld%lld",&x,&y)
#define maxn 100010
#define S second
#define ll long long int
#define inf 1000002014
#define infl 1000000000000020000ll
#define mod 100000000
#define sz(x) (int) x.size()
#define pi pair< int,int >
#define pii pair<int,pi>
#define pu push
#define ld long double
#define ull unsigned long long int
#define trace1(x)  cerr << #x << ": " << x << endl
#define trace2(x, y)  cerr << #x << ": " << x << " | " << #y << ": " << y << endl
int main(int argc, char const *argv[])
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int n,x;
    sd(n);
    int ctr = 0;
    for (int i = 0; i < n; ++i)
    {
        sd(x);
        if(x%2==1)
            ++ctr;
    }
    if(ctr%2==0)
        puts("YES");
    else
        puts("NO");
    return 0;
}   

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

void Main() {
    // input
    u_int64_t N;
    cin >> N;

    int64_t ans = 1;
    int64_t mod = 1000000000 + 7;


    // process
    int64_t tmp1 = 2;
    int64_t tmp2 = 1;
    for(u_int64_t i = 0; i < N; i++) {
        ans *= 10;
        ans %= mod;
        tmp1 *= 9;
        tmp1 %= mod;
        tmp2 *= 8;
        tmp2 %= mod;
    }
    tmp1 = mod - tmp1;
    ans += tmp1;
    ans %= mod;
    ans += tmp2;
    ans %= mod;

    if (ans < 0) {
        ans *= -1;
    }

    // output
    cout << ans << endl;

}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <vector>
#include <numeric>
#include <math.h>
#include <set>

#define inf 1e15
#define sz 1e5
using ll = long long int;
using namespace std;

int main() {
int n;
cin>>n;
int count=0;
    for (int i = 1; i < n; ++i) {
        int a=(n-1)/i;
        count+=a;

    }
    cout<<count<<endl;


    return 0;
}

Measured memory_bytes: 3588
import java.util.Scanner;

public class Main
{
	public static void main(String[] args)
	{
		Scanner cin = new Scanner(System.in);
		
		int n,s;
		while(cin.hasNext())
		{
			s = 0;
			n = cin.nextInt();
			for(int i=n; i<600; i+=n)
			{
				s+=n*i*i;
			}
			System.out.println(s);
		}
	}
}

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

using namespace std;

int a[200005];

int main() {
	int n;
	scanf("%d", &n);
	
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	
	long long res = 0;
	int mx = 0;
	
	for (int i = 0; i < n; i++) {
		res += max(0, mx - a[i]);
		mx = max(mx, a[i]);
	}
	
	printf("%lld\n", res);
}


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

#define max 50

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

int main()
{
    int a, b, c, d;
    
    scanf("%d %d %d", &a, &b, &c);
    
    d=c-(a-b);
    
    if (d>=0) {
        printf("%d", d);
    } else {
        printf("%d", 0);
    }
    
    return 0;
}



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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N;
vint G[111111];
int par[111111];
int sum[111111];

void dfs(int v,int p){
    par[v]=p;
    sum[v]=1;
    for(auto u:G[v]){
        if(u==p)continue;
        dfs(u,v);
        sum[v]+=sum[u];
    }
}

signed main(){
    cin>>N;
    rep(i,N-1){
        int a,b;
        cin>>a>>b;
        a--;b--;
        G[a].pb(b);G[b].pb(a);
    }
    dfs(0,-1);

    vint lis;
    int cur=N-1;
    while(true){
        lis.pb(cur);
        if(cur==0)break;
        cur=par[cur];
    }

    vint A(lis.size());
    A[0]=sum[lis[0]];
    for(int i=1;i<lis.size();i++){
        A[i]=sum[lis[i]];
        A[i]-=sum[lis[i-1]];
    }

    reverse(all(A));

    int X=0,Y=0;
    rep(i,A.size()){
        if(i<(A.size()+1)/2)X+=A[i];
        else Y+=A[i];
    }

    if(X>Y)cout<<"Fennec"<<endl;
    else cout<<"Snuke"<<endl;
    return 0;
}


Measured memory_bytes: 13940
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
#include <iostream>
#include <math.h>
#define rep(i,n) for(int i = 0; i <(n); i++)
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;

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

int main(void) {
	int N, i, j, k, tmp, cnt = 0, ans = 0;
	bool flag1 = false,flag2 = false,flag3 = false;
	vector<int> p;
	scanf("%d",&N);
	rep(i, N) {
		scanf("%d", &tmp);
		p.push_back(tmp);
	}

	rep(i, N) {
		if (i + 1 != p.at(i)) {//違うとき
			if (!flag1) {//フラグおｋ
				flag1 = true;
			}
			else if (!flag2) {//おｋ
				flag2 = true;
			}
			else {//だめ
				flag1 = false;
				flag2 = false;
				flag3 = true;
				break;
			}
		}
	}
	if (flag1 == true && flag2 == true || flag3 == false) {
		printf("YES\n");
	}
	else {
		printf("NO\n");
	}

	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
ll factorial(int i) {       //階乗
    if (i == 0) return 1;
    return (factorial(i - 1)) * i;
}
int main() {
    int d;
    cin >> d;
    vector<int> c(26); //満足度の下がりやすさ
    rep(i, 26) cin >> c[i];
    vector<vector<int>> s(d, vector<int> (26)); //満足度の増減(たてが日時、よこがコンテストの種類)
    rep(i, d) {
        rep(j, 26) cin >> s[i][j];
    }
    vector<int> ans = {6,1,16,3,10,5,12,7,14,9,8,11,18,13,20,15,22,17,24,19,26,21,23,25,2,4};
    // cout << ans.size()<< endl;
    /*rep(i, 26) ans[i] = i + 1;
    rep(i, 26) {
        swap(ans[i], ans[i + 3]);
        cout << ans[0] << endl;
        ans.erase(remove(ans.begin(), ans.end(), ans[0]), ans.end());
    }*/
    rep(i, 365) cout << ans[i % 26] << endl;
    
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
#pragma gcc optimize("ofast")
using namespace std;

#define ll long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define mod 1000000007
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(int x=j;x<n;x++)
typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;

vvi g;
ll n,m;
vi dp;
vector<bool>vis;

void dfs(ll s)
{
    vis[s] = true;
    for(auto x:g[s])
    {
        if(!vis[x])dfs(x);
        dp[s] = max(dp[s],dp[x]+1);
    }
}
int main(){
    cin>>n>>m;
    vis = vector<bool>(n+1,false);
    dp = vi(n+1,0);
    g = vvi(n+1);
    rep(i,0,m)
    {
        ll u,v; cin>>u>>v;
        g[u].pb(v);
    }

    rep(i,1,n+1)
    {
        if(!vis[i])dfs(i);
    }
    cout<<*max_element(dp.begin(),dp.end())<<endl;

    return 0;
}


Measured memory_bytes: 8576
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <queue>
#include <iomanip>
using namespace std;
typedef long long ll;

int main() {
    int n, a[100010];
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];

    vector<int> ans;
    ans.push_back(2000000000);
    for (int i = 0; i < n; i++) {
        if (ans[ans.size() - 1] >= a[i]) {
            ans.push_back(a[i]);
        }
        else {
            int l = 0, r = ans.size();
            while (r - l > 1) {
                int mid = (l + r) / 2;
                if (ans[mid] >= a[i]) l = mid;
                else r = mid;
            }
            ans[r] = a[i];
           // cout << i << " " << ans[l] << endl;
        }
        /*cout << "y ";
        for (int i = 0; i < ans.size(); i++) {
            cout << ans[i] << " " ;
        }
        cout << endl;*/
    }

    cout << ans.size() - 1 << endl;
}

/*
g++ -std=c++14 abc134/e.cpp
 */

Measured memory_bytes: 1276
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

#define mod 1000000007

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

int N,high,X,Y,H;

int main(){
    cin>>N;
    int x[N],y[N],h[N];
    bool flag;
    rep(i,N){
        cin>>x[i]>>y[i]>>h[i];
    }
    rep(i,N){
        if(h[i]>0){
            X=x[i];
            Y=y[i];
            H=h[i];
            break;
        }
    }
    rep(i,101){
        rep(j,101){
            flag=true;
            high=H+abs(i-X)+abs(j-Y);
            rep(k,N){
                    if(h[k]!=max(high-abs(i-x[k])-abs(j-y[k]),0)){
                        flag=false;
                        break;
                    }
            }
            if(flag){
                cout<<i<<" "<<j<<" "<<high<<endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc088/tasks/abc088_d
#include <bits/stdc++.h>

using namespace std;
// #define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

using pii = pair<int, int>;
const vector<pii> dir = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};

// 第1引数はtrueの箇所のみ通行可能、第2引数はスタート、第3引数はゴール
// 戻り値はスタートからゴールまでの最短距離。到達不可の場合は-1
int bfs(vector<vector<bool>> flags, pii start, pii end) {
    queue<tuple<int, int, int>> q;
    q.push({start.first, start.second, 0});
    // 後戻りを防ぐため壁にする
    flags[start.first][start.second] = false;
    // 到達不可能の場合は-1
    int ret = -1;
    while (!q.empty()) {
        auto t = q.front();
        q.pop();
        int y = get<0>(t);
        int x = get<1>(t);
        int d = get<2>(t);
        if (y == end.first && x == end.second) {
            ret = d;
            break;
        }
        for (auto &a : dir) {
            int ny = y + a.first;
            int nx = x + a.second;
            if (flags[ny][nx]) {
                q.push({ny, nx, d + 1});
                // 後戻りを防ぐため壁にする
                flags[ny][nx] = false;
            }
        }
    }
    return ret;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int Y, X;
    cin >> Y >> X;
    // 周囲を壁扱いにするため+2する
    vector<vector<bool>> flags(Y + 2, vector<bool>(X + 2));
    int wall = 0;
    FOR(y, 1, Y + 1) {
        string s;
        cin >> s;
        REP(x, s.size()) {
            if (s[x] == '.') {
                flags[y][x + 1] = true;
            } else {
                // 壁の数をカウント
                wall++;
            }
        }
    }
    int ans = bfs(flags, {1, 1}, {Y, X});
    // 到達不可
    if (ans == -1) {
        cout << -1 << endl;
    } else {
        // スタート位置は黒くできないので-1
        cout << Y * X - wall - 1 - bfs(flags, {1, 1}, {Y, X}) << endl;
    }

    return 0;
}


Measured memory_bytes: 3676
#include<iostream>
int main() {
	int a[10];
		std::cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4] >> a[5] >> a[6] >> a[7] >> a[8] >> a[9];
	std::cout << a[0] + a[1] + a[2] + a[3] + a[4] + a[5] + a[6] + a[7] + a[8] + a[9] << std::endl;
	return 0;
}


Measured memory_bytes: 3132
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,n) for (int64_t i=0; i<(n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    int n; cin>>n;
    string s; cin>>s;
    int ans=0;
    string t,u;
    rep(i,n-1){
        t=s.substr(0,i+1);
        u=s.substr(i+1,n-i-1);
        map<char,int> mp, mpp;
        int kari=0;
        for(auto& v: t) mp[v]++;
        for(auto& v: u) mpp[v]++;
        for(auto &v: mp){
            for(auto &w: mpp){
                if(v.first==w.first) kari++;
            }
        }
        ans=max(ans,kari);
    }
    cout<<ans<<endl;
    return 0;
}

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

int main() {
    while (true) {
        int m, f, r; 
        cin >> m >> f >> r;
        if (m == -1 && f == -1 && r == -1)
            break;
        if (m == -1 || f == -1)
            cout << 'F';
        else if (m + f >= 80) 
            cout << 'A';
        else if (m + f >= 65)
            cout << 'B';
        else if (m + f >= 50)
            cout << 'C';
        else if (m + f >= 30) {
            if (r >= 50)
                cout << 'C';
            else 
                cout << 'D';
        }
        else 
            cout << 'F';
        cout << '\n';
    }
}

Measured memory_bytes: 1120
using System;
using System.Linq;

namespace ABC132A
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string s = Console.ReadLine();
            char first = s[0];
            Console.WriteLine(s.Distinct().Count() == 2 && s.Where(e => e == first).Count() == 2 ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
#include <unistd.h>
#define ll long long
#define inf 1000000007
#define inf16 0x3f3f3f3f
#define INF 1000000000000000007LL
#define VI vector<int>
#define VPII vector<pair<int, int> >
#define VLL vector<ll>
#define PII pair<int, int>
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define endl '\n'
#define ALL(c) (c).begin(), (c).end()
using namespace std;

#define int ll

int h, w, n, k, ans;

int pot[50*50];

int query(int y1, int y2, int x1, int x2)
{
	cout << "? " << y1 << " " << x1 << " " << y2 << " " << x2 << endl;
	int ans;
	cin >> ans;
	return ans;
}

void solve(int y1, int y2, int x1, int x2, int cnt, int split)
{
	if(cnt==0)
		return;

	if(cnt==(y2-y1+1)*(x2-x1+1))
	{
		for(int i = y1; i <= y2; ++i)
		{
			for(int j = x1; j <= x2; ++j)
			{
				ans += pot[i*w+j];
				ans %= k;
			}
		}

		return;
	}

	if(y1!=y2)//split)
	{
		int m = (y1+y2)/2;
		int h = query(y1, m, x1, x2);
		solve(y1, m, x1, x2, h, split^1);
		solve(m+1, y2, x1, x2, cnt-h, split^1);
	}
	else
	{
		int m = (x1+x2)/2;
		int h = query(y1, y2, x1, m);
		solve(y1, y2, x1, m, h, split^1);
		solve(y1, y2, m+1, x2, cnt-h, split^1);
	}
}

int32_t main()
{
	cin >> h >> w >> n >> k;

	pot[0] = 1;

	for(int i = 1; i < 50*50; ++i)
	{
		pot[i] = pot[i-1]*2%k;
	}

	for(int j = 0; j < w; j += 6)
	{
		solve(0, h-1, j, min(j+5, w-1), query(0, w-1, j, min(j+5, w-1)), 1);
	}

	/*for(int i = 0; i < h; i += 5)
	{
		for(int j = 0; j < w; j += 5)
		{
			solve(i, i+4, j, j+4, query(i, i+4, j, j+4), 1);
		}
	}*/

	//solve(0, h-1, 0, w-1, n, 1);

	cout << "! " << ans << endl;
}

Measured memory_bytes: 724
#include<iostream>
using namespace std;
int main(){
  int n;
  int i;
  int card[4][13]={{}};
  cin >> n;
  char a;
  int b;
  for(i=0;i<n;i++) {
    cin >> a >> b;
    switch(a){
    case 'S':
      card[0][b-1]=1;
      break;
    case 'H':
      card[1][b-1]=1;
      break;
    case 'C':
      card[2][b-1]=1;
      break;
    case 'D':
      card[3][b-1]=1;
      break;
    }
  }
  for(i=0;i<52;i++) {
    switch(i/13){
    case 0:
      if(card[0][i%13]==0) cout << "S " << i+1 << endl;
      break;
    case 1:
      if(card[1][i%13]==0) cout << "H " << i%13+1 << endl;
      break;
    case 2:
      if(card[2][i%13]==0) cout << "C " << i%13+1 << endl;
      break;
    case 3:
      if(card[3][i%13]==0) cout << "D " << i%13+1 << endl;
      break;
    }
  }
   
  return 0;
}


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

using namespace std;

const int maxn = 210;
int n,l[maxn],ans;

int main()
{
    scanf("%d",&n);
    for (int i = 1; i <= 2 * n; i++)
        scanf("%d",&l[i]);
    sort(l + 1,l + 1 + 2 * n);
    for (int i = 1; i <= 2 * n; i += 2)
        ans += l[i];
    printf("%d\n",ans);

    return 0;
}


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

int main() {
	int n;cin>>n;
	vector<int> a(n);
	int max=0;
	int min=n;
	vector<int> c(n,0);
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(min>a[i])min=a[i];
		if(max<a[i])max=a[i];
		c[a[i]]++;
	}
	int flag=1;
	if(max%2){
		if(min!=(max+1)/2){
			flag=0;
		}
		if(c[min]!=2){
			flag=0;
		}
		for(int i=min+1;i<=max;i++){
			if(c[i]<2){
				flag=0;
			}
		}
	}else{
		if(min!=max/2){
			flag=0;
		}
		if(c[min]!=1){
			flag=0;
		}
		for(int i=min+1;i<=max;i++){
			if(c[i]<2){
				flag=0;
			}
		}
	}
	if(flag){
		cout<<"Possible"<<endl;
	}else{
		cout<<"Impossible"<<endl;
	}

	return 0;
}

Measured memory_bytes: 256
// 6/13
// リアルタイム参加
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;

int main() {
    ll A, B;
    ll V, W;
    ll T;
    // cin >> A >> B >> V >> W >> T;
    cin >> A >> V >> B >> W >> T;

    if (A == B) {
        cout << "YES" << endl;
        return 0;
    }
    if (W >= V) {
        cout << "NO" << endl;
        return 0;
    }

    double time;
    time = (double)abs(B - A) / (double)(V - W);

    if (time <= (double)T) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>
 
template <class T> void chmin(T&a,const T&b) { a = min(a,b); }
template <class T> void chmax(T&a,const T&b) { a = max(a,b); }
 
void print(){cout<<endl;}
template <class Head, class... Tail>
void print(Head&& h,Tail&&... t){ 
	if(sizeof...(t)==0)
		cout<<h;
	else
		cout<<h<<' ';
	print(move(t)...);
}
 
const double EPS =1e-9;
const long INF =2147483647;//32bit 2*1e+9
const long MOD =1e+9+7;
#define PI 3.14159265258979
 
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};
 
int main(void){
	int H,W,counter[10]={},result=0;
	int chart[10][10],wall[210][210];

	cin>>H>>W;
	REP(i,10) REP(j,10)
			cin>>chart[i][j];
	REP(i,H) REP(j,W)
			cin>>wall[i][j];
	REP(i,H) REP(j,W)
			if(wall[i][j]>=0) counter[wall[i][j]]++;

	REP(r,10)
		REP(i,10)
			REP(j,10)
				chmin(chart[i][j],chart[i][r]+chart[r][j]);

	REP(i,10) result+=(counter[i]*chart[i][1]);
	print(result);
	return 0;
}


Measured memory_bytes: 384
N,Q = map(int,input().split())
S = list(input())
S.insert(0,0)
C = [0 for _ in range(N+1)]
cnt = 0
for i in range(2,N+1):
    if S[i-1]=="A" and S[i]=="C":
        cnt += 1
        C[i] = cnt
    else:
        C[i] = cnt
for _ in range(Q):
    l,r = map(int,input().split())
    print(C[r]-C[l])

Measured memory_bytes: 6876
import heapq
from collections import deque
from enum import Enum
import sys
import math
from _heapq import heappush, heappop
import copy
from test.support import _MemoryWatchdog

BIG_NUM = 2000000000
HUGE_NUM = 99999999999999999
MOD = 1000000007
EPS = 0.000000001
sys.setrecursionlimit(100000)


J = 0
O = 1
I = 2
JO = 3
OI = 4

num_JOI = 0

N = int(input())
input_str = input()

dp = [[0]*(5) for _ in range(N+1)]

for i in range(1,(N+1)):
    if input_str[i-1] == "J":
        dp[i][J] += 1
    elif input_str[i-1] == "O":
        dp[i][O] += 1
        dp[i][JO] += dp[i-1][J]
    else: #input_str[i-1] == "I"
        dp[i][I] += 1
        dp[i][OI] += dp[i-1][O]
        num_JOI += dp[i-1][JO]
    for k in range(5):
        dp[i][k] += dp[i-1][k] #累積和にする

maximum = max(dp[N][JO],dp[N][OI]) #右端にIを足した場合と、左端にJを足した場合の大きい方

#最大の加算をもたらすOを探す
for i in range(1,(N+1)):
    if input_str[i-1] == "J":
        maximum = max(maximum,dp[i][J]*(dp[N][I]-dp[i][I]))
    elif input_str[i-1] == "O":
        maximum = max(maximum,dp[i-1][J]*(dp[N][I]-dp[i][I]))
    else:
        maximum = max(maximum,dp[i-1][J]*(dp[N][I]-dp[i][I]+1))

print("%d"%(num_JOI+maximum))



Measured memory_bytes: 40780
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  string s;std::cin >> s;
  ll a=s[0]-'0', b=s[1]-'0', c=s[2]-'0', d=s[3]-'0';
  re(i, (1<<4)){
    ll tmp = i;
    ll k = a;
    k += (tmp%2==1?-b:b);
    char A = (tmp%2==1?'-':'+');
    tmp /=2;
    k += (tmp%2==1?-c:c);
    char B = (tmp%2==1?'-':'+');
    tmp/=2;
    k += (tmp%2==1?-d:d);
    char C = (tmp%2==1?'-':'+');
    if(k==7){
      std::cout << a;
      std::cout << A;
      std::cout << b;
      std::cout << B;
      std::cout << c;
      std::cout << C;
      std::cout << d;
      std::cout << "=7" << '\n';
      return 0;
    }
  }
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')


def solve():
    n = int(input())
    d = defaultdict(int)
    mx = 0
    for _ in range(n):
        s = input()
        d[s] += 1
        mx = max(mx, d[s])
    a = []
    for k in d:
        if d[k] == mx:
            a.append(k)
    a.sort()
    for e in a:
        print(e)
    



t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()




"""

"""





Measured memory_bytes: 35636