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

ll n,a;
ll sum=0;
vector<ll> t;

ll calc(ll a){
  return a*(a-1LL)/2LL;
}

ll solve5(){
  if(t[0]>=4LL){
    return t[4]+t[3]+t[2]+t[1]+t[0]-10LL;
  }
  if(t[1]>=4LL){
    return t[4]+t[3]+t[2]+t[1]+t[0]-9LL;
  }
  if(t[2]>=4LL){
    return t[4]+t[3]+t[2]+t[1]+t[0]-9LL;
  }
  if(t[3]>=4LL){
    return t[4]+t[3]+t[2]+t[1]+t[0]-9LL;
  }
  if(t[4]>=4LL){
    return t[4]+t[3]+t[2]+t[1]+t[0]-8LL;
  }
  return 7LL;
}

ll solve(){
  if(t.size()==0)return 1LL;
  if(t.size()==1)return t[0];
  if(t.size()==2)return t[0]+t[1]-1LL;
  if(t.size()==3)return t[0]+t[1]+t[2]-3LL;
  if(t.size()==4)return t[0]+t[1]+t[2]+t[3]-6LL;
  return solve5();
}

int main(){
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a;
    if(a>2LL)t.push_back(a);
    sum+=calc(a);
  }
  sort(t.begin(),t.end());
  ll ans=solve();
  while(calc(ans)<sum)ans++;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1212
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=100005,L=30;
int n;
int Query(int ans){
    char ret[20];
    printf("%d\n",ans);
	fflush(stdout);
    scanf("%s",ret);
    if(ret[0]=='V') exit(0);
    return ret[0]=='M'?1:0;
}
int main()
{
	scanf("%d",&n);
    int l=0,r=n-1;
    int f=Query(0);
    while(l<r){
        int mid=(l+r)>>1;
        int p=Query(mid);
        if(p!=f){
            if(mid&1)
                l=mid+1;
			else
				r=mid;
        }
		else
			if(mid&1)
                r=mid;
			else
				l=mid+1;
    }
    Query(r);
}


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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vi b(n - 1);
  for (int i = 0; i < n - 1; i++) {
    cin >> b[i];
  }
  int ans = b[0];
  for (int i = 1; i < n - 1; i++) {
    int a = min(b[i], b[i - 1]);
    // printf("%d ", a);
    ans += a;
  }
  ans += b[n - 2];
  cout << ans << endl;
  return 0;
}


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

using namespace std;

int main()
{
    int A, B;
    cin >> A >> B;
    if (A >= B)
        cout << A + max(A - 1, B) << endl;
    else
        cout << B + max(B - 1, A) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main (void){

    int i,j, n;
    long long sum = 0;

    cin >> n;
    int a[n];

    for(j = 0;j < n;j++){
        cin >> a[j];
    }

    for(i = 0;i < n -1;i++){
        
        if(a[i] > a[i+1]){
            sum = sum +(a[i] - a[i+1]);
            a[i+1] = a[i];
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 4368
#include <stdio.h>
#define MAX 101

int matrixChainMultiplication(int, int *);
int min(int, int);

int main() {
  int n,p[MAX],i;
  scanf("%d",&n);
  for(i = 0; i < n; i++) {
    scanf(" %d %d",&p[i],&p[i+1]);
  }
  printf("%d\n",matrixChainMultiplication(n,p));
  return 0;
}

int matrixChainMultiplication(int n, int *p) {
  int m[MAX][MAX],i,j,k,l;
  for(i = 1; i <= n; i++) {
    m[i][i] = 0;
  }
  for(i = 2; i <= n; i++) {
    for(j = 1; j <= n - i + 1; j++) {
      k = j + i -1;
      m[j][k] = 1000000;
      for(l = j; l <= k - 1; l++) {
	m[j][k] = min(m[j][k],m[j][l] + m[l + 1][k] + p[j - 1] * p[l] * p[k]);
      }
    }
  }
  return m[1][n];
}

int min(int a, int b) {
  if(a < b) return a;
  else return b;
}

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

int main(){
    using namespace std;
    constexpr unsigned long MOD = 1000000007;
    auto f = [&MOD](auto& a, auto k){(a.second += (a.first += a.second * k) %= MOD) %= MOD; return a.first;};
    unsigned long N;
    cin >> N;
    vector<pair<pair<unsigned long, unsigned long>, unsigned long>> tapi(1048576, {{1, 0}, 0});
    vector<unsigned long> zeros(N + 2);
    unsigned long ans{0}, t{500000004}, a{0};
    for(unsigned long i = 1, A; i <= N; ++i){
        cin >> A;
        a ^= A;
        zeros[i + 1] = zeros[i] + !a;
        if(a){
            ans += f(tapi[a].first, zeros[i + 1] - zeros[tapi[a].second]);
            tapi[a].second = i + 1;
        }else (t *= 2) %= MOD;
    }
    cout << (a ? tapi[a].first.first : (ans + t) % MOD) << endl;
    return 0;
}

Measured memory_bytes: 28672
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int M = scanner.nextInt();
        int[] A = new int[M];
        int syukudaiSum = 0;
        for (int i = 0; i<M; i++) {
            A[i] = scanner.nextInt();
            syukudaiSum += A[i];
        }
        if (N - syukudaiSum >= 0) {
            System.out.println(N - syukudaiSum);
        } else {
            System.out.println("-1");
        }
    }
}

Measured memory_bytes: 46756
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		//y = x / p = (1900M + 100(N-M)) * 2^M
		System.out.println((int)((1900*m + 100*(n-m))*Math.pow(2, m)));
	}
}

Measured memory_bytes: 23764
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  vector<bool> b(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
    a[i] -= 1;
    b[i] = true;
  }
  int cnt = 0;

  for(int i = 0; i < n; i++){
    if(b[i]){
      if(a[a[i]] == i && b[a[i]] == true){
        b[a[i]] = false;
        cnt++;
      }
    }
    b[i] = false;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 640
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e16;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    ll N, P; cin >> N >> P;
    ll ans = 1;
    for (ll i = 1; i*i <= P; i++) {
        if(P%i != 0) continue;
        ll cnt = 0;
        ll tmp = P;
        if(i != 1){
            while(tmp > 0){
                if(tmp % i != 0) break;
                tmp /= i; cnt++;
            }
            if(cnt >= N) ans = max(ans, i);
        }
        tmp = P; ll j = P / i; cnt = 0;
        if(j != 1){
            while(tmp > 0){
                if(tmp % j != 0) break;
                tmp /= j; cnt++;
            }
            if(cnt >= N) ans = max(ans, j);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<long long> a(n);
  for(auto &i:a)cin>>i;
  
  sort(a.begin(),a.end(),greater<>());
  
  long long x = 0;
  for(int i=1;i<n;++i){
    if(a[i]==a[i-1]){
      if(x==0){
        x = a[i];
        i++;
      }
      else {
        cout << x * a[i];
        return 0;
      }
    }
  }
  cout << 0;
  return 0;
}

Measured memory_bytes: 1024
import itertools
mod = 10**9+7

n = int(input())
a = list(map(int, input().split()))

rgb = [0,0,0]
# r = 1
# b = 0
# g = 0
ans = 1

for i in range(0, n):
    cnt = a[i]
    conb = 0
    isFirst = True
    for j in range(3):
        eachCnt = rgb[j]
        if cnt == eachCnt:
            conb += 1
            if isFirst:
                rgb[j] += 1
                isFirst = False
    # print('conb', conb)
    ans *= conb % mod

# print('ans', ans)
print(ans % mod)

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

bool check_value( std::vector<unsigned long long> &v )
{
	for ( auto &&it : v )
	{
		if ( ( it & 1 ) == 0 )
		{
			// 一つでも偶数が見つかればOK
			it >>= 1;	//	先に2で割っておく
			return ( true );
		}
	}

	// 全部奇数
	return ( false );
}

int main()
{
	unsigned int n;
	std::vector<unsigned long long> v;

	std::cin >> n;
	for ( int i = 0; i < n; i++ )
	{
		unsigned long long tmp;
		std::cin >> tmp;
		v.emplace_back( tmp );
	}

	unsigned long long counter = 0;
	while ( check_value( v ) )
	{
		counter++;
	}

	std::cout << counter << std::endl;

	return ( 0 );
}


Measured memory_bytes: 1016
import java.util.*;

public class Main {
	// public static void printArray(int[] a) {
	// 	for (int i = 0; i < a.length; i++) {
	// 		System.out.print(a[i] + ", ");
	// 	}
	// 	System.out.println();
	// }

	// public static<T> void printArrayT(T[] a) {
	// 	for (int i = 0; i < a.length; i++) {
	// 		System.out.print(a[i] + ", ");
	// 	}
	// 	System.out.println();
	// }

	// public static class Triple implements Comparable<Triple> {
	// 	public int A, B, C;
	// 	Triple(int A, int B, int C) {
	// 		this.A = A;
	// 		this.B = B;
	// 		this.C = C;
	// 	}

	// 	@Override
	// 	public String toString() {
	// 		return String.format("(%d, %d, %d)", A, B, C);
	// 	}

	// 	@Override
	// 	public int compareTo(Triple o) {
	// 		int a = this.A - o.A;
	// 		if (a != 0) return a;
	// 		int b = this.B - o.B;
	// 		if (b != 0) return b;
	// 		return this.C - o.C;
	// 	}
	// }

	static class Zero extends RuntimeException { }

	static long MOD = 1000000007;

	static long calc2(ArrayList<Integer>[] edge, int K, int myPat, int node, int parent) {
		if (myPat <= 0) {
			throw new Zero();
		}
		long result = myPat;
		int pat = 1;
		for (int n : edge[node]) {
			if (n == parent) continue;
			pat++;

			result *= calc2(edge, K, K - pat, n, node);
			result %= MOD;
		}
		// System.out.printf("%d %d %n", node, result);
		return result;
	}

	static long calc(ArrayList<Integer>[] edge, int K) {
		long result = K;
		int pat = 0;
		if (edge[1] != null) {
			for (int node : edge[1]) {
				pat++;
				result *= calc2(edge, K, K - pat, node, 1);
				result %= MOD;
			}
		}
		// System.out.printf("%d %d %n", 1, result);
		return result;
	}

	static void reg(ArrayList<Integer>[] edge, int a, int b) {
		if (edge[a] == null) {
			edge[a] = new ArrayList<>();
		}
		edge[a].add(b);
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		@SuppressWarnings("unchecked")
		ArrayList<Integer>[] edge = new ArrayList[N + 1];
		for (int i = 0; i < N - 1; i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			reg(edge, a, b);
			reg(edge, b, a);
		}
		long value;
		try {
			value = calc(edge, K);
		} catch (Zero e) {
			value = 0;
		}

		System.out.println(value);
	}
}


Measured memory_bytes: 118060
def main():
    x = int(input())
    if False:
        print((360 // x) if 360%x == 0 else (360 // x)+1)
    else:
        k = 1
        temp = x
        while temp % 360 != 0:
            k += 1
            temp += x
        print(k)


    temp = 360 // x

if __name__ == '__main__':
    main()


Measured memory_bytes: 61724
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define REP(var, s, n) for (int var = (s); var < (n); ++var)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()

int main() {
  //
  int n;
  cin >> n;
  string s;
  cin >> s;
  vi l(n), r(n);
  if (s[0] == 'W') {
    l[0] = 1;
  } else {
    l[0] = 0;
  }
  if (s[n - 1] == 'E') {
    r[n - 1] = 1;
  } else {
    r[n - 1] = 0;
  }

  REP(i, 1, n) {
    if (s[i] == 'W') {
      l[i] = l[i - 1] + 1;
    } else {
      l[i] = l[i - 1];
    }
    if (s[n - 1 - i] == 'E') {
      r[n - 1 - i] = r[n - i] + 1;
    } else {
      r[n - 1 - i] = r[n - i];
    }
  }

  int ans = min(r[1], l[n - 2]);
  REP(i, 1, n - 1) {
    int cnt = l[i - 1] + r[i + 1];
    ans = min(ans, cnt);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3068
// -----------------------------------------------
// Framework <https://github.com/vain0x/procon>
//
// See the bottom of file for solution.
// -----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

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

#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let N = read!(usize);
    let P = read![[f64]];

    // dp[i][x] = p <=> コイン 0..i を投げたとき x 枚のコインが表になる確率が p
    let mut dp = vec![vec![0.0_f64; N + 1]; N + 1];
    dp[0][0] = 1.0;

    for i in 0..N {
        let mut p = P[i];

        for x in 0..N {
            dp[i + 1][x] += (1.0 - p) * dp[i][x];
            dp[i + 1][x + 1] += p * dp[i][x];
        }
    }

    // x > N - x ⇔ 2 * x > N ⇔ x > [N/2] ⇔ x >= [N/2] + 1

    println!("{}", ((N / 2 + 1)..N + 1).map(|i| dp[N][i]).sum::<f64>());
}


Measured memory_bytes: 90364
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  int N, K;
  cin >> N >> K;
  vector<int> l(N);
  for(int i = 0; i < N; i++){
    cin >> l[i];
  }
  sort(l.rbegin(),l.rend());
  
  /*for(int i = 0; i < N; i++){
    cout << l[i] << " ";
  }
  cout << endl;*/
  
  int ans = 0;
  for(int i = 0; i < K; i++){
    ans = ans + l[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>
#include <complex>

using namespace std;

#define mod 1000000007

int main()
{
	int n;
	string s;
	cin >> n >> s;
	for(int i = 0; i < s.length(); i++){
		int tmp = s[i] - 'A';
		char res = (char)'A' + ((tmp + n) % 26);
		s[i] = res;
	}
	cout << s << endl;
 }

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

int main() {
  int n,m,c;
  cin >> n >> m >> c;
  vector<int> b(m);
  rep(i,0,m) cin >> b[i];
  int ans = 0;
  rep(i,0,n) {
    int code = c;
    rep(j,0,m) {
      int a;
      cin >> a;
      code += a*b[j];
    }
    if (code > 0) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>
using namespace std;
 
#define ll long long
 
 
int main() {
  
  	ll K;
  	ll A, B; 
  	cin >> K >> A >> B;
	
  	for(ll i = A; i<=B; i++){
    	if(i%K==0){
          	cout << "OK" << endl;
          	break;
        }
      	if(i==B){
        	cout << "NG" << endl;
        }
    }
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
    public static void main(String... args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNextInt()) {
            int n = sc.nextInt();
            int sum = 0;
            for (int a = 0; a < 10; a++) {
                for (int b = 0; b < 10; b++) {
                    for (int c = 0; c < 10; c++) {
                        for (int d = 0; d < 10; d++) {
                            if (a + b + c + d == n) {
                                sum++;
                            }
                        }
                    }
                }
            }
            System.out.println(sum);
        }
    }
}


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

int main() {
  std::string str;
  std::cin >> str;
  std::vector<std::string> check = {"maerd", "remaerd","esare","resare"};
  std::reverse(str.begin(), str.end());
  int flag = 0;
  for (int i=0; i<str.size();) {
    int temp_flag = 1;
    for (int j=0; j < 4; j++) {
      if (str.substr(i,check.at(j).size()) == check.at(j)) {
        temp_flag = 0;
        i += check.at(j).size();
        break;
      }
    }
    if (temp_flag) {
      flag = 1;
      break;
    }
  }
  if (flag) {
    std::cout << "NO" << std::endl;
  }
  else {
    std::cout << "YES" << std::endl;
  }
}

Measured memory_bytes: 512
import queue
n = int(input())
way = [[] for i in range(n+1)]
for i in range(n-1):
    a, b = map(int,input().split())
    way[a].append(b)
    way[b].append(a)

qf = queue.Queue()
qs = queue.Queue()
qf.put(1)
qs.put(n)
who = ["" for i in range(n+1)]
wht = [10**5+5 for i in range(n+1)]
who[0] = "N"
who[1] = "F"
who[n] = "S"
wht[0] = 0
wht[1] = 0
wht[n] = 1


while not(qf.empty() and qs.empty()):
    if not qf.empty():
        fi = qf.get()
        if who[fi] == "F":
            for i in way[fi]:
                if wht[i] > wht[fi] + 2:
                    qf.put(i)
                    wht[i] = wht[fi] + 2
                    who[i] = "F"
    if not qs.empty():
        si = qs.get()
        if who[si] == "S":
            for i in way[si]:
                if wht[i] > wht[si] + 2:
                    qs.put(i)
                    wht[i] = wht[si] + 2
                    who[i] = "S"

if who.count("F") > who.count("S"):
    print("Fennec")
else:
    print("Snuke")


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

int main() {
    string S; cin >> S;
    if (S == "SUN") cout << "7" << endl;
    if (S == "MON") cout << "6" << endl;
    if (S == "TUE") cout << "5" << endl;
    if (S == "WED") cout << "4" << endl;
    if (S == "THU") cout << "3" << endl;
    if (S == "FRI") cout << "2" << endl;
    if (S == "SAT") cout << "1" << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

class ModTools:
    """ 階乗たくさん使う時用のテーブル準備 """

    def __init__(self, MAX, MOD):
        """ MAX：階乗に使う数値の最大以上まで作る """
        
        MAX += 1
        self.MAX = MAX
        self.MOD = MOD
        # 階乗テーブル
        factorial = [1] * MAX
        factorial[0] = factorial[1] = 1
        for i in range(2, MAX):
            factorial[i] = factorial[i-1] * i % MOD
        # 階乗の逆元テーブル
        inverse = [1] * MAX
        # powに第三引数入れると冪乗のmod付計算を高速にやってくれる
        inverse[MAX-1] = pow(factorial[MAX-1], MOD-2, MOD)
        for i in range(MAX-2, 0, -1):
            # 最後から戻っていくこのループならMAX回powするより処理が速い
            inverse[i] = inverse[i+1] * (i+1) % MOD
        self.fact = factorial
        self.inv = inverse
    
    def nCr(self, n, r):
        """ 組み合わせの数 (必要な階乗と逆元のテーブルを事前に作っておく) """

        if n < r: return 0
        # 10C7 = 10C3
        r = min(r, n-r)
        # 分子の計算
        numerator = self.fact[n]
        # 分母の計算
        denominator = self.inv[r] * self.inv[n-r] % self.MOD
        return numerator * denominator % self.MOD

r1, c1, r2, c2 = MAP()

mt = ModTools(r2+c2+2, MOD)
# nCr(0, 0)からnCr(n, r)までの全ての組み合わせの総和
def calc(r, c):
    return mt.nCr(r+c+2, r+1) - 1

# 2次元で区間和取る時の要領で4点足し引き
ans = calc(r2, c2) - calc(r2, c1-1) - calc(r1-1, c2) + calc(r1-1, c1-1)
print(ans%MOD)


Measured memory_bytes: 161268
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
  int x;
  cin >> x;

  vector<int> dp(x + 200);
  dp[0] = 1;
  for (int i = 0; i <= x; i++) {
    if (!dp[i]) continue;
    for (int j = 100; j <= 105; j++) {
      dp[i + j] = 1;
    }
  }
  cout << dp[x] << endl;
}


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

struct edge {
    int to, weight;
    edge(int t, int w) : to(t), weight(w) {};
};

vector<vector<edge>> graph;
vector<int> color;

void dfs(int from, int cur = 0) {
    color[from] = cur;
    for (auto to : graph[from]) {
        if (color[to.to] != -1) continue;
        if (to.weight % 2 == 0) dfs(to.to, cur);
        else dfs(to.to, 1 - cur);
    }
}

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

    graph.resize(n);
    rep(i, n - 1) {
        int u, v, w;
        cin >> u >> v >> w;
        u--, v--;
        graph[u].push_back(edge(v, w));
        graph[v].push_back(edge(u, w));
    }

    color.resize(n, -1);
    dfs(0);
    rep (i, n) {
        cout << color[i] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 8192
//int a = stoi(c); 文字列をintへ
//小文字から大文字
//transform(a.begin(), a.end(), a.begin(), ::toupper);
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//等価なものに変換する思考
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//配列はvector<>を使う：意味わからないエラーがなくなる。
//背反な事象にちゃんとわける
//チェックリストはマップを使う
//数が大きい時の比較はstring型で行う
//全て0になったか調べたい->0になるたびにcntする
//またはかかつか
//例外処理は最初にする
//x = p^m + q^n...の約数の個数:(n+1)*(m+1)....
//N!のどの素因数で何回割れるか
//⇔1~Nまでの数がそれぞれどの素因数で何回割り切れるかの和
//パズルの問題->一般化して全探索
//数が大きい時のせぐふぉはコードテストで試してみる
//スペルミスに注意
//stack<ll> s;
//s.push(要素);s.top();s.pop();
//queue<ll> q;
//q.push(要素);q.front();q.pop();
//同じ作業繰り返す系の問題：収束先を見つける
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

//円周率
const double PI = 3.14159265358979323846;
//割るやつ
const ll M = (pow(10, 9) + 7);

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}


//a,bの最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

//nC2の計算
ll C(ll N) {
	return N * (N - 1) / 2;
}

//階乗計算
ll f(ll n) {
	if (n == 0 || n == 1) return 1;
	else return (n * f(n - 1)) % M;
}

//Nをdで何回割れるか
ll divcnt(ll N, ll d) {
	ll ans = 0;
	while (1) {
		if (N%d == 0) {
			ans++;
			N /= d;
		}
		else break;
	}

	return ans;
}

//素数判定
bool prime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2) {
		if (num % i == 0) return false;
	}
	return true;
}

//フィボナッチ数列
vector<ll> memo(pow(10, 6) + 1);
ll fibo(ll n) {
	if (n == 1) return 1;
	else if (n == 2) return 1;
	else if (memo[n] != 0) return memo[n];
	else return memo[n] = fibo(n - 1) + f(n - 2);
}

int main() {
	ll N; cin >> N;
	vector<string> S(N); rep(i, N)cin >> S[i];

	map<string, ll> p;
	rep(i, N) p[S[i]] = 1;

	auto begin = p.begin(), end = p.end();

	ll ans = 0;
	for (auto it = begin; it != end; it++) {
		ans++;
	}

	cout << ans << endl;
//mapのキー：it->first mapのバリュー：it->second
}

Measured memory_bytes: 32984
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define re return
#define all(a) a.begin(),a.end()
#define int long long
using namespace std;
const int dx[4]={-1,1,0,0};
const int dy[4]={0,0,-1,1};
signed main()
{
	string s;
	cin>>s;
	reverse(all(s));
	int ans=0;
	for (int mask=0;mask<(1<<(sz(s)-1));mask++){
		int x=s[0]-'0';
		int num=1;
		for (int i=1;i<sz(s);i++){
			num*=10;
			if ((mask>>(i-1))&1){
				num=1;
			}
			x+=((s[i]-'0')*num);
		}
		ans+=x;//cout<<x<<'+';
	}
	cout<<ans;
	re 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
using namespace std;

typedef pair<int,int> pii;
typedef long long ll;

const int N = 1e5 + 5, inf = 1e9;

int dp[N];

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	fill(dp,dp+N,inf);
	int n;
	cin >> n;
	dp[0] = 0;
	rep(i,0,n){
		gmin(dp[i+1], dp[i] + 1);
		for(int x = 6; i + x <= n; x*=6){
			gmin(dp[i+x], dp[i] + 1);			
		}
		for(int x = 9; i + x <= n; x*=9){
			gmin(dp[i+x], dp[i] + 1);			
		}
	}
	cout << dp[n] << '\n';
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n,i,j,k,l,a,b,c,t,m;
    cin>>n;
    c=0;
    for(i=1;i<=n;i++)
    {
        if(i%3!=0&&i%5!=0)
        {
            c+=i;
        }
    }
    cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 3636
import math
a, b, h, m = map(int, input().split())

ap = h * 30 + m * 0.5
bp = m * 6

ang = abs(ap - bp)

if ang > 180:
    ang = 360 - ang

ans = a**2 + b**2 - (2 * a * b * math.cos(math.radians(ang)))

print(math.sqrt(ans))


Measured memory_bytes: 62280
#include<stdio.h>
#include<string.h>


int main(void)
{
	int i;
	char str[13];
	
	scanf("%s",str);
	
	for(i=0; i<4 ; i++){
		printf("%c",str[i]);
	}
	
	printf(" ");
	for(i=4; i<12; i++){
		printf("%c",str[i]);
	}
	printf("\n");
	
	return 0;
}


Measured memory_bytes: 128
e1,e2,e3,e4=map(int,input().split())
if e1==e2 and e3==e4:
    print('yes')
elif e1==e3 and e2==e4:
    print('yes')
elif e1==e4 and e2==e3:
    print('yes')
elif e1==e2==e3==e4:
    print('yes')
else:
    print('no')


Measured memory_bytes: 5596
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    int ans = 0;
    for(int i = 1; i*i <= N; i++){
      ans = i*i;
    }
    
    System.out.println(ans);
  }
}

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

int main() {
  int N;
  cin >> N;
  int H[100];
  for (int i = 0; i < N; i++) {
    cin >> H[i];
  }

  int m = 0, count = 0;
  for (int i = 0; i < N; i++) {
    if (H[i] >= m) {
      count++;
      m = H[i];
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
IDENTIFICATION DIVISION.
PROGRAM-ID. 175B.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 INP        PIC  X(1100).
01 N          PIC  9(03).
01 P1         PIC  9(04) COMP.
01 P2         PIC  9(04) COMP.
01 I          PIC  9(04) COMP.
01 J          PIC  9(04) COMP.
01 K          PIC  9(04) COMP.
01 TBL1.
   03 L1      PIC  9(10) OCCURS 101.
01 TBL2.
   03 L2      PIC  9(10) OCCURS 100.
   03 K2      PIC  9(03) OCCURS 100.
01 L-C        PIC  9(03) COMP.
01 CNT        PIC  9(06) COMP.
01 OUT        PIC  Z(5)9.
*>
PROCEDURE DIVISION.
  ACCEPT N.
  ACCEPT INP.
*>       
  MOVE ZERO TO TBL1 TBL2.
  MOVE 1 TO P1.
  PERFORM VARYING I FROM 1 BY 1 UNTIL I > N
    PERFORM VARYING P2 FROM P1 BY 1 UNTIL INP(P2:1) = ' '
    END-PERFORM
    MOVE INP(P1:P2 - P1) TO L1(I)
    COMPUTE P1 = P2 + 1
  END-PERFORM.
*>
  SORT L1 DESCENDING KEY L1.
*>
  MOVE 1     TO L-C.
  MOVE L1(1) TO L2(L-C)
  MOVE 1     TO K2(L-C)
  PERFORM VARYING I FROM 1 BY 1 UNTIL I >= N
    IF (L1(I + 1) < L1(I)) AND (L1(I + 1) > 0)
      ADD  1         TO L-C
      MOVE L1(I + 1) TO L2(L-C)
      MOVE 1         TO K2(L-C)
    ELSE
      ADD  1         TO K2(L-C)
    END-IF
  END-PERFORM.
*>
  MOVE 0 TO CNT.
  PERFORM VARYING I FROM 1 BY 1 UNTIL I > L-C + 2
    COMPUTE J = I + 1
    PERFORM VARYING J FROM J BY 1 UNTIL J > L-C + 1
      COMPUTE K = J + 1                        
      PERFORM VARYING K FROM K BY 1 UNTIL K > L-C
        IF (L2(I) + L2(J) > L2(K)) AND
           (L2(J) + L2(K) > L2(I)) AND
           (L2(K) + L2(I) > L2(J)) 
          COMPUTE CNT = CNT + K2(I) * K2(J) * K2(K)
        END-IF
      END-PERFORM
    END-PERFORM
  END-PERFORM.
*>
  MOVE CNT TO OUT.
  DISPLAY FUNCTION TRIM(OUT).
  STOP RUN.


Measured memory_bytes: 3964
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
r, D, x = [int(x) for x in input().split()]
ls =[]
a = x
for i in range (10):
    b = r*a-D
    ls.append(b)
    a = b

for i in ls:
    print(i)
    


Measured memory_bytes: 2940
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> Vl;
typedef vector<double> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<VS> VSS;  
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;  //ll とdoubleは違う
// cout << << endl;
// cin >> ;


int main(){
    double c=0,d=0,k=0,n,m,h,w,p,q;
    double ans=0;
    string s,s1,s2;
    cin >> n;
    d = n;
    int i=1;
    while(n){
        if(i%2==1){
            c++;
        }
        i++;
        n--;
    }
    cout << c/d << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main (void){
    int n,i,ans=0;
    for(i=0;i<5;i++){
        scanf("%d",&n);
        if(n<40)ans=ans+40;
        else ans=ans+n;
    }
    ans=ans/5;
    printf("%d\n",ans);
return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define long long long 

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update> pref_trie;
typedef tree<long int,null_type,less<long int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef cc_hash_table<long int,long int, hash<long int>, equal_to<long int>, direct_mask_range_hashing<long int>, 
hash_standard_resize_policy<hash_exponential_size_policy<>, hash_load_check_resize_trigger<true>, true>> ht;


ht dp;
long int solve(vector<pair<long int,long int>> &v, long int n, long int h){
	if(h <= 0)
		return 0;

	if(dp[h])
		return dp[h];

	long int ans = 1e18;
	for(long int i = 0; i < n; i++){
		ans = min(ans,solve(v,n,h-v[i].first) + v[i].second);
	}
	return dp[h] = ans;
}

int main(){
   IOS;
 //    #ifndef ONLINE_JUDGE
 //        freopen("in.txt",  "r",  stdin);
 //        freopen("out.txt", "w", stdout);
 //    #endif
 	long int h,n;
	cin>>h>>n;

	vector<pair<long int,long int>> v(n);
	for(long int i = 0; i < n; i++)
		cin>>v[i].first>>v[i].second;

	cout<<solve(v,n,h); 	  
   return 0;
}

Measured memory_bytes: 1532
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cassert>
#include <functional>
#include <string>
#include <sstream>
using namespace std;


int main(){
  int A, B, C; cin >> A >> B >> C;
  if(A <= C && C <= B) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)x.size())
#define FOR(i,a,b) for (int i=a;i<=b;++i)
#define FORD(i,a,b) for (int i=a;i>=b;--i)
using namespace std;
typedef long long LL;
typedef pair<int,int> pa;
typedef vector<int> vec;
void getint(int &v){
    char ch,fu=0;
    for(ch='*'; (ch<'0'||ch>'9')&&ch!='-'; ch=getchar());
    if(ch=='-') fu=1, ch=getchar();
    for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';
    if(fu) v=-v;
}
const int MO=1e9+7;
int n,m,t,cnt[555],k,a[222222];
LL ans,fac[200010],PW[555][555],f[2][555][555],inv[200010],INV[200010];
LL pw(LL x,LL y){
	LL t=1;
	for (;y;y>>=1){
		if (y&1) t=t*x%MO;
		x=x*x%MO;
	}
	return t;
}
LL C(int x,int y){
	return fac[x]*inv[y]%MO*inv[x-y]%MO;
}

int main(){
	fac[0]=1;
	FOR(i,1,200000) fac[i]=fac[i-1]*i%MO;
	FOR(i,1,200000) INV[i]=pw(i,MO-2);
	inv[200000]=pw(fac[200000],MO-2);
	FORD(i,199999,0) inv[i]=inv[i+1]*(i+1)%MO;
	FOR(i,0,550) FOR(j,0,550) PW[i][j]=pw(i,j);
	cin>>n>>m;
	FOR(i,1,n){
		int x;
		getint(x);
		++cnt[x];
	}
	f[t][0][0]=1;
	FORD(i,m,0){
		FOR(j,0,m)
			FOR(k,0,j/(i+1))
				if (f[t][j][k]){
					LL o=f[t][j][k];
					f[t][j][k]=0;
					int tt=j-k*i+k;
					FOR(l,0,(m+1-k-j)/(i+1)){
						if (tt+l>500){
							int gg=1;
						}
						(f[t^1][j+l*i][k+l]+=o*inv[l]%MO*((l&1)?-1:1)*(i==0?1ll:PW[tt+l][cnt[i]]))%=MO;
					}
				}
		t^=1;
	}
	FOR(k,1,m+1) (ans-=fac[k]*f[t][m+1-k][k])%=MO;
	ans=(ans%MO+MO)%MO;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 12544
using System;

namespace abc123A
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int a = Int32.Parse(Console.ReadLine());
            int b = Int32.Parse(Console.ReadLine());
            int c = Int32.Parse(Console.ReadLine());
            int d = Int32.Parse(Console.ReadLine());
            int e = Int32.Parse(Console.ReadLine());
            int k = Int32.Parse(Console.ReadLine());
            int f = b - a;
            int g = c - a;
            int h = d - a;
            int i = e - a;
            int j = c - b;
            int l = d - b;
            int m = e - b;
            int n = d - c;
            int o = e - c;
            int p = e - d;
            if (k >= f && k >= g && k >= h && k >= i && k >= j && k >= l && k >= m && k >= n && k >= o && k >= p)
                Console.WriteLine("Yay!");
            else
                Console.WriteLine(":(");
        }
    }
}


Measured memory_bytes: 11092
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		long A = long.Parse(str[0]);
		long B = long.Parse(str[1]);
		long C = long.Parse(str[2]);
		long ans = Math.Max(0,B+C-A);
		Console.WriteLine(ans);
	}
}


Measured memory_bytes: 13140
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
string alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/

int main(void){
  int N;
  cin >> N;
  int num = N*25/27;
   int ans_1, ans, num_1;
  num_1 = num+1;
  
  ans = num *1.08;
  ans_1 = num_1*1.08; 
  if (ans_1 == N) cout << num_1 << endl;
  else if(ans == N) cout << num << endl;
  else cout << ":(" << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)
int main() {
  int n;
  cin >> n;
  vector<int> a(n + 1), b(n), c(n - 1);
  REP(i, n) {
    cin >> a.at(i);
  }
  a.at(n) = 0;
  REP(i, n) {
    cin >> b.at(i);
  }
  REP(i, n - 1) {
    cin >> c.at(i);
  }
  int res = 0;
  REP(i, n) {
    res += b.at(a.at(i) - 1);
    if (a.at(i) + 1 == a.at(i + 1)) {
      res += c.at(a.at(i) - 1);
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
int main(void){
    int n;
    cin>>n;
    int sum_a=0,sum_b=0;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    for(int i=0;i<n;i++){
        if(i%2==0)sum_a+=a[i];
        else sum_b+=a[i];
    }
    cout<<sum_a-sum_b<<endl;
    return 0;
}


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

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

  --A;
  --B;
  int ans = A * B;
  cout << ans << endl;
 
  return 0;
}

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

int main(){
  int n;
  string bottan[]={
    "",
    ".,!? ", // 1
    "abc", // 2
    "def", // 3
    "ghi", // 4
    "jkl", // 5
    "mno", // 6
    "pqrs", // 7
    "tuv", // 8
    "wxyz", // 9
  };
  int cnt[] = {0,5,3,3,3,3,3,4,3,4};
  
  cin >> n;
  while(n--){
    string str; cin >> str;
    int len = str.size();
    int cnt1=0,cnt2=0;
    for(int i=0;i<len;i++){
      if(str[i] == '0'){
	if(cnt1 != 0){
	  if(cnt2%cnt[cnt1] == 0){
	    cout << bottan[cnt1][cnt[cnt1]-1];
	  }
	  else {
	    cout << bottan[cnt1][cnt2%cnt[cnt1]-1];
	  }
	}
	cnt1 = 0; cnt2 = 0;
      }
      else {
	if(cnt1 == 0){
	  cnt1 = str[i] - '0';
	  cnt2++;
	}
	else {
	  cnt2++;
	}
      }
    }
    cout << endl;
  }
}

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

long long int N, C, D[33][33], c[3][33], d, E[3][33], a;
string s;

int main(){
    scanf("%lld%lld", &N, &C);
    for(int i = 0; i < C; ++i)
        for(int j = 0; j < C; ++j)
            scanf("%lld", D[i] + j);
    for(int i = 0; i < N; ++i)
        for(int j = 0; j < N; ++j){
            scanf("%lld", &d);
            ++c[(i + j) % 3][d - 1];
        }
    for(int i = 0; i < 3; ++i)
        for(int j = 0; j < C; ++j)
            for(int k = 0; k < C; ++k)
                E[i][j] += c[i][k] * D[k][j];
    a = 561562465235623;
    for(int i = 0; i < C; ++i){
        d = E[0][i];
        for(int j = 0; j < C; ++j){
            if(i == j)continue;
            d += E[1][j];
            for(int k = 0; k < C; ++k){
                if(i == k || j == k)continue;
                d += E[2][k];
                a = min(a, d);
                d -= E[2][k];
            }
            d -= E[1][j];
        }
    }
    cout << a << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main () {
  char a,b;
  scanf(" %c %c", &a, &b);
              
  if (a<b){
    printf("<\n");
  } else if (a > b) {
    printf(">\n");
  } else if (a = b) {
    printf("=\n");
  }
  return 0;
}


Measured memory_bytes: 128
import java.util.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args){
    Scanner sc = new Scanner(in);
    int n = sc.nextInt();
		int u = sc.nextInt();
		int[] v = new int[n];
		int[] w = new int[n];

		for (int i = 0; i < n; i++) {
			v[i] = sc.nextInt();
			w[i] = sc.nextInt();
		}

		int[][] dp = new int[n+1][u+1];

		for (int i = n; i >= 0; i--) {
			for (int j = 0; j <= u; j++) {
				if (i == n) {
					dp[i][j] = 0;
					continue;
				} else {
					if (w[i] > j) {
						dp[i][j] = dp[i+1][j];
					} else {
						dp[i][j] = Math.max(dp[i+1][j], dp[i+1][j - w[i]] + v[i]);
					}
				}
			}
		}

		out.println(dp[0][u]);
	}
}



Measured memory_bytes: 31132
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;

typedef long long ll;

ll N, M;

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

    vector<ll> P(M), Y(M);
    rep(i, M) cin >> P[i] >> Y[i]; 

    map<ll, vector<pair<ll, ll>>> mp;
    rep(i, M) {
        mp[P[i]].push_back(make_pair(Y[i], i + 1)); 
    }

    map<ll, pair<ll, ll>> ans;

    // 県ごとに処理
    for (auto iter = mp.begin(); iter != mp.end(); iter++) {
        sort(iter->second.begin(), iter->second.end());

        for (ll i = 0; i < iter->second.size(); i++) {
           // printf("p: %06d f: %d s: %d idx: %06d\n", 
           // iter->first, iter->second[i].first, iter->second[i].second, i + 1);
           // ans[iter->second[i].second] = sprintf("%")  
           // cout << sprintf("%d", iter->second[i].second) << endl;
           ans[iter->second[i].second] = make_pair(iter->first, i + 1);
        }
    }

    for (auto iter = ans.begin(); iter != ans.end(); iter++) {
        printf("%06d%06d\n", ans[iter->first].first, ans[iter->first].second);
    }
}

Measured memory_bytes: 20224
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF (1e9+1)
//#define INF (1LL<<59)

#define MAX_V 100


// ????????¨???
struct edge{int to,cap,rev;};

vector<edge> G[MAX_V];  //??°???????????????
int level[MAX_V];       //?§??????????????????¢
int iter[MAX_V];        //???????????§????????????

// from??????to?????????????????????cap???????????°?????????????????????
void add_edge(int from,int to,int cap){
	G[from].push_back(  (edge){ to  ,cap,(int)G[to  ].size()   }  );
	G[to  ].push_back(  (edge){ from,0  ,(int)G[from].size()-1 }  );
}

// s????????????????????¢???BFS??§?¨??????????
void bfs(int s){
	rep(i,MAX_V)level[i]=-1;
	queue<int> que;
	level[s]=0;
	que.push(s);
	while(!que.empty()){
		int v=que.front();que.pop();
		
		rep(i,G[v].size()){
			edge &e=G[v][i];
			if(e.cap>0 && level[e.to]<0){
				level[e.to]=level[v]+1;
				que.push(e.to);
			}
		}
	}
}

//?¢?????????????DFS??§??¢???
int dfs(int v,int t,int f){
	if(v==t)return f;
	for(int i=iter[v];i<G[v].size();i++){
		edge &e=G[v][i];
		if(e.cap>0&&level[v]<level[e.to]){
			int d=dfs(e.to,t,min(f,e.cap));
			if(d>0){
				e.cap-=d;
				G[e.to][e.rev].cap+=d;
				return d;
			}
		}
	}
	return 0;
}

// s??????t???????????§???????±???????
int max_flow(int s,int t){
	int flow=0;
	for(;;){
		bfs(s);
		if(level[t]<0)return flow;
		memset(iter,0,sizeof(iter));
		int f;
		while((f=dfs(s,t,INF))>0){
			flow+=f;
		}
	}
}


int main(){
	int v,e;
	cin>>v>>e;
	rep(i,e){
		int a,b,c;
		cin>>a>>b>>c;
		add_edge(a,b,c);
	}
	cout<<max_flow(0,v-1)<<endl;
}

Measured memory_bytes: 3184
#include<iostream>
using namespace std;
int main()
{
    char str[3][3];
    for (int i=0;i<3;i++)
        for (int j=0;j<3;j++)
            {
                cin>>str[i][j];
            }
    for(int i=0;i<3;i++)
    {
        cout<<str[i][i];
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    public class Prog
    {
        const int MOD = 1000000007;
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            new Prog().Solve(new ConsoleInput(Console.In, ' '));
            Console.Out.Flush();
        }

        public void Solve(ConsoleInput cin)
        {
            var n = cin.ReadInt;
            var a = cin.ReadIntArray(n);

            var b = 0d;

            for (int i = 0; i < n; i++)
            {
                b += 1d / (double)a[i];
            }

            var ans = (1d / b);

            Console.WriteLine(ans);
        }
    }
    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        public void ReadIntArrays(long N, out int[] A, out int[] B) { A = new int[N]; B = new int[N]; for (long i = 0; i < N; ++i) { A[i] = ReadInt; B[i] = ReadInt; } }
    }
}


Measured memory_bytes: 13268