akhauriyash/Code-Regression huggingface dataset:
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

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

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}

#[allow(unused)]
use std::cmp::{max, min};
#[allow(unused)]
use std::collections::HashMap;

#[allow(unused)]
fn gcd(x: i64, y: i64) -> i64 {
    if y == 0 {
        x
    } else {
        gcd(y, x % y)
    }
}

#[allow(unused)]
fn lcm(x: i64, y: i64) -> i64 {
    x * y / gcd(x, y)
}

fn main() {
    input! {
        // usize
        // n: usize,
        // vec
        // v: [i64; n],
        a: i64,
        b: i64,
    }

    let ans: i64;

    if (b - 1) % (a - 1) == 0 {
        ans = (b - 1) / (a - 1);
    } else {
        ans = (b - 1) / (a - 1) + 1;
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


class union_find_t {
public:
  union_find_t(int T) : T_(T), parent_(new int[T]), rank_(new int[T]), count_(new int[T]) {
    for (int i = 0; i < T_; i++) {
      parent_[i] = i;
      rank_  [i] = 0;
      count_ [i] = 1;
    }
  };

  ~union_find_t() {
    delete[] parent_;
    delete[] rank_;
    delete[] count_;
  };

public:
  int find(int x) {
    if (parent_[x] == x) {
      return x;
    }
    else {
      return parent_[x] = find(parent_[x]);
    }
  };

  void unite(int x, int y) {
    x = find(x);
    y = find(y);

    if (x == y)
      return;

    if (rank_[x] < rank_[y]) {
      parent_[x]  =        y;
      count_ [y] += count_[x];
    }
    else {
      parent_[y]  =        x;
      count_ [x] += count_[y];

      if (rank_[x] == rank_[y])
        rank_[x] ++;
    }
  };

  bool same(int x, int y) {
    return find(x) == find(y);
  };

public:
  int count(int x) {
    return count_[find(x)];
  };

private:
  int T_;

  int* parent_;
  int* rank_;
  int* count_;
};


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int N, M, A, B;

  std::cin >> N >> M;

  union_find_t uf(N);

  for (int i = 0; i < M; i ++) {
    std::cin >> A >> B;

    A --;
    B --;

    uf.unite(A, B);
  }

  int np = 0;

  for (int i = 0; i < N; i ++)
    np = std::max(uf.count(i), np);

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


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

using namespace std ;

int main ()
{
    string s ;
    long long g = 0 ;
    cin >> s ;
    int x = s . size ()  - 1 ;
    for ( int i = 0 ; i < ( 1 << x ) ; ++ i ){
        long long sum = s . at ( 0 ) - '0' ;
        for ( int j = 0 ; j < x ; ++ j ){
            if ( i & ( 1 << j ) ){
                g += sum ;
                sum = 0 ;
            }
            sum = sum * 10 + ( s . at ( j + 1 ) - '0' ) ;
        }
        g += sum ;
    }
    cout << g ;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define db(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<'\n'
const int N = 1e5;
const int inf = 1e9+9;
#define ll long long
ll w[N+9], val[N+9], mem[109][N+9];
// min weight for value j, from n to 1

ll dp(int i, int j) {
	if(j==0) return 0;
	if(i<0 || j<0) return inf;
	if(mem[i][j]!=-1) return mem[i][j];
	return mem[i][j] = min(dp(i-1, j), dp(i-1, j-val[i])+w[i]);
}
int main(){
	ios_base::sync_with_stdio(0);
	int a,b,n,W,T,cas=0;
	cin>>n>>W;
	for(int i=1;i<=n;++i) {
		cin>>w[i]>>val[i];
	}
	memset(mem, -1, sizeof(mem));
	int res = 0;
	for(int j=0;j<=N;++j) {
		if(dp(n, j) <= W) {
			res = max(res, j);
		}
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 86272
/*by freesteed*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define pb push_back
#define fill(x,c) memset(x,c,sizeof(x))
#define fi first
#define se second
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define caset int ___T; cin>>___T; for(int cs=1;cs<=___T;cs++)
#define get_be(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
//get_be biger & equal
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
const ll mod=1e9+7;
const ll oo=1e9+10;
const int Max = 1e6+10;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
//ll a[Max];
ll n,d;
void solve(){
	cin>>n>>d;
	cout<<(n+2*d)/(2*d+1);
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//caset{
		solve();
	//}
  	return 0;
}





Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#include <cassert>
#include <functional>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << x << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 10000


int main() {
  int N;

  cin >> N;

  int k = 2;

  while (k * (k - 1) / 2 < N) k++;

  if (k * (k - 1) / 2 != N) {
    puts("No");
    return 0;
  }

  puts("Yes");

  vector<int> ans[SIZE];

  int idx = 1;
  for (int i = 0; i < k; i++) {
    for (int j = i + 1; j < k; j++) {
      ans[i].push_back(idx);
      ans[j].push_back(idx);
      idx++;
    }
  }

  printf("%d\n", k);

  for (int i = 0; i < k; i++) {
    printf("%d", ans[i].size());
    for (int t : ans[i]) {
      printf(" %d", t);
    }
    puts("");
  }

  return 0;
}


Measured memory_bytes: 4504
Module Module1

    Sub Main()
        'let
        Dim tmp As String() = Split(Console.ReadLine())
        Dim N As Long = tmp(0)
        Dim K As Long = tmp(1)

        'var
        Dim ans As Long = Math.Abs(CLng(N Mod K <> 0))

        Console.WriteLine(ans)

    End Sub

End Module

Measured memory_bytes: 13536
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iomanip>
#include <functional>
#include <bitset>
#include <limits>
#include <cstdio>
#include <cmath>
#include <cassert>
#include <random>

#ifdef DEBUG
#include "library/Utility/debug.cpp"
#else
#define debug(...)
#endif

#define rep(i,n) for(int i=0;i<(n);++i)
#define EL '\n'
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using lnt = long long;
struct FIO{FIO(){std::cin.tie(0);std::cout.tie(0);std::ios_base::sync_with_stdio(0);std::cout<<std::fixed<<std::setprecision(15);}}fIO;
/*-*/

struct Node
{
	char c; bool end; int i;
	std::vector<int> to;
	Node(char c, bool end, int i) : c(c),end(end),i(i),to(26,-1) {}
};

int main() {
	int n;
	std::cin >> n;
	std::vector<std::string> s(n);
	rep(i,n) std::cin >> s[i];
	// create trie
	std::vector<Node> trie;
	trie.emplace_back(' ',false,0);
	auto add = [&](auto f,int i,std::string& t,int j) -> void {
		if(j==-1) {
			trie[i].end=true;
			return;
		}
		if(trie[i].to[t[j]-'a']==-1) {
			int k=trie.size();
			trie[i].to[t[j]-'a']=k;
			trie.emplace_back(t[j],false,k);
			f(f,k,t,j-1);
		} else {
			f(f,trie[i].to[t[j]-'a'],t,j-1);
		}
	};
	rep(i,n) {
		add(add,0,s[i],s[i].size()-1);
	}
	lnt ans=0;
	std::vector<lnt> v(26,0);
	std::vector<lnt> active(26,0);
	auto dfs = [&](auto f,int i) -> void {
		int activated=0;
		debug(i,v,ans,trie[i].c);
		int cc=trie[i].c-'a';
		if(i!=0&&active[cc]<v[cc]) {
			activated=v[cc]-active[cc];
			active[cc]+=activated;
		}
		if(trie[i].end) rep(j,26) ans+=active[j];
		rep(j,26) {
			int to=trie[i].to[j];
			if(to==-1) continue;
			if(trie[to].end) v[j]++;
		}
		rep(j,26) {
			int to=trie[i].to[j];
			if(to==-1) continue;
			f(f,to);
		}
		if(activated) {
			active[trie[i].c-'a']-=activated;
		}
		rep(j,26) {
			int to=trie[i].to[j];
			if(to==-1) continue;
			if(trie[to].end) v[j]--;
		}
	};
	dfs(dfs,0);
	print(ans-n);
}


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

class Program
{
    static int N;
    static int[] a;

    static void Main()
    {
        N = int.Parse(Console.ReadLine());
        a = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int x = a.Sum() / N;
        Console.WriteLine(Math.Min(Cost(x), Cost(x + 1)));
    }

    static long Cost(int x)
    {
        return a.Select(s => (long)Math.Pow(s - x, 2.0)).ToArray().Sum();
    }
}

Measured memory_bytes: 13396
import sys

def setLine(tempH, line):
    for i in range(0, len(line)):
        geo[tempH][i] = line[i:i+1]

def solve():
    person = 0
    for i in range(0,H):
        for j in range(0,W):
            if geo[i][j] is not "_":
                search(i,j)
                person += 1
    print(person)

def search(i,j):
    temp = geo[i][j]
    geo[i][j] = "_"
    for a in range(0,4):
        idx, jdy = i + dx[a], j + dy[a]
        if(isOnMap(idx, jdy)):
            if(isNeededToSolve(temp, idx, jdy)):
                search(idx,jdy)

def isOnMap(i,j): return (0<=i and 0<=j and i<H and j<W)

def isNeededToSolve(temp,i,j):
    target = geo[i][j]
    return (target is not "_" and temp is target)

limit = 10**7
sys.setrecursionlimit(limit)

H, W, tempH = -1, -1, 0
dx = [-1,0,1,0]
dy = [0,-1,0,1]
geo = [[0 for i in range(1)]for j in range(1)]
while True:
    line = input()
    if H is -1 and W is -1:
        p = line.split(" ")
        H, W = int(p[0]), int(p[1])
        geo = [[0 for i in range(W)] for j in range(H)]
    else:
        setLine(tempH, line)
        tempH+=1
    if H is 0 and W is 0:break
    if tempH is H:
        solve()
        H, W, tempH = -1, -1, 0

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

using namespace std;

// 素数判定
bool is_prime(int N) {
    int tmp;

    tmp = N;
    
    if(tmp == 1) {
        return false;
    }

    for (int a = 2; a * a <= N; a++) {
        if(tmp % a == 0) {
            return false;
        }
    }
    
    return true;
}

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

    int l, r;
    vector<int> count_like_number(100001, 0);
    vector<int> count(Q, 0);

    count_like_number[0] = 0;

    // 制約の各数について2017likeか判定して数を数える
    for(int i = 1; i <= 100000; i++) {
        if(is_prime(i) == true && is_prime((i+1)/2) == true) {
            count_like_number[i] = count_like_number[i-1] + 1;
        } else {
            count_like_number[i] = count_like_number[i-1];
        }
    }

    // 各クエリについて計算
    for(int k = 0; k < Q; k++) {
        cin >> l >> r;
        count[k] = count_like_number[r] - count_like_number[l-1];
    }

    for(auto c : count) {
        cout << c << endl;
    }

	return 0;
}

Measured memory_bytes: 4048
#include<iostream>
#include<string>
using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	string str;
	if (a > b) {
		str = string(a, '0'+b);
	}
	else {
		str = string(b, '0'+a);
	}
	cout << str << endl;
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
from collections import defaultdict
import math
import re

def main():
    A, B, T = map(int, input().split())

    num = 0
    for t in range(100):
        t += 1
        if t > T + 0.5:
            break
        if t % A == 0:
            num += B

    print(num)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3444
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;
int main()
{
  queue<int> Q;
  int n,u,k,vv,cur,dst;
  cin >> n;
  vector<int> D(n,-1),check(n,0);
  vector< vector<int> > v(n);
  for(int i = 0;i < n;++i){
    cin >> u >> k;
    for(int j = 0;j < k;++j){
      cin >> vv;
      v[u - 1].push_back(vv);
    }
    sort(v[u - 1].begin(),v[u - 1].end());
  }
  D[0] = 0;
  check[0] = 1;
  Q.push(1);
  while(!Q.empty()){
    cur = Q.front();
    Q.pop();
    for(int i = 0;i < v[cur - 1].size();++i){
      dst = v[cur - 1][i];
      if(check[dst - 1] == 0){
	D[dst - 1] = D[cur - 1] + 1;
	check[dst - 1] = 1;
	Q.push(dst);
      }
    }
  }
  for(int i = 0;i < n;++i)
    cout << i + 1 << " " << D[i] << endl;
}

Measured memory_bytes: 1224
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define lint long long
using namespace std;
int q,m=1000000007;
lint x,y,f[99]={0,1,1};
int main(){
	scanf("%d",&q);
	rep(i,96)f[i+3]=f[i+1]+f[i+2];
	rep(i,q){
		scanf("%lld %lld",&x,&y);
		if(x>y)swap(x,y);
		if(y<=2){
			printf("1 %d ",y==1?1:x==1?2:4);
			continue;
		}
		rep(j,99){
			if(x<f[j]||y<f[j+1]){
				lint a=x==1?2:1;
				rep(k,j-2){
					lint n=f[j-1]+f[j-3-k]*f[k+2],m=f[j]+f[j-2-k]*f[k+2];
					if(n<=x&&m<=y)a+=(y-m)/n+1;
				}
				if(f[j]<=x){
					a++;
					rep(k,j-2)a+=(x-f[j])/(f[j-2-k]*f[k+2]);
				}
				printf("%d %d ",j-2,a%m);
				break;
			}
		}
	}
}

Measured memory_bytes: 4332
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll mod = 998244353;
ll dp[3010] = {0}, ans = 0;
int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i++){
		int x;
		scanf("%d", &x);
		for (int j = m; j >= x; j--) {
			if (j == m) {
				if (m == x)ans = (ans + 1ll*i*(n-i+1)%mod) % mod;
				else if (m-x > 0) ans = (ans + 1ll*dp[m-x]*(n-i+1)%mod)%mod;
				
			}
			else if (j == x) {
				dp[j] = (dp[j] + i)%mod;
			}
			else dp[j] = (dp[j] + dp[j-x])%mod;
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 3800
#include"bits/stdc++.h"
using namespace std;

struct node {
	int cnt = 0;
	int parent=0;
	bool checked = false;
};

int cal(vector<node>& nodes, node& node) {
	if (node.checked) {
		return node.cnt;
	}else if (node.parent != 0) {
		node.checked = true;
		node.cnt += cal(nodes, nodes[node.parent]);
		return node.cnt;
	}
	else {
		node.checked = true;
		return node.cnt;
	}
}

int main() {
	int n, q;
	cin >> n >> q;
	vector<node> nodes(n+1);
	for (int i = 1;i < n;i++) {
		int tempa, tempb;
		cin >> tempa >> tempb;
		nodes[tempb].parent=tempa;
	}
	for (int i = 0;i < q;i++) {
		int tempp, tempx;
		cin >> tempp >> tempx;
		
		nodes[tempp].cnt+=tempx;

	}
	for (int i = 1;i <= n;i++) {
		cout << cal(nodes,nodes[i])<< ' ';
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 4736
#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_macros)]
#![allow(unused_variables)]
#![allow(unused_imports)]
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($y: expr),+) => {
        ::std::cmp::max($x, max!($($y),+))
    };
}

macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($y: expr),+) => {
        ::std::cmp::min($x, max!($($y),+))
    };
}

use std::cmp;
use std::collections::{HashSet, BinaryHeap, VecDeque};
use std::iter::FromIterator;
fn main() {
    input!{
        N: usize,
        edges: [(usize1, usize1, usize); N-1],
    }

    let mut e = vec![Vec::new(); N];
    for &(u, v, w) in edges.iter() {
        e[u].push((v,w));
        e[v].push((u,w));
    }

    let mut d = vec![std::usize::MAX; N];
    d[0] = 0;
    let mut q = HashSet::<usize>::from_iter(0..N);
    let mut costs = BinaryHeap::<EdgeCost>::with_capacity(N);
    costs.push(EdgeCost(0, 0));
    while q.len() > 0 {
        let EdgeCost(prev, cc) = costs.pop().unwrap();
        if !q.remove(&prev) {
            continue;
        }
        for &(qq, cc) in e[prev].iter() {
            if q.contains(&qq) {
                d[qq] = cmp::min(d[qq], d[prev] + cc);
                costs.push(EdgeCost(qq, d[qq]));
            }
        }
    }

    for &d in d.iter() {
        println!("{}", d%2);
    }
}

#[derive(Clone, Eq, PartialEq, PartialOrd)]
struct EdgeCost(usize, usize);
 
impl Ord for EdgeCost {
    fn cmp(&self, other: &Self) -> cmp::Ordering {
        self.1.cmp(&other.1)
    }
}

Measured memory_bytes: 22908
def readInt():
    return list(map(int, input().split()))

n = int(input())
a = readInt()
b = 0
ans = 0

for i in a:
    b += i ** 2

# print(sum(a))
ans = ((sum(a) ** 2 - b) // 2) % (10 ** 9 + 7)
print(ans)


Measured memory_bytes: 105296
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!

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

#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

using ll = int64_t; using vll = vector<ll>; using vvll = vector<vll>;
using pll = pair<ll, ll>; using vpll = vector<pll>; using vvpll = vector<vpll>;

// ------------------------------------------------------------------------------------------------

ll a, b, c, d;

ll query(ll x, ll y, ll z) {
    return y / z - x / z;
}

void func() {
    cin >> a >> b >> c >> d; a--;
    cout << b - a - query(a, b, c) - query(a, b, d) + query(a, b, c * d / __gcd(c, d)) << endl;
}

int main() {
    fast_io; cout.precision(32);
    ll t = 1; // cin >> t;
    for (ll i = 1; i <= t; i++) {
        func();
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define fi first
#define se second
#define inf (INT_MAX/2-1)
#define infl (1LL<<60)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define sz(a) (int)(a).size()
#define all(a) begin(a),end(a)
#define y0 y5656
#define y1 y7878
#define aaa system("pause");
#define dbg(x) cerr<<(#x)<<": "<<(x)<<'\n',aaa
#define dbga(x,n) cerr<<(#x)<<"[]: ";for(int _=0;_<n;_++)cerr<<x[_]<<' ';cerr<<'\n',aaa
#define dbgs(x) cerr<<(#x)<<"[stl]: ";for(auto _:x)cerr<<_<<' ';cerr<<'\n',aaa
#define dbgp(x) cerr<<(#x)<<": "<<x.fi<<' '<<x.se<<'\n',aaa
#define maxn 3000

using namespace std;

ll v[maxn+5][maxn+5];
ll d[maxn+5][maxn+5][5];

void umax (ll &a, ll b) {
  a = max(a, b);
}

int main () {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int n, m, k; cin >> n >> m >> k;
  int i, j, z;
  for (i = 1; i <= k; i++) {
    int a, b; cin >> a >> b;
    cin >> v[a][b];
  }
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++) {
      umax(d[i][j][0], d[i-1][j][3]);
      umax(d[i][j][1], d[i-1][j][3] + v[i][j]);
      for (z = 0; z <= 3; z++) {
        umax(d[i][j][z], d[i][j-1][z]);
        if (z < 3) umax(d[i][j][z+1], d[i][j-1][z] + v[i][j]);
        if (z > 0) umax(d[i][j][z], d[i][j][z-1]);
      }
    }
  cout << d[n][m][3];
  return 0;
}

Measured memory_bytes: 426080
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc1 = new Scanner(System.in);

		int k = sc1.nextInt();
		int ans = 0;

		if (k % 2 == 0) {
			ans = (k / 2) * (k / 2);
		}
		else {
			ans = (k / 2 + 1) * (k / 2);
		}

		System.out.println(ans);

		sc1.close();

	}

}


Measured memory_bytes: 23124
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct Node{
  int key;
  struct Node *right, *left, *parent;
};

struct Node *root, *NIL;

struct Node *find(struct Node *u, int k){
  while(u != NIL && k != u->key){
    if(k < u->key) u = u->left;
    else {
      u = u->right;
    }
  }
 return u;
}

void insert(int k){
  struct Node *y = NIL;
  struct Node *x = root;
  struct Node *z;

 z = (struct Node *)malloc(sizeof(struct Node));

  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key){
      x = x->left;
    }
    else {
      x = x->right;
    }
  }
  z->parent = y;
  if(y==NIL){
    root = z;
  }
  else {
    if(z->key < y->key){
      y->left = z;
    }
    else {
      y->right = z;
    }
  }
}

void inorder(struct Node *u){
  if(u == NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(struct Node *u){
  if(u == NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

int main(){
  int n,i,x;
  char com[1000];

  scanf("%d",&n);

  for(i=0; i<n; i++){
    scanf("%s",com);
    if(com[0]=='f'){
      scanf("%d",&x);
      struct Node *t = find(root,x);
      if(t!=NIL) printf("yes\n");
      else {
        printf("no\n");
      }
    }
      else if(!strcmp(com,"insert")){
        scanf("%d",&x);
        insert(x);
      }
      else if(!strcmp(com,"print")){
        inorder(root);
        printf("\n");
        preorder(root);
        printf("\n");
      }
    }

  return 0;
}



Measured memory_bytes: 20440
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
//typedef tree<int,null_type,less<int >,rb_tree_tag,tree_order_statistics_node_update>indexed_set;
template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p);
template <class T>
ostream &operator <<(ostream &os, vector<T>&v);
template <class T>
ostream &operator <<(ostream &os, set<T>&v);
#define debug(a) cerr<<#a<<" --> "<<(a)<<endl;
#define fastInput ios_base::sync_with_stdio(false);cin.tie(0)
#define INPUT freopen("input.txt","r",stdin)
#define OUTPUT freopen("output.txt","w",stdout)
#define ERROR  1e-9
#define pi (2*acos(0))
const ll mod = 998244353;
const int N = 1e5 +5;
ll dp[N][4];
ll cnt[N];
ll n;

ll fun(ll idx, ll porer)
{
    //cout<<idx<<" "<<porer<<endl;
    if(idx==n)
    {
        if(porer==0)
        {
            return 0;
        }
        else{
            return -1e15;
        }
    }
    ll &ret = dp[idx][porer];
    if(ret!=-1)
        return ret;
    ll now = cnt[idx]- porer;
    if(now<0)
    {
        return -1e15;
    }
    ll ans = (now/2) + fun(idx+1,0);
    if(now)
        ans= max(ans , ((now-1)/2)+1+ fun(idx+1, 1));

    return ret = ans;
}
void SOLVE(int cas)
{
    memset(dp,-1,sizeof dp);
    scanf("%lld",&n);
    for(ll i=0;i<n;i++)
    {
        scanf("%lld",&cnt[i]);
    }
    printf("%lld\n",fun(0,0));

}


/*


*/



int main()
{
    //INPUT;
    //OUTPUT;
    int t=1,cas=0;
    //scanf("%d",&t);
    while(t--)
    {
        SOLVE(++cas);
    }

    return 0;
}



//os.order_of_key(v): returns how many elements strictly less than v
//os.find_by_order()

template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p)
{
    os<<"{"<<p.first<<", "<<p.second<<"} ";
    return os;
}
template <class T>
ostream &operator <<(ostream &os, vector<T>&v)
{
    os<<"[ ";
    for(int i=0; i<v.size(); i++)
    {
        os<<v[i]<<" " ;
    }
    os<<" ]";
    return os;
}

template <class T>
ostream &operator <<(ostream &os, set<T>&v)
{
    os<<"[ ";
    for(T i:v)
    {
        os<<i<<" ";
    }
    os<<" ]";
    return os;
}


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

using namespace std;

typedef long long ll;

int main() {
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int h;
        cin >> h;
        n -= h;
        if (n < 0) {
            cout << -1;
            return 0;
        }
    }
    cout << n;
    return 0;
}


Measured memory_bytes: 3636
import sys

if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
    
    
    
N,M=map(int,input().split())
a=0
b=0
AC=[0]*(N+1)
pen=[0]*(N+1)
p=0
l=[]
for i in range(M):
	j,r=input().split()
	if AC[int(j)]==0:
		if r=="WA":
			pen[int(j)]+=1
		else:
			AC[int(j)]+=1
for k in range(N+1):
	if AC[k]==1:
		p+=pen[k]

print(sum(AC),p)
	

Measured memory_bytes: 4596
#include<bits/stdc++.h>
#define ALL(c) begin(c), end(c)
using namespace std;
using ll = long long;
using ld = long double;


void go_karatsuba(auto a, auto b, auto ret, size_t n){
    if(n<=10){
        fill(ret, ret+n*2-1, 0);
        for(size_t i=0; i<n; ++i)
        for(size_t j=0; j<n; ++j) ret[i+j] += a[i]*b[j];
    }else
    if(n&1){
        go_karatsuba(a,b,ret,n-1);
        ret[n*2-3] = 0;
        for(size_t i=0; i<n-1; ++i) ret[i+n-1] += a[i]*b[n-1] + b[i]*a[n-1];
        ret[n*2-2] = a[n-1]*b[n-1];
    }else{
        auto ar = a, al = a+n/2, 
		     br = b, bl = b+n/2,
        	 asum = ret+n*5, bsum = asum+n/2,
        	 x1 = ret, x2 = x1+n, x3 = x2+n;
        for(size_t i=0; i<n/2; ++i){
            asum[i] = al[i] + ar[i];
            bsum[i] = bl[i] + br[i];
        }
        go_karatsuba(ar, br, x1, n/2);
        go_karatsuba(al, bl, x2, n/2);
        go_karatsuba(asum, bsum, x3, n/2);
        for(size_t i=0; i<n; ++i) x3[i] -= x1[i]+x2[i];
        for(size_t i=0; i<n; ++i) ret[i+n/2]+=x3[i];
	}
	ret[n*2-1] = 0;
}

template<class T>
vector<T> mul(const vector<T> &_a, const vector<T> &_b){
	auto n = max(size(_a), size(_b));
	vector<T> a(n), b(n);
	copy(ALL(_a), begin(a));
	copy(ALL(_b), begin(b));
	vector<T> ret(n*6);
	go_karatsuba(begin(a), begin(b), begin(ret), n);
	return vector<T>(begin(ret), begin(ret)+size(_a)+size(_b)-1);
} 


int main(){
	//freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout);
	ios::sync_with_stdio(0);cin.tie(0);//cout.precision(12);cout<<fixed;
	
	const int P = 2e5+3;
	const int g = 2;
	
	vector<int> f(P);
	for(int x=1,i=0;i<P-1;++i){
		f[x] = i;
		x = 1LL*x*g %P;
	}
	
	int n;
	cin>>n;
	
	vector<int> a(n);
	for(auto &_ : a) cin>>_;
	//ll answer = 0;
	//for(int i=0;i<n;++i) for(int j=0;j<n;++j) answer+=1LL*a[i]*a[j]%P;
	
	vector<ll> cnt(P-1);
	for(int x : a){
		x%=P;
		if(x) cnt[f[x]]++;
		//cerr<<x<<' '<<f[x]<<endl;
	}
	
	//for(int i=0;i<P;++i) cout<<cnt[i]<<' '; cout<<endl;
	
	auto m = mul(cnt,cnt);
	//for(auto x : m) cout<<x<<' '; cout<<endl;
	for(int i=P-1;i<size(m);++i) m[i%(P-1)]+=m[i];
	m.resize(P-1);
	//for(auto x : m) cout<<x<<' '; cout<<endl;
	
	ll ans = 0;
	for(int i=0,x=1; i<P-1; ++i, x=1LL*x*g%P) ans+=m[i]*x;
	
	for(int x:a) ans-=1LL*x*x%P;
	ans/=2;
	
	cout<<ans<<endl;
	
	//cout<<answer<<endl;
	
	return 0;
}


Measured memory_bytes: 21912
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;

typedef long long ll;
const ll maxn=1e3+10,mod=1e9+7;
ll n,m,k;
char s[maxn][maxn];
struct matrix{
	ll x[4][4],lenx,leny;
	matrix(ll a,ll b){
		memset(x,0,sizeof(x));
		lenx=a;leny=b;
	}
	inline void e(){
		for(ll i=0;i<lenx;++i)
			x[i][i]=1;
	}
	matrix operator* (matrix o){
		matrix res(lenx,o.leny);
		for(ll i=0;i<lenx;++i)
			for(ll j=0;j<o.leny;++j)
				for(ll k=0;k<leny;++k)
					(res.x[i][j]+=x[i][k]*o.x[k][j])%=mod;
		return res;
	}
};
inline matrix qpow(matrix a,ll n){
	matrix res(a.lenx,a.leny);res.e();
	while(n){
		if(n&1ll)
			res=res*a;
		a=a*a;
		n>>=1;
	}
	return res;
}
inline ll qpow(ll a,ll n){
	ll res=1;
	while(n){
		if(n&1ll)
			res=res*a%mod;
		a=a*a%mod;
		n>>=1;
	}
	return res;
}

inline void judge(){
	if(!k){
		puts("1");
		exit(0);
	}
	bool flag1=false,flag2=false;
	for(ll i=0;i<m;++i)
		if(s[0][i]=='#'&&s[n-1][i]=='#')
			flag1=true;
	for(ll i=0;i<n;++i)
		if(s[i][0]=='#'&&s[i][m-1]=='#')
			flag2=true;
	if(flag1&&flag2){
		puts("1");
		exit(0);
	}
	if(!flag1&&!flag2){
		ll cnt=0;
		for(ll i=0;i<n;++i)
			for(ll j=0;j<m;++j)
				if(s[i][j]=='#')
					++cnt;
		printf("%lld\n",qpow(cnt,k-1));
		exit(0);
	}
	if(flag1){
		for(ll i=0;i<n;++i)
			for(ll j=0;j<m;++j)
				if(i>=m||j>=n)
					s[j][i]=s[i][j];
				else if(i<j)
					swap(s[i][j],s[j][i]);
		swap(n,m);
	}
}

int main(){
	scanf("%lld%lld%lld",&n,&m,&k);
	for(ll i=0;i<n;++i)
		scanf("%s",s[i]);
	judge();
	matrix res(1,4),base(4,4);
	for(ll i=0;i<n;++i){
		if(s[i][0]=='#')
			if(s[i][m-1]=='#')
				if(s[i][1]=='#')
					++base.x[0][1],++base.x[1][1],++base.x[2][3],++base.x[3][3];
				else
					++base.x[0][0],++base.x[1][0],++base.x[2][2],++base.x[3][2];
			else
				if(s[i][1]=='#')
					++base.x[0][1],++base.x[1][1],++base.x[2][1],++base.x[3][1];
				else
					++base.x[0][0],++base.x[1][0],++base.x[2][0],++base.x[3][0];
		for(ll j=1;j<m-1;++j)
			if(s[i][j]=='#')
				if(s[i][j-1]=='#')
					if(s[i][j+1]=='#')
						++base.x[0][3],++base.x[1][3],++base.x[2][3],++base.x[3][3];
					else
						++base.x[0][2],++base.x[1][2],++base.x[2][2],++base.x[3][2];
				else
					if(s[i][j+1]=='#')
						++base.x[0][1],++base.x[1][1],++base.x[2][1],++base.x[3][1];
					else
						++base.x[0][0],++base.x[1][0],++base.x[2][0],++base.x[3][0];
		if(m>1&&s[i][m-1]=='#')
			if(s[i][m-2]=='#')
				if(s[i][0]=='#')
					++base.x[0][2],++base.x[1][3],++base.x[2][2],++base.x[3][3];
				else
					++base.x[0][2],++base.x[1][2],++base.x[2][2],++base.x[3][2];
			else
				if(s[i][0]=='#')
					++base.x[0][0],++base.x[1][1],++base.x[2][0],++base.x[3][1];
				else
					++base.x[0][0],++base.x[1][0],++base.x[2][0],++base.x[3][0];
	}
	res.x[0][0]=1;
	res=res*qpow(base,k-1);
	printf("%lld\n",(res.x[0][0]+res.x[0][2])%mod);
	return 0;
}

Measured memory_bytes: 1280
import math

def resolve():
    a,b,h,m = map(int, input().split())
    a_deg = h*30 + m*0.5
    b_deg = m*6
    angle = abs(a_deg - b_deg)
    if angle == 0 or angle == 360:
        print(abs(b-a))
        return
    elif angle == 180:
        print(a+b)
        return 
    elif angle > 180:
        angle = 360 - angle
    rad = math.radians(angle)
    sq_c = a*a + b*b - 2*a*b*math.cos(rad)
    print(math.sqrt(sq_c))

resolve()

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

int a, L;

void fill_zero(string &s) {
    while ((int)s.size() < L) {
        s = "0" + s;
    }
}

int main() {
    while (cin >> a >> L, L) {
        string s = to_string(a);
        fill_zero(s);
        
        map<string, int> mp;
        int cnt = 1;
        while (true) {
            if (mp.find(s) != mp.end()) {
                cout << mp[s] - 1 << " " << stoi(s) << " " << cnt - mp[s] << endl;
                break;
            }
            mp[s] = cnt++;
            string a, b;
            a = b = s;
            sort(a.begin(), a.end());
            sort(b.rbegin(), b.rend());
            s = to_string(stoi(b) - stoi(a));
            fill_zero(s);
        }
    }
}


Measured memory_bytes: 3244
let K = readLine()!.split(separator: " ").map({Int($0)!})[1]
let A = readLine()!.split(separator: " ").map({Int($0)! - 1})

var visit: [Int: Int] = [:]

var cities: [Int] = []
var city = 0
while visit[city] == nil {
    visit[city] = cities.count
    cities.append(city)
    city = A[city]
}

if K < cities.count {
    print(cities[K] + 1)
} else {
    let start = visit[city]!
    print(cities[start + (K - start) % (cities.count - start)] + 1)
}


Measured memory_bytes: 26504
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

bool even(string& s) {
  if (s.size() % 2 == 1) return false;
  int n = s.size() / 2;
  for (int i = 0; i < n; i++) {
    if (s[i] != s[i+n]) return false;
  }
  return true;
}

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

  int n;
  cin >> n;

  vector<long> a(n);
  for (auto& i : a) {
    cin >> i;
  }

  if (n == 1) {
    cout << a[0] << endl;
    return 0;
  }

  for (int i = n-1; i >= 0; i-=2) {
    cout << a[i] << " ";
  }

  int j = n % 2 == 0 ? 0 : 1;
  for (int i = j; i < n; i+=2) {
    cout << a[i];
    if (i < n-2) cout << " ";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 3712
#pragma region header
#include <bits/stdc++.h>
using namespace std;

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;

constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
constexpr char EL[] = "\n";

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define UNIQUE(x) (x).erase(unique(all(x)), (x).end());
#define REPIT(x) for(auto it=(x).begin(), end=(x).end(); it!=end; ++it)
#define perm(c) sort(all(c)); for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<typename T = i64>
T IN() { T x; cin >> x; return (x); }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}

void print() {
  cout << EL;
}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
	cout << a;
	if (&a != &vec.back()) cout << " ";
  }
  cout << EL;
}
template <class T>
void print(vector<vector<T>> &df) {
  for (auto& vec : df) {
	print(vec);
  }
}

struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

signed solve()
{
	int x;
	cin >> x;
	print(x < 1200 ? "ABC" : "ARC");
	return 0;
}

#ifndef LOCALCODE
signed main()
{
	return solve();
}
#endif


Measured memory_bytes: 256
import java.util.Scanner;

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

        Scanner scanner = new Scanner(System.in);
        Integer a = scanner.nextInt();
        Integer b = scanner.nextInt();

        Integer x = a / b;
        Integer y = a % b;
        double z = (double) a / (double) b;
        System.out.println(x + " " + y + " " + String.format("%.5f", z));
    }
}


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

int main() {
	
	int n;
	cin >> n;
	ostringstream oss;
	oss << n;
	cout << "ABC" + oss.str() << endl;
	
	return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}
#define N 100010
vector<P> g[N];
ll d[N];
bool used[N];
void dfs(int u){
	used[u] = true;
	for(auto p: g[u]){
		if(used[p.fst]) continue;
		d[p.fst] = d[u]+p.snd;
		dfs(p.fst);
	}
}
int main(){
	int n;
	cin>>n;
	rep(i, n-1){
		ll a, b, c;
		cin>>a>>b>>c;
		a--; b--;
		g[a].pb(P(b, c));
		g[b].pb(P(a, c));
	}
	int q, k;
	cin>>q>>k;
	dfs(k-1);
	rep(_, q){
		ll a, b;
		cin>>a>>b;
		a--; b--;
		cout<<d[a]+d[b]<<endl;
	}
	return 0;
}


Measured memory_bytes: 12800
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;



int main(){
    ll n;
    cin>>n;
    vector<pll> a(n*2);
    for(int i=0;i<n;i++){
        ll A,B;
        cin>>A>>B;
        a[i*2]={A,1};
        a[i*2+1]={B,-1};
    }
    sort(a.begin(),a.end());
    ll sum=0;
    ll ans=0;
    for(int i=0;i<a.size();i++){
        sum+=a[i].S;
        ans=max(ans,sum);
    }
    cout<<ans<<endl;
    
    
    
    return 0;
}



Measured memory_bytes: 6004
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MD=1e9+7;
string s;
int l,d;
ll dp[12345][2][102];
ll fun(int i,int st,int su)
{
	if(dp[i][st][su]!=-1) return dp[i][st][su];
	if(i==l)
	{
		if(su==0) return 1;
		else return 0;
	}
	ll ans=0;
	for(int j=0;j<10;j++)
	{
		if(!st)
		{
			if(j<s[i]-'0')
			ans=(ans+fun(i+1,1,(su+j)%d))%MD;
			else if(j==s[i]-'0')
			ans=(ans+fun(i+1,0,(su+j)%d))%MD;
		}
		else
		ans=(ans+fun(i+1,1,(su+j)%d))%MD;
	}
	return dp[i][st][su]=ans;
}
int main()
{
	cin>>s>>d;
	l=s.length();
	memset(dp,-1,sizeof(dp));
	cout<<(fun(0,0,0)-1+MD)%MD;
	return 0;
}

Measured memory_bytes: 20864
S = input()
Month = []
for i in range(1,13):
    if i < 10:
        Month.append("0" + str(i))
    else:
        Month.append(str(i))
YYMMpt = 0
MMYYpt = 0
if S[0:2] in Month:
    MMYYpt += 1
if S[2:4] in Month:
    YYMMpt += 1
if YYMMpt == 0 and MMYYpt == 0:
    print("NA")
elif YYMMpt == 0 and MMYYpt == 1:
    print("MMYY")
elif YYMMpt == 1 and MMYYpt == 0:
    print("YYMM")
else:
    print("AMBIGUOUS")

Measured memory_bytes: 3064
import java.math.BigDecimal;
import java.math.MathContext;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a[] = new int[3];
        for (int i = 0;i < 3;++i){
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        System.out.println(Math.abs(a[0] - a[2]));
    }
}


Measured memory_bytes: 21716
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <numeric>
#include <utility>
#include <iomanip>

using namespace std;
using int64 = long long;

struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;

int main() {
    string s, t;
    cin >> s >> t;
    if (s.size() < t.size()) {
        cout << "UNRESTORABLE" << endl;
        return 0;
    }

    bool check = true;
    for (int i=s.size()-t.size(); i>=0; i--) {
        bool f = true;
        for (int j=0; j<t.size(); j++) {
            if (s[i+j] == t[j] || s[i+j] == '?')
                continue;
            f = false;
            break;
        }
        if (f) {
            for (int j=0; j<t.size(); j++)
                s[i+j] = t[j];
            check = false;
            break;
        }
    }
    if (check) {
        cout << "UNRESTORABLE" << endl;
        return 0;
    }

    for (auto i : s)
        cout << (i=='?'?'a':i);
    cout << endl;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int n; cin >> n;
    vector<int> A;
    A.push_back(0);
    rep(i,n){
        int a; cin >> a;
        A.push_back(a);
    }
    A.push_back(0);
    int sum = 0;
    rep(i,n+1) sum += abs(A[i+1] - A[i]);
    for(int i = 1; i <= n; i++){
        int ans = sum;
        ans -= abs(A[i] - A[i-1]);
        ans -= abs(A[i+1] - A[i]);
        ans += abs(A[i+1] - A[i-1]);
        cout << ans << endl;
    }
}

Measured memory_bytes: 1784
st = list()
while True:
    a = list(map(lambda x: int(x),input().split(" ")))
    if min(a[0:2]) == -1:
        if max(a) == -1:
            break
        else:
            st += {"F"}
    else:
        if 80 <= sum(a[0:2]):
            st += {"A"}
        elif 65 <= sum(a[0:2]):
            st += {"B"}
        elif 50 <= sum(a[0:2]):
            st += {"C"}
        elif 30 <= sum(a[0:2]):
            if 50 <= a[2]:
                st += {"C"}
            else:
                st += {"D"}
        else:
            st += {"F"}
    
for s in st:
    print(s)

Measured memory_bytes: 6724
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <list>
#define rep(i,n) for(int i=0; i<n; ++i)
using namespace std;

int main() {
    int n; string s;
    cin >> n >> s;
    vector<char> ans;
    ans.clear();
    for (int i = 0; i < n; ++i) {
        if (i == 0) ans.push_back(s[i]);
        else {
            if (s[i - 1] != s[i]) ans.push_back(s[i]);
        }
    }
    cout << ans.size() << endl;
    return 0;
}



Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main(){
  int h,w;
  cin>>h>>w;
  vector<string>a(h);
  for(int i=0;i<h;i++){
    cin>>a[i];
  }
  vector<bool>row(h,false);
  vector<bool>col(w,false);
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(a[i][j]=='#'){
        row[i]=true;
        col[j]=true;
      }
    }
  }
  for(int i=0;i<h;i++){
    if(row[i]){
      for(int j=0;j<w;j++){
        if(col[j]){
          cout<<a[i][j];
        }
      }
      cout<<endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
ll c[601][601], c1[601][601], c2[601][601];
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w;
    cin >> h >> w;
    for (int i = 0; i < h; i++) {
        string s;
        cin >> s;
        for (int j = 0; j < w; j++) {
            if (s[j] == '#') {
                c[i + j][i - j + 300]++;
            }
        }
    }
    for (int i = 0; i <= 600; i++) {
        c1[i][0] = c[i][0];
        for (int j = 1; j <= 600; j++) {
            c1[i][j] = c1[i][j - 1] + c[i][j];
        }
    }
    for (int i = 0; i <= 600; i++) {
        c2[0][i] = c[0][i];
        for (int j = 1; j <= 600; j++) {
            c2[j][i] = c2[j - 1][i] + c[j][i];
        }
    }
    ll res1 = 0, res2 = 0;
    for (int i = 0; i <= 600; i++) {
        for (int j = 0; j <= 600; j++) {
            for (int k = j + 1; k <= 600; k++) {
                if (c[i][j] && c[i][k]) {
                    if (i + k - j <= 600) {
                        res1 += c[i + k - j][k] + c[i + k - j][j];
                        res2 += c1[i + k - j][k - 1] - c1[i + k - j][j];
                    }
                    if (i - (k - j) >= 0) {
                        res1 += c[i - (k - j)][k] + c[i - (k - j)][j];
                        res2 += c1[i - (k - j)][k - 1] - c1[i - (k - j)][j];
                    }
                }
                if (c[k][i] && c[j][i]) {
                    if (i + k - j <= 600) {
                        res1 += c[k][i + k - j] + c[j][i + k - j];
                        res2 += c2[k - 1][i + k - j] - c2[j][i + k - j];
                    }
                    if (i - (k - j) >= 0) {
                        res1 += c[k][i - (k - j)] + c[j][i - (k - j)];
                        res2 += c2[k - 1][i - (k - j)] - c2[j][i - (k - j)];
                    }
                }
            }
        }
    }
    cout << res1 / 2LL + res2 << endl;
}

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

int n, p, x[105], y[105], S[105][105];
int dp[105][105][105];

int main(){
  
  cin>>n>>p;
  
  for(int i=0;i<n;i++) cin>>x[i]>>y[i];
  
  for(int i=0;i<n;i++)
    for(int j=i+1;j<n;j++){
      
      int t=0;
      
      for(int k=i;k<j;k++) t=max(0, y[k]-max(0, x[k]-t));
      
      S[i][j]=t;
    }
  
  memset(dp,-1,sizeof(dp));
  
  dp[0][0][0]=p;
  
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
      for(int k=0;k<n;k++){
	
	if(dp[i][j][k]==-1) continue;
	
	int X=max(0, x[i]-S[i-k][i]);
	
	int t=max(0, y[i]-X);
	
	if(t<=dp[i][j][k]) dp[i+1][j+1][k+1]=max(dp[i+1][j+1][k+1], dp[i][j][k]-t);
	
	dp[i+1][j][0]=max(dp[i+1][j][0], dp[i][j][k]);
      }
  
  int ans=0;
  
  for(int i=0;i<=n;i++)
    for(int j=0;j<=n;j++)
      if(dp[n][i][j]!=-1) ans=max(ans, i);
  
  cout<<ans<<endl;
  
  return 0;
}

Measured memory_bytes: 7672