akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define FOR(i,a,b) for(long long i = (a); i < (b); i++)
#define FORD(i,a,b) for(int i = (a); i >= (b); i--)
#define REP(i,a) for(int i = 0; i < (a); i++)
#define REPD(i,a) for(int i = (a)-1; i >= 0; i--)
#define sz(a) (int)a.size()
#define ALL(a) a.begin(),a.end()

#define ii pair<int,int>
#define fi first
#define se second
#define ll long long
#define N 1e5

using namespace std;

int main()
{
    int n;
    cin>>n;
    vector<pair<int,int>> ar;
    FOR(i,0,n)
    {
        int x,y;
        cin>>x>>y;
        ar.push_back(make_pair(x,y));
    }
    sort(ar.begin(),ar.end());
    double ans=0;
    ll cnt=0;
    do
    {
        FOR(i,0,n-1)
        {
            ans+=sqrt((ar[i].fi-ar[i+1].fi)*(ar[i].fi-ar[i+1].fi)+(ar[i].se-ar[i+1].se)*(ar[i].se-ar[i+1].se));
        }
        cnt++;
    }
    while(next_permutation(ar.begin(),ar.end()));
    cout<<fixed;
    cout<<setprecision(10)<<ans/cnt;
    return 0;
}


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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  int n; cin>>n;
  vector<ll> c(3);
  cin>>c[0]>>c[1]>>c[2];
  vector<string> s(n);
  rep(i, n)cin>>s[i];

  map<string, pi>m;
  m["AB"] = {0,1};
  m["AC"] = {0,2};
  m["BC"] = {1,2};

  if(c[0]+c[1]+c[2]==0) { cout<<"No"<<endl; return 0; }

  vector<char> result;
  rep(i, n){
    auto cs = s[i];
    int l = m[cs].first;
    int r = m[cs].second;

    if(c[l]>c[r]){
      c[l]--;c[r]++;
      result.push_back("ABC"[r]);
    }else if(c[r]>c[l]){
      c[r]--;c[l]++;
      result.push_back("ABC"[l]);
    }else{
      if(i<n-1 && (m[s[i+1]].first == l || m[s[i+1]].second == l) ){
        c[r]--;c[l]++;
        result.push_back("ABC"[l]);
      }else{
        c[l]--;c[r]++;
        result.push_back("ABC"[r]);
      }
    }
    if(c[0]<0 || c[1]<0 || c[2]<0) { cout<<"No"<<endl; return 0; }
  }

  cout<<"Yes"<<endl;
  for(auto cs: result)cout<<cs<<endl;

  return 0;
}


Measured memory_bytes: 6740
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-6;
const ld pi = acos(-1.0);
typedef vector<vector<ll>> mat;
typedef vector<int> vec;

void solve() {
	int n; cin >> n;
	vector<int> h(n);
	int ans = 0;
	int tmp = 0;
	rep(i, n) {
		cin >> h[i];
	}
	rep(i, n - 1) {
		if (h[i] >= h[i + 1])tmp++;
		else tmp = 0;
		ans = max(ans, tmp);
	}
	cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(5);
	//init();
	solve();
	stop
		return 0;
}


Measured memory_bytes: 640
#include<cstdio>
#include<algorithm>

using namespace std;

int n,py[10000];

int chain(int u,int l){
	int rem=(u+1)+(n-l);
	if(u<0 || n<=l)	return rem;

	int color=py[u],cnt=0;
	for(;u>=0;u--,cnt++){
		if(py[u]!=color)	break;
	}
	for(;l<n;l++,cnt++){
		if(py[l]!=color)	break;
	}
	if(cnt>=4)	return chain(u,l);
	return rem;
}

int main(){
	for(;scanf("%d",&n),n;){
		for(int i=0;i<n;i++)	scanf("%d",&py[i]);

		int pymin=1<<30;
		for(int i=0;i<n;i++)for(int c=1;c<=3;c++){
			if(py[i]!=c){
				int tmp=py[i];
				py[i]=c;
				if(i>0 && py[i-1]==c)			pymin=min(pymin,chain(i-1,i));
				else if(i<n-1 && py[i+1]==c)	pymin=min(pymin,chain(i,i+1));
				py[i]=tmp;
			}
		}

		printf("%d\n",pymin);
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <fstream>
#include <string>
#include <unordered_map>
#include <stdio.h>
#include <list>
#include <vector>
#include <algorithm>
#include <stack>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

int main()
{	
	int n,b,c;
	cin >> n>>b>>c;
	if(n+b+c>=22)cout<<"bust"<<endl;
	else cout<<"win"<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath> 
#include <queue>
#include <functional>

using namespace std;
//typedef long long ll;
typedef pair<int, int> P;
//static const int dx[4] = {1, -1, 0, 0};
//static const int dy[4] = {0, 0, 1, -1};

static const int MAX = 401;
static const int INF = 1000000;

//const ll MOD = 1e+9 + 7;

int main() {

    int N, M_a, M_b; cin >> N >> M_a >> M_b;

    vector<P> Point(MAX);
    vector<int> Cost(MAX);
    for (int i = 0; i < N; i++) 
        scanf("%d %d %d", &Point[i].first, &Point[i].second, &Cost[i]);

    int a_cnt, b_cnt, cost_cnt;
    vector< vector<int> > dp(MAX, vector<int>(MAX, INF));

    dp[0][0] = 0;

    for (int num = 0; num < N; num++) {

        a_cnt = Point[num].first;
        b_cnt = Point[num].second;
        cost_cnt = Cost[num];

        for (int i = MAX; i >= 1; i--) {

            if (a_cnt > i) continue;

            for (int j = MAX; j >= 1; j--) {

                if (b_cnt > j) continue;
                if (dp[i - a_cnt][j - b_cnt] != INF) {
                    dp[i][j] = min(dp[i - a_cnt][j - b_cnt] + cost_cnt, 
                                        dp[i][j]);
                }
            }
        }
    }

    int max_m = max(M_a, M_b);
    int ans = INF;
    for (int i = 1; max_m * i < MAX; i++) {
        ans = min(ans, dp[M_a * i][M_b * i]);
    }
    if (ans == INF) 
        cout << -1 << '\n';
    else 
        cout << ans << '\n';

}


Measured memory_bytes: 896
#include<algorithm>
#include<cmath>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printw) FUNC(printwe) FUNC(printb) FUNC(printbe) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w;
    cin >> h >> w;
    vector<string> ss(h); cin >> ss;
    vector<vector<int>> visited(h, vector<int>(w));
    ll ans = 0;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            vector<tuple<int, int, char>> poss;
            poss.emplace_back(i, j, 0);
            ll bs = 0, ws = 0;
            while(poss.size()){
                auto p = poss.back(); poss.pop_back();
                int y = get<0>(p), x = get<1>(p);
                char prev = get<2>(p);
                if(y < 0 || h <= y || x < 0 || w <= x){ continue; }
                if(prev == ss[y][x]){ continue; }
                if(visited[y][x]){ continue; }
                visited[y][x] = 1;
                (ss[y][x] == '#' ? bs : ws)++;
                printde(y, x);
                poss.emplace_back(y + 1, x, ss[y][x]);
                poss.emplace_back(y, x + 1, ss[y][x]);
                poss.emplace_back(y - 1, x, ss[y][x]);
                poss.emplace_back(y, x - 1, ss[y][x]);
            }
            ans += ws * bs;
        }
    }
    cout << ans << '\n';
}


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

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  int x;
  cin >> x;
  int res = 0;
  switch (x) {
    case 400 ... 599:
      res = 8;
      break;
    case 600 ... 799:
      res = 7;
      break;
    case 800 ... 999:
      res = 6;
      break;
    case 1000 ... 1199:
      res = 5;
      break;
    case 1200 ... 1399:
      res = 4;
      break;
    case 1400 ... 1599:
      res = 3;
      break;
    case 1600 ... 1799:
      res = 2;
      break;
    case 1800 ... 1999:
      res = 1;
      break;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3636
<?php

fscanf(STDIN, '%d', $n);
$dict = array();
for ($i = 0; $i < $n; $i++) {
    $line = trim(fgets(STDIN));
    if ($line[0] === 'i') {
        $dict[substr($line, 7)] = 1;
    } else {
        echo empty($dict[substr($line, 5)]) ? 'no' : 'yes', PHP_EOL;
    }
}

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

#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

int main() {
  int n, x, t;
  cin >> n >> x >> t;

  cout << ((n + x - 1) / x) * t;
}


Measured memory_bytes: 3592
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;

typedef long long s64;

const int MaxN = 1000000;
const int M = 1000000007;

int n;

int f[MaxN + 1];
int g[MaxN + 1];

int main()
{
	cin >> n;

	f[1] = g[1] = 1;
	for (int i = 2; i <= n; ++i)
	{
		if (i >= 3)
			f[i] = g[i - 3];
		f[i] = (f[i] + f[i - 1]) % M;
		g[i] = (f[i] + g[i - 1]) % M;
	}

	int res = (s64)f[n] * n % M;
	for (int i = 1; i < n; ++i)
		res = (res + f[i] * ((s64)(n - 1) * (n - 1) % M + min(n - 1, i + 1))) % M;

	cout << res << endl;

	return 0;
}

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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()

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

const long long INF = 1LL << 60;

int main()
{
    string ans = "";
    rep(i, 3) {
        string S;
        cin >> S;
        ans += S[i];
    }

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

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head, tail, n;

void enqueue(P x){
  Q[tail] = x;
  if(tail + 1 == LEN) tail = 0;
  else tail++;
}

P dequeue(){
  P x = Q[head];
  if(head + 1 == LEN) head = 0;
  else head++;
  return x;
}

int main(){
  head = 1;
  int elaps = 0;
  int i,q;
  P u;
  scanf("%d %d", &n, &q);
  tail = n + 1;
  
  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name); //p
    scanf("%d", &Q[i].t); //time
  }

  while(head != tail){
      u = dequeue();
      
      if(u.t > q){
      u.t -= q;
      elaps += q;
    }
    else if(u.t <= q){
      elaps += u.t;
      u.t = 0;
      }
      
    if(u.t > 0){
      enqueue(u);
    }
    else if(u.t == 0){
      printf("%s %d\n",u.name,elaps);
    }
  }
  
  return 0;
}



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

using namespace std;

long long inf=1000000007;

int main(){
	string s;
	cin>>s;
	int n=s.size()-1;
	long long ans=0;

	for(int i=0;i<(1<<n);i++){
		bitset<9> bits=i;
		long long pre=0;
		long long keta=1;

		for(int j=n;j>0;j--){
			pre+=(s.at(j)-'0')*keta;

			if(bits.test(j-1)){
				keta=1;
			}else{
				keta*=10;
			}
		}

		pre+=(s.at(0)-'0')*keta;

		ans+=pre;
	}

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
import networkx as nx

N = int(input())
ABC = [list(map(int, input().split())) for _ in range(N - 1)]
Q, K = map(int, input().split())
XY = [list(map(int, input().split())) for _ in range(Q)]

G = nx.Graph()

for a, b, c in ABC:
    G.add_edge(a - 1, b - 1, weight=c)

# pred, dist = nx.dijkstra_predecessor_and_distance(G, K - 1)
dist = nx.shortest_path_length(G, K - 1, weight='weight')

for x, y in XY:
    print(dist[x - 1] + dist[y - 1])



Measured memory_bytes: 208284
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

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

fn main() {
    let v = read_vec::<usize>();
    let (h, w, k) = (v[0], v[1], v[2]);
    let mut grid = vec![vec![]; h];
    for y in 0..h {
        grid[y] = read::<String>()
            .chars()
            .map(|x| x.to_digit(10).unwrap() as i64)
            .collect::<Vec<_>>();
    }
    grid.reverse();
    let mut ans = 0;

    for y in 0..h {
        for x in 0..w {
            let mut grid_clone = grid.clone();
            for yy in y..h - 1 {
                grid_clone[yy][x] = grid_clone[yy + 1][x];
            }
            grid_clone[h - 1][x] = 0;
            ans = max(ans, solve(grid_clone, k));
        }
    }
    println!("{}", ans);
}

fn solve(mut grid: Vec<Vec<i64>>, k: usize) -> i64 {
    let mut coef = 1i64;
    let mut temp_ans = 0;
    let h = grid.len();
    let w = grid[0].len();
    loop {
        // for round
        let mut marked = HashSet::new();
        for y in 0..h {
            for x in 0..w + 1 - k {
                // 0 means not exists.
                if grid[y][x] != 0 && grid[y][x..x + k].iter().all(|&cell| cell == grid[y][x]) {
                    for i in 0..k {
                        if !marked.contains(&(x + i, y)) {
                            marked.insert((x + i, y));
                            temp_ans += grid[y][x] * coef;
                        }
                    }
                }
            }
        }
        if marked.is_empty() {
            break;
        }

        // reconstruct
        let mut new_grid = vec![vec![0; w]; h];
        let mut removed = vec![0; w];
        for y in 0..h {
            for x in 0..w {
                while removed[x] + y < h && marked.contains(&(x, removed[x] + y)) {
                    removed[x] += 1;
                }
                if removed[x] + y >= h {
                    continue; // 0 is already set.
                }
                new_grid[y][x] = grid[removed[x] + y][x];
            }
        }
        grid = new_grid;
        coef *= 2;
    }
    temp_ans
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


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

using ll = long long;
#define ALL(c) (c).begin(), (c).end()
const int MOD = 1000000007;

int main() {
    int n;
    cin >> n;
    int m = 1;
    while (m * m <= n) {
        m++;
    }
    cout << (m - 1) * (m - 1) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
typedef long long int ll;
int main(){
  string s;
  cin >>s;
  ll ss=s.size(),ans=0,bs=0;
  for(ll i=0;i<ss;i++){
   if(s[i]=='B') bs++;
   else ans+=bs;
  }
  cout <<ans<<endl;
}


Measured memory_bytes: 640
#include <stdio.h>

int main(int argc, char **argv){
	int i,j;
	int h,w;

	for(;;){
		// Input
		scanf("%d %d",&h, &w);
		// Finish Check
		if( h == 0 && w == 0 ){
			break;
		}
		// Output
		for(i=1;i<=h;i++){
			for(j=1;j<=w;j++){
				if( ( i + j ) % 2 == 0 ){
					printf("#");
				} else {
					printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
	}
	
	return 0;
}

Measured memory_bytes: 572
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		if(S.equals("AAA") || S.equals("BBB")){
			System.out.println("No");
		}else{
			System.out.println("Yes");			
		}
	}
}


Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char>cvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
int main()	{
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  while(a>0 && c>0){
    c-=b;
    if(c>0)
      a-=d;
  }
  if(a>0)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}

Measured memory_bytes: 3488
//abc072_a Sandglass2


#include <iostream>
using namespace std;

int main()
{
int x;
int a;
int b;

	cin >> x;
	cin >> a;
	cin >> b;
	a -= x;
	b -= x;
	if( a < 0 ) a *= - 1;
	if( b < 0 ) b *= - 1;

	if( a < b )
		cout << "A" << endl;
	else
		cout << "B" << endl;

	return 0;
}






Measured memory_bytes: 256
import sys
from collections import Counter
 
 
def main():
    H, W, M = map(int, sys.stdin.readline().rstrip().split())
    Mh = [0] * H
    Mw = [0] * W
    B = []
    for i in range(M):
        h, w = map(int, sys.stdin.readline().rstrip().split())
        Mh[h - 1] += 1
        Mw[w - 1] += 1
        B.append((h - 1, w - 1))
 
    nh = max(Mh)
    nw = max(Mw)
 
    # 交差する場所に置かれた処理物があるか？
    lh = Counter(Mh)[nh]
    lw = Counter(Mw)[nw]
 
    out = 0
    for (h, w) in B:
        if Mh[h] == nh and Mw[w] == nw:
            out += 1
 
    if out == lh * lw:
        print(nh + nw - 1)
    else:
        print(nh + nw)
 
 
main()

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

int main() {
    int n, m;
    cin >> n >> m;
    
    vector<int> c(n);
    vector<int> a(m), b(m);
    
    for (int i = 0; i < m; i++) {
        cin >> a.at(i) >> b.at(i);
        c.at(a.at(i) - 1)++;
        c.at(b.at(i) - 1)++;
    }
    
    for (int i = 0; i < n; i++) cout << c.at(i) << endl;
}

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

namespace my {
/*汎用*/
template <typename T>
void input_vec(vector<T> &a, ll n) {
  assert(a.empty());
  for (ll i = 0; i < n; i++) {
    T tmp;
    cin >> tmp;
    a.push_back(tmp);
  }
}
template <typename T>
void input_set(set<T> &a, ll n) {
  assert(a.empty());
  for (ll i = 0; i < n; i++) {
    T tmp;
    cin >> tmp;
    a.insert(tmp);
  }
}

char itoc(int i) { return i + '0'; }
int ctoi(char c) { return c - '0'; }

/*整数*/
ll gcd(ll a, ll b) {  // O( log(max(a,b)) )
  a = abs(a);
  b = abs(b);
  if (a < b) swap(a, b);
  while (b != 0) {
    a %= b;
    swap(a, b);
  }
  return a;
}
ll lcm(ll a, ll b) { return a * (b / my::gcd(a, b)); }  // O( log(max(a,b)) )
ll modinv(ll n, ll mod) {                               // O( log(max(n,mod)) )
  assert(mod > 0 && my::gcd(n, mod) == 1);
  n %= mod;
  if (n < 0) n += mod;
  ll a = mod, b = n, x = 1, y = 0;
  while (b != 0) {
    ll q = a / b, r = a % b;
    a = b;
    b = r;
    y -= q * x;
    swap(x, y);
  }
  y %= mod;
  if (y < 0) y += mod;
  return y;
}

bool is_prime(ll n) {  // O( sqrt(n) )
  bool flag = true;
  for (ll i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      flag = false;
      break;
    }
  }
  return flag;
}
vector<pair<ll, ll>> prime_factorize(ll n) {  // O( sqrt(n) )
  vector<pair<ll, ll>> ret;
  for (ll i = 2; i * i <= n; i++) {
    if (n % i != 0) continue;
    ll exp = 0;
    while (n % i == 0) {
      n /= i;
      exp++;
    }
    ret.push_back(make_pair(i, exp));
  }
  if (n != 1) ret.push_back(make_pair(n, 1));
  return ret;
}

/*union find*/
class unionfind {
 private:
  /*根のparの値は「-(その木の要素数)」とする*/
  ll n_;
  vector<ll> par;

  ll root(ll a) {  // O( log(n) )
    if (par.at(a) < 0)
      return a;
    else {
      par.at(a) = root(par.at(a));  //経路圧縮
      return par.at(a);
    }
  }

 public:
  unionfind(ll n) : n_(n), par(n, -1) {}  // O(n)

  void unite(ll a, ll b) {  // O( log(n) )
    assert(0 <= a && a < n_);
    assert(0 <= b && b < n_);
    if (root(a) == root(b))
      return;
    else {
      ll ra = root(a), rb = root(b);
      if (-par.at(ra) < -par.at(rb)) swap(ra, rb);  //サイズによる併合
      par.at(ra) += par.at(rb);
      par.at(rb) = ra;
    }
  }

  bool is_same(ll a, ll b) {  // O( log(n) )
    assert(0 <= a && a < n_);
    assert(0 <= b && b < n_);
    return root(a) == root(b);
  }

  ll size(ll a) {  // O( log(n) )
    assert(0 <= a && a < n_);
    return -par.at(root(a));
  }
};
}  // namespace my
////////////////////////////////////////////////

void dfs(string &s, int pos, char cmax, vector<string> &ans) {
  if (pos == s.size())
    ans.push_back(s);
  else if (pos == 0) {
    s.at(pos) = 'a';
    cmax = 'a';
    dfs(s, pos + 1, cmax, ans);
  } else {
    for (char c = 'a'; c <= cmax + 1; c++) {
      s.at(pos) = c;
      dfs(s, pos + 1, max(cmax, c), ans);
    }
  }
}

int main() {
  int n;
  cin >> n;
  string s(n, 'a');
  vector<string> ans;
  dfs(s, 0, 'a', ans);
  for (auto &ansi : ans) cout << ansi << endl;
}

Measured memory_bytes: 7264
n,l = map(int,input().split())
sum_a=0
for i in range(n):
    sum_a+=l+i
aa=[]
for i in range(n):
    aa.append(l+i)
if aa.count(0)==1:
    print(sum_a)
elif min(aa)>0:
    print(sum_a - min(aa))
else:
    print(sum_a - max(aa))


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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> d(100, 0);
    for (size_t i = 0; i < n; ++i) {
        int dd;
        cin >> dd;
        d[dd - 1] = d[dd - 1] + 1;
    }
    int num = 0;
    for (size_t i = 0; i < 100; ++i) {
        if (d[i] != 0) ++num;
    }
    cout << num << endl;
    return EXIT_SUCCESS;
}

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

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n, k;
    cin >> n >> k;
    vector<int> h(n), dp(n, numeric_limits<int>::max());
    for(int i = 0; i < n; ++i)
        cin >> h[i];
    dp[0] = 0;
    for(int i = 1; i < n; ++i) {
        for(int j = i - 1; j >= max(0, i - k); --j) {
            dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]));
        }
    }
    cout << dp[n - 1] << '\n';
}

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

int main() {
  int H, W;
  char A;
  cin >> H >> W;
  
  vector<string> top(W + 2, "#");
  for (int i = 0; i < W + 2; i++) cout << top.at(i);
  
  cout << endl;
  
  vector<string> mid(W + 2, "#");
  for (int j = 0; j < H; j++) {
    for (int i = 0; i < W + 2; i++) {  
      if (i > 0 && i < W + 1) {
        cin >> A;
        mid.at(i) = A;
      }
      cout << mid.at(i);
    }
    cout << endl;
  }
  
  vector<string> btm(W + 2, "#");
  for (int i = 0; i < W + 2; i++) cout << btm.at(i);
  
  cout << endl;
}

Measured memory_bytes: 3596
#![allow(unused_imports)]
#![allow(clippy::many_single_char_names)]

// language: Rust(1.42.0)
// check available crates on AtCoder at "https://atcoder.jp/contests/language-test-202001"
// My Library Repo' is at "https://github.com/Loptall/prcn_lib"

/*
    そう甘くはないんだな〜w
*/

// from std...
use std::cmp::{
    max, min, Ordering,
    Ordering::{Equal, Greater, Less},
    Reverse,
};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::convert::TryInto;
use std::mem::swap;
use std::num::{NonZeroU32, ParseIntError};
use std::ops::{
    Add, AddAssign, BitAnd, BitAndAssign, BitOr, BitOrAssign, BitXor, BitXorAssign, Div, DivAssign,
    Index, IndexMut, Mul, MulAssign, Neg, Rem, RemAssign, Shl, ShlAssign, Shr, ShrAssign, Sub,
    SubAssign,
};
use std::process::exit;
use std::{f32, f64, i128, i16, i32, i64, i8, isize, u128, u16, u32, u64, u8, usize};

// Dep' crates are...
use itertools::*;
use itertools_num::*;
use lazy_static::lazy_static;
use maplit::{btreemap, btreeset, hashmap, hashset};
use num_bigint::{BigInt, BigUint};
use num_complex::Complex;
use num_integer::{binomial, gcd, lcm, multinomial, Integer};
use num_rational::Rational;
use num_traits::{clamp, one, pow, zero, Num, NumAssignOps, NumOps, One, Pow, Zero};
use permutohedron::Heap;
use proconio::{
    fastout, input, is_stdin_empty,
    marker::{Bytes, Chars, Isize1, Usize1},
};
use rand::random;

pub const MOD10E9_7: usize = 1000000007;
pub const MOD99_: usize = 998244353;
pub const MAX: usize = std::usize::MAX;
pub const PI: f64 = f64::consts::PI;
pub const A: u8 = 65;

// code...
// #[fastout]
fn main() {
    input! {
        s: Chars
    }

    let n = s.len();
    let mut dp = vec![vec![0; 13]; n + 1];
    dp[0][0] = 1;

    for (i, c) in s.into_iter().enumerate() {
        match c.to_digit(10) {
            Some(k) => {
                for j in 0..13 {
                    dp[i+1][(j * 10 + k as usize) % 13] += dp[i][j];
                }
            }
            None => {
                for k in 0..10 {
                    for j in 0..13 {
                        dp[i + 1][(j * 10 + k as usize) % 13] += dp[i][j];
                    }
                }
            }
        }

        for j in 0..13 {
            dp[i + 1][j] %= MOD10E9_7;
        }
    }

    // dbg!(&dp);
    let ans = dp[n][5];
    println!("{}", ans);
}


Measured memory_bytes: 15572
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <math.h>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };


// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

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

bool isPrime(int n) {
	for(int i = 2; i * i <= n; i++){
		if (n % i == 0) return false;
	}
	return n != 1;
}

// 素因数分解 pair.firstで素数、pair.secondで対応する指数
vector<pair<long long, long long> > prime_factorize(long long n) {
	vector<pair<long long, long long> > res;
	for (long long p = 2; p * p <= n; ++p) {
		if (n % p != 0) continue;
		int num = 0;
		while (n % p == 0) { ++num; n /= p; }
		res.push_back(make_pair(p, num));
	}
	if (n != 1) res.push_back(make_pair(n, 1));
	return res;
}

const int MAX = 210000;

//二項係数を求める前処理 テーブルを作る　O(n)
// facは階乗
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod%i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}

// 二項係数計算
ll COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

// 勉強になりました

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

	int n;
	cin >> n;

	COMinit();

	vector<int> sum(n + 1, 0);

	// 1 ~ nでの数を素因数分解する
	Rep(i, 2, n + 1) {
		auto vec = prime_factorize(i);
		for (auto pa : vec) {
			sum[pa.first] += pa.second;
		}
	}
	ll ans = 1;
	Rep(i, 2, n + 1) {
		ans *= (sum[i] + 1);
		ans %= mod;
	}

	cout << ans << endl;

	return 0;
}

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

int main(){
	string s;
	cin >>s;
	int a = (s[0] - '0')*10 + (s[1] - '0');
	int b = (s[2] - '0')*10 + (s[3] - '0');

	if (a>12&&b>12||(a<1&&b<1)||(a<1&&b>12)||(a>12&&b<1))
		cout <<"NA";
	else if (a>12||a<1)
		cout <<"YYMM";
	else if (b>12||b<1)
		cout <<"MMYY";
	else
		cout <<"AMBIGUOUS";
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

long long f_n(long long n, long long x);

int main()
{
    long long a, b, x;
    cin >> a >> b >> x;

    long long ans;

    if (a > 0) {
        ans = f_n(b, x) - f_n(a - 1, x);
    } else {
        ans = f_n(b, x);
    }

    cout << ans << endl;

    return 0;
}

// 0以上n以下の整数のうち、xで割り切れるものの個数を返す
long long f_n(long long n, long long x) {
    return (n / x) + 1;
}

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

int main(){
    vector<int> a(3) ;
    rep(i,3) cin >> a[i] ;
    int k ;
    cin >> k ;
    sort(a.begin(),a.end()) ;
    cout << a[0] + a[1] + a[2]*pow(2,k) <<endl;
}

Measured memory_bytes: 4052
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}


ll f(string s){
	ll ret = 0;
	rep(i,s.size()){
		ret *= 10;
		ret += s.at(i) - '0';
	}
	return ret;
}


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;cin >> s;
	ll ans = 0;
	int n = s.size();
	rep(i,(1 << (n - 1))){
		int k = 0;
		ll sum = 0;
		rep(j,n - 1){
			if(i & (1 << j)){
				sum += f(s.substr(k, j - k + 1));
				k = j + 1;
			}
		}
		sum += f(s.substr(k, n - k));
		ans += sum;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
n = int(input())
a = [int(i) for i in input().split()]
arrival = [-1 for i in range(n)]
for i in range(n):
    arrival[a[i] - 1] = i + 1
for i in range(n - 1):
    print(str(arrival[i]), end = " ")
print(arrival[n - 1])

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

int main() {
	long long N, ans=0;
    cin >> N;
  	vector<int> A(N);
    for (int i=0; i<N; i++){
      		cin >> A[i];
    }
    for (int i=1; i<N; i++){
      	if (A[i]<A[i-1]){
          	ans += A[i-1]-A[i];
            A[i] = A[i-1];
        }
    }
    cout << ans << endl;
}




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

int main()
{
  int i,ans;
  char str[100002];
  scanf("%s", str);
  int len;
  int coeff;
  len = strlen(str);

  long x[100002];
  x[0] = 1;
  for (i = 1; i <= len; i++) {
    x[i] = x[i -1] * 3 % 1000000007;
  }
  i = 0;
  ans = 0;
  coeff = 1;
  while (str[i]) {
    if (str[i] == '1') {
      ans = (ans + coeff * (x[len-i-1]+2-1)) % 1000000007; 
      coeff = coeff * 2 % 1000000007;
    }
    i++;
  }

  printf("%d\n", ans+1);
}

Measured memory_bytes: 1024
/**
*    author:  yuya1234
*    created: 16.07.2020 16:23:40
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
long double eps = 1.0E-14;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define FORV(i,v) for(auto i=v.begin(); i!=v.end();i++)

#define SORT(s) sort((s).begin(),(s).end())
#define SORTD(s) sort((s).rbegin(),(s).rend())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define SZ(x) ((int)(x).size())
#define MEMSET(v, h) memset((v), h, sizeof(v))

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<class T>T lcm(T a,T b){return gcd(a,b)*(a/gcd(a,b))*(b/gcd(a,b));}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  //std::cout << std::fixed << std::setprecision(15);

  int n;
  cin>>n;

  int b[n];

  REP(i,n)cin>>b[i];

  vector<int> ans;
  bool flg=true;

  REP(i,n)
  {
    if(b[i]<=i+1)ans.insert(ans.begin()+ b[i]-1,b[i]);
    else
    {
      flg=false;
      break;
    }
  }

  if(flg)
  {
    for(auto v:ans)cout<<v<<endl;
  }
  else cout<<-1<<endl;

  return 0;
}

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

int main(void)
{
    char a,b,c,i,j,k,n;

    cin >> a;

    switch(a){
        case 'A':
        cout << 'T';
        break;
        case 'C':
        cout << 'G';
        break;
            case 'G':
        cout << 'C';
        break;
        case 'T':
        cout << 'A';
        break;
    }
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int X, A, B;

int main() {
  INCANT;
  cin >> X >> A >> B;
  cout << (X-A)%B << "\n";
  return 0;
}

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

int main() {
    int n;
    while(cin >> n, n) {
        vector<int> w(n);
        for(int i = 0; i < n; ++i) {
            cin >> w[i];
        }
        vector<vector<int>> dp(n, vector<int>(n, -1));
        function<int(int, int)> solve = [&] (int l, int r) {
            if(l >= r) return 0;
            int& res = dp[l][r];
            if(res != -1) return res;
            for(int i = l; i < r; ++i) {
                res = max(res, solve(l, i) + solve(i + 1, r));
            }
            if(abs(w[l] - w[r]) <= 1) {
                if(solve(l + 1, r - 1) == max(0, r - l - 1)) {
                    res = r - l + 1;
                }
            }
            return res;
        };
        cout << solve(0, n - 1) << endl;
    }
}



Measured memory_bytes: 3288
#include <bits/stdc++.h>
#define MAX (ll)(1e6 + 7)
#define INF (ll)(1e17 + 7)
#define MOD (ll)(1e9 + 7)
#define PI (double)(3.14159265)
#define IO ios_base :: sync_with_stdio (false);
#define LOG 22

using namespace std;
using ll = long long;

int main () {
	int k, n;
	cin >> k >> n;
	int ar[n];
	for (int i = 0; i < n; i++) {
		cin >> ar[i];
	}
	int ma = 0;
	for (int i = 1; i < n; i++) {
		ma =max (ar[i] - ar[i - 1], ma);
	}
	ma = max (ar[0] + k - ar[n - 1], ma);
	cout << k - ma << "\n";
}


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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

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

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { return a * b / GCD(a, b); }

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  int n; cin>>n;
  vi a(n+2);
  a[0]=a[n+1]=0;
  irep(i,1,n+1) cin>>a[i];
  
  int t=0;
  for(int i=0; i<n+2; i++){
    t+=abs(a[i+1]-a[i]);
  }

  irep(i,1,n+1){
    int ans=t+abs(a[i+1]-a[i-1])-abs(a[i]-a[i-1])-abs(a[i+1]-a[i]);
    cout<<ans<<endl;
  }
  
}


Measured memory_bytes: 1664
#define _GLIBCXX_DEBUG
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <map>
using namespace std;
typedef long long ll;
#define ALL(v) (v).begin(), (v).end()
const int mod = 1e9+7;
const int inf = 1e9;

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

	ll ans = 1;
	for (int i = 2; i <= N; i++) {
		bool p = 1;
		for (int j = 2; j*j <= i; j++) {
			if (i%j == 0) {
				p = 0;
				break;
			}
		}
		if (p) {
			int m = N;
			int k = 0;
			while (m) {
				k += m/i;
				m /= i;
			}
			ans *= k+1;
			ans %= mod;
		}
	}

	cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)

int main() {

	int N, T;
	scanf("%d%d", &N, &T);

	int ans = 123456;
	rep(i, N) {
		int c, t;
		scanf("%d%d", &c, &t);

		if (t <= T) {
			ans = min(ans, c);
		}
	}

	if (ans == 123456) printf("TLE\n");
	else printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 256
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][] a = new int[n][3];
        int[][] dp = new int[n+1][3];

        for(int i = 0; i<n; i++) {
            a[i][0] = sc.nextInt();
            a[i][1] = sc.nextInt();
            a[i][2] = sc.nextInt();
        }

        dp[1][0] = a[0][0];
        dp[1][1] = a[0][1];
        dp[1][2] = a[0][2];

        for(int i = 2; i<n+1; i++) {
            for(int j = 0; j<3; j++) {
                int ca = (j+1)%3;
                int cb = (j+2)%3;
                dp[i][j] = Math.max(dp[i-1][ca]+a[i-1][j], dp[i-1][cb]+a[i-1][j]);

            }
        }
        int ans = Math.max(dp[n][0],dp[n][1]);
        ans = Math.max(ans,dp[n][2]);
        System.out.println(ans);
    }
}

Measured memory_bytes: 100960
s = str(input())
n = len(s)

# 回文の判定
for i in range((n-1)//2):
  # print(i)
  if s[i] != s[n-i-1]:
    print('No')
    exit(0)
    
# 前半回文の判定
for j in range((n-1)//4):
  # print(j)
  if s[j] != s[(n-1)//2 -j-1]:
    print('No')
    exit(0)
    
# 回文の判定
for k in range((n+3)//2, n):
  # print(k)
  if s[k] != s[n-k-1]:
    print('No')
    exit(0)
    
print('Yes')

Measured memory_bytes: 3064
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#include <map>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
//================================================

int a = 0, b = 0, c, d, n, k=0;
string s, t;


int main()
{
	int p, q, r;
	cin >> p >> q >> r;
	cout << p + q + r - max({ p,q,r }) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#define LL long long
using namespace std;
int main()
{
    char ch[200];
    cin >> ch;
    int len =strlen(ch);
    cout << ch[0]<< len-2 << ch[len-1]<<endl;
    return 0;
}


Measured memory_bytes: 256
import os

def main():
	num = list(map(int, input().split()))	
	if num[0] == num[1] or num[0] == num[2]:
		if num[1] == num[2]:
			print("No")
		else:
			print("Yes")
	else:
		if num[1] == num[2]:
			print("Yes")
		else:
			print("No")

if __name__ == "__main__":
	main()

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int x1, x2, x3, x4, y1, y2, y3, y4;
	cin>>x1>>y1>>x2>>y2;
	x3=x2+(y1-y2);
	y3=y2+(x2-x1);
	x4=x3+(y2-y3);
	y4=y3+(x3-x2);
	cout<<x3<<' '<<y3<<' '<<x4<<' '<<y4<<'\n';
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		String string = sc.nextLine();

		if (string.charAt(2) == string.charAt(3) && string.charAt(4) == string.charAt(5)) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}

	}
}

Measured memory_bytes: 35648
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
using ll = long long;
using ld = long double;
using namespace std;
//const int INF = 7+(1e+9);
ll GCD(ll x, ll y)
{
    if (y == 0)
    {
        return x;
    }
    else
    {
        return GCD(y, x % y);
    }
}
ll LCM(ll x, ll y)
{
    return x / GCD(x, y) * y;
}
struct UnionFind
{
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    UnionFind(int N) : par(N)
    { //最初は全てが根であるとして初期化
        for (int i = 0; i < N; i++)
            par[i] = i;
    }

    int root(int x)
    { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x)
            return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y)
    {                     // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry)
            return;   //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y)
    { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};
long long modinv(long long a, long long m)
{
    long long b = m, u = 1, v = 0;
    while (b)
    {
        long long t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0)
        u += m;
    return u;
}
ll MOD = 1e9 + 7;

int main()
{
    ll a, b, q;
    cin >> a >> b >> q;
    vector<ll> sh(a + 2);
    for (int i = 1; i <= a; i++)
    {
        cin >> sh[i];
    }
    sh[0] = -1e18;
    sh[a + 1] = 1e18;
    sort(sh.begin(), sh.end());
    vector<ll> te(b + 2);
    for (int i = 1; i <= b; i++)
    {
        cin >> te[i];
    }
    te[0] = -1e18;
    te[b + 1] = 1e18;
    sort(te.begin(), te.end());
 //   cout<<q<<endl;
    for (int i = 0; i < q; i++)
    {
        ll x;
        cin >> x;
        ll sh1=sh[lower_bound(sh.begin(), sh.end(), x) - sh.begin()];
        ll sh2=sh[lower_bound(sh.begin(), sh.end(), x) - sh.begin()-1];
        ll te1=te[lower_bound(te.begin(), te.end(), x) - te.begin()];
        ll te2=te[lower_bound(te.begin(), te.end(), x) - te.begin()-1];
      //  cout<<sh1<<" "<<sh2<<" "<<te1<<" "<<te2<<endl;
        cout<<min({abs(sh1-te1)+min(abs(sh1-x),abs(te1-x)),abs(sh2-te1)+min(abs(sh2-x),abs(te1-x)),abs(sh1-te2)+min(abs(sh1-x),abs(te2-x)),abs(sh2-te2)+min(abs(sh2-x),abs(te2-x))})<<endl;
    }
}


Measured memory_bytes: 2944
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
#include<queue>

using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n; ++i)
#define ALL(a) (a).begin(),(a).end()
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n)cin >> a[i];
    sort(ALL(a));
    ll l = a.back();
    a.pop_back();
    a.push_back(10000000000);
    auto itr = lower_bound(ALL(a), l/2);
    ll pos = itr - a.begin();
    if(pos > 0)if(abs(l/2 - a[pos-1]) < abs(l/2 - a[pos]))pos--;
    cout << l << " " << a[pos] << endl;
}

Measured memory_bytes: 1024
solve a b c x = do
  d <- [0..a]
  e <- [0..b]
  f <- [0..c]
  if 500*d+100*e+50*f==x
    then return x
    else []

main = do
  a <- readLn
  b <- readLn
  c <- readLn
  x <- readLn
  putStrLn $ show $ length $ solve a b c x


Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
int n,a[3][105],dp[3][105];
int main()
{
    scanf("%d",&n);
    for (int i=1;i<=2;++i)
        for (int j=1;j<=n;++j) {
            int x;scanf("%d",&x);
            dp[i][j]=max(dp[i-1][j],dp[i][j-1])+x;
        }
    printf("%d\n",dp[2][n]);
    return 0;
}


Measured memory_bytes: 3816
import java.util.*;
public class Main {
	static char[] l = new char[] {'q','w','e','r','t','a','s','d','f','g','z','x','c','v','b'};
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		HashMap<String,Boolean> a = new HashMap<String,Boolean>();
		int n = stdIn.nextInt();
		for(int i = 0; i < n; i++) {
			a.put(stdIn.next(), true);
		}
		int m = stdIn.nextInt();
		boolean c = true;
		for(int i = 0; i < m; i++) {
			String b = stdIn.next();
			if(!a.containsKey(b)) {
				System.out.println("Unknown " + b);
			}
			else {
				if(c) {
					System.out.println("Opened by " + b);
					c = false;
				}
				else {
					System.out.println("Closed by " + b);
					c = true;
				}
			}
		}
	}
}

Measured memory_bytes: 20536
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


int main()
{
	int H, W;
	cin >> H >> W;

	int h, w;
	cin >> h >> w;

	println((H - h) * (W - w));
}

Measured memory_bytes: 256
h,w,d = map(int,input().split())
li = [-1]*h*w

for i in range(h):
    a = list(map(int,input().split()))
    for j in range(w):
        li[a[j]-1] = (i,j)

li2 = [[] for _ in range(d)]
li3 = [[0] for _ in range(d)]
for i in range(d):
    li_tmp = li[i::d]
    for j in range(len(li_tmp)-1):
        li2[i].append(abs(li_tmp[j][0]-li_tmp[j+1][0]) + abs(li_tmp[j][1]-li_tmp[j+1][1]))

for i in range(d):
    for j in range(len(li2[i])):
        if j == 0:
            li3[i].append(li2[i][j])
        else:
            li3[i].append(li3[i][-1] + li2[i][j])

q = int(input())
for _ in range(q):
    l,r = map(int,input().split())
    l -= 1
    r -= 1
    l1 = l % d
    print(li3[l1][r//d] - li3[l1][l//d])


Measured memory_bytes: 67588