akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<vector>
#include<tgmath.h>
using namespace std;

#define lld long long

int main(){
    lld K,N;
    lld A[200001];
    lld diff[200001];
    cin >> K >> N;
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    for(int i=0;i<N;i++){
        if(i == N-1){
            diff[i] = abs(A[0] + K - A[i]);
        } else {
            diff[i] = abs(A[i]-A[i+1]);
        }
    }
    lld sum = 0;
    lld maxx = -1;
    for(int i=0;i<N;i++){
        sum += diff[i];
        maxx = max(maxx,diff[i]);
    }
    cout << sum - maxx << endl;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  string s;
  cin >> s;
  int n = s.size();
  string rs = s;
  reverse(rs.begin(), rs.end());
  string fr = s.substr(0, (n-1)/2);
  string rfr = fr;
  reverse(rfr.begin(), rfr.end());
  string re = s.substr((n+3)/2-1);
  string rre = re;
  reverse(rre.begin(), rre.end());
  cerr << fr << " " << re << endl;
  if(s ==rs && fr == rfr && re == rre) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<bool> path1(n, false), path2(n, false);
    rep(i,m){
        int a, b;
        cin >> a >> b;
        a--; b--;
        if(a == 0) path1[b] = true;
        if(b == n-1) path2[a] = true;
    }
    rep(i,n){
        if(path1[i] && path2[i]){
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
    return 0;
}

Measured memory_bytes: 256
// Problem : A - A?C
// Contest : AtCoder - AtCoder Beginner Contest 166
// URL : https://atcoder.jp/contests/abc166/tasks/abc166_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

    
/*
CODED BY               
**************
DARSHAN JAIN
darshanjain31
**************
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define endl '\n'
#define MOD 1000000007
using namespace std;
int main()
{
	string s;
	cin>>s;
	if(s=="ABC")
	cout<<"ARC"<<endl;
	else
	cout<<"ABC"<<endl;
}






Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ios::sync_with_stdio(0);
	int n;
	cin>>n;
	std::vector<ll> a(n);
	int p=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(abs(a[p])<abs(a[i])){
			p=i;
		}
	}
	cout<<2*n-1<<endl;
	for(int i=0;i<n;i++){
		cout<<p+1<<" "<<i+1<<endl;
	}
	if(a[p]<0){
		for(int i=n;i>1;i--){
			cout<<i<<" "<<i-1<<endl;
		}
	}else{
		for(int j=1;j<n;j++){
			cout<<j<<" "<<j+1<<endl;
		}
	}
		return 0;
}

Measured memory_bytes: 256
x, y = [int(i) for i in input().split()]

A = set([1, 3, 5, 7, 8, 10, 12])
B = set([4, 6, 9, 11])
C = set([2])

def both_in(X):
    return x in X and y in X

if both_in(A) or both_in(B) or both_in(C):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#!/usr/bin/env python3

import sys

n = int(sys.stdin.readline().strip())
d = [ int(x) for x in sys.stdin.readline().strip().split() ]

c=0
for i in range(n):
    for j in range(i+1,n):
        c+= d[i] * d[j]
#
print(c)


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

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(lol i=0;i<lol(n);i++)
#define REPD(i,n) for(lol i=n-1;i>=0;i--)
#define FOR(i,a,b) for(lol i=a;i<=lol(b);i++)
#define FORD(i,a,b) for(lol i=a;i>=lol(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) lol(x.size()) //sizeをsize_tからllに直しておく
//定数
#define PI 3.1415926535897932385 //pi
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//最大値最小値
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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main()
{
    //lol result{0};
    string s; cin >> s;
    //int k; cin >> k;
    /*
    vector<int> a(n);
    REP(i, n)
    {
        cin >> a[i];
    }
    */
    if(s[1] == 'R')
        cout << "ABC" << endl;
    else
    {
        cout << "ARC" << endl;
    }
    

    //cout << result << endl;
    return 0;
}

Measured memory_bytes: 3532
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<stdio.h>
#include<iostream>
#include<numeric>
using namespace std;

int main() {
	int x;
	cin >> x;
	if (x == 3 || x == 5 || x == 7)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, a, b) for(ll i = ll(a); i <= ll(b); i++)
ll calculate(ll h)
{
	if(h>1)
	{
		return 2*calculate(floor(h/2))+1;
	}
	else
		return 1;
}
int main()
{
	ll h,x,n=1,a=1;
	cin>>h;	
	cout<<calculate(h);
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int n,a,b,c=0;
    cin>>n>>b;
    for(int i=1;i<n;i++){
        cin>>a;
        if(a==b){
            c++;
            if(i<n-1){
                i++;
                cin>>a;
            }
        }
        b=a;
    }
    cout<<c<<endl;
}


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

int main() {
  
  int N, K, T;
  cin >> N >> K;
  vector<int> P(N);
  T = 0;
  
  for (int i = 0; i < N; i++) {
    cin >> P.at(i);
  }
  
  sort(P.begin(), P.end());
  
  for (int i = 0; i < K; i++) {
    T = T + P.at(i);
  }
  
  cout << T;
  
}

Measured memory_bytes: 3572
#セグ木
from collections import deque
def f(L, R): return L + R #マージ
def g(old, new): return old+new #更新
zero = 0 #マージにおける零元

class segtree:
    def __init__(self, N, z): #要素数、零元
        self.M = 1
        while self.M<N: self.M *= 2
        self.dat = [z] * (self.M*2-1)
        self.ZERO = z

    def update(self, x, idx, l=0, r=-1):
        if r==-1: r = self.M
        idx += self.M-1
        self.dat[idx] = g(self.dat[idx], x)
        while idx > 0:
            idx = (idx-1)//2
            self.dat[idx] = f(self.dat[idx*2+1], self.dat[idx*2+2])

    def query(self, a, b=-1, idx=0, l=0, r=-1):
        if r==-1: r = self.M
        if b==-1: b = self.M
        q = deque([])
        q.append([l, r, 0])
        ret = self.ZERO
        while len(q):
            tmp = q.popleft()
            L = tmp[0]
            R = tmp[1]
            if R<=a or b<=L: continue
            elif a<=L and R<=b:
                ret = f(ret, self.dat[tmp[2]])
            else:
                q.append([L, (L+R)//2, tmp[2]*2+1])
                q.append([(L+R)//2, R, tmp[2]*2+2])
        return ret

#Verify https://atcoder.jp/contests/abc157/submissions/11965304

def zaatu(LIST):
    s = set(LIST)
    ar = list(s)
    ar.sort()
    dic = dict()
    for i in range(len(ar)): dic[ar[i]] = i
    return dic

n, k = map(int, input().split())
a = [int(input()) for _ in range(n)]
for i in range(n):
    a[i] -= k
    if i!=0: a[i] += a[i-1]
dic = zaatu(a)
seg = segtree(n+1, 0)
ans = 0
for num in a: ans += (num>=0)
for i in range(n): a[i] = dic[a[i]]
for i in range(n):
    ans += seg.query(0, a[i]+1)
    seg.update(1, a[i])
print(ans)


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


int main(){
    int K,A,B;
    bool flag = false;
    cin>>K>>A>>B;
    for(int i=1;K*i<=B;i++){
        if(A<=i*K&&i*K<=B){
            flag = true;
        }
    }
    if(flag){
        cout<<"OK"<<endl;
    }else{
        cout<<"NG"<<endl;
    }
}

Measured memory_bytes: 3632
[Sa,Sb,Sc]=[list(input()) for i in range(3)]
turn="a"
while not ((turn=="a" and len(Sa)==0)or(turn=="b" and len(Sb)==0)or(turn=="c"and len(Sc)==0)):
    win=turn
    if turn=="a":
        turn=Sa.pop(0)
    elif turn=="b":
        turn=Sb.pop(0)
    else:
        turn=Sc.pop(0)
print(str.upper(turn))


Measured memory_bytes: 3060
use proconio::input;
use proconio::marker::Chars;

fn main() {
    input! {
        s: Chars
    };
    match s
        .iter()
        .position(|&s_i| s_i == 'C')
        .and_then(|i_c| s.iter().skip(i_c + 1).position(|&s_i| s_i == 'F'))
    {
        None => println!("No"),
        Some(_) => println!("Yes"),
    };
}


Measured memory_bytes: 2136
#include <iostream>
#include <bits/stdc++.h>
#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long int ll;
const ll INF=1e18+5;
int main()
{
    IO;
    int n ;
    cin>>n;
    double arr[n+2];
    for(int i = 0; i< n ; i ++) cin>>arr[i];
    double dp[n+2][n+2];
    dp[0][0]=1-arr[0];
    dp[0][1]=arr[0];
    for(int i = 1 ; i< n ; i ++)
        for(int j = 0 ; j <=i+1 ; j ++)
             if(j==0)
                dp[i][j]=(1-arr[i])*dp[i-1][j];
             else if(j==i+1)
                dp[i][j]=arr[i]*dp[i-1][j-1];
             else
                dp[i][j]=(1-arr[i])*dp[i-1][j]+(arr[i]*dp[i-1][j-1]);
    double ans=0;
    for(int i = n; i>n/2;i--)ans+=dp[n-1][i];
    printf("%.10f\n", ans);
    return 0;
}


Measured memory_bytes: 49876
import itertools

z = []
for i in range(1000):
    a =i**5
    # print(a)
    z.append(a)

X = int(input())

z_p = list(itertools.permutations(z, 2))
for i in range(len(z_p)):
    if z_p[i][0] - z_p[i][1] ==  X:
        print(z.index(z_p[i][0]),z.index(z_p[i][1]))
        exit()
    elif z_p[i][0] + z_p[i][1] ==  X:
        print(z.index(z_p[i][1]),-(z.index(z_p[i][0])))
        exit()


Measured memory_bytes: 80344
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int h,w;
  cin>>h>>w;
  char c[h][w];
  rep(i,0,h){
    rep(j,0,w){
      cin>>c[i][j];
    }
  }
  vector<int> a,b;
  rep(i,0,h){
    bool p=false;
    rep(j,0,w){
      if(c[i][j]=='#'){
        p=true;
      }
    }
    if(p) a.push_back(i);
  }
  rep(i,0,w){
    bool p=false;
    rep(j,0,h){
      if(c[j][i]=='#'){
        p=true;
      }
    }
    if(p) b.push_back(i);
  }
  for(int i:a){
    for(int j:b){
      cout<<c[i][j];
    }
    cout<<endl;
  }
}

Measured memory_bytes: 256
import java.util.*;

class Main{
    static Scanner sc = new Scanner(System.in);
    static StringBuffer sb = new StringBuffer();
    public static void main(String args[]){
        int n=sc.nextInt();
        long k=sc.nextLong();
        Map<Integer,Long> a=new TreeMap<>();
        for(int i=0;i<n;i++){
            int temp=sc.nextInt();
            if(!a.containsKey(temp)) a.put(temp,(long)0);
            a.replace(temp,a.get(temp)+sc.nextInt());
        }
        long res=0;
        for(int key:a.keySet()){
            k-=a.get(key);
            if(k<=0){
                res=key;
                break;
            }
        }
        System.out.println(res);
    }
}

Measured memory_bytes: 64732
s = input()

if s[0] == s[1] and s[2] == s[3] and s[1] != s[2]:
    print('Yes')
elif s[0] == s[2] and s[1] == s[3] and s[1] != s[2]:
    print('Yes')
elif s[0] == s[3] and s[1] == s[2] and s[1] != s[3]:
    print('Yes')
else:
    print('No')

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

int main() {

  int cnt = 0;
  int ans = 0;
  int size = 0;
  for(char c; ~scanf("%c", &c) && c != '\n'; size++) {
    if(c == 'S') cnt++;
    else if(cnt > 0) {
      cnt--;
      ans++;
    }
    else {
      cnt = 0;
    }
  }

  cout << size - 2 * ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
def main():
    A, B, K = map(int, input().split())
    res = set()
    for i in range(K):
        if A+i <= B:
            res.add(A+i)
        if B-i >= A:
            res.add(B-i)
    res = sorted(list(res))
    for i in res:
        print(i)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define next Next
#define gc getchar
#define int long long
const int N=1e6+5;
int n,m,k,ans,a[N],b[N];
char s[N];
//char buf[1<<21],*p1=buf,*p2=buf;
//inline int gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}
inline int read()
{
    int ret=0,f=0;char c=gc();
    while(!isdigit(c)){if(c=='-')f=1;c=gc();}
    while(isdigit(c)){ret=ret*10+c-48;c=gc();}
    if(f)return -ret;return ret;
}
signed main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	if(n!=6){puts("No");return 0;}
	if(s[3]!=s[4]){puts("No");return 0;}
	if(s[5]!=s[6]){puts("No");return 0;}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF INT_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0; i<n; ++i)
#define FOR(i, s, e) for(ll i=s; i<e; ++i)
#define MOD 1000000007
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, M;
  cin >> N >> M;
  printf("%s", N==M ? "Yes" : "No");
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<map>
#include<math.h>
#include<queue>
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MOD = 1000000007;
const int mod = 1000000007;
const int INF = 1000000000;
const long long LINF = 1e18;
const int MAX = 510000;

int main(){
	int a, b, k;
	cin >> a >> b >> k;
	if (a + k > b - k) {
		for (int i = a; i <= b; i++)cout << i << endl;
	}
	else {
		for (int i = a; i < a + k; i++)cout << i << endl;
		for (int i = b - k + 1; i <= b; i++)cout << i << endl;
	}
	return 0;
}

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

const int MAXN = 302;

double dp[MAXN][MAXN][MAXN];
int N,vis[MAXN][MAXN][MAXN];

double solve(int x,int y,int z){
	
	if(vis[x][y][z]) return dp[x][y][z];
	//printf("Solving %d %d %d\n",x,y,z);
	vis[x][y][z] = 1;

	if(x == 0 && y == 0 && z == 0) return dp[x][y][z] = 0;

	int soma = x + y + z;
	double convertido = (double)soma;
	double tot = N/convertido;
	
	//printf("Tot antes %d %d %d %d %lf\n",N - soma,x,y,z,tot);

	if(x != 0) tot += x*((solve(x-1,y,z) )/convertido);
	if(y != 0) tot += y*((solve(x+1,y-1,z) )/convertido);
	if(z != 0) tot += z*((solve(x,y+1,z-1) )/convertido);

	//printf("Tot (%d,%d,%d) = %lf\n",x,y,z,tot);

	return dp[x][y][z] = tot;

}

int main(){

	int a[4] = {0,0,0,0};

	cin >> N;

	for(int i = 1;i<=N;i++){
		int x;
		cin >> x;
		a[x]++;
	}

	printf("%.9lf\n",solve(a[1],a[2],a[3]));

	return 0;
}

Measured memory_bytes: 321792
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
typedef long long ll;
using namespace std;

int main(){
    
    int alice,bob;cin>>alice>>bob;
    if(alice==1)alice+=100;if(bob==1)bob+=100;
    long long int a=1000000000000;
    long long int b=0;
    for(long long int i=1;i<=a;i++)b++;
    if(alice==bob)printf("Draw");
    else if(alice<bob)printf("Bob");
    else printf("Alice");
    
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int mod = 1000000007;
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[] a = new int[n+1];
		int[] position = new int[n+1];
		for(int i=0;i<=n;i++) {
			position[i] = -1;
		}
		int idx1 = 0;
		int idx2 = 0;
		for(int i=0;i<n+1;i++) {
			a[i] = in.nextInt();
			if(position[a[i]]>=0) {
				idx1 = position[a[i]];
				idx2 = i;
			}else {
				position[a[i]] = i;
			}
		}
		in.close();
		
		StringBuilder sb = new StringBuilder();
		String ls = System.lineSeparator();
		long comb1 = n+1;
		long comb2 = 1;
		long ans = comb1-comb2;
		sb.append(ans+ls);
		for(int l=2;l<=n+1;l++) {
			comb1 = (((comb1*(n+2-l))%mod)*modpow(l,mod-2,mod))%mod;
			ans = comb1;
			if(n+idx1-idx2>=l-1) {
				comb2 = (((comb2)*(n+idx1-idx2-l+2)%mod)*modpow(l-1,mod-2,mod))%mod;
				ans -= comb2;
			}
			if(ans<0) ans += mod;
			sb.append(ans+ls);
		}
		System.out.println(sb.toString());
		

	}
	
	public static int modpow(int base,int pow,int mod) {
		long res = 1;
		long num = base;
		while(pow>0) {
			if((pow&1)==1) res = (res*num)%mod;
			pow = pow>>1;
			num = (num * num)%mod;
		}
		return (int)res;
	}

}


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

 using namespace std;
 int main() {
   char s1, s2, s3;
   cin >> s1 >> s2 >> s3;
   cout << (int)(s1 - '0') + (int)(s2 - '0') + (int)(s3 - '0') << endl;
 }


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int b[n-1];
  for(int i=0;i<n-1;i++)
  cin>>b[i];
  int a[n];
  a[0]=b[0];
  int sum=0;
  if(n==2) {
  cout<<2*a[0];return 0;}
  
  for(int i=0;i<n-2;i++)
  {
    int m;
    if(b[i]<b[i+1]) m=b[i];
    else m=b[i+1];
    if(a[i]>b[i]) a[i]=b[i];
    a[i+1]=m;
    a[i+2]=b[i+1];
    sum+=a[i];
  }
  sum+=a[n-2]+a[n-1];
  cout<<sum;
  
}


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;





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

    string s;
    cin>>s;
    int n = s.length();
    for (int i=0; i<n; i++) {
	if (s[i]=='?') s[i]='D';
    }

    cout<<s<<endl;
    
    
    return 0;
}


Measured memory_bytes: 3740
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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;
}

ll gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return (b);
    }
    else
    {
        return (gcd(b, a % b));
    }
}

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

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

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


int main(){
ll a,b,c;
cin>>a>>b>>c;
if(a+b>=c){
    cout<<"Yes"<<endl;
}else{
    cout<<"No"<<endl;
}
}









Measured memory_bytes: 256
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

def main():
    N = int(input())
    B = input_nums()
    B = B[::-1]
    A = [B[0], B[0]]
    for b in B[1:]:
        if A[-1] > b:
            A.pop()
            A.append(b)
            A.append(b)
        else:
            A.append(b)
    print(sum(A))

if __name__ == '__main__':
    main()

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

int n,a,b;

int main(){
	scanf("%d%d%d",&n,&a,&b);
	if (a>b) swap(a,b);
	if (b-a&1) printf("Borys\n");
	else printf("Alice\n");
	return 0;
} 

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
	int N; cin >> N;
	int A[N];
	rep(i, N) {
		cin >> A[i];
		if (i != 0) {
			if (A[i] - A[i - 1] > 1) {
				cout << -1 << endl;
				return 0;
			}
		}
	}
	if (A[0] != 0) {
		cout << -1 << endl;
		return 0;
	}
	int tmp = 0;
	rep(i, N) {
		if (A[i] == 0) tmp = 0;
		else {
			tmp++;
			if (A[i] > tmp) {
				cout << -1 << endl;
				return 0;
			}
		}
	}
	int ans = A[N - 1];
	int tmp2 = 0;
	for (int i = N - 1; i >= 1; i--) {
		// cout << A[i] << " " << A[i - 1] << endl;
		if (A[i] - A[i - 1] != 1) ans += A[i - 1];
		
	}
	cout << ans << endl;




    return 0;
}


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

using namespace std;
//using namespace __gnu_pbds;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#define FOR(i, a, b) for (int i=a; i<b; i++)
#define F0R(i, a) for (int i=0; i<a; i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

const int MOD = 1000000007;
double PI = 4*atan(1);

int N,M, R[3001], num[3001], dp[3001][3001];
string s;

int main() {
	cin >> N >> M >> s;
	F0R(i,N) R[i] = i+1;
	R[N] = N;
	
	F0R(i,M) {
	    int l,r; cin >> l >> r; l--,r--;
	    R[l] = max(R[l],r+1);
	}
	
	F0R(i,N+1) {
	    int pre = 0;
	    if (i) pre = R[i-1];
	    
	    R[i] = max(pre,R[i]);
	    for (int j = pre; j < R[i]; ++j) if (s[j] == '1') num[i] ++;
	}
	
	//F0R(i,N+1) cout << i << " " << R[i] << "\n";
	dp[N][0] = 1;
	F0Rd(L,N) F0R(j,R[L]-L+1) {
	    if (j <= R[L]-L-1) dp[L][j] += dp[L+1][j+num[L+1]]; // what should these indices be
	    if (j >= 1) dp[L][j] += dp[L+1][j+num[L+1]-1];
	    dp[L][j] %= MOD;
	    //cout << L << " " << j << " " << dp[L][j] << "\n";
	}
	cout << dp[0][num[0]];
}

Measured memory_bytes: 33920
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] array = new int[n+2];
		array[0] = 0;
		array[n+1] = 0;
		for(int i = 1; i < n+1;i++) array[i] = sc.nextInt();
		int sum = 0;
		for(int i = 0; i < n+1;i++) sum += Math.abs(array[i] - array[i+1]);
		StringBuilder sb = new StringBuilder();
		for(int i = 1; i < n+1;i++) {
			sb.append(sum - Math.abs(array[i-1] - array[i]) - Math.abs(array[i] - array[i+1]) + Math.abs(array[i-1] - array[i+1]));
			sb.append("\n");
		}
		System.out.println(sb.toString());
	}
}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = 998244353;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;
const ll A_MAX = pow(10,6);

// inverse(逆元)の計算
ll inv(ll a,ll m=MOD) {
  ll b = m, x = 1, y = 0;
  while (b!=0) {
    ll d = a/b;
    a -= b*d; swap(a, b);
    x -= y*d; swap(x, y);
  }
  return x>=0 ? x : x+m;
}

int main() {
  int N; cin >> N;
  ll num[A_MAX+1] = {}; rep(i,N) { ll tmp; cin >> tmp; num[tmp]++; }
  ll w[A_MAX+1] = {}; repr(i,1,A_MAX+1) w[i] = inv(i);
  repr(i,1,A_MAX+1) {
    for (ll j=i*2; j<=A_MAX; j+=i) {
      w[j] -= w[i]; w[j] %= MOD;
    }
  }

  ll result = 0;
  repr(i,1,A_MAX+1) {
    ll sum1 = 0, sum2 = 0;
    for (ll j=i; j<=A_MAX; j+=i) {
      sum1 += j*num[j]; sum1 %= MOD;
      sum2 += (((j*j)%MOD)*num[j])%MOD; sum2 %= MOD;
    }
    sum1 *= sum1; sum1 %= MOD;
    ll tmp = (sum1-sum2)%MOD;
    tmp *= inv(2); tmp %= MOD;
    tmp *= w[i]; tmp %= MOD;
    result += tmp; result %= MOD;
    // if (i<=10) cout << i << " " << sum1 << " " << sum2 << endl;
    // if (i<=10) cout << tmp << " " << result << endl;
  }
  result = (result+MOD) % MOD;
  cout << result << endl;
  return 0;
}

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

#define rep(i,n) for(int i=0; i<n; i++)
#define all(x) (x).begin(),(x).end()
#define INF (1e9)

int sx,sy,tx,ty;
int main(){
  int sx,sy,tx,ty;
  cin >> sx >> sy >> tx >> ty;
  rep(i,ty-sy)cout << "U";
  rep(i,tx-sx)cout << "R";
  rep(i,ty-sy)cout << "D";
  rep(i,tx-sx)cout << "L";
  cout << "L";
  rep(i,ty-sy+1)cout << "U";
  rep(i,tx-sx+1)cout << "R";
  cout << "D" << "R";
  rep(i,ty-sy+1)cout << "D";
  rep(i,tx-sx+1)cout << "L";
  cout << "U" << endl;
}

Measured memory_bytes: 256
import java.text.DecimalFormat;
import java.util.stream.LongStream;
import java.util.stream.IntStream;
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);

        AtCoder problem = new AtCoder(sc);
        problem.solve(out);

        out.flush();
    }

}

class AtCoder {

    String s;

    AtCoder(FastScanner sc) {
        s = sc.next();
    }

    void solve(PrintWriter out) {
        out.println(s.replace(",", " "));
    }

}

class FastScanner {

    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte()) {
            return buffer[ptr++];
        } else {
            return -1;
        }
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
            ptr++;
        }
        return hasNextByte();
    }

    public String next() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {
            throw new NumberFormatException();
        }
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 21588
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>

using namespace std;
int main() {

    int i,number_of_bluecard,number_of_redcard;
    map<string,int> strs;
    string str;
    int max_yen = 0;

    cin >> number_of_bluecard;

    for(i = 0; i< number_of_bluecard; i++){
        cin >> str;
        if(strs.find(str) == strs.end()){
            strs[str] = 1;
        } else {
            strs[str]++;
        }
    }

    cin >> number_of_redcard;

    for(i = 0;i<number_of_redcard; i++){
        cin >> str;
        if(strs.find(str) != strs.end() && strs[str] != 0 ){
            strs[str]--;
        }
    }

    for(auto itr = strs.begin(); itr != strs.end(); itr++){
        if(max_yen < itr->second) {
            max_yen = itr->second;
        }
    }

    cout << max_yen << endl;
    return 0;
}

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

using namespace std;
using ll=long long;
using vi=vector<int>;
const int N = 5001;
char buff[N];

int main() {
    int k , n;
    scanf("%s", buff);
    string s(buff);
    scanf("%d", &k);
    n = (int)s.size();
    vector<string>a;
    for(int i = 1; i <= k; ++i){
        for(int j = 0; j < n - i + 1; ++j){
            a.push_back( s.substr(j , i) );
        }
    }
    sort(a.begin(), a.end());
    a.resize(unique(a.begin(), a.end()) - a.begin());
    cout << a[k - 1] << '\n';

    return 0;
}



Measured memory_bytes: 1660
#import numpy as np
#import functools
#import operator
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as comb_with
#from itertools import permutations as perm
#import collections as C #most_common
#import math


#N = int(input())
N,K= map(int,input().split())
#P = list(map(int,input().split()))
#S= str(input())
c=0
for i in range(N,K+1):
    i=list(str(i))
    j=list(reversed(i))
    if i==j:
        c+=1
print(c)


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

int main() {
  int N;
  string S;
  cin >> N;
  for (int i=0; i<N; i++) {cin>>S;
  if ( S == "Y" ){cout << "Four" << endl;
                 break;}
  else if ( i+1 == N ){cout << "Three" << endl;
                 break;}
  else {continue;}
  }
}


Measured memory_bytes: 256
def check_signature():
    s = input()
    t = input()
    dict_s = {}
    dict_t = {}
    for s_, t_ in zip(s, t):
        if s_ not in dict_s:
            dict_s[s_] = t_
        if t_ not in dict_t:
            dict_t[t_] = s_
        if dict_s[s_] != t_ or dict_t[t_] != s_:
            return False
    else:
        return True

print('Yes' if check_signature() else 'No')

Measured memory_bytes: 3632
// ConsoleApplication.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//

#include "stdio.h"
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <string>
#include <iostream>
#include <vector>
#include <sstream>

using namespace std;

static const int IntMax = 1000000000;

void outputA(const std::vector<int>& A)
{
	const int N = A.size();
	cout << A.front();
	for (int k = 1; k != N; ++k) {
		cout << " " << A.at(k);
	}
	cout << endl;
}

int main()
{
	//const int numberOfValues = getIntFromStringInput(cin);
	int N; cin >> N;
	std::vector<int> A(N);
	for (int k = 0; k != N; ++k) {
		cin >> A.at(k);
	}

	for (int i = 1; i != N; ++i) {
		outputA(A);
		int v = A.at(i);
		int j = i - 1;
		while (j >= 0 && A.at(j) > v) {
			A.at(j + 1) = A.at(j);
			--j;
		}
		A.at(j + 1) = v;
	}
	outputA(A);

	return 0;
}


Measured memory_bytes: 3096
from collections import defaultdict
import sys
sys.setrecursionlimit(1000000)

n, m = [int(i) for i in raw_input().split()]
parents = defaultdict(list)

i = 0
while i < m:
    u, v = [int(x) for x in raw_input().split()]
    parents[v-1].append(u-1)
    i += 1

def calc_f(parents, f, i):
    if i < 0 or i >= len(f):
        return 0

    if f[i] != -1:
        return f[i]

    f[i] = 0
    for v in parents[i]:
        f[i] = max(f[i], calc_f(parents, f, v)+1)

    return f[i]

f = [-1] * n
j = 0
while j < n:
    calc_f(parents, f, j)
    j += 1

if len(f) == 0:
    print 0
else:
    print max(f)

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

int main(){
  int a,b;
  cin >> a >> b;
  cout << max(0,a-2*b) << endl;
  
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoderRegularContest069
{
    public class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(program1(new String[] { Console.ReadLine(), Console.ReadLine() }));
        }

        public static string program1(string[] args)
        {
            var n = int.Parse(args[0]);
            var s = args[1].ToCharArray();

            var animalPattern = new List<char>[] { new List<char>() { 'S', 'S' }, new List<char> { 'S', 'W' }, new List<char> { 'W', 'W' }, new List<char> { 'W', 'S' } };

            return string.Join("", animalPattern.Select(animals => {
                s.Skip(1).Aggregate(animals.First(), (ani, ans) =>
                {
                    var current = animals.Last();
                    if (ans == 'o' && current == 'S' || ans == 'x' && current == 'W')
                    {
                        animals.Add(ani);
                    }
                    else
                    {
                        animals.Add(ani == 'S' ? 'W' : 'S');
                    }
                    return current;
                });

                return animals;
            })
            .Where(animals => animals.First() == animals.Last())
            .Select(animals => animals.Take(n))
            .FirstOrDefault(animals => {
                if (s.First() == 'o' && animals.First() == 'S' || s.First() == 'x' && animals.First() == 'W')
                {
                    return animals.ElementAt(1) == animals.Last();
                }
                else
                {
                    return animals.ElementAt(1) != animals.Last();
                }
            }) ?? new List<char>() { '-', '1' }) ;
        }
    }
}


Measured memory_bytes: 18272
N = int(input())

list = []
for i in range(N):
    list.append(str(input()))
a = list.count("AC")
b = list.count("WA")
c = list.count("TLE")
d = list.count("RE")

print("AC x",a)
print("WA x" ,b)
print("TLE x" ,c)
print("RE x" ,d)

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

int main(void){
    char day[10];
    
    scanf("%s",day);
    
    if (strcmp(day,"SUN")==0){
        printf("7");
    } else if (strcmp(day,"MON")==0){
        printf("6");
    } else if (strcmp(day,"TUE")==0){
        printf("5");
    } else if (strcmp(day,"WED")==0){
        printf("4");
    } else if (strcmp(day,"THU")==0){
        printf("3");
    } else if (strcmp(day,"FRI")==0){
        printf("2");
    } else if (strcmp(day,"SAT")==0){
        printf("1");
    }
    
    return 0;
}


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

using namespace std;

class UF{
  private:
    int n;
    vector<int> r, p;
  public:
    UF(int num){
      n = num;
      for(int i=0;i<n;i++){
        r.push_back(1);
        p.push_back(i);
      }
    }
    int find(int x){
      if(x == p[x])return x;
      return p[x] = find(p[x]);
    }
    bool same(int x, int y){
      return find(x) == find(y);
    }
    void unite(int x, int y){
      x = find(x), y = find(y);
      if(x==y)return;
      if(r[x]<r[y])swap(x, y);
      r[x] += r[y];
      p[y] = x;
      n--;
    }
    int size(int x){
      return r[find(x)];
    }
    int cnt(){
      return n;
    }
};

int main(){
  int n, m, p[100009];
  cin >> n >> m;
  UF uf(n);
  for(int i=0;i<n;i++){
    cin >> p[i];
    p[i]--;
  }
  for(int i=1;i<=m;i++){
    int x, y;
    cin >> x >> y;
    x--;y--;
    uf.unite(x, y);
  }
  int cnt=0;
  for(int i=0;i<n;i++){
    if(uf.same(p[i], i))cnt++;
  }
  cout << cnt << endl;
}



Measured memory_bytes: 1652
#include<iostream>
#include<cstdio>

using namespace std;

int main(){
    char b;
    cin >> b;
    if (b == 'A') {
        puts("T");
    }else if (b == 'T') {
        puts("A");
    }else if (b == 'G') {
        puts("C");
    }else if (b == 'C') {
        puts("G");
    }
    
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#define _GLIBCXX_DEBUG // check []
#define DIVISOR 1000000007

using namespace std;
typedef pair<int,int> pii;
typedef pair<int64_t, int64_t> pII;

template<typename T>
void cins(vector<T>& arr) { for(T& e: arr) cin >> e; }

#ifdef DEBUG
#define debug(fmt, ...) \
    printf("[debug: %s] " fmt, __func__, __VA_ARGS__)
#define ps(arr) \
    for(auto e: arr) cout << e << " "; \
    cout << endl;
#else
#define debug(fmt, ...)
#define ps(arr)
#endif

int main(void) {
    string str;
    cin >> str;
    vector<int> pos;
    for(int i = 1; i <= str.length(); i++) {
        char ch = str[i-1];
        // move left
        if(ch == 'W') pos.push_back(i);
    }
    int64_t sum = 0;
    for(int i = 1; i <= pos.size(); i++) {
        int idx = pos[i-1];
        sum += idx-i;
        debug("%lld\n", sum);
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 4352
N = int(input())

A = [0]*N
B = [0]*N

for i in range(N):
  A[i],B[i] = map(int, input().split())
A.sort()
B.sort()
 
if len(A)%2 != 0:
  ans = B[N//2]-A[N//2]+1
else:
  ans = (B[N//2]+B[N//2-1]) - (A[N//2]+A[N//2-1]) + 1

print(ans)

Measured memory_bytes: 25356
#pragma GCC optimize("Ofast","unroll-loops")
#pragma GCC push_options
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#include <xmmintrin.h>
#include <immintrin.h>
using namespace::std;
__attribute__((constructor))void init(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/priority_queue.hpp>
#include<ext/pb_ds/tag_and_trait.hpp>
// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// typedef mp::number<mp::cpp_dec_float<0>> cdouble;
// typedef mp::cpp_int cint;
template<typename T>using pbds=__gnu_pbds::tree<T,__gnu_pbds::null_type,less<T>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>;
template<typename T>using pbds_map=__gnu_pbds::tree<T,T,less<T>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>;
template<typename T,typename E>using hash_map=__gnu_pbds::gp_hash_table<T,E>;
template<typename T>using pqueue =__gnu_pbds::priority_queue<T, greater<T>,__gnu_pbds::rc_binomial_heap_tag>;
typedef long long lint;
#define INF (1LL<<60)
#define IINF (1<<30)
#define EPS (1e-10)
#define MOD 1000000007LL
//#define MOD 998244353LL
typedef vector<lint> vec;
typedef vector<vector<lint>> mat;
typedef vector<vector<vector<lint>>> mat3;
typedef vector<string> svec;
typedef vector<vector<string>> smat;
template<typename T>inline void numout(T t){bool f=0;for(auto i:t){cout<<(f?" ":"")<<i<INF/2?i:"INF";f=1;}cout<<endl;}
template<typename T>inline void numout2(T t){for(auto i:t)numout(i);}
template<typename T>inline void output(T t){bool f=0;for(auto i:t){cout<<(f?" ":"")<<i;f=1;}cout<<endl;}
template<typename T>inline void output2(T t){for(auto i:t)output(i);}
template<typename T>inline void _output(T t){bool f=0;for(lint i=0;i<t.size();i++){cout<<f?"":" "<<t[i];f=1;}cout<<endl;}
template<typename T>inline void _output2(T t){for(lint i=0;i<t.size();i++)output(t[i]);}
#define rep(i,n) for(lint i=0;i<lint(n);++i)
#define repi(i,a,b) for(lint i=lint(a);i<(lint)(b);++i)
#define rrep(i,n) for(lint i=lint(n)-1;i>=0;--i)
#define rrepi(i,a,b) for(lint i=lint(b)-1;i>=lint(a);--i)
#define irep(i) for(lint i=0;;++i)
#define all(n) begin(n),end(n)
#define dist(a,b,c,d) sqrt(pow(a-c,2)+pow(b-d,2))
inline lint gcd(lint A,lint B){return B?gcd(B,A%B):A;}
inline lint lcm(lint A,lint B){return A/gcd(A,B)*B;}
// inline cint cgcd(cint A,cint B){return B?cgcd(B,A%B):A;}
// inline cint clcm(cint A,cint B){return A/cgcd(A,B)*B;}
inline bool chmin(auto& s,const auto& t){bool res=s>t;s=min(s,t);return res;}
inline bool chmax(auto& s,const auto& t){bool res=s<t;s=max(s,t);return res;}
const vector<lint> dx={1,0,-1,0,1,1,-1,-1};
const vector<lint> dy={0,1,0,-1,1,-1,1,-1};
#define SUM(v) accumulate(all(v),0LL)
auto call=[&](auto f,auto... args){return f(f,args...);};

int main(){
	lint a,b;
	cin>>a>>b;
	cout<<b*2-a<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _for(i,a,b) for(int i = (a);i <= (b);++i)
#define LOCAL
typedef long long ll;
const int maxn = 1e5+5;
int main()
{
#ifdef LOCALa
    freopen("simple.in","r",stdin);
    freopen("simple.out","w",stdout);
#endif
    int n;
    scanf("%d",&n);
    bool ok = true;
    for(int i = 1;i <= n;++i)
    {
        int a;
        scanf("%d",&a);
        if(a%2==0)
        {
            if(a%3!=0&&a%5!=0)ok=false;
        }
    }
    if(ok)printf("APPROVED\n");
    else printf("DENIED\n");
    return 0;
}

Measured memory_bytes: 256
#--Next Alphabet
alphabet = ["dummy", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", 
            "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
num = len(alphabet)

character = input()

i = 0
for i in range(num):
  i = i + 1
  if(alphabet[i] == character):
    break
  else:
    pass

print(alphabet[i+1])


Measured memory_bytes: 2940
#include <iostream>
using namespace std;
int main(){
    int H, W, i, k;
    while (1){
        cin >> H >> W;
        if (H==0 && W == 0){
            break;
        }else{
            for (i=0; i<H; i++){
                for (k=0; k<W; k++){
                    if (i==0 || i==H-1){
                        cout << "#" ;
                    }else{
                        if (k==0 || k==W-1){
                            cout << "#";
                        }else{
                            cout << ".";
                        }
                    }
                }
                cout << endl;
            }
            cout << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3100
s = input()
s_len = len(s)

s_p = s[0]
ans = 1
i = 1
while i < s_len:
    s_n = s[i]
    i+=1
    while (s_p == s_n) and (i < s_len):
        s_n += s[i]
        i+=1
    if s_p != s_n:
        ans += 1
    s_p = s_n

print(ans)

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

int main()
{
  string s;
    cin>>s;
    int l=s.size();
    for(int i=0;i<l;i++)
    {
        if(s[i]=='7')
        {
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3572
A, B, C, X, Y = map(int, input().split())
if A+B>C*2:
    ans = 2*C*min(X, Y)
    if X>Y:
        ans += (X-Y)*min(A, 2*C)
    elif X<Y:
        ans += (Y-X)*min(B, 2*C)
else:
    ans = X*A+Y*B
print(ans)

Measured memory_bytes: 3060
# Vicfred
# https://atcoder.jp/contests/abc071/tasks/arc081_a
# greedy, sorting
class Counter(dict):
    def __missing__(self, i):
        return 0

n = int(input())
a = list(map(int, input().split()))

a.sort()
a.reverse()

counter = Counter()
for i in a:
    counter[i] += 1

first = -1
second = -1
for item in a:
    if second != -1:
        break;
    if counter[item] >= 2:
        if first == -1:
            first = item
            counter[item] -= 2
        elif second == -1:
            second = item

if first != -1 and second != -1:
    print(first*second)
else:
    print(0)


Measured memory_bytes: 21676
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ll long long
//priority_queue<int, vector<int>, greater<int> > pq;
const int N = 100030;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =    1e9+7;
vector<pair<int,int> > v[N];
vector<int> ans(N);
int n;
void dfs(int curr,int pre,int val)
{
	ans[curr]=val;
	for(auto u :  v[curr])
	{
		if(u.fi!=pre) dfs(u.fi,curr,val^(u.se&1));
	}
}
int main()
{
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin>>n;
rep(i,1,n)
{
	int a,b,c;
	cin>>a>>b>>c;
	v[a].emplace_back(b,c);
	v[b].emplace_back(a,c);
	
}
dfs(1,0,0);
for(int i=1;i<=n;i++)
cout<<ans[i]<<endl;
}







Measured memory_bytes: 8448
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String t = sc.next();
		int n = s.length();
		int m = t.length();
		int[][] dp = new int[n+1][m+1];
		for(int i=1; i<=n; i++){
			dp[i][0] = i;
		}
		for(int j=1; j<=m; j++){
			dp[0][j] = j;
		}
		for(int i=1; i<=n; i++){
			for(int j=1; j<=m; j++){
				if(s.charAt(i-1)==t.charAt(j-1)){
					dp[i][j] = Math.min(dp[i-1][j-1], dp[i-1][j]+1);
					dp[i][j] = Math.min(dp[i][j], dp[i][j-1]+1);
				}
				else{
					dp[i][j] = Math.min(dp[i-1][j-1]+1, dp[i-1][j]+1);
					dp[i][j] = Math.min(dp[i][j], dp[i][j-1]+1);
				}
			}
		}
		System.out.println(dp[n][m]);
	}
}


Measured memory_bytes: 30924