akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, K; cin >> n >> K;
    vi L(n); for(auto& e : L) cin >> e;
    sort(_all(L));

    int res = 0;
    rep(i, K){
        res += L[n - i - 1];
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Tarek
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BBetweenAAndB solver = new BBetweenAAndB();
        solver.solve(1, in, out);
        out.close();
    }

    static class BBetweenAAndB {
        public static long countDivisibles(long A, long B, long M) {
            if (A % M == 0)
                return (B / M) - (A / M) + 1;
            return (B / M) - (A / M);
        }

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long a = in.nextLong();
            long b = in.nextLong();
            long x = in.nextLong();
            out.println(countDivisibles(a, b, x));
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}



Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N, M; cin >> N >> M;
    vector<int> A(N);
    vector<pair<int, int>> CB(M);
    for(int i = 0; i < N; i++) cin >> A.at(i);
    for(int i = 0; i < M; i++) {
        int B, C; cin >> B >> C;
        CB.at(i) = make_pair(C, B);
    }
    sort(A.begin(), A.end());
    sort(CB.begin(), CB.end()); reverse(CB.begin(), CB.end());
    
    vector<int> vec;
    for(int i = 0; i < M; i++) {
        for(int j = 0; j < CB.at(i).second; j++) {
            if(vec.size()>N) break;
            vec.push_back(CB.at(i).first);
        }
    }
    
    int i = 0;
    int j = 0;
    while(i < N && j < vec.size()) {
        if(A.at(i) < vec.at(j)) {
            A.at(i) = vec.at(j);
            i++;
        }
        j++;
    }
    
    long long ans = 0;
    for(int i = 0; i < N; i++) ans += A.at(i);
    cout << ans << endl;
}


Measured memory_bytes: 2044
import sys
input = sys.stdin.buffer.readline

def main():
  n, c = map(int, input().split())
  D = [list(map(int, input().split())) for _ in range(c)]
  C = [list(map(int, input().split())) for _ in range(n)]
  A = [[0]*c for _ in range(3)]
  for i in range(n):
    for j in range(n):
      x = C[i][j] - 1
      r = (i+j)%3
      for y in range(c):
        A[r][y] += D[x][y]
  ans = float("inf")
  for i in range(c):
    for j in range(c):
      for k in range(c):
        if i == j or j == k or k == i:
          continue
        temp = A[0][i] + A[1][j] + A[2][k]
        ans = min(ans, temp)
  print(ans)

if __name__ == "__main__":
  main()

Measured memory_bytes: 5236
import fractions

def main():
    a,b,c,d = map(int,input().split())
    a,c = min(a,c),max(a,c)
    b,d = min(b,d),max(b,d)

    c -= a
    a = 0
    d -= b
    b = 0

    if a==c or b==d:
        return 0

    g = fractions.gcd(c,d)
    c//=g
    d//=g
    ct = c+d-1
    return g*ct

if __name__ == '__main__':
    print(main())


Measured memory_bytes: 5304
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int main()
{
    int a,b,c;
    while(~scanf("%d",&a))
    {
        if(a==1)
        {
            printf("Hello World\n");
        }
        else
        {
            scanf("%d%d",&b,&c);
            printf("%d\n",b+c);
        }
    }
    return 0;
}

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

int main()
{
    int n,k,a;
    cin >> n >> k;
    int temp=n;
    while(temp--)
        {
            cin >> a;
        }
    int sum=1;
    if(k<n)
    {
        n=n-k;
        k--;
        sum+=n/k;
        if(n%k!=0)
            sum++;
    }
    cout << sum;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int t[4][14];
    int n, i,j,c;
    char m, d;
    for(i=0; i < 4; i++){
        for(j=0; j < 14; j++){
            t[i][j]=0;
        }
    }
    scanf("%d", &c);
    for(i = 0; i < c; i++){
        scanf("%c", &d);
        scanf("%c %d", &m, &n);
        if(m == 'S')
            t[0][n] = 1;
        else if(m == 'H')
            t[1][n] = 1;
        else if(m == 'C')
            t[2][n] = 1;
        else if(m == 'D')
            t[3][n] = 1;
    }
    for(j=1; j < 14; j++){
        if(t[0][j] != 1){
            printf("S %d\n", j);
        }
    }
  
    for(j=1; j < 14; j++){
        if(t[1][j] != 1){
            printf("H %d\n", j);
        }
    }
    for(j=1; j < 14; j++){
        if(t[2][j] != 1)
            printf("C %d\n", j);
    }
    for(j=1; j < 14; j++){
        if(t[3][j] != 1)
            printf("D %d\n", j);
    }
 return 0;
}


Measured memory_bytes: 2140
import java.util.*;

public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		ArrayDeque<Long> queue = new ArrayDeque<Long>();
		for(int i = 1; i <= 9; i++){
			queue.add((long) i);
		}
		int count = 0;
		long x = 0;
		do{
			x = queue.poll();
			count++;
			if(x % 10 != 0)queue.add(x * 10 + (x % 10) - 1);
			queue.add(x * 10 + (x % 10));
			if(x % 10 != 9)queue.add(x * 10 + (x % 10) + 1);			
		}while(count < N);
		System.out.println(x);
	}
}

Measured memory_bytes: 30036
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
const int mm=1000000007,lim=1005;
int i,j,k,n,m,ans,a[1111];
int main(){
	while (scanf("%d",&n)!=EOF){
		ans=1;
		for (i=1;i<=n;i++) a[i]=i;
		for (i=2;i<=n;i++){
			for (j=1,k=0;j<=n;j++)
			 for (;a[j]%i==0;a[j]/=i) k++;
			ans=(ll)ans*(ll)(k+1)%mm;
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 128
u[]={1,5,10,50,100,500},n[6],i,b,c,m,r,t;main(p,s){for(;scanf(s="%d\n",&p)*p;printf(s,m)){for(i=0;i<6;m=1e9)scanf(s,n+i++);for(b=500;b--;c+=b%5+b/5%2+b/10%5+b/50%2+b/100%5,m=r||c>m?m:c)for(c=0,r=p+b,i=6;i--;r-=t*u[i])t=fmin(r/u[i],n[i]),c+=t;}}

Measured memory_bytes: 0
#include <stdio.h>
#define MAX 101
 
void dfs();
void reVisit(int);
 
int Adj[MAX][MAX];
int d[MAX];
int f[MAX];
int n, time;
 
int main()
{
  int i, j;
  int u, v, k;
 
  scanf("%d", &n);
  for(i = 1; i <= n; i++)
    {
      for(j = 1; j <= n; j++)
    {
      Adj[i][j] = 0;
    }
    }
  for(i = 1; i <= n; i++)
    {
      scanf("%d %d", &u, &k);
      for(j = 1; j <= k; j++)
    {
      scanf("%d", &v);
      Adj[u][v] = 1;
    }
    }
 
  dfs();
 
  for(i = 1; i <= n; i++)
    {
      printf("%d %d %d\n", i, d[i], f[i]);
    }
 
 return 0;
}
 
void dfs()
{
  int i;
 
  time = 0;
 
  for(i = 0; i < n; i++)
    {
      d[i] = 0;
      f[i] = 0;
    }
 
  for(i = 1; i <= n; i++)
    {
      if(d[i] == 0)
    reVisit(i);
    }
}
 
void reVisit(int u)
{
  int i, j;
 
  d[u] = ++time;
 
 
  for(i = 1; i <= n; i++)
    {
      if(Adj[u][i] == 1 && d[i] == 0)
    {
      reVisit(i);
    }
    }
 
  f[u] = ++time;
}

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

#define fr(i,n) _back
#define pb	push_back
#define eb	emplace_back
#define mk	make_pair
#define fi	first
#define se	second
#define endl	'\n'

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<ii> vii;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
const int T = 5e5 + 3;
int seg[4*T];
int n,a,b;
char c;
string s;

void build(int node, int i, int j) {
    if(i == j) seg[node] = (1<<(s[i]-'a'));
    else {
        int mid = (i+j)>>1;
        build(2*node,i,mid);
        build(2*node+1,mid+1,j);
        seg[node] = (seg[2*node] | seg[2*node+1]);
    }
}

void update(int node, int i, int j) {
    if(i > b or j < a) return;
    if(i >= a and j <= b) seg[node] = (1<<(c-'a'));
    else {
        int mid = (i+j)>>1;
        update(2*node,i,mid);
        update(2*node+1,mid+1,j);
        seg[node] = (seg[2*node] | seg[2*node+1]);
    }
}

int query(int node, int i, int j) {
    if(i > b or j < a) return 0;
    if(i >= a and j <= b) return seg[node];
    int mid = (i+j)>>1;
    return (query(2*node,i,mid) | query(2*node+1,mid+1,j));
}

int main() {
    ios_base::sync_with_stdio(false);
    cin >> n >> s;
    s = "#" + s;
    build(1,1,n);
    int q; cin >> q;
    while(q--) {
        int op;
        cin >> op;
        if(op==1) {
            cin >> a >> c;
            b = a;
            update(1,1,n);
        } else {
            cin >> a >> b;
            cout << __builtin_popcount(query(1,1,n)) << endl;
        }
    }
    return 0;
}



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

typedef long long int ll;
typedef vector<long long>lve;
typedef vector<pair<ll,ll> > lvp;
typedef vector<pair<string,ll> > svp;

#define spc        ' '
#define endl       '\n'
#define F          first
#define S          second
#define pp         pop_back
#define PI         2*acos(0)
#define pb         push_back
#define mp         make_pair
#define GCD(x,y)   __gcd(x,y)
#define lb         lower_bound
#define bs         binary_search
#define LCM(x,y)   ((x*y)/__gcd(x,y))
#define btpc       __builtin_popcountll
#define sp(x)      cout<<fixed<<setprecision(x)

const   long long  cs=2e5+5;
const   long long  inf=1e18;
const   long long  mod=1e9+7;
void solve()
{
    ll t,n,n1,m,a,b,c,d,e,i,j,k,x,y,z,cnt=0,cnt1=0;
    bool flag = false;      vector<long long> v,v1;

    cin >> n;
    ll l[n];
    for (auto& i : l)
    cin >> i;   // learn a system
 
    cnt = 0;
    for ( i = 0; i < n; i++) {
        a = l[i];
        for ( j = i + 1; j < n; j++) {
            b = l[j];
            if (a == b)
                continue;
            for ( k = j + 1; k < n; k++) {
                c = l[k];
                if (a == c || b == c)
                    continue;
                if (a + b <= c || b + c <= a || c + a <= b)
                    continue;
                cnt++;
            }         
        }
    }
    cout << cnt;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);    cout.tie(NULL);

    solve();

    return 0;
}


Measured memory_bytes: 3656
/*
LANG:C++
PROB:

*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <iostream>
// #define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)


using namespace __gnu_pbds;
using namespace std;


typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    ordered_set;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
typedef unsigned long long ui64;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
const int mod=1000000007;
  i64 poww(i64 a, i64 b)
  {
    a%=mod;
    i64 res=1;
    while(b)
      {
if(b&1)res=res*a%mod;

      a=a*a%mod;
      b/=2;

      }
      return res;
  }
  i64 inv(i64 a)
  {
    return poww(a,mod-2);
  }
  int s;
  int dp[3000];
  int rec(int x)
  {
  	if(x<3)return 0;
  	
  	int ans=1;
  	if(dp[x]!=-1)return dp[x];

  	for(int i=3;i<=x;i++)
  	{
  		ans+=rec(x-i);
  		ans%=mod;

  	}

  	return dp[x]=ans;
  }
  void solve()
  {

// int s;
cin>>s;
memset(dp,-1,sizeof(dp));
cout<<rec(s);
  }
  
  int main()
  {
ios::sync_with_stdio(false);
    cin.tie(nullptr);
    #ifndef ONLINE_JUDGE
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
    #endif
int t=1;
while(t--)
{
  solve();
}

    return 0;
  }


Measured memory_bytes: 3640
#include <cstdio>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR (i, 0, n)
#define _ << " _ " <<
#define TRACE(x) cerr << #x << " = " << x << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)
//#define debug
//#define TRACE(x)

using namespace std;

typedef long long llint;

const int MAXN = 100010;

int n;
int a[MAXN];
llint sum;

int main(void) {
  scanf("%d",&n);
  REP(i, n) {
    scanf("%d",&a[i]);
    sum += a[i];
  }

  llint t = (llint)n*(n+1)/2;
  if (sum % t) {
    printf("NO\n");
    return 0;
  }
  llint k = sum / t;

  a[n] = a[0];
  REP(i, n) {
    llint x = (a[i+1] - a[i]) % n;
    if (x < 0) x += n;
    if (x != k % n || a[i+1] - a[i] > k) {
      printf("NO\n");
      return 0;
    }
  }

  printf("YES\n");
    
  return 0;
}


Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  int ans = 0;
  while (n) {
    ans += n % 10;
    n /= 10;
  }
  cout << (ans == 1 ? 10 : ans) << endl;
  return 0;
}

Measured memory_bytes: 256
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    sx, sy, tx, ty = list(map(int, readline().split()))
    ans = []
    for j in range(2):
        if j != 0:
            ans.append("D" if tx - sx >= 0 else "U")
            ans.append("R" if tx - sx >= 0 else "L")

        for i in range(abs(tx - sx)):
            ans.append("R" if tx - sx >= 0 else "L")
        for i in range(abs(ty - sy)):
            ans.append("U" if tx - sx >= 0 else "D")

        if j != 0:
            ans.append("U" if tx - sx >= 0 else "D")
            ans.append("L" if tx - sx >= 0 else "R")
            ans.append("U" if tx - sx >= 0 else "D")
            ans.append("L" if tx - sx >= 0 else "R")

        for i in range(abs(tx - sx)):
            ans.append("L" if tx - sx >= 0 else "R")
        for i in range(abs(ty - sy)):
            ans.append("D" if tx - sx >= 0 else "U")

        if j != 0:
            ans.append("D" if tx - sx >= 0 else "U")
            ans.append("R" if tx - sx >= 0 else "L")
    print("".join(ans))


if __name__ == '__main__':
    solve()


Measured memory_bytes: 39152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    int A, B, C, D;
    cin >> A >> B >>C >> D;
    if(A + B > C + D){
        printf("Left\n");
    }
    else if(A + B < C + D){
        printf("Right\n");
    }
    else{
        printf("Balanced\n");
    }
}

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

using namespace std;

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

int main() {
    char str[1112];

    scanf("%s", str);

    int tam = strlen(str);

    if (str[tam-1] == 's')
        printf("%ses\n", str);
    else
        printf("%ss\n", str);

    return 0;
}

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

typedef long long ll;
typedef pair<int,int> P;
int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};
 
int main(){
  int n; 
  cin >> n;
  int ma=-1, mi=1000000009;
  for(int i=0; i<n; i++){
    int a; cin >> a;
    ma = max(ma, a);
    mi = min(mi, a);
  }
  int ans = ma - mi;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
  #include<math.h>
  using namespace std;
  int main()
  {
    int N,A;
    cin>>N>>A;
    int remain = N % 500;
    if (remain <= A) {
      puts("Yes");
    }
    else {
      puts("No");
    }
    return 0;
  }


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//s[i]-'0'でchar文字→int数に;
//string s = to_string(int数);
//int n = stoi(string文字列)
//実行時間制約2秒では２×10^8回くらいまで計算できる


int main() {
  int n;
  string s;
  cin >> n >> s;
 
  int ans = 0;
  repo(i,n) {
    int cnt = 0;
    set<char> x;
    set<char> y;
    rep(j,i) {
    x.insert(s[j]);
    }
    rep(j,n-i) {
    y.insert(s.substr(i,n-i).at(j));
    }
    for(auto value : x) {
      if(y.count(value)) cnt++;
    }
    ans = max(ans,cnt);
  }
  cout << ans << endl;
}

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

int main(void) {
    int i,n;
    vector<int> F(N);
    cin >> n;
    F.resize(n);
    F[0] = 1;
    F[1] = 1;
    for(i=2;i<=n;i++){
        F[i] = F[i-2] + F[i-1];
    }
    cout << F[n] << endl;
    return 0;
}

Measured memory_bytes: 1196
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
using std::ostream;

#include <list>
using std::list;

#include <cstring>
using std::string;
using std::strlen;

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

    list <int> L;
    string op;
    int x;

    for (int i = 0; i < n; ++i) {
        cin >> op;

        if(op[0] == 'i'){
            cin >> x;
            L.push_front(x);
        }else if(op[0] =='d'){
            if (strlen(op.c_str()) > 6){
                if (op[6] == 'F') L.pop_front();
                else if (op[6] == 'L') L.pop_back();
            }
            else{
                cin >> x;
                for(auto it=L.begin(); it !=L.end(); it++){
                    if(*it == x){
                        L.erase(it);
                        break;
                    }
                }
            }
        }
    }

    for (auto it=L.begin(); it != L.end(); it++){
        if(it != L.begin()) cout << " ";
        cout << *it;
    }
    cout << endl;

}




Measured memory_bytes: 34372
def sum(x):
  return x*(x+1)/2

n=int(input())
total =sum(n)
three=int(n/3)
five=int(n/5)
fifteen=int(n/15)
three=sum(three)*3
five=sum(five)*5
fifteen=sum(fifteen)*15
print(int(total-three-five+fifteen))

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

def main():
  n = int(input())
  ball = [tuple(map(int, input().split())) for i in range(n)]

  ans = n
  for i in range(n):
    for j in range(n):
      p, q = ball[i][0] - ball[j][0], ball[i][1] - ball[j][1]
      par = [-1]*n
      node = [[] for i in range(n)]
      for s in range(n):
        for t in range(n):
          x, y = ball[s][0] - ball[t][0], ball[s][1] - ball[t][1]
          if x == p and y == q:
            node[s].append(t)
            node[t].append(s)
      already = [False]*n
      count = 0
      for k in range(n):
        if already[k]:
          continue
        count += 1
        already[k] = True
        not_yet = deque([k])
        while not_yet:
          key = not_yet.pop()
          for v in node[key]:
            if already[v]:
              continue
            already[v] = True
            not_yet.append(v)
      if ans > count:
        ans = count
  print(ans)

  
main()

Measured memory_bytes: 9416
#include <bits/stdc++.h>
#include <iostream>
#include<stdio.h>
#include<math.h>
#include<string.h>
using namespace std;

int main() {
	int t,n,i,j,k,l,a,b,c,d;
//	int a[100001];
	char s[100001];
	vector<int> v;
	scanf("%s",s);
	if(s[strlen(s)-1]=='s')
	{
	    printf("%s",s);
	    printf("es");
	}
	else
	{
	printf("%s",s);
	printf("s");
	}
	return 0;
}


Measured memory_bytes: 3752
fn main() {
    let mut sc = Scanner::new();
    let n = sc.usize_read();
    let x: i64 = sc.read();
    let xx: Vec<i64> = sc.read_vec(n);
    let mut v = vec![];
    for &xx in xx.iter() {
        v.push((x - xx).abs());
    }

    let mut g = v[0];
    for i in 1..n {
        g = gcd(g, v[i]);
    }
    println!("{}", g);
}

fn gcd(a: i64, b: i64) -> i64 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}

struct Scanner {
    ptr: usize,
    length: usize,
    buf: Vec<u8>,
    small_cache: Vec<u8>,
}

#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner {
        Scanner {
            ptr: 0,
            length: 0,
            buf: vec![0; 1024],
            small_cache: vec![0; 1024],
        }
    }

    fn load(&mut self) {
        use std::io::Read;
        let mut s = std::io::stdin();
        self.length = s.read(&mut self.buf).unwrap();
    }

    fn byte(&mut self) -> u8 {
        if self.ptr >= self.length {
            self.ptr = 0;
            self.load();
            if self.length == 0 {
                self.buf[0] = b'\n';
                self.length = 1;
            }
        }

        self.ptr += 1;
        return self.buf[self.ptr - 1];
    }

    fn is_space(b: u8) -> bool {
        b == b'\n' || b == b'\r' || b == b'\t' || b == b' '
    }

    fn read_vec<T>(&mut self, n: usize) -> Vec<T>
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        (0..n).map(|_| self.read()).collect()
    }

    fn usize_read(&mut self) -> usize {
        self.read()
    }

    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        let mut b = self.byte();
        while Scanner::is_space(b) {
            b = self.byte();
        }

        for pos in 0..self.small_cache.len() {
            self.small_cache[pos] = b;
            b = self.byte();
            if Scanner::is_space(b) {
                return String::from_utf8_lossy(&self.small_cache[0..(pos + 1)])
                    .parse()
                    .unwrap();
            }
        }

        let mut v = self.small_cache.clone();
        while !Scanner::is_space(b) {
            v.push(b);
            b = self.byte();
        }
        return String::from_utf8_lossy(&v).parse().unwrap();
    }
}


Measured memory_bytes: 6396
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int n, t; cin >> n >> t;
    VI a(n), b(n);
    FOR(i, 0, n)cin >> a[i] >> b[i];

    auto dp = vec<int>(n + 1, t, 2);
    FOR(i, 0, n)FOR(j, 0, t) {
        FOR(k, 0, 2) {
            chmax(dp[i + 1][j][k], dp[i][j][k]);
            if (j + a[i] < t)chmax(dp[i + 1][j + a[i]][k], dp[i][j][k] + b[i]);
        }
        chmax(dp[i + 1][j][1], dp[i][j][0] + b[i]);
    }

    int ans = 0;
    FOR(j, 0, t)FOR(k, 0, 2)chmax(ans, dp[n][j][k]);
    cout << ans << "\n";
}

Measured memory_bytes: 492928
using System;
using static System.Console;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
      int n = int.Parse(ReadLine());
      if (n%1000==0)
      {
        WriteLine(0);
      }
      else
      {
        WriteLine(1000-n%1000);
      }
      
      
      
    }
}

Measured memory_bytes: 27528
#include <bits/stdc++.h>
using namespace std;
#define PI 3.141592653589793
#define MOD 1000000007
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(v) v.begin(), v.end()

typedef long long ll;
typedef long double ld;


int main() {
    ll N, D;
    cin >> N >> D;
    ll ans = 0;
    rep(i,N){
        ll tmp1, tmp2;
        cin >> tmp1 >> tmp2;
        if(tmp1 * tmp1 + tmp2 * tmp2 <= D * D){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
# 点数計算
def scoring(last_, c, s, t, d, score):
    # score += s[d][t[d]-1]
    score = s[d][t]
    k = 8
    
    for i in range(len(c)):
        # score -= c[i] * (d+1 - last_[d][i])
        # score -= c[i] * (d + 1 - last_[i])
        score -= k * c[i] * (d + 1 - last_[i]) + (k * (k+1)) / 2
    return score


# input
score = 0
D = int(input())
c = [int(i) for i in input().split()]
s = []
for i in range(D):
    s.append([int(i) for i in input().split()])
# t = []
# for i in range(D):
#     t.append(int(input()))
last = [[0 for i in range(len(c))] for j in range(D+1)] # last[d][i]

ans = []
for d in range(D):
    # last[d][t[d]-1] = d+1
    last_dummy = last[d][:]
    score = 0
    t_d = 0
    for t in range(len(c)):
        last_dummy2 = last_dummy[:]
        last_dummy2[t] = d+1
        if score < scoring(last_dummy2, c, s, t, d, score):
            score = scoring(last_dummy2, c, s, t, d, score)

            t_d = t

    ans.append(t_d)
    last[d][t_d] = d+1


    # last更新
    for i in range(len(c)):
        last[d+1][i] = last[d][i]


[print(ans[i]+1) for i in range(D)]





Measured memory_bytes: 9584
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define RFOR(i,a,b) for(int i=(b-1); i>=(a); i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
using ll = long long;
using D = double;
using LD = long double;
using P = pair<int, int>;
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 main(){
    int n,m; ll k; cin >> n >> m >> k;
    vector<ll> a(n), b(m);
    rep(i,n) cin >> a[i];
    rep(i,m) cin >> b[i];
    int ans = 0;
    vector<ll> sa(n+1), sb(m+1);
    rep(i,n) sa[i+1] = sa[i] + a[i];
    rep(i,m) sb[i+1] = sb[i] + b[i];

    rep(i,n+1){
        if(sa[i] > k) break;
        int cnt = 0;
        if(k - sa[i] >= sb[m]) cnt = m;
        else cnt = upper_bound(ALL(sb), k - sa[i]) - sb.begin() -1;
        chmax(ans, i + cnt);
    }

    cout << ans << endl;
}


Measured memory_bytes: 9576
H,W,D=map(int,raw_input().split())
C={}
for i in range(H):
	A=map(int,raw_input().split())
	cnt=1
	for j in A:
		C[j]=(i+1,cnt)
		cnt+=1

dist=[ 0 for i in range(H*W+1) ]

for i in range(1,H*W+1):
	if i<=D:
		continue
	dist[i]=dist[i-D]+abs(C[i-D][0]-C[i][0])+abs(C[i-D][1]-C[i][1])
	

Q=input()
for i in range(Q):
	L,R=map(int,raw_input().split())
	print dist[R]-dist[L]


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

int main(){
  ll h,n;
  cin>>h>>n;
  ll a[n];
  ll sum=0;
  for(int i=0; i<n; i++){
    cin >>a[i];
    sum+=a[i];
  }
  
  if(sum>=h) cout << "Yes"<< endl;
  else cout << "No" << endl;
  
  
}

Measured memory_bytes: 1024
n, x = gets.chomp.split.map{|e| e.to_i}
cands = gets.chomp.split.map{|e| e.to_i}


c = 0
(0..(n - 1)).each do |i|
  dif = cands[i] - x
  if dif > 0
    cands[i] = x
    c += dif
  end
end


( 1..(n - 1) ).each do |i|
  sum = cands[i - 1] + cands[i]
  dif = sum - x
  if dif > 0
    cands[i] -= dif
    c += dif
  end
end

print c

   

Measured memory_bytes: 9604
#include<stdio.h>
int main(void){
    while(1){
        char gengou[10]; int y,m,d;
        scanf("%s",gengou);
        if(gengou[0]=='#') break;
        scanf("%d%d%d",&y,&m,&d);
        if((y==31&&m>=5)||y>=32){
            printf("? %d %d %d\n",y-30,m,d);
        }
        else{
            printf("%s %d %d %d\n",gengou,y,m,d);
        }
    }
}



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

using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); ++i)
double const PI = 3.1415926535897932384626433;
using P = pair<int, int>;

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

Measured memory_bytes: 3636
h, n = map(int, input().split())
a, b = [], []
for _ in range(n):
    i, j = map(int, input().split())
    a.append(i)
    b.append(j)

# DP
l = [0]
for i in range(1,h+1):
    cand = []
    for j in range(n):
        if i - a[j] >= 0 and l[i - a[j]] != 'none':
            cand.append(l[i - a[j]] + b[j])
    if cand == []:
        l.append('none')
    else:
        l.append(min(cand))
for i in range(h+1, h+max(a)):
    cand = []
    for j in range(n):
        if 0 <= i - a[j] < h and l[i - a[j]] != 'none':
            cand.append(l[i - a[j]] + b[j])
    if cand == []:
        l.append('none')
    else:
        l.append(min(cand))
l = l[h:]
l = [i for i in l if type(i) == int]
print(min(l))

Measured memory_bytes: 44408
#include<cstdio>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;

struct union_find{
  int par[10000],rank[10000];
  union_find(int n){
    for(int i=0;i<n;i++){
      par[i] = i;
      rank[i] = 1;
    }
  }
  int find(int x){
    if(par[x]==x) return x;
    else return par[x] = find(par[x]);
  }
  void unite(int x,int y){
    x = find(x);
    y = find(y);
    if(x==y) return;
    if(rank[x]>rank[y]) par[y] = x;
    else{
      if(rank[x]==rank[y]) rank[y]+=rank[x];
      par[x] = y;
    }
  }
  bool same(int x,int y){return find(x)==find(y);}
};

int main(){
  int v,e;
  scanf("%d %d",&v,&e);
  union_find uf(v);
  vector<pair<int,pair<int,int> > > E;
  for(int i=0;i<e;i++){
    int s,t,w;
    scanf("%d %d %d",&s,&t,&w);
    E.push_back(make_pair(w,make_pair(s,t)));
  }
  sort(E.begin(),E.end());
  int ans = 0;
  //bool used[v];
  //fill(used,used+v,false);
  for(int i=0;i<E.size();i++){
    int s = E[i].second.first;
    int t = E[i].second.second;
    int w = E[i].first;
    if(!uf.same(s,t)){
      ans+=w;
      uf.unite(s,t);
    }
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 4080
#include <iostream>
#include <deque>

using namespace std;

typedef long long LL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define PB push_back
#define TARO 0
#define JIRO 1

LL dp[3000][3000]; // dp[i][j] : i番目からj番目まででのX-Yの値
LL solve(int turn, deque<LL>& A, int i, int j) {
  if (dp[i][j] != -1)
    return dp[i][j];
  if (A.size() == 0)
    return 0;
  if (A.size() == 1)
    return (turn == TARO ? 1 : -1) * A.front();
  LL front = A.front(),
    back = A.back();
  A.pop_front();
  LL res = solve(1 - turn, A, i + 1, j) + (turn == TARO ? 1 : -1) * front;
  A.push_front(front);
  A.pop_back();
  LL res2 = solve(1 - turn, A, i, j - 1) + (turn == TARO ? 1 : -1) * back;
  A.push_back(back);
  if (turn == TARO)
    return dp[i][j] = res > res2 ? res : res2;
  return dp[i][j] = res < res2 ? res : res2;
}

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

  deque<LL> A;
  for (int i = 0; i < N; ++i) {
    LL a;
    cin >> a;
    A.PB(a);
  }
  REP(i, 3000)
    REP(j, 3000)
    dp[i][j] = -1; // dp[i][j] : i番目からj番目まででのX-Yの値
  cout << solve(TARO, A, 0, N - 1) << endl;
  return 0;
}


Measured memory_bytes: 70912
using System;

class main{
	static void Main(){
		string[] str = Console.ReadLine().Trim().Split(' ');
		int A = int.Parse(str[0]);
		int B = int.Parse(str[1]);
		int K = int.Parse(str[2]);
		if((B - A + 1) <= 2 * K){
			for(int i = A; i <= B; i++){
				Console.WriteLine(i);
			}
		}else{
			for(int i = A; i < A + K; i++){
				Console.WriteLine(i);
			}
			for(int i = B - K + 1; i <= B; i++){
				Console.WriteLine(i);
			}
		}
	}
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
ll a;
ll h,n;
int main()
{
    cin>>h>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a;
        h-=a;
    }
    if(h<=0)
    cout<<"Yes\n";
    else
    cout<<"No\n";
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void debug(String str){
        boolean debug = false;
        if(debug != true){
            return;
        }
        System.out.println(str);
    }
    public static void main(String[] args) {

        int N;
        int X;
        int[] listL;

        try (Scanner sc = new Scanner(System.in)) {
            N = sc.nextInt();
            X = sc.nextInt();
            listL = new int[N];
            for(int i = 0;i < N;i++){
                listL[i] =  sc.nextInt();
            }
        }
        int d = 0;
        int bound = 0;
        for(int l : listL){
            d += l;
            bound++;
            if(d>X){
                break;
            }
        }
        if(d <= X){
            bound++;
        }
        System.out.println(bound);


    }


}


Measured memory_bytes: 23380
#include<stdio.h>
int main(void)
{
	int x,a,b;
	scanf("%d %d %d",&x,&a,&b);
	if(a>=b) printf("delicious\n");
	if(a<b){
		if(b-a<=x) printf("safe\n");
		else printf("dangerous\n");
	}
	return 0;
}	

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
// const lint MOD = 998244353;
int x_pos[4] = {1,0,-1,0}, y_pos[4] = {0,1,0,-1};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
char upper(char c){
	return c-0x20;
}
char lower(char c){
	return c+0x20;
}

int gcd(int x, int y) {
  if (y == 0) return x;
  return gcd(y, x%y);
}

int main(){
	int n; cin>>n;
	ll y; cin>>y;
	rep(i,n+1){
		rep(j,n+1){
			if (i+j>n) break;
			if (10000*i+5000*j+1000*(n-i-j)==y){
				cout << i << " " << j << " " << n-i-j << endl;
				return 0;
			}
		}
	}
	cout << -1 << " " << -1 << " " << -1 << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] k = sc.next().toCharArray();
		char[] g = sc.next().toCharArray();
		StringBuilder sb = new StringBuilder();
		for(int i = 0; i < g.length; i++) {
			sb.append(k[i]).append(g[i]);
		}
		if(k.length - g.length == 1) {
			sb.append(k[k.length-1]);
		}
		System.out.println(sb);
	}
}


Measured memory_bytes: 21972
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;

typedef long long int64;

const int mod = 1000000007;
struct mint {
    long long x;
    explicit mint(const long long x=0) : x(x%mod) {}

    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) { return (*this) *= a.inv();}
    mint operator+(const mint a) const { mint res(*this); return res+=a; }
    mint operator-(const mint a) const { mint res(*this); return res-=a; }
    mint operator*(const mint a) const { mint res(*this); return res*=a; }
    mint operator/(const mint a) const {mint res(*this); return res/=a;}
    mint inv() const { return pow(mod-2);}
    friend ostream& operator<<(ostream &os, const mint a) noexcept { return os << a.x; }
    constexpr bool operator == (const mint& r) const noexcept { return this->x == r.x; }
    constexpr bool operator != (const mint& r) const noexcept { return this->x != r.x; }
    mint pow(long long t) const {
        if (!t) return mint(1);
        mint a = pow(t>>1);
        a*=a;
        if(t&1) a*= *this;
        return a;
    }
};


//mint frac(long long n) {mint res(1); for (int i=1;i<=n;i++)res*=mint(i);return res;}

struct combination {
    vector<mint> fact, ifact;

    // コンストラクタ
    combination(int64 n):fact(n+1),ifact(n+1) {
        fact[0] = mint(1);
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*mint(i);
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*mint(i);
    }

    mint nCr(int64 n, int64 r) {
        if (r < 0 || r > n) return mint(0);
        return fact[n]*ifact[r]*ifact[n-r];
    }
    mint nPr(int64 n, int64 r) {
        if (r < 0 || r > n) return mint(0);
        return fact[n]*ifact[n-r];
    }
} comb(100010);

int main() {
    int64 n,k;
    cin >> n >> k;
    vector<int64> a(n);
    for (int64 i=0; i<n; i++) cin >> a[i];
    sort(a.begin(), a.end());

    mint ans(0);

//    mint minSum(0);
//    mint maxSum(0);
    for (int64 i=0; i<n; i++) {
        ans += mint(a[i]) * comb.nCr(i,k-1) - mint(a[i]) * comb.nCr(n-i-1,k-1);
//        minSum += mint(a[i]) * comb.nCr(n-i-1, k-1);
//        maxSum += mint(a[i]) * comb.nCr(n, k-1);
    }

//    reverse(a.begin(), a.end());
//    for (int64 i=0; i<n; i++) {
//        maxSum += mint(a[i]) * comb.nCr(n-i-1, k-1);
//    }

//    mint ans = maxSum - minSum;
    cout << ans << endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<double> v(N+1);
  for(int i=0;i<N;i++){
    cin>> v[i];
  }
  sort(v.begin(),v.end());
//cout<<v[0]<<endl;
  for(int i=1;i<N;i++){
    v[i+1] = (v[i+1]+v[i])/2;
   // cout<<v[i+1]<<endl;
  }
  cout<<v[N]<<endl;
  //priority_queue<int> que;
  //for(int i=M-1;i>=0;i--){
//    for(int j:v[i]) que.push(j);
//  }



}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
  ll A, B, C;
  cin >> A >> B >> C;
  if(A == B && A == C && A % 2 == 0) {
    cout << -1 << endl;
  }
  else {
    int count = 0;
    while(A % 2 == 0 && B % 2 == 0 && C % 2 == 0) {
      ll a = A, b = B, c = C;
      A = b / 2 + c / 2;
      B = c / 2 + a / 2;
      C = a / 2 + b / 2;
      count++;
    }
    cout << count << endl;
  }
}

Measured memory_bytes: 3528
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, a, b;
    long long maxt = 0, maxa = 0;
    cin >> n;
    vector<int> sum(n);
    for(int i = 0; i < n; i++)
	{
        cin >> a >> b;
        sum.at(i) = a + b;
        maxt += b;
    }
    sort(sum.begin(), sum.end(), greater<int>());
    for(int i = 0; i < n; i++)
	{
        if(i % 2 == 0)
        maxa += sum.at(i);
    }
    cout << maxa - maxt << endl;
    return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define ALL(v) v.begin(), v.end()

ll A, B, K;

int main() {
    cin >> A >> B >> K;
    ll k = min(A, K);
    A -= k;
    K -= k;
    B -= min(B, K);
    cout << A << " " << B << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string s;
int main(){
	cin>>s;
	for(int i=0;i<s.length();i++){
		if(s[i]=='C'){
			for(int j=i+1;j<s.length();j++){
				if(s[j]=='F')return not printf("Yes");
			}
		}
	}
	cout<<"No";
	return 0;
}


Measured memory_bytes: 256
a = input()
b = input()

len_a = len(a)
len_b = len(b)

if len_a > len_b:
    print('GREATER')
elif len_a < len_b:
    print('LESS')
else:
    if a > b:
        print('GREATER')
    elif a < b:
        print('LESS')
    else:
        print('EQUAL')

Measured memory_bytes: 8984
#include <bits/stdc++.h>
using namespace std;
#define MD 1000000007
#define INF 1000000000
typedef long long int ll;
typedef pair<ll, ll> P;
template <typename T>
std::string tostr(const T &t)
{
    std::ostringstream os;
    os << t;
    return os.str();
}
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int main()
{
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; i++)
    {
        cin >> v[i];
    }
    map<int, int> mp;
    for (int i = 0; i < n; i++)
    {
        if (!mp.count(v[i]))
        {
            mp[v[i]] = 1;
        }
        else
        {
            mp[v[i]]++;
        }
    }
    int cnt = 0;
    for (auto itr = mp.begin(); itr != mp.end(); ++itr)
    {
        if (itr->second <= 1)
        {
            continue;
        }
        else if (itr->second % 2 == 0)
        {
            cnt++;
        }
    }
    if (cnt % 2 == 0)
    {
        cout << mp.size() << endl;
    }
    else
    {
        cout << mp.size() - 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 5376
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int size(char *s);

int main() {
	char s[11], suti[4];
	char *sp;
	int i, a = 0, b = 753, min = 999;

	scanf("%s", &s);

	sp = &s[0];

	for (i = 0; i < size(sp); i++) {
		suti[0] = s[i];
		suti[1] = s[i + 1];
		suti[2] = s[i + 2];
		suti[3] = '\0';
		a = atoi(suti);

		if (abs(b - a) <= min) min = abs(b - a);
	}

	printf("%d\n", min);

	return 0;
}

int size(char *p) {
	int n = 0;

	while (*p != '\0') {
		n++;
		p++;
	}

	return n - 2;
}

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

int main(){
    int H, W; cin >> H >> W;
    vector<string> fi(H);
    for(int i = 0; i < H; i++) cin >> fi[i];

    int left[2000][2000], right[2000][2000], up[2000][2000], down[2000][2000];

    for(int i = 0; i < H; i++){
        int cur = 0;
        for(int j = 0; j < W; j++){
            if(fi[i][j] == '#') cur = 0;
            else cur++;
            left[i][j] = cur;
        }
    }

    for(int i = 0; i < H; i++){
        int cur = 0;
        for(int j = W - 1; j >= 0; j--){
            if(fi[i][j] == '#') cur = 0;
            else cur++;
            right[i][j] = cur;
        }
    }

    for(int j = 0; j < W; j++){
        int cur = 0;
        for(int i = 0; i < H; i++){
            if(fi[i][j] == '#') cur = 0;
            else cur++;
            up[i][j] = cur;
        }
    }

    for(int j = 0; j  < W; j++){
        int cur = 0;
        for(int i = H - 1; i >= 0; i--){
            if(fi[i][j] == '#') cur = 0;
            else cur++;
            down[i][j] = cur;
        }
    }

    int res = 0;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if(fi[i][j] == '#') continue;
            res = max(res, left[i][j] + right[i][j] + up[i][j] + down[i][j] - 3);
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 66816
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <string.h>
using namespace std;

int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    int x;
    x=(b-a)*(b-a+1)/2-b;
    printf("%d",x);
    return 0;
}


Measured memory_bytes: 256
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
s = min(a) + min(b)

c_min = 200001
for _ in range(M):
    x, y, c = map(int, input().split())
    c_min = min(c_min, a[x-1] + b[y-1] - c)

result = min(s, c_min)
print(result)

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

void out(ll x, ll y){ cout << x << " " << y << endl;}
int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    ll sm = 0;
    for(int i=0;i<n;i++){
        cin >> a[i];
        sm += abs(a[i]);
    }
    sort(a.begin(),a.end());
    if(a[0] < 0 && a[n-1] > 0){
        // マイナスの物はn-1に, プラスの物は0と演算することで絶対値の総和が解
        cout << sm << endl;
    }else{
        // 全符号が同じなら最小値分差っ引く
        if(a[0] < 0) cout << sm - 2*abs(a[n-1]) << endl;
        else cout << sm - 2*abs(a[0]) << endl;
    }
    for(int i=1;i<n-1;i++){
        if(a[i] < 0){
            out(a[n-1], a[i]);
            a[n-1] -= a[i];
        }else{
            out(a[0], a[i]);
            a[0]  -= a[i];
        }
    }
    out(a[n-1], a[0]);
}

Measured memory_bytes: 2304
import math
A,B,H,M = map(int,input().split())

tanshin_kakudo = (360/12) * H + (360/12)/60 * M
tyoushin_kakudo = (360/60) * M
kakudo_sub = abs(tanshin_kakudo-tyoushin_kakudo)
print(math.sqrt((A**2)+(B**2)-2*A*B*math.cos(math.radians(kakudo_sub))))

Measured memory_bytes: 9416