akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <iostream>
#include<math.h>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main()
{
    int N, M;
    cin >> N >> M;
    vector<bool>vec(1000, true);
    vector<pair<int, int>>pairs(M);
    for (int i=0; i<=999; i++) {
        if (i < 10) {
            if (N != 1) {
                vec[i] = false;
            }
        } else if (i < 100) {
            if (N != 2) {
                vec[i] = false;
            }
        } else {
            if (N != 3) {
                vec[i] = false;
            }
        }
    }
    for (int i=0; i<M; i++) {
        int s, c;
        cin >> s >> c;
        pairs[i] = make_pair(s, c);
    }

    int min_ = 0;
    int max_ = 0;
    if (N == 1) {
        max_ = 9;
    } else if (N == 2) {
        min_ = 10;
        max_ = 99;
    } else {
        min_ = 100;
        max_ = 999;
    }

    for (int i=0; i<M; i++) {
        int s = pairs[i].first;
        int c = pairs[i].second;
        for (int i=min_; i<=max_; i++) {
            if (N == 1) {
                int v = i % 10;
                if (v != c) {
                    vec[i] = false;
                }
            } else if (N == 2) {
                int v = 0;
                if (s == 1) {
                    v = (i / 10) % 10;
                } else {
                    v = i % 10;
                }

                if (v != c) {
                    vec[i] = false;
                }
            } else {
                int v = 0;
                if (s == 1) {
                    v = ((i / 10) / 10) % 10;
                } else if (s == 2) {
                    v = (i / 10) % 10;
                } else {
                    v = i % 10;
                }

                if (v != c) {
                    vec[i] = false;
                }
            }
        }
    }

    bool is_ok = false;
    for (int i=0; i<1000; i++) {
        if (vec[i]) {
            cout << i << endl;
            is_ok = true;
            break;
        }
    }

    if (!is_ok) {
        cout << "-1" << endl;
    }
    return 0;
}

Measured memory_bytes: 3596
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<numeric>
#include<queue>
#include<string>
#include<vector>
#include <stdio.h>
#define ll long long
#include<cstring>
#define rep(i,n) for(int i=0;i<n;i++)
ll mod = 1000000007;
using namespace std;
priority_queue<ll int>QUE;//きゅー

int length(char* str) {
	int len = strlen(str);
	return len;
}

int main(void)
{
	int D;
	cin >> D;
	string ans;
	if (D == 25) {
		ans = "Christmas";
	}
	else if (D == 24) {
		ans = "Christmas Eve";
	}
	else if (D == 23) {
		ans = "Christmas Eve Eve";
	}
	else {
		ans = "Christmas Eve Eve Eve";
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <unordered_map>

using namespace std;
using LL = long long;

constexpr int MOD = 1000000000 + 7;
constexpr int INF = 2000000000;

int main() {
	int d, l;
	cin >> d >> l;
	cout << d / l + d%l << endl;
}

Measured memory_bytes: 3092
h, w = map(int, input().split())
a = [list(input()) for _ in range(h)]

for _ in range(w):
    for i, j in enumerate(a):
        if set(j) == set("."):
            a.pop(i)
    a_t = [list(x) for x in zip(*a)]
    for i, j in enumerate(a_t):
        if set(j) == set("."):
            a_t.pop(i)
    a = [list(x) for x in zip(*a_t)]

[print(*ans, sep="") for ans in a]

Measured memory_bytes: 9452
N = int(input())
A  = list(map(int, input().split()))
ans = []
count = 0
i = 0
while i <= N-2:
  if A[i] >= A[i+1]:
    count += 1
    i += 1
  else:
    ans.append(count)
    count = 0
    i += 1
ans.append(count)
print(max(ans))
    

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define FOR(NAME, START, NUM) for (ll NAME = START; NAME < (NUM); NAME++)
#define REP(NAME, NUM) for (ll NAME = 0; NAME < (NUM); NAME++)
#define BREP(NAME, NUM) for (ll NAME = (NUM)-1; NAME >= 0; NAME--)
#define ALL(NAME) (NAME).begin(), (NAME).end()
const ll LINF = 1e18;
const int INF = 1e9;
const int mod = 1e9+7;

int main(){
  long double W,H,x,y;
  cin>>W>>H>>x>>y;
  
  cout<<W*H/2<<' ';
  if(x == W/2 && y == H/2)cout<<1<<endl;
  else cout<<0<<endl;

}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

/* define */
#define Yes(X) puts ( (X) ? "Yes" : "No")
#define YES(X) puts ( (X) ? "YES" : "NO")
#define FOR(i, a, b) for ( int i = (a); i < (b) ; i++)
#define REP(i, n) for ( int i = 0; i < (n) ; i++)
#define max(a, b) (((a) > (b)) ? (a) : (b))
#define min(a, b) (((a) < (b)) ? (a) : (b))
#define max3(a, b, c) ((max((a), (b)) > (c)) ? max((a), (b)) : (c))
#define min3(a, b, c) ((min((a), (b)) < (c)) ? min((a), (b)) : (c))

/* const */
const int MOD = 1000000007;

/* alias */
typedef long long ll;
typedef unsigned  u;

/* function */
int cmp(const void *a, const void *b) {
	return *(int*)a - *(int*)b;
}
int cmp2(const void *a, const void *b) {
	return *(int*)b - *(int*)a;
}
int gcd(int a, int b) {
	if (b != 0)return gcd(b, a % b);
	return a;
}
ll Lgcd(ll a, ll b) {
	if (b != 0) return Lgcd(b, a % b);
	return a;
}
int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}
ll Llcm(ll a, ll b) {
	return a / Lgcd(a, b) * b;
}

/* main */

int main() {
	int n, d, r;
	scanf("%d%d", &n, &d);
	if (n % (d * 2 + 1)) r = n / (2 * d + 1) + 1;
	else r = n / (2 * d + 1);
	printf("%d", r);
	return 0;
}

Measured memory_bytes: 128
n=int(input())
nums=list(map(int,input().split()))
count=0
for i in range(n):
    
    minj=i
    minv=nums[minj:].index(min(nums[minj:]))+minj
    if minv!=minj:
        count+=1

    nums[minj],nums[minv]=nums[minv],nums[minj]
    

def show(nums):
    for j in range(len(nums)):
        if j!=len(nums)-1:
            print(nums[j],end=' ')

        else:
            print(nums[j])

show(nums)
print(count)


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

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

    for(int i=b;i<=c;i++)
    {
        if(i%a==0)
        {
            temp = 1;
            break;
        }
    }
    if(temp == 1)
        cout<<"OK"<<endl;
    else
        cout<<"NG"<<endl;

    return 0;
}


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

int main () {
  string s;
  cin >> s;
  bool dance = true;
  for (int i = 0; i < s.size();i++){
    if ((i%2 == 0) && (s.at(i) == 'L')) dance = false;
    else if ((i%2 == 1) && (s.at(i) == 'R')) dance = false;
  }
  if (dance) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using PQI = priority_queue<int>;
using PQL = priority_queue<long>;

int main()
{
    int n, m;
    cin >> n >> m;
    cout<< n*(n-1)/2 + m*(m-1)/2 << endl;

    return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
A = [int(x) - 1 for x in input().split()]

visited = [None] * N
visited[0] = 0
period = None
k = K
cur = 0
while 0 < k:
    next_town = A[cur]
    k -= 1
    if visited[next_town] is None or period is not None:
        visited[next_town] = visited[cur] + 1
    else:
        period = visited[cur] + 1 - visited[next_town]
        k -= k // period * period
    cur = next_town
print(cur + 1)

Measured memory_bytes: 32328
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x)  x.begin(),x.end()
#define vi vector<int>
#define print(x) for(auto it=x.begin();it!=x.end();it++) cout<<*it<<' '; cout<<'\n';
#define in(x,n) for(int e=0;e<n;e++){int y;cin>>y;x.pb(y);}
#define lower(sl)  transform(sl.begin(), sl.end(), sl.begin(), ::tolower); 
//Available in Snips
#define fi(i, x, y)   for (__typeof(x) i = x; i < y; i ++)
#define fir(i, x, y)  for (__typeof(x) i = x; i > y; i --)
#define fv(x)   for (auto itr = x.begin(); itr != x.end(); itr ++)
#define fvr(x)  for (auto itr = x.end() - 1; itr != x.begin() - 1; itr --)

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//code here
    int n,k,p[200005];

	cin>>n>>k;
    for(int i=1;i<=n;i++) cin>>p[i], p[i]+=p[i-1];
    int mx=0;
    for(int i=0;i+k<=n;i++) mx=max(mx,p[i+k]-p[i]);
    cout<<setiosflags(ios::fixed)<<setprecision(12)<<(k+mx)*0.5;

}

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[] P = new int[N];
		Arrays.setAll(P, i -> sc.nextInt());
		sc.close();

		int cnt = 0;
		for (int i = 0; i < N; i++) {
			if (P[i] != (i + 1)) {
				cnt++;
			}
		}

		if (cnt == 0 || cnt == 2) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}


Measured memory_bytes: 26452
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int input_A = sc.nextInt();
		int input_B = sc.nextInt();
		int input_C = sc.nextInt();
		int input_K = sc.nextInt();
		sc.close();

		int sum = 0;

		if(input_K - input_A >= 0) {
			sum = input_A;
			input_K = input_K - (input_A + input_B);

			if(input_K > 0) {
				sum = sum - input_K;
			}

		}else {
			sum = input_K;
		}

		// 出力
		System.out.println(sum);

	}
}

Measured memory_bytes: 27008
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <random>
#include <time.h>
#include <chrono>
#include <sstream>
#include <iomanip>
#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 ll long long
#define INF 1000000001
#define mod 1000000007
#define sort(s) sort(s.begin(), s.end());
#define reverse(s) reverse(s.begin(), s.end());
#define P pair<int,int>
#define valid(x,y,h,w) (0<=x&&x<h&&0<=y&&y<w)
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }


int main() {
	int n, m, c,a;
	cin >> n >> m >> c;
	vector<int>  b(m);
	rep(i, m) {
		cin >> b[i];
	}
	int ans = 0;
	rep(j, n) {
		int x = 0;
		rep(i, m) {
			cin >> a;
			x += a * b[i];
		}
		x += c;
		if (x > 0) {
			ans++;
		}
		
	}
	cout << ans << endl;
	
}



Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
 
using namespace std;
 
int main(void){
 
  int p[14][14] = {0};
  int x,y,size;
  char ten,tenten;
 back:;
  while( cin >> x >> ten >> y >> tenten >> size ){
    x += 2;
    y += 2;
    switch(size){
    case 3:
      p[x-2][y]++;
      p[x+2][y]++;
      p[x][y-2]++;
      p[x][y+2]++;
    case 2:
      p[x+1][y+1]++;
      p[x-1][y-1]++;
      p[x+1][y-1]++;
      p[x-1][y+1]++;
    case 1:
      p[x][y+1]++;
      p[x][y-1]++;
      p[x-1][y]++;
      p[x+1][y]++;
      p[x][y]++;
    }
  }
   
  int cnt = 0;
  int m = 0;
  for( int i = 2 ; i < 12 ; i++ ){
    for( int j = 2 ; j < 12 ; j++ ){
      if( p[i][j] == 0 ) cnt++;
      m = max( m , p[i][j] );
      //  cout << " " << p[i][j] << " ";
    }
    //cout << endl;
  }
  cout << cnt << endl << m << endl;
  return 0;
}

Measured memory_bytes: 1160
h,w=map(int,input().split())
maze=[[None] for _ in range(h)]
for i in range(h):
  s=list(input())
  for j in range(w):
    if s[j]=="#":
      pass
    else:
      s[j]=0
  maze[i]=s

for i in range(h):
  for j in range(w):
    if maze[i][j]=="#":
      for ii in range(i-1,i+1+1):
        for jj in range(j-1,j+1+1):
          if 0<=ii<h and 0<=jj<w:
            if maze[ii][jj]!="#":
              maze[ii][jj]+=1
for i in range(h):
  for j in range(w):
    print(maze[i][j],end="")
  print()

Measured memory_bytes: 3444
#include <stdio.h>

int main(){
    int a, b;
    char op;
    while(1){
        scanf("%d %c %d", &a, &op, &b);
        if(op=='?'){
            break;
    	}else if(op=='+'){
    	    printf("%d\n", a+b);
    	}else if(op=='-'){
    	    printf("%d\n", a-b);
    	}else if(op=='*'){
    	    printf("%d\n", a*b);
    	}else if(op=='/'){
    	    printf("%d\n", a/b);
        }
    }
    return 0;
}


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

#define lli long long int
#define REP(i, s, n) for (int i = s; i < n; i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL << 50)
#define DEBUG 0
#define mp(a, b) make_pair(a, b)
#define SORT(V) sort(V.begin(), V.end())
#define PI (3.141592653589794)

void func(long long K)
{
    queue<lli> q;
    REP(i, 1, 10)
    {
        q.push(i);
    }

    lli cnt = 0;
    while (q.size())
    {
        cnt++;
        if (cnt == K)
        {
            cout << q.front() << endl;
            return;
        }
        lli top = q.front();
        q.pop();
        lli under = top % 10;
        if (under != 0)
            q.push(top * 10 + under - 1);
        q.push(top * 10 + under);
        if (under != 9)
            q.push(top * 10 + under + 1);
    }
}

int main()
{
    // cout << fixed << setprecision(5);

    long long K;
    scanf("%lld", &K);
    func(K);
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define int long long

signed main(){
    int n, d;
    cin >> n >> d;
    cout << (int)ceil(n/(2.0*d+1)) << endl;
}

Measured memory_bytes: 256
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_B main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif


int main_B() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N; cin >> N;
    int CMAX = 100 / 4;
    int DMAX = 100 / 7;

    bool ok = false;
    for(int c = 0; c<=CMAX; c++) {
        for(int d =0; d<=DMAX; d++) {
            if (4*c+7*d==N) {
                ok = true;
                cerr << c << ' ' << d << endl;
                break;
            }
        }
        if (ok) break;
    }    

    string ans = ok ? "Yes" : "No";
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
typedef long long ll;

ll gcd(ll x, ll y){
	if(x < y) x ^= y ^= x ^= y;
	return (x % y ? gcd(y, x % y) : y);
}

int main(){
	ll n, k; cin >> n >> k;
	ll a[n];
	ll max = 0;
	bool jud = 0;
	for(ll i = 0; i < n; ++i){
		cin >> a[i];
		if(a[i] >= k) jud = 1;
	}
	if(!jud){
		cout << "IMPOSSIBLE\n";
		return 0;
	}
	ll g = a[0];
	for(ll i = 0; i < n; ++i){
		g = gcd(a[i], g);
	}
	if(!(k % g)) cout << "POSSIBLE\n";
	else cout << "IMPOSSIBLE\n";
	return 0;
}

Measured memory_bytes: 1024
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<queue>
#define ll long long
using namespace std;
const int maxn=1e5;
int x,y,z,n;
ll ans,f[maxn+8],sum;
priority_queue<int,vector<int>,greater<int> >st;

int read()
{
    int x=0,f=1;char ch=getchar();
    for (;ch<'0'||ch>'9';ch=getchar()) if (ch=='-') f=-1;
    for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
    return x*f;
}

struct Vertex
{
    int v1,v2,v3,cm;
}a[maxn+8];

bool cmp(Vertex x,Vertex y){return x.cm>y.cm;}

int main()
{
    x=read(),y=read(),z=read();n=x+y+z;
    for (int i=1;i<=n;i++)
	a[i].v1=read(),a[i].v2=read(),a[i].v3=read(),a[i].cm=a[i].v1-a[i].v2,sum+=a[i].v3;
    sort(a+1,a+n+1,cmp);
    ll now=0;
    for (int i=1;i<=x;i++) st.push(a[i].v1-a[i].v3),now+=a[i].v1-a[i].v3;
    f[x]+=now;
    for (int i=x+1;i<=n-y;i++)
	{
	    st.push(a[i].v1-a[i].v3);
	    int x=st.top();st.pop();
	    now+=a[i].v1-a[i].v3;
	    now-=x;
	    f[i]+=now;
	}
    while(!st.empty()) st.pop();now=0;
    for (int i=n-y+1;i<=n;i++) st.push(a[i].v2-a[i].v3),now+=a[i].v2-a[i].v3;
    f[n-y]+=now;
    for (int i=n-y;i>x;i--)
	{
	    st.push(a[i].v2-a[i].v3);
	    int x=st.top();st.pop();
	    now+=a[i].v2-a[i].v3;
	    now-=x;
	    f[i-1]+=now;
	}
    for (int i=x;i<=n-y;i++) ans=max(ans,f[i]+sum);
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 2684
import sys

N = int(input())
H = list(map(int, sys.stdin.readline().rsplit()))

dp = [10 ** 18] * N
dp[0] = 0
dp[1] = abs(H[0] - H[1])

for i in range(2, N):
    dp[i] = min(dp[i - 1] + abs(H[i - 1] - H[i]), dp[i - 2] + abs(H[i - 2] - H[i]))

print(dp[N - 1])


Measured memory_bytes: 20288
N = int(input())
A = [int(x) for x in input().split()]
M = [0] * (2 * N)
for i in range(N):
  M[i + 1] = A[i] - M[i]
M[N] = (M[0] + M[N]) // 2
for i in range(N - 1):
  M[N + i + 1] = A[i] - M[N + i]
print(' '.join([str(m * 2) for m in M[N:]]))

Measured memory_bytes: 23844
#include <iostream>
#include <vector>
#include <math.h>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;

int ans=1e9;
int n;
int a,b,c;
vector<int> l(10);

void dfs(int u,int a0, int b0, int c0, int score){
	if(u==n){
		if(a0 == 0 || b0 == 0 || c0 == 0) return;
		score -=30;
		score += abs(a0-a);
		score += abs(b0-b);
		score += abs(c0-c);
		ans=min(ans,score);
		return ;
	}
	for(int i=0;i<4;i++){
		if(i==0){
			dfs(u+1,a0+l[u],b0,c0,score+10);
		}
		if(i==1){
			dfs(u+1,a0,b0+l[u],c0,score+10);
		}
		if(i==2){
			dfs(u+1,a0,b0,c0+l[u],score+10);
		}
		if(i==3){
			dfs(u+1,a0,b0,c0,score);
		}
	}
}
int main(){
	cin>>n;
	cin>>a>>b>>c;
	cinf(n,l);
	dfs(0,0,0,0,0);
	cout << ans << endl;
}

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

int main(){
    int a,b;
    cin >> a >> b;
    if(a+b == 3)cout << 3 << endl;
    if(a+b == 4)cout << 2 << endl;
    if(a+b == 5)cout << 1 << endl;
}

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

dp = [sum(H) + 1] * N
dp[0] = 0

for i in range(1, N):
    if i - 2 >= 0:
        dp[i] = min(dp[i-2] + abs(H[i] - H[i-2]), dp[i])
    dp[i] = min(dp[i-1] + abs(H[i] - H[i-1]), dp[i])

print(dp[-1])

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

// Loops
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define _rrep(i, n) rrepi(i, n, 0)
#define rrepi(i, a, b) for (int i = int(a) - 1; i >= int(b); --i)

#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(xi, x) for (auto &&xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)

// typedef
template <class T> using vec = vector<T>;
using ll = long long;
using vi = vec<ll>;
using vvi = vec<vi>;
using vvvi = vec<vvi>;
using pii = pair<ll, ll>;

// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define mp make_pair

// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase(unique(all(v)), v.end())
#define perm(c)                                                                \
  sort(all(c));                                                                \
  for (bool c##p = 1; c##p; c##p = next_permutation(all(c)))

template <class T> pair<T, size_t> max(vector<T> &x) {
  auto it = max_element(all(x));
  return mp(*it, it - x.begin());
}
template <class T> pair<T, size_t> min(vector<T> &x) {
  auto it = min_element(all(x));
  return mp(*it, it - x.begin());
}

template <class T> inline bool chmax(T &maxval, const T &newval) {
  if (maxval < newval) {
    maxval = newval;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &minval, const T &newval) {
  if (minval > newval) {
    minval = newval;
    return 1;
  }
  return 0;
}

// Utilities
// Grid world utilities
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
#define inside(H, W, y, x) 0 <= (x) && (x) < (W) && 0 <= (y) && (y) < (H)

// Debug
#ifdef LOCAL
#include "dump.hpp"
#define debug(x) cerr << #x << ": " << x << '\n'
#else
#define dump(...)
#define debug(x)
#endif

// Paste snippets here!!

//

void solve(long long X) {
  ll ret = (X / 500) * 1000;
  X -= (X/500) * 500;
  ret += (X / 5) * 5;
  cout << ret << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false); // Magic for faster cin
  cout.precision(12);
  long long X;
  std::cin >> X;
  solve(X);
  return 0;
}


Measured memory_bytes: 3604
#include<iostream>
#include<map>
using namespace std;
int main()
{
	map<int , int> mp;
	int n;	cin>>n;
	for(int i=1;i<=n;i++){
		int x;	cin>>x;
		mp[x]++;
		if(mp[x]==2){
			cout<<"NO"<<endl;
			return 0;
		}
	}
	cout<<"YES"<<endl;
}

Measured memory_bytes: 9600
#include<iostream>
using namespace std;
int main(){
    int m,f,r;
    while(1){
        cin>>m>>f>>r;
        if(m==-1 && f==-1 && r==-1)   break;
        else if(m==-1 || f==-1)   cout<<"F"<<endl;
        else if(m+f>=80)    cout<<"A"<<endl;
        else if(m+f>=65)    cout<<"B"<<endl;
        else if(m+f>=50)    cout<<"C"<<endl;
        else if(m+f>=30){
            if(r>=50)   cout<<"C"<<endl;
            else    cout<<"D"<<endl;
        }
        else cout<<"F"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
static const int INF (1<<30);

int main() {
  int N; cin >> N;
  double x = 0;
  rep(i, N) {
    int y; cin >> y;
    x += 1.0 / y;
  }

  double ans = 1.0 / x;
  printf("%.10f\n", ans);

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int                     memo[2000] = {0};
const int       STD = 1000000007;

int             culc_pattern(int s)
{
        int     ret = 1;
        int     temp;
        int     i;

        if (s <= 5)
                return (1);
        for (i = 3; i <= s - 3; i++)
        {
                if (memo[i] != 0)
                        temp = memo[i];
                else
                {
                        temp = culc_pattern(i);
                        memo[i] = temp;
                }
                ret = (ret + temp) % STD;
        }
        return (ret);
}

int             main(void)
{
        int     s;
        int     ans = 0;

        scanf("%d", &s);
        if (s < 3)
        {
                printf("%d\n", 0);
                return (0);
        }
        ans = culc_pattern(s) % STD;
        printf("%d\n", ans);
        return (0);
}

Measured memory_bytes: 1712
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
using namespace std;
int main(){
    int hantei =0;
    string S;
    cin >> S;
    rep(i,4){
        if(S[i]==S[i+1]){
            hantei=1;
        }
    }
    if(hantei==1){
        cout << "Bad" <<endl;
    }    
    else{
        cout << "Good" <<endl;
    }
    return 0;
}


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

using namespace std;

template <typename T> T gcd(T x, T y) {
  if (y == 0)
    return x;
  return gcd(y, x % y);
}

template <typename T> T lcm(T x, T y) {
  if (x == 0 || y == 0)
    return 0;
  return x / gcd(x, y) * y;
}

int main() {
  int N;
  cin >> N;
  N += 2;
  vector<int> A(N + 2, 0);
  for (int i = 1; i < N; i++)
    cin >> A[i];
  int sum = 0;

  for (int i = 1; i < N; i++)
    sum += abs(A[i - 1] - A[i]);

  for (int i = 1; i < N - 1; i++) {
    cout << sum - abs(A[i - 1] - A[i]) - abs(A[i] - A[i + 1]) +
                abs(A[i - 1] - A[i + 1])
         << endl;
  }
}


Measured memory_bytes: 2172
#include "bits/stdc++.h"
 
using namespace std;
 
// template<typename... T>
// void read(T&... args) {
//     ((cin >> args), ...);
// }
 
// template<typename... T>
// void write(T&&... args) {  
//     ((cout << args << " "), ...);
// }
 
// #define deb(x) cerr << #x << " " << x <<endl;
 
// #define debs(args ...) cerr << __LINE__ << ": ", err(new istringstream(string(#args)), args), cerr << '\n'
// void err(istringstream *iss) {}
// template<typename T, typename ... Args> void err(istringstream *iss, const T &_val, const Args & ... args) {
//     string _name;
//     *iss >> _name;
//     if (_name.back()==',') _name.pop_back();
//     cerr << _name << " = " << _val << "; ", err(iss, args ...);
// }


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

	int n;
	while(cin>>n){
		vector<int>lst(n);	
		for(int i=0; i<n; cin>>lst[i++]);
		vector<long long>dp(n+2,0);
		dp[2]=abs(lst[1]-lst[0]);

		for(int i=3; i<=n; ++i)
			dp[i]=min(dp[i-1]+abs(lst[i-1]-lst[i-2]), dp[i-2]+abs(lst[i-1]-lst[i-3]));

		cout<<dp[n]<<endl; 
	}
	
    return 0;
}

Measured memory_bytes: 1408
#include <stdio.h>
int main(void) {
	int n, count = 0;
	int p[50], change[50];
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
		scanf("%d", &p[i]);
	for (int i = 1; i <= n; i++) {
		if (p[i] != i) {
			change[count] = i;
			count++;
		}
	}
	if (count == 0) {
		printf("YES\n");
		return 0;
	}
	if (count == 1) {
		printf("NO\n");
		return 0;
	}
	int keep;
	keep = p[change[0]];
	p[change[0]] = p[change[1]];
	p[change[1]] = keep;
	for (int i = 1; i <= n; i++) {
		if (p[i] != i) {
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");
	return 0;
}

Measured memory_bytes: 128
import java.io.*;
import java.util.*;
public class Main
{
	
	private void solve()throws IOException
	{
		int l=nextInt();
		out.printf("%10f",1.0d*l*l*l/27.0);
	}

	 
	///////////////////////////////////////////////////////////

	public void run()throws IOException
	{
		br=new BufferedReader(new InputStreamReader(System.in));
		st=null;
		out=new PrintWriter(System.out);

		solve();

		br.close();
		out.close();
	}
	public static void main(String args[])throws IOException{
		new Main().run();
	}
	BufferedReader br;
	StringTokenizer st;
	PrintWriter out;
	String nextToken()throws IOException{
		while(st==null || !st.hasMoreTokens())
		st=new StringTokenizer(br.readLine());
		return st.nextToken();
	}
	String nextLine()throws IOException{
		return br.readLine();
	}
	int nextInt()throws IOException{
		return Integer.parseInt(nextToken());
	}
	long nextLong()throws IOException{
		return Long.parseLong(nextToken());
	}
	double nextDouble()throws IOException{
		return Double.parseDouble(nextToken());
	}
}

Measured memory_bytes: 21204
import numpy as np
N = int(input())
A = np.array(input().split(), dtype=int)
B = np.array(input().split(), dtype=int)
C = np.array(input().split(), dtype=int)
A.sort()
B.sort()
C.sort()

CB = np.searchsorted(B, C, side="left")
BA = np.searchsorted(A, B, side="left")
tmp = [0]+BA.cumsum().tolist()
tmp = np.array(tmp)

ans = tmp[CB].sum()
print(ans)


Measured memory_bytes: 26476
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;

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

    cout << max(c - (a - b), 0) << endl;
    return 0;
}

Measured memory_bytes: 256
#EDP-A
import sys
n = int(sys.stdin.readline())
H = list(map(int, sys.stdin.readline().split()))
dp = [0 for _ in range(n)]

#print(H)
dp[1] = abs(H[1]-H[0])
#print(dp)

for i in range(2, n):
    dp[i] = min(abs(H[i]-H[i-2])+dp[i-2], abs(H[i]-H[i-1])+dp[i-1])

print(dp[-1])

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

int w,h;
string field[21]; // ¶ðµ¤ÌÅstring^Ìzñðg¤ÆÖÅ·B

// 4ßT(ãº¶E)ÌÆ«ÍÌæ¤ÈzñðpÓ·éÆÖ
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};

// »Ýn(x,y)
void dfs(int x, int y){
	// ¡¢éÆ±ëð'B'Éu«·¦é
	field[y][x] = 'B';

	// Ú®·é4ûüð[v
	for(int i=0 ; i < 4 ; i++ ){
		// xûüÉdx[i], yûüÉdy[i], Ú®µ½êð(mx,my)Æ·é
		int mx = x + dx[i];
		int my = y + dy[i];
		// ÍÍOÉo½Æ«ÍÌÖ
		if( mx < 0 || my < 0 || mx >= w || my >= h ) continue;
		// ¢^C'.'¾Á½çÄAÄÑoµ
		if( field[my][mx] == '.' ){
			dfs( mx , my );
		}
	}
}

int main(){
	while( cin >> w >> h , w||h ){
		for(int y=0 ; y < h ; y++ ){
			cin >> field[y];
		}

		for(int y=0 ; y < h ; y++ ){
			for(int x=0 ; x < w ; x++ ){
				if( field[y][x] == '@' ){ // l'@'¾Á½çÄAÖðÄÑo·
					dfs( x , y );
				}
			}
		}
		int ans = 0;
		// [vÅ'B'Ìð¦é(BÂ\È¢^CÌ)
		for(int y=0 ; y < h ; y++ ){
			for(int x=0 ; x < w ; x++ ){
				if( field[y][x] == 'B' )
					ans++;
			}
		}
		cout << ans << endl;
	}
}

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

//#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))


int main(void){
    int N, K;
    cin >> N >> K;

    vector<double> vec(N);
    for (int i = 0; i < N; i++)
    {
    cin >> vec[i];
    }
    //vec = vec;
    for (int i = 0; i < vec.size(); ++i)
    {
        vec[i] = (vec[i]+1) / 2;
        //cout << vec[i] << endl;
    }
    vector<double> s(N+1, 0); // s[0] = 0 になる
    double maxs = 0;
    for (int i = 0; i < N; ++i) s[i+1] = s[i] + vec[i];
    for (int i = 0; i < N - (K-1); ++i)
    {
        maxs = max(maxs, s[i+K] - s[i]);
    }
    cout << setprecision(12) << maxs << endl;

}


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

int main() {
    ll x, mod, ans;
    cin >> x;
    mod = x % 11;
    ans = x / 11 * 2;
    if(mod == 0) {
        ans += 0;
    } else if(mod <= 6) {
        ans += 1;
    } else {
        ans += 2;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
#define PAUSE \
	int t;    \
	cin >> t
#define int long long
#define vi vector<long long>
#define mapii map<long long, int>
#define mapci map<char, int>
#define append(x) push_back(x)
#define tcase          \
	long long t;       \
	scanf("%lld", &t); \
	while (t--)
#define prq priority_queue
#define fio                           \
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL)
// #define debug(x, y) cout<<"case #"<<x<<" at itr #"<<y<<endl
#define debug(x) cout << "case #" << x << endl
#define ff first
#define ss second
#define range(ini, x) for (int itr = ini; itr < x; itr++)
#define takearr(x)    \
	for (auto &i : x) \
	cin >> i
#define print(x)     \
	for (auto i : x) \
		cout << i << " ";
#define FOR(x, y) for (int i = x; i < y; i++)
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define foreach(i, x) for (auto i : x)
#define setbitcount __builtin_popcount
//******************/
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif
//******************/
// #define range(ini, x, step) for( int itr = ini, i < x; itr += step )
using namespace std;
// using namespace __gnu_pbds;
// template < class type > using oset=tree<type, null_type,less<type>, rb_tree_tag,tree_order_statistics_node_update>;
const int mmx = 1e5 + 1;
const int mnx = 1e4 + 1;
const int mmod = 1e9 + 7;

int n, k;
int dp[mmx][3];
vector <array<int,3>> arr;

int func( int index, int prev ){

if( dp[index][prev] != -1 ) return dp[index][prev];

if( index == n - 1 ){

	int maxi = INT_MIN;
	for0(i,3){
		if( i != prev ) maxi = max( maxi, arr[index][i] );
	}
	dp[index][prev] = maxi;
	return dp[index][prev];
}

int maxxi = INT_MIN;
for0(i,3){
	if( i != prev ){
		maxxi = max( maxxi, arr[index][i] + func( index + 1, i ) );
	}
}

dp[index][prev] = maxxi;
return dp[index][prev];

}

signed main()
{

	memset(dp, -1, sizeof dp);

	cin>>n;
	for0(i,n){
		int x, y, z;
		cin>>x>>y>>z;
		arr.push_back( { x, y, z } );
	}


	cout<<max( func(0,0), max( func(0,1), func(0,2) ) );

	return 0;
}

Measured memory_bytes: 13424
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define endl '\n'
#define ll long long
#define P pair<int,int>

signed main() {
    string s;
    int k;
    cin >> s >> k;

    int n = s.size();
    vector<int> a(n);

    for(int i = 0; i < n; i++){
        int x = s[i] - 'a';
        a[i] = x;
    }

    for(int i = 0; i < n; i++){
        if(i == n - 1){
            a[i] += k;
            a[i] %= 26;
            break;
        }

        if(a[i] == 0) continue;
        if(a[i] + k < 26) continue;

        k -= (26 - a[i]);
        a[i] += (26 - a[i]);
        a[i] %= 26;
    }

    for(int i = 0; i < n; i++){
        char c = a[i] + 'a';
        cout << c;
    }
    cout << endl;
}



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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  vector<string> s(3);
  REP(i, 3)
    cin >> s[i];

  cout << "A" << s[1][0] << "C" << endl;

}


Measured memory_bytes: 256
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
  int n = sc.nextInt();
  int[] h = new int[n+2];
  h[0] = 0;
  h[n+1] = 0;
  for(int i = 0;i < n;i++){
    h[i+1] = sc.nextInt();
  }
  int cnt = 0;
  for(;;){
    int a = 200;
    int b = 200;
    for(int i = 0;i < n+2;i++){
      if(h[i] != 0){
        a = i;
        break;
      }
    }
    if(a == 200)break;
    for(int i = a;i < n+2;i++){
      if(h[i] == 0){
        b = i;
        break;
      }
    }
    for(int i = a;i < b;i++){
      h[i]--;
    }
    cnt++;
  }
  System.out.println(cnt);
}}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<ll>::iterator sit;
typedef map<ll,ll>::iterator mit;

ll dp[3001][5][5];
const int MOD = 1e9 + 7;

void add(ll &a, ll b)
{
	a+=b;
	a%=MOD;
	if(a<0) a+=MOD;
}

ll mult(ll a, ll b)
{
	return (a*b)%MOD;
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	string s1,s2;
	cin>>s1>>s2;
	if(s1[0]==s2[0])
	{
		for(int i=0;i<3;i++)
		{
			for(int j=0;j<3;j++)
			{
				if(i==j) dp[0][i][j] = 1;
			}
		}
		if(n==1)
		{
			cout<<3<<'\n';
			return 0;
		}
	}
	else
	{
		for(int i=0;i<3;i++)
		{
			for(int j=0;j<3;j++)
			{
				if(i!=j) dp[0][i][j] = 1;
			}
		}
		if(n==1)
		{
			cout<<6<<'\n';
			return 0;
		}
	}
	ll ans=0;
	for(int i=1;i<n;i++)
	{
		for(int j=0;j<3;j++)
		{
			for(int k=0;k<3;k++)
			{
				if(j==k&&s1[i]!=s2[i]) continue;
				if(j!=k&&s1[i]==s2[i]) continue;
				for(int l=0;l<3;l++)
				{
					for(int m=0;m<3;m++)
					{
						if(s1[i]==s1[i-1]&&l!=j) continue;
						if(s1[i]!=s1[i-1]&&l==j) continue;
						if(s2[i]==s2[i-1]&&m!=k) continue;
						if(s2[i]!=s2[i-1]&&m==k) continue;
						add(dp[i][j][k],dp[i-1][l][m]);
					}
				}
				if(i==n-1) add(ans,dp[i][j][k]);
			}
		}
	}
	ans%=MOD;if(ans<0) ans+=MOD;
	cout<<ans<<'\n';
}


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

class Program
{
    static void Main()
    {
        var str = Console.ReadLine();
        var array = str.Split(' ').Select(s => int.Parse(s)).ToArray();
        
        for(int i = 0; i < 3; i++){
            for(int l = 2; l > i; l--){
                
                if(array[l] < array[l-1]){
                    var tmp = array[l];
                    array[l] = array[l-1];
                    array[l-1] = tmp;
                }
                
            }
        }
        
        Console.WriteLine(array[0] + " " + array[1] + " " + array[2]);
    }
}



Measured memory_bytes: 18336
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

class Main{
	public static void main(String[] args) {
		List<String> youbi =
				new ArrayList<String>(Arrays.asList("mon","tue","wed","thu","fri","sat","sun"));
		int[] hi=new int[30];
		for(int i=0; i<30; i++) {
			hi[i]=(4+i)%7;
		}
		BufferedReader bfr=new BufferedReader(new InputStreamReader(System.in));
		String str="";
		int aa=0;
		while(true) {
			try {
				str=bfr.readLine();
				if(str==null) {
					System.exit(0);
				}
				aa=Integer.parseInt(str);
				
				if(aa>=31) {
					System.exit(0);
				}
				System.out.println(youbi.get((hi[aa-1])));
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}
}


Measured memory_bytes: 24552
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue>
#include <stack>
#include <map>
using namespace std;

int main()
{
    long long a,b,c;
    long long maxn;
    scanf("%lld %lld %lld",&a,&b,&c);
    if(a>b)maxn=a;
    else maxn=b;
    if(maxn>c)maxn=maxn;
    else maxn=c;
    if(maxn%2==0)printf("0");
    else
    {
        if(maxn==a)printf("%lld",b*c);
        else if(maxn==b)printf("%lld",a*c);
        else if(maxn==c)printf("%lld",a*b);
    }

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0; i < n; i++)

int main(){
    int N;
    cin >> N;
    vector<tuple<string, int, int>> vc(N);
    rep(i, N){
        string S;
        int P;
        cin >> S >> P;
        P = 100 - P;
        vc[i] = make_tuple(S, P, i+1);
    }
    sort(vc.begin(), vc.end());
    for(auto p : vc){
        cout << get<2>(p) << endl;
    }
    return 0;
}

Measured memory_bytes: 3592
#include <stdio.h>
int main(void){
  int n,k;
  scanf("%d%d",&n,&k);
  int count=0,tmp;
  for(int i=0;i<n;i++){
    scanf("%d",&tmp);
    if(tmp>=k)count++;
  }
  printf("%d\n",count);
  return 0;
}
  

Measured memory_bytes: 128
'''
問題を言い換えると
0<=bi<=ai for any iにおいて、sum_i bi = Kとなる通りの数を求めよ

dp[i,j] .. 通りの総数、総和がちょうどjになるとき、:iまでの子供を考慮したとき
dp[i+1,j]=sum_{k=0}^{a_{i}} dp[i,j-k]

これではTLEになりそうなので、累積和で高速に計算する必要がある
'''

import sys
sys.setrecursionlimit(1 << 25)
readline = sys.stdin.buffer.readline
read = sys.stdin.readline  # 文字列読み込む時はこっち

import numpy as np
from functools import partial
array = partial(np.array, dtype=np.int64)
zeros = partial(np.zeros, dtype=np.int64)
full = partial(np.full, dtype=np.int64)


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと


def a_int(): return int(readline())


def ints(): return np.fromstring(readline(), sep=' ', dtype=np.int64)


MOD = 10**9 + 7

N, K = ints()
A = ints()

from numba import njit


@njit('(i8,i8,i8[:])', cache=True)
def solve(N, K, A):
    dp = np.zeros((N + 1, K + 1), dtype=np.int64)
    dp[0, 0] = 1
    for i in range(N):
        # 前の列の累積和を作りたい
        total = 0
        for j in range(K + 1):
            # ai個でところてんすればいい
            total += dp[i, j]
            total %= MOD
            if j - A[i] - 1 >= 0:
                total -= dp[i, j - A[i] - 1]
            dp[i + 1, j] = total % MOD

    print(dp[N, K])


solve(N, K, A)


Measured memory_bytes: 189632
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main
{
  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
    String s;
    String sl[];

    s = r.readLine();
    sl = s.split(" ");
    int n = Integer.parseInt(sl[0]);
    int m = Integer.parseInt(sl[1]);

    boolean acd[] = new boolean[100001];
    int wa[] = new int[100001];

    for(int i = 0; i < m; i++)
    {
      s = r.readLine();
      sl = s.split(" ");
      int v = Integer.parseInt(sl[0]) - 1;
      if(sl[1].equals("AC"))
      {
        acd[v] = true;
      }
      else if(!acd[v])
      {
        wa[v]++;
      }
    }


    int acs = 0;
    int was = 0;
    for(int i = 0; i < n; i++)
    {
      if(acd[i])
      {
        acs++;
        was += wa[i];
      }
    }

    System.out.printf("%d %d", acs, was);
  }

}

class RemRing
{
  long module;

  public RemRing(long module)
  {
    this.module = module;
  }

  public long sum(long a, long b)
  {
    return (a + b + module) % module;
  }

  public long sub(long a, long b)
  {
    return (a - b + module) % module;
  }

  public long prod(long a, long b)
  {
    return (a * b) % module;
  }

  public long div(long a, long b)
  {
    return (a * inv(b)) % module;
  }

  public long inv(long a)
  {
    long b = this.module;
    long u = 1;
    long v = 0;
    while (b > 0)
    {
      long t = a / b;
      a -= t * b;
      u -= t * v;
      long z = a;
      a = b;
      b = z;
      z = u;
      u = v;
      v = z;
    }
    u %= this.module;
    if (u < 0)
      u += this.module;
    return u;
  }
}

Measured memory_bytes: 55816
N = int(input())
choice = [list(map(int, input().split())) for i in range(N)]
dp = [[-1] * (N), [-1] * (N), [-1] * (N)]
for x in range(N):
    if x == 0:
        dp[0][0] = choice[0][0]
        dp[1][0] = choice[0][1]
        dp[2][0] = choice[0][2]
    else:
        dp[0][x] = max(dp[1][x - 1], dp[2][x - 1]) + choice[x][0]
        dp[1][x] = max(dp[0][x - 1], dp[2][x - 1]) + choice[x][1]
        dp[2][x] = max(dp[0][x - 1], dp[1][x - 1]) + choice[x][2]
print(max(dp[0][-1], dp[1][-1], dp[2][-1]))


Measured memory_bytes: 66136
#include <bits/stdc++.h>
using namespace std;
int main()
{

    long long int  n;
    cin>>n;
    if(n%2==0){
        
        cout<<n/2<<endl;
    }else{
        cout<<(n/2)+1<<endl;
    }
    
    
    
    return 0;
}


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

int main()
{
  int k, a, b;
  cin >> k >> a >> b;
  for (int i = a; i <= b; i++) {
   if (i % k == 0) {
   	cout << "OK" << endl;
     return 0;
   }
  }
  cout << "NG" << endl;
}

Measured memory_bytes: 3608
#include <queue>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int V, E, s, t, w[5003], r[5003], d[5003]; vector<int> G[5003], H[5003];
int main() {
	scanf("%d%d", &V, &E);
	for(int i = 0; i < V; i++) scanf("%d%d", w + i, r + i);
	for(int i = 0; i < E; i++) {
		scanf("%d%d", &s, &t); s--, t--;
		G[s].push_back(t);
		G[t].push_back(s);
	}
	for(int i = 0; i < V; i++) {
		fill(d, d + V, -1); d[i] = 0;
		queue<int> que; que.push(i);
		while(!que.empty()) {
			int u = que.front(); que.pop();
			for(auto &e : G[u]) {
				if(d[e] == -1) {
					d[e] = d[u] + 1;
					H[i].push_back(e);
					if(d[e] < r[i]) que.push(e);
				}
			}
		}
	}
	fill(d, d + V, 1999999999); d[0] = 0;
	priority_queue<pair<int, int> > que2; que2.push(make_pair(0, 0));
	while(!que2.empty()){
		int u = que2.top().second; que2.pop();
		if(u == V - 1) { printf("%d\n", d[u]); break; }
		for(auto &e : H[u]) {
			if(d[e] > d[u] + w[u]) {
				d[e] = d[u] + w[u];
				que2.push(make_pair(-d[e], e));
			}
		}
	}
}

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

int main(){
    int n;
    cin >> n;
    vector<int> s(n);
    for(int i = 0; i < n; i++) cin >> s[i];
    int sum = 0;
    for(int i = 0; i < n; i++) sum += s[i];

    if(sum % 10 != 0) cout << sum << endl;
    else{
        int ans = 0;
        for(int i = 0; i < n; i++){
            if((sum-s[i])%10 != 0 && sum-s[i] > ans) ans = sum-s[i];
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <cassert>
#include <algorithm>
#include <string>
#include <map>
#define REP(i,k,n) for(int(i)=(k);(i)<(n);++(i))
using namespace std;

int N,M;

int main()
{
  cin >> N;
  map<string, int> mp1,mp2;
  REP(i,0,N) {
    string s;
    cin >> s;
    // s が2つ目以降
    if (mp1.count(s)) mp1[s] += 1;
    else mp1[s] = 1;
  }
  cin >> M;
  REP(i,0,M) {
    string t;
    cin >> t;
    if (mp2.count(t)) mp2[t] += 1;
    else mp2[t] = 1;
  }

  int max_score = 0;            // 無関係な文字列を言えば，最悪でも0点取れる．
  // sの全ての文字列
  for(auto it = mp1.begin(); it != mp1.end(); ++it) {
    string s = it->first;
    int score;                  // 何円？
    // mp2にその文字が含まれてるか？
    if (mp2.count(s)) {
      score = it->second - mp2[s]; // mp1[s] - mp2[s]
    } else {
      score = it->second;
    }

    max_score = max(max_score, score);
  }

  cout << max_score << endl;

  return 0;
}


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

template <typename T>
std::vector<std::pair<std::complex<T>, int>> convex_hull(std::vector<std::pair<std::complex<T>, int>> points) {
  std::sort(points.begin(), points.end(), [](const std::pair<std::complex<T>, int>& a, const std::pair<std::complex<T>, int>& b) {
    return (std::real(a.first) < std::real(b.first)) || ((std::real(a.first) == std::real(b.first)) && std::imag(a.first) < std::imag(b.first));
  });
  points.erase(std::unique(points.begin(), points.end()), points.end());

  int n = points.size(), k = 0;
  if (n < 3) return points;
  else {
    auto cross = [](const std::complex<T>& a, const std::complex<T>& b) {
      return std::real(a) * std::imag(b) - std::imag(a) * std::real(b);
    };

    std::vector<std::pair<std::complex<T>, int>> ret(n << 1);
    for (int i = 0; i < n; ret[k++] = points[i++]) {
      while (k >= 2 && cross(ret[k - 1].first - ret[k - 2].first, points[i].first - ret[k - 1].first) <= 0) --k;
    }
    for (int i = n - 2, t = k + 1; i >= 0; ret[k++] = points[i--]) {
      while (k >= t && cross(ret[k - 1].first - ret[k - 2].first, points[i].first - ret[k - 1].first) <= 0) --k;
    }
    ret.resize(k - 1);
    return ret;
  }
}

using namespace std;

int main(){
  int N;
  cin >> N;
  
  vector<pair<complex<double>, int>> holes(N);
  for(int i = 0; i < N; i++){
    double x, y;
    cin >> x >> y;
    
    holes[i] = {complex<double>(x, y), i};
  }
  
  vector<pair<complex<double>, int>> ch = convex_hull(holes);
  
  int n = ch.size();
  
  vector<double> prob(N, 0);
  for(int i = 0; i < n; i++){
    prob[ch[i].second] = (M_PI - arg((ch[(i - 1 + n) % n].first - ch[i].first) / (ch[(i + 1) % n].first - ch[i].first))) / (2 * M_PI);
  }
  
  cout << fixed << setprecision(10);
  for(int i = 0; i < N; i++){
    cout << prob[i] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 4168
#include <bits/stdc++.h>
#define endl '\n'
#define _USE_MATH_DEFINES
using namespace std;

int main() {
	
	ios::sync_with_stdio(false);
    cin.tie(0);
    
    long long int ans,a;
    long double b,c;
    cin>>a>>b;
    ans = a*b;
    cout<<ans;
    
	return 0;
}

Measured memory_bytes: 3736