akhauriyash/Code-Regression huggingface dataset:
import sys
import math
import fractions
import itertools
from collections import deque
import copy
import bisect

MOD = 10 ** 9 + 7
INF = 10 ** 18 + 7
input = lambda: sys.stdin.readline().strip()


def judge_prime_num(n):
    if n % 2 == 0:
        return True
    else:
        for num in range(3, int(math.sqrt(n) + 2)):
            if n % num == 0:
                return False
        return True


Q = int(input())
primes = [2]
checker = []
for i in range(3, 10 ** 5 + 1, 2):
    if judge_prime_num(i) is True:
        primes.append(i)
set_primes = set(primes)
for i in primes:
    if (i+1)//2 in set_primes:
        checker.append(i)
for i in range(Q):
    l, r = map(int,input().split())
    print(bisect.bisect_right(checker, r) - bisect.bisect_left(checker, l))


Measured memory_bytes: 6992
def main():
    n, k = [int(e) for e in input().split()]
    H = [int(input()) for i in range(n)]

    H = sorted(H)

    ans = float('inf')
    for ki in range(n - k + 1):
        diff = H[ki + k - 1] - H[ki]
        ans = min(diff, ans)

    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 51032
#include<stdio.h>
int main(){
  int N,i,j,A[1000],key;
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }
    for(i=0;i<=N-1;i++){
      key=A[i];
      j=i-1;
      while(j>=0&&A[j]>key){
	A[j+1]=A[j];
	j=j-1;
      }
      A[j+1]=key;
      for(j=0;j<N-1;j++){
	printf("%d ",A[j]);
      }
      printf("%d\n",A[j]);
    }
    return 0;
}



Measured memory_bytes: 2056
#include<bits/stdc++.h>
#define ll long long int
#define ve vector<int>
#define vl vector<long long int>
#define vs vector<string>
#define vve vector<vector<int>>
#define all(a) a.begin(),a.end()
using namespace std;

int main(){
  ll n;
  cin>>n;
  vl a(n);
  bool A=true;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  sort(all(a));
  for(int i=1;i<n;i++){
    if(a[i-1]==a[i]) A=false;
  }
  if(A) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

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

#define int long long
#define sp ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define cps CLOCKS_PER_SEC
#define mod (int)(1000000007)
#define f first
#define s second
#define debug1(x) cerr<<x<<"\n"
#define debug2(x,y) cerr<<x<<" "<<y<<"\n"
#define debug3(x,y,z) cerr<<x<<" "<<y<<" "<<z<<"\n"
#define nl cerr<<"\n";
#define pq priority_queue
#define inf 9999999999999999
#define test cerr<<"abcd\n";
#define pi pair<int,int>
#define pii pair<int,pi>
#define pb push_back
#define mxn 200005
#define mxnn 2000005
int32_t main(){
sp;
int n,k;
cin >>n>>k;
int mat[n+1][n+1];
for(int i = 1;i<=n;i++) for(int j = 1;j<=n;j++) cin >>mat[i][j];
int unit[n+1][n+1];
memset(unit,0,sizeof unit);
for(int i = 1;i<=n;i++) unit[i][i] = 1;
int ans[n+1][n+1];
for(int i = 0;i<=n;i++) for(int j = 0;j<=n;j++) ans[i][j] = unit[i][j];
while(k){
    if(k&1){
        int c[n+1][n+1];
        memset(c,0,sizeof c);
        for(int i = 1;i<=n;i++){
            for(int j = 1;j<=n;j++){
                int x = 0;
                for(int k = 1;k<=n;k++){
                    x = (x+ans[i][k]*mat[k][j])%mod;
                }
                c[i][j] = x;
            }
        }
        for(int i = 1;i<=n;i++) for(int j = 1;j<=n;j++) ans[i][j] = c[i][j];
    }
        int c[n+1][n+1];
        memset(c,0,sizeof c);
        for(int i = 1;i<=n;i++){
            for(int j = 1;j<=n;j++){
                int x = 0;
                for(int k = 1;k<=n;k++){
                    x = (x+mat[i][k]*mat[k][j])%mod;
                }
                c[i][j] = x;
            }
        }
        for(int i = 1;i<=n;i++) for(int j = 1;j<=n;j++) mat[i][j] = c[i][j];
    k>>=1;
}
int sum =  0;
for(int i = 1;i<=n;i++) for(int j = 1;j<=n;j++) sum = (sum+ans[i][j])%mod;
cout<<sum;
return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<pair<ll,ll>> vp;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define reep(i,n) for(ll i = n; i >-1; i--)
#define deb(variable) cout<<#variable<<"="<<variable<<endl
#define MMOD(i) ((i%MOD)+MOD)%MOD;
#define vec(i,j) vector<vector<ll>>(i,vector<ll>(j,0))
const ll INF=99999999999999999;
const ll MOD=128;
const ll MAX_N=500010;
ll a,b,c,d,e,x,y,z,k,m,n,l,q,ans=0;
vl v(100010,0),anss(100010,0);
vp p[100010];
string s;
ll solve(void){
    return 0;
}
int main(){
    cin>>n>>k>>s;
    s[k-1]-=('A'-'a');
    cout<<s<<endl;
}

Measured memory_bytes: 4096
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    A, op, B = input().split()
    if op=='+':
        print(int(A)+int(B))
    else:
        print(int(A)-int(B))


if __name__ == '__main__':
    main()


Measured memory_bytes: 9096
#include <stdio.h>

int main(void)
{
	int a, b, sum = 0, digit = 0;
	
	while(scanf("%d %d", &a, &b) != EOF){
	
		sum = a + b;
		
		while(sum != 0){
			sum = sum / 10;
			digit++;
		}
		
		printf("%d\n", digit);
		
		digit = 0;
	}
	return 0;
}

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

int main() {
	int64_t n, m; cin >> n >> m;
	int64_t a[n]; for(int i = 0; i < n; ++i) cin >> a[i];
	int64_t imos[2 * m + 1] = {};
	vector<int> v[m + 1];
	for(int i = 1; i < n; ++i) {
		v[a[i]].push_back(i);
		if(a[i - 1] < a[i]) {
			++imos[a[i - 1] + 2];
			--imos[a[i] + 1];
		} else {
			++imos[a[i - 1] + 2];
			--imos[a[i] + 1 + m];
		}
	}
	for(int i = 1; i <= 2 * m; ++i) {
		imos[i] += imos[i - 1];
	}
	int64_t ans[m + 1] = {};
	for(int i = 1; i < n; ++i) {
		if(a[i - 1] < a[i]) {
			ans[1] += a[i] - a[i - 1];
		} else {
			ans[1] += a[i];			
		}
	}
	for(int i = 2; i <= m; ++i) {
		ans[i] = ans[i - 1];
		ans[i] -= imos[i] + imos[i + m];
		for(int j : v[i - 1]) {
			if(a[j - 1] < a[j]) {
				ans[i] += a[j] - a[j - 1] - 1;
			} else {
				ans[i] += (a[j] + m) - a[j - 1] - 1;
			}
		}
	}
	int64_t anss = 1e18;
	for(int i = 1; i <= m; ++i) {
		anss = min(anss, ans[i]);
	}
	cout << anss << '\n';
	return 0;
}

Measured memory_bytes: 8064
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 998244353;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-9;

ll modadd(ll x, ll y) {
    return ((x + y) % mod + mod) % mod;
}

ll modminus(ll x, ll y) {
    return (x - y + mod) % mod;
}

ll multiply(ll x, ll y) {
    return (x % mod) * (y % mod) % mod;
}

ll modpower(ll x, ll y) {
    if (y == 0) {
        return 1;
    } else if (y == 1) {
        return x % mod;
    } else if (y % 2 == 0) {
        ll p = modpower(x, y / 2);
        return p * p % mod;
    } else {
        ll p = modpower (x, y / 2);
        return (p * p) % mod * (x % mod) % mod;
    }
}

ll matrixrank(vector< vector<ll> > mat) {
    ll h = mat.size();
    ll w = mat[0].size();
    ll now = 0;
    for (ll i = 0; i < w; i++) {
        ll pivot = -1;
        for (ll j = now; j < h; j++) {
            if (mat[j][i] != 0) {
                pivot = j;
                break;
            }
        }
        if (pivot == -1) {
            continue;
        }
        if (pivot != now) {
            swap(mat[now], mat[pivot]);
        }
        // for (ll j = i + 1; j < w; j++) {
        //     mat[now][j] /= mat[now][i];
        // }
        for (ll j = now + 1; j < h; j++) {
            if (mat[j][i]) {
                for (ll k = i + 1; k < w; k++) {
                    mat[j][k] ^= mat[now][k];
                }
            }
        }
        now++;
        if (now == h) {
            break;
        }
    }
    return now;
}

int main() {
    ll N, M;
    cin >> N >> M;
    ll a[N][M];
    REP(i, 0, N) {
        REP(j, 0, M) {
            cin >> a[i][j];
        }
    }
    vector< vector<ll> > mat(N);
    REP(i, 0, N) {
        mat[i].resize(M);
        REP(j, 0, M) {
            mat[i][j] = a[i][j];
        }
    }
    ll rank = matrixrank(mat);
    // cout << rank << endl;
    ll ans = modminus(modpower(2, N + M - 1), modpower(2, N + M - rank - 1));
    cout << ans << endl;
}


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

using namespace std;

vector< vector<int> >dp(100001, vector<int>(3,-1));
int dfs(vector< vector<int> >&nums, int i, int ac){
    if(i==nums.size()) return 0;
    
    if(dp[i][ac]!=-1) return dp[i][ac];
    
     int taken;
         if(ac==0) taken = max(dfs(nums,i+1,1) + nums[i][1], dfs(nums,i+1,2)+ nums[i][2]);
        else if(ac==1) taken = max(dfs(nums,i+1,0) + nums[i][0], dfs(nums,i+1,2)+ nums[i][2]);
        else taken = max(dfs(nums,i+1,0) + nums[i][0], dfs(nums,i+1,1)+ nums[i][1]);

dp[i][ac]= taken;
    return taken;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n; cin>>n; 
    vector< vector<int> >nums(n, vector<int>(3) );
    dp.assign(100001, vector<int>(3,-1));
    for(int i=0; i<n; ++i) {
        for(int j=0; j<3; ++j)
        cin>>nums[i][j];
    }
    int res= dfs(nums,0,0 );
    for(int i=1; i<=2; ++i) res= max(res, dfs(nums,0,i ));
    cout<<res<<'\n';
  
    return 0;
}

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

int main()
{
  int N, X, m[110];
  cin >> N >> X;
  int S = 0, M = 1e9;
  for (int i = 0; i < N; i++)
  {
    cin >> m[i];
    S += m[i];
    if(M > m[i])
      M = m[i];
  }
  cout << N + (X - S)/M << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <complex>
#include <functional>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cctype>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(c,i) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main()
{
	int n;
	cin>>n;
	while(n--){
		double xa,ya,ra,xb,yb,rb;
		cin>>xa>>ya>>ra>>xb>>yb>>rb;
		double dist=hypot(xa-xb,ya-yb);
		
		int res;
		if(dist>ra+rb)
			res=0;
		else if(ra>dist+rb)
			res=2;
		else if(rb>dist+ra)
			res=-2;
		else
			res=1;
		
		cout<<res<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
# include"stdio.h"
int main(){
    char o[51],e[51];
    scanf("%s %s",o,e);
    int i=0;
    while(o[i]!='\0'&&e[i]!='\0'){
       printf("%c%c",o[i],e[i]);
       i++;
    }
    if(o[i]!='\0')
        printf("%c",o[i]);
    printf("\n");
}


Measured memory_bytes: 1704
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) fixed << setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll MODPOW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = MODPOW(n, m / 2);
    return (tmp * tmp) % MOD;
  } else {
    return (n * MODPOW(n, m - 1)) % MOD;
  }
}

ll MODDIV(ll a, ll b) { return a * MODPOW(b, MOD - 2) % MOD; }

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N;
  cin >> N;
  vl A(N);
  ll sum = 0;
  ll rm = 0;
  REP(i, N) {
    cin >> A[i];
    sum += A[i];
    sum %= MOD;
    rm += (A[i] * A[i]) % MOD;
    rm %= MOD;
  }
  cout << MODDIV(((sum * sum) % MOD) + MOD - rm, 2) << endl;

  return 0;
}


Measured memory_bytes: 4780
#include <iostream>
#include <vector>
#include <cstdlib>
#define rep(i,n) for(int i=0;i<n;++i)

using namespace std;
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; }

const long long INF = 1LL << 60;
int main(){
  int n;
  cin>>n;
  vector<int> h(n);
  rep(i,n){cin>>h[i];}
  vector <int> dp(n);
  dp[0]=0;
  dp[1]=abs(h[1]-h[0]);
  for (int i=2;i<n;i++){
    dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));

  }
  cout<<dp[n-1];

}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <map>
#include <math.h>
using namespace std;

int main(){
    string s, t;
    int n;
    cin >> s;
    n = int(s.size()/2);
    for (int i = 0; i < s.size(); i++) {
        if (s[i] != s[s.size()-1-i]) {
            cout << "No" << endl;
            return 0;
        }
    }
    for (int i = 0; i < n; i++){
        if (s[i] != s[n-i-1]) {
            cout << "No" << endl;
            return 0;
        }
    }
    t = s.substr(s.size() - n,s.size());
    for (int i = 0; i < n; i++){
        if (t[i] != t[n-i-1]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
H,W = list(map(int,input().split()))

S = [input() for i in range(H)]

L,R,U,D = [[[0]*W for i in range(H)] for i in range(4)]

for i in range(H):
    for j in range(W):
        if S[i][j] == ".":
            if i != 0:
                U[i][j] = U[i-1][j]+1
            else:
                U[i][j] = 1
            if j != 0:
                L[i][j] = L[i][j-1]+1
            else:
                L[i][j] = 1
            
        else:
            U[i][j] = 0
            L[i][j] = 0

        ri = H-i-1
        rj = W-j-1
        if S[ri][rj] == ".":
            if i != 0:
                D[ri][rj] = D[ri+1][rj]+1
            else:
                D[ri][rj] = 1
            if j != 0:
                R[ri][rj] = R[ri][rj+1]+1
            else:
                R[ri][rj] = 1
        else:
            D[ri][rj] = 0
            R[ri][rj] = 0


ans = 0
for i in range(H):
    for j in range(W):
        ans = max(ans,L[i][j]+R[i][j]+U[i][j]+D[i][j]-3)

print(ans)


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

typedef struct _data_st
{
    int rows, columns;
    struct _data_st *next;
} data_st;

int main(int argc, char *argv[])
{
    data_st *head = NULL, *tail = NULL;
    for (int rows, columns; scanf("%d %d", &rows, &columns) == 2 && (rows || columns);)
    {
        data_st *data = (data_st *)malloc(sizeof(data_st));
        *data = (data_st){.rows = rows, .columns = columns, .next = NULL};
        head = head ?: data;
        if (tail)
        {
            tail->next = data;
        }
        tail = data;
    }
    while (head)
    {
        data_st *data = head;
        head = head->next;
        for (int row = 0; row < data->rows; ++row)
        {
            const char c = (!row || row == data->rows - 1) ? '#' : '.';
            printf("#");
            for (int column = 1; column < data->columns - 1; ++column)
            {
                printf("%c", c);
            }
            printf("#\n");
        }
        printf("\n");
        free(data);
    }
    tail = NULL;
    return 0;
}



Measured memory_bytes: 2060
import math

def dist(a,b):
	if len(a)!=len(b):
		return -1
	else:
		tmp=0
		for i in range(len(a)):
			tmp+=(a[i]-b[i])**2
		return math.sqrt(tmp)

n,d=map(int,input().split())
x=[[] for i in range(n)]
for i in range(n):
	x[i]=list(map(int,input().split()))
ans=0
for i in range(n):
	for j in range(n):
		if i>=j:
			pass
		else:
			tmp=dist(x[i],x[j])
			if tmp.is_integer()==True:
				ans+=1
print(ans)

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

int main(){
	int n;
	string s;
	cin >> n >> s;
	vector<int> w(n+2,0), b(n+2,0);
	for(int i=0; i<n; i++){
		b[i+1] = b[i];
		if(s[i]=='#') b[i+1]++;
	}
	for(int i=n-1; i>=0; i--){
		w[i+1] = w[i+2];
		if(s[i]=='.') w[i+1]++;
	}
	int ans = 1e9;
	for(int i=0; i<n+1; i++){
		ans = min(ans, b[i]+w[i+1]);
	}
	cout << ans << endl;
	return 0;
}

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

//関数
    
    
    
//main関数
int main() {
    
    
    
    //入力
     long Q,H,S,D,N;
     cin >>Q>>H>>S>>D>>N;
     
    
    
    
    
    
    
    
    
    //計算
    bool DtoS=(D>2*S),DtoH=(D>4*H),DtoQ=(D>8*Q),StoH=(S>2*H),StoQ=(S>4*Q),HtoQ=(H>2*Q);
    long q=0,h=0,s=N%2,d=N/2;
    
    if(DtoS){
        s+=2*d;
        d=0;
    }
    if(DtoH){
        h+=4*d;
        d=0;
    }
    if(DtoQ){
        q+=8*d;
        d=0;
    }
    if(StoH){
        h+=2*s;
        s=0;
    }
    if(StoQ){
        q+=4*s;
        s=0;
    }
    if(HtoQ){
        q+=2*h;
        h=0;
    }
    
    //出力
    cout<<Q*q+H*h+S*s+D*d<<endl;

}

Measured memory_bytes: 256
import numpy as np

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

diff = np.array(h[:-1]) - np.array(h[1:])

renzoku = 0
kekka = 0
for i in range(len(diff)):
    if diff[i] >= 0:
        renzoku += 1
    else:
        if renzoku > kekka:
            kekka = renzoku
        renzoku = 0
if renzoku > kekka:
    kekka = renzoku

print(kekka)

Measured memory_bytes: 23348
#!/usr/bin/python3
# -*- coding: utf-8 -*-

from queue import *


class Edge(object):
    def __init__(self, dst, len_):
        self.dst = dst
        self.len = len_


MAX_K = int(1e5 + 5)
INF = int(1e9)

K = 0
dis = [INF for i in range(0, MAX_K)]
vis = [False for i in range(0, MAX_K)]
edge = [[] for i in range(0, MAX_K)]
q = PriorityQueue()


def add(s, t, d):
    edge[s].append(Edge(t, d))


def build():
    for i in range(1, K):
        add(i, i * 10 % K, 0)
        add(i, (i + 1) % K, 1)


def dij(s):
    dis[s] = 0
    q.put((0, s))
    while not q.empty():
        x = q.get()[1]
        if vis[x]:
            continue
        vis[x] = True
        for e in edge[x]:
            if dis[e.dst] > dis[x] + e.len:
                dis[e.dst] = dis[x] + e.len
                q.put((dis[e.dst], e.dst))


if __name__ == "__main__":
    K = int(input())
    build()
    dij(1)
    print(dis[0] + 1)


Measured memory_bytes: 60408
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using E = System.Linq.Enumerable;
 
class Program
 {

        static void Main(string[] args)
        {
          //var N = int.Parse(Console.ReadLine());
          //var ABX = Console.ReadLine();.Split(' ').Select(x => long.Parse(x)).ToArray();
          var S = Console.ReadLine();
          var flag = true;
          while(true){
            if(S == ""){
              break;
            }else if(S.Length < 3){
              flag = false;
              break;
            }
            
            var rear = S.Substring(S.Length-3);
            if(S.Length >= 7 && rear == "mer"){
              rear = S.Substring(S.Length-7);
              if(rear == "dreamer"){
                S = S.Remove(S.Length-7);
              }else{
                flag = false;
                break;
              }
            }else if(S.Length >= 5 && rear == "eam"){
              
              rear = S.Substring(S.Length-5);
              
              if(rear == "dream"){
                S = S.Remove(S.Length-5);
                //Console.WriteLine(rear);
              }else{
                flag = false;
                break;
              }
            }else if(S.Length >= 5 && rear == "ase"){
              rear = S.Substring(S.Length-5);
              if(rear == "erase"){
                S = S.Remove(S.Length-5);
              }else{
                flag = false;
                break;
              }
            }else if(S.Length >= 6 && rear == "ser"){
              rear = S.Substring(S.Length-6);
              if(rear == "eraser"){
                S = S.Remove(S.Length-6);
              }else{
                flag = false;
                break;
              }
            }else{
              flag = false;
              break;
            }
          }
          if(flag){
            Console.WriteLine("YES");
          }else{
            Console.WriteLine("NO");
          }
        }
  

}







Measured memory_bytes: 29600
#include<bits/stdc++.h>
#define FOR(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define FORN(i,b,a)for(int i=(b);_a=(a);i>=_a;i--)
#define REP(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define re return
#define vi vector<int>
#define pb push_back
#define si set<int>
#define in insert
#define fl float
#define db double
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define mod 1000000007
#define INF 1000000007
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
ll dp[100100]; 
int main()
{
	int n;
	int W;
	ll w[111];
	ll v[111];
	cin>>n>>W;
	REP(i,n)
		cin>>w[i]>>v[i];
	REP(i,W+5)
		dp[i]=0; 
	REP(i,n)
		for(int j=W;j>=w[i];j--)
		{
			dp[j]=max(dp[j],dp[j-w[i]]+v[i]);
		}
	cout<<dp[W]<<endl;
	return 0;
}



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

int main(){
    while(1){
        string number;
        cin >> number;
        if(number == "0")break;
        int sum = 0;
        
        for(int i=0; i< number.size(); i++){
            sum += number[i] - '0';
        }
        cout << sum << endl;
    }
    return 0;
}


Measured memory_bytes: 3216
// https://atcoder.jp/contests/dp/tasks/dp_g

#include <bits/stdc++.h>
#pragma gcc optimize("Ofast")
using namespace std;

int dfs(vector<vector<int>>&adj, vector<int>&dp, vector<bool>&visited, int vertex) {
    visited[vertex] = true;
    if(adj[vertex].size() == 0) {
        dp[vertex] = 0;
        return 0;
    } else {
        for(auto v: adj[vertex]) {
            if(!visited[v]) {
                int ans = dfs(adj, dp, visited, v);
            } 
            dp[vertex] = max(dp[vertex], 1 + dp[v]);
        }
    }
    return dp[vertex];
}

int main() {
    int n, e;
    cin >> n >> e;
    vector<vector<int>>adj(n+1);
    int u, v;
    for(int i = 0; i < e; ++i) {
        cin >> u >> v;
        adj[u].push_back(v);
    }

    vector<int>dp(n+1, 0);
    vector<bool>visited(n+1, false);
    int max_path = 0;
    for(int i = 1; i <= n; ++i) {
        if(!visited[i]) {
            max_path = max(max_path, dfs(adj, dp, visited, i));
        }
    }
    cout << max_path;

    return 0;
}

Measured memory_bytes: 9472
#include<stdio.h>
int cal(int *a);
int main(){
int a,b;
scanf("%d%d",&a,&b);
if((a>=1&&a<=9)&&(b>=1&&b<=9)){
a+=b;
cal(&a);
}
return 0;
}
int cal(int *a)
{
    if(*a<10){
        printf("%d\n",*a);
    }
    else{
        printf("error\n");
    }
}


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

int main() {
  int s;
  int a, b, c;
  cin >> s;
  a = s / 100;
  s = s % 100;
  b = s / 10;
  s = s % 10;
  c = s;
  
  
  
  cout << a + b + c << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <queue>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

// rep(i, 100) { cout << i << endl; } => 0 1 2 ... 99
#define rep(i, n) for(int i = 0, i##_len = (n); i < (int)n; i++)

// std::sort(all(v));
#define all(x) (x).begin(), (x).end()

// long long int
using ll = long long;

// utility to cast return value of size function to int
#define SZ(x) ((int)(x).size())

// VS defines "_DEBUG" macro when debug configuration.
#if _DEBUG
#define dump(x) cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#else
#define dump(x)
#define debug(x)
#endif

// update max
template<class T>bool chmax(T & prov, const T & cur)
{
	if (cur > prov)
	{
		prov = cur;
		return true;
	}
	return false;
}

// update min
template<class T>bool chmin(T & prov, const T & cur)
{
	if (cur < prov)
	{
		prov = cur;
		return true;
	}
	return false;
}

int main()
{
	int N;
	cin >> N;
	double ans = (double)(N-N/2) / N;

	printf("%0.10lf\n", ans);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <set>
#include <string>
using namespace std;

int main(){
    int a,b,c;
    cin >> a >> b >> c;

    string ans;
    if ( a+b >= c) ans = "Yes";
    else ans = "No";
    cout << ans << endl;
}

Measured memory_bytes: 384
#coding: utf-8
N = int(input())
A= list(map(int,input().split()))
A = [0] + A + [0]
def diff(X):
    diff_x = list(range(len(X)-1))
    for i in range(len(X)-1):
        diff_x[i] = abs(X[i] - X[i+1])
    return diff_x
Adiff = diff(A)
SUM = 0
for i in range(len(Adiff)):
    SUM += Adiff[i]
for i in range(N):
    SUMM = SUM
    SUMM += abs(A[i]-A[i+2]) - Adiff[i+1]-Adiff[i]
    print(SUMM)


Measured memory_bytes: 14040
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
const ll INF=(ll)1e18+10;
const double PI=acos(-1);

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 (a>b) { a=b; return 1; } return 0; }
int dy[]={-1,1,0,0};
int dx[]={0,0,-1,1};



int main() {
    string S; int Q;
    cin>>S>>Q;
    deque<char> dq;
    for(char c:S) dq.push_back(c);
    bool rev=false;
    int q,f; char c;
    for (int i = 0; i < Q; ++i) {
        cin>>q;
        if(q==1) rev^=1;
        else{
            cin>>f>>c;
            if(rev==(f==1)) dq.push_back(c);
            else dq.push_front(c);
        }
    }
    //cout<<dq.size()<<endl;
    if(!rev){
        while(!dq.empty()){
            cout<<dq.front();
            dq.pop_front();
        }
    }else{
        while(!dq.empty()){
            cout<<dq.back();
            dq.pop_back();
        }
    }
    cout<<endl;

    return 0;
}


Measured memory_bytes: 1024
import java.util.*;

public class Main {
  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] A = new int[N+1];
    for (int i = 0; i < N+1; i++) {
      A[i] = sc.nextInt();
    }
    long ans = 0;
    for (int i = 0; i < N; i++) {
      int b = sc.nextInt();
      if (i == 0) {
        int delL = Math.min(A[0], b);
        A[0] -= delL;
        int delR = Math.min(A[1], b-delL);
        A[1] -= delR;
        ans += (delL + delR);
      } else if (i == N-1) {
        int delR = Math.min(A[N], b);
        A[N] -= delR;
        int delL = Math.min(A[N-1], b-delR);
        A[N-1] -= delL;
        ans += (delL + delR);
      } else {
        int delL = Math.min(A[i], b);
        A[i] -= delL;
        int delR = Math.min(A[i+1], b-delL);
        A[i+1] -= delR;
        ans += (delL + delR);
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 66392
x ,n = map(int, input().split())
s = list(map(int, input().split()))
number = list(range(0,102))
min = 100
if n == 0:
  print(x)
  exit()
  
for i in range(n):
  number.remove(s[i])

for i in range(102 - n):
  if min > abs(x - number[i]):
    min = abs(x - number[i])
    j = i
print(number[j])


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

typedef long long int int64;

typedef struct point2d{
  int a,b;
} point;

int cmp(const void *a,const void *b){
  point *p=(point *)a;
  point *q=(point *)b;
  if(p->a!=q->a) return p->a-q->a;
  return p->b-q->b;
}

void run(void){
  int h,w,n;
  scanf("%d%d%d",&h,&w,&n);
  point *p=(point *)malloc(sizeof(point)*n*9);
  int len=0;
  int i;
  for(i=0;i<n;i++){
    int a,b;
    scanf("%d%d",&a,&b);
    int j,k;
    for(j=-1;j<=1;j++){
      for(k=-1;k<=1;k++){
	if(1<a+j && a+j<h && 1<b+k && b+k<w){
	  p[len].a=a+j;
	  p[len].b=b+k;
	  len++;
	}
      }
    }
  }
  qsort(p,len,sizeof(point),cmp);
  int64 cnt[10]={};
  i=0;
  while(i<len){
    int j=i;
    while(j<len && cmp(p+i,p+j)==0) j++;
    cnt[j-i]++;
    i=j;
  }
  cnt[0]=(int64)(h-2)*(w-2);
  for(i=1;i<=9;i++) cnt[0]-=cnt[i];
  for(i=0;i<=9;i++){
    printf("%lld\n",cnt[i]);
  }
}

int main(void){
  run();
  return 0;
}

Measured memory_bytes: 14204
#include<bits/stdc++.h>
using namespace std;
#define LL long long
const LL MOD =1000000007;
const LL maxn=506;
LL pows[maxn][maxn];
LL sum[maxn][maxn];
LL dp[maxn][maxn];
LL a[maxn];
LL b[maxn];
int main()
{
    LL n,c;
    cin>>n>>c;
    for(LL i=1;i<=n;i++)
        cin>>a[i];
    for(LL i=1;i<=n;i++)
        cin>>b[i];
    for(LL i=1;i<=500;i++){
        pows[i][0]=1;
        for(LL j=1;j<=500;j++)
            pows[i][j]=(pows[i][j-1]*i)%MOD;
    }
    for(LL i=1;i<=500;i++)
        for(LL j=0;j<=500;j++)
            sum[i][j]=(sum[i][j]+sum[i-1][j]+pows[i][j])%MOD;
    dp[0][0]=1;//前i人分j糖果
    for(LL i=1;i<=n;i++){//枚举1-n个人
        for(LL j=0;j<=c;j++){//枚举0-c个糖
            for(LL k=0;k<=j;k++){
                LL temp=(sum[b[i]][k]-sum[a[i]-1][k]+MOD)%MOD;
                dp[i][j]=(dp[i][j]+dp[i-1][j-k]*temp)%MOD;
            }
        }
    }
    cout<<dp[n][c];
}


Measured memory_bytes: 5760
#include<iostream>
#include<string>
using namespace std;
int main(){
	string buf;
	cin>>buf;
	bool flag=false;
	for(int i=0;i<buf.length();++i){
		if(buf[i]==buf[i+1]){
			cout<<i+1<<" "<<i+2<<endl;
			flag=true;
			break;
		}
		else if(buf[i]==buf[i+2] && i<buf.length()-2){
			cout<<i+1<<" "<<i+3<<endl;
			flag=true;
			break;
		}
	}
	if(!flag)
		cout<<-1<<" "<<-1<<endl;
	return 0;
}

Measured memory_bytes: 512
def main():
    N, K = map(int, input().split())

    ds = []
    current_members = set(range(1,N+1))
    for i in range(K):
        d = int(input())
        members= map(int, input().split())
        current_members -= set(members)
    
    #print(current_members)
    print(len(current_members))


if __name__ == '__main__':
    main()


Measured memory_bytes: 9176
/*
*ID: juryc
*LANG: C++
*/
#include<bits/stdc++.h>
using namespace std;
const int N = 1e6+5; 
vector<int> primes(N,1);
vector<int> mp(N,0),pmc(N,0);    
void sieve(){
primes[0]=primes[1]=0; 
for(int i=2;i<N;i++){
if(primes[i]){
for(int j=i;j<N;j+=i){
primes[j]=0; 
if(mp[j]){ pmc[i]++; }
}
}
}
}

int main(){
int n; cin>>n;
vector<int> v(n); 
int flag3=1; 
for(int& i: v) { cin>>i; mp[i]++; if(mp[i]>1&&(i!=1)) flag3=0; }
sieve(); 
int gd=v[0];
for(int i=1;i<n;i++) gd=__gcd(gd,v[i]);
int flag1=1; 
for(int i=1;i<N;i++){
flag1&=(pmc[i]<=1); 
}
int flag2=1; flag2&=(gd==1); 
flag1&=flag3;
if(flag1) cout<<"pairwise coprime"; 
else if(flag2) cout<<"setwise coprime"; 
else cout<<"not coprime";
cout<<endl;   
return 0;
}


Measured memory_bytes: 18740
#include <iostream>
#include <algorithm>
#include <climits>
#include <vector>
#include <stack>
#include <cmath>
#include <queue>
#include <set>
#include <map>
using namespace std;

int main() {
    int n,a;
    cin >> n >>a;
    if(n%500 <= a) cout << "Yes";
    else cout << "No";
    cout << endl;

    return 0;
}


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

int main(){
    int H, W, A, B;
    scanf("%d%d%d%d", &H, &W, &A, &B);
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if(i < H - B){
                if(j < W - A)printf("0");
                else printf("1");
            }else{
                if(j < W - A)printf("1");
                else printf("0");
            }
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,j,n) for(int i=j;i<n;++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(), i.rend()
#define INF 1e9
#define LINF 1e18
const int mod = 1e9 + 7;
 
typedef long long i64;
typedef pair<int, int> pi;
 
template <class T> using vt = vector<T>;
template <class T> using vvt = vector<vector<T>>;
 
i64 gcd(i64 n, i64 m) {return (m == 0? n : gcd(m, n % m));}
i64 lcm(i64 n, i64 m) {return (n / gcd(n, m) * m);}
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

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

  string s;
  cin >> s;

  int ans = 0;
  int l = 0, r = s.size() - 1;
  while(l < r) {
    if(s[l] != s[r]) ans++;
    l++; r--;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <unordered_set>
#include <numeric>
using namespace std;

const int MOD = 1e9 + 7;
#define ll long long


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

int findlcm(vector<int >arr, int n)
{
	int ans = arr[0];

	for (int i = 1; i < n; i++)
		ans = (((arr[i] * ans)) /
		(gcd(arr[i], ans)));

	return ans;
}

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

	vector<int> arr(n);
	for (int i = 0; i < n; i++)
	{
		cin >> arr[i];
	}

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

	double res = ((double)arr[0] + (double)arr[1]) / 2;

	for (int i = 2; i < n; i++)
	{
		res = ((double)arr[i] + res) / 2;
	}

	printf("%.5f\n", res);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template <class F>
auto recursive(F f) {
    return [f](auto... a) { return f(f, a...); };
}
template <class I, class V = typename I::value_type>
V sum_up(const I &l, const I &r) {
    V v;
    for (I i = l; i != r; i++) v = i == l ? *i : v + *i;
    return v;
}
template <class I, class T = iterator_traits<I>>
I operator+(I it, int n) {
    for (int i = 0; i < n; i++) it++;
    return it;
}
template <class I, class T = iterator_traits<I>>
I operator-(I it, int n) {
    for (int i = 0; i < n; i++) it--;
    return it;
}
template <class T>
using rev_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template <class T>
using vector2d = vector<vector<T>>;
struct fixprec {
    int x;
    fixprec(int d) : x(d) {}
};
ostream &operator<<(ostream &o, fixprec f) { return o << fixed << setprecision(f.x); }
void R_YESNO(bool p) { cout << (p ? "YES" : "NO") << endl; }
void R_YesNo(bool p) { cout << (p ? "Yes" : "No") << endl; }

/*!* [binsearch] *!*/
/*+* 二分探索 *+*/
// judge を満たすような下限を求める
// l:[X] 定義域外部の上限
// r:[X] 定義域外部の下限
// judge:[X -> bool] X を評価する関数
// lower:[bool] falseにすると代わりに上限を求める
// eps:[X] 終了距離

template <typename X>
X BinSearch(X l, X r, function<bool(X)> judge, bool lower = true, X eps = 1) {
    while (r - l > eps) {
        X m = (r + l) / 2;
        if (judge(m) == lower) {
            r = m;
        } else {
            l = m;
        }
    }
    return lower ? r : l;
}

// O(NlogNlogK) = O(N(logN)^2)
int main() {
    i64 N, K;
    cin >> N >> K;
    vector<i64> V(N);
    for (i64 &a : V) cin >> a;
    sort(WHOLE(V));
    i64 A[int(2e5)];
    for (int i = 0; i < N; i++) A[i] = V[i];
    i64 ans = BinSearch<i64>(-1.1e18, 1.1e18, [&](i64 X) -> bool {
        // X |-> M:積ペアのうちX以下のものの数
        i64 M = 0;
        // O(NlogN)
        for (int i = 0; i < N; i++) {
            // k : A[i] と積を取ってX以下になる限界
            // int k = BinSearch<int>(-1, N, [&A, i, X](int j) -> bool {
            //     return A[i] * A[j] <= X;
            // }, A[i] < 0);
            int k = 0;
            {{{
                int l = -1, r = N, eps = 1;
                bool lower = A[i] < 0;
                while (r - l > eps) {
                    int m = (r + l) / 2;
                    if ((A[i] * A[m] <= X) == lower) {
                        r = m;
                    } else {
                        l = m;
                    }
                }
                k = lower ? r : l;
            }}}

            if (A[i] < 0) {
                M += N - k;
            } else {
                M += k + 1;
            }
            // 自乗が含まれているなら削除
            if (A[i] * A[i] <= X) M--;
        }
        // ダブルカウンティングを解消
        return M >= 2 * K;
    });
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3328
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long M = sc.nextLong();
		if (M<=2*N) {
			System.out.println(M/2);
		} else if (M>2*N) {
			long sum = N;
			long temp = M - 2*N;
			sum +=temp/4;
			System.out.println(sum);
		}
	}
}

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

int main(){
    string s;
    cin>>s;
    bool flag=false;
    int len=s.size();
    for(int i=1;i<s.size();i++){
        if((len-i)%2!=0)continue;
        else{
            string str1=s.substr(0,(len-i)/2);
            string str2=s.substr((len-i)/2,(len-i)/2);
            if(str1==str2){
                cout<<len-i<<endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3584
# include <bits/stdc++.h>
# define INF 1e9
using namespace std;

int main(){

  int N;
  cin >> N;
  int F[N][10];
  for(int i=0; i<N; i++){
    for(int j=0; j<10; j++){
      cin >> F[i][j];
    }
  }

  int P[N][11];
  for(int i=0; i<N; i++){
    for(int j=0; j<11; j++){
      cin >> P[i][j];
    }
  }

  vector<vector<int>> state;
  state.push_back({});

  for(int i=0; i<10; i++){
    vector<vector<int>> temp;
    for(int j=0; j<state.size(); j++){
      for(int k=0; k<2; k++){
        state[j].push_back(k);
        temp.push_back(state[j]);
        state[j].pop_back();
      }
    }
    state = temp;
  }

  int ans = -INF;
  for(int i=0; i<state.size(); i++){
    if(accumulate(state[i].begin(), state[i].end(), 0) == 0) continue;
    int u = 0;
    for(int k=0; k<N; k++){
      int v = 0;
      for(int j=0; j<10; j++){
        v += state[i][j] * F[k][j];
      }
       u += P[k][v];
    }
    ans = max(ans, u);
  }

  cout << ans << endl;

}


Measured memory_bytes: 512
#include<string>
#include<list>
#include<iostream>
using namespace std;
int main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  string str;
  list<int> data;
  list<int>::iterator it,l;
  int n,x;
  cin >> n;
  while(n--){
    cin >> str;
    if(str == "insert"){
      cin >> x;
      data.push_front(x);
    }else if(str == "delete"){
      cin >> x;
      for(it=data.begin(),l=data.end();it!=l;++it){
	if(*it == x){
	  data.erase(it);
	  break;
	}
      }
    }else if(str == "deleteFirst") data.pop_front();
    else data.pop_back();
  }
  for(it=data.begin(),l=--data.end();it!=l;++it) cout << *it << " ";
  cout << *it << endl;
}



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

int main(){
    int N;
    cin >> N;
    int L[2*N];
    for (int i = 0; i<2*N;i++){
        int li;
        cin >> li;
        L[i] = li;
        //cout << L[i] << endl;
    }
    int size = sizeof(L)/sizeof(L[0]);
    sort(L, L+size);
    //for (int j=0;j<2*N;j++) cout << L[j];
    int total = 0;
    for (int k =0;k<2*N-1;k+=2){
        int curr = L[k];
        //cout << "Curr= " << curr<<endl;
        total += curr;
    }
    cout << total;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

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

//ナップサック問題

int main()
{
	int n, w;
	cin >> n >> w;
	int weight[110], value[110];
	REP(i, n) cin >> value[i] >> weight[i];

	int dp[110][10010];

	REP(i, w + 1) dp[0][w] = 0;

	REP(i, n){
		REP(j, w + 1){
			if (j >= weight[i]) dp[i + 1][j] = max(dp[i][j - weight[i]] + value[i], dp[i][j]);
			else dp[i + 1][j] = dp[i][j];
		}
	}

	cout << dp[n][w] << endl;



}



Measured memory_bytes: 7000
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;

const int c_YET = -1;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const ll MAX = 1e9;
const double PI = 3.14159265358979323846264338327950288;
//========================================================================



int main() {

	////==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	////==================================
	

	ll N;
	cin >> N;

	ll ans = 0;
	for (int i = 1; i <= N; i++)
	{
		if (i % 3 != 0 && i % 5 != 0)
		{
			ans += i;
		}
	}
	cout << ans;






}





Measured memory_bytes: 3652
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
ll tot,ans;
void solve(){
	cin >> tot;
	ans += (tot / 500) * 1000;
	tot %= 500;
	ans += (tot / 5) * 5;
	cout << ans << endl;
	return;
}

int main(){
	solve();
	return 0;
}

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

using namespace std;
typedef long long ll;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define INF (ll)2e9
#define MOD ((ll)1e9+7)
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((int)(x).size())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define bit(n) (1LL<<(n))

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

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

template<class InputIterator>
InputIterator adv(InputIterator x, typename std::iterator_traits<InputIterator>::difference_type n) {
    advance(x, n);
    return x;
}

class mod {
    static ll fact[];
public:

    template<class... A>
    static ll mul(A... args) {
        ll res = 1;
        for (ll i : std::initializer_list < ll > {args...}) {
            res = (res * i) % MOD;
        }
        return res;
    }

    static ll power(ll base, ll exp) {
        if (exp == 0) return 1;
        if (exp & 1) {
            return mul(base, power(base, exp - 1));
        } else {
            ll p = power(base, exp / 2);
            return mul(p, p);
        }
    }

    static ll factorial(int n) {
        if (fact[n] != 0) return fact[n];
        if (n == 0) return 1;
        return fact[n] = mul(n, factorial(n - 1));
    }

    static ll inverse(int n) {
        return power(n, MOD - 2);
    }

    static ll comb(int n, int r) {
        if (r < 0 || r > n) return 0;
        return mul(factorial(n), inverse(factorial(n - r)), inverse(factorial(r)));
    }

    template<class... A>
    static ll div(ll dividend, A... args) {
        ll res = dividend;
        for (ll i : std::initializer_list < ll > {args...}) {
            res = mul(res, inverse(i));
        }
        return res;
    }

    template<class... A>
    static ll add(A... args) {
        ll res = 0;
        for (ll i : std::initializer_list < ll > {args...}) {
            res = (res * i) % MOD;
        }
        return res;
    }

    template<class... A>
    static ll sub(ll l, A... args) {
        ll res = l;
        for (ll i : std::initializer_list < ll > {args...}) {
            res = (res - i + MOD) % MOD;
        }
        return res;
    }
};

ll mod::fact[(int) 1e6 + 1];

int ni() {
    int i;
    cin >> i;
    return i;
}

ll nll() {
    ll l;
    cin >> l;
    return l;
}

int main() {
    int N = ni();
    ll sum = 0;
    ll ans = 0;
    FOR(i, 1, INF) {
        sum += i;
        ans++;
        if (sum >= N) break;
    }

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

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int n,r,i,j,p,c,a[51],b[51];
    while(1){
        scanf("%d %d\n",&n,&r);
        if (n==0&&r==0) break;
        for (i=1;i<=n;i++) {
            a[i]=n+1-i; 
            b[i]=n+1-i;
        }
        for (i=0;i<r;i++) {
            scanf("%d %d",&p,&c);
            for (j=1;j<=c;j++) {
                b[j]=a[j+p-1];
            }
            for (j=c+1;j<=c+p-1;j++) {
                b[j]=a[j-c];
            }
            for (j=1;j<=n;j++) {
                a[j]=b[j];
            }
        }
        
        printf("%d\n",a[1]);
        
    }
    return 0;
}

Measured memory_bytes: 1032