akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

int N, C;
vector<int> s, t, c;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> C;
  s.resize(N);
  t.resize(N);
  c.resize(N);
  map<int, vector<pair<int, int>>> mp;
  for (int i = 0; i < N; i++) {
    cin >> s[i] >> t[i] >> c[i];
    mp[c[i]].push_back(make_pair(s[i], t[i]));
  }

  vector<int> cum(200001, 0);
  for (auto &e : mp) {
    sort(e.second.begin(), e.second.end());
    int i = 0;
    while (i < e.second.size()) {
      int first = e.second[i].first;
      int cur = e.second[i].second;
      while (i + 1 < e.second.size() && cur == e.second[i + 1].first) {
        i++;
        cur = e.second[i].second;
      }
      cum[2 * first - 1]++;
      cum[2 * cur]--;
      i++;
    }
  }
  int ans = 0;
  int cur = 0;
  for (int i = 0; i < 200001; i++) {
    cur += cum[i];
    ans = max(ans, cur);
  }

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

Measured memory_bytes: 3584
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>

using namespace std;

int main(){

  string s;
  cin >> s;

  cout << s[0] << s.size()-2 << s[s.size()-1] << endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	// ２点間の距離
	public static double getDistance (double x1, double y1, double x2, double y2) {
		return Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
	}

	public static int solve (double xa, double ya, double ra, double xb, double yb, double rb) {
		double largeR = Math.max(ra, rb);
		double smallR = Math.min(ra, rb);
		double d = getDistance(xa,ya,xb,yb);
		if (d < largeR - smallR)
			return smallR == ra ? -2 : 2;
		return largeR + smallR < d ? 0 : 1;
	}

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		for (int i = 0; i < n; i++) {
			double xa = sc.nextDouble();
			double ya = sc.nextDouble();
			double ra = sc.nextDouble();
			double xb = sc.nextDouble();
			double yb = sc.nextDouble();
			double rb = sc.nextDouble();
			System.out.println(solve(xa,ya,ra,xb,yb,rb));
		}

	}

}

Measured memory_bytes: 20476
use std::collections::HashMap;

fn get_line() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn main() {
    let (n, m) =  {
        let nm = get_line().split_whitespace()
            .map(|e| e.parse().unwrap())
            .collect::<Vec<i64>>();
        (nm[0], nm[1])
    };

    let heights = get_line().split_whitespace()
        .map(|e| e.parse().unwrap())
        .collect::<Vec<i64>>();

    let mut map: HashMap<usize, Vec<usize>> = HashMap::new();
    for i in 1..n + 1 {
        map.insert(i as usize, Vec::new());
    }

    for _ in 0..m {
        let (a, b) =  {
            let ab = get_line().split_whitespace()
                .map(|e| e.parse().unwrap())
                .collect::<Vec<usize>>();
            (ab[0], ab[1])
        };
        map.get_mut(&a).unwrap().push(b);
        map.get_mut(&b).unwrap().push(a);
    }

    let mut count = 0;
    for (key, v) in &map {
        let is_good = v.iter()
            .all(|x| heights[key - 1] > heights[x - 1]);
        if is_good { count += 1; }
    }

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


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

using namespace std;

typedef long long ll;

const int MAXN = 100000;
const ll MOD = 1000000007;

ll cntA[MAXN+1], cntB[MAXN+1], cntC[MAXN+1], cntQ[MAXN+1];

// 二分累乗法により、x^n %mod を求める
ll mod_pow(ll x, ll n){
  if (n == 0) return 1;
  ll res = mod_pow(x * x %MOD, n / 2);
  // nが奇数の場合, x^n = ((x^2)^(n/2)) * x
  if(n & 1) return res = res * x %MOD;
  // nが偶数の場合、x^n = (x^2)^(n/2)
  return res %MOD;
}

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  string s; cin >> s;
  int size = s.size();
  for(int i=0;i<size;i++){
    cntA[i+1] = cntA[i];
    cntB[i+1] = cntB[i];
    cntC[i+1] = cntC[i];
    cntQ[i+1] = cntQ[i];
    if(s[i] == 'A'){
      cntA[i+1] = cntA[i] + 1;
    }else if(s[i] == 'B'){
      cntB[i+1] = cntB[i] + 1;
    }else if(s[i] == 'C'){
      cntC[i+1] = cntC[i] + 1;
    }else{
      cntQ[i+1] = cntQ[i] + 1;
    }
  }
  ll ans = 0;
  for(int i=1;i<=size;i++){
    if(s[i-1] == 'B' || s[i-1] == '?'){
      ll leftA = cntA[i-1];
      ll leftQ = cntQ[i-1];
      ll rightC = cntC[size] - cntC[i];
      ll rightQ = cntQ[size] - cntQ[i];
      //cout << leftA << " " << leftQ << " " << rightC << " " << rightQ << endl;
      ans += ((leftA * rightC) %MOD) * mod_pow(3, (leftQ + rightQ));
      ans %= MOD;
      ans += ((leftA * rightQ) %MOD) * mod_pow(3, (leftQ + rightQ - 1));
      ans %= MOD;
      ans += ((leftQ * rightC) %MOD) * mod_pow(3, (leftQ + rightQ - 1));
      ans %= MOD;
      ans += ((leftQ * rightQ) %MOD) * mod_pow(3, (leftQ + rightQ - 2));
      ans %= MOD;
      // cout << ans << endl;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3664
from itertools import combinations
from collections import defaultdict
n=int(input())
S=tuple(input().strip() for _ in range(n))
d=defaultdict(int)
A=('M','A','R','C','H')
for i in range(n):
    tmp=S[i][0]
    if tmp in A:
        d[tmp]+=1
B=[]
for a in A:
    if d[a]:
        B.append(a)
if len(B)<3:
    print(0)
else:
    ans=0
    for i in combinations(B,3):
        tmp=1
        for j in range(3):
            tmp*=d[i[j]]
        ans+=tmp
    print(ans)

Measured memory_bytes: 10220
N,M = map(int,input().split())
A = sorted(list(map(int,input().split())),reverse = True)
while M > 0:
    A[0] //= 2
    for i in range(1,M):
        if i < N and A[i] >= A[0]:
            A[i] //= 2
        else:
            M -= i
            A.sort(reverse = True)
            break
    else:
        break
print(sum(A))


Measured memory_bytes: 14252
import sys
input = sys.stdin.readline
from collections import deque

def main():
    h,w=map(int,input().split())
    s=[list(input()) for _ in range(h)]
    dp=[[0]*w for _ in range(h)]
    for j in range(w):
        for i in range(h):
            if s[i][j]=='#':
                continue
            else:
                if j==0:
                    if i==0:
                        dp[i][j]=1
                    else:
                        dp[i][j]=dp[i-1][j]%(10**9+7)
                elif i==0:
                    dp[i][j]=dp[i][j-1]%(10**9+7)
                else:
                    dp[i][j]=(dp[i-1][j]+dp[i][j-1])%(10**9+7)
    print(dp[h-1][w-1])

if __name__ == '__main__':
    main()

Measured memory_bytes: 51808
#include <iostream>
#include <cstdio>
#include <cstring>
#include <climits>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <sstream>
#include <numeric>
#include <iomanip>
// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>

///////////////////////////////////////////////////////////////
// namespace
///////////////////////////////////////////////////////////////
using namespace std;
// namespace mp = boost::multiprecision;

///////////////////////////////////////////////////////////////
// types
///////////////////////////////////////////////////////////////
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
// using mpi = mp::cpp_int;
// using mpf = mp::number<mp::cpp_dec_float<1024>>;

/////////////////////////////////////////////////////////////////
// https://github.com/atcoder-live/library/blob/master/mint.cpp
/////////////////////////////////////////////////////////////////
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


int main() {
    string s; cin >> s;
    for (char &c: s) {
        if (c == '?') c = 'D';
    }
    cout << s << endl;
    // cout << setprecision(10);
    return 0;
}


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

namespace ProblemB
{
    class Program
    {
        static void Main(string[] args)
        {
            var T = Console.ReadLine().ToArray();

            for(int i = 0; i < T.Length; i++)
            {
                if(T[i] == '?')
                {
                    T[i] = 'D';
                }
            }
            foreach (var s in T)
            {
                Console.Write(s);
            }
            Console.WriteLine();

        }
    }
}


Measured memory_bytes: 27612
#include <iostream>

using namespace std;

const int MOD = 1000000007;
const int MAX = 1100000;

long long fac[MAX], finv[MAX], inv[MAX];

void comInit() {
	fac[0] = fac[1] = inv[1] = finv[0] = finv[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;
	}
}

long long nCr(int n, int r) {
	if (n < r || n < 0 || r < 0) return 0;
	return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

int main() {
	comInit();
	long long n, k; cin >> n >> k;
	long long ans = (1 + n * (n - 1)) % MOD;
	for (int i = 2; i <= min(n - 1, k); ++i) {
		(ans += nCr(n + (n - i - 1) - (n - i), n - i - 1) * nCr(n, i) % MOD) %= MOD;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 25984
#include <bits/stdc++.h>
using namespace std;
const int N = 100005;

int n;
char a[N];

int ans[N];

int main()
{
    cin >> a;
    n = strlen(a);
    int u;
    for (int i = n - 1; i >= 0; --i)
    {
        if (a[i] == 'R')
        {
            if (a[i + 1] != 'R')
            {
                u = i;
            }
            if ((u - i) % 2 == 0)
            {
                ans[u]++;
            }
            else
            {
                ans[u + 1]++;
            }
        }
    }
    for (int i = 0; i < n; ++i)
    {
        if (a[i] == 'L')
        {
            if (a[i - 1] != 'L')
            {
                u = i;
            }
            if ((i - u) % 2 == 0)
            {
                ans[u]++;
            }
            else
            {
                ans[u - 1]++;
            }
        }
    }
    for (int i = 0; i < n; ++i)
        cout << ans[i] << ' ';
    cout << endl;
    return 0;
}


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

public class Main {
  Scanner sc;

  boolean[][] done;
  char[][] field;

  int[][] ofs = new int[][] { { 0, 1 }, { 1, 0 }, { -1, 0 }, { 0, -1 } };

  int dfs(int x, int y) {
    if ( done[ y ][ x ] || field[ y ][ x ] == '#' )
      return 0;

    int sum = 1;
    done[ y ][ x ] = true;
    for ( int[] d : ofs ) {
      sum += dfs( x + d[ 0 ], y + d[ 1 ] );
    }

    return sum;
  }

  void run() {
    for ( ;; ) {
      int w, h;
      w = ni();
      h = ni();

      if ( ( w | h ) == 0 ) {
        break;
      }

      done = new boolean[h + 2][w + 2];
      field = new char[h + 2][w + 2];

      for ( int i = 0; i < h + 2; ++i ) {
        for ( int j = 0; j < w + 2; ++j ) {
          field[ i ][ j ] = '#';
        }
      }

      int sx = 0;
      int sy = 0;
      for ( int i = 1; i <= h; ++i ) {
        char[] str = ns().toCharArray();
        for ( int j = 1; j <= w; ++j ) {
          field[ i ][ j ] = str[ j - 1 ];
          if ( field[ i ][ j ] == '@' ) {
            sx = j;
            sy = i;
          }
        }
      }

      System.out.println( dfs( sx, sy ) );
    }
  }

  Main() {
    sc = new Scanner( System.in );
  }

  int ni() {
    return sc.nextInt();
  }

  String ns() {
    return sc.next();
  }

  public static void main(String[] args) {
    new Main().run();
  }

  void debug(Object... os) {
    System.err.println( Arrays.deepToString( os ) );
  }
}

Measured memory_bytes: 29184
#include<stdio.h>

int main (void)
{
    char s[4];
    scanf("%s",s);
    
    int j =1;

    for (j=1;j<4;)
    {
        if (s[j]==s[j-1])
        {   
            printf("Bad");
            break;
        }
        else 
        {
            j++;
        }
    }
    if (j==4)
        printf("Good");
    return 0;
}


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

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
 
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int > vi;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<pii> vpii;
 
#define ALL(x) (x).begin(), (x).end()
#define RESET(x) memset((x), 0, sizeof (x))
#define FOR(i, b, e) for ( int i = (b); i < (e); ++i)
#define RE(i, n) FOR(i, 0, (n))
#define FOREACH(i, x, y) for ( int i = (x); i <= (y); ++i)
#define two(X) (1<<(X))//NOTES:two(
#define contain(S,X) (((S)&two(X))!=0)//NOTES:contain(
#define chkmin(X, Y) (X) = min((X), (Y))
#define chkmax(X, Y) (X) = max((X), (Y))
#define sqr(X) ((X) * (X))
 
const ll maxn = (ll) 2e5 + 100;
const ll maxm = (ll) 1e6;
const int LOGN = 22;
const ll INF = 1e15+ 10;
const ll MOD = 1e9 + 7;
const double PI = acos(-1.0);
const double EPS = 1e-12;

int pre[maxn];
int FindPre(int x) {
    if (pre[x] != x) {
        pre[x] = FindPre(pre[x]);
    }
    return pre[x];
}
void UnionPre(int x, int y) {
    x = FindPre(x);
    y = FindPre(y);
    if (x != y)
        pre[y] = x;
}


int main() {
#ifndef ONLINE_JUDGE
  //  freopen("in.txt", "r", stdin);
#endif

    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int n, m;
    while (cin >> n >> m) {
        FOREACH(i, 1, n) pre[i] = i;
        vi a(n + 1);
        RE(i, n) cin >> a[i + 1];
        RE(i, m) {
            int x, y;
            cin >> x >> y;
            UnionPre(x, y);
        }
        int ans = 0;
        FOREACH(i, 1, n) {
            int x = a[i];
            ans += (FindPre(x) == FindPre(i));
        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <stack>

using namespace std;

#define INF 1010001000
#define EPS 1e-10
#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

typedef pair<int, int> i_i;
typedef long long int llong;
typedef pair<llong, llong> ll_ll;
typedef struct edge {int f, t;}Edge;


int main()
{
    int n;
    while (cin >> n, n) {
        int ans = INF;
        for (int i = 0; i*i*i <= n; i++) {
            for (int j = 0; i*i*i + j*j <= n; j++) {
                int k = n - (i*i*i + j*j);
                ans = min(ans, i+j+k);
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 2996
#include <stdlib.h>
#include <stdio.h>
int compare(const void *a,const void *b){
    if(*(long *)a>*(long *)b)return -1;
    return 1;
}
int main()
{   
    long n,h;
    scanf("%ld%ld",&n,&h);
    long a[n],b[n];
    for(int i=0;i<n;i++){
        scanf("%ld%ld",&a[i],&b[i]);
    }
    qsort(a,n,sizeof(long),compare);
    qsort(b,n,sizeof(long),compare);
    
    
    long ans=0,i=0;
    while(h>0){
        
        if(a[0]>b[i]||i==n){
            if(h%a[0]==0){
            ans+=h/a[0];}
            else{
                ans+=h/a[0]+1;
            }
            break;
        }else{
            h-=b[i];
            i++;
            ans++;
        }
    }
    printf("%ld",ans);

    return 0;
}


Measured memory_bytes: 2556
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();

		String str[] = new String[a];
		for (int i = 0; i < b + 2; i++) {
			System.out.print("#");
		}

		System.out.println();

		for (int i = 0; i < a; i++) {
			str[i] = sc.next();
			System.out.println("#" + str[i] + "#");
		}

		for (int i = 0; i < b + 2; i++) {
			System.out.print("#");
		}

		System.out.println();

	}
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
#define all(c) c.begin(),c.end()
#define init(c) memset(c,0,sizeof c)
#define S second
#define F first
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int N=20000005;
int n,k,x,t,a,b,m;
string s;
vi v;

void solve(){
	cin >> a >>b;
	cout << a*b;
}

int main(){

	int t= 1;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define int long long
int ncr(int n){
int mul = n*(n-1);
mul = mul/2;
return mul;
}

main(){
int n,x,k = 0,sum = 0;
cin>>n;
int A[n+1],B[n+1],C[n+1];
for(int i=0;i<=n;i++){
    A[i] = 0;
}
for(int i = 1;i<=n;i++){
    cin>>x;
    B[i] = x;
    A[x]++;
}
for(int i=1;i<=n;i++){
    sum += ncr(A[i]);
}
for(int i=1;i<=n;i++){
    k = B[i];
    x = A[k] - 1;
    C[i] = sum - x;
}
for(int i=1;i<=n;i++){
    cout<<C[i]<<endl;
}
}


Measured memory_bytes: 7296
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1000000007
typedef long long ll;
const int INF32 = 2147483647;
const ll INF64  = 9223372036854775807;
using namespace std;
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;
}

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

    int N, K;
    cin >> N >> K;

    int ans = N - K + 1;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

#define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
#define fb(i,a,b) for(int (i) = (a); (i) >= (b); --(i))
#define mod 998244353
#define xx first
#define yy second
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define maxn 100005

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;/// find_by_order(x)(x+1th) , order_of_key() (strictly less)
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());



ll p[maxn];
ll q[maxn];
ll r[maxn];
int x,y,a,b,c;
bool cmp(ll n, ll m){
    return n > m;
}
ll f[2 * maxn];
vector<ll>pom;
int main()
{

    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> x >> y >> a >> b >> c;
    ff(i,0,a - 1)cin >> p[i];
    ff(i,0,b - 1)cin >> q[i];
    ff(i,0,c - 1)cin >> r[i];
    sort(p,p+a,cmp); sort(q,q+b,cmp); sort(r,r+c,cmp);
    int levi = 0;
    int desni = 0;
    a = x;
    b = y;
    while( (levi < a) || (desni < b)){
        if(desni == b || (levi<a && p[levi] > q[desni])){
            pom.pb(p[levi]);
            levi++;
        }
        else pom.pb(q[desni++]);
    }
    ll sum = 0;
    ff(i,0,pom.size() - 1){
        sum += pom[i];
        f[i + 1] = sum;
    }
    //ff(i,0,4)cout << f[i] << " ";
    //cout << endl;
    ll res = 0;
    ll trsum = 0;
    res = max(res, f[a + b]);
    ff(i,0,c - 1){
        trsum += r[i];
        if(i+1 > x+y)break;
        res = max(trsum + f[x + y - i - 1], res);
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 5616
#include <stdio.h>
#include <iostream>
#include <cstdio>
#include <algorithm> 
#include <stdio.h>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <list>
#include <utility>
#include <set>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <bitset>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <random>

using namespace std;

static const double EPS = 1e-9;
template<class T> bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
template<class T> void amin(T &a, T v) { if (a > v) a = v; }
template<class T> void amax(T &a, T v) { if (a < v) a = v; }
int ROUND(double x) { return (int)(x + 0.5); }
bool ISINT(double x) { return fabs(ROUND(x) - x) <= EPS; }
bool ISEQUAL(double x, double y) { return fabs(x - y) <= EPS * max(1.0, max(fabs(x), fabs(y))); }
double SQSUM(double x, double y) { return x * x + y * y; }
#define PI  (acos(-1))
#define ARRAY_NUM(a) (sizeof(a)/sizeof(a[0])) 
#define NG (-1)
#define BIG ((int)1e9+10)
#define BIGLL ((ll)4e18)
#define SZ(a) ((int)(a).size())
#define SQ(a) ((a)*(a))
typedef unsigned long long ull;
typedef long long ll;

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

	vector <ll> a(n);
	vector <ll> b(n);

	vector <int> e(n);
	for (int i = 0; i < n-1; ++i)
	{
		cin >> a[i] >> b[i];
		a[i]--;
		b[i]--;
		e[a[i]]++;
		e[b[i]]++;
	}

	vector <ll> c;
	for (int i = 0; i<n; ++i)
	{
		ll tmp;
		cin >> tmp;
		c.push_back(tmp);
	}

	sort(c.begin(), c.end());

	vector <ll> w(n, NG);

	for (int i = 0; i < n; ++i)
	{
		// 一番次数が小さい頂点。
		vector <int> d(n);

		for (int k = 0; k < n-1; ++k)
		{
			if (w[a[k]]==NG && w[b[k]] == NG)
			{
				d[a[k]]++;
				d[b[k]]++;
			}
		}

		/*
		for (int s=0;s<n;s++)
		{
			// BEGIN CUT HERE
			cerr << " d[s]=" << d[s] << endl;
			// END CUT HERE

		}
		*/

		int bestD = BIG;
		int bestE = BIG;
		int bestID = NG;

		for (int k = 0; k < n; ++k)
		{
			if (w[k] != NG) continue;

			if (d[k] < bestD || d[k]==bestD && e[k] < bestE)
			{
				bestD = d[k];
				bestE = e[k];
				bestID = k;
			}
		}

		w[bestID] = c[i];

		/*
		// BEGIN CUT HERE
		cerr << " bestD=" << bestD << " bestE=" << bestE << " bestID=" << bestID << endl;
		// END CUT HERE
		*/

	}

	ll sum = 0;
	for (int i = 0; i < n - 1; ++i)
	{
		sum += min(w[a[i]], w[b[i]]);
	}

	cout << sum << endl;
	for (int i = 0; i < n; ++i)
	{
		if (i > 0) printf(" ");
		printf("%lld", w[i]);
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 768
#include <stdio.h>

int main() {
	int n, a[10001], i;
	int min, max;
	long long sum = 0;
	scanf("%d", &n);
	for (i = 0; i<n; i++) {
		scanf("%d", &a[i]);
	}
	min = a[0];
	max = a[0];
	for (i = 0; i<n; i++) {
		if (min>a[i])min = a[i];
		if (max<a[i])max = a[i];
		sum += a[i];
	}
	printf("%d %d %ld\n", min, max, sum);
	return 0;
}

Measured memory_bytes: 2780
#include<bits/stdc++.h>
using namespace std;
int main(){
int N; cin>>N;
  vector <int> A(N);
  for(int i=0;i<N;i++){
  cin>>A.at(i);
  }
  string ans="APPROVED";
  for(int i=0;i<N;i++){
  if(A.at(i)%2==0 && A.at(i)%3!=0 && A.at(i)%5!=0){
   ans="DENIED"; break;
  
  }
  
  
 }cout<<ans<<endl;
 
  return 0;
}

Measured memory_bytes: 256
from collections import deque

K = int(input())

q = deque([1,2,3,4,5,6,7,8,9])

cnt = 1

while cnt < K:
    c = q.popleft()
    if c % 10 != 0:
        q.append(c * 10 + c % 10 - 1)
    q.append(c * 10 + c % 10)
    if c % 10 != 9:
        q.append(c * 10 + c % 10 + 1)
    cnt += 1

print(q.popleft())

Measured memory_bytes: 11908
#include<bits/stdc++.h>
using namespace std; 
 
#define FAST_I0 ios_base::sync_with_stdio(false); cin.tie(NULL); 
#define endl "\n"
#define int long long 
#define vvi vector<int>
#define pb push_back

void think(){
	int x;
	cin >> x;
	cout << !x << endl;
}

int32_t main(){
	FAST_I0; 
	int testcase = 1; 
//	cin >> testcase;
	while(testcase--){
		think();
		}
	return 0;	

}


Measured memory_bytes: 3644
import math

a, b, h, m = map(int, input().split())


H_kakudo = (30 * h) + (m * 0.5)
M_kakudo = 6 * m
kakudo = abs(H_kakudo - M_kakudo)
if kakudo > 180:
    kakudo = 360 - kakudo

result = (a ** 2) + (b ** 2) - (2 * a * b * math.cos(math.radians(kakudo)))

print(math.sqrt(result))


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

using namespace std;
#define int64 long long

const int N_MAX = 200010;

string S;
int dp[N_MAX][2];
int n;

void outerInit() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	auto fi = new ifstream("test.inp");
	if (*fi) {
		cin.rdbuf(fi->rdbuf());
	}
}

void readData() {
	cin >> S;
	n = S.size();
	S = "$" + S;
}

void solveData() {
	for (int i = 1; i <= n; ++i) {
		if (S[i] != S[i - 1]) {
			dp[i][0] = max(dp[i - 1][0], dp[i - 1][1]) + 1;
		}
		else {
			dp[i][0] = dp[i - 1][1] + 1;
		}

		if (i > 1) {
			dp[i][1] = dp[i - 2][0] + 1;
			if (i > 3 && (S[i] != S[i - 2] || S[i - 1] != S[i - 3])) {
				dp[i][1] = max(dp[i][1], dp[i - 2][1] + 1);
			}
		}
	}

	cout << max(dp[n][0], dp[n][1]) << "\n";
}

int main() {
	outerInit();

	readData();
	solveData();
}

Measured memory_bytes: 2128
import numpy as np
import statistics

N = int(input())
A = [int(i) for i in input().split()]

A_minus_i = [A[i] - (i+1) for i in range(N)]

# print(A)
# print(A_minus_i)

bf = statistics.median(A_minus_i)
# print(bf)

# b_l = int(bf)+1
# b_m = int(bf)
# b_s = int(bf)-1
#
# score_l = sum([abs(a - b_l) for a in A_minus_i])
# score_m = sum([abs(a - b_m) for a in A_minus_i])
# score_s = sum([abs(a - b_s) for a in A_minus_i])

score = sum([abs(a - bf) for a in A_minus_i])

print(int(score))


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

#define maxn
#define FOR(i, l, r) for (int i=l; i<=r; ++i)
#define FORD(i, r, l) for (int i=r; i>=l; --i)
#define REP(i, r) for (int i=0; i<(int)r; ++i)
#define REPD(i, r) for (int i=(int)r-1; i>=0; --i)
#define fi first
#define se second
#define mk make_pair
#define nil NULL
#define y0 y902
#define y1 y232
#define x0 x92
#define x1 x899
#define next asdfa
#define sz size
#define Debug(X) {cerr << #X << " = " << X << '\n';}
#define PR(A, n) {cerr << #A << " = "; FOR(i, 1, n) cerr << A[i] << ' '; cerr << '\n';}
#define PR0(A, n) {cerr << #A << " = "; REP(i, n) cerr << A[i] << ' '; cerr << '\n';}
typedef long long ll;
typedef double db;
typedef pair<db, db> dd;
typedef pair<int, int> ii;
typedef vector<int> vi;
const int inf = 1e9;
template<class T> int getbit(T x, int pos) {return (x>>(pos-1)) & 1;}
template<class T> void turn_on(T &x, int pos) {x = x | ((T)1<<(pos-1));}
template<class T> void turn_off(T &x, int pos) {x = x & ~((T)1<<(pos-1));}
template<class T> T sqr(T a) {return a*a;}

int main() {
    //freopen("biscuit.inp", "r", stdin);
    //freopen("", "w", stdout);
    //ios::sync_with_stdio(0); cin.tie(0);
    int n, p;
    bool odd = false;
    scanf("%d%d", &n, &p);
    FOR(i, 1, n) {
        int x; scanf("%d", &x);
        if (x%2) odd = true;
    }
    if (!odd) printf("%lld", p==1 ? 0 : 1LL<<(n));
    else printf("%lld", 1LL<<(n-1));
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<utility>
using namespace std;
int main () {
  int N;
  cin >> N;
  vector<pair<int, int>>ro(N);
  for (int i = 0; i < N; i ++) {
    int a, b;
    cin >> a >> b;
    ro[i] = make_pair(a + b, a - b);
  }
  sort(ro.begin(), ro.end());
  vector<bool>use(N);
  int min = -1000000003;
  int ans = 0;
  for (int i = 0; i < N; i ++) {
    if (min <= ro[i].second) {
      ans ++;
      min = ro[i].first;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
N=input()
L=len(N)
ans=[[0 for e in range(2)] for f in range(L)]
ans[0][0]=int(N[L-1])
ans[0][1]=10-int(N[L-1])
if L>1:
 for i in range(1,L):
  ans[i][0]=min(ans[i-1][0]+int(N[L-1-i]),ans[i-1][1]+int(N[L-1-i])+1)
  ans[i][1]=min(ans[i-1][0]+10-int(N[L-1-i]),ans[i-1][1]+10-int(N[L-1-i])-1)
print(min(ans[L-1][0],ans[L-1][1]+1))

Measured memory_bytes: 157348
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t n;
    cin >> n;
    cout << 800*n-(n/15*200) << endl;
}


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

using namespace std;
using ll=long long;
using vi=vector<int>;
using vl=vector<ll>;
using vs=vector<string>;
using li=list<int>;
using lil=list<ll>;
using lis=list<string>;
using fli=forward_list<int>;
using fll=forward_list<ll>;
using fls=forward_list<string>;
using si=stack<int>;
using sl=stack<ll>;
using ss=stack<string>;
using qi=queue<int>;
using ql=queue<ll>;
using qs=queue<string>;
using pqi=priority_queue<int>;
using pql=priority_queue<ll>;
using pqs=priority_queue<string>;
using dqi=deque<int>;
using dql=deque<ll>;
using dqs=deque<string>;

#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, a, n) for(int i = (a); i < (n); i++)
#define repr(i, n) for(int i = (n); i >= 0; i--)
#define repr2(i, a, n) for(int i = (n); i >= (a); i--)

template<typename T,typename U>
void Inparray(T &f,U n){for(int i=0;i<n;i++) cin>>f[i];}

template<typename T,typename U>
void Printarray(T f,U n){for(int i=0;i<n;i++) i!=n ? cout<<f[i]<<" " : cout<<f[i];}
template<typename T,typename U>
void Printarray2(T f,U n){for(int i=0;i<n;i++) cout<<f[i]<<endl;}
template<typename T,typename U,typename V>
void Printarray3(T f,U a,V b){
  rep(i,a){
    rep(j,b){
      cout<<f[i][j];
    }
    cout<<endl;
  }
}
template<typename T,typename U>
void Printarray4(T f,U n){
  rep(i,n){
    rep(j,n){
      cout<<f[i][j];
    }
    cout<<endl;
  }
}

void flagfunc(bool flag,string A,string B){flag ? cout<<A<<endl : cout<<B<<endl;}
void flag2func(bool flag){flag ? cout<<"Yes"<<endl : cout<<"No"<<endl;}
void flag3func(bool flag){flag ? cout<<"YES"<<endl : cout<<"NO"<<endl;}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int n;cin>>n;
  vector<int> x(n);rep(i,n)cin>>x[i];
  int ans=1000000,sum;
  rep2(i,1,100){
    sum=0;
    rep(j,n)sum+=pow(x[j]-i,2);
    if(ans>sum)ans=sum;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

int N, K;
double DP[100001];

int main() {
	cin >> N >> K;
	for (int i = 1; i <= N; ++i) {
		DP[min(i, K)] += 1.0 / N;
	}
	for (int i = 1; i < K; ++i) {
		DP[min(i * 2, K)] += DP[i] / 2;
	}
	printf("%.12f\n", DP[K]);
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
using namespace std;
int main(void){
    // Your code here!
    int a, b;
    string str_A, str_B;
    cin >> a >> b;
    
    for(int i = 0; i < b; i++){
        str_A += to_string(a);
    }
    for(int i = 0; i < a; i++){
        str_B += to_string(b);
    }
    
    if(str_A < str_B){
        cout << str_A << endl;
    }
    else{
        cout << str_B << endl;
    }

}


Measured memory_bytes: 256
n,a,b,c,d = map(int,input().split())
s = input()
if c<d:
  if "##" not in s[a-1:d]:
    print("Yes")
  else:
    print("No")
else:
  if "..." in s[b-2:d]:
    print("Yes")
  else:
    if s[d-2]=="#":
      print("No")
    else:
      print("Yes")

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

int main (){
    string S;
    cin>>S;
    ll N=S.size();
    ll A=0;
    ll B=0;
  	vector<char> AA(N), BB(N);
    for(int i=0; i<N; i++){
        if(i%2){
            AA.at(i)='0';
            BB.at(i)='1';
        }
        else{
            AA.at(i)='1';
            BB.at(i)='0';
        }
    }
    for(int i=0; i<N; i++){
        if(AA.at(i)==S.at(i)){
            A ++;
        }
        if(BB.at(i)==S.at(i)){
            B ++;
        }
    }
    ll C=max(A, B);
    cout<<N-C;
}






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

int main() 
{
#ifdef ONPC
    freopen("input.txt", "r", stdin);
#endif
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);  
  ll n,m,p,l;cin>>n>>m>>p;
  if(m==0)
  {
  while(n--)cout<<p-1<<" ";
  }
  //cout<<min((p/n),(p/m));
  else {
  ll rest=n-m;
  while(m--)cout<<p<<" ";
    if(p==1)l=2;
    else l=p-1;
  while(rest--)cout<<l<<" ";}
 return 0;
}


Measured memory_bytes: 1280
#include<stdio.h>
#include<iostream>
#include<vector>
#include <bits/stdc++.h>
#include <queue>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>

using namespace std;
typedef long long ll;

#define rep(i,n) for(ll i=0; i<(ll)(n); i++)
#define Q 1000000007

ll n,m,k;
// ll ans = 0;
// vector<ll> a(N);
// const int M = 2;
// void dfs(vector<int> &A) {
//     // 終端条件 --- 10 重ループまで回したら処理して打ち切り
//     ll sum = std::accumulate(A.begin(), A.end(), 0LL);
//     if (sum > k) {
//       if(sum.size() > ans){
//         ans = sum.size();
//       }
//       return;
//     }

//     for (int v = 0; v < M; ++v) {
//         A.push_back(v);
//         dfs(A);
//         A.pop_back(); // これが結構ポイント
//     }
// }

bool IsPrime(ll num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (ll i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

int main(){
  
  cin>>n>>m>>k;
  vector<ll> a(n),b(m);
  ll sum = 0;
  rep(i, n){
    cin >> a[i];
  }
  rep(i,m){
    cin >> b[i];
  }

  
  // 累積和を事前に求める
  vector<ll> asum(n+1), bsum(m+1);
  rep(i,n){
    asum[i+1] = asum[i] + a[i];
  }
  rep(i,m){
    bsum[i+1] = bsum[i] + b[i];
  }

  ll i = 0, j = m, ans = 0;
  while(true){
    if(i >= n+1) break;
    if(asum[i] > k){
      break;
    }
    while(true){
      if(j <= 0) break;
      if(bsum[j] <= k - asum[i]){
        break;
      }else{
        j--;
      }
    }
    ans = max(ans, i+j);
    i++;
  }
  
  
  cout << ans << endl;


  return 0;
}

Measured memory_bytes: 9560
#include <bits/stdc++.h>
using namespace std;
 
int main () {
  int64_t H;
  cin >> H;
  int64_t ans = 1;
  while (H > 0) {
    H = floor(H / 2);
    ans *= 2;
  }
  ans--;
  cout << ans << endl;
}

Measured memory_bytes: 3592
#include <stdio.h>
#include <string.h>
int main()
{
    int n=0;
    int t=0;
    int i;
    char s[12];
    int m;
    gets(s);
    m=strlen(s);
    for(i=0;i<m; i++)
    {
        if(s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T')
        {
            t++;
             if(n<t)
                n=t;
        }
        else
        {

            t=0;
        }
    }
    printf("%d",n);
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,a[100010],maxx=0,minn=1e9,sum;
int s;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>s;
		if(s<=n)
		{
		a[s]++;
		maxx=max(maxx,s);
		minn=min(minn,s);
		}
		else sum++;
	}
	for(int i=minn;i<=maxx;i++)
	if(a[i]>i)sum=sum+a[i]-i;
	else if(a[i]<i)sum=sum+a[i];
	cout<<sum;
	return 0;
} 

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			int N = scan.nextInt();
			String[] S = new String[N];
			Map<String, Integer> map = new HashMap<String,Integer>();
			map.put("AC", 0);
			map.put("WA", 0);
			map.put("TLE", 0);
			map.put("RE", 0);
			for(int i = 0;i<N;i++) {
				S[i]= scan.next();
				map.put(S[i], map.get(S[i])+1);
			}
			
			
			System.out.println("AC x "+map.get("AC"));
			System.out.println("WA x "+map.get("WA"));
			System.out.println("TLE x "+map.get("TLE"));
			System.out.println("RE x "+map.get("RE"));

		}	
	}
}


Measured memory_bytes: 63756
from bisect import bisect_left
x, n = map(int, input().split())
if n != 0:
    P = list(map(int, input().split()))
    P = sorted(P)
else:
    P = []

flag = False
ans = []
if x not in P or n == 0:
    ans.append(x)
else:
    idx = bisect_left(P, x)
    for i in range(1, 110):
        for_num = P[idx] + i
        bac_num = P[idx] - i
        if for_num not in P:
            ans.append(for_num)
            flag = True
        if bac_num not in P:
            ans.append(bac_num)
            flag = True
        if flag:
            break

print(min(ans))

Measured memory_bytes: 9148
###############################################################################

from sys import stdout
from bisect import bisect_left as binl
from copy import copy, deepcopy


mod = 1


def intin():
    input_tuple = input().split()
    if len(input_tuple) <= 1:
        return int(input_tuple[0])
    return tuple(map(int, input_tuple))


def intina():
    return [int(i) for i in input().split()]


def intinl(count):
    return [intin() for _ in range(count)]


def modadd(x, y):
    global mod
    return (x + y) % mod


def modmlt(x, y):
    global mod
    return (x * y) % mod


def lcm(x, y):
    while y != 0:
        z = x % y
        x = y
        y = z
    return x


def combination(x, y):
    assert(x >= y)

    if y > x // 2:
        y = x - y

    ret = 1

    for i in range(0, y):
        j = x - i
        i = i + 1

        ret = ret * j
        ret = ret // i

    return ret


def get_divisors(x):
    retlist = []
    for i in range(1, int(x**0.5) + 3):
        if x % i == 0:
            retlist.append(i)
            retlist.append(x // i)
    return retlist


def get_factors(x):
    retlist = []
    for i in range(2, int(x**0.5) + 3):
        while x % i == 0:
            retlist.append(i)
            x = x // i
    retlist.append(x)
    return retlist


def make_linklist(xylist):
    linklist = {}
    for a, b in xylist:
        linklist.setdefault(a, [])
        linklist.setdefault(b, [])
        linklist[a].append(b)
        linklist[b].append(a)
    return linklist


def calc_longest_distance(linklist, v=1):
    distance_list = {}
    distance_count = 0
    distance = 0
    vlist_previous = []
    vlist = [v]
    nodecount = len(linklist)

    while distance_count < nodecount:
        vlist_next = []
        for v in vlist:
            distance_list[v] = distance
            distance_count += 1
            vlist_next.extend(linklist[v])
        distance += 1
        vlist_to_del = vlist_previous
        vlist_previous = vlist
        vlist = list(set(vlist_next) - set(vlist_to_del))

    max_distance = -1
    max_v = None
    for v, distance in distance_list.items():
        if distance > max_distance:
            max_distance = distance
            max_v = v

    return (max_distance, max_v)


def calc_tree_diameter(linklist, v=1):
    _, u = calc_longest_distance(linklist, v)
    distance, _ = calc_longest_distance(linklist, u)
    return distance


###############################################################################


def main():
    n, i = intin()

    print(n - i + 1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3544
import java.util.*;
public class Main {
   public static void main(String[] args) {  
      Scanner sc = new Scanner(System.in);
      String s = sc.next();
      int count = 0;
      for(int i = 0; i < s.length(); i++){
         count = 0;
         for(int j = i; j < s.length(); j++){
            if(s.charAt(i) == s.charAt(j)){
               count++;
            }
            else 
               break;
            if(count == 3){
               System.out.println("Yes");
               System.exit(0);
            }
         }
      }
      System.out.println("No");
   }
}

Measured memory_bytes: 23124
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#include <queue>
#define PIE 3.14159265358979
#define rep(i,n) for(int i = 0;i < (n);i++)
#define MOD 1000000007
using namespace std;
typedef long long ll;
int main(){
    int N,a[21][21];
    cin>>N;
    rep(i,N){
        rep(j,N){
            cin>>a[i][j];
        }
    }
    int twoN = 1<<N;
    ll dp[2][1<<21];
    int now = 0,prev = 1;
    dp[now][0]=1;
    for(int i = 0;i < N;i++){
        now = 1-now,prev = 1-prev;
        for(int bit = 0; bit < twoN; bit++){
            dp[now][bit]=0;
        }
        for(int bit = 0; bit < twoN; bit++){
            if(__builtin_popcount(bit)!=i)
                continue;
            for(int j = 0;j < N;j++){
                if(a[i][j]==0)
                    continue;
                if((bit&(1<<j))==0){
                    dp[now][bit|(1<<j)]+=dp[prev][bit];
                    dp[now][bit|(1<<j)]%=MOD;
                }
            }
        }
    }
    cout<<dp[now][(1<<N)-1]<<endl;
}



Measured memory_bytes: 33024
def composite(d,n,s):
    for a in (2,3,5,7):
        p = False
        if pow(a,d,n) == 1:
            p = True
            continue
        for i in range(s):
            if pow(a, 2**i * d, n) == n-1:
                p = True
                break
        return not p
    return False

def is_prime(n):
    if n==2:
        return True
    elif n%2==0:
        return False
    else:
        d,s = n-1, 0
        while not d%2:
            d,s = d>>1,s+1
        return not composite(d,n,s)
r = []
n = int(input())
for i in range(n):
  n = int(input())
  if is_prime(n):
      if n not in r:
          r.append(n)

print(len(r))

Measured memory_bytes: 7756
N,M = map(int,input().split())
L = []
for i in range(M):
    L.append(list(map(str,input().split())))
from operator import itemgetter
L.sort(key=itemgetter(0))
count_AC = 0
count_WA = 0
temp = 0
p = 0
#print(L)

for i in range(M):
    #print(L[i])
    if L[i][0] != p:
        p = L[i][0]
        temp = 0
        flag = 'WA'
        if L[i][1] == 'WA':
            temp += 1
        else:
            count_AC += 1
            flag = 'AC'
    else:
        if L[i][1] == 'WA':
            temp += 1
        else:
            if flag == 'WA':
                count_AC += 1
                count_WA += temp
                flag = 'AC'
            else:
                pass
            
    #print(temp, count_AC, count_WA)

print('{} {}'.format(count_AC, count_WA))

Measured memory_bytes: 33916
#include <iostream>
#include <string>
using namespace std;
    int main(){
    int a=0;
    string S,A="CODEFESTIVAL2016";
    cin >> S;
    for(int x=0; x<=15; x++){
        if(S[x]!=A[x]){
        a += 1;
        }
    }cout << a << endl;
    }

Measured memory_bytes: 256
N = int(input())
S = []
for i in range(N):
    S.append(input())
M = int(input())
T = []
for i in range(M):
    T.append(input())
    
dic = {}
for i in range(N):
    if S[i] in dic:
        dic[S[i]] += 1
    else:
        dic[S[i]] = 1
for i in range(M):
    if T[i] in dic:
        dic[T[i]] -= 1
    
ans = 0
for key in dic:
    if ans < dic[key]:
        ans = dic[key]
        
print(ans)

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

string s;

int main() {
    cin>>s;
    sort(s.begin(),s.end());
    if (s[0]==s[1]&&s[1]!=s[2]&&s[2]==s[3]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    int x;
    cin >> x;
    while(true){
        bool is_prime = false;
        for(int i = 2; i * i <= x; i++){
            if(x % i == 0)
                is_prime = true;
        }
        if(!is_prime){
            cout << x << endl;
            return 0;
        }
        x++;
    }
    return 0;
}

Measured memory_bytes: 3612
import math

L = int(input())
r = math.floor(math.log2(L))
N = r + 1

E_list = []

for i in range(1, N):
    E_list.append((i, i+1, 0))
    E_list.append((i, i+1, 2**(r - i)))
    if L - 2**(N-i-1) >= 2**r:
        E_list.append((1, i+1, L - 2**(N-i-1)))
        L -= 2**(N-i-1)

M = len(E_list)

print(N, M)
for e in E_list:
    print(e[0], e[1], e[2])



Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(int i=0;i<(int)n;i++)
ll mod=1e9+7;
#define PI acos(-1)
struct edge{int from, to;};

int main(){
    int n,m;
    cin>>n>>m;
    vector<string> a,b;
    rep(i,n){
        string u;
        cin>>u;
        a.push_back(u);
    }
    rep(i,m){
        string u;
        cin>>u;
        b.push_back(u);
    }
    bool exist=false;
    for(int ly=0;ly<n;ly++){
        for(int lx=0;lx<n;lx++){
            if(ly+m-1>=n or lx+m-1>=n) continue;

            bool match=true;
            for(int y=0;y<m;y++){
                for(int x=0;x<m;x++){
                    if(a[ly+y][lx+x]!=b[y][x]) match=false;
                }
            }
            if(match) exist=true;
        }
    }

    if(exist) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include<algorithm>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
typedef pair<int,int> pint;
typedef long long ll;
const int inf   = 1<<30;
const ll  longinf = 1LL<<60;
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};
int main(){
  int n;
  cin>>n;
  int a[n];
  rep(i,n) cin>>a[i];
  sort(a,a+n);
  reverse(a,a+n);
  int i,j;
  ll x[2];
  i=j=x[0]=x[1]=0;
  while(i<n){
    if(a[i]==a[i+1]){
      x[j]=a[i];
      j++;
      if(j==2)break;
      i+=2;
      }
    else
      i++;
    }
  cout<<x[0]*x[1]<<endl;
  return 0;
  }


Measured memory_bytes: 640