akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
	int n,q;

	scanf("%d %d",&n,&q);

	int a[n],b[q+1],c[q+1];
	memset(a,0,sizeof(a));
	string s;

	cin>>s;

	for(int i=1; i<=q; i++) {
		int x,y;
		scanf("%d %d",&x,&y);
		b[i]=x;
		c[i]=y;
	}

	for(int i=1; i<n; i++) {
		if(i-1>n) {
			a[i]=0;
		} else {
			if(s[i-1]=='A'&&s[i]=='C') {
				a[i]=1;
			}
		}
	}
	int sum=0;
	for(int i=0; i<n; i++) {
		sum+=a[i];
		a[i]=sum;
	}
	for(int i=1; i<=q; i++) {
		printf("%d\n",a[c[i]-1]-a[b[i]-1]);
	}

	return 0;
}


Measured memory_bytes: 2176
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
using namespace std;
typedef long long ll;
int main(){
  int n,m;
  string s;
  cin >> n >> m >> s;
  int now = 0;
  now = n;
  vector<int> res;
  bool possible = true;
  while(now > 0){
    bool can = false;
    for(int i = max(now - m,0);i < now;i++){
      if(s[i] == '0'){
        //cout << i << endl;
        can = true;
        res.insert(res.begin(),now - i);
        now = i;
        break;
      }
    }
    if(!can){
      possible = false;
      break;
    }
  }
  if(possible){
    for(int i = 0;i < res.size();i++)cout << res[i] << " ";
    cout << endl;
  }
  else{
    cout << -1 << endl;
  }
}

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

map<ll,ll>di;


int main()
{
    ll n,s=0;
    cin>>n;
    ll l1[n+1],l2[n+1],l3[n+1];
    for(int i=1;i<=n;i++){
        cin>>l1[i];
    }
    for(int i=1;i<=n;i++){
        cin>>l2[i];
    }
    for(int i=1;i<=n;i++){
        cin>>l3[i];
    }
    sort(l1+1,l1+n+1);
    sort(l2+1,l2+n+1);
    sort(l3+1,l3+n+1);
    //for(int i=1;i<=n;i++){
        ll noi=0,nok=0;
        for(int k=1;k<=n;k++){
//            if(l1[k]<l2[i]&&noi==0)noi=n-k+1;
//            if(l2[i]<l3[k]&&nok==0)nok=n-k+1;
//            if(noi&&nok)break;
              auto it=lower_bound(l1+1,l1+n+1,l2[k]);
              noi=it-(l1+1);//noi-=1;
              auto it2=upper_bound(l3+1,l3+n+1,l2[k]);
              nok=n-(it2-(l3+1));
              //cout<<noi<<" "<<nok<<endl;
              s+=(ll)(noi*nok);
        }

    //}
    cout<<s;
}


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

int main() {
  // ここにプログラムを追記
	int N,A,s1,s2,s3;
  	cin >> N;
  	
  s1 = N / 100;
  s3 = N % 2; 
  
  s2 = (N - (s1 * 100) - s3) / 10;
  
  	cout << s1 + s2 + s3 << endl;
}

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

int main()
{
	string a;
	cin >> a;
	for (int b = 0; b < a.length(); b++) {
		if (a[b] != 'A'&&a[b] != 'B'&&a[b] != 'C')cout << (char)(a[b] - 3) ;
		else cout << (char)(a[b] + 23);
	}
	cout << endl;
}

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

ll powmod(ll base, ll exp, ll mod){
    if(exp == 0){
        return 1;
    }
    if(exp % 2 == 0){
        ll t = powmod(base, exp/2, mod);
        return (t * t) % mod;
    }
    return (base * powmod(base, exp - 1, mod)) % mod;
}

unordered_map<ll, ll> primefactordecomp(ll n){
    unordered_map<ll, ll> ans = unordered_map<ll, ll>();
    ll m = pow(n, 0.5) + 1;
    for (ll i = 2; i < m; i++){
        while (n > 1){
            if (n % i != 0){
                break;
            }

            if (n % i == 0) {
                if (ans.count(i)) {
                    ans[i] = ans[i] + 1;
                } else {
                    ans[i] = 1;
                }
                n = ll(n / i);
                continue;
            }
        }
    }
    if (n > 1) {
        if (ans.count(n)) {
            ans[n] = ans[n] + 1;
        } else {
            ans[n] = 1;
        }
    }
    return ans;
}

int main(){
    int N;
    unordered_map<ll, ll> total_primes = unordered_map<ll, ll>();
    vector<unordered_map<ll, ll>> each_primes = vector<unordered_map<ll, ll>>();

    ll M = pow(10, 9) + 7;
    cin >> N;
    ll A[N];
    for (int i = 0; i < N; i++){
        ll c;
        cin >> c;
        unordered_map<ll,ll> primes = primefactordecomp(c);
        for(pair<ll, ll> p: primes){
            if(total_primes.count(p.first) == 0) {
                total_primes[p.first] = 0;
            }
            total_primes[p.first] = max(p.second, total_primes[p.first]);
        }
        A[i] = c;
        each_primes.emplace_back(primes);
    }
    ll lcm = 1;
    for(pair<ll, ll> p: total_primes){
        lcm *= powmod(p.first, p.second, M);
        lcm %= M;
    }

    ll ans = 0;
    for (int i = 0; i < N; i++){
        ans += (lcm * powmod(A[i], M-2, M)) % M;
        ans %= M;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3416
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 100005;
struct ii {
	ll a, b;
	bool operator < (ii o) const {
		return tie(a, b) < tie(o.a, o.b);
	}
};

ll N;
ii arr[2*MAXN], pos[MAXN];

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	
	cin >> N;
	ll a = 0, b = 0;
	for (int i = 0; i < N; i++) {
		cin >> arr[2*i].a >> arr[2*i|1].a;
		pos[i] = {arr[2*i].a, arr[2*i|1].a};
		a += arr[2*i].a;
		b += arr[2*i|1].a;
		arr[2*i].b = arr[2*i|1].b = i;
	}
	sort(arr, arr+2*N);
	
	multiset<ii> s;
	ll sum = 0;
	for (int i = 0; i < N; i++) s.insert(arr[i]), sum += arr[i].a;
	
	ll ans = min(a, b);
	for (int i = 0;i < N; i++) {
		if (s.find({pos[i].a, i}) != s.end()) {
			s.erase(s.find({pos[i].a, i}));
			sum -= pos[i].a;
		}
		if (s.find({pos[i].b, i}) != s.end()) {
			s.erase(s.find({pos[i].b, i}));
			sum -= pos[i].b;
		}
		vector<ii> keluar;
		while ((int)s.size() > N-2) {
			sum -= s.rbegin()->a;
			keluar.push_back(*s.rbegin());
			s.erase(prev(s.end()));
		}
		s.insert({pos[i].a, i});
		s.insert({pos[i].b, i});
		sum += pos[i].a + pos[i].b;
		ans = min(ans, sum);
		
		for (auto j: keluar) {
			s.insert(j);
			sum += j.a;
		}
		while ((int)s.size() > N) {
			sum -= s.rbegin()->a;
			s.erase(prev(s.end()));
		}
	}
	cout << ans << "\n";
	
	return 0;
}


Measured memory_bytes: 11264
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main (){
    int N,K,Q;
    int sum=0;
    cin >> N >> K >> Q ;
    int A[100003];
    int s[100003];
    for(int i=1;i<=N;i++){
        s[i]=K;
    }

    for(int i=0;i<Q;i++){
        cin >> A[i];
        s[A[i]]+=1;
    }
    for(int i=1;i<=N;i++){
        if(s[i]-Q>0){
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <set>

#include <string>
#include <vector>
#include <algorithm>

using namespace std;

vector<string> ss;

int main() {
	int n,m;

	cin >> n >> m;

	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		ss.push_back(s);
	}
	sort(ss.begin(),ss.end());

	for (string s : ss) {
		cout << s;
	}
	cout << endl;

	return 0;
}

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

int minjumps(vector<int>v,int k)
{
  int n=v.size();
  vector<int>dp(n,0);
  for(int i=n-2;i>=0;i--)
  {
      int min=dp[i+1]+abs(v[i]-v[i+1]);
      for(int j=i+2;j<n&&j<=k+i;j++)
      {
          int cost=dp[j]+abs(v[i]-v[j]);
          if(cost<min)
              min=cost;
      }
      dp[i]=min;

  }
  return dp[0];
}

int main()
{
  int n,k;
  cin>>n>>k;
  vector<int>v(n);
  for(int i=0;i<n;i++)
  {
    cin>>v[i];
  }
  cout<<minjumps(v,k)<<endl;  
  return 0;
}

Measured memory_bytes: 1408
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <iostream>
#include <set>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <complex>
#include <map>
#include <queue>
#include <array>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<pii> vii;
typedef vector<string> vs;

vvi g;
int C = 0, L;

void dfs(int v, int p, int d) {
  if (d > L) ++C;
  for (int nv : g[v]) {
    if (nv == p) continue;
    dfs(nv, v, d + 1);
  }
}

int main() {
  int n, k;
  cin >> n >> k;
  g.resize(n);
  for (int i = 0; i < n-1; ++i) {
    int a,b;
    cin >> a >> b;
    --a; --b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  int mi = n;
  if (k % 2 == 0) {
    for (int i = 0; i < n; ++i) {
      C = 0;
      L = k / 2;
      dfs(i, -1, 0);
      mi = min(mi, C);
    }
  } else {
    for (int a = 0; a < n; ++a) for (int b : g[a]) {
      C = 0;
      L = k / 2;
      dfs(a, b, 0);
      dfs(b, a, 0);
      mi = min(mi, C);
    }
  }
  cout << mi << endl;
  return 0;
}

Measured memory_bytes: 384
import numpy as np

N = int(input())
A = [0] + list(map(int, input().split()))

A = np.array(A, dtype = np.int64)
A = np.cumsum(A)

dp = np.zeros((N, N), dtype = np.int64)

for j in range(1, N):
    for i in range(N - j):
        # print (dp[i, i:i + j], dp[i + 1:i + j + 1, i + j])
        tmp = min(dp[i, i:i + j] + dp[i + 1:i + j + 1, i + j])
        dp[i][i + j] = tmp + A[i + j + 1] - A[i]

print (dp[0][N - 1])

Measured memory_bytes: 15668
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 = sc.nextInt();
        int b = sc.nextInt();
        sc.close();

        int ans = Math.min(n * a, b);
        System.out.println(ans);
    }

}


Measured memory_bytes: 22228
#define _GLIBCXX_DEBUG //エラーを出すためのおまじない
#include <bits/stdc++.h>
#include <algorithm>
//#include <cstdlib>  // abs() for integer
#include <cmath>    // abs() for float, and fabs()
#include <math.h>
using namespace std;
#define coYES cout << "YES" << endl
#define coNO cout << "NO" << endl
#define coYes cout << "Yes" << endl
#define coNo cout << "No" << endl
#define coyes cout << "yes" << endl
#define cono cout << "no" << endl
//#define cocount cout << count << endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define Cinint(n) int n;\
cin >> n;
#define Cinvecint(a, n) vector<int> a(n);\
for (int i = 0; i < (int)(n); i++) {\
  int num;\
  cin >> num;\
  a.at(i) = num;\
}
#define Cinstring(s) string s;\
cin >>s;

  

int main() {
  char al;
  cin >> al;
  string alsmall = "abcdefghijklmnopqrstuvwxyz"; //size 26
  string albig = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  rep(i, 26) {
    if (alsmall.at(i) == al) {
      cout << 'a' << endl;
    }
    else if (albig.at(i) == al) {
      cout << 'A' << endl;
    }
  }
}


Measured memory_bytes: 3560
"""
N = list(map(int,input().split()))
S = [str(input()) for _ in range(N)]
S = [list(map(int,list(input()))) for _ in range(h)] 
print(*S,sep="")
"""

import sys
sys.setrecursionlimit(10**6)
input = lambda: sys.stdin.readline().rstrip()
inf = float("inf") # 無限

a = int(input())
print(a+a**2+a**3)

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

int main(){
    int k,n;
    cin >> k >> n;
    vector<int> a(n);
    rep(i,n) cin >> a.at(i);

    //aはソート済み
    int dmax = a.at(0) + k - a.at(n - 1);
    for(int i = 0; i < n - 1; i++) {
        dmax = max(dmax,a.at(i + 1) - a.at(i));
    }
    cout << k - dmax << endl;
}


Measured memory_bytes: 1024
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

enum MOD = (10 ^^ 9) + 7;

void main()
{
    long N = lread();
    bool[long] D;
    foreach (_; 0 .. N)
    {
        long A = lread();
        D[A] = (A in D) ? !D[A] : true;
    }
    D.values.sum().writeln();
}


Measured memory_bytes: 6652
#include <iostream>
#include <cmath>

using namespace std;

int roundUp(int x, int index);

int main(void)
{
    int i;
    int n;
    double intrst;
    int debt;
    
    cin >> n;
    
    debt = 100000;
    intrst = 0.05;
    for (i = 0; i < n; i++) {
        debt *= 1.0 + intrst;
        debt = roundUp(debt, 4);
    }
    
    cout << debt << endl;
    
    return 0;
}

int roundUp(int x, int index)
{
    int exp10;
    
    exp10 = pow(10, index - 1);
    if(x % exp10 != 0){
        x += exp10 - (x % exp10);
    }
    
    return x;
}

Measured memory_bytes: 1200
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);

		int n = sc.nextInt();

		long[] l = new long[n + 1];
		l[0] = 2;
		l[1] = 1;
		for (int i = 2; i <= n; i++) {
			l[i] = l[i - 1] + l[i - 2];
		}

		out.println(l[n]);
		out.flush();
	}

}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) return true;
		else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) return false;
		}
		return true;
	}

	private byte readByte() {
		if (hasNextByte()) return buffer[ptr++];
		return -1;
	}

	private boolean isPrintableChar(byte c) {
		return '!' <= c && c <= '~';
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public String next() {
		if (!hasNext()) throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		byte b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public int nextInt() {
		if (!hasNext()) throw new NoSuchElementException();
		int n = 0;
		boolean minus = false;
		byte b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) throw new NumberFormatException();
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = nextInt();
		}
		return a;
	}

	public long nextLong() {
		if (!hasNext()) throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		byte b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) throw new NumberFormatException();
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++) {
			a[i] = nextInt();
		}
		return a;
	}
}

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

int main() {
    int n;
    cin >> n;
    int v,w,x,y,z;
    w = n % 10;// 1
    v = n / 10;
    x = v % 10;// 10
    v = v / 10;
    y = v % 10;// 100
    v = v / 10;
    z = v % 10;//1000
    if (z == y && y == x) 
        cout << "Yes" << endl;
    else if (w == x && x == y)
        cout << "Yes" << endl;
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#define MOD 1000000007
using namespace std;

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

long long int C[4000][4000];
for(int i=0;i<=2000;i++){
  C[i][0]=1;
  for(int j=1;j<=i;j++){
    C[i][j]=(C[i-1][j]+C[i-1][j-1])%MOD;
  }
}

for(int i=1;i<=K;i++){
  cout<<C[N-K+1][i]*C[K-1][i-1]%MOD<<endl;
}

}


Measured memory_bytes: 63872
import sys
import textwrap

s=input()
c=-1
if "hi" not in s:
    print("No")
    sys.exit()
    
w=textwrap.wrap(s,2)

for i in w:
    if i!="hi":
        c=0
        break
if c==0:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 3444
use proconio::input;

fn main() {
    input! {
        N: usize,
        S: [String; N],
    };

    let mut ac = 0;
    let mut wa = 0;
    let mut tle = 0;
    let mut re = 0;

    for str in S {
        if str == "AC" {
            ac += 1;
        } else if str == "WA" {
            wa += 1;
        } else if str == "TLE" {
            tle += 1;
        } else {
            re += 1;
        }
    }
    println!("AC x {}\nWA x {}\nTLE x {}\nRE x {}", ac, wa, tle, re);
}


Measured memory_bytes: 7788
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define chmax(a,b) (a<(b)?(a=b,1):0)
#define chmin(a,b) (a>(b)?(a=b,1):0)
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

bool isPalindrome(ll n) {
  ll t = n;
  ll r = 0;
  while(t) {
    r = r*10 + t%10;
    t /= 10;
  }
  return r == n;
}
int main() {
  int n;
  while(cin >> n) {
    int ans = -1;
    int dist = INF;
    REP(i,13000) {
      if (isPalindrome(i)) {
        if (chmin(dist,abs(i-n))) {
          ans = i;
        }
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 1164
use std::cmp::min;

fn main() {
    let (n, k): (i64, i64) = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let mut iter = buf.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    };

    let ans = min(n % k, k - n % k);
    println!("{}", ans);
}

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

#define IOS cin.tie(0);ios_base::sync_with_stdio(false)

#define ll      long long
#define Fi      first
#define Se      second
#define Pb      push_back
#define vi      vector<int>
#define vs      vector<string>
#define vp      vector<pair<int,int>>
#define vvi     vector<vector<int>>
#define vvp     vector<vector<pair<int,int>>>
using Graph  =  vector<vector<int>>; //Caution!! Segmentation Fault!! Don't forget to add +1!

#define sz(x) (int)x.size()
#define all(v) v.begin(),v.end()
#define output_s(s) printf("%s\n",(s).c_str())
#define END cout<<"\n"

#define rep(i,n)        for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m)      for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m)     for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m)    for(int i=(int)(n);i>=(int)(m);i--)
#define SRepS(i,n,m)    for(int i=(int)(n);i*i<=(int)(m);i++)
#define RepA(x)         for(auto &item:(x))

void CINT(){} //@shibh308's template
template<class Head,class... Tail> void CINT(Head&& head,Tail&&... tail){cin>>head; CINT(move(tail)...);}    
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
#define VCIN(x) for(auto &item:x) cin>>item

void OUT(){}
template<class Head,class...Tail> void OUT(Head&& head,Tail&&...tail){cout<<head<<(sizeof...(tail)?" ":"\n"); OUT(move(tail)...);}
#define COUT(...) OUT(__VA_ARGS__)

template<typename TypeInt>TypeInt GCD(TypeInt a,TypeInt b){return a%b==0?b:GCD(b,a%b);} //最大公約数
template<typename TypeInt>TypeInt LCM(TypeInt a,TypeInt b){return a*b/GCD(a,b);} //最小公倍数
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}
template<class T>bool comp(T a,T b){return abs(a)<abs(b);} //比較関数

void YES(bool f){printf(f?"YES\n":"NO\n");}
void Yes(bool f){printf(f?"Yes\n":"No\n");}
void Possible(bool f){printf(f?"Possible\n":"Impossible\n");}
void POSSIBLE(bool f){printf(f?"POSSIBLE\n":"IMPOSSIBLE\n");}

//----------------------library------------------------//

//const int dx[4]={1,0,-1,0};
//const int dy[4]={0,1,0,-1};
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int NMAX = 200;
const int INF = 1e9;
const int MOD = 1e9+7;
bool flag;

//----------------------Global-------------------------//

signed main(){
    CIN(N);
    map<char,int> mp;
    SCIN(s);
    RepA(s)mp[item]++;
    rep(i,N-1){
        map<char,int> cur;
        SCIN(S);
        RepA(S)cur[item]++;
        RepA(mp) chmin(item.second,cur[item.first]);
    }
    RepA(mp)rep(i,item.second)printf("%c",item.first);
    END;


    return 0;
}

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

int main() {
   string a,b;
   cin >> a >> b;
   sort(a.begin(),a.end());
   sort(b.begin(),b.end());
   reverse(b.begin(),b.end());
   
   if(a.size() > b.size()){
       for(int i = 0; i < a.size() - b.size(); i++){
           b = b + '.';
       }
   }
   else if(b.size() > a.size()){
       for(int i = 0; i < b.size() - a.size(); i++){
           a = a + '.';
       }
   }
   bool flag = false;
   int i = 0;
   while(1){
       if(a == b){
           break;
       }
       else if(a[i]-b[i] > 0){
           break;
       }
       else if(a[i]-b[i] < 0){
           flag = true;
           break;
       }
       i++;
    }
    flag ? cout << "Yes" << endl : cout << "No" << endl;
   
}

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

# dp[i][j]: 最初のi枚を投げたときに表がj枚となる確率
dp = [[0] * (n + 1) for _ in range(n + 1)]

dp[0][0] = 1.0

for i in range(n):
	for j in range(n):
		dp[i + 1][j + 1] += dp[i][j] * p[i] # 表
		dp[i + 1][j] += dp[i][j] * (1 - p[i]) # 裏

res = 0
for j in range(n + 1):
	if n < 2 * j: # 表の枚数 > 裏の枚数
		res += dp[n][j]

print(res)

Measured memory_bytes: 253704
#include<stdio.h>

int main(void)
{
  long int N,A,B,a,b;
  scanf("%ld%ld%ld",&N,&A,&B);
  a = N / (A+B) * A;
  b = N % (A+B);
  if(b>A)
    printf("%ld\n",a+A);
  else
    printf("%ld\n",a+b);
  return 0;
}


Measured memory_bytes: 128
//#include <bits/stdc++.h>
#include <iostream>
#include<math.h>

using namespace std;

int n;
int a[200];

bool waru() {
	for (int i = 0; i < n; i++)
	{
		if (a[i] % 2 != 0) {

			return false;
		}
		a[i] = a[i] / 2;
	}
	return true;
}


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

	int ans = 0;

	while (true) {
		if (waru() == true) {
			ans++;
		}
		else {
			break;
		}
	}
	cout << ans << endl;



	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 rep2(s,i, n) for (int i = (int)s; i < (int)(n); i++)
#define pb push_back
typedef long long ll;



int main(){
    ll n,k;
    cin>>n>>k;
    ll new_n=0;
    bool check=true;
    while(check||(new_n!=new_n%k)){
        check=false;
        new_n=n%k;
    }
    if(abs(new_n-k)<new_n)new_n=abs(new_n-k);

    cout<<new_n<<endl;
    return 0;
}

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

int h, w, ans=0;
vector<string> fi;

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

int main() {
    cin >> h >> w;
    fi.resize(h);
    for (int i = 0; i < h; ++i) cin >> fi.at(i);

    vector<vector<int> > dist(h, vector<int>(w, -1));
    queue<pair<int, int> > que;

    for (int i = 0; i < h; ++i)
    {
    	for (int j = 0; j < w; ++j)
    	{
    		if (fi.at(i).at(j) == '#')
    		{
    			dist.at(i).at(j) = 0;
    			que.push(pair<int, int>(i, j));
    		}
    	}
    }

    // BFS
    while(!que.empty()) {
    	auto cur = que.front();
    	que.pop();

    	for (int dir = 0; dir < 4; ++dir)
    	{
    		int nx = cur.first + dx[dir];
    		int ny = cur.second + dy[dir];

    		if (nx < 0 || nx >= h || ny < 0 || ny >= w) continue;

    		if (dist.at(nx).at(ny) == -1)
    		{
    			dist.at(nx).at(ny) = dist.at(cur.first).at(cur.second) + 1;
    			que.push(pair<int, int>(nx, ny));
    		}
    	}
    }

    for (int i = 0; i < h; ++i)
    {
    	for (int j = 0; j < w; ++j)
    	{
    		ans = max(ans, dist.at(i).at(j));
    	}
    }

    cout << ans << endl;
}

Measured memory_bytes: 13456
import java.util.Scanner;

public class Main {
	private Scanner sc;
	
	public static void main(String[] args) {
		new Main();
	}
	
	public Main() {
		sc = new Scanner(System.in);

		int nico = Integer.parseInt(sc.nextLine());
		for (int i = 0; i < nico; i++) {
			String n0 = sc.nextLine();
			String n1 = sc.nextLine();
			String ans = "";
			
			int lim = n0.length();
			if (lim < n1.length()) lim = n1.length();
			
			int c = 0;
			for (int j = 0; j < lim; j++) {
				int a = 0;
				int b = 0;
				
				if (j < n0.length()) {
					a = n0.charAt(n0.length() - j - 1) - '0';
				}
				if (j < n1.length()) {
					b = n1.charAt(n1.length() - j - 1) - '0';
				}
				
				int sum = a + b + c;
				if (sum > 9) {
					sum = sum - 10;
					c = 1;
				} else {
					c = 0;
				}
				
				ans = sum + ans;
			}
			if (c == 1) ans = c + ans;
			
			if (ans.length() > 80) {
				System.out.println("overflow");
			} else {
				System.out.println(ans);
			}
		}
	}
}

Measured memory_bytes: 26096
from sys import stdout
printn = lambda x: stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True  and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

def foo(i):
    #ddprint("foo {} call ".format(i))
    mn = 0
    mx = i
    while mx-mn>=2:
        mid = (mx+mn)//2
        if a[i]+m < a[mid]:
            mn = mid
        else:
            mx = mid
    r = mx
    #ddprint("r {}".format(r))
    if r>p:
        return False
    #q = v-n+i-r
    #if q<=0:
    #    return (a[i]+m >= a[p])
    ok = False
    for s in range(r,p+1):
        ret = ( (i-s)*(a[i]+m) >= acc[i-1]-acc[s-1]+m*(v-n+i-s))
        #ddprint("ret {} i {} s {} ai {} m {} acm {} acp {} v-n+i-s {}".format(ret,i,s,a[i],m,acc[i-1],acc[s-1],v-n+i-s))
        if ret:
            ok = True
            break
    #ret = ( (i-p)*(a[i]+m) >= max(a[p], acc[i-1]-acc[p-1]+m*q) )
    #ddprint("foo {} returns {}".format(i,ok))
    return ok

n,m,v,p = inm()
a = inl()
a.sort(reverse=True)
a[0:0] = [0] # a1..an
acc = [0]*(n+1)
for i in range(1,n+1):
    acc[i] = acc[i-1]+a[i]
ddprint("n {} m {} v {} p {}".format(n,m,v,p))
ddprint(a)
ddprint(acc)
mn = p
mx = n+1
while mx-mn>=2:
    #ddprint("loop mn {} mx {}".format(mn,mx))
    mid = (mn+mx)//2
    if foo(mid):
        mn = mid
    else:
        mx = mid
print(mn)


Measured memory_bytes: 62704
N=int(input())
l=[]
for i in range(2,int(N**0.5)+1):
    if N % (i) == 0:
       l.append(i)
if len(l) == 0:
    print(N-1)
elif len(l) == 1:
    print(int(N / l[0]) + l[0] -2)
elif len(l) == 2 and N == l[0] * l[1]:
    print(l[0] + l[1] -2)
else:
    distance = 10**12 - 2
    tmp = 0
    for i in range(len(l)):
        for j in range(i, len(l)):
            if N % (l[i] * l [j]) == 0 and distance > (N / (l[i] * l [j])) + (l[i] * l [j]) -2:
              distance = int(N / (l[i] * l [j])) + (l[i] * l [j]) -2
    print(distance)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

typedef long long ll;

using namespace std;

int main()
{
    ll D, G; cin >> D >> G;

    vector<ll> P(D), C(D);
    for(ll i = 0; i < D; i++) cin >> P[i] >> C[i];

    vector<ll> ord(D);

    for(ll i = 0; i < D; i++) ord[i] = i + 1; //並び替え配列構成

    ll min_cnt = 1e5;

    do{
        ll cnt = 0; ll total = G;

        for(ll i = 0; i < D; i++){
            if(total <= ord[i]*100*P[ord[i] - 1]){
                //おまけ無し終了
                while(total > 0 ){
                    total -= 100*ord[i];
                    cnt++;
                }
                break;
            }else{
                total -= ord[i]*100*P[ord[i] - 1];
                cnt += P[ord[i]- 1];
                if(total > C[ord[i] - 1]) total -= C[ord[i] - 1]; //おまけ有り続行
                else break; //おまけ有り終了
            }
        }

        min_cnt = min(min_cnt,cnt);
    }while(next_permutation(ord.begin(),ord.end()));

    cout << min_cnt << endl;

    return 0;
}


Measured memory_bytes: 256
s = input()
if (s[0] == s[1] and s[0] != s[2] and s[2] == s[3]) or (s[0] == s[2] and s[1] == s[3] and s[0] != s[1]) or (s[0] == s[3] and s[1] == s[2] and s[0] != s[1]):
  print("Yes")
else:
  print("No")

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


void solve(long long H, long long N, std::vector<long long> A, std::vector<long long> B){
    std::vector<long long> DP(H+1,0);
    std::vector<long long> update_array(N,0);
    for (int i=1;i<=H;i++){
        for (int j=0;j<N;j++){
            if (i- A[j]>=0){
                update_array[j] = DP[i-A[j]] + B[j];
            }else{
                update_array[j] = B[j];
            }
        }
        DP[i] = *std::min_element(update_array.begin(),update_array.end());
    }
    printf("%lld\n",DP[H]);
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long H;
    scanf("%lld",&H);
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    std::vector<long long> B(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
        scanf("%lld",&B[i]);
    }
    solve(H, N, std::move(A), std::move(B));
    return 0;
}


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

int main(){
    int m1,d1,m2,d2;
    cin >> m1 >> d1 >> m2 >> d2;
    if (m1 == m2)
    {
        cout << 0 << endl;
    }else{
    cout << 1 << endl;
    }
    return 0;
}

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

int main() {
    int a, b;
    cin >> a >> b;
    int ans = 6-a-b;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>

using namespace std;
int w, h;
int c[100][100];
int dx[8]={-1, 0, 1, 0, -1, -1, 1, 1};
int dy[8]={0, -1, 0, 1, -1, 1, -1, 1};
int cnt=0;

void search(int x, int y);

int main()
{
	while(1){
		cin >> w >> h;
		if(w == 0 && h == 0) break;
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				cin >> c[i][j];
			}
		}
		for(int i  = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				if(c[i][j] == 1){
					c[i][j] = 0;
					search(i, j);
					cnt++;
				}
			}
		}
		cout << cnt << endl;
		cnt = 0;
	}
}

void search(int x, int y)
{
	int nx, ny;
	for(int i = 0; i < 8; i++){
		nx = x + dx[i];
		ny = y + dy[i];
		if(nx < 0 || ny < 0 || nx >= h || ny >= w) continue;
		if(c[nx][ny] == 1){
			c[nx][ny] = 0;
			search(nx, ny);
		}
	}
}

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

int main(){
  string s; cin >> s;
  int a=s[0]-'0', b=s[1]-'0', c=s[2]-'0', d=s[3]-'0', ans=0;
  char op1, op2, op3;

  for(int i=0; i<(1<<3); i++){
    ans=0;
    if((i>>2)&1){
      op1='+';
      ans=a+b;
    }else if(!((i>>2)&1)){
      op1='-';
      ans=a-b;
    }
    if((i>>1)&1){
      op2='+';
      ans+=c;
    }else if(!((i>>1)&1)){
      op2='-';
      ans-=c;
    }
    if(i&1){
      op3='+';
      ans+=d;
    }else if(!(i&1)){
      op3='-';
      ans-=d;
    }
    if(ans==7) break;
  }
  cout << s[0] << op1 << s[1] << op2 << s[2] << op3 << s[3] << '=' << ans << endl;

  return 0;
}


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

  cin >> N;

  if ( N < 1000) {
    cout << "ABC" << endl;
  } else {
    cout << "ABD" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    char s[120];
    int h,w;
    cin >> h >> w;
    for(int i=0;i<h;i++){
        cin >> s;
        cout << s << endl;
        cout << s << endl;
    }
    return 0;
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  int N;
  cin>>N;
  if(N%2)cout<<2*N<<endl;
  else cout<<N<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <tuple>
#include <string>

#define printhere cout << "HERE\n"
#define printV(v, n)    \
    for (int i = 0; i < n; i++) \
        cout << v[i] << " ";
#define readV(v, n)     \
    for (int i = 0; i < n; i++) \
        cin >> v[i];
#define pb(v, t) v.push_back(t)
#define mp(a, b) make_pair(a, b)
#define ll long long
#define ull unsigned long long

using namespace std;

int main()
{
    int n;
    cin >> n;
    int dig = n % 10;
    if(dig == 3) cout << "bon\n";
    else if(dig == 0 || dig == 1 || dig == 6 || dig == 8) cout << "pon\n";
    else cout << "hon\n";
    return 0;
}

Measured memory_bytes: 3620
# include <bits/stdc++.h>
///# include <ext/pb_ds/assoc_container.hpp>
///# include <ext/pb_ds/tree_policy.hpp>

///using namespace __gnu_pbds;
using namespace std;

# define ll long long
# define ld long double
# define pb push_back
# define ppb pop_back

const ll N = 1e5 + 10;
const ll M = 1e7 + 1000;
const ll mod = 998244353;
const ll INF = 1e18;
const ll inf = -1e18;

///typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> void_set;

bool isprime(ll x) {
    if(x == 1) return false;
    ll y = sqrt(x);
    for(int i = 2;i <= y;i++) {
        if(x % i == 0) {
            return false;
        }
    }
    return true;
}

ll bin_pow(ll a, ll b) {
    if(b == 0) return 1;
    if(b == 1) return a;
    if(a == 0) return 0;
    if(a == 1) return a;
    if(b % 2 == 0) {
        ll pw = bin_pow(a, b / 2);
        return pw * pw;
    } else {
        return bin_pow(a, b - 1) * a;
    }
}

const ld pi = acos(-1);

ll n;
pair <ll, ll> a[N];

int main() {
    ///ios_base::sync_with_stdio(false);
    ///cin.tie(NULL), cout.tie(NULL);
    ///setlocale(0,"RUS");
    ///ifstream cin("input.txt");
    ///ofstream cout("output.txt");
    cin >> n;
    for(int i = 1;i <= n;i++) {
        cin >> a[i].first;
        a[i].second = i;
    }
    sort(a + 1, a + n + 1);
    for(int i = 1;i <= n;i++) {
        cout << a[i].second << " ";
    }
}
/**
**/



Measured memory_bytes: 2432
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <array>
#include <initializer_list>
#include <random>
#include <regex>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
using namespace std;

char dat[111][111];
int cnt[256];

int need[5];

int main()
{
    int h, w;
    scanf("%d%d",&h,&w);

    for (int i = 1; i <= h; i++) scanf("%s", dat[i] + 1);
    for (int i = 1; i <= h; i++) for (int j = 1; j <= w; j++) cnt[dat[i][j]]++;

    for (int i = 1; i <= h; i++)
    {
        if (h - i + 1 < i) break;
        for (int j = 1; j <= w; j++)
        {
            if (w - j + 1 < j) break;

            int factor = 4;
            if (i == h - i + 1) factor /= 2;
            if (j == w - j + 1) factor /= 2;

            need[factor] += factor;
        }
    }

    for (int i = 4; i >= 1; i /= 2)
    {
        for (int j = 'a'; j <= 'z' && need[i]; j++)
        {
            while (need[i] && cnt[j] >= i)
            {
                cnt[j] -= i;
                need[i] -= i;
            }
        }

        if (need[i])
        {
            printf("No\n");
            return 0;
        }
    }

    printf("Yes\n");
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() (int, error) {
	return strconv.Atoi(nextString())
}

func main() {
	scanner.Split(bufio.ScanWords)

	counts := map[int]int{}
	for i := 0; i < 10; i++ {
		for j := 0; j < 10; j++ {
			for k := 0; k < 10; k++ {
				for l := 0; l < 10; l++ {
					s := i + j + k + l
					if s <= 50 {
						counts[s]++
					}
				}
			}
		}
	}
	// fmt.Println(counts)
	for {
		n, err := nextInt()
		if err != nil {
			break
		}
		cnt, ok := counts[n]
		if ok {
			fmt.Println(cnt)
		} else {
			fmt.Println(0)
		}
	}
}



Measured memory_bytes: 1084
#include <cmath>
#include <functional>
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <sstream>
#include <chrono>
#include <cstring>

using namespace std;

typedef long long ll;

#ifdef iq
  mt19937 rnd(228);
#else
  mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif

int s, t;

ll ok[18][2];
ll comb[51][51];
ll f[51];

ll ans = 0;

void brute(int bit, int sign, ll cands) {
  if (bit == 18) {
    ans += f[__builtin_popcountll(cands)] * sign;
  } else {
    if (((s >> bit) & 1) == ((t >> bit) & 1)) {
      brute(bit + 1, sign, cands);
    } else {
      brute(bit + 1, sign, cands);
      brute(bit + 1, -sign, cands & ok[bit][0]);
      brute(bit + 1, -sign, cands & ok[bit][1]);
    }
  }
}

int main() {
#ifdef iq
  freopen("a.in", "r", stdin);
#endif
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  cin >> s >> t;
  comb[0][0] = 1;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n; j++) {
      if (i) comb[i][j] += comb[i - 1][j];
      if (i && j) comb[i][j] += comb[i - 1][j - 1];
    }
  }
  for (int i = 0; i <= n; i++) {
    for (int j = 1; j <= k; j++) {
      f[i] += comb[i][j];
    }
  }
  vector <int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  if ((t & s) != s) {
    cout << 0 << '\n';
    return 0;
  }
  vector <int> x;
  for (int i = 0; i < n; i++) {
    if (((a[i] & t) == a[i]) && ((a[i] | s) == a[i])) {
      x.push_back(a[i]);
    }
  }
  a = x;
  n = (int) a.size();
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 18; j++) {
      ok[j][(a[i] >> j) & 1] |= (1ll << i);
    }
  }
  brute(0, 1, (1ll << n) - 1);
  cout << ans << endl;
}


Measured memory_bytes: 3684
#include<stdio.h>

int kiriage( int x )
{   
    return x%1000==0 ? x : x+1000-(x%1000);
}

int main(){

	int i,n;
	int sum=100000;
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		sum=kiriage(sum*1.05);
	}
	printf("%d\n",sum);

	return 0;
}

Measured memory_bytes: 592
import numpy as np
N =int(input())
data =np.array( [[ int(i) for i in input().split(" ")] for i in range(N)])
t_past = 0
x_past = 0
y_past = 0
flag = 0
for i in range(N):
    t_diff = data[i,0] - t_past
    x_diff = data[i,1] - x_past
    y_diff = data[i,2] - y_past
    if not( t_diff -abs(x_diff) -abs(y_diff) >=0 and (t_diff-abs(x_diff)-abs(y_diff))%2 ==0):
        flag = 1
        break
    t_past = data[i,0]
    x_past = data[i,1]
    y_past = data[i,2]
if flag == 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 32456
import sys

commands = sys.stdin.readline().rstrip()

def main():
    res = []
    for c in commands:
        if c == 'B':
            if res:
                res.pop()
        else:
            res.append(c)
    return ''.join(res)
            
if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 2940
#!usr/bin/env python3
from collections import defaultdict, deque, Counter, OrderedDict
from functools import reduce, lru_cache
import collections, heapq, itertools, bisect
import math, fractions
import sys, copy

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI1(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline().rstrip())
def LS(): return [list(x) for x in sys.stdin.readline().split()]
def S(): return list(sys.stdin.readline().rstrip())
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
dire = [[1, 0], [0, 1], [-1, 0], [0, -1]]
dire8 = [[1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]]
MOD = 1000000007

def main():
    N = I()
    A = LI()

    ans = 0
    for i, ai in enumerate(A):
        if i % 2 == 0 and ai % 2 == 1:
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 77128
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <stack>
#define Endl endl
#define mp make_pair
#define rep(N) for(int i=0;i<N;i++)
#define repj(N) for(int j=0;j<N;j++)
#define ll long long 
#define pii pair<int,int>
#define pll pair<ll,ll>
#define For(I,N) for(int I=0;I<N;I++)
#define cinone(N) int N;cin>>N;
#define scanfone(N) int N;cin>>N;
#define cinng(N,M) int N[M];for(int yiuytvnm=0;yiuytvnm<M;yiuytvnm++) cin>>N[yiuytvnm];
#define scanfng(N,M) int N[M];for(int qrwuoiq=0;qrwuoiq<M;qrwuoiq++) scanf("%d",&N[qrwuoiq]);
#define over(A) {cout<<A<<endl;exit(0);}
#define pip pair<int,pair<int,int> >
typedef unsigned long long ull;
const int inf=103974182;
using namespace std;
int n;
pair<int,pii> a[200005];
vector <pair<int,pii> >vec;
set <pair<int,pair<int,int> > > squ;
int f[200005];
priority_queue <pip,vector <pip>,greater<pip> >que;

int find(int x)
{
	return (x==f[x]?x:f[x]=find(f[x]));
}

int add(int x,int y)
{
	x=find(x);
	y=find(y);
	if(rand()&1) f[x]=y;else f[y]=x;
}

bool compare1(pair<int,pii> a,pair<int,pii> b)
{
	return a.second.first<b.second.first;
}

bool compare2(pair<int,pii> a,pair<int,pii> b)
{
	return a.second.second<b.second.second;
}

void init()
{
	for(int i=0;i<200005;i++)
	{
		f[i]=i;
	}
}

int main()
{
//	freopen("input.txt","r",stdin);
	cin>>n;
	for(int i=0;i<n;i++)
	{
		scanf("%d%d",&a[i].second.first,&a[i].second.second);
		a[i].first=i;
	}
	sort(a,a+n,compare1);
	for(int i=0;i<n-1;i++)
	{
		vec.push_back(mp(min(abs(a[i+1].second.first-a[i].second.first),abs(a[i+1].second.second-a[i].second.second)),mp(a[i].first,a[i+1].first)));
	}
	sort(a,a+n,compare2);
	for(int i=0;i<n-1;i++)
	{
		vec.push_back(mp(min(abs(a[i+1].second.first-a[i].second.first),abs(a[i+1].second.second-a[i].second.second)),mp(a[i].first,a[i+1].first)));
	}
	sort(vec.begin(),vec.end());
//	for(int i=0;i<vec.size();i++)
//	{
////		que.push(vec[i]);
//		squ.insert(vec[i]);
//	}
//	for(set <pair<int,pii> > ::iterator it=squ.begin();it!=squ.end();it++)
//	{
//		cout<<it->first<<' '<<it->second.first<<' '<<it->second.second<<endl;
//	}
//	cout<<que.size()<<endl;
	init();
	int k=0;
	ll ans=0;
	int len=unique(vec.begin(),vec.end())-vec.begin();
	for(int i=0;i<len;i++)
	{
//		cout<<que.size()<<endl;
//		system("pause");
		if(k==n-1) break;
		pip t=vec[i];
		if(find(t.second.first)==find(t.second.second)) continue;
		k++;
//		cout<<k<<endl;
		ans+=t.first;
		add(t.second.first,t.second.second);
	}
	cout<<ans<<Endl;
	return 0;
}

Measured memory_bytes: 6132
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define BUF 1e5
#define INF 1 << 30
#define vi vector<int>
#define vvi vector<vector<int>>
#define all(a) (a).begin(), (a).end()
#define bit(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
constexpr ll mod = 1e9 + 7;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            int x = (i ^ j);
            int tmp = 0;
            dump(x, x & 1);
            while (!(x & 1)) {
                x /= 2;
                tmp++;
            }
            cout << tmp + 1 << endl;
        }
    }
}

Measured memory_bytes: 512
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

ll n , A , B , C , D;

int main(){
    cin >> n >> A >> B >> C >> D;
    rep(i,0,n) {
        ll left = -D * i + C * (n - 1 - i);
        ll right= -C * i + D * (n - 1 - i);
        if(left <= B - A && B - A <= right)
            return puts("YES") , 0;
    }
    puts("NO");
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
    typedef long long int ll;
    #define vll vector<long long int> 
    #define pb push_back
    #define f(i,x,n) for (i=x;i<n;i++)
    
    
    void solve(){
       int n;
       cin >> n;
       ll a[n];
       ll sum=0;
       for(int i=0;i<n;i++)cin >> a[i];
       for(int i=1;i<n;i++){
           if(a[i]<a[i-1]){
               sum+=a[i-1]-a[i];
               a[i]=a[i-1];
           }
       }
        cout << sum ;
    }
    int main(){
    	ios_base::sync_with_stdio(false); 
         	cin.tie(NULL);
    	int t=1;
    	
    	while(t--)
    	solve();	
    	
    
    }

Measured memory_bytes: 5176