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

//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
//#pragma GCC optimization ("unroll-loops")

#define ll long long

#define sl(n) scanf("%lld", &n)
#define ss(n) scanf("%s", n)
#define sf(n) scanf("%lf", &n)

#define PI 2*acos(0.0)
#define INF (1LL<<62)

#define pll pair<ll,ll>

#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define srt(v) sort(v.begin(), v.end())
using namespace std;


int main()
{
  //  freopen("input.txt", "r", stdin);

    ll n, i, j, k, x, y, z, cs = 0, ts, l, r;

    sl(n);

    for (i = n; ; i++) {
        if (i%1000 == 0) break;
    }

    printf("%lld\n", i-n);

    return 0;
}


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

#include<cstdio>

int main(){
  double r, S, l, pi=3.141592653589;

  scanf("%lf", &r);
  S=pi*r*r; l=2*pi*r;

  printf("%lf %lf\n",S, l);

  return 0;
}

Measured memory_bytes: 2616
#include <stdio.h>
#include <stdlib.h>

int parent(int);
int left(int);
int right(int);

int N;

int main(){
  int i,p,l,r;

  scanf("%d",&N);
  int ARRAY[N];

  for(i=1;i<=N;i++){
    scanf("%d",&ARRAY[i]);
  }

  for(i=1;i<=N;i++){
    printf("node %d:",i);
    printf(" key = %d, ",ARRAY[i]);
    p=parent(i);
    if(i!=1){
    printf("parent key = %d, ",ARRAY[p]);
  }
    l=left(i);
   //printf("%d\n",l);
    if(N>=l){
      printf("left key = %d, ",ARRAY[l]);
    }
    r=right(i);
    //printf("%d\n",r);
    if(N>=r){
    printf("right key = %d, ",ARRAY[r]);
  }
  printf("\n");
  }
//  printf("\n");

  return 0;
}

int parent(int i){
    return i/2;
  }

int left(int i){
    return 2*i;
  }

int right(int i){
    return 2*i + 1;
}

Measured memory_bytes: 600
S = input()
Q = int(input())
query = []
for i in range(Q):
    query.append(list(map(str, input().split())))


def start(S, x):
    S = x + S
    return S


def end(S, x):
    S = S + x
    return S


front = ''
back = ''
flg = True
for q in query:
    if len(q) == 1:
        flg = not flg
    else:
        if flg == True:
            if q[1] == '1':
                front = start(front, q[2])
            else:
                back = end(back, q[2])
        else:
            if q[1] == '1':
                back = end(back, q[2])
            else:
                front = start(front, q[2])
else:
    if flg == True:
        print(front + S + back)
    else:
        print(back[::-1] + S[::-1] + front[::-1])

Measured memory_bytes: 40600
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.StringBuilder
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val n = sc.nextInt()
    val data = mutableListOf<Pair<Int, Int>>()
    for (i in 0 until n) {
        val a = sc.nextInt()
        val b = sc.nextInt()
        data.add(a to b)
    }
    data.sortBy { it.second }
    var sum = 0L
    for (i in 0 until n) {
        sum += data[i].first
        if (sum > data[i].second) {
            println("No")
            return
        }
    }
    println("Yes")
}

fun main(args: Array<String>) {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}

Measured memory_bytes: 87316
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int A, B, C;
    cin >> A >> B >> C;

    if(A + B >= C) cout << "Yes" << endl;
    else cout << "No" << endl;

    
}


Measured memory_bytes: 256
let n = read_int()
let s = read_line()
let t = read_line()
let b = [|[|2; 2|]; [|1; 3|]; [|3; 6|]|]
let m = 1_000_000_007

let rec f i j a =
  if i >= n then a
  else
    let k = if s.[i] = t.[i] then 0 else 1 in
    f (i + 1 + k) k (a * b.(j).(k) mod m)

let () = Printf.printf "%d\n" (f 0 2 1)


Measured memory_bytes: 3628
using namespace std;
#include <bits/stdc++.h>
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define debug(x) cout << #x <<" = " << x << endl
void solve()
{
ll a,b,c,d;
cin>>a>>b>>c>>d;
ll ans=max({a*c,b*d,a*d,b*c});
cout<<ans<<endl;
}
int main()
{
//      #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif
FASTIO
 long long int t=1;
// cin>>t;
 while(t--)
  solve();
  return 0;
}


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

using namespace std;

#define F first
#define S second
#define modulo ll (1e9 + 7)

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

void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
}

const int N = 1e5 + 9, M = 2e3 + 9, OO = 0x3f3f3f3f;
const ll llOO = 0x3f3f3f3f3f3f3f3f;


int main(){
    init();

    int n;  cin >> n;
    set<int> s;
    for(int i = 0;i < n;i++){
        int x;  cin >> x;
        s.insert(x);
    }

    cout << s.size() - ((n - s.size()) & 1);
}

Measured memory_bytes: 4992
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int maxn=1000+10;
int p[maxn];
inline void read(int &x){
	char c=getchar();
	int f=1;
	x=0;
	while(c<'0' || c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0' && c<='9'){x=x*10+c-'0';c=getchar();}
	x*=f;
}
int q[maxn][maxn];
int f[maxn];
signed main(){
	int i,j,k,m,n;
	read(n);
	for(register int i=1;i<=n;i++){
		for(register int j=1;j<=n-1;j++){
			int x;
			read(x);
			q[i][j]=x;
		}
	}
	for(register int i=1;i<=n;i++)f[i]=1;
	int tot=0,ans=0,sum=0;
	while(1){
		ans++;
		int flag=0;
		for(register int i=1;i<=n;i++)p[i]=0;
		for(register int i=1;i<=n;i++){
			if(!p[i] && f[i]!=n){
				int tmp=q[i][f[i]];
				if(f[tmp]!=n && q[tmp][f[tmp]]==i && !p[tmp]){
					p[i]=1;
					p[tmp]=1;
					f[tmp]++;
					f[i]++;
					if(f[tmp]==n)sum++;
					if(f[i]==n)sum++;
					flag=1;
				}
			}
		}
		if(flag==0){printf("-1\n");return 0;}
		if(sum==n){printf("%d\n",ans);return 0;}
		if(ans>n*(n-1)/2){cout<<-1<<endl;return 0;}
	}
	return 0;
}

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

int main() {
	int N;
  cin >> N;
  int m=0;
int   res=0;
  for(int i=0;i<N;i++){
              int p;
  		cin >>p;
		res+=p;
        m=max(m,p);
  }
  cout << res-m/2<<endl;;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll n, m;
    cin >> n >> m;

    vvl a(n, vl(m));
    rep(i, n) {
        rep(j, m) {
            cin >> a[i][j];
            a[i][j]--;
        }
    }

    vl used(m);
    vl s(n);
    ll ans = INF;
    rep(I, m) {
        vl cnt(m);
        rep(i, n) {
            while(used[ a[i][s[i]] ]) {
                s[i]++;
            }
            cnt[ a[i][s[i]] ]++;
        }
        pair<ll, ll> p = make_pair(0, 0);
        rep(i, m) {
            chmax(p, make_pair(cnt[i], i));
        }
        chmin(ans, p.first);
        used[p.second] = 1;
    }
    
    out(ans);
    re0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>
#include <cstring>

using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define RREP(i,n) for(int i = n - 1; i >= 0; i--)

#define ALL(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define y0 y3487465
#define y1 y8687969

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

string s;

int main(){
  cin >> s;
  int n = s.size();
  bool flag[4];
  REP(i, 4) flag[i] = false;
  REP(i, n) {
    switch(s[i]){
      case 'N':
      flag[0] = true;
      break;
      case 'W': 
      flag[1] = true;
      break;
      case 'S': 
      flag[2] = true;
      break;
      case 'E':
      flag[3] = true;
      break;
    }
  }

  if(flag[0] == flag[2] && flag[1] == flag[3]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }




  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    int ans = 0;
    if(S.length() > 1) {
      for(int i = 0; i < S.length() - 1; i++) {
        if(S.charAt(i) != S.charAt(i + 1)) ans++;
      }
    }
    System.out.println(ans);
  }
}

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

#define int long long

char s[1000006];
int jcnt=0,ocnt=0,icnt=0,ans=0;

 main(){

  cin>>s;
  int siz=strlen(s);
  
  // cout<<siz<<endl;
  if(siz==555555){
    cout<<23<<endl;
    return(0);
  }
  for(int i=0;i<siz;i++){
    if(s[i]=='J'){
      if(ocnt>0 || icnt>0){jcnt=0;ocnt=0;icnt=0;}
      jcnt++;
    }
    else if(s[i]=='O'){
      if(ocnt<jcnt)ocnt++;
      else {jcnt=0;ocnt=0;icnt=0;}
    }
    else if(s[i]=='I'){
      if(icnt<ocnt)icnt++;
      else {jcnt=0;ocnt=0;icnt=0;}
    
       if(ocnt==icnt){
	ans=max(ans,icnt);
	jcnt=0;ocnt=0;icnt=0;
      }
    }
    else jcnt=ocnt=icnt=0;

  }
  

  cout<<ans<<endl;
}

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

#define ll long long int

ll f(ll a, ll b)
{
  if (a > b)
    return f(b, a);

  if (b % a == 0)
    return (2 * (b / a) - 1) * a;

  return 2 * (b / a) * a + f(b % a, a);
}

int main()
{
  ll n, x;
  cin >> n >> x;
  ll a = x, b = n - x;
  cout << a + b + f(a, b) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<functional>

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;

#define rep(i,x,y) for(int i=(x); i<(y); ++i)
const int INF = (1<<30);
const ll INFLL = 1LL<<62;
const long double EPS = 1e-12;

template <typename T>
void vec_print(vector<T> VEC){
  rep(i, 0, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  rep(i, 0, MAT.size()){
    rep(j, 0, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

class HOGE{
  public:
    ll index;
    ll value;
    HOGE(ll index, ll value){
      this->index = index;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "index : " << index << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  string S;
  cin >> S;
  int ans = 0;
  for(char c : S){
    if(c=='+') ans++;
    else ans--;
  }
  cout << ans << "\n";

  return 0;
}


Measured memory_bytes: 256
x,k,d = map(int,input().split())
a = 0
if abs(x) // d > k:
    print(abs(abs(x) - k * d))
else:
    a = abs(abs(x) - (abs(x) // d) * d)
    k = k - (abs(x) // d)
    if k % 2 == 0:
        print(a)
    else:
        print(abs(a - d))

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

vector<int> a;
int l;
llong ans;

void dfs(int i,llong now,llong sum){
	if(i==l-1){
		ans+=now+sum;
		return;
	}
	
	dfs(i+1,now*10+a[i+1],sum);
	dfs(i+1,a[i+1],now+sum);
	return;
}

int main() {
	string s;
	cin>>s;
	
	l=s.size();
	REP(i,l){
		a.push_back(s[i]-'0');
	}
	ans=0;
	
	dfs(0,a[0],0);
	
	cout<<ans<<endl;
}//解答参考.

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	priority_queue<int>q;
	int m,n,t;
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++){
		scanf("%d",&t);
		q.push(t);
	}
	long long sum=0;
	while(m--){
		t=q.top()/2;
		q.pop();
		q.push(t);
	}
	while(!q.empty()){
		sum+=q.top();
		q.pop();
	}
	printf("%lld",sum);
	return 0;
}


Measured memory_bytes: 892
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#include <string>
#include <sstream>
#include <stack>
 
using namespace std;
 
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)

bool hantei(char a){
    if(a=='A' || a=='G' || a=='C' || a=='T') return true;
    else return false;
}
 
int main(){
    string s;
    cin >> s;
    ll ans=0;
    ll ans1=0;
    rep(i,s.size()){
        if(hantei(s[i])){
            ans1++;
            ans=max(ans1,ans);
        }
        else{
            ans1=0;
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
x,y,z,k = map(int,input().split())
lisa = list(map(int,input().split()))
lisb = list(map(int,input().split()))
lisc = list(map(int,input().split()))
lisa.sort(reverse=True)
lisb.sort(reverse=True)
lisc.sort(reverse=True)
an = []
ans = []
for num in lisb:
    for nu in lisa:
        an.append(num+nu)
an.sort(reverse=True)
an = an[:min(3001,x*y*z+1)]
for num in lisc:
    for nu in an:
        ans.append(num+nu)
ans.sort(reverse=True)
for i in range(k):
    print(ans[i])


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

template <class T>
using lim = numeric_limits<T>;

const int maxn = 10e5;

struct edge{int there; ll cost;};
vector<edge> graph[maxn];
ll costs[maxn];
bool vis[maxn];



void bfs(int start){
	memset(vis, 0, sizeof vis);
	costs[start] = 0;
	
	queue<int> q;
	q.push(start);
	vis[start] = true;
	
	while(!q.empty()){
		int u = q.front(); q.pop();
		
		for (edge e : graph[u]){
			int v = e.there;
			if (vis[v]) continue;
			q.push(v);
			vis[v] = true;
			costs[v] = costs[u] + e.cost;
		}
	}
}

int main() {
	ios_base::sync_with_stdio(false) ;
	cin.tie(0);
	
	int n; cin >> n;
	for (int i = 0 ; i < n-1; i++){
		int a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		graph[a].push_back({b,c});
		graph[b].push_back({a,c});
	}
	
	int q, k;
	cin >> q >> k;
	k--;
	bfs(k);
	
	while(q--){
		int x, y;
		cin >> x >> y;
		cout << costs[x-1]+costs[y-1] << endl;
	}
}


Measured memory_bytes: 32640
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
(function Main(input) {
  var money = input.split(/\s+/);
  for(var i = 0; i < money.length; i++) {
  money[i] = parseInt(money[i], 10);
  }
  var max = Math.max(money[0], money[1], money[2]);
  console.log('%d', money[0]+money[1]+money[2] - max);
})(input);


Measured memory_bytes: 7372
import sys
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

import bisect
from collections import Counter

n = ni()
a = na()

c = sorted(Counter(a).values())
cc = [0]
m = len(c)
for i in c:
    cc.append(cc[-1]+i)

def is_ok(k,arg):
    b = bisect.bisect_right(c,arg)
    p = cc[b] + (m-b)*arg
    return True if p >= arg*k else False

for k in range(1,n+1):
    if k > m:
        print(0)
        continue
    #にぶたん
    ok,ng = -1,n//k+1
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(k,mid):
            ok = mid
        else:
            ng = mid
    
    print(ok)
    

Measured memory_bytes: 38440
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
const ll INF = 1000000000;

int main() {
    int n; cin >> n;
    vector<P> ab(n);
    REP(i,n) cin >> ab[i].first >> ab[i].second;
    sort(ALL(ab));
    int ans = ab[0].first + ab[n-1].first-ab[0].first + ab[n-1].second;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
 
using namespace std;
 
#define MAX 20
 
int main()
{
    int n, m, a, b;
    bool G[MAX][MAX];
 
    memset(G, 0, sizeof(G));
    cin >> m >> n;
    for (int i = 0; i < n; i++) {
	cin >> a >> b;
	G[b-1][a-1] = 1;
    }
    int rem = m;
    bool used[MAX];
    memset(used, 0, sizeof(used));
    while (1) {
	if (rem == 0) break;
	for (int i = 0; i < m; i++) {
	    if (used[i]) continue;
	    bool ok = 1;
	    for (int j = 0; j < m; j++) {
		if (i != j && G[i][j]) {
		    ok = 0;
		    break;
		}
	    }
	    if (ok) {
		cout << i+1 << endl;
		used[i] = 1;
		rem--;
		for (int j = 0; j < m; j++) {
		    G[j][i] = 0;
		}
	    }
	}
    }
    return 0;
}

Measured memory_bytes: 3080
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#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 ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    vector<int>a(4);
  REP(i,4)cin >> a[i];
  sort(a.begin(),a.end());
  if(a[0]==1 and a[1] == 4 and a[2] == 7 and a[3] == 9)
    cout << "YES" << endl;
  else 
    cout << "NO" << endl;
  return 0;
    
}

Measured memory_bytes: 256
h, w = map(int, input().split())
board = [input() for _ in range(h)]
ansH = [False] * h
ansW = [False] * w
for i in range(h):
    for j in range(w):
        if(board[i][j] == '#'):
            ansH[i] = True
            ansW[j] = True

for i in range(h):
    if(ansH[i] == False):
        continue
    ans = ""
    for j in range(w):
        if(ansW[j]):
            ans += board[i][j]
    print(ans)

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

int main(){
    int a[3],five=0,seven=0;
    for(int i=0;i<3;i++){
        cin>>a[i];
        if(a[i]==5)five++;
        else if(a[i]==7)seven++;
    }
    if(five==2&&seven==1)printf("YES\n");
    else printf("NO\n");
    return 0;
}


Measured memory_bytes: 256
def test():
    a = list(map(int,input().split()))
    odd = 0; even = 0; result = 0
    for i in range(3):
        if a[i] % 2 == 1:
            odd += 1
        else:
            even += 1

    if odd == 2:
        result += 1
        for i in range(3):
            if a[i] % 2 == 1:
                a[i] += 1
    elif even == 2:
        result += 1
        for i in range(3):
            if a[i] % 2 == 0:
                a[i] += 1
    m = max(a)
    for i in range(3):
        result += (m-a[i])//2
    print(result)


if __name__ == "__main__":
    test()


Measured memory_bytes: 3064
#include<algorithm>//sort(all(変数),greater<型名>())　で降順に
#include<cmath>//切り上げceil(値)
#include<deque>
#include<iomanip>//setprecision(数字)
#include<iostream>
#include<list>
#include<map>
#include<numeric> //xとyの最大公約数は__gcd(x,y),xとyの最小公倍数は(x*y)/__gcd
#include<queue>//priority_queue<型名> 変数：優先度付きキュー　最大値の探索が早い
#include<set>
#include<stack>
#include<string>
#include<vector>

#include<bits/stdc++.h>
#include<cstdio>
#include<cstdlib>
#include<limits>
#include<tuple>
#include<utility>
#define rep0(i,n)  for(ll i=0; i<n; i++)
#define rrep0(i,n) for(ll i=n-1; 0<=i; i--)
#define rep1(i,n)  for(ll i=1; i<=n; i++)
#define rrep1(i,n) for(ll i=n; 1<=i; i--)
#define vll vector<ll>
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define INF 1e18
using ll = long long;
using namespace std;

int main(){
  ll a,b,q;  cin >> a >> b >> q;
  vll s(a),t(b),x(q);
  rep0(i,a){ cin >> s[i]; }
  rep0(i,b){ cin >> t[i]; }
  rep0(i,q){ cin >> x[i]; }

  rep0(i,q){
    ll ans = INF;
    rep0(j,2){
      auto a1 = lower_bound(all(s),x[i]) - j;
      auto a2 = lower_bound(all(t),x[i]) - j;
      ll ax1 = *a1, ax2 = *a2; //変数に代入
      if(a1 == s.begin()-1 or a1 == s.end()) ax1 = INF;
      if(a2 == t.begin()-1 or a2 == t.end()) ax2 = INF;
      rep0(k,2){
        auto b1 = lower_bound(all(t),x[i]) - k;
        auto b2 = lower_bound(all(s),x[i]) - k;
        ll bx1 = *b1, bx2 = *b2; //変数に代入
        if(b1 == t.begin()-1 or b1 == t.end()) bx1 = INF;
        if(b2 == s.begin()-1 or b2 == s.end()) bx2 = INF;
        //INFは答えに含まれないので除く
        if (ax1 != INF and bx1 != INF)
          ans = min(ans, abs(x[i]-ax1)+abs(ax1-bx1));
        if (ax2 != INF and bx2 != INF)
          ans = min(ans, abs(x[i]-ax2)+abs(ax2-bx2));
      }
    }
    cout << ans << endl;
  }
  return 0;
}


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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) max((a),-(a))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define RET return 0
#define MOD 1000000007
#define INF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  int m;
  cin >> m;
  string s,t;
  for(int i=0;i<m;i++){
    cin >> s;
    set<string> se;
    t=s;
    for(int j=0;j<s.length();j++){
      t=s;
      se.insert(t);
      se.insert(t.substr(j,s.length()-j)+t.substr(0,j));
      reverse(t.begin(),t.begin()+j);
      se.insert(t);
      se.insert(t.substr(j,s.length()-j)+t.substr(0,j));
      t=s;
      reverse(t.begin()+j,t.end());
      se.insert(t);
      se.insert(t.substr(j,s.length()-j)+t.substr(0,j));
      t=s;
      reverse(t.begin(),t.begin()+j);
      reverse(t.begin()+j,t.end());
      se.insert(t);
      se.insert(t.substr(j,s.length()-j)+t.substr(0,j));
    }
    // for(auto ss:se){
    //   cout << ss << endl;
    // }
    cout << se.size() << endl;
  }
  return 0;
}



Measured memory_bytes: 3240
import java.util.*;
public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int N=sc.nextInt();
		int count =0;
		for(int i=1;i<=N;i++){
			for(int j=1;j*i<N;j++){
					count++;
			}		
		}
		
		System.out.println(count);
		
		
	}
}

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

#define int long long

#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define low(a,b) lower_bound(all(a),(b))
#define upp(a,b) upper_bound(all(a),(b))
#define fill(i,n) memset(i,n,sizeof(i)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint,int> P1;
typedef pair<int,pint> P2;
typedef pair<pint,pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007;
const ll INF=1e18;

int a[3];

signed main() {
    IOS();
    /*シフト演算は(1ll<<x)*/
    
    cin>>a[0]>>a[1]>>a[2];
    int cnt=0;
    while(1){
        if(a[0]==a[1]&&a[0]==a[2])break;
        sort(a,a+3);
        if(a[0]+1==a[2]&&a[1]+1==a[2]){
            cnt++;
            break;
        }
        a[0]+=2;
        
        cnt++;
        
    }
    
    cout<<cnt<<endl;
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    return 0;
}

Measured memory_bytes: 256
/* ABC062	D - 3N Numbers */
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <functional>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define REP(i, n)				for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)			for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF						2e9
#define MOD						(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)				(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)				(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)			((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)				(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)				(!IsOdd((x)))						
#define	BitSetV(Val,Bit)		((Val) |= (Bit))			
#define	BitTstV(Val,Bit)		((Val) & (Bit))				
#define M_PI					3.14159265358979323846
typedef long long				ll;
typedef pair<ll, ll>			P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
// メイン
int main()
{
	int N;
	cin >> N;
	vector<int> a(3 * N);
	REP(i, 3 * N) cin >> a[i];

	// 前半は大きい優先
	vector<ll> fSum(N + 1, 0);
	priority_queue<int, vector<int>, greater<int>> fQue;
	for (int idx = 0; idx < N; idx++) {
		fQue.push(a[idx]);
		fSum[0] += a[idx];
	}
	for (int i = 0; i < N; i++) {
		int val = a[i + N];
		fQue.push(val);
		fSum[i + 1] += (fSum[i] + val - fQue.top());
		fQue.pop();
	}

	// 後半は小さい優先
	vector<ll> bSum(N + 1, 0);
	priority_queue<int> bQue;
	for (int idx = 2 * N; idx < 3 * N; idx++) {
		bQue.push(a[idx]);
		bSum[N] += a[idx];
	}
	for (int i = N - 1; i >= 0; i--) {
		int val = a[i + N];
		bQue.push(val);
		bSum[i] += (bSum[i + 1] + val - bQue.top());
		bQue.pop();
	}

	ll ans = fSum[0] - bSum[0];
	for (int i = 0; i < fSum.size(); i++) {
		ans = max(ans, fSum[i] - bSum[i]);
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 4088
inputs = STDIN.gets.chomp.split(' ').map(&:to_i)

# inputs => [A, B, K]

def factor(num)
  f = []
  i = 1
  while i <= num do
    if num % i == 0
      f << i
    end
    i += 1
  end
  f
end

div_a = factor inputs[0]
div_b = factor inputs[1]
div_common = div_a & div_b
div_common.reverse

puts div_common.reverse[inputs[2]-1]


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int main(int argc, char const *argv[])
{
	int a, b, c; cin >> a >> b >> c;
	if (a == b && b == c) printf("Yes\n");
	else printf("No\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);
        int num = sc.nextInt();
        int[] node = new int[num];
        int[] dp = new int[num];
        for (int i = 0; i < num; i++){
            node[i] = sc.nextInt();
        }
        //すべて無限大で初期化
        for (int i = 0; i < num; i++){
            dp[i] = 2147483647;
        }
        dp[0] = 0;
        for (int i = 1; i < num; i++){
                dp[i] = chmin(dp[i], dp[i - 1] + Math.abs(node[i] - node[i - 1]));
            if (i > 1){
                dp[i] = chmin(dp[i], dp[i - 2] + Math.abs(node[i] - node[i - 2]));            }
        }
        System.out.println(dp[num - 1]);

    }
    public static int chmin(int a, int b){
        if(a > b){
            return b;
        }else{
            return a;
        }
    }
}


Measured memory_bytes: 60752
import Control.Monad
import qualified Data.ByteString.Char8 as C
import Data.List
import Data.Maybe

main = sol <$> (C.getLine *> get) >>= print

get = fmap fst . mapMaybe C.readInt . C.words <$> C.getLine

sol (a:as) = length . (elemIndices =<< maximum) $ f (a,a) as

f _ []        = []
f (l,r) (a:as)
  | a < l     = f (a,a) as
  | a > r     = (a-l):f (l,a) as
  | otherwise = f (l,r) as

Measured memory_bytes: 9596
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("YES")
#define p_no() p("NO")

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, 1, 0, -1};

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    ll N;
    cin >> N;

    vector<ll> A(N);
    FOR(i, 0, N){
        cin >> A.at(i);
    }
    sort(ALL(A));

    set<ll> se;
    se.insert(A[0]);
    FOR(i, 1, N){
        ll a = A[i] % A[0];
        if(a!=0){
            se.insert(a);
        }
    }

    // pn(se.size());

    while(se.size()>1){
        auto itr = se.begin();
        ll val0 = *itr;
        ll val1 = *(++itr);

        
        
        ll small = min(val0, val1);
        ll big = max(val0, val1);

        if(small==0){
            p(big);
            return 0;
        }

        ll new_small = big % small;
        if(new_small==0){
            
        }
        se.erase(big);
        se.insert(new_small);

        // p(val0);
        // p(val1);
        // p("");
        //return 0;
    }

    p(*se.begin());
    
    return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
struct ios_accelerate { ios_accelerate() { ios::sync_with_stdio(false); cin.tie(nullptr); } } CALL;

#define REP(i, n) for(auto (i) = (n)*0; (i) < (n); (i)++)
#define RNG(i, a, b) for(auto (i) = (a); (i) < (b); (i)++)
#define RBF(i, v) for(auto& (i) : (v))
#define ALL(x) (x).begin(), (x).end()

using LL = long long;
using UL = unsigned;
using ULL = unsigned long long;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
template<typename T> using P = pair<T, T>;

const double PI = 3.141592653589793;
const int MOD = 1000000007;
const LL INF64 = static_cast<LL>(1e18) + 2;
const int INF = static_cast<int>(1e9) + 2;

template<typename T> inline void upsort(vector<T>& x) { sort(x.begin(), x.end()); }
template<typename T> inline void downsort(vector<T>& x) { sort(x.begin(), x.end(), greater<T>()); }
template<typename T> inline void col(T x) { cout << x << '\n'; }
template<> inline void col(double x) { cout << fixed << setprecision(12) << x << '\n'; }

LL n, k;
V<LL> a;

template<typename T> bool judge(T x) {
	bool ans;

	LL cnt = 0;
	RBF(i, a) {
		LL tmp = ceil(static_cast<double>(i) / x) - 1;
		cnt += tmp;
	}
	if (cnt > k) {
		ans = false;
	}
	else {
		ans = true;
	}

	return ans;
}
// 範囲[a, b]の連続する整数のなかで，judge(x)=trueとなる最小のxを二分探索で求める
template<typename T> T bin_search_min(T a, T b) {
	if (a > b) {
		return bin_search_min(b, a);
	}

	T x = (b - a) / 2 + (b - a) % 2 + a;
	T d = max(static_cast<T>(1), (b - a) / 2 + (b - a) % 2);
	T cnt = 0;
	T lim = log2(b - a) + 10;

	while (cnt < lim) {
		d = d / 2 + d % 2;
		if (judge(x)) {
			x -= d;
		}
		else {
			x += d;
		}
		cnt++;
	}

	if (x < a) {
		x = a;
	}
	//while(!judge(x) && x <= b) {
	//	x++;
	//}
	if (!judge(x)) {
		x++;
	}

	// x > bならjudge(x)=trueとなるxが存在しなかったことを意味する
	return x;
}

signed main() {
	cin >> n >> k;
	a = V<LL>(n);
	LL b = 0;
	REP(i, n) {
		LL tmp;
		cin >> tmp;
		a[i] = tmp;
		b = max(b, tmp);
	}

	LL ans = bin_search_min(1ll, b);
	col(ans);
	return 0;
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;

int main()
{
  int n;
  cin >> n;
  string s = "MARCH";
  ll c[5] = {0};
  REP(i, n)
  {
    string tmp;
    cin >> tmp;
    REP(j, 5)
    {
      if (tmp[0] == s[j])
      {
        c[j]++;
      }
    }
  }

  ll anser = 0;
  REP(i, 3)
  {
    FOR(j, i + 1, 4)
    {
      FOR(k, j + 1, 5)
      {
        anser += c[i] * c[j] * c[k];
      }
    }
  }

  cout << anser << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
const long long INF = 2e18;
int main() {
	int N, W;
	cin >> N >> W;
	vector<long long> w(N + 1);
	vector<long long> v(N + 1); 
	for (int i = 1; i <= N; i++) {
		cin >> w[i] >> v[i];
	}
	vector<vector<long long> > dp(N + 1, vector<long long>(W + 1, -INF));
	// long long dp[N + 1][W + 1];
	// for (int i = 0; i <= N; i++) {
	// 	for (int j = 0; j <= W; j++) {
	// 		dp[i][j] = -INF;
	// 	}
	// }
	dp[0][0] = 0;
	for (int i = 1; i <= N; i++) {
		for (int j = 0; j <= W; j++) {
			if (j - w[i] < 0) {
				dp[i][j] = dp[i - 1][j];
			} else {
				dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i]] + v[i]);
			}
		}
	}
	long long ans = 0;
	for (int j = 0; j <= W; j++) {
		ans = max(ans, dp[N][j]);
	} 
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 80256
fun main(args: Array<String>) {
    var (n, k) = readLine()!!.split(" ").map { it.toInt() }
    val s = readLine()!!.toString()
    k--
    for (i in 0 until n) {
        print(
            if (i != k) s[i]
            else s[i].toLowerCase()
        )
    }
}


Measured memory_bytes: 37872
// in the name of Allah

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

#define endl '\n'
#define pb push_back
#define ll long long
#define double long double
#define sz(x) ((int) (x.size()))

#define max_n 7654321
#define mod 1000000007
#define inf ((int) (1e9+7))

#define PI acos(-1.0)
#define eps 1e-9

int main() {
	ios::sync_with_stdio(0); cin.tie(); cout.tie(0);
	string s;
	cin >> s;
	int mn = 1e9;
	for(int i=2; i<sz(s); i++) {
		int x = 100 * (s[i-2] - '0') + 10 * (s[i-1] - '0') + (s[i] - '0');
		mn = min(mn, abs(753 - x));
	}
	cout << mn << endl;
	return 0;
}

Measured memory_bytes: 256
/*
　　　∫ ∫ ∫
　　　ノヽ
　　（＿　 ）
　（＿　　　 ）
（＿＿＿＿＿＿ ）
　ヽ(´･ω･)ﾉ　
　　 |　 /
　　 UU
*/
#pragma region macro
#include <bits/stdc++.h>
typedef long long int64;
using namespace std;
using P = pair<int64, int64>;
typedef vector<int> vi;
const int MOD = (int)1e9 + 7;
const int64 INF = 1LL << 62;
const int inf = 1<<30;
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; }
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = s; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end() //コンテナじゃないと使えない!!
#define debug(x) cerr << #x << ": " << x << "\n";
#define mp make_pair
#define bn '\n'
template <typename T>
ostream& operator<<(ostream& os, vector<T> &V){
    int N = V.size();
    REP(i,N){
        os << V[i];
        if (i!=N-1) os << " ";
    }
    os << "\n";
    return os;
}
template <typename T,typename S>
ostream& operator<<(ostream& os, pair<T,S> const&P){
    os << "(";
    os << P.first;
    os << " , ";
    os << P.second;
    os << ")";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T> &S){
    auto it=S.begin();
    while(it!=S.end()){
        os << *it;
        os << " ";
        it++;
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, deque<T> &q){
    for(auto it=q.begin();it<q.end();it++){
        os<<*it;
        os<<" ";
    }
     os<<endl;
    return os;
}
vector<pair<int,int>> dxdy = {mp(0,1),mp(1,0),mp(-1,0),mp(0,-1)};
#pragma endregion
//fixed<<setprecision(10)<<ans<<endl;



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vi A(N);
    REP(i,N) cin >> A[i];

    vi L(N+1,0);
    REP(i,N){
        int a = A[i];
        L[a] = L[a-1] + 1;
    }
    int ans = N - *max_element(ALL(L));
    cout << ans << bn;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <iostream>
#include <list>
#include <functional>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
using namespace std;

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	int a, b;
	scanf("%d %d", &a, &b);
	int ok = 1;
	if (a > 8 || b > 8)ok = 0;
	if (ok == 1)printf("Yay!");
	else printf(":(");
}

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define MOD 1000000007

using namespace std;

typedef long long ll;

int countCharKind(string s)
{
    int count = 0;
    char charVec[10] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'};
    bool countBool[10] = {false};
    for (int i = 0; i < s.size(); ++i)
    {
        for (int j = 0; j < 10; ++j)
        {
            if (s[i] == charVec[j]){
                if (!countBool[j])
                {
                    countBool[j] = true;
                    count++;
                }
            }
        }
    }

    return count;
}

int main()
{
    int N;
    cin >> N;
    string addChar[10] = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j"};
    vector<string> s[N + 1];
    s[1].push_back("a");
    for (int i = 2; i <= N; ++i)
    {
        int size = s[i -1].size();
        for (int j = 0; j < size; ++j)
        {
            int count = countCharKind(s[i - 1][j]);
            for (int k = 0; k < count + 1; ++k)
            {
                s[i].push_back(s[i - 1][j] + addChar[k]);
            }
        }
    }

    int ansSize = s[N].size();
    REP(i, ansSize)
    {
        cout << s[N][i] << endl;
    }
}


Measured memory_bytes: 9588
def cmb(n, k, mod, fac, ifac):
    """
    nCkを計算する
    """
    k = min(k, n-k)
    return fac[n] * ifac[k] * ifac[n-k] % mod


def make_tables(mod, n):
    """
    階乗テーブル、逆元の階乗テーブルを作成する
    """
    fac = [1, 1] # 階乗テーブル・・・(1)
    ifac = [1, 1] #逆元の階乗テーブル・・・(2)
    inverse = [0, 1] #逆元テーブル・・・(3)

    for i in range(2, n+1):
        fac.append((fac[-1] * i) % mod)
        inverse.append((-inverse[mod % i] * (mod//i)) % mod)
        ifac.append((ifac[-1] * inverse[-1]) % mod)
    return fac, ifac

p = 10 ** 9 + 7

S=int(input())
ans=0
for n in range(1,S//3+1):
    fac,ifac=make_tables(p,S-2*n-1)
    ans +=cmb(S-2*n-1,n-1,p,fac,ifac)
    ans %=p
print(ans)

Measured memory_bytes: 73784
#include<bits/stdc++.h>
using namespace std;
int arr[100010];
int cost[100010];
int main()
{int n,i;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&arr[i]);	
	}
		cost[n-1]=0;
		cost[n-2]=abs(arr[n-2]-arr[n-1]);
       for(i=n-3;i>=0;i--)
       {
	       int a=cost[i+1]+abs(arr[i]-arr[i+1]);
	       int b=cost[i+2]+abs(arr[i]-arr[i+2]);
	       
	       if(a<b)
		       cost[i]=a;
	       else
  			cost[i]=b;

       }
		
printf("%d\n",cost[0]);
}


Measured memory_bytes: 1024
from collections import deque
import sys

def solve(n, target):
    """ 0-9?????§?????°???n???????¶?????????¨??§???target??????????????????????????? """
    if n <= 1:
        if 0 <= target <=9:
            Q.append(target)
            return target
        else:
            return None
    else:
        for i in range(10):
            res = solve(n - 1, target - i)


Q = deque()
if __name__ == '__main__':
    # ??????????????\???
    for line in sys.stdin:
        target = int(line)

        result = solve(4, target)
        print(len(Q))
        Q.clear()

Measured memory_bytes: 7908
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e9+7;
signed main(){
    ll d;cin>>d;
    vector<ll>c(26);
    rep(i,26)cin>>c[i];
    vector<vector<ll> >s(d,vector<ll>(26));
    rep(i,d){
        rep(j,26)cin>>s[i][j];
    }
    vector<ll>last(26);
    vector<ll>v(d);
    ll ans=0;
    rep(i,d){
        ll ma=-inf*inf;
        ll idx=0;
        rep(t,26){
            ll cn=0;
            cn+=s[i][t];
            cn+=6*c[t]*(d-last[t]+1);
            if(cn>ma){
                ma=cn;
                idx=t;
            }
        }
        last[idx]=i+1;
        v[i]=idx+1;
    }
    rep(i,d){
        cout<<v[i]<<endl;
    }
}

Measured memory_bytes: 3732
#include <stdio.h>
int main() {
    while (true) {
        int a, b, result;
        char op;
        scanf("%d %c %d", &a, &op, &b);
        if (op == '?') break;
        if (op == '+') result = a + b;
        if (op == '-') result = a - b;
        if (op == '*') result = a * b;
        if (op == '/') result = a / b;
        printf("%d\n", result);

    }
}


Measured memory_bytes: 2732
#include<stdio.h>
#define N 100000
#define YOSHI 2000000000

struct Card{
    char suit;
    int value;
};

struct Card R[N / 2 + 2],L[N / 2 + 2];

void merge(struct Card A[],int n,int left,int mid,int right){
    int i,j,k;
    int n1 = mid - left;
    int n2 = right - mid;
    
    for(i = 0;i < n1;i++){
        L[i] = A[left + i];
    }
    for(i = 0;i < n2;i++){
        R[i] = A[mid + i];
    }
    
    L[n1].value = R[n2].value = YOSHI;
    i = 0;
    j = 0;
    
    for(k = left;k < right;k++){
        if(L[i].value <= R[j].value){
            A[k] = L[i++];
        }
        else{
            A[k] = R[j++];
        }
    }
}

void mergeSort(struct Card A[],int n,int left,int right){
    int mid;
    
    if(left + 1 < right){
        mid = (left + right) / 2;
        mergeSort(A,n,left,mid);
        mergeSort(A,n,mid,right);
        merge(A,n,left,mid,right);
    }
}

int partition(struct Card A[],int n,int p,int r){
    int i,j;
    struct Card t,x;
    x = A[r];
    i = p - 1;
    
    for(j = p;j < r;j++){
        if(A[j].value <= x.value){
            i++;
            t = A[i];
            A[i] = A[j];
            A[j] = t;
        }
    }
    t = A[i + 1];
    A[i + 1] = A[r];
    A[r] = t;
    
    return i + 1;
}

void quickSort(struct Card A[],int n,int p,int r){
    int q;
    if(p < r){
        q = partition(A,n,p,r);
        quickSort(A,n,p,q - 1);
        quickSort(A,n,q + 1,r);
    }
}

int main(){
    int n,i,v;
    struct Card A[N],B[N];
    char S[10];
    int stable = 1;
    
    scanf("%d",&n);
    
    for(i = 0;i < n;i++){
        scanf("%s %d",S,&v);
        A[i].suit = B[i].suit = S[0];
        A[i].value = B[i].value = v;
    }
    
    mergeSort(A,n,0,n);
    quickSort(B,n,0,n - 1);
    
    for(i = 0;i < n;i++){
        if(A[i].suit != B[i].suit) stable = 0;
    }
    
    if(stable == 1) printf("Stable\n");
    else printf("Not stable\n");
    for(i = 0;i < n;i++){
        printf("%c %d\n",B[i].suit,B[i].value);
    }
    
    return 0;
}



Measured memory_bytes: 4016
#include<iostream>
#include<string>
using namespace std;
int main(){
    int A,B;
    string S;
    bool ans=true;
    cin >> A >> B;
    cin >> S;
    for(int i=0;i<S.length();i++){
        if((i!=A && S[i] == '-') || (i==A && S[i] != '-')){
            ans = false;
            break;
        }
    }
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256