akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#define PRECISION(x) cout << fixed << setprecision(x)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define ALLR(X) (X).rbegin(), (X).rend()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second

using namespace std;
 
template<class T> void max_self(T & a, const T & b) { if(a < b) a = b; }
template<class T> void min_self(T & a, const T & b) { if(a > b) a = b; }
typedef long long LL;
const int INF = 1e9 + 7;
const double PI = acos(-1.0);
const double EPS = (1e-9);

const int M = 55555;
bool isPrime[M + 5];
vector<int> in;

inline void sieve(){
  isPrime[0] = isPrime[1] = false;

  for(int prime = 2; prime * prime < M; ++prime){
    if(!isPrime[prime]) continue;

    for(int composite = prime * prime; composite < M; composite += prime){
      isPrime[composite] = false;
    }
  }

  for(int prime = 2; prime < M; ++prime){
    if(prime % 5 != 1) continue;
    if(isPrime[prime]) in.PB(prime);
  }

  return;
}
    

int main(){
  FAST_IO
  int N; cin >> N;
  memset(isPrime, true, sizeof isPrime);

  sieve();

  for(int rep = 0; rep < N; ++rep) cout << in[rep] << " ";

  return 0;
}


Measured memory_bytes: 384
from collections import deque
MOD = 10**9 + 7
N, K = map(int, input().split())
G = [[] for i in range(N)]
for i in range(N-1):
    a, b = map(int, input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)
U = [0]*N
P = [0]*N
que = deque([0])
U[0] = 1
P[0] = -1
R = []
ans = K
while que:
    v = que.popleft()
    R.append(v)
    c = 0
    for w in G[v]:
        if U[w]:
            continue
        U[w] = 1
        que.append(w)
        P[w] = v
        c += 1
    s = 0
    if P[v] != -1:
        s = 2
    else:
        s = 1
    for i in range(c):
        ans = ans * (K-s-i) % MOD
print(ans)


Measured memory_bytes: 74016
import java.util.Scanner;
public class Main {
		public static void main(String[] args) {
	      
	      Scanner sc = new Scanner(System.in);
	      
	      int A = sc.nextInt();
		  int B = sc.nextInt();
          if(B%A==0){
            System.out.println(A+B);
          }else{
            System.out.println(B-A);
          }
        }
}

Measured memory_bytes: 22612
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#define ll long long
#define ull unsigned long long
#define INF (1 << 29)
#define LLINF (1LL << 61)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-9
#define P pair<int, int>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define all(a) (a).begin(), (a).end()
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void yes() { cout << "yes" << endl; }
void no() { cout << "no" << endl; }

class Point {
public:
	double x, y;
	
	Point(double x = 0, double y = 0) : x(x), y(y) {}

	Point operator+(Point p) { return Point(x + p.x, y + p.y); }
	Point operator-(Point p) { return Point(x - p.x, y - p.y); }
	Point operator*(double k) { return Point(x * k, y * k); }
	Point operator/(double k) { return Point(x / k, y / k); }

	bool operator<(const Point& p) const {
		return x != p.x ? x < p.x : y < p.y;
	}

	bool operator==(const Point& p) const {
		return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
	}

	friend istream& operator>>(istream& stream, Point& p) {
		double x, y;
		stream >> x >> y;
		p.x = x;
		p.y = y;
		return stream;
	}

	friend ostream& operator<<(ostream& stream, const Point& p) {
		stream << fixed << setprecision(10) << p.x << " " << p.y;
		return stream;
	}

	double abs() { return sqrt(norm()); }
	double norm() { return x * x + y * y; }

	double dot(Point v) {
		return x * v.x + y * v.y;
	}

	double cross(Point v) {
		return x * v.y - y * v.x;
	}
};

class Segment {
public:
	Point p1, p2;

	Segment(Point p1 = Point(), Point p2 = Point()) : p1(p1), p2(p2) {}

	Point project(Point p) {
		Point base = p2 - p1;
		double r = (p - p1).dot(base) / base.norm();
		return p1 + base * r;
	}
};

class Circle {
public:
	Point c;
	double r;
	Circle(Point c = Point(), double r = 0) : c(c), r(r) {}
};

typedef Point Vector;
typedef Segment Line;
typedef vector<Point> Polygon;

int main() {
	Point p1, p2, p;
	int q;

	cin >> p1 >> p2 >> q;
	Segment s(p1, p2);
	while (q--) {
		cin >> p;
		cout << s.project(p) << endl;
	}

	return 0;
}

Measured memory_bytes: 3288
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;
const int MOD = 1e9+7;


#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((int)(x).size())
//vvintを作る　マクロで　 #define vvint(N,M) vector<vector<int>>

using namespace std;


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

    ll h;
    cin >> h;
    ll count = 0;
    while(h > 0){
        h/=2;
        count++;
    }
    ll ans = 0;
    for(int i = 0; i < count;i++){
        ans += pow(2,i);
    }

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

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
#define MOD 1000000007
#define all(c) c.begin(), c.end()
#define peek(v)      \
	for (auto i : v) \
		cout << i << ' ';

void solve()
{
	vector<ll> v(1001, 0);
	ll n, k;
	cin >> n;
	for (ll i = 2; i <= n; i++)
	{
		k = i;
		for (ll j = 2; k > 1;)
		{
			if (k % j == 0)
				k /= j, v[j]++;
			else
				j++;
		}
	}
	ll res = 1;
	for (ll i : v)
		res = res * (i + 1) % MOD;
	cout << res;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	solve();
	cerr << "\n\n~" << 500 * clock() / CLOCKS_PER_SEC << "ms\n";
	return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

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

const int INF = 1000000000;
const int MOD = 1000000007;
const double eps = 1e-9;

int main(int argc, char *argv[]) {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<int> a(N);
    rep(i, N) cin >> a[i], a[i]--;

    int ans = 0;
    rep(i, N) {
        int j = a[i];
        if (i == a[j]) ans++;
    }
    cout << ans / 2 << endl;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main(){
  string s,t;
  cin >> s;
  cin >> t;
  s = s + s;
  if(s.find(t) != string::npos){
    cout << "Yes" << endl; 
  }else{
    cout << "No" << endl;  
  }
  return 0;
}

Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding("utf8");
let input = "";
process.stdin.on("data", function(chunk) {input += chunk;});
process.stdin.on("end", function() {main(input.split("\n"));});

const NIL = -1;

class Queue {
	constructor(size) {
		this.top = 0;
		this.tail = 0;
		this.ary = new Array(size);
	}
	isEmpty() {
		return this.top === this.tail;
	}
	enqueue(val) {
		this.ary[this.tail++] = val;
	}
	dequeue() {
		return this.ary[this.top++];
	}
}

function allocNode(u,k) {
	const p = {};
	p.value = u;
	p.depth = NIL;
	p.chldNum = k;
	p.chldHead = k > 0 ? new Array(k) : null;
	return p;
}

function bfs(q,top) {
	let i, u, v;
	q.enqueue(0);
	top[0].depth = 0;
	while (!q.isEmpty()) {
		u = q.dequeue();
		for (i = 0; i < top[u].chldNum; i++) {
			v = top[u].chldHead[i];
			if (top[v].depth != NIL) continue;
			top[v].depth = top[u].depth + 1;
			q.enqueue(v);
		}
	}
}

function main(lines) {
	let i, j, u, k
	let line;
	const n = Number(lines[0]);

	const q = new Queue(n);

	const top = new Array(n);
	for (i = 0; i < n; i++) {
		line = lines[1 + i].split(" ").map(Number);
		u = line[0];
		k = line[1];
		top[i] = allocNode(u,k);
		for (j = 0; j < k; j++)	top[i].chldHead[j] = line[2 + j] - 1;
	}

	bfs(q,top);

	for (i = 0; i < n; i++) console.log(top[i].value,top[i].depth);
}


Measured memory_bytes: 16568
package main

import "fmt"

func main() {
	var n int
	var a []uint

	fmt.Scan(&n)

	for i := 0; i < n; i++ {
		var _a uint
		fmt.Scan(&_a)

		a = append(a, _a)
	}

	count := 0

	for {
		for i := 0; i < len(a); i++ {
			if a[i]%2 == 0 {
				a[i] /= 2
			} else {
				fmt.Println(count)
				return
			}
		}
		count++
	}
}


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

cnt = 0
ans = []
for i in range(h):
    if i % 2 == 0:
        for j in range(w):
            if a[i][j] % 2 != 0 and j != w - 1:
                a[i][j + 1] += 1
                a[i][j] -= 1
                cnt += 1
                ans.append([i+1, j+1, i+1, j+2])
            elif a[i][j] % 2 != 0 and j == w - 1:
                if i==h-1:
                    break
                else:
                    a[i + 1][j] += 1
                    a[i][j] -= 1
                    cnt += 1
                    ans.append([i+1,j+1,i+2,j+1])
            else:
                pass
    else:
        for j in range(w):
            if a[i][w - 1 - j] % 2 != 0 and w - 1 - j != 0:
                a[i][w - 1 - j - 1] += 1
                a[i][w - 1 - j] -= 1
                cnt += 1
                ans.append([i+1, w-j,i+1,w-1-j])
            elif a[i][w - 1 - j] % 2 != 0 and w - 1 - j == 0:
                if i==h-1:
                    break
                else:
                    a[i + 1][w - 1 - j] += 1
                    a[i][w - 1 - j] -= 1
                    cnt += 1
                    ans.append([i+1, w - j, i + 2, w - j])
            else:
                pass
print(cnt)
for i in ans:
    print(' '.join(map(str, i)))

Measured memory_bytes: 29800
#include <iostream>
using namespace std;
int main(void){
    long a, b;
    cin >> a >> b;
    
    if(a*b <= 0){
        std::cout << "Zero" << std::endl;
        
    }else if((a + b) < 0 and (b - a) % 2 == 0){
        std::cout << "Negative" << std::endl;
        
    }else{
        std::cout << "Positive" << std::endl;
    }
}


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

int main() {
  int n,m;
  cin>>n>>m;
  int a[n][m],b[250009][4];
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      int k;
      cin>>k;
      a[i][j]=k;
    }
  }
  int t=0;
  for(int i=0;i<n;i++){
    for(int j=0;j<m-1;j++){
      if(a[i][j]%2==1){
        b[t][0]=i+1;
        b[t][1]=j+1;
        b[t][2]=i+1;
        b[t][3]=j+2;
        a[i][j+1]++;
        t++;
      }
    }
  }
  for(int i=0;i<n-1;i++){
    if(a[i][m-1]%2==1){
      b[t][0]=i+1;
      b[t][1]=m;
      b[t][2]=i+2;
      b[t][3]=m;
      a[i+1][m-1]++;
      t++;
    }
  }
  cout<<t<<endl;
  for(int i=0;i<t;i++){
    cout<<b[i][0]<<' '<<b[i][1]<<' '<<b[i][2]<<' '<<b[i][3]<<endl;
  }
}


Measured memory_bytes: 6400
n = int(input())
L = list(map(int,input().split()))
def gcd(a,b):
    while b != 0:
        k = b
        b = a%b
        a = k
    return a
g = gcd(max(L[0],L[1]),min(L[0],L[1]))
lcm = L[0]*L[1]//g
for i in range(2,len(L)):
    cur = gcd(max(lcm,L[i]),min(lcm,L[i]))
    if lcm%L[i] == 0:
        None
    elif L[i]%lcm == 0:
        lcm = L[i]
    else:
        lcm = lcm*L[i]//cur
print(lcm)


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

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

    int a[A], b[B];
    for(int i = 0; i < A; i++) cin >> a[i];
    for(int i = 0; i < B; i++) cin >> b[i];

    int m[M][3];
    for(int j = 0; j < M; j++){
        for(int i = 0; i < 3; i++) cin >> m[j][i];
    }

    int mina = a[0], minb = b[0];

    for(int i = 0; i < A; i++){
        if(mina > a[i]) mina = a[i];
    }

    for(int i = 0; i < B; i++){
        if(minb > b[i]) minb = b[i];
    }

    int minv = mina + minb;

    int minvv[M];

    for(int j = 0; j < M; j++){
        for(int i = 0; i < 3; i++){
            minvv[j] = a[m[j][0]-1] + b[m[j][1]-1] - m[j][2];
        }
    }

    int minmin = minv;

    for(int i = 0; i < M; i++){
        if(minmin > minvv[i]) minmin = minvv[i];
    }

    cout << minmin << endl;

}

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

int main(){
    int n, m, c;
    cin >> n >> m >> c;

    vector<int> a(m),b(m);
    for(int i = 0; i < m; i++){
        cin >> b[i];
    }
    int cnt = 0;
    for(int i = 0; i < n; i++){
        int sum = 0;
        for(int j = 0; j < m; j++){
            cin >> a[j];
            sum += (a[j] * b[j]);
        }
        sum += c;
        if(sum > 0){
            cnt++;
        }
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <set>
#include <algorithm>

typedef long long ll;
const ll MOD = 1e9 + 7;
const long long INF = 1LL<<60;
const double PI=3.14159265358979323846;
const int NMAX=100005;
using namespace std;

int main(){
    ll n;
    cin >> n;
    ll ans = 1;
    vector<unsigned long long> a(n);
    for(ll i = 0; i < n; i++){
        cin >> a[i];
        if(a[i] == 0) ans = 0;
    }

    if(ans != 0){
        for(ll i = 0; i < n; i++){
            unsigned long long tmp = ans*a[i];
            if(ans == -1 || tmp > (1000000000000000000) || tmp/a[i] != ans){
                ans = -1;
                break;
            } else {
                ans = tmp;
            }
        }
    }

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

Measured memory_bytes: 4048
#include <iostream>
#include <sstream>
#include <fstream>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include<iomanip>
#define sqr(x) (x)*(x)
#define ll long long
using namespace std;
string st,st1,st2;
int n,m,i,j,mi=2147480000,dep;
char ch;
bool check(string st,char ch)
{
	int i;
	for (i=0;i<st.length();i++)
	{
		if (st[i]!=ch) return 0; 
	}
	return 1;
}
int main()
{
	cin>>st;
	for (ch='a';ch<='z';ch++)
	{
		dep=0;
		st1=st;
		//cerr<<st1<<endl;
		while (!check(st1,ch))
		{
			st2=""; 
			for (i=0;i<st1.length()-1;i++)
			{
				if (st1[i]==ch) st2.push_back(st1[i]);
					else st2.push_back(st1[i+1]);
			}
			//cerr<<st2<<endl;
			st1=st2;
			dep++;
		}
		mi=min(mi,dep);
	}
	cout<<mi;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int x1 = sc.nextInt();
		int y1 = sc.nextInt();
		int x2 = sc.nextInt();
		int y2 = sc.nextInt();

		int x = x2-x1;
		int y = y2-y1;

		System.out.print(x2-y+" ");
		System.out.print(y2+x+" ");
		System.out.print(x1-y+" ");
		System.out.print(y1+x+" ");
		System.out.println();
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;

int N;
int H[21];

int main(){
    cin>>N;
    rep(i,N) cin>>H[i];

    int ans=0;
    int maxh=0;
    rep(i,N){
        if(maxh<=H[i]){
            ans++;
            maxh=H[i];
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//pair sort
bool compare_by_b(pair<LL, LL> a, pair<LL, LL> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}


void solve(long long N, long long K){
    if(K%2==0){
        LL a = N/K;
        LL b = (N+(K/2))/K;
        cout<<a*a*a+b*b*b<<endl;
    }
    else{
        LL ans = N/K;
        cout<<ans*ans*ans<<endl;
    }
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    solve(N, K);
    return 0;
}


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

using namespace std;
long long dp[105][100005],a[105],b[105];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,w;
    cin >> n >> w;
    for (int i = 1; i<=n; i++)
        cin >> a[i] >> b[i];
    for (int i = 0; i<=n; i++)
        for (int j = 0; j<=100000; j++)
            dp[i][j] = INT_MAX;
    dp[0][0] = 0;
    for (int i = 1; i<=n; i++)
        for (int j = 0; j<=100000; j++)
        {
            dp[i][j] = dp[i-1][j];
            if (j>=b[i])
                dp[i][j] = min(dp[i][j],dp[i-1][j-b[i]]+a[i]);
        }
    int ans = 0;
    for (int i = 0; i<=100000; i++)
        if (dp[n][i]<=w)
            ans = i;
    cout << ans;
}


Measured memory_bytes: 80256
#include <bits/stdc++.h>
#define MAXN 100005
#define mod 1000000007
#define inf LLONG_MAX/3
using namespace std;

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

ll power(ll x,ll y,ll m=mod)
{
  ll ans = 1;
  while(y>0)
  {
    if(y&1)
    {
      ans = (ans*x)%m;
    }
    x = (x*x)%m;  
    y /= 2;
  }
  return ans%m;
}

ll modInverse(ll a, ll m=mod) 
{ 
    ll m0 = m; 
    ll y = 0, x = 1; 
  
    if (m == 1) 
      return 0; 
  
    while (a > 1) 
    { 
        // q is quotient 
        ll q = a / m; 
        ll t = m; 
  
        // m is remainder now, process same as 
        // Euclid's algo 
        m = a % m, a = t; 
        t = y; 
  
        // Update y and x 
        y = x - q * y; 
        x = t; 
    } 
  
    // Make x positive 
    if (x < 0) 
       x += m0; 
  
    return x; 
} 

ll get(string s)
{
  ll res = 0;
  for(int i=0;i<s.length();i++)
  {
    res += s[i]-'0';
    res *= 10;
  }
  return res/10;
}


int main()
{
  // #ifndef ONLINE_JUDGE 
  // freopen("input.txt", "r", stdin); 
  // #endif
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll t=1;
  // cin>>t;
  while(t--)
  {
    ll n,m,i,j,ans=0;
    cin>>n;
    cout<<ceil(n/2.0);
    return 0;
    ll a[3][3],mark[3][3];
    map<ll,pll> mp;
    for(i=0;i<3;i++)
    {
      for(j=0;j<3;j++)
      {
        cin>>a[i][j];
        mark[i][j] = 0;
        mp[a[i][j]] = {i,j};
      }
    }
    cin>>n;
    while(n--)
    {
      cin>>m;
      if(mp.find(m)!=mp.end())
      {
        auto it = mp.find(m);
        mark[it->second.first][it->second.second] = 1;
      }
    }
    for(i=0;i<3;i++)
    {
      for(j=0;j<3;j++)
      {
        a[i][j] = mark[i][j];
        // cout<<mark[i][j]<<" ";
      }
      // cout<<"\n";
    }
    if(a[0][0]+a[0][1]+a[0][2]==3 || a[1][0]+a[1][1]+a[1][2]==3 || a[2][0]+a[2][1]+a[2][2]==3 ||
      a[0][0]+a[1][0]+a[2][0]==3 || a[0][1]+a[1][1]+a[2][1]==3 || a[0][2]+a[1][2]+a[2][2]==3 ||
      a[0][0]+a[1][1]+a[2][2]==3 || a[0][2]+a[1][1]+a[2][0]==3)
    {
      cout<<"Yes";
    }
    else
    {
      cout<<"No\n";
    }
  }
  return 0;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  set<char> m;
  m.insert(s[0]);
  m.insert(s[1]);
  m.insert(s[2]);
  if (m.size() > 1) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }                   
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(v) v.begin(), v.end()

using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
const double PI = 2 * acos(0);

int main() {
	int A, B, C;
	scanf("%d%d%d", &A, &B, &C);
	swap(A, B);
	swap(A, C);
	printf("%d %d %d\n", A, B, C);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n, tot = 1;
int a[200005];
bool check(int t) {
	int last = a[t];
	for (int i = t + 1; i <= n; i++) {
		if (a[i] > last) {//up
			return true;
		} else if (a[i] < last) {//down
			return false;
		} else {
			last = a[i];
		}
	}
	return false;
}
int main() {
	scanf ("%d", &n);
	for (int i = 1; i <= n; i++)
		scanf ("%d", &a[i]);
	bool tmp = check(1);
	int last = a[1];
	for (int i = 2; i <= n; i++) {
		if (a[i] >= last && tmp) {
			last = a[i];
			continue;
		} else if (a[i] <= last && !tmp) {
			last = a[i];
			continue;
		} else {
			tot++;
			tmp = check(i);
			last = a[i];
			continue;
		}
	}
	printf ("%d", tot);
	return 0;
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;

class WithIndex<T>
{
    public T Value;
    public int Index;
    public WithIndex(T value, int index)
    {
        this.Value = value;
        this.Index = index;
    }
}

static class Template
{
    public static int LineToInt()
    {
        return int.Parse(Console.ReadLine());
    }

    public static string[] LineToStrings()
    {
        return Console.ReadLine().Split();
    }

    public static int[] LineToInts()
    {
        return LineToStrings()
            .Select(s => int.Parse(s))
            .ToArray();
    }


    public static int[,] LinesToIntTable(int lineCount, int columnCount)
    {
        var value = new int[lineCount, columnCount];
        foreach (var y in Enumerable.Range(0, lineCount))
        {
            var ints = LineToInts();
            foreach (var x in Enumerable.Range(0, columnCount))
            {
                value[y, x] = ints[x];
            }
        }
        return value;
    }

    public static IEnumerable<WithIndex<T>> WithIndex<T>(this IEnumerable<T> sequence)
    {
        int index = 0;
        foreach (var item in sequence)
        {
            yield return new WithIndex<T>(item, index);
            index++;
        }
    }

    static void Main(string[] args)
    {
        var inputs = LineToInts();
        var n = inputs[0];
        var r = inputs[1];
        var count = 1;
        var i = r + 1;
        while (i + r + 1 <= n)
        {
            count++;
            i += 2 * r + 1;
        }
        Console.WriteLine(count);
    }
}



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

#define pout(n)  printf ("%d\n", n)

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
#define BIT(bit,a,n) for (int bit = a;bit < (1<<n);bit++) // {0, 1, ..., n-1} の部分集合の全探索 // n番目のフラグが立っている状態は (1<<n)

const int d4x[4] = {1, 0, -1, 0};
const int d4y[4] = {0, 1, 0, -1};
const int d8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const int d8y[8] = { 0,1,1,1,0,-1,-1,-1 };

#define MAX_N (int)2e5+20

typedef long long ll;
using namespace std;

int a,b;
string s;
int main() {
    scanf("%d%d",&a,&b);
    cin >> s;
    rep(i,0,s.size()){
        if(i == a){
            if(s[i] != '-'){
                puts("No");
                return 0;
            }
        }
        else{
            if(s[i] == '-'){
                puts("No");
                return 0;
            }
        }
    }
    puts("Yes");
    return 0;
}

Measured memory_bytes: 256
gets
a = gets.split.map(&:to_i)
b = a.clone.sort

gmin = b[0]

cost = 0
loop = {}
0.upto(b.size-1){|i|
  if a[i] != b[i] && loop[i] != 1 then
    sum = 0
    min = a[i]
    n = 0
    idx = b.index(a[i])
    loop[idx] = 1
    flag = 0
    loop do
      min = a[idx] if min > a[idx]
      flag = 1 if a[idx] == gmin
      sum += a[idx]
      idx = b.index(a[idx])
#      printf "idx: %d\n", idx
      n += 1
      break if loop[idx] == 1
      loop[idx] = 1
    end
    if n == 2 then
      cost += sum
    elsif n > 2 then
      if (n-2) * min < min + (n+1)*gmin then
        cost += sum + (n-2) * min
      else
        cost += sum + min + (n+1) * gmin
      end
    end
#    printf "%d %d %d %d\n", sum, min, n, flag
  end
}

puts cost

Measured memory_bytes: 8772
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>

#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INPUT1(n, a) for(int i##n = 0; i##n < n; i##n++) {cin >> a[i##n]; } //n = count, a = vector 
#define OUTPUT1(n, a) cout << "---count---" << endl << n << endl << "---content---" << endl; for(const auto b : a){cout << b << endl; }
#define INPUT2(x, y, field) for(int i##x = 0; i##x < y; i##x++) { for(int j##x = 0; j##x < x; j##x++) { cin >> field[i##x][j##x]; } }
#define OUTPUT2(x, y, field) cout << "---count---" << endl << x << " " << y << endl <<"---content---" << endl; for(int i##x = 0; i##x < y; i##x++) { cout << i##x << "   "; for(int j##x = 0; j##x < x; j##x++) { cout << field[i##x][j##x] << " "; } cout << endl; }

using namespace std;
using ll = long long;

const int INF = 1001001001;

int main()
{
	char x, y;
	cin>>x;
	
	rep(i, 2){
	    cin>>y;
	    
	    if(x!=y){
	        cout<<"Yes";
	        return 0;
	    }
	}
	
	cout<<"No";
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

ll sum(ll l, ll r) {
    return (l+r)*(r-l+1)/2;
}

int main(){
    int n, k;
    cin >> n >> k;
    mint ans;
    for ( int i = k; i <= n + 1; ++i ) {
        ll l = sum(0, i-1), r = sum(n-i+1, n);
        ans += r - l + 1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3640
#include<iostream>
#include<algorithm>

using namespace std;

#define MAX 100
#define INFTY 1ll<<31

int n;
long long d[MAX][MAX];

void warshallFloyd(){
  
  for(int k=0;k<n;k++){
    for(int i=0;i<n;i++){
      if(d[i][k] == INFTY) continue;
      for(int j=0;j<n;j++){
        if(d[k][j] == INFTY) continue;
        d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
      }
    }
  }

}



int main(void){

  int e, u, v;
  long long c;
  cin >> n >> e;


  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      d[i][j] = INFTY;
    }
  }

  for(int i=0;i<n;i++){
    d[i][i] = 0;
  }

  for(int i=0;i<e;i++){
    cin >> u >> v >> c;
    d[u][v] = c;
  }

  warshallFloyd();

  bool negative_loop=false;
  
  for(int i=0;i<n;i++){
    if( d[i][i] < 0){
      negative_loop = true;
      break;
    }
  }

  if(negative_loop){
    cout << "NEGATIVE CYCLE" << endl;
  }else{
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
        if( j!= 0){
          cout << " ";
        }
        if(d[i][j] == INFTY){
          cout << "INF";
        }else{
          cout << d[i][j];
        }      
      }
      cout << endl;
    }
  }  
  
  return 0;
}



Measured memory_bytes: 3196
#include <iostream>
using namespace std;
     
int main() {
	int cards[4][13];
	for(int i=0; i<4; i++){
		for(int j=0; j<13 ;j++){
			cards[i][j]=0;
		}
	}
	int n;
	cin >> n ;
	for(int h=0; h<n ;h++){
		int num ;
		char mar ;
		cin>> mar >> num ;
		if(mar == 'S'){
			cards[0][num-1]=1;
		}
		if(mar == 'H'){
			cards[1][num-1]=1;
		}
		if(mar == 'C'){
			cards[2][num-1]=1;
		}
		if(mar == 'D'){
			cards[3][num-1]=1;
		}
	}
	for (int i=0; i<4 ; i++){
		for (int j=0 ; j<13 ; j++){
			if(cards[i][j] == 0){
				if(i == 0){cout<< "S " <<j+1 <<endl;}
				if(i == 1){cout<< "H " <<j+1 <<endl;}
				if(i == 2){cout<< "C " <<j+1 <<endl;}
				if(i == 3){cout<< "D " <<j+1 <<endl;}
			}
		}
	}
    return 0;
    }



Measured memory_bytes: 3088
#include<bits/stdc++.h>
#define For(a,b,c) for(int a=b;a<=c;++a)
#define Dor(a,b,c) for(int a=b;a>=c;--a)
using namespace std;
int main() {
	int n,x,s=0,ans=1;
	scanf("%d%d",&n,&x);
	For(i,1,n) {
		int t;
		scanf("%d",&t);
		if((s+=t)<=x) ++ans;
		else break;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9, MOD = 1e9 + 7;
const long long LINF = 1e18;
using namespace std;
#define int long long
//template

//main
signed main()
{
    int H, W, N;
    cin >> H >> W >> N;
    int sy, sx;
    cin >> sy >> sx;
    string s, t;
    cin >> s >> t;
    int l = 1, r = W;
    int out = 0;
    for (int i = N - 1; i >= 0; i--)
    {
        if (t[i] == 'R')
            l--;
        if (t[i] == 'L')
            r++;
        l = max(1LL, l);
        r = min(W, r);
        if (s[i] == 'R')
            r--;
        if (s[i] == 'L')
            l++;

        if (r < l)
            out++;
    }
    if (sx < l || sx > r)
        out++;
    l = 1;
    r = H;
    for (int i = N - 1; i >= 0; i--)
    {
        if (t[i] == 'D')
            l--;
        if (t[i] == 'U')
            r++;
        l = max(1LL, l);
        r = min(H, r);
        if (s[i] == 'D')
            r--;
        if (s[i] == 'U')
            l++;

        if (r < l)
            out++;
    }
    if (sy < l || sy > r)
        out++;
    if (out)
        cout << "NO" << endl;
    else
        cout << "YES" << endl;
}


Measured memory_bytes: 776
#include <cstdio>

int n;

int main(){

  scanf("%d", &n);

  bool can = false;

  for(int i = 0; i <= 25 ; i++){
    int sum = 4 * i;
    if(sum == n){
      can = true;
      break;
    }
    for(int j = 0; j <= 14; j++){
      sum += 7;
      if(sum == n){
        can = true;
        break;
      }
    }
  }

  if(can)
    printf("Yes\n");
  else
    printf("No\n");

  return 0;

}


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

int main() {
  string S;
  cin >> S;
  
  int count_a = 0; // 101010...
  int count_b = 0; // 010101...
  
  for (int i = 0; i < S.length(); i++) {
    switch (S.at(i)) {
      case '0':
        if (i % 2 == 0) {
          count_b++;
        } else {
          count_a++;
        }
        break;
      case '1':
        if (i % 2 == 0) {
          count_a++;
        } else {
          count_b++;
        }
        break;
    }
  }
  
  int answer = min(count_a, count_b);
  cout << answer << endl;
}

Measured memory_bytes: 512
#coding:utf-8
import sys,os
from collections import defaultdict, deque
from fractions import gcd
from math import ceil, floor
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    MIIS = lambda: map(int,input().split())
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    XLMIIS = lambda x: [LMIIS() for _ in range(x)]
    YN = lambda c : print('Yes') if c else print('No')
    MOD = 10**9+7

    N,K = MIIS()
    #NからK+1
    # a % b = K + x (x = 0 ... b-K-1) (K+1<=b)
    # a // b = y (y=0...(N-K)//b)
    ans = 0
    # for i in range(K+1,N+1):
    #     diff = ((N-K)//i+1) * (i-K)
    #     print(i,diff,i-K-1,i-K)
    #     ans += ((N-K)//i+1) * (i-K)
    # print(ans)
    ans = 0
    # for b in range(1,N+1):
    #     for a in range(1,N+1):
    #         # write(str('|{} {} {}| '.format(a,b,a % b >= K)))
    #         if a % b >= K:
    #             ans += 1
    #     print()
    ans2 = 0
    for b in range(K+1,N+1):
        ans2 += (N//b)*(b-K)
        # print(b,N//b*b+1,max(N - (N//b*b + K) +1,0))

        
        ans2 += max(N - (N//b*b + K) +min(1,K),0)
        # for r in range(N//b*b+1,N+1):
            
        #     if r % b >= K:
        #         ans2 += 1
        #     else:
        #         print('a!',r,b)
        # write(str('|{} {}| '.format(b,(N//b)*(b-K)+max((N%b)-K,0))))
        # print()
    
    print(ans2)

    

if __name__ == '__main__':
    main()

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

const int MAX_N = (int)1e6 + 10;

int main () {
    string N; cin >> N;
    int n = N.length();
    int f[n+1][2];
    f[0][0] = 0; f[0][1] = 1;
    for (int i = 1; i <= n; i++) {
        int t = N[i-1]-'0';
        f[i][0] = min(f[i-1][0] + t, f[i-1][1] + (10-t));
        f[i][1] = min(f[i-1][0] + t + 1, f[i-1][1] + (9-t));
    }
    cout << f[n][0] << endl;
}


Measured memory_bytes: 9220
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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=1001001001;
vector<pair<int64_t,int64_t>>pppp(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p;
}
 
int main() {
  string s;
  cin>>s;
  int n=s.size();
  set<char>k;
  for(int i=0;i<n;i++){
    k.insert(s[i]);
  }
  int ans=999999;
  for(auto a:k){
    int cnt=0,MAX=0;
    for(int i=0;i<n;i++){
     if(s[i]==a){cnt=0;}
     else{cnt++;}
     MAX=max(cnt,MAX);
    }
    ans=min(ans,MAX);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <string>
#include <vector>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

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

  vector<long long> p(1000);
  rep(i, 1000) {
    p[i] = (long long)i * i * i * i * i;
  }

  long long a1, a2, b;
  rep(i, 1000) {
    a1 = p[i];
    a2 = -a1;

    rep(j, 1000) {
      b = p[j];
      if (X == a1 + b) {cout << i << " " << -j << endl; return 0;}
      else if (X == a1 - b) {cout << i << " " << j << endl; return 0;}
      else if (X == a2 + b) {cout << -i << " " << -j << endl; return 0;}
      else if (X == a2 - b) {cout << -i << " " << j << endl; return 0;}
    }
  }

  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <set>

using namespace std;
typedef long long LL;
static const double EPS = 1e-9;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n) 
void decode(vector<string> &words)
{
  int s=0;
  REP(i,words.size()){
    REP(j,26){
      REP(k,words[i].size()){
        if(words[i][k] >= 'a' && words[i][k] <= 'z' )
        words[i].replace(k, 1, 1,
              'a' + ( words[i][k] + 1 - 'a')%26 );
        
        if(words[i] == "the"||words[i] == "this" || words[i] == "that" )
          s = j;
      }
    }
  }
  REP(i,words.size())
    REP(j,words[i].size())
      if(words[i][j] >= 'a' && words[i][j] <= 'z' )
        words[i].replace(j, 1, 1, 'a' + (words[i][j] + s+1 - 'a')%26 );
}

int main(void){  
  vector<string> words;
  string bf;

  while(true){
    if(!(cin >> bf)) break;
    words.push_back(bf);
    int c = getchar();
    if(c=='\n'){
      decode(words);
      cout << words[0];
      FOR(i,1,words.size())
        cout << " " << words[i];
      cout << endl;
      words.clear();
    }
  }
  return 0;
}

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

const int maxn = 2e5;

int n,k;
int dig[maxn];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>k;
	if(n%k==0) cout<<0<<endl;
	else cout<<1<<endl;
}

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

double ang(double a, double b){
    return min(abs(a-b), 360-abs(a-b));
}

int main(){
    int n;
    for(scanf("%d",&n);n--;){
        double a, b;
        scanf("%lf:%lf",&a,&b);
        a = a*30 + b/2;
        b = b*6;
        if( ang(a,b) < 30 ) puts("alert");
        else if( ang(a,b) < 90 ) puts("warning");
        else puts("safe");
    }
    return 0;
}

Measured memory_bytes: 1040
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N,K=MI()
    A=LI()
    for i in range(N):
        A[i]-=1
    *cumsum, = accumulate(A)
    for i in range(N):
        cumsum[i]%=K

    cnt = defaultdict(int)
    ans = 0
    for i,c in enumerate(cumsum):
        if i>=K:
            cnt[cumsum[i-K]]-=1
        if c==0 and i<K-1:
            ans += 1
        ans += cnt[c]
        cnt[c]+=1
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 123048
/* ----------------------- reclone_rk --------------------------------------------*/ 
#include<bits/stdc++.h>
using namespace std;
#define int long long int
const int mod=1e9+7;

#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define prq priority_queue<int>
#define prqp priority_queue<pair<int,int>>
#define vtr vector<int>
#define INF INT_MAX
#define NINF INT_MIN
#define endl "\n"
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define pvtr vector<pair<int,int>>
#define FOR(i,a,n) for (int i=(a);i<=(n);++i)

int gcd(int a, int b){ if(a == 0) return b; return gcd(b%a, a);}
int MOD(int n){ return ((n%mod)+mod)%mod;}
int power(int a,int b){ if(b==0)return 1LL;int s=power(a,b/2LL);s*=s;s%=mod;if(b&1LL)return (s*a)%mod;return s;}
int inv(int a){return power(a,mod-2);}
int nCr(int n,int r){if(r>n)return 0LL;if(n-r<r)r=n-r;int ans=1;for(int i=0;i<r;i++){ans*=(n-i);ans=MOD(ans);ans*=inv(i+1);ans=MOD(ans);}return ans;}

int pi = 3.14159265358979323846;
signed main()
{   
    int k, a, b;
    cin>>k>>a>>b;
    int flag = 0;
    for(int i=a; i<=b; i++)
    {
    	if(i%k == 0)
    	{
    		flag = 1;
    		break;
    	}
    }
    if(flag == 1)
    	cout<<"OK"<<endl;
    else
    	cout<<"NG"<<endl;
	return 0;
}

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

int main() {
  string s;
  cin>>s;
  int kotae=0;
  for(int i=0;i<s.size()-1;i++){
    if(s[i]!=s[i+1])kotae++;
  }
  cout<<kotae<<endl;
  return 0;
}

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

struct Node {
  int key;
  Node *right,*left,*parent;
};

Node *root,*NIL;

Node *find(Node *u,int k) {
  while (u!=NIL and k!=u->key) {
    if (k<u->key) {
      u=u->left;
    }
    else {
      u=u->right;
    }
  }
  return u;
}
void insert(int k) {
  Node *y=NIL;
  Node *x=root;
  Node *z;
  z=(Node *)malloc(sizeof(Node));
  z->key=k;
  z->left=NIL;
  z->right=NIL;
  while (x!=NIL) {
    y=x;
    if (z->key<x->key) {
      x=x->left;
    }
    else {
      x=x->right;
    }
  }
  z->parent=y;
  if (y==NIL) {
    root=z;
  }
  else {
    if (z->key<y->key) 
      y->left=z;
    
    else 
      y->right=z;
    
  }
}
void inorder(Node *u) {
  if (u==NIL) 
    return ;
  
  inorder(u->left);
  cout<<" "<<u->key<<flush;
  inorder(u->right);
}
void preorder(Node *u) {
  if (u==NIL) {
    return ;
  }
  cout<<" "<<u->key<<flush;
  preorder(u->left);
  preorder(u->right);
}
int main() {
  int n;
  cin>>n;
  for (int i=0; i<n; i++) {
    string com;
    cin>>com;
    if (com=="insert") {
      int x;
      cin>>x;
      insert(x);
    }
    else if (com=="print") {
      inorder(root);
      cout<<endl;
      preorder(root);
      cout<<endl;
    } else {
      int x;
      cin>>x;
      Node *t=find(root,x);
      if (t!=NIL) {
        cout<<"yes"<<endl;
      }
      else {
        cout<<"no"<<endl;
      }
    }
  }
  return 0;
}


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

int main() {
        int A,B,C,K;

        cin >> A >> B >> C;
        cin >>K;

        cout <<  A+B+C+max({ A, B, C})*((1<<K)-1) << endl;

        return 0;
}

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

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("4");
            WillReturn.Add("10 30 40 20");
            //30
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("2");
            WillReturn.Add("10 10");
            //0
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("6");
            WillReturn.Add("30 10 60 10 60 50");
            //40
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();

        int[] HArr = InputList[1].Split(' ').Select(X => int.Parse(X)).ToArray();
        int UB = HArr.GetUpperBound(0);

        // 最小コスト[現在位置] なDP表
        var DPDict = new Dictionary<int, int>();
        DPDict[0] = 0;

        for (int I = 0; I <= UB; I++) {
            if (DPDict.ContainsKey(I) == false) continue;

            Action<int> wkAct = (pNewInd) =>
            {
                if (pNewInd > UB) return;
                int NewVal = DPDict[I] + Math.Abs(HArr[I] - HArr[pNewInd]);

                if (DPDict.ContainsKey(pNewInd)) {
                    if (DPDict[pNewInd] <= NewVal) {
                        return;
                    }
                }
                DPDict[pNewInd] = NewVal;
            };
            wkAct(I + 1); // 1つ先にジャンプする場合
            wkAct(I + 2); // 2つ先にジャンプする場合

            //Console.WriteLine("{0}回目のDPの結果", I);
            //foreach (var EachPar in DPDict) {
            //    Console.WriteLine("DPDict[{0}]={1}", EachPar.Key, EachPar.Value);
            //}
        }
        Console.WriteLine(DPDict[UB]);
    }
}


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

using namespace std;

using ll = long long;

inline ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

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

    int n;
    cin >> n;

    ll res = 1, t;
    for (int i = 0; i < n; ++i) {
        cin >> t;
        res = lcm(res, t);
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
def actual(s):
    N = len(s)
    num_repeat = (N // 2)

    if N % 2 == 0:
        # 偶数の場合 1010... か 0101... に限られる
        valid_pattern1 = '10' * num_repeat
        valid_pattern2 = '01' * num_repeat
    else:
        # 奇数の場合 10101... か 10101... に限られる
        valid_pattern1 = '1' + '01' * num_repeat
        valid_pattern2 = '0' + '10' * num_repeat

    flip_step1 = 0
    flip_step2 = 0

    for bit, v1, v2 in zip(s, valid_pattern1, valid_pattern2):
        flip_step1 += int(bit != v1)
        flip_step2 += int(bit != v2)

    return min(flip_step1, flip_step2)


s = input()
print(actual(s))

Measured memory_bytes: 3444
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long x = sc.nextLong();
        long ans = 0;
        ans += x / 500 * 1000;
        x %= 500;
        ans += x / 5 * 5;
        System.out.println(ans);
    }
}

Measured memory_bytes: 22996