akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1000000007
typedef long long ll;
using namespace std;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

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

    ll N;
    cin >> N;

    ll a    = N;
    int b   = 10;
    int mn  = 0;
    int cnt = 0;
    bool f  = true;
    while (a != 0) {
        if (a % 10 <= b) {
            b  = a % 10;
            mn = cnt;
        }
        a /= 10;
        cnt++;
    }

    if (cnt == 1) {
        std::cout << N << std::endl;
        return 0;
    }
    if (mn == cnt - 1)
        mn--;
    int ans1 = 0;
    int ans2 = 0;
    REP(i, cnt) {
        if (i == mn + 1) {
            ans1 += N % 10 - 1;
        } else {
            ans1 += 9;
        }
        ans2 += N % 10;
        N /= 10;
    }

    std::cout << max(ans1, ans2) << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int A, B, M;
int a[114514], b[114514];
int x[114514], y[114514], c[114514];

int main(void) {
	int i;
	int teika, waribiki, temp;
	if (scanf("%d%d%d", &A, &B, &M) != 3) return 1;
	for (i = 1; i <= A; i++) {
		if (scanf("%d", &a[i]) != 1) return 1;
	}
	for (i = 1; i <= B; i++) {
		if (scanf("%d", &b[i]) != 1) return 1;
	}
	for (i = 1; i <= M; i++) {
		if (scanf("%d%d%d", &x[i], &y[i], &c[i]) != 3) return 1;
	}

	temp = a[1];
	for (i = 2; i <= A; i++) {
		if (a[i] < temp) temp = a[i];
	}
	teika = temp;
	temp = b[1];
	for(i = 2; i <= B; i++) {
		if (b[i] < temp) temp = b[i];
	}
	teika += temp;

	waribiki = a[x[1]] + b[y[1]] - c[1];
	for (i = 2; i <= M; i++) {
		temp = a[x[i]] + b[y[i]] - c[i];
		if (temp < waribiki) waribiki = temp;
	}

	printf("%d\n", teika <= waribiki ? teika : waribiki);
	return 0;
}


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

int main(void){
	char n[50][50], m[50][50];
	int nn, nm, cou;

	cin >> nn >> nm;
	for(int i=0; i<nn; i++){
		cin >> n[i];
	}
	for(int i=0; i<nm; i++){
		cin >> m[i];
	}
	for(int h=0; h<=nn-nm; h++){
		for(int i=0; i<=nn-nm; i++){
			cou=0;
			for(int j=0; j<nm; j++){
				for(int k=0; k<nm; k++){
					if(n[j+h][k+i]!=m[j][k]){
						cou=-1;
					}
					if(cou==-1){
						break;
					}else if(++cou==nm*nm){
						cout << "Yes" << endl;
						return 0;
					}
				}
			}
		}
	}
	cout << "No" << endl;
}


Measured memory_bytes: 508
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 998244353;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

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

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

ll lcm(ll a, ll b) {
	return a / gcd(a, b) *b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


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

template<typename T>
struct Segment_Tree {
	typedef function<T(T, T)> F;

	ll n;
	F f;//モノイドとしての演算(最小値、和　など)
	T unit;//単位元

	ll size;
	vector<T> seg;

	Segment_Tree(ll n0, F f0, T unit0) {
		n = n0;
		f = f0;
		unit = unit0;

		size = 1;
		while (size < n) {
			size *= 2;
		}
		seg.assign(2 * size, unit);
	}


	void update(ll k, T x) {//k番目の要素をxに更新
		k += size - 1;
		seg[k] = x;
		while (k > 1) {
			k /= 2;
			seg[k] = f(seg[2 * k], seg[2 * k + 1]);
		}
	}



	T query_prep(ll a, ll b, ll k, ll l, ll r) {//[a,b)とkに対応する区間[l,r)の共通部分でクエリ
		if (b <= l || a >= r) { return unit; }
		if (a <= l && r <= b) { return seg[k]; }

		T v1 = query_prep(a, b, 2 * k, l, (l + r) / 2);
		T v2 = query_prep(a, b, 2 * k + 1, (l + r) / 2, r);
		return f(v1, v2);

	}

	T query(ll a, ll b) {
		return query_prep(a, b, 1, 1, size + 1);
	}

};



int main() {
	ll N;
	cin >> N;

	vector<vector<ll>> g(N+1);

	repn(i, N-1) {
		ll a, b;
		cin >> a >> b;
		g[a].push_back(b);
		g[b].push_back(a);
	}

	vector<ll> dis(N + 1,-1);
	queue<ll> q;

	dis[1] = 0;
	q.push(1);

	while (!q.empty()) {
		ll v = q.front();
		q.pop();

		for (ll w : g[v]) {
			if (dis[w] != -1) { continue; }
			dis[w] = dis[v] + 1;
			q.push(w);
		}
	}

	vector<ll> od, ev;

	repn(i, N) {
		if (dis[i] % 2 == 1) { od.push_back(i); }
		else { ev.push_back(i); }
	}

	ll O = od.size();
	ll E = ev.size();

	//rep(i, O) cout << od[i];
	//cout << endl;
	//rep(i, E) cout << ev[i];


	vector<ll> ans(N + 1,-1);

	vector<ll> us(N + 1, 0);

	if (O <= N / 3) {
		rep(i, O) {
			ans[od[i]] = 3 * (i + 1);
			us[3 * (i + 1)] = 1;
		}

		ll j = 1;
		rep(i, E) {
			while (us[j] == 1) { j++; }
			ans[ev[i]] = j;
			j++;
		}
	}

	else if ( E<= N / 3) {
		rep(i, E) {
			ans[ev[i]] = 3 * (i + 1);
			us[3 * (i + 1)] = 1;
		}

		ll j = 1;
		rep(i, O) {
			while (us[j] == 1) { j++; }
			ans[od[i]] = j;
			j++;
		}
	}

	else {
		rep(i, (N+2) / 3) {
			ans[od[i]] = 3 * i + 1;
		}

		rep(i, (N + 1) / 3) {
			ans[ev[i]] = 3 * i + 2;
		}

		ll j = 1;
		repn(i, N) {
			if (ans[i] == -1) {
				ans[i] = 3 * j; j++;
			}
		}
	}

	repn(i, N) cout << ans[i] << " ";

	
	

	system("PAUSE");

}





Measured memory_bytes: 23132
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
#include<cassert>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
#define ceil(a, b) a / b + !!(a % b)

int main() {
    int a, b, c; cin >> a >> b >> c;
    int x; cin >> x;
    int ans = 0;
    int aa = 0;
    while (aa * 500 <= x) {
        int bb = 0;
        while (aa * 500 + bb * 100 <= x) {
            int cc = 0;
            while (aa * 500 + bb * 100 + cc * 50 <= x) {
                if (aa * 500 + bb * 100 + cc * 50 == x) {
                    //cout << aa << " " << bb << " " << cc << endl;
                    ans++;
                }
                cc++;
                if (cc > c) break;
            }
            bb++;
            if (bb > b) break;
        }
        aa++;
        if (aa > a) break;
    }
    cout << ans << endl;
}


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

def main():
    n, s = map(int, input().split())
    a = list(map(int, input().split()))

    dp = [0]*(s+1)
    dp[0] = 1
    mod = 998244353

    for i in range(n):
        for j in range(s, -1, -1):
            if dp[j] and j + a[i] <= s:
                dp[j+a[i]] += dp[j]
                dp[j+a[i]] %= mod
            dp[j] *= 2
            dp[j] %= mod

    print(dp[s])
    
    
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 68116
package main

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

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func first(m map[int]struct{}) int {
	for k, _ := range m {
		return k
	}

	return 0
}

func main() {
	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)

	n := nextInt()
	m := nextInt()

	v := make(map[int]map[int]struct{})

	for i := 0; i < m; i++ {
		a := nextInt()
		b := nextInt()

		if len(v[a]) == 0 {
			v[a] = make(map[int]struct{})
		}
		v[a][b] = struct{}{}

		if len(v[b]) == 0 {
			v[b] = make(map[int]struct{})
		}
		v[b][a] = struct{}{}
	}

	unvisited := make(map[int]struct{})

	for i := 1; i <= n; i++ {
		unvisited[i] = struct{}{}
	}

	maxGroupSize := 0
	for len(unvisited) > 0 {
		groupSize := 0
		startNode := first(unvisited)
		q := []int{startNode}

		delete(unvisited, startNode)

		for len(q) > 0 {
			node := q[0]
			q = q[1:]
			groupSize++

			if _, ok := v[node]; !ok {
				// no edge
				continue
			}

			for nextNode, _ := range v[node] {
				if _, ok := unvisited[nextNode]; ok {
					q = append(q, nextNode)
					delete(unvisited, nextNode)
				}
			}
		}

		if groupSize > maxGroupSize {
			maxGroupSize = groupSize
		}
	}

	fmt.Println(maxGroupSize)
}


Measured memory_bytes: 64428
def call(n):
    s = ""
    for i in range(1,n+1):
        if i%3 == 0:
            s += " {0}".format(i)
        else:
            x = i
            while x > 0:
               if x%10 == 3:
                   s += " {0}".format(i)
                   break
               x = x // 10
    print(s)

m = int(input())
call(m)

Measured memory_bytes: 7632
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#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;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

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();}
ll dp[3][2020] = {};
int main(){
    std::ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int cur = 0;
    int nxt = 1;
    ll ret = 0;
    int len = s.length();
    for(int i=0;i<len;++i){
        int digit = s[i] - '0';
        //dump(digit)
        dp[nxt][digit] += 1;
        for(int j=0;j<2019;++j)
        {
            int mod = (j * 10 + digit) % 2019;
            dp[nxt][mod] += dp[cur][j];
        }
        ret += dp[nxt][0];
        cur = 1 - cur;
        nxt = 1 - nxt;
        for(int j=0;j<2019;++j)
        {
            dp[nxt][j] = 0;
        }
    }

    cout << ret << endl;
}

Measured memory_bytes: 3788
package main

import (
	"fmt"
)

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

func rsort(nums []int, n int) {
	for i := 1; i < n; i++ {
		v := nums[i]
		j := i - 1
		for j >= 0 && nums[j] < v {
			nums[j+1] = nums[j]
			j--
		}
		nums[j+1] = v
	}
}

func main() {
	var a, b, k int
	fmt.Scan(&a, &b, &k)

	m := min(a, b)
	var nums []int
	for i := 1; i <= m; i++ {
		if a%i == 0 && b%i == 0 {
			nums = append(nums, i)
		}
	}

	rsort(nums, len(nums))

	fmt.Println(nums[k-1])
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
typedef long long ll;
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
using Graph = vector<vector<int>>;

int main()
{
    int h, w, n;
    cin >> h >> w >> n;
    h = max(h, w);
    int ans = (n - 1) / h + 1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a, b, ans, count;

	while(scanf("%d %d", &a, &b)!=EOF)
	{
		ans=a+b;
		
		for(count=0; ans!=0; count++)
		{
			ans/=10;
		}
	
		printf("%d\n", count);
	}
	
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,ans;
  cin >> a >> b;
  ans = (a * b) % 2;
  if (ans == 0) {
    cout << "Even" << endl;
  } else {
    cout << "Odd" << endl;
  }
}

Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
    input = input.split("\n");
    var line = input[0].split(" ");
    var num = parseInt(line[0]);
    var key_index = parseInt(line[1]);
    var ans = [];
    
    var first = 0;
    var second = 0;

    for(var i =0; i<100001;i++){
        ans[i] = 0;
    }

    for(var i =0; i<num;i++){
        var temp = input[i+1].split(" ");
//        console.log(temp);
        first = parseInt(temp[0]);
        second = parseInt(temp[1]);
        
        ans[first]+=second;
    }

    for(var i =0; i<100001;i++){
        if(ans[i]!=0){
//            console.log(i+":"+ans[i]);
        }
    }
    
    var index = 1;
    var current_amount = 0;

    while(1){
        current_amount += ans[index];
        if(current_amount<key_index){
            index++;
        } else {
//            console.log("current_amount:"+current_amount+" index:"+index);
            console.log(index);
            break;
        }
    }
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));



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

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();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007; // 998244353

#define CLR(a) memset((a), 0, sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    ll X; cin >> X;
    ll ans = 1000*(X/500);
    X %= 500;
    ans += 5*(X/5);
    cout << ans << 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;
using ll = long long;


int main(){
    int n; cin >> n;
    vector<int> tmp(300000, 0);
    rep(i, n-1) {
        int a = 0; cin >> a;
        tmp[a]++;
    }

    for(int i = 1; i <= n; i++) {
        cout << tmp[i] << endl;
    }


    return 0;
}



Measured memory_bytes: 4576
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void run(void){
  int a,b,c,k;
  scanf("%d%d%d%d",&a,&b,&c,&k);
  if(a<b){
    int swap=a;
    a=b;
    b=swap;
  }
  if(a<c){
    int swap=a;
    a=c;
    c=swap;
  }
  
  int i;
  for(i=0;i<k;i++) a*=2;
  printf("%d\n",a+b+c);
}

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


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const int N=1e3;
int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n;cin>>n;
  if(n<1200)cout<<"ABC"<<endl;
  else if(n<2800)cout<<"ARC"<<endl;
  else cout<<"AGC"<<endl;
  return 0;
}


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

int pw(int n,int k){
  assert(k>=0);
  int res=1;
  while(k){
    if(k&1)res*=n;
    n*=n;
    k>>=1;
  }
  return res;
}

signed main(){
  vector<int> v(15,1);
  int now=10;
  for(int i=1;i<15;i++){
    char s;
    cout<<"? "<<now<<endl;
    cin>>s;v[i]=(s=='Y');
    now*=10;
  }
  int tim=-1;
  for(int i=0;i<15&&tim<0;i++)if(!v[i])tim=i;
  if(~tim){
    int l=pw(10,tim-1),r=pw(10,tim)-1;
    char s;
    cout<<"? "<<l<<1<<endl;
    cin>>s;
    if(s=='Y'){
      cout<<"! "<<l<<endl;
      return 0;
    }
    while(r-l>1){
      int m=(r+l)>>1;
      cout<<"? "<<m<<1<<endl;
      cin>>s;
      if(s=='N')l=m;
      else r=m;
    }
    cout<<"! "<<r<<endl;
  }
  else{
    int now=2;
    for(int i=0;i<15;i++)v[i]=0;
    for(int i=1;i<15;i++){
      char s;
      cout<<"? "<<now<<endl;
      cin>>s;v[i]=(s=='Y');
      now*=10;
    }
    tim=-1;
    for(int i=0;i<15&&tim<0;i++)if(v[i])tim=i;
    if(tim<0)cout<<"! 1"<<endl;
    else cout<<"! "<<pw(10,tim-1)<<endl;
  }
}


Measured memory_bytes: 596
#include <iostream>
#include <vector>
#include <queue>
#include <functional>
#include <algorithm>
#include <cmath>
using namespace std;

typedef pair<int, int> S;
typedef pair<int, S> P;

const int INF = 1 << 21;
const int MAX_C = 10, MAX_N = 100, MAX_M = 500;

int dp[MAX_N + 1][MAX_C + 1], w[MAX_N + 1][MAX_N + 1];
int c, n, m, s, d;

int solve()
{
    for(int i = 0; i <= MAX_N; i++) 
        for(int j = 0; j <= MAX_C; j++) 
            dp[i][j] = INF;
    
    priority_queue<P, vector<P>, greater<P> > que;
    que.push(P(0, S(s, c)));
    while(!que.empty()) {
        P p = que.top(); que.pop();
        int cost = p.first,  from = p.second.first, t = p.second.second;
        
        if(from == d)
            return cost;

        for(int to = 1; to <= n; to++) {
            if(cost + w[from][to] < dp[to][t]) {
                dp[to][t] = cost + w[from][to];
                que.push(P(dp[to][t], S(to, t)));
            }
        }

        if(t > 0) {
            for(int to = 1; to <= n; to++) {
                if(w[from][to] / 2 + cost < dp[to][t - 1]) {
                    dp[to][t - 1] = w[from][to] / 2 + cost;
                    que.push(P(dp[to][t-1], S(to, t - 1)));
                }
            }
        }
    }
}

int main()
{
    while(cin >> c >> n >> m >> s >> d && c || n || m) {

        for(int i = 0; i <= n; i++) 
            for(int j = 0; j <= n; j++)
                w[i][j] = INF;
        int a, b, f;
        for(int k = 0; k < m; k++) {
            cin >> a >> b >> f;
            w[a][b] = w[b][a] = f;
        }

        cout << solve() << endl;
    }
}

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

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

int main(){
    ll N,D;
    cin>>N>>D;
    vector<ll> X(N),Y(N);
    REP(i,N) cin>>X[i]>>Y[i];

    ll ans=0;
    REP(i,N){
        ll dis=pow(X[i],2)+pow(Y[i],2);
        if(dis<=pow(D,2)) ans++;
    }
    cout<<ans<<endl;
}

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

int main() {
  char buffer[100];
  char duffer[100];
    int number1;
    int number2;
    int a,b,c=0;
  	int i=0;
    int g=0;
    int h=0;
    int s=0;
    int t=0;
  	int pq=0;
  	int qtr=0;
      scanf("%s",duffer);
    number2=atoi(duffer);
    int data[number2];
    for(i=0;i<number2;i++){
    scanf("%s",buffer);
      number1=atoi(buffer);
    data[i]=number1;
    }
      

  for(pq=0;pq<number2;pq++){
    g+=data[pq];
    qtr+=data[pq];
  }
	g=g/2;
	t+=data[0];
for(h=0;h<number2;h++){
    if(s<=g && g<t){
break;
    }else{
    s+=data[h];
    t+=data[h+1];
}
}

  if(abs(qtr-2*s)<abs(qtr-2*t)){
    printf("%d",abs(qtr-2*s));
  }else{
    printf("%d",abs(qtr-2*t));
  }
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) int((a).size())
#define out(a) cout<<(a)<<endl;
const int INF=INT_MAX;
const int MAX = 510000;
const ll MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];

int main(){
  ll n,q;cin>>n>>q;
  string s;cin>>s;
  vll sum(n,0);
  rep(i,0,n-1){
    if(s[i]=='A'&&s[i+1]=='C'){
      sum[i+1]=sum[i]+1;
    }
    else{sum[i+1]=sum[i];}
  }
  rep(i,0,q){
    ll l,r;cin>>l>>r;
    l--;r--;
    cout<<sum[r]-sum[l]<<endl;
  }

}




Measured memory_bytes: 4256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;


template<class T> class BIT   // 1-indexed (0 is not used)
{
private:
    int num;
    vector<T> bit;
public:
    BIT(int n):bit(vector<T>(n+1, 0)), num(n) {}

    T sum(int i) {   // sum of 1..i
        if (!i) return 0;
        return bit[i] + sum(i-(i&-i));
    }

    void add(int i, T x) {
        if (i > num) return;
        bit[i] += x;
        add(i+(i&-i), x);
    }
};

ll InvNum( int n, int* a )
{
    map<int,int> mp;
    int i;
    for(i=0; i<n; i++) {
        mp[a[i]]=0;
    }
    int num=0;
    auto it=mp.begin();
    for(; it!=mp.end(); ++it) {
        num++;
        it->second=num;
    }

    ll ans=0;
    BIT<int> bit(num);
    for(i=0; i<n; i++) {
        ans += i - bit.sum(mp[a[i]]);
        bit.add(mp[a[i]], 1);
    }
    return ans;
}

ll mpow(ll x, ll n){ //x^n(mod M)
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % MOD;
        x = x*x % MOD;
        n = n >> 1;
    }
    return ans;
}

ll minv(ll x){
    return mpow( x, MOD-2 );
}

int main(int argc, char* argv[])
{
    int n;
    ll  K;
    scanf("%d%lld", &n, &K);

    vector<int> a(n);
    map<int,int> z;
    int i;
    for(i=0; i<n; i++) {
        scanf("%d", &a[i]);
        z[a[i]]++;
    }

    ll ans0=InvNum( n, &(a[0]) );
    ll ans=ans0*K %MOD;

    ll ans1=n*n;
    ll ans2=0;
    auto it=z.begin();
    for(; it!=z.end(); ++it) {
        ans2 += (it->second)*(it->second);
    }
    ans1 = (ans1-(ans2%MOD) +MOD)%MOD;
    ans1 = K*(K-1)%MOD *minv(2)%MOD *ans1%MOD *minv(2) %MOD;

    ans = (ans + ans1)%MOD;
    printf("%lld\n", ans);


    return 0;
}


Measured memory_bytes: 384
s = gets.chomp.split('')
s.map! { |x| (x == 'A' || x == 'C' || x == 'G' || x == 'T') ? x : ' ' }
array = s.join.split(' ').map { |y| y.length }
if array.empty?
  puts '0'
else
  puts array.max
end


Measured memory_bytes: 1788
/* - - - - - - - - - - - - - - -
	User : 		VanishD
	problem :
	Points : 	
- - - - - - - - - - - - - - - */
# include <bits/stdc++.h>
# define 	ll 		long long
using namespace std;
const int inf = 0x3f3f3f3f, INF = 0x7fffffff;
const ll  infll = 0x3f3f3f3f3f3f3f3fll, INFll = 0x7fffffffffffffffll;
int read(){
	int tmp = 0, fh = 1; char ch = getchar();
	while (ch < '0' || ch > '9'){ if (ch == '-') fh = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9'){ tmp = tmp * 10 + ch - '0'; ch = getchar(); }
	return tmp * fh;
}
const int P = 1e9 + 7, N = 210;
int n, h[N];
ll f[N][2][2][2], g0[2][2][2], g1[2][2][2], use[N];
ll power(ll x, int y){
	ll i = x; x = 1;
	while (y > 0){
		if (y % 2 == 1) x = x * i % P;
		i = i * i % P;
		y /= 2;
	}
	return x;
}
int main(){
//	freopen(".in", "r", stdin);
//	freopen(".out", "w", stdout);
	n = read();
	for (int i = 1; i <= n; i++) h[i] = read(); 
	h[++n] = 1;
	int las = inf, lim, tmp, cnt = 0;
	while (cnt < n){
		lim = -1;
		for (int j = 1; j <= n; j++)
			if (use[j] == 0) 
				lim = max(h[j], lim);
		tmp = las - lim;
		for (int j = 1; j <= n; j++){
			if (use[j] == 2) continue;
			if (use[j] == 0){
				if (h[j] < lim) continue;
				use[j] = 1;
				f[j][0][0][0] = f[j][0][1][1] = 1;
				cnt++;
			}
			else if (use[j] == 1){
				f[j][0][0][0] = f[j][0][1][1] = (f[j][0][1][1] + f[j][0][0][0]) * power(2, tmp - 1) % P;
				f[j][0][0][1] = f[j][0][1][0] = (f[j][0][0][1] + f[j][0][1][0]) * power(2, tmp - 1) % P;
				if (tmp % 2 == 1){
					swap(f[j][1][0][0], f[j][1][1][1]);
					swap(f[j][1][0][1], f[j][1][1][0]);
				}
			}
			if (j != 1 && use[j - 1] != 0){
				use[j] = 2;
				int k = j - 1;
				while (use[k] == 2) k--;
				for (int t0 = 0; t0 <= 1; t0++)
					for (int t1 = 0; t1 <= 1; t1++)
						for (int t2 = 0; t2 <= 1; t2++)
							g0[t0][t1][t2] = f[k][t0][t1][t2], g1[t0][t1][t2] = f[j][t0][t1][t2];
				for (int t0 = 0; t0 <= 1; t0++)
					for (int t1 = 0; t1 <= 1; t1++){
						f[k][0][t0][t1] = (g0[0][t0][1] * g1[0][0][t1] + g0[0][t0][0] * g1[0][1][t1]) % P;
						f[k][1][t0][t1] = ((g0[1][t0][1] + g0[1][t0][0]) * (g1[1][0][t1] + g1[1][1][t1] + g1[0][0][t1] + g1[0][1][t1])) % P;
						f[k][1][t0][t1] = (f[k][1][t0][t1] + (g0[0][t0][1] + g0[0][t0][0]) * (g1[1][0][t1] + g1[1][1][t1])) % P;
						f[k][1][t0][t1] = (f[k][1][t0][t1] + g0[0][t0][1] * g1[0][1][t1] + g0[0][t0][0] * g1[0][0][t1]) % P;
					}
			}
		}
		las = lim; 
	}
	ll ans = 0;
	for (int t0 = 0; t0 <= 1; t0++)
		for (int t1 = 0; t1 <= 1; t1++)
			ans = (ans + f[1][0][t0][t1] + f[1][1][t0][t1]) % P;
	printf("%lld\n", 1ll * ans * power(2, P - 2) % P);
	return 0;
}

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

#define plus __________plus
#define fi first
#define se second
#define show(x) cerr << #x << "=" << "\n"
typedef long long ll;
typedef unsigned long long ull;

using namespace std;

int n, k;
int a[100001];
ll sum[100001];
ll plus[100001];


int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout << fixed;
#ifdef LOCAL_DEFINE
  FILE *stream1;
  //FILE *stream2;
  stream1 = freopen("in.txt", "r", stdin);
  //stream2 = freopen("out.txt", "w", stdout);
  if (stream1 == NULL) return 0;
  //if (stream2 == NULL) return 0;:w
#endif
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sum[0] = a[0];
  for (int i = 1; i < n; i++) {
    sum[i] = sum[i - 1] + a[i];
  }
  for (int i = 0; i < n; i++) {
    if (i == 0) {
      a[i] > 0 ? plus[i] = a[i] : plus[i] = 0;
      continue;
    }
    a[i] > 0 ? plus[i] = plus[i - 1] + a[i] : plus[i] = plus[i - 1];
  }
  ll ans = 0;
  for (int i = 0; i <= n - k; i++) {//black
    ll res = sum[i + k - 1] - sum[i] + a[i];
    if (i > 0) {
      res += plus[i - 1];
    }
    if (i + k < n) {
      res += plus[n - 1] - plus[i + k - 1];
    }
    ans = max(ans, res);
  }
  for (int i = 0; i <= n - k; i++) {//white
    ll res = 0;
    if (i > 0) {
      res += plus[i - 1];
    }
    if (i + k < n) {
      res += plus[n - 1] - plus[i + k - 1];
    }
    ans = max(ans, res);
  }
  cout << ans << endl;
#ifdef LOCAL_DEFINE
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s.\n";
  fclose(stream1);
  //fclose(stream2);
#endif
  return 0;
}

Measured memory_bytes: 2176
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long[] l = new long[87];
		l[0] = 2;
		l[1] = 1;
		for (int i = 2; i < l.length; i++) {
			l[i] = l[i - 1] + l[i - 2];
		}
		System.out.println(l[N]);
	}
}

Measured memory_bytes: 21844
import math
import string
import itertools
import fractions
import heapq
import collections
import re
import array
import bisect
import sys
import random
import time
from collections import deque
inf = 10**9


def main():
    o = 1
    s = deque(input())
    q = int(input())
    for i in range(q):
        qu = input().split()
        if qu[0] == '1':
            o = int(not o)
        else:
            addo = 1 if qu[1] == '1' else 0
            if o == addo:
                s.appendleft(qu[2])
            else:
                s.append(qu[2])
        # print(s, o)
    
    if o:
        print(''.join(s))
    else:
        s.reverse()
        print(''.join(s))




if __name__ == '__main__':
    main()


Measured memory_bytes: 10668
#include <algorithm>
#include <iostream>
#include <vector>

int main() {
	int N, M;
	std::cin >> N >> M;
	std::vector<std::pair<int, int>> request(M);
	for(int i = 0; i < M; i++) {
		int a, b;
		std::cin >> a >> b;
		request[i] = std::make_pair(a - 1, b - 1);
	}

	std::sort(request.begin(), request.end(), [](auto a, auto b) {
		return a.second < b.second;
	});

	int result = 0;
	while(!request.empty()) {
		int last = request.front().second;
		auto end = std::remove_if(request.begin(), request.end(), [=](auto a) {
			return a.first < last;
		});
		request.erase(end, request.end());
		result++;
	}

	std::cout << result << std::endl;

	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

#define BOMB '#'

struct board {
    int h;
    int w;
    char board[50][51];
};

struct board b = {
    0,
    0,
    {}
};

int is_bomb(int y, int x)
{
    if (b.board[y][x] == BOMB) {
        return 1;
    }
    return 0;
}

int bomb_cnt(int y, int x)
{
    int d[8][2] = {
        {-1, -1},
        {-1, 0},
        {-1, 1},
        {0, -1},
        {0, 1},
        {1, -1},
        {1, 0},
        {1, 1},
    };
    int cnt = 0;
    for (int i = 0; i < 8; ++i) {
        int dy = y + d[i][0];
        int dx = x + d[i][1];
        if (dy < 0 || dy > b.h || dx < 0 || dx > b.w) {
            continue;
        }
        if (is_bomb(dy, dx)) {
            cnt++;
        }
    }
    return cnt;
}

int main(int argc, char const *argv[])
{
    scanf("%d %d", &b.h, &b.w);
    for (int i = 0; i < b.h; ++i) {
        scanf("%s", b.board[i]);
    }

    struct board n = {
        b.h,
        b.w,
        {}
    };
    for (int i = 0; i < b.h; ++i) {
        for (int j = 0; j < b.w; ++j) {
            if (is_bomb(i, j)) {
                n.board[i][j] = BOMB;
            } else {
                sprintf(&n.board[i][j], "%d", bomb_cnt(i, j));
            }
        }
    }
    for (int i = 0; i < b.h; ++i) {
        printf("%s\n", n.board[i]);
    }
    return 0;
}

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

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

double distance(vector<int> vec1, vector<int> vec2){
    double tmp = 0;
    rep(i, vec1.size()){
        tmp += pow(vec1[i]-vec2[i], 2);
    }
    return sqrt(tmp);
}

int main() {
    int n,d;
    cin >> n >> d;
    vector<vector<int>> vec(n, vector<int>(d));
    rep(i,n){
        rep(j, d){
            int tmp;
            cin >> tmp;
            vec[i][j] = tmp;
        }
    }
    int cnt = 0;
    rep(i, n-1){
        int idx = i + 1;
        while(idx < n){
            double dist = distance(vec[i], vec[idx]);
            if(ceil(dist) == floor(dist)){
                cnt++;
            }
            idx++;
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
use io::*;

fn main() {
    let con = read_string();
    let mut sc = Scanner::new(&con);

    let d: i32 = sc.next();
    let n: i32 = sc.next();

    let n = if n == 100 { 101 } else { n };

    let ans = 100_i64.pow(d as u32) * n as i64;

    println!("{}", ans);
}

//-----

pub mod io {
    use std;
    use std::str::FromStr;

    pub struct Scanner<'a> {
        iter: std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }

        pub fn next<T: FromStr>(&mut self) -> T {
            let s = self.iter.next().unwrap();
            if let Ok(v) = s.parse::<T>() {
                v
            } else {
                panic!("Parse error")
            }
        }

        pub fn next_vec_len<T: FromStr>(&mut self) -> Vec<T> {
            let n: usize = self.next();
            self.next_vec(n)
        }

        pub fn next_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.next()).collect()
        }
    }

    pub fn read_string() -> String {
        use std::io::Read;

        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }

    pub fn read_line() -> String {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    }
}


Measured memory_bytes: 4352
# -*- coding: utf-8 -*-

import sys
if sys.version_info.minor >= 5: from math import gcd
else: from fractions import gcd

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

def divisors(N: int) -> set:
    """ 約数の列挙・個数 """
    from math import sqrt

    # 1とその数はデフォで入れとく
    s = {1, N}
    # 終点はルート切り捨て
    for i in range(2, int(sqrt(N))+1):
        # 割り切れるなら、iとN/iを追加
        if N % i == 0:
            s.add(i)
            s.add(N // i)
    return s

N = INT()
A = LIST()

gcds = 0
for a in A:
    gcds = gcd(gcds, a)

ans = sorted(divisors(gcds))
[print(a) for a in ans]



Measured memory_bytes: 5696
#include<stdio.h>
int main(){
  int a,b,c,d,e,k;
  scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&k);
  if(e - a > k ){
    printf(":(");
  }else if(d-a > k){
     printf(":(");
  }else if(c-a > k){
     printf(":(");
  }else if(b-a > k){
     printf(":(");
  }else if(c-b > k){
     printf(":(");
  }else if(d-b > k){
     printf(":(");
  }else if(e-b > k){
     printf(":(");
  }else if(d-c > k){
     printf(":(");
  }else if(e-c > k){
     printf(":(");
  }else if(e-d > k){
     printf(":(");
  }else{
    printf("Yay!");
  }
}

Measured memory_bytes: 128
import itertools

N, M = map(int, input().split())

S = []
for i in range(M):
    s = list(map(int, input().split()))
    S.append(s[1:])
    
P = [int(i) for i in input().split()]

A = [0, 1]
ans = 0
for i in itertools.product(A, repeat = N):
    flag = 0
    for j in range(M):
        cnt = 0
        for s in S[j]:
            if i[s - 1] == 1:
                cnt += 1
        if cnt % 2 != P[j]:
            flag = 1
    if flag == 0:
        ans += 1
        
print(ans)

Measured memory_bytes: 41584
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        try (Scanner scan = new Scanner(System.in)) {
            // スキップ
            scan.nextLine();

            // 検索対象をmapに格納する
            Map<String, String> map = new HashMap<String, String>();
            for (String num : scan.nextLine().split(" ")) {
                map.put(num, "");
            }

            // スキップ
            scan.nextLine();

            // 検索対象が存在する場合はカウントする
            int count = 0;
            for (String num : scan.nextLine().split(" ")) {
                if (map.containsKey(num)) {
                    count++;
                }
            }

            System.out.println(count);
        }

    }

}



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

int main(void){
  int n, l, sum = 0, maxlen = 0;
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> l;
    if(l > maxlen){
      sum += maxlen;
      maxlen = l;
    } else{
      sum += l;
    }
  }
  if(maxlen < sum) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
use std::io::prelude::*;

fn input<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

#[allow(dead_code)]
fn with_stdout_lock<F: FnOnce(std::io::BufWriter<std::io::StdoutLock>)>(f: F) {
    let out = std::io::stdout();
    let w = std::io::BufWriter::new(out.lock());
    f(w);
}

#[allow(unused_macros)]
macro_rules! debug {
    ($var:expr) => {
        match &$var { v => eprintln!(concat!(stringify!($var), "={:?}"), v) }
    };
    ($var:expr, $($vars:expr),*) => {
        match &$var { v => eprint!(concat!(stringify!($var), "={:?} "), v) }
        debug!($($vars),*);
    };
}

fn main() {
    let n: usize = input();
    let mut h: Vec<i32> = (0..n).map(|_| input()).collect();

    let mut ans = 0;
    loop {
        let mut l = 0;
        while l < n && h[l] == 0 {
            l += 1;
        }
        if l == n {
            break;
        }
        let mut r = l;
        let mut mn = h[l];
        while r < n && h[r] > 0 {
            mn = std::cmp::min(mn, h[r]);
            r += 1;
        }
        ans += mn;
        for i in l..r {
            h[i] -= mn;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int siz=2e5;
const long inf=1e9;
int main(){
	int N; cin>>N;
	int S[(1<<N)];
	rep(i,0,(1<<N)) cin>>S[i];
	sort(S, S+(1<<N), greater<int>());
    int res[(1<<N)] = {}; res[0] = S[0];
	priority_queue<pair<int,int>> pq[N]; pq[N-1].push({res[0], 0});
	int k = 1;
	rep(i,1,(1<<N)){
        int j = N-1;
        int v;
        while(j >= 0){
            if(!pq[j].empty()){
                v = pq[j].top().second;
        		if(res[v] > S[k]){
                    res[v|(1<<j)] = S[k];
                    pq[j].pop();
                    break;
                }
            }
            if(j == 0){ cout<<"No"<<endl; return 0; }
            j--;
        }
        if(j > 0){
            pq[j-1].push({res[v], v});
        	pq[j-1].push({res[v|(1<<j)], v|(1<<j)});
        }k++;
	}cout<<"Yes"<<endl;
}

Measured memory_bytes: 4600
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main{
	
	public static void main(String[] args)throws Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		
		while(true){
			String[] line = br.readLine().split(" ");
			
			int h = Integer.parseInt(line[0]);
			int w = Integer.parseInt(line[1]);
			
			if(h == 0 && w == 0){
				break;
			}
			
			for(int i=0; i<h; i++){
				for(int j=0; j<w; j++){
					if(i%2 == 0){
						if(j%2 ==0){
							sb.append("#");
						}
						else{
							sb.append(".");
						}
					}
					else{
						if(j%2 ==0){
							sb.append(".");
						}
						else{
							sb.append("#");
						}
					}
				}
				sb.append("\n");
			}
			sb.append("\n");
			System.out.print(sb);
			sb.delete(0,sb.length());
		}
	}
}

Measured memory_bytes: 24920
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, n) for(int i = 1; i <= (int)(n); i++)
const long long INF = 1LL << 60;
const double PI=3.14159265358979323846;
int main() 
{
    long long n,k;
    cin >> n >> k;
    cout << min(n%k,abs(n%k-k)) << endl;
}

Measured memory_bytes: 256
// AOJ 0029 English Sentence
// ??????0??????????£? 5???
// map????????£?????°???????????????????????§???????????????????????¬??????????????????????¢?????????????
#include <iostream>
#include <map>
#include <string>
using namespace std;
int N,Q;
string era[10010];
int eby[10010],wy[10010];
int solve(){
	cin >> N >> Q;
	if(N+Q==0)return 1;
	for(int i=0;i<N;i++){
		cin >> era[i] >> eby[i] >> wy[i];
	}
	for(int i=0;i<Q;i++){
		int tar;
		cin >> tar;
		bool known = false;
		for(int j=0;j<N;j++){
			if(wy[j]-eby[j]<tar&&tar<=wy[j]){
				cout << era[j] << ' ' << tar-(wy[j]-eby[j]) << endl;
				known = true;
				break;
			}
		}
		if(!known)cout << "Unknown" << endl;
	}
	return 0;
}
int main(){
	while(!solve()){}
	return 0;
}

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

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}






int ggcd(int a,int b)
{
 
  int r, tmp;
 
  
 
  /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
 
 
  return b;
}







int fac(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}

int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}
///////////////////////////
int main() {
  int n;
  cin>>n;
  vector<int> v(n),w(n);
  rep(i,n) cin>>v[i];
  w[0]=0;
  w[1]=abs(v[1]-v[0]);
  for(int i=2;i<n;i++) w[i]=min(w[i-1]+abs(v[i]-v[i-1]),w[i-2]+abs(v[i]-v[i-2]));
  cout<<w[n-1]<<endl;
}
///////////////////////////


Measured memory_bytes: 1024
let _ = readLine()
let A = readLine()!.characters.split(" ").map{Int(String($0))!}
var dic = [Int : Int]()
for i in A {
    if dic[i] == nil {
        dic[i] = 0
    }
    dic[i]! += 1
}
let a = dic.filter{$0.1>=2}.sort(){$0.0>$1.0}
var ans = 0
if a.count > 0 {
    if a[0].1 >= 4 {
        ans = a[0].0 * a[0].0
    } else if a[1].1 >= 2 {
        ans = a[0].0 * a[1].0
    }
}
print(ans)

Measured memory_bytes: 13764
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author anand.oza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CChristmasEve solver = new CChristmasEve();
        solver.solve(1, in, out);
        out.close();
    }

    static class CChristmasEve {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt(), k = in.nextInt();

            Integer[] h = new Integer[n];
            for (int i = 0; i < n; i++)
                h[i] = in.nextInt();
            Arrays.sort(h);

            int answer = Integer.MAX_VALUE;
            for (int i = 0; i + k - 1 < n; i++) {
                answer = Math.min(answer, Math.abs(h[i] - h[i + k - 1]));
            }

            out.println(answer);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 37716
import java.util.Arrays;
import java.util.Scanner;
class Main{
    public static void main(String[] a){
    Scanner sc = new Scanner(System.in);
    int N=sc.nextInt();
    int[][] t=new int[N][3];
for(int i=0; i<N; i++){
for(int j=0; j<3; j++){
t[i][j]=sc.nextInt();
}
}
sort(t);

for(int i=0; i<N; i++){
if(t[i][2]*t[i][2]==(t[i][1]*t[i][1]+t[i][0]*t[i][0])){
System.out.println("YES");

}else{
System.out.println("NO");

}
}

    }
    public static void sort(int[][] t){
    int [] s=new int[3];
    for(int i=0; i<t.length; i++){
    for(int j=0; j<3; j++){
    s[j]=t[i][j];
    }
      Arrays.sort(s);
      for(int k=0; k<3; k++){
      t[i][k]=s[k];
      }
    }
    }
}

Measured memory_bytes: 34540
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e9+7;
int main(){
    ll n,m,k;cin>>n>>m>>k;
    vector<ll>a(n),b(m);
    ll mi=inf;
    rep(i,n){
        cin>>a[i];
        mi=min(mi,a[i]);
    }
    ll mii=inf;
    rep(i,m){
        cin>>b[i];
        mii=min(mii,b[i]);
    }
    ll ans=mi+mii;
    rep(i,k){
        ll x,y,c;cin>>x>>y>>c;
        x--;y--;
        ans=min(a[x]+b[y]-c,ans);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
///*
#include<iostream>
using namespace std;

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

	if (a - b >= 2) {
		coin = a--;
		coin += a;
	}
	else if (b - a >= 2) {
		coin = b--;
		coin += b;
	}
	else {
		coin += a;
		coin += b;
	}

	cout << coin << endl;
	return 0;

}
//*/

Measured memory_bytes: 256