akhauriyash/Code-Regression huggingface dataset:
function main(){
  var i = 0;
  while(true){
    var fieldInfo = input[i].split(' ');
    var width = fieldInfo[0] - 0;//toInt
    var height = fieldInfo[1] - 0;//toInt

    // 0 0が入力された
    if(!width && !height){
      break;
    }

    var start;
    var goal;
    var elem = [[],[],[],[],[]];
    for(var ei = 0;ei < 5; ei++){
      elem[ei].length = 0;
    }
    
    for(var y = 0; y < height; y++){
      i++;//1行進める
      for(var x = 0; x < width; x++){
        var c = input[i][x];

        switch(c){
        case 'S':
          start = new Pos(x, y);
          break;
        case 'G':
          goal = new Pos(x, y);
          break;
        case '.':
          break;
        default : // 入力値が正しいので、絶対に属性
          elem[c-1][elem[c-1].length] = new Pos(x, y);
          break;
        }
      }
    }

    
    var bestElement = -1;
    var distance = Infinity;
    
    // 属性ごとにループ
    for (var startElem = 0; startElem < 5; startElem++) {
      // DPの初期化 DP[属性][同じ属性内の連番]
      var dp = [[],[],[],[],[]];
      for(var h = 0; h < 5; h++){
        var hLength = elem[h].length;
        dp[h].length = hLength;
        for(var hidx = 0; hidx < hLength; hidx++){
          dp[h][hidx] = Infinity;
        }
      }
      
      // 最初に選んだパチモンから次に捕まえられる属性番号
      var first = (startElem + 1) % 5;

      for (var j = 0, firstLength = elem[first].length; j < firstLength; j++) {
        // s→e1を計算
        dp[first][j] = dist(start, elem[first][j]);
      }
      
      // s->1->2->3->4->g
      // なので、ループは間の-> * 3分まわす
      for (var e = 0; e < 3; e++) {
        // ex->e(x+1)
        var now = (first + e) % 5;
        var next = (now + 1) % 5;

        for (var j = 0, nowLength = elem[now].length; j < nowLength; j++) {
          for (var k = 0, nextLength = elem[next].length; k < nextLength; k++) {
            dp[next][k] = min(
              dp[next][k],
              dp[now][j] + 
                  dist(elem[now][j], elem[next][k]));
          }
        }
      }
      
      var last = (first + 3) % 5;
      var lastLength = elem[last].length;
      for (var j = 0; j < lastLength; j++) {
        // e4->g
        var d = dp[last][j] + 
                    dist(elem[last][j], goal);
        
        if (d < distance) {
          distance = d;
          bestElement = startElem + 1;
        }
        
      }
      
    }
    
    if (distance == Infinity) {
      console.log("NA");
    } else {
      console.log(bestElement + " " + distance);
    }

    i++;
  }
  

}

function dist(from, to){
  return Math.abs(from.x - to.x) + Math.abs(from.y - to.y)
}

function min(a1, a2){
  return a1 < a2 ? a1 : a2;
}

function Pos(a, b){
  this.x = a;
  this.y = b;
}

var
input = '';

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
process.stdin.on('end', function() {
  input = input.split('\n');
  main();
});

Measured memory_bytes: 61440
"use strict";
const main = arg => {
  let city = arg.split("\n")[0];
  let monster = arg.split("\n")[1].split(" ").map(n=> n*1);
  let yusya =  arg.split("\n")[2].split(" ").map(n=> n*1);
  let ans = 0;
  for(let i = 0; i < city; i++){
    // まずは左側にあるモンスターを全力で倒す
    let left = Math.min(monster[i],yusya[i]);
    ans += left;
    // monster[i] -= left;
    yusya[i] -= left;
    
    // 残った戦力で右を全力で倒す
    let right = Math.min(monster[i+1],yusya[i]);
    ans += right;
    monster[i+1] -= right;
    //yusya[i] -= right;
  }
  console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 32172
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>

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 FORR(i, m, n) for(int i = n;i >= m;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 999999999
#define MINF -999999999
#define ALL(n) n.begin(),n.end()
#define MP make_pair
#define F first
#define S second

int main() {
	string s;
	cin >> s;
	if (s[0] == 'A' && s[1] == 'K' && s[2] == 'I' && s[3] == 'H') {
		if (s[4] == 'A' && s[5] == 'B') {
			if (s[6] == 'A' && s[7] == 'R') {
				if ((s[8] == 'A' and s[9] == '\0') or s[8] == '\0') {
					cout << "YES" << endl;
					return 0;
				}
			}
			if (s[6] == 'R') {
				if ((s[7] == 'A' and s[8] == '\0') or s[7] == '\0') {
					cout << "YES" << endl;
					return 0;
				}
			}
		}
		if (s[4] == 'B') {
			if (s[5] == 'A' && s[6] == 'R') {
				if ((s[7] == 'A' and s[8] == '\0') or s[7] == '\0') {
					cout << "YES" << endl;
					return 0;
				}
			}
			if (s[5] == 'R') {
				if ((s[6] == 'A' and s[7] == '\0')or s[6] == '\0') {
					cout << "YES" << endl;
					return 0;
				}
			}
		}
	}
	else if (s[0] == 'K' && s[1] == 'I' && s[2] == 'H') {
		if (s[3] == 'A' && s[4] == 'B') {
			if (s[5] == 'A' && s[6] == 'R') {
				if ((s[7] == 'A' and s[8] == '\0') or s[7] == '\0') {
					cout << "YES" << endl;
					return 0;
				}
			}
			if (s[5] == 'R') {
				if ((s[6] == 'A' and s[7] == '\0') or s[6] == '\0') {
					cout << "YES" << endl;
					return 0;
				}
			}
		}
		if (s[3] == 'B') {
			if (s[4] == 'A' && s[5] == 'R') {
				if ((s[6] == 'A' and s[7] == '\0') or s[6] == '\0') {
					cout << "YES" << endl;
					return 0;
				}
			}
			if (s[4] == 'R') {
				if ((s[5] == 'A' and s[6] == '\0') or s[5] == '\0') {
					cout << "YES" << endl;
					return 0;
				}
			}
		}
	}
	cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 256
from sys import stdin,stdout
input = stdin.readline
def write(n,sep="\n"):
	stdout.write(str(n))
	stdout.write(sep)
def gil():
	return list(map(int, input().split()))
X, K, D = map(int, input().split())
X = abs(X)
if X >= K * D:
    print(abs(X - K * D))
    exit()
mov = X // D    
if abs(X-mov*D) > abs(X-(mov+1)*D):
    mov += 1
rem = abs(X-mov*D)
mov = K - mov   
mov = mov % 2
print(abs(rem-mov*D))

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

using namespace std;

int main()
{
    int x, n;

    vector<int> p;

    cin >> x >> n;

    for (int i = 0; i < n; ++i)
    {
        p.emplace_back();
        cin >> p.back();
    }

    for (int i = 0;; ++i)
    {
        if(x - i < 0)
        {
            cout << 0 << "\n";
            return 0;
        }

        auto itr = find(p.begin(), p.end(), x - i);
        if (itr == p.end())
        {
            cout << x - i << "\n";
            return 0;
        }
        
        itr = find(p.begin(), p.end(), i + x);
        if (itr == p.end())
        {
            cout << i + x << "\n";
            return 0;
        }

    }

        return 0;
}

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

int main(){
  int N,a;
  cin>>N;
  a=N%10;
  if(a==3){
    cout<<"bon";
  }else if(a==0||a==1||a==6||a==8){
    cout<<"pon";
  }else{
    cout<<"hon";
  }
}

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

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

  int n;
  cin >> n;

  double even = 0;
  double odd = 0;
  for (int i = 1; i <= n; i++) {
    if (i % 2 == 0) {
      even++;
    } else {
      odd++;
    }
  }

  double ans = odd / n;

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
import heapq

n,m = list(map(int, input().split()))
h = []
for i in range(n):
  a, b = list(map(int, input().split()))
  heapq.heappush(h, (a, b))

ans = 0
remain = m
for i in range(len(h)):
  price, count = heapq.heappop(h)
  if(remain - count <= 0):
    ans += price * remain
    print(ans)
    exit()
  else:
    ans += price * count
    remain -= count

Measured memory_bytes: 16712
#include <stdio.h>
#define maxn 200010
#define LL long long
#define mod 1000000007
LL a[maxn],sum,ans;//防int溢出，long long最方便。
int main(){
	int n,i;
	scanf("%d",&n);
	for(i=1;i<=n;i++)scanf("%lld",&a[i]);
	for(i=2;i<=n;i++)sum=(sum+a[i])%mod;
	for(i=1;i<n;i++)ans=(ans+a[i]*sum)%mod,sum=((sum-a[i+1])%mod+mod)%mod;
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 3272
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

string S = "";
string T = "";
ll dp[3005][3005];
ll N, M;

ll rec(int indS, int indT) {
	if(indS >= N) {
		return 0;
	}
	if(indT >= M) {
		return 0;
	}
	ll &ans = dp[indS][indT];
	if(ans != -1) {
		return ans;
	}
	if(S[indS] == T[indT]) {
		ans = 1 + rec(indS + 1, indT + 1);
	}
	else {
		ans = max(rec(indS + 1 , indT), rec(indS, indT + 1));
	}
	return ans;
}

void stringFound(int indS, int indT) {
	if(indS >= N) {
		return;
	}
	if(indT >= M) {
		return;
	}
	int ans = rec(indS, indT);
	if(S[indS] == T[indT]) {
		cout << S[indS];
		return stringFound(indS + 1, indT + 1);
	}
	else {
		if(ans == rec(indS + 1, indT))  {
			return stringFound(indS + 1, indT);
		}
		return stringFound(indS, indT + 1);
	}
}

int main() {
	cin >> S;
	N = S.size();
	cin >> T;
	M = T.size();
	memset(dp, -1, sizeof(dp));
	// cout << rec(0, 0);
	stringFound(0, 0);
	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 71168
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using G = vector<vector<int>>;
    
int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];

    sort(a.begin(), a.end(), greater<ll>());

    ll ans = 0;

    priority_queue<ll> q;
    q.push(a[0]);

    for(int i=1; i<n; i++){
        ll toru = q.top();
        q.pop();
        ans += toru;
        q.push(a[i]);
        q.push(a[i]);
    }

    cout << ans << endl;
    return 0;
}

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

//A - Task Scheduling Problem
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 < a.length; i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        int res = 0;
        for (int i = 1; i < a.length; i++) res += (a[i] - a[i - 1]);
        System.out.println(res);
    }
}


Measured memory_bytes: 21844
def main():
     k = int(input())

     runrun = [1, 2, 3, 4, 5, 6, 7, 8, 9]
     count = 0
     while(len(runrun) < k):
          target = runrun[count]
          num = target % 10
          if num != 0:
               runrun.append(target * 10 + num - 1)
          runrun.append(target * 10 + num)
          if num != 9:
               runrun.append(target * 10 + num + 1)

          count += 1

     print(runrun[k-1])

if __name__ == "__main__":
    main()

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef vector<pll> vpll;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back

inline void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

inline void OUT(void){
  cout << "\n";
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  ll N, K;
  IN(N,K);
  ll ans=0;
  REP(i,N){
    ll h;
    IN(h);
    if(h>=K) ans++;
  }

  OUT(ans);

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 10010;
int n,m;
int v[N],d[N];
void solve(){
    int a,b;
    for(int i=1;i<=n;++i){
        scanf("%d%d",&a,&b);
        v[i] = a-b;
        d[i] = a+b;
    }
}
int main()
{
    int a,b;
    cin >> a >> b;
    printf("%d\n",max(a+b,max(a-b,a*b)));
    return 0;
}


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

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			int N = scan.nextInt();
			int[]A = new int[N];
			int[]B = new int[N];
			for(int i = 0;i<N;i++) {
				A[i] = scan.nextInt();
				B[i] = A[i];
			}
			Arrays.sort(B);
			int max = B[N-1];
			int  maxdub = 0;
			if(B[N-2]==max)maxdub =1;
			
			for(int i = 0;i<N;i++) {
				if(A[i]<max) {
					System.out.println(max);
				}else{
					if(maxdub==0) {
						System.out.println(B[N-2]);
					}else{
						System.out.println(max);
					}
				}
			}
			
		}
		
		
	}
		

}


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

int main(){
    char S[11],T[12];
    cin>>S>>T;
    int ans=1;
    for(int i=0;i<strlen(S);i++){
        if(S[i]!=T[i]){printf("No\n");return 0;}
    }
    printf("Yes\n");
} 

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

int main(int argc, char* argv[]) {
  int N, maxH = 0;
  cin >> N;
  vector<int> h(N);
  for (int i = 0; i < N; i++) {
    cin >> h[i];
    maxH = max(maxH, h[i]);
  }
  int tot = 0, cnt;
  for (int H = 1; H <= maxH; H++) {
    cnt = 0;
    bool st = false;
    for (int i = 0; i < N; i++) {
      if (!st && h[i] >= H) {
        st = true;
        cnt++;
      } else if (st && h[i] < H) {
        st = false;
      }
    }
    tot += cnt;
  }
  cout << tot << endl;
  return 0;
};

Measured memory_bytes: 256
macro_rules! get {
      ($t:ty) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.trim().parse::<$t>().unwrap()
          }
      };
      ($($t:ty),*) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              let mut iter = line.split_whitespace();
              (
                  $(iter.next().unwrap().parse::<$t>().unwrap(),)*
              )
          }
      };
      ($t:ty; $n:expr) => {
          (0..$n).map(|_|
              get!($t)
          ).collect::<Vec<_>>()
      };
      ($($t:ty),*; $n:expr) => {
          (0..$n).map(|_|
              get!($($t),*)
          ).collect::<Vec<_>>()
      };
      ($t:ty ;;) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.split_whitespace()
                  .map(|t| t.parse::<$t>().unwrap())
                  .collect::<Vec<_>>()
          }
      };
      ($t:ty ;; $n:expr) => {
          (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
      };
}

use std::collections::HashSet;

fn main() {
    // 入力
    let s = get!(i64);

    let mut a = s;
    let mut m = 1;
    let mut dp = HashSet::new();
    while !dp.contains(&a) {
        dp.insert(a);
        a = if a % 2 == 0 {
            a / 2
        } else {
            3 * a + 1
        };
        m += 1;
    }
    let ans = m;

    // 出力
    println!("{}", ans);
}


Measured memory_bytes: 4352
#!/usr/bin/env python
# -*- coding:utf-8 -*-

x = input()
n = len(x)

s, t = 0, 0
cnt = 0
for i in range(n):
    if x[i] == 'T':
        if s > 0:
            s -= 1
            cnt += 2
    elif x[i] == 'S':
        s += 1

# i = 0
# s = 0
# t = 0
# cnt = 0
# while i < n:
#     while i < n and x[i] == 'T':
#         i += 1
#         t += 1
#     tmp = min(t, s)
#     cnt += tmp * 2
#     if t - tmp == 0:
#         s -= tmp
#     else:
#         s = 0
#         t = 0

#     while i < n and x[i] == 'S':
#         i += 1
#         s += 1
print(n - cnt)


Measured memory_bytes: 3500
#include <bits/stdc++.h>
#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 FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }



int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(25);

  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];

  map<ll, ll> mp;
  rep(i, n) ++mp[a[i]];
  ll ans = 0;
  rep(i, n) ans += a[i];

  ll q;
  cin >> q;
  while (q--) {
    ll b, c;
    cin >> b >> c;

    ans += (c - b) * mp[b];
    mp[c] += mp[b];
    mp[b] = 0;
    cout << ans << '\n';
  }


  




  
  return 0;
}

Measured memory_bytes: 10052
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------

int main(void){
    int h, w;
    cin >> h >> w;
    vector<string> a(h);

    for(int i = 0; i < h; i++) cin >> a[i];

    int cnt = 0;

    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(a[i][j] == '#'){
                cnt++;
            }
        }
    }

    if(cnt == h + w - 1){
        cout << "Possible" << endl;
    } else {
        cout << "Impossible" << endl;
    }
}

Measured memory_bytes: 256
/*
author: Apoorv Singh
*/

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

typedef vector <int> vi;
typedef vector <long long> vl;
typedef pair <int, int> pii;
typedef pair <long long, long long> pll;
#define ll long long
#define pb push_back   
#define all(c) c.begin(), c.end()
#define watch(x) cout << (#x) << " " << (x) << endl;
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = a; i > b; --i)
#define um unordered_map
#define F first
#define S second

ll modulo = 1e9 + 7;

template <class X>

void printarr(X arr[], int n)
{
    for (int i = 0; i < n; ++i)
        cout << arr[i] << " ";
    cout << endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,m,q;
    cin >> n >> m >> q;
    int arr[501][501];
    FOR(i,0,n+1)
    {
        FOR(j,0,n+1)
            arr[i][j] = 0;
    }
    while (m--)
    {
        int l,r;
        cin >> l >> r;
        ++arr[l][r];
    }
    int dp[n+1][n+1];
    FOR(i,0,n+1)
    {
        FOR(j,0,n+1)
            dp[i][j] = 0;
    }
    FOR(i,1,n+1)
    {
        dp[i][0] = arr[i][0];
        FOR(j,1,n+1)
            dp[i][j] = dp[i][j-1]+arr[i][j];
    }
    while (q--)
    {
        int p,q;
        cin >> p >> q;
        int ans = 0;
        FOR(i,p,q+1)
            ans += dp[i][q];
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 2944
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<complex>
#include<iomanip>
 
#define EPS (1e-10)
using namespace std;
#define PI (3.1415926535)
 
long long f(int n){
    if(n == 1)return 1;
    return n*f(n-1);
}
 
int main(){
    int n;
    cin >> n;

    cout << f(n) << endl;
 
    return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
#define int               long long
#define pb                push_back
#define ppb               pop_back
#define pf                push_front
#define ppf               pop_front
#define all(x)            (x).begin(),(x).end()
#define sz(x)             (int)((x).size())
#define fr                first
#define sc                second
#define pii               pair<int,int>
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))
#define ppc               __builtin_popcount
#define ppcll             __builtin_popcountll

template<typename T1,typename T2>istream& operator>>(istream& in,pair<T1,T2> &a){in>>a.fr>>a.sc;return in;}
template<typename T1,typename T2>ostream& operator<<(ostream& out,pair<T1,T2> a){out<<a.fr<<" "<<a.sc;return out;}
template<typename T,typename T1>T amax(T &a,T1 b){if(b>a)a=b;return a;}
template<typename T,typename T1>T amin(T &a,T1 b){if(b<a)a=b;return a;}

const long long INF=1e18;
const int32_t M=1e9+7;
const int32_t MM=998244353;

const int N=0;



void solve(){
	string s;
	cin>>s;
	if(s[1]=='B')cout<<"ARC";
	else cout<<"ABC";
}
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	#ifdef SEIVE
		seive();
	#endif
	#ifdef NCR
		init();
	#endif
	int t=1;
	//cin>>t;
	while(t--) solve();
	return 0;
}


Measured memory_bytes: 3580
#include <cstdio>
using namespace std;

int main() {
	char S[11];
	bool wa = false;
	int n;
	int len;

	scanf("%s", S);
	for (int i = 0; i < 11; i++) {
		if (S[i] == '\0') {
			len = i;
		}
	}

	if (S[0] != 'A') {
		wa = true;
	}
	n = 0;
	for (int i = 1; i < len; i++) {
		if (i >= 2 && i <= len - 2 && S[i] == 'C')n++;
		else if (S[i] >= 64 && S[i] <= 89) {
			wa = true;
		}
	}
	if (n != 1) {
		wa = true;
	}

	if (wa) {
		printf("WA\n");
	}
	else {
		printf("AC\n");
	}

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;

int main() {
    int n, m, a, b;
    cin >> n >> m;
    set<int> hoge;
    set<int> huga;
    set<int> piyo;
    
    for (int i = 0; i < m; i++) {
        cin >> a >> b;
        if (a == 1) {
            hoge.insert(b);
            piyo.insert(b);
        } else if (b == n) {
            huga.insert(a);
            piyo.insert(a);
        }
    }
    if (hoge.size() + huga.size() == piyo.size()) {
        cout << "IMPOSSIBLE" << endl;
    } else {
        cout << "POSSIBLE" << endl;
    }
}

Measured memory_bytes: 18944
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000



int main(){
	
	string S;
	cin>>S;
	
	map<char,int> mp;
	for(int i=0;i<3;i++)mp[S[i]]++;
	
	if(mp['A']*mp['B']==0)cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
	
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
// debug
#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl;
#define ddd(x, y, z) cerr << "(" #x "," #y "," #z "):(" << x << "," << y << "," << z << ")" << endl;
#define dump(v) cerr<<#v":[ ";for (auto macro_vi:v){cerr<<macro_vi<< " ";}cerr<<"]"<<endl;
#define ddump(v) cerr<<#v":"<<endl;for(auto macro_row:v) {cerr<<"["; for (auto macro__vi:macro_row){cerr<<macro__vi<< " ";}cerr<<"]"<<endl;}
#define damp(m) for(auto macro_pair:m){cerr<< macro_pair.first<<":"<<macro_pair.second<<endl;}
#define dpair(p) cerr << #p":"<<"(" << p.first << "," << p.second << ")" << endl;
// iterate
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define itr(macro_v,i) macro_v.begin()+i
// etc
#define chmin(mi, val) mi = min(mi, val);
#define chmax(ma, val) ma = max(ma, val);
using ll = long long;

using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    cin >> a >> b;
    if(1<=a and a<=9 and 1<=b and b<=9){
        cout << a*b << endl;
    }
    else{
        cout << -1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

type process struct {
	name string
	time int
}

type queue struct {
	arr []process
}

func (q *queue) enqueue(p process) {
	q.arr = append(q.arr, p)
}

func (q *queue) dequeue() process {
	res := q.arr[0]
	q.arr = q.arr[1:]
	return res
}

func (q *queue) isEmpty() bool {
	return len(q.arr) == 0
}

func main() {
	var N, quantum, totalTime int
	var q queue
	fmt.Scan(&N, &quantum)
	for i := 0; i < N; i++ {
		var name string
		var time int
		fmt.Scan(&name, &time)
		q.enqueue(process{name, time})
	}
	for !q.isEmpty() {
		p := q.dequeue()
		t := min(quantum, p.time)
		p.time -= t
		totalTime += t
		if p.time > 0 {
			q.enqueue(p)
		} else {
			fmt.Printf("%s %d\n", p.name, totalTime)
		}
	}
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}



Measured memory_bytes: 8384
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 1000000007;

Int mod_pow(Int x, Int n) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % MOD; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % MOD;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}


double H[1005];

int main(){
    cin.tie(0);

    int N; cin >> N;
    double T; cin >> T;
    double A; cin >> A;
    for (int i = 0; i < N; i++){
        cin >> H[i];
    }
    double mi = 100000;
    int ans;
    for (int i = 0; i < N; i++){
        double sa = abs(T - H[i] * 0.006 - A);
        if (mi > sa){
            ans = i;
            mi = sa;
        }
    }
    cout << ans + 1 << endl;
}


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

int main() {
	long long x, k, d;
	scanf("%lld %lld %lld", &x, &k, &d);
	if(x < 0) x *= -1;
	long long j = x / d;
	if(k <= j){
		printf("%lld\n", x - (k * d));
	}else{
		k -= j;
		long long mn = x - (j * d);
		if(mn > abs(mn - d)){
			mn = abs(mn - d);
			k--;
		}
		if(k % 2 == 0) printf("%lld\n", mn);
		else printf("%lld\n", min(abs(mn + d), abs(mn - d)));
	}
	return 0;
}
//ios_base::sync_with_stdio(false);
//cin.tie(0);
//tod-ngen


Measured memory_bytes: 3796
//解答例を参考にしたコード
#include <iostream>

using namespace std;

int main(){
    int N, A, B, C, D;
    string S;
    cin >> N >> A >> B >> C >> D >> S;

    //添字変更
    S = '#' + S + '#';

    //lambda式
    auto cannot_reach = [&](int start, int end){
        for(int i = start;i + 1 <= end;i++){
            if(S[i] == '#' && S[i+1] == '#')return true;
        }
        return false;
    };

    if(cannot_reach(A, C) || cannot_reach(B, D)){
        cout << "No" << endl;
        return 0;
    }

    if(C>D){
        bool snuke_can_over = false;
        for(int i=B;i<=D;i++){
            if(S[i-1] == '.' && S[i] == '.' && S[i+1] == '.'){
                snuke_can_over = true;
            }
        }
        if(!snuke_can_over){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;

}


Measured memory_bytes: 772
#include <iostream>
#include <string>
using namespace std;
int main() {
    int a,b;
    string s;
    cin>>a>>b>>s;
    bool f=true;
    for(int i=0;i<a;i++)
        if(s[i]<'0'||s[i]>'9')
        {
            f=false;
            break;
        }
    if(f&&s[a]!='-')
        f=false;
    if(f)
    for(int i=a+1;i<=a+b;i++)
        if(s[i]<'0'||s[i]>'9')
        {
            f=false;
            break;
        }
    if(f)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    // insert code here...
    //std::cout << "Hello, World!\n";
    return 0;
}


Measured memory_bytes: 256
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        int h, w;
        String[][] mat;
        // 読み込み
        try(Scanner sn = new Scanner(System.in)) {
            h = sn.nextInt();
            w = sn.nextInt();
            mat = new String[h][];
            for (int i = 0; i < h; i++)
                mat[i] = sn.next().split("");
        }
        List<Integer> showRowIndex = new LinkedList<>();
        for (int i = 0; i < h; i++)
            for (int j = 0; j < w; j++)
                if (mat[i][j].equals("#")) {
                    showRowIndex.add(i);
                    break;
                }
        List<Integer> showColIndex = new LinkedList<>();
        for (int i = 0; i < w; i++)
            for (int j = 0; j < h; j++)
                if (mat[j][i].equals("#")) {
                    showColIndex.add(i);
                    break;
                }
        // 表示
        for (int i: showRowIndex) {
            for (int j: showColIndex) {
                System.out.print(mat[i][j]);
            }
            System.out.println();
        }
    }
}


Measured memory_bytes: 24920
#include <bits/stdc++.h>
using namespace std;
int a[3];
int main()
{
	for(int i = 0; i < 3; ++i) cin >> a[i];
	sort(a, a + 3);
	int ans = a[2] - a[1];
	a[0] += ans;
	a[1] += ans;
	if((a[2] - a[0]) & 1) { ++ans, ++a[1], ++a[2];}
	ans += (a[2] - a[0]) / 2;
	cout << ans << endl;
	return 0;
}
	 

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

using namespace std;

int n;
vector<int> adj[100010];

int dfs(int x, int pre = 0) {
	int cnt = 0;
	for (int i = 0; i < adj[x].size(); ++i) {
		int y = adj[x][i];
		if (y != pre)
			cnt += dfs(y, x);
	}
	return cnt < 2 ? cnt ^ 1 : cnt;
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i < n; ++i) {
		int u, v;
		scanf("%d%d", &u, &v);
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	puts(dfs(1) ? "First" : "Second");
}

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

int main()
{
  int n;
  cin >> n;
  cout << n * n  << endl;
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;

int main() {
	 ll n,t,i,p,q,c=0,l; cin>>n>>t; ll a[n+1]; ll b[n+1]={0};
	 for(i=1;i<=n;i++) {cin>>a[i];}
	 while(t--)
	 {
	     cin>>p>>q;
	     b[p]=max(b[p],a[q]);
	     b[q]=max(b[q],a[p]);
	 }
	 for(i=1;i<=n;i++)
	 { 
	     if (a[i]>b[i]) {c++;}
	 } cout<<c;
	return 0;
}

Measured memory_bytes: 5180
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define takeline cin.ignore();
#define sc second
#define N 3000005
#define endl "\n"
#define mod 1000000007
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll a;
	cin>>a;
	a=3*a*a;
	cout<<a;
	return 0;
}

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

signed main(){
  long long  a , b , n , ans;
  cin>>n>>a>>b;
  if(a == 0){
    ans=0;
  } else {
    ans=n/(a+b)*a;
    if(n%(a+b) > 0){
      if( n%(a+b) > a){
        ans+=a;
      } else {
        ans+=n%(a+b);
      }
    }
  }
  cout<<ans<<endl;
  return(0);
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
typedef long long ll;
typedef double dd;
#define For(i,j,k) for (int i=(int)j;i<=(int)k;++i)
#define Forr(i,j,k) for (int i=(int)j;i>=(int)k;--i)
#define Set(a,p) memset(a,p,sizeof(a))
using namespace std;

template<typename T>bool chkmax(T &a,T b) { return a<b?a=b,1:0; }
template<typename T>bool chkmin(T &a,T b) { return a>b?a=b,1:0; }

const int maxn=2e6+1e2;
const int inf=0x3f3f3f3f;
struct Edge {
	int from,to,dis;
	bool operator < (const Edge &aa) const {
		return dis<aa.dis;
	}
}e[maxn];
int n,m;
int tot;
ll Ans;
int fa[maxn],val[maxn];

inline int read() {
	int x=0,p=1;
	char c=getchar();
	while (!isdigit(c)) { if (c=='-') p=-1; c=getchar();}
	while (isdigit(c)) { x=(x<<1)+(x<<3)+(c-'0'); c=getchar();}
	return x*p;
}

inline void add(int u,int v,int w) {
	e[++tot]=(Edge){u,v,w};
}

int find(int x) {
	if (x!=fa[x]) fa[x]=find(fa[x]);
	return fa[x];
}

int main() {
	n=read(); m=read();
	For (i,0,n) fa[i]=i; Set(val,inf);
	while (m--) {
		int u=read(),v=read(),w=read(); u%=n; v%=n;
		chkmin(val[u],w+1); chkmin(val[v],w+2);
		add(u,v,w);
	}
	For (i,1,n<<1) chkmin(val[i%n],val[(i-1)%n]+2);
	For (i,0,n-1) add(i,(i+1)%n,val[i]);
	sort(e+1,e+tot+1);
	For (i,1,tot) {
		int u=e[i].from,v=e[i].to;
		u=find(u); v=find(v);
		if (u!=v) {
			Ans+=1ll*e[i].dis; fa[u]=v;
		}
	}
	printf("%lld\n",Ans);
	return 0;
}

Measured memory_bytes: 19712
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int n;
    string s;
    cin >> n >> s;
    vector<int> r, g;
    unordered_set<int> b;
    rep(i, (int)s.size()){
        if(s[i] == 'R') r.push_back(i);
        else if(s[i] == 'G') g.push_back(i);
        else b.insert(i);
    }

    ll ans = 0;
    for(int i : r){
        for(int j : g){
            int k1 = -1;
            int k2 = -1;
            int k3 = -1;
            if((i + j) % 2 == 0){
                k1 = (i + j) / 2;
            }
            k2 = max(i, j) + abs(i - j);
            k3 = min(i, j) - abs(i - j);
            ans += b.size();
            if(b.find(k1) != b.end()) ans--;
            if(b.find(k2) != b.end()) ans--;
            if(b.find(k3) != b.end()) ans--;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3676
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define mp make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n) 
#define SIZE(x) ((int)(x).size())
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef pair<int, int> pint;
typedef pair<lint, lint> plint;
typedef vector<lint> vec;
typedef vector<vector<lint>> matrix;
typedef priority_queue<lint> p_que;
typedef priority_queue<lint, vector<lint>, greater<lint>> p_que_rev;
const lint INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

lint gcd(lint a, lint b) {
    lint r;
    while (b != 0) {
        r = a % b;
        a = b; 
        b = r;
    }
    return a;
}

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

lint power(lint x, lint n, lint mod = MOD) {
    lint ret = 1;
    while(n > 0) {
        if(n & 1){
            (ret *= x) %= mod;
        }
        (x *= x) %= mod;
        n >>= 1;
    }
    return ret;
}

vector<lint> make_power(int n, lint base){
    lint num = 1;
    vector<lint> ret;
    for (int i=0; i<=n; ++i){
        ret.push_back(num);
        num *= base;
    }
    return ret;
}

pair<vector<lint>, vector<lint>> prime_factor_decomp(lint n) {
    vector<lint> p, e;
    lint m = n;
    for (lint i = 2; i * i <= n; i++) {
        if (m % i != 0){
            continue;
        }
        int c = 0;
        while (m % i == 0){
            c++;
            m /= i;
        }
        p.push_back(i);
        e.push_back(c);
    }
    if (m > 1) {
        p.push_back(m);
        e.push_back(1);
    }
    return make_pair(p, e);
}


lint n;

void input(){
    cin >> n;
}

void solve(){
    lint ans = 0;
    for (lint i=1; i*i<=n; ++i){
        if(n % i == 0){
            lint j = n / i;
            ans = i + j - 2;
        }
    }
    cout << ans << endl;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    input();
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
ll dx[]={0,0,1,1,1,-1,-1,-1};
ll dy[]={1,-1,-1,0,1,-1,0,1};

int main()
{
   char ch;
   cin>>ch;
   cout<<char(ch+1);
}


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

bool comp1(pair<ll,ll> p1,pair<ll,ll> p2){
  return p1.second>p2.second;
}
bool comp2(pair<ll,ll> p1,pair<ll,ll> p2){
  return p1.first < p2.first;
}
int main (){
  ll w1,n1;
  cin >> n1 >> w1;
  vector< pair<ll,ll> > vp(n1);
  for(int i=0;i<n1;i++){
    cin >> vp[i].first >> vp[i].second;
  }
  sort(vp.begin(),vp.end(),comp1);
  stable_sort(vp.begin(),vp.end(),comp2);

  vector<ll> kati_wa[4],kati(4);
  int pos=0;

  for(int i=0;i<4;i++){
    kati_wa[i].push_back(0);
    kati[i]=0;
  }
  kati_wa[0].push_back(vp[0].second);
  kati[0]=vp[0].first;
  for(int i=1;i<n1;i++){
    if(vp[i].first!=vp[i-1].first){
      pos++;
      kati[pos]=vp[i].first;
    }
    if(kati_wa[pos].size()!=0)
      kati_wa[pos].push_back(kati_wa[pos][kati_wa[pos].size()-1]+vp[i].second);
    else
      kati_wa[pos].push_back(vp[i].second);
  }
  ll ans = 0;

  for(int i=0;i<kati_wa[0].size();i++){
    for(int j=0;j<kati_wa[1].size();j++){
      for(int k=0;k<kati_wa[2].size();k++){
        for(int l=0;l<kati_wa[3].size();l++){
        //  int l = n1-(i+j+k);
          //if(l<0||l>kati_wa[3].size()-1) continue;
          //cout<<i<<" "<<j<<" "<<k<<" "<<l<<endl;
          //cout<<kati[0]*i+kati[1]*j+kati[2]*k+kati[3]*l<<endl;
          //cout<<w1<<endl;
          if(kati[0]*i+kati[1]*j+kati[2]*k+kati[3]*l<=w1){
            //cout<<"aaaaaaaaaaaa"<<endl;
            ans = max(ans,kati_wa[0][i]+kati_wa[1][j]+kati_wa[2][k]+kati_wa[3][l]);
          }
        }
      }
    }
  }
  cout<<ans<<endl;

  return 0;
}

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

int main() {
  int A, B, a, b, c, d, sum;
  sum = 0;
  cin >> A >> B;
  for (int i = A; i < B + 1; i++){
   a = i / 10000;
   b = i / 1000 % 10;
   c = i / 10 % 10;
   d = i % 10;
    if (a == d && b == c){
      sum++;
    }
  }
  cout << sum << endl;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i = 0; i < N; i++) cin >> A.at(i);
    sort(A.begin(), A.end());
    cout << A.back() - A.at(0) << endl;
}

Measured memory_bytes: 256
n,m = map(int, input().split())
s = set()
l,r = -float("inf"), float("inf")
for i in range(m):
    left, right = map(int, input().split())
    if left > l:
        l = left
    if right < r:
        r = right
if l > r:
    print(0)
else:
    print(r-l+1)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

vector<ll> prime(100010);
bool is_prime[100010];

ll sieve(ll n){
	ll p = 0;
	for(int i = 0; i <= n; i++) {//初期化
		is_prime[i] = true;
	}
	is_prime[0] = is_prime[1] = false;
	for(int i = 2; i <= n; i++) {
		if(is_prime[i]){
			prime[p++] = i;
			for(int j = 2 * i; j <= n; j+= i) {
				is_prime[j] = false;
			}
		}
	}
	return p;
}

int main(){
	int q;cin>>q;
	vector<P> v(q);
	for(int i = 0; i < q; i++) {
		ll l,r;cin>>l>>r;
		v[i] = mp(l,r);
	}

	sieve(100000);
	vector<int> a(100010,0);
	for(int i = 3; i <= 100009; i+= 2) {
		if((is_prime[i]) && (is_prime[(i + 1) / 2])){
			a[i]= (1 + a[i - 2]);
		}
		else{
			a[i] = a[i - 2];
		}
	}
	for(int i = 0; i < q; i++) {
		cout << a[v[i].sc] - a[max((v[i].fs - 2LL),1LL)] << endl;
	}
	return 0;
}

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

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

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

	string s;
	cin >> s;
	reverse(s.begin(), s.end());
	s += '0';

	int n = s.size();
	vector<vector<ll>> dp(n + 5, vector<ll>(2, 1e9));
	dp[0][0] = 0;
	REP(i, n) REP(j, 2) {
		int a = s[i] - '0';
		a += j;
		if(a < 10) dp[i + 1][0] = min(dp[i + 1][0], dp[i][j] + a);
		if(a > 0) dp[i + 1][1] = min(dp[i + 1][1], dp[i][j] + 10 - a);
	}
	cout << dp[n][0] << endl;

	return 0;
}

Measured memory_bytes: 55964
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>

template <class T>
inline void read(T &x) {
    x = 0;
    int f = 0;
    char ch = getchar();
    while (!isdigit(ch))    { f |= ch == '-'; ch = getchar(); }
    while (isdigit(ch))     { x = (x << 1) + (x << 3) + (ch ^ 48); ch = getchar(); }
    x = f ? -x : x;
    return;
}

long long n, ans, r, g, b;
char s[4010];

int main() {
    read(n);    std::cin >> s + 1;
    for (int i = 1; i <= n; ++i) {
        if (s[i] == 'R')    ++r;
        if (s[i] == 'B')    ++b;
        if (s[i] == 'G')    ++g;
    }
    ans = r * b * g;
    for (int len = 1; len <= n; ++len) {
        for (int i = 1; i <= n; ++i) {
            int j = i + len, k = i + len + len;
            if (k > n)  break;
            if (s[i] != s[j] && s[i] != s[k] && s[j] != s[k])   --ans;
        }
    }
    printf("%lld\n", ans);
    return 0;
}

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

using namespace std;

int main(){

  int n,m;
  vector<vector<int>> human;

  cin >> n >> m;

  int a[m+1];
  int ans=0;

  for(int i=0;i<m+1;i++){
    a[i]=0;
  }

  human.resize(n);
  for(int i=0;i<n;i++){

    int k;
    cin >> k;
    human[i].resize(k);
    for(int j=0;j<k;j++){
      cin >> human[i][j];
    }

  }

  for(int i=0;i<n;i++){
    for(int j=0;j<(int)(human[i].size());j++){
      a[human[i][j]]++;
    }
  }

  for(int i=0;i<m+1;i++){
    if(a[i]==n) ans++;
  }

  cout << ans << endl;
  
  return 0;

}


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

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }

int main()
{
  int n;
  cin >> n;
  vector<bool> a(n + 1), b(n + 1);
  REP(i, n) {
    int x;
    cin >> x;
    a[i + 1] = x == 1;
  }
  int ans = 0;
  for(int i = n; i > 0; i--) {
    bool c = a[i];
    for(int j = 2; i * j < n + 1; j++) {
      c ^= b[i * j];
    }
    b[i] = c;
    if (b[i]) ans++;
  }
  cout << ans << endl;
  bool f = true;
  FOR(i, 1, n + 1) {
    if(b[i]) {
      if (f) {
        cout << i;
        f = false;
      } else {
        cout << " " << i;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(n); ++i)
using ll = long long;
const int INF = 1001001001;
const int mod = 1000000007;

vector<int> to[200005];
vector<int> ans;

void dfs(int v, int p=-1){   //頂点vについて連結されている頂点を探索　pはどこから来たか
    for(int u : to[v]){
        if(u==p) continue;  // 親なら飛ばす
        ans[u] += ans[v];
        dfs(u,v);
    }
}


int main(){
    int N,Q;
    cin >> N >> Q;
    
    for(int i=0;i<N-1;i++){
        int a,b;
        cin >> a >> b;
        --a;
        --b;

        to[a].push_back(b);
        to[b].push_back(a);
    }
    ans.resize(N);
    for(int i=0;i<Q;i++){
        int p,x;
        cin >> p >> x;
        --p;
        ans[p] +=x;
    }

    dfs(0);

    for(int i=0;i<N;i++){
        cout << ans[i] << endl;
    }
    return 0;
    

}

Measured memory_bytes: 23552
#include<stdio.h>
#define N 105
#define W 0
#define B 1
#define DC -1
#define inf 1000000
int n;
int d[N];
int pi[N];
int color[N];

void prim(int hako[N][N]);
  
    
int main(){
  int i,j;
  int sum=0;
  int hako[N][N];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&hako[i][j]);
    }
  }
  prim(hako);
  for(i=0;i<n;i++) sum+=d[i];
  printf("%d\n",sum);
  return 0;
}

void prim(int hako[N][N]){
  int i=0,u,v;
  int mincost;
  for(i=0;i<n;i++) {
    color[i]=W;
    pi[i]=DC;
    d[i]=inf;
    }
  d[0]=0;
  while(1){
    mincost=inf;
    for(i=0;i<n;i++){
      if(color[i]!=B &&d[i]<mincost){
	mincost =d[i];
	u=i;
      }
    }
    if(mincost==inf) break;
    color[u]=B;
    for(i=0;i<n;i++){
      if(hako[u][i]!=DC){
	v=i;
	if(color[v]!=B && hako[u][v]<d[v]){
	  pi[v]=u;
	  d[v]=hako[u][v];
	}
      }
    }
    
  }
}



Measured memory_bytes: 2048
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

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

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    
    if(k%2) swap(a,b);
    cout1(a-b)
}

Measured memory_bytes: 256