akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <algorithm>

#define MOD_BIG 1000000007
using std::string;
using std::cin;
using std::cout;
using std::cerr;
using std::endl;
using ll = long long;
using std::vector;

template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) {
    vec.resize(len);
    for (auto &v : vec) ndarray(v, args...);
}

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



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

int main() {
    
    int N, K;
    cin >> N >> K;
    int ans = 0;
    for (int i = 0; i < N; i++) {
        int h;
        cin >> h;
        if (h >= K) {
            ans += 1;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict 
import sys
import math 
import random
def get_array(): return list(map(int , sys.stdin.readline().strip().split()))
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def input(): return sys.stdin.readline().strip()

sys.setrecursionlimit(10**5)

def r(ind):
    if dp[ind]!=-1:
        return dp[ind]
    if ind+1>=n:
        return 0
    ans1 = abs(a[ind+1]-a[ind])+r(ind+1)
    if ind+2>=n:
        dp[ind] = ans1 
        return dp[ind] 
    ans2 = abs(a[ind+2]-a[ind])+r(ind+2)
    dp[ind] = min(ans1,ans2)
    return dp[ind]

n = int(input())
a = get_array()
dp = [-1]*(n+5) 
print(r(0))


Measured memory_bytes: 169128
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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(){
    ll n;cin >> n;
    if(n%2)cout << 0 <<endl,exit(0);
    ll ans=0;
    ll t=2;
    rep(i,31){
        if(t==2980232238769531250)break;
        t*=5;
        ans+=n/t;
    }
    cout << ans <<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
 
int max(int a,int b){return (a<b?b:a);};
typedef struct {
  int p,s,deg,dep,h,left,right;
} Node;
 
Node t[100000];
int n;
 
void setdepth(int x){
  if(t[x].p==-1){
    t[x].dep=0;
    return;
  }
  if(t[x].dep==-1){
    setdepth(t[x].p);
    t[x].dep=t[t[x].p].dep+1;
  }
}
 
void setheight(int x){
 
  int l=t[x].left;
  int r=t[x].right;
  if(t[x].deg==0){
    t[x].h=0;
    return;
  }
  if(t[x].h==-1){
    if(l!=-1){
      setheight(l);
      t[x].h=max(t[x].h,t[l].h+1);
    }
    if(r!=-1){
      setheight(r);
      t[x].h=max(t[x].h,t[r].h+1);
    }
  }
}
 
void init(){
  int i;
  for(i=0;i<100000;i++){
    t[i].p=t[i].s=t[i].deg=t[i].dep=t[i].h=t[i].left=t[i].right=-1;
  }
}
 
int main(){
  init();
  int i,id,a,b;
 
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d %d %d",&id,&a,&b);
    if(a!=-1){
      t[id].left=a;
      t[a].p=id;
    }
    if(b!=-1){
      t[id].right=b;
      t[b].p=id;
    }
    if(a!=-1&&b!=-1){
      t[a].s=b;
      t[b].s=a;
    }
    t[id].deg=(a!=-1)+(b!=-1);
    
  }
 
  for(i=0;i<n;i++){
    printf("node %d: parent = %d, sibling = %d, degree = %d, ",i,t[i].p,t[i].s,t[i].deg);
    setdepth(i);
    setheight(i);
    printf("depth = %d, height = %d, ",t[i].dep,t[i].h);
     
    if(t[i].p==-1)printf("root\n");
    else if(t[i].deg!=0)printf("internal node\n");
    else printf("leaf\n");
     
  }
  return 0;
}



Measured memory_bytes: 5344
//

#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <iomanip>
#include <fstream>

using namespace std;

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

#define endl "\n"
#define mp make_pair

const int mod = 1000000007;
const int INF = 1000000000;

int k;
ll a[100005];
ll resMin, resMax;
bool ok = 1;

int main() {
	ll t1, t2;

	ios::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> k;

	for (int i = 0; i < k; i++) {
		cin >> a[i];
	}

	if (a[k - 1] != 2)
		ok = 0;
	else {
		resMin = 2;
		resMax = 3;
	}

	for (int i = k - 2; i > -1; i--) {
		if ((resMin - resMin % a[i]) < resMin)
			resMin += a[i] - resMin % a[i];

		resMax += a[i] - (resMax % a[i]) - 1;
	}

	t1 = resMin;
	t2 = resMax;

	for (int i = 0; i < k; i++) {
		t1 -= t1 % a[i];
		t2 -= t2 % a[i];
	}

	if ((t1 != 2) || (t2 != 2))
		ok = 0;
	
	if (ok)
		cout << resMin << " " << resMax << endl;
	else
		cout << -1;

	return 0;
}

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

int main() {
  int n;
  string s;
  cin >> n >> s;
  int x = 0;
  int xmax = 0;
  rep(i,n) {
    if (s[i] == 'I') x++;
    else x--;
    xmax = max(x, xmax);
  }
  cout << xmax << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <chrono>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define eps 1e-9

typedef long long ll;

using namespace std;

const int N = 1e5;
int a[N+5];

int digitSum (int n) {

    int sum = 0;

    while (n) {

        sum+=n%10;
        n/=10;
    }

    return sum;
}

int main()

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

    int n, a, b, ans = 0;

    cin >> n >> a >> b;

    for (int i = 1; i <= n; i++) {

        int z = digitSum(i);

        if (z >= a && z <= b) ans+=i;
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int n;
	int a,b;
	cin>>n;
	if(n==1)
		cout<<"Hello World"<<endl;
	else if(n==2)
	{
		cin>>a>>b;
		cout<<a+b;
	}
		
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

mi = min(a)
ma = max(a)

ans = 10 ** 10
for i in range(mi, ma + 1):
    buf = sum(map(lambda x: (x - i) ** 2, a))
    if ans > buf:
        ans = buf
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
int main() {
    std::cin.tie(nullptr); std::ios::sync_with_stdio(false);
    int A, B;
    std::cin >> A >> B;
    int ans = (((A > B) ? A : B) -= 1) + 1;
    ans += std::max(A, B);
    std::cout << ans << std::endl;
}

Measured memory_bytes: 256
#include <cstdio>

int main(int argc, char *argv[])
{
	int cards[4][13] = {0};
	char cc[4] = {'S' ,'H', 'C', 'D'};
	
	int n;
	scanf("%d ", &n);
	
	int t = n;
	while (t)
	{
		char buff[1024] = {0};
		gets(buff);
		
		char c0;
		int v;
		sscanf(buff, "%c %d", &c0, &v);
		switch (c0)
		{
		case 'S':
			cards[0][v-1] = 1;
			break;
		case 'H':
			cards[1][v-1] = 1;
			break;
		case 'C':
			cards[2][v-1] = 1;
			break;
		case 'D':
			cards[3][v-1] = 1;
			break;
		default:
			break;
		}
		t--;
	}
	
	for (int r = 0; r < 4; r++)
	{
		for (int c = 0; c < 13; c++)
		{
			if (cards[r][c] == 0)
				printf("%c %d\n", cc[r], c+1);
		}
	}
	
	return 0;
}

Measured memory_bytes: 1036
import java.util.Scanner;


public class Main 
{
    public static void main(String[] args) 
    {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int sum = 0;
        for(int i=1;i<n;i++)
        {
            sum+=i;
        }
        for(int i=1;i<m;i++)
        {
            sum+=i;
        }
        System.out.println(sum);
    }
}


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

int main() {
        int N;
        int a,b,ans=0;
        cin >> N;

        a=N/4;
        b=N/7;

        for(int i=0; i<=a; i++){
                for(int j=0; j<=b; j++){
                        if(4*i+7*j==N) ans++;
                }
        }

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

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

int main(){
   int x,y,i=0,a[3000],b[3000];
   0 <= x,y <= 10000;
   while(1){
       cin >> x >> y;
       a[i] = x;
       b[i] = y;
       if(x == 0 && y == 0) break;
       if(x <= y){
           cout << a[i] <<" "<< b[i] << endl;
        }else{
            cout << b[i] << " "<< a[i] << endl;
        }
        i++;
   } 
   return 0;
}


Measured memory_bytes: 3120
n = int(input())
a = list(map(int, input().split()))
s = [0]*n
for i in range(n):
	s[a[i]-1] += 1
k = 0
for i in range(n):
	if s[i] >= 2:
		k += ((s[i]*(s[i]-1))//2)
for i in range(n):
	if s[a[i]-1] >= 2:
		print(k-(s[a[i]-1]-1))
	else:
		print(k)

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

int main(){
	string S;
	int Q;
	
	cin >> S >> Q;
	int flag=0;
	string A,B;
	for(int i=0;i<Q;i++){
		 int T;
		 cin >> T;
		 if(T==1){
		 	flag^=1;
		 }else{
		 	int F;
		 	string C;
		 	cin >> F >> C;
		 	if(F==1){
		 		if(flag==0)A+=C;
		 		else B+=C;
		 	}else{
		 		if(flag==0)B+=C;
		 		else A+=C;
		 	}
		 }
	}
	reverse(A.begin(), A.end());
	S=A+S+B;
	if(flag==1)reverse(S.begin(), S.end());
	cout << S << endl;
}

Measured memory_bytes: 1348
N = int(input())
h= list(map(int, input().split()))
dp = [0 for i in range(N)]
dp[1] = abs(h[1]-h[0])
for i in range(2,N):
    dp[i] = min(dp[i-1] + abs(h[i]-h[i-1]), dp[i-2] + abs(h[i] - h[i-2]))

print(dp[N - 1])

Measured memory_bytes: 20560
#include <stdio.h>

int main(void)
{ 
	int a[3];
	int i,j,m;
	for(i=0;i<3;i++) scanf("%d",&a[i]);
	for(i=0;i<3;i++){
		for(j=i+1;j<3;j++){
			if(a[i]>a[j]){
				m=a[i];
				a[i]=a[j];
				a[j]=m;
			}
		}
	}
	printf("%d %d %d\n",a[0],a[1],a[2]);
	return 0;
}


Measured memory_bytes: 2712
function main(lines) {
  const input = lines.split(' ')
  const a = parseInt(input[0], 10)
  const b = parseInt(input[1], 10)
  const S = a * b
  const L = 2*a + 2*b
  
  console.log(S + ' ' + L)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 15384
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<string>
#include<queue>
#include<utility>
#include<cmath>
#include<sstream>
#include<istream>
#include<numeric>
#include<stdlib.h>

using namespace std;

int main()
{
  long long X, K, D;
  cin >> X >> K >> D;

  long long jump_cnt = abs(X)/D;

  long long rest_cnt = K - jump_cnt;
  if(rest_cnt < 0){
    cout << min( abs(X+K*D), abs(X-K*D) ) << endl;
    return 0;
  }

  X = X % D;

  if(rest_cnt % 2 == 0){
    cout << abs(X) << endl;
  }
  else{
    cout << min( abs(X+D), abs(X-D) ) << endl;
  }

  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<ll>;
using vvi = vector<vector<ll>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const ll MOD = 1000000007;
const ll INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(ll i=0;i<(ll)(s.size());++i) {
    cout << s[i];
    if(i == (ll)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
signed main() {
  cin.tie(0);
  cout << fixed << setprecision(10);
  string s; cin >> s;
  ll k; cin >> k;
  bool same = true;
  for(ll i=0;i<(ll)(s.size());++i) {
    if(s[0] != s[i]) {
      same = false;
      break;
    }
  }
  if(same) {
    cout << k * ((ll)(s.size())) / 2 << endl;
    return 0;
  }
  vector<ll> v;
  ll cnt = 1;
  for(ll i=1;i<(ll)(s.size());++i) {
    if(s[i] == s[i-1]) {
      cnt++;
    } else {
      v.push_back(cnt);
      cnt = 1;
    }
  }
  if(cnt) v.push_back(cnt);
  ll beg = v[0], ed = v[(ll)(v.size()) - 1];
  ll su = 0;
  for(ll i=1;i<(ll)(v.size())-1;++i) {
    su += v[i] / 2;
  }
  if(s[0] == s[(ll)(s.size())-1]) cout << su * k + beg/2 + ed/2 + ((beg + ed) / 2) * (k-1) << endl;
  else cout << (su + beg/2 + ed/2) * k << endl;
}


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

int main(){
    long long A,B,C,D;
    cin >> A >> B >> C >> D;
    long long X = B/C-(A-1)/C;
    long long Y = B/D-(A-1)/D;
    long long Z = B/(C/__gcd(C,D)*D)-(A-1)/(C/__gcd(C,D)*D);
    cout << B-A+1-X-Y+Z << endl;
}


Measured memory_bytes: 256
s = gets.chomp.split("")
digit = s.length - 1

comb_count = 2 ** digit

answer = 0
comb_count.times do |i|
  ary = ("%0#{digit}b" % i).split("")
  formula = ""
  s.length.times do |j|
    formula += s[j]
    if ary[j] == "1"
      formula += "+"
    end
  end
  answer += eval(formula)
end

puts answer

Measured memory_bytes: 1916
import java.util.Scanner;

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];
		int ans = 0;
		
		for (int i= 1; i <= N; i++){
			a[i] = sc.nextInt();
		}
		int x = 1;
		while (ans < N){
			x = a[x];
			ans++;
			if (x == 2) {
				System.out.println(ans);
				sc.close();
				return;
			}
		}
		
		System.out.println("-1");
		sc.close();
	}
}


Measured memory_bytes: 50840
#include<bits/stdc++.h>
using namespace std;
#define int long long 
const int m=1e9+7;
int n;
void matmul(int a[51][51], int b[51][51])
{
    int c[51][51]={};
    for(int i=0; i<n; ++i)
    {
        for(int j=0; j<n; ++j)
        {
            for(int k=0; k<n; ++k)
            {
                c[i][j]=(c[i][j] + a[i][k]*b[k][j]%m )%m;
            }
        }
    }
    for(int i=0; i<n; ++i)
    {
        for(int j=0; j<n; ++j)
        {
            a[i][j]=c[i][j];
        }
    }
}
void cpy(int a[51][51], int b[51][51])
{
    for(int i=0; i<n; ++i)
    {
        for(int j=0; j<n; ++j)
            a[i][j]=b[i][j];
    }
}
void powr(int r, int a[51][51], int ans[51][51])
{
    if(r==1)
    {
        cpy(ans, a);
        return;
    }
    powr(r>>1, a, ans);
    matmul(ans, ans);
    if(r&1)
    {
        matmul(ans, a);
    }
}
int32_t main()
{
    int k;
    cin>>n>>k;
    int a[51][51];
    for(int i=0; i<n; ++i)
    {
        for(int j=0; j<n; ++j)
        {
            cin>>a[i][j];
        }
    }
    int res[51][51]={};
    powr( k, a,  res);
    int ans=0;
    for(int i=0; i<n; ++i)
    {
        for(int j=0; j<n; ++j)
        {
            ans=(ans+res[i][j])%m;
        }
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include<cstdio>

int main() {
	int n, a, b;
	scanf("%d %d %d", &n, &a, &b);
	if(n + 1 >= a + b && (long long)a * (long long)b >= n) {
		int m = n;
		for(int i=b;i>0;i--) {
			printf("%d\n", i);
			int from = b+1 > m-a+2 ? b+1 : m-a+2;
			for(int j=from;j<=m;j++) {
				printf("%d\n", j);
			}
			if(m >= from) m = from-1;
		}
	} else {
		printf("-1\n");
	}
	return 0;
}


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

int main(){
	int n, m;
	cin >> n >> m;
	int a[100][100], b[100];
	for(int k = 0; k < n*m; k++){
		int i = k / m;
		int j = k - m*i;
		cin >> a[i][j];
	}
	for(int j = 0; j < m; j++){
		cin  >> b[j];
	}
	for(int i = 0; i < n; i++){
		int c = 0;
		for(int j = 0; j < m; j++) c += a[i][j] * b[j];
		cout << c << endl;
	}
	return 0;
}

Measured memory_bytes: 1200
#include <iostream>
#include <string>

using namespace std;

int main() {
    int number_to_replace;
    string input, output;
    char word_after_changing;
    bool condition = false;

    do {    
        cin >> number_to_replace;
        cin >> input;
        // 0 ≦ number_to_replace ≦ 26 と 1 ≦ input ≦ 10^4 のとき、
        // while文を抜ける
        if(number_to_replace >= 0 || number_to_replace <= 26) {
            if(input.length() >= 1 || input.length() <= 10*10*10*10) {
                condition = true;
            }
        }
    } while(!condition);

    for(int i = 0; i < input.length(); i++) {
        word_after_changing = input[i] + number_to_replace;
        // 変換後がZ以上になるときはAに戻す
        if(word_after_changing > 'Z') {
            word_after_changing = ('A' - 1) + (word_after_changing - 'Z');
        }
        output += word_after_changing;
    }

    cout << output << endl;

    return 0;
}

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

 ll GCD (ll a, ll b) {
   return b ? GCD (b, a % b) : a;
 }

 vector<pair<ll, ll>> pf(ll n) {
    vector<pair<ll, ll>> res;
    for (ll p = 2; p * p <= n; p++) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) {
           n /= p;
           num++;
        }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

 int main() {
   ll A, B;
   cin >> A >> B;

   cout << pf(GCD(A, B)).size() + 1 << endl;
 }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    int a; cin >> a;
    int b; cin >> b;
    if (abs(b-a) % 2 == 1){
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }
    cout << (a+b) / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

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

int main()
{
	int W, H, C;
	cin >> W >> H >> C;

	int g = gcd(W, H);
	int c = C * (W / g) * (H / g);
	cout << c << endl;

	return 0;
}


Measured memory_bytes: 3108
from collections import deque
n = int(input())
a = [int(x) for x in input().split()]
b = deque()

rev = False

for i in range(n):
    if not rev:
        b.append(a[i])
    else:
        b.appendleft(a[i])
    rev = not rev

if rev:
    print(*list(b)[::-1])
else:
    print(*list(b))

Measured memory_bytes: 25532
#include<iostream>
#include<vector>

using namespace std;

int main(){
    int N,M,C,sum;

    cin >> N >> M >> C;

    vector<int> B(M);
    int A[N][M];

    for(int i=0;i<B.size();i++){
        cin >> B[i];
    }

    for(int i=0;i<N;i++){
        for(int j=0;j<M;j++){
            cin >> A[i][j];
        }
    }
    
    int sorce = 0;
    
    for(int i=0;i<N;i++){

        sum=C;

        for(int j=0;j<M;j++){
            sum+=A[i][j]*B[j];
        }

        if(sum>0){
            sorce++;
        }
    }

    cout << sorce << endl;
}

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 	int a, b, x;
 	cin >> a >> b >> x;
 	if(x >= a && x - a <= b && x < a+b)
 		cout << "YES" << endl;
 	else
 		cout << "NO" << endl;	

    return 0;
}

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

using namespace std;

int main() {
  
  int n,i,l,j;
  cin>>n>>l;
  string s;
  vector<string>v;
  
  for(i=0;i<n;i++)
  {
      cin>>s;
      v.push_back(s);
  }

  sort(v.begin(),v.end());
  
  for(i=0;i<n;i++)
  {
      for(j=0;j<l;j++)cout<<v[i][j];
  }

}

Measured memory_bytes: 3588
#ifdef LOCAL_BUILD
#include "pch.h"
#define DLOG(msg) cout << "#" << __LINE__ << ":" << msg << endl;
#else
#include <bits/stdc++.h>
#define DLOG(msg)
#endif
using namespace std;

template <typename T = int, int Size = 100000>
struct Queue {
  Queue() : in_buf_(new T[Size]), out_buf_(new T[Size]) {}

  T pop() {
    if (out_index_ == out_limit_) {
      out_buf_.swap(in_buf_);
      out_limit_ =  in_index_;
      in_index_ = 0;
      out_index_ = 0;
    }
    return out_buf_[out_index_++];
  }

  void put(T t) { in_buf_[in_index_++] = t; }

  bool empty() const {
    return !in_index_ && (out_index_ == out_limit_);
  }

 private:
  size_t in_index_ = 0;
  size_t out_limit_ = 0;
  size_t out_index_ = 0;
  unique_ptr<T[]> in_buf_;
  unique_ptr<T[]> out_buf_;
};

struct Process {
  string name;
  int time;
};

int main() {
  int n, q;
  cin >> n >> q;
  Queue<Process, 100000> Q;
  for (int i = 0; i < n; ++i) {
    Process proc;
    cin >> proc.name >> proc.time;
    Q.put(move(proc));
  }
  uint64_t elapsed = 0ULL;
  while (!Q.empty()) {
    auto proc = Q.pop();
    if (proc.time <= q) {
      elapsed += proc.time;
      cout << proc.name << " " << elapsed << endl;
    } else {
      elapsed += q;
      proc.time -= q;
      Q.put(proc);
    }
  }
}

Measured memory_bytes: 8336
#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
#include <stdio.h>
#include <bits/stdc++.h>

using namespace std;

#include <x86intrin.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define all(x) x.begin(), x.end()

#define mp make_pair
#define in insert
#define er erase
#define con continue
#define pb push_back
#define sc scanf
#define pr printf
#define ub upper_bound
#define lb lower_bound
#define s second
#define f first
//#define int long long

const long long infl = 1e18; 
const int N = 3e5 + 300, N2 = 2e3, inf = 1e9 + 200;

set <int> S;
vector <int> g;
int n, m, k;
int a[N], d[N];
string ss;

int rast(int x, int y){
	return abs(a[x] - a[y]);
}

main (){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> a[i];
	}
	d[1] = rast(0, 1);
	for (int i = 2; i < n; i++){
		d[i] = min(d[i - 2] + rast(i, i - 2), d[i - 1] + rast(i, i - 1));
	}
	cout << d[n - 1];
	return 0;
}












Measured memory_bytes: 1024
n , c , k = map(int,input().split())
t = [int(input()) for i in range(n)]
t.sort()

ans = 0
cou = 0
lim = 0

for i in range(n):
    if lim == 0:
        lim = t[i] + k
        cou = 1
        if c == 1:
            lim = 0
            cou = 0
            ans += 1
    elif lim > t[i]:
        if cou == c - 1:
            ans += 1
            cou = 0
            lim = 0
        elif cou < c - 1:
            cou += 1
    elif lim == t[i]:
        ans += 1
        cou = 0
        lim = 0
    elif lim < t[i]:
        ans += 1
        cou = 1
        lim = t[i] + k

if cou > 0:
    ans += 1

print(ans)
        

Measured memory_bytes: 7512
#include <iostream>
#include <bits/stdc++.h>
#define ll long long int
using namespace std;

ll p[13];
ll pp[13];

void prep()
{
    p[0]=1;
    pp[0]=1;
    for(int i=1;i<13;i++) p[i]=p[i-1]*2;
    for(int i=1;i<13;i++) pp[i]=pp[i-1]*10;
}

int main()
{
    ll res=0;
    string s; cin>>s;
    prep();
    int n=s.length();
    for(int i=0;i<n;i++)
    {
        int bfr=i;
        int beh=n-i-1;
        for(int w=0;w<=10;w++)
        {
            if(beh<w) break;
            ll dig=s[i]-'0';
            dig*=pp[w];
            dig*=p[bfr];
            ll x=beh-w;
            dig*=p[max(0LL,x-1)];
            res+=dig;
        }
    }
    cout<<res;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define mxn (1<<16)
#define ll long long
#define lowbit(x) (x&-x)
#define mdn 1000000007
using namespace std;

int f[mxn],in[16],n,m;
int b[16][mxn];
int sg[16][mxn],cnt[16][mxn];

int main()
{
	int i,j,x,y,k;
	scanf("%d%d",&n,&m);
	for(i=1;i<=m;i++)
	{
		scanf("%d%d",&x,&y);x--;y--;
		b[x][1<<y]=1;
	}
	for(i=0;i<n;i++)
		for(j=1;j<(1<<n);j++)
			cnt[i][j]=cnt[i][j^lowbit(j)]+b[i][lowbit(j)];
	f[0]=1;
	for(i=1;i<(1<<n);i++)
	{
		if(((i&3)==3)||((i&3)==0))
		{
			f[i]=1;
			for(j=i;~j;j=(j?(j-1)&i:j-1))// mei ju zi ji
			{
				if(j==i||j==0)	continue;
				if(((j&3)!=0)&&((j&3)!=3))	continue;
				int cur=f[j^i];
				for(k=0;k<n;k++)
				{
					if(j&(1<<k))// shu yu zi ji
						cur=((ll)cur*(1ll<<cnt[k][i^j])%mdn)%mdn;
					else if(i&(1<<k))// shu yu bu ji
						cur=((ll)cur*((1ll<<cnt[k][j])-1ll)%mdn)%mdn;
				}
				f[i]=((ll)f[i]+cur)%mdn;
			}
		}
	}
	int cur=1;
	for(i=1;i<=m;i++)	cur=(cur<<1ll)%mdn;
	printf("%d\n",((ll)cur-f[(1<<n)-1]+mdn)%mdn);
	return 0;
}

Measured memory_bytes: 7552
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {($($a:expr),*) => {println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}
#[allow(unused_macros)]
macro_rules! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> { fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering { self.0.partial_cmp(&other.0).unwrap() }}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;


fn main() {
    input!{s:chars};
    println!("{}", s.iter().enumerate().filter(|&(i,_x)| i%2==0).map(|(_,x)| x).cloned().collect::<String>());
}


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

int main(){
  int N,M;  cin >> N >> M;
  int cc[30] = {};

  for(int i = 0;i < N;i++){
    int K;
    cin >> K;
    for(int j = 0;j < K;j++){
      int emp;
      cin >> emp;
      cc[emp-1]++;
    }
  }

  int count = 0;
  for(int i = 0;i < 30;i++){
    if(cc[i] == N)count++;
  }

  cout << count << endl;


}


Measured memory_bytes: 256
import copy
import bisect
import sys
input = sys.stdin.readline

N,M=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))

mod=10**9+7
As=copy.deepcopy(A)
Bs=copy.deepcopy(B)
As.sort()
Bs.sort()

ans=0

if len(set(A))==N and len(set(B))==M:
    ans=1
    for i in range(N*M,0,-1):
        ai=bisect.bisect_left(As,i)
        bi=bisect.bisect_left(Bs,i)
        if ai>=N or bi>=M:
            ans=0
            break
        if As[ai]==i:
            if Bs[bi]==i:
                #1通りに定まる
                continue
            else:
                ans*=M-bi
        elif Bs[bi]==i:
            ans*=N-ai
        else:
            #置けるます-すでに置かれているます
            ans*=(N-ai)*(M-bi)-(N*M-i)
        ans%=mod
        
print(ans%mod)

Measured memory_bytes: 44968
#include<bits/stdc++.h>
using namespace std;
#define ll long long int

int main() {

    ll N;
    cin >> N;

    vector<ll> x, y;
    ll tx, ty;
    for (int i = 0; i < N; i++) {
        cin >> tx >> ty;
        x.push_back(tx);
        y.push_back(ty);
    }

    double ans = 0;
    double sum = 0;
    for (int i = 0; i < N-1; i++) {
        sum = 0;
        for (int j = i+1; j < N; j++) {
            sum += sqrt((x[i] - x[j])*(x[i] - x[j]) + (y[i] - y[j])*(y[i] - y[j]));
        }
        ans += (sum / N * 2);
    }

    cout << setprecision(15) << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
    int N, H;
    cin >> N >> H;
    int a[100000], b[100000];
    for(int i=0;i<N;i++)
        cin >> a[i] >> b[i];
    //降順ソート
    sort(a, a + N, greater<int>());
    sort(b, b + N, greater<int>());

    int count = 0;  //攻撃回数
    //投げ刀
    for(int i=0;b[i] > a[0] && 0 < H;i++){
        H -= b[i];
        count++;
    }
    //振り刀
    while(0 < H){
        H -= a[0];
        count++;
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll mod=1000000007;
const int MAX_N = 1000;         // n の最大値
 
// nCk を取得
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
 
int main() {
int k,t;
string s;
cin>>s;
k = s.size();
if(k<=3){cout<<"No"<<endl;}
else if(s.at(0)=='Y'&&s.at(1)=='A'&&s.at(2)=='K'&&s.at(3)=='I'){
cout<<"Yes"<<endl;}
else{
cout<<"No"<<endl;}}


Measured memory_bytes: 3604
n = int(input())
a = [list(map(int,input().split()))for i in range(2)]
adef = [[0]*n for i in range(2)]
for i in range(2):
    for j in range(n):
        adef[i][j] = a[i][j]
vec = ((0,1),(1,0))
stack = [(0,0)]
while stack:
    next = []
    for x,y in stack:
        for nx,ny in vec:
 
            tx = x+nx
            ty = y+ny
            if tx <0 or ty< 0 or tx >1 or ty > n-1:continue
            next.append((tx,ty))
            a[tx][ty] = max(adef[tx][ty]+ a[x][y],a[tx][ty])
           
    stack = next
    if (1,n-1) in stack:break
print(a[1][n-1])


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

int main() {

  int N, K, x, l, M;
  cin >> N >> K;
  l = 0;
  M = K / 2;

  for (int i = 0; i < N; i++) {
    cin >> x;
    if (x <= 0 || x >= K) break;
    else if (x <= M) l += x;
    else l += K - x;
  }

  cout << l * 2 << endl;

}


Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Convert;
using static System.Console;
using static System.Math;
class MainClass
{
	static void Main(string[] args)
	{
		Answer();
	}
	public static void Answer()
	{
      var str = Console.ReadLine();
      var ans3 = "";
      for (int i = 1; i <= str.Length; i+=2)
      {
        ans3 += str[i-1];
      }
      Console.WriteLine(ans3);
	}
}


Measured memory_bytes: 32724
N = int(input())
h = list(map(int, input().split()))
dp = [float("inf") for _ in range(N)]
dp[0] = 0
for i in range(N - 1):
	dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i + 1] - h[i]))
	if i < N - 2:
		dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i + 2] - h[i]))
print(dp[N - 1])

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


int main(){
	int n,k,m,j;
	cin >> n;
	int M[100][100] = {};
	for (int i = 0;i < n;i++) {
		cin >> m>>k;
		for (int l = 0;l < k;l++) {
			cin >> j;
			M[m - 1][j - 1] = 1;
		}
	}
	for (int i = 0;i < n;i++) {
		for (int l=0;l < n;l++) {
			if(l>0){
			    cout<<" ";
			    
			}
			cout << M[i][l] ;
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3128
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <algorithm>
#include <functional>

using namespace std;

#define rep(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define each(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)

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

int w,h,res;
char field[30][30];

void dfs(int y, int x){
  int i;

  res++;
  rep(i,4){
    int my = y + dy[i], mx = x + dx[i];
    if(0 <= my && 0 <= mx && my < h && mx < w && field[my][mx] != '#' && field[my][mx] != '@'){
      field[my][mx] = '#';
      dfs(my,mx);
    }
  }
}

int main(){
  int i,j;

  while(true){
    scanf("%d %d",&w,&h);
    if(w == 0 && h == 0) break;
    res = 0;
    rep(i,h) scanf("%s",field[i]);
    rep(i,h) rep(j,w) if(field[i][j] == '@') dfs(i,j);
    printf("%d\n",res);
  }

  return 0;
}

Measured memory_bytes: 1196
#include <stdio.h>

long int abs(long int a){
  if(a<0){
    return -a;
  }
  return a;
}

long int min(long int a, long int b){
  if(a>b){
    return b;
  }
  return a;
}

int main(){
  int N;
  scanf("%d",&N);
  int K;
  scanf("%d",&K);
  long int h[100001];
  int i;
  for(i=1;i<=N;i++){
    scanf("%ld",&h[i]);
  }
  long int dp[100001];
  dp[1]=0;
  for(i=2;i<=K;i++){
  	dp[i]=abs(h[i]-h[1]);
  }
  for(i=K+1;i<=N;i++){
  	dp[i]=2*10000*100000;
  	int j;
    for(j=1;j<=K;j++){
    	dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
    }
  }
  printf("%ld",dp[N]);
}

Measured memory_bytes: 1664
import java.util.*;
public class Main {
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
      
        int A = sc.nextInt();
        int B = sc.nextInt();
        
if (A == 1) {
 if  (B == 2) {
 System.out.println("3");
 } else {
 System.out.println("2");
 }
} else if (A == 2) {
  if  (B == 1) {
 System.out.println("3");
 } else {
 System.out.println("1");
 }
} else {
  if  (B == 1) {
 System.out.println("2");
 } else {
 System.out.println("1");
 }
}
     }
}

Measured memory_bytes: 23892
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,temp = 0,ans = 0,i;
    cin>>n;
    string s;
    cin>>s;
    for(i = 0; i < n; i++)
    {
        if(s[i] == 'I')
            temp++;
        if(s[i] == 'D')
            temp--;
        ans = max(temp,ans);
    }
    cout<<ans<<endl;
}


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

int main(){
	int input[10];
	for(int i=0; i<10; i++){
		cin >> input[i];
	}
	sort(input, input+10);

	for(int i =1; i <= 3; i++){
		cout << input[10-i] << endl;
	}
}

Measured memory_bytes: 1176
#include <iostream>
#include <vector>

using namespace std;

const int MN = 100100;

vector<int> g[MN];
int res[MN];
string que[MN];
int rq[MN][26];
int buf[26][26];
int nw;
struct Node {
    using NP = Node*;
    NP nx[26] = {};
    int id = -1, sz = 0;
    void add(string &s, int pos, int id) {
        sz++;
        if (pos == int(s.size())) {
            this->id = id;
            return;
        }
        int nc = s[pos]-'a';
        if (!nx[nc]) {
            nx[nc] = new Node();
        }
        nx[nc]->add(s, pos+1, id);
    }
    void dfs() {
        if (id != -1) {
            for (int qid: g[id]) {
                res[qid] = nw;
                for (int i = 0; i < 26; i++) {
                    for (int j = 0; j < 26; j++) {
                        if (rq[qid][j] < rq[qid][i]) {
                            res[qid] += buf[i][j];
                        }
                    }
                }
            }
            nw++;
        }
        for (int i = 0; i < 26; i++) {
            if (!nx[i]) continue;
            for (int j = 0; j < 26; j++) {
                if (i == j) continue;
                if (!nx[j]) continue;
                buf[i][j] += nx[j]->sz;
            }
            nx[i]->dfs();
            for (int j = 0; j < 26; j++) {
                if (i == j) continue;
                if (!nx[j]) continue;
                buf[i][j] -= nx[j]->sz;
            }
        }
        if (id != -1) {
            nw--;
        }
    }
};

int main() {
    ios::sync_with_stdio(0);
    Node* trie = new Node();
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        trie->add(s, 0, i);
    }
    //cout << trie->sz << endl;
    int q;
    cin >> q;
    for (int i = 0; i < q; i++) {
        int k;
        cin >> k >> que[i];
        for (int j = 0; j < 26; j++) {
            rq[i][que[i][j]-'a'] = j;
        }
        g[k-1].push_back(i);
    }
    trie->dfs();
    for (int i = 0; i < q; i++) {
        cout << res[i]+1 << endl;
    }
    return 0;
}


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



int main(){
    long long int n,a,b;
    cin>>n>>a>>b;
    if(n<1||n>1000000000||a<1||a>1000000000||b<1||b>1000000000){
        cout<<"0";
        return 0;
    }
    if(n==1&&a!=b){
        cout<<"0";
        return 0;
    }
    else if(a>b){
        cout<<"0";
        return 0;
    }
    int min[101]={0},max[101]={0},aa[101]={0},bb[101]={0};

    int i=100;
    long long int aaa=a,bbb=b;
    while(aaa>0){
        aa[i]=aaa%10;
        aaa/=10;
        i--;
    }

    i=100;
    while(bbb>0){
        bb[i]=bbb%10;
        bbb/=10;
        i--;
    }

    long long int index=0;
    for(i=100;i>=0;i--){
        index=index+aa[i]*(n-1)+bb[i];
        min[i]=index%10;
        index/=10;
    }
    index=0;

    for(i=100;i>=0;i--){
        index=index+bb[i]*(n-1)+aa[i];
        max[i]=index%10;
        index/=10;
    }

    int flag=0;

    for(i=100;i>=0;i--){
        if(i==100)
            index=max[i]-min[i]-flag+1;

        else
            index=max[i]-min[i]-flag;
        if(index<0){
            flag=1;
            index+=10;
        }
        else{
            flag=0;
        }
        max[i]=index;
    }
    i=0;
    while(max[i]==0)
        i++;
    if(i>100)
        cout<<"1";
    for(i;i<=100;i++)
        cout<<max[i];



}





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

#define SIGN_LENGTH 9
#define CIPHER_NUM 32
#define CODE_MAX 801
#define NUL 0x00
#define INITIALIZE 0
#define TEXT_LENGTH_MAX 101
#define FIVE 5

typedef struct cipher
{
	char charcter_change_sign[SIGN_LENGTH];
	char sign_change_charcter[FIVE + 1];
	char charcter;
}CIPHER;

int main(void)
{
	
	CIPHER code[CIPHER_NUM] = {
		{"100101", "00000", 'A'},
		{"10011010", "00001", 'B'},
		{"0101", "00010", 'C'},
		{"0001", "00011", 'D'},
		{"110", "00100", 'E'},
		{"01001", "00101", 'F'},
		{"10011011", "00110", 'G'},
		{"010000", "00111", 'H'},
		{"0111", "01000", 'I'},
		{"10011000", "01001", 'J'},
		{"0110", "01010", 'K'},
		{"00100", "01011", 'L'},
		{"10011001", "01100", 'M'},
		{"10011110", "01101", 'N'},
		{"00101", "01110", 'O'},
		{"111", "01111", 'P'},
		{"10011111", "10000", 'Q'},
		{"1000", "10001", 'R'},
		{"00110", "10010", 'S'},
		{"00111", "10011", 'T'},
		{"10011100", "10100", 'U'},
		{"10011101", "10101", 'V'},
		{"000010", "10110", 'W'},
		{"10010010", "10111", 'X'},
		{"10010011", "11000", 'Y'},
		{"10010000", "11001", 'Z'},
		{"101", "11010", ' '},
		{"010001", "11011", '.'},
		{"000011", "11100", ','},
		{"10010001", "11101", '-'},
		{"000000", "11110", '\''},
		{"000001", "11111", '?'}
	};
	
	unsigned short i = INITIALIZE;
	unsigned short j = INITIALIZE;
	unsigned short k = INITIALIZE;
	char input_text[TEXT_LENGTH_MAX];
	
	
	for(i = 0; i < TEXT_LENGTH_MAX; i++)
	{
		input_text[i] = NUL;
	}
	
	while(gets(input_text) != NULL)
	{
		unsigned short text_length = INITIALIZE;
		unsigned short barcode_length = INITIALIZE;
		unsigned short count = INITIALIZE;
		unsigned short c = 0;
		unsigned short cc = 0;
		char barcode[CODE_MAX];
		char code_fivecut[CODE_MAX / FIVE][FIVE];/*160:5*/
		
		for(i = 0; i < CODE_MAX - 1; i++)//配列の最後(800番目)には\0が入るためマイナス1してある
		{
			barcode[i] = NUL;
		}
		
		for(i = 0; i < CODE_MAX / FIVE;i++)
		{
			for(j = 0; j < 5; j++)
			{
				code_fivecut[i][j] = '0';
			}
		}
		
		for(i = 0; i < TEXT_LENGTH_MAX; i++)
		{
			text_length++;
			if(input_text[i] == NUL)
			{
				break;
			}
		}
		
		for(i = 0; i < text_length; i++)
		{
			for(j = 0; j < CIPHER_NUM; j++)
			{
				if(input_text[i] == code[j].charcter)
				{
					strcat(barcode, code[j].charcter_change_sign);
				}
			}
		}
		
		for(i = 0; i < CODE_MAX; i++)
		{
			barcode_length++;
			if( barcode[barcode_length] == '\0')
			{
				break;
			}
		}
		
		for(i = 0; i < barcode_length; i++)
		{
			for(j = 0; j < FIVE; j++)
			{
				if(c < barcode_length)
				{
					code_fivecut[i][j] =  barcode[c];
					c++;
				}
			}
		}
		
		for(i = 0;i < CODE_MAX ; i+= FIVE)
		{
			if(barcode_length <= i)
			{
				count = i / FIVE;
				break;
			}
		}
		
		for(i = 0; i < count; i++)
		{
			for(j = 0; j < CIPHER_NUM; j++)
			{
				for(k = 0; k < FIVE; k++)
				{
					if(code_fivecut[i][k] == code[j].sign_change_charcter[k])
					{
						cc++;
					}
				}
				if(cc == FIVE)
				{
					printf("%c",code[j].charcter);
				}
				cc = 0;
			}
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 520
def koch_curve(points, n):
    if n == 0:
        return points
    result = []
    for i in range(len(points) - 1):
        x = points[i+1][0] - points[i][0]
        y = points[i+1][1] - points[i][1]
        s = [points[i][0]+x/3, points[i][1]+y/3]
        t = [points[i][0]+2*x/3, points[i][1]+2*y/3]
        u_x = t[0]/2 - t[1]*(3**0.5/2) + s[0]/2+(3**0.5)*s[1]/2
        u_y = t[0]*3**0.5/2 + t[1]/2 + s[1]/2-(3**0.5)*s[0]/2
        u = [u_x, u_y]
        result.extend([points[i], s, u, t])
    result.append(points.pop())
    return koch_curve(result, n - 1)

n = int(input())
for point in koch_curve([[0.0, 0.0], [100.0, 0.0]], n):
    print(*map(str, point))

Measured memory_bytes: 8408
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
typedef long long int ll;

int main(){
	string s; cin >> s;
	string t;
	int cnt=0;
	for(int i=0;i<s.size();i++){
		if(s[i]!='x'){
			t+=s[i];
		}
		else{
			cnt++;
		}
	}
	string r=t;
	reverse(t.begin(),t.end());
	if(t!=r){
		cout << -1 << endl;
		return 0;
	}
	if(cnt==0){
		cout << cnt << endl;
		return 0;
	}
	int ans=0;
	int left=0;
	for(int i=s.size()-1;i>=0;i--){
		if(left>=i){
			break;
		}
		if(s[i]==s[left]){
			left++;
		}
		else if(s[i]=='x'){
			ans++;
		}
		else{
			ans++;
			left++;
			i++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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 int inf = INT_MAX;
const int MOD = 1000000007;
const long long INF = LLONG_MAX;

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

ll N, T;
vector<Pll> ev;

int main() {
  cin >> N >> T;
  rep(i, 0, N) {
    ll t;
    cin >> t;
    ev.push_back(Pll(t, 1));
    ev.push_back(Pll(t + T, 0));
  }

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

  ll st = 0;
  ll end = T;
  ll ans = 0;
  for (auto e : ev) {
    if (e.second == 1) {
      if (e.first <= end) {
        end = e.first + T;
      } else {
        ans += end - st;
        st = e.first;
        end = e.first + T;
      }
    } else {
      if (e.first <= end) {
        continue;
      } else {
        ans += end - st;
        st = -1;
        end = -1;
      }
    }
  }

  ans += end - st;

  cout << ans;
}


Measured memory_bytes: 11448
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
using namespace std;
using ll = long long;
#define rep(i, j, n) for(int i = (j); i < (n); ++i)
#define rrep(i, j, n) for(int i = (n) - 1; (j) <= i; --i)


constexpr ll MOD = 1000000007;
constexpr ll INF = 1LL << 60;



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

	int n, k; cin >> n >> k;
	vector<pair<int, int>> a;
	rep(i, 0, n) {
		int b, c; cin >> b >> c;
		a.emplace_back(b, c);
	}
	sort(a.begin(), a.end());

	ll ans = 0;
	int i = 0;
	while (k) {
		ll d = min(k, a[i].second);
		ans += d * a[i].first;
		k -= d;
		i++;
	}
	cout << ans;
	return 0;
}

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

using namespace std;

int main()
{
   int n,cnt=0;
   
   cin >> n;
   
   int a[n];
   
   for(int i=0;i<n;i++) cin >> a[i];
   
   sort(a,a+n);
   
   cout << a[n/2]-a[(n/2)-1];
   
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <climits>
#include <numeric>
#include <cassert>
#include <algorithm>
#include <queue>
#include <map>
#include <stack>
#include <set>
#include <vector>
#include <array>
#include <memory>

#define IN(a,b) (a.find(b) != a.end())
#define p(a,b) make_pair(a,b)
#define readVec(a) for (int64_t __i = 0; __i<(int64_t)a.size();__i++){cin>>a[__i];}

// jimjam

template<typename T>
void pMin(T &a, T b) {if (b<a){a=b;}}
template<typename T>
void pMax(T &a, T b) {if (b>a){a=b;}}
template<typename T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& c);
template<typename A, typename B>
std::ostream& operator<<(std::ostream& os, const std::pair<A,B>& c) {std::cout << "(" << c.first << ", " << c.second << ")";return os;}
using namespace std;

int64_t numFactors[1000005];
bool flag=false;
void sieve(int64_t k) {
	for (int64_t i = 1; i*i <= k; i++) {
		//assert(i<k);
		if (k%i==0) {
			int64_t a=i;
			int64_t b=k/i;
			assert(max(a,b)<1000005);
			if (numFactors[a] && a!=1) {
				flag=true;
				return;
			}
			numFactors[a]++;
			if (a!=b) {
				if (numFactors[b]) {
					flag=true;
					return;
				}
				numFactors[b]++;
			}
		}
	}
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

	int64_t n; cin >> n;
	vector<int64_t> a(n);
	readVec(a);
	for (int64_t i: a) {
		sieve(i);
	}
	int64_t curr=a[0];
	for (int64_t i = 1; i < n; i++) {
		curr=__gcd(curr,a[i]);
	}

	if (!flag) {
		cout << "pairwise coprime" << endl;
	} else if (curr==1) {
		cout << "setwise coprime" << endl;
	} else {
		cout << "not coprime" << endl;
	}
	return 0; 
}




Measured memory_bytes: 18916
#include<bits/stdc++.h>
#define ll long long int
#define mk make_pair
#define pb push_back
#define INF (ll)1e18
#define pii pair<ll,ll>
#define mod 1000000007 //998244353
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fb(i,a,b) for(ll i=a;i>b;i--)
#define ff first
#define ss second
#define PI 3.141592653589793238
#define pq priority_queue<ll>
#define pqr priority_queue<ll,vector<ll>,greater<ll>()>
using namespace std;
ll pow_mod(ll a,ll b)
{
	ll res=1;
	while(b!=0)
	{
		if(b&1)
		{
			res=(res*a)%mod;
		}
		a=(a*a)%mod;
		b/=2;
	}
	return res;
}
map<ll,ll>mp;
ll n,a,b,c,d;

ll solve(ll x){
    if(x==0)
    return 0;
    
    if(x==1)
    return d;
    
    if(mp[x]>0)
    return mp[x];
    
    ll mn;
    if(d>INF/x)
    mn=INF;
    else
    mn=min(d*x,INF);
    
    ll l2,r2,l3,r3,l5,r5;
    
    l2=x/2;
    r2=(x+1)/2;
    
    r3=(x+2)/3;
    l3=x/3;
    
    l5=x/5;
    r5=(x+4)/5;
    
    if(x%2==0)
    mn=min(mn,a+solve(x/2));
    
    if(x%3==0)
    mn=min(mn,b+solve(x/3));
    
    
    if(x%5==0)
    mn=min(mn,c+solve(x/5));
    ll t;
    
    mn=min(mn,(x%2)*d+a+solve(l2));
    t=2-x%2;
    if(t==2)
    t=0;
    
   mn=min(mn,t*d+a+solve(r2));
    
    
    t=3-x%3;
    if(t==3)
    t=0;
    
    
    mn=min(mn,(x%3)*d+b+solve(l3));
    mn=min(mn,t*d+b+solve(r3));
    
    
    t=5-x%5;
    if(t==5)
    t=0;
    
    mn=min(mn,(x%5)*d+c+solve(l5));
    mn=min(mn,t*d+c+solve(r5));
    
    return mp[x]=mn;
    
}
void find()
{
    cin>>n>>a>>b>>c>>d;
    
    ll ans=solve(n);
    
    mp.clear();
    cout<<ans<<endl;
}
int32_t main()
{    ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
     
//Start from Here.

  ll t;
  t=1;
  cin>>t;
  while(t--)
  find();
  
//Good Bye!
    return 0;
}

Measured memory_bytes: 4432