akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5+5;
const ll INF = 2e9+10;

int a, b;
int main(){
    #ifdef Irene
    freopen("in.txt", "r", stdin);
    #endif // Irene
    ios_base::sync_with_stdio(false);

    map<int, int> mp;
    mp[1] = 300000;
    mp[2] = 200000;
    mp[3] = 100000;
    cin >> a >> b;
    cout << mp[a] + mp[b] + (a==1 && b==1 ? 400000 : 0) << "\n";
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1000000007;

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

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

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

	map<char,int> ans_mp;
	for (int i = 0; i < n; i++) {
		map<char,int> mp;
		string s;
		cin >> s;
		for (auto&& var : s) {
			mp[var]++;
		}
		if (i == 0) {
			ans_mp = mp;
		}
		for (auto&& var : mp) {
			if (ans_mp[var.first] > var.second) {
				ans_mp[var.first] = var.second;
			}
		}
		for (auto&& var : ans_mp) {
			if (var.second > mp[var.first]) {
				var.second = mp[var.first];
			}
		}
	}

	for (auto&& var : ans_mp) {
		for (int i = 0; i < var.second; i++) {
			cout << var.first;
		}
	}

	cout << endl;
	return 0;
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll H, N;
    cin >> H >> N;
    ll sum = 0;
    rep(i, N) {
        ll temp;
        cin >> temp;
        sum += temp;
    }
    if(sum >= H) cout << "Yes";
    else cout << "No";
    cout << endl;
    return 0;
}


Measured memory_bytes: 3640
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<algorithm>
#include<set>
using namespace std;

int extgcd(int a, int b, int &x, int &y) {
	int c = a;
	if (b != 0) {
		c = extgcd(b, a%b, y, x);
		y -= (a / b)*x;
	}
	else {
		x = 1;
		y = 0;
	}
	return c;
}
signed main() {
	int a, b, x, y;
	scanf("%d%d", &a, &b);
	int d = extgcd(a, b, x, y);
	cout << x << " " << y << endl;
}

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

using namespace std;

int a, b;
int main()
{
	cin >> a >> b;
	if(a >= 13)
		cout << b;
	if(a >= 6 && a <= 12)
		cout << b * 0.5;
	if(a < 6)
		cout << "0";
}
 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;

int main() {

    int n, a, b;
    cin >> n >> a >> b;
    
    cout << min(n*a, b) << endl;
    
    return 0;

}

Measured memory_bytes: 256
S = input()
if S.count("R") == 3:
    print("3")
elif S.count("R") == 2:
    if S[1] == S[0]:
        print("2")
    elif S[1] == S[2]:
        print("2")
    else:
        print("1")
elif S.count("R") == 1:
    print("1")
else:
    print("0")

Measured memory_bytes: 9096
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
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; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int sx,sy,tx,ty; cin >> sx >> sy >> tx >> ty;

    int dx=tx-sx,dy=ty-sy;

    //行き
    rep(i,ty-sy) cout<<'U';
    rep(i,tx-sx) cout<<'R';

    //帰り
    rep(i,dy) cout<<'D';
    rep(i,dx) cout<<'L';

    //行き
    cout<<'L';
    rep(i,dy+1) cout<<'U';
    rep(i,dx+1) cout<<'R';
    cout<<'D';

    //帰り
    cout<<'R';
    rep(i,dy+1) cout<<'D';
    rep(i,dx+1) cout<<'L';
    cout<<'U';

    cout<<endl;
    //cout<<"UURDDLLUUURRDRDDDLLU"<<endl;

}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> istream& operator>>(istream& is,vector<T>& v) { for(T& t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream& os,const vector<T>& v) { for(T t:v){os<<t<<" ";} os<<"\n"; return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
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;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

ll dp[60][2];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int n,p;
    cin >> n >> p;
    vi a(n);
    cin >> a;
    dp[0][0] = 1;
    rep2(i,1,n+1) rep(j,2) {
        int now = a[i-1]%2;
        dp[i][j] += dp[i-1][j];
        dp[i][j] += dp[i-1][(j-now+2)%2];
    }
    cout << dp[n][p] << endl;
}


Measured memory_bytes: 256
n = gets.chomp.to_i
travel = []
n.times {
  travel.push( gets.chomp.split(" ").map(&:to_i) )
}

current = [0,0,0]
travel.each {|next_point|
  dt = next_point[0] - current[0]
  dx = next_point[1] - current[1]
  dy = next_point[2] - current[2]
  buffer = dt - (dx + dy)
  if buffer < 0 or buffer % 2 == 1 then
    puts "No"
    exit
  end
  current = next_point
}
puts "Yes"


Measured memory_bytes: 9468
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
#define int long long
using namespace std;

template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}

template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

signed main(){
	int n, x;
	cin >> n >> x;

	vector<int> l(n);
	cin >> l;

	int cur = 0;
	int ans = 0;
	rep(i,n){
		if(cur <= x) ans++;
		cur += l[i];
	}
	if(cur <= x) ans++;

	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define rando mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define fi first
#define se second
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define debugii(x) cerr << " - " << #x << ": " << x.fi<<","<<x.se << endl;
#define sep() cerr << "--------------------" << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ll long long
#define ii pair<int,int>
#define v vector<int>
#define vii vector<ii>
#define vv vector<vector<int> >
#define mp make_pair
#define INF 1000000000
#define pb push_back
#define EPS 1e-9
const int MOD = 1000000007; // 998244353
int main(){
	boost;
	int n;
	cin>>n;
	long double ans=0.0,a;
	for (int i = 0; i < n; ++i)
	{
		cin>>a;
		ans+=(1.0/a);
	}
	cout<<fixed<<setprecision(7)<<1.0/ans;
	return 0;
}
//long long
//array bounds
//special cases
//binary search

Measured memory_bytes: 256
import math
 
def permutations_count(n, r):
    if r == 2:
        return int( (n*(n-1) ) / r )
    if r == 1:
        return n
 
 
N = int(input())
A = list(map(int,input().split()))
 
data = [0] * (N+1)
 
for i in range(N):
    data[A[i]] += 1
 
total = 0
 
for i in range(N+1):
    if data[i] >= 2:
        total += permutations_count(data[i],2)
 
 
 
for i in range(N):
    if data[A[i]] - 1 > 0 :
        print( total - permutations_count(data[A[i]]-1,1) )
    else:
        print(total)



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

using namespace std;

typedef long long ll;

int main() {
    ll n, i, j,k;
    cin >> n;
    ll sum = 1;
    for(i = 2; sum < n;i++){
        sum += i;
    }
    if(sum != n) {
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
        cout << i-- << endl;
        cout << i << " ";
        ll cnt = 1;
        for(j = 1; j <= i; j++) {
            cout << cnt << " ";
            cnt += j;
        }
        cout << endl;
        cout << i << " ";
        cnt = 1;
        for(j = 1; j <= i; j++) {
            cout << cnt << " ";
            cnt += j+1;
        }
        cout << endl;
        cnt = 1;

        for(j = 1; j <= i-1; j++) {
            cnt += j;
            ll now = cnt;
            cout << i << " ";
            for(k = 0; k <= j; k++) {
                cout << now << " ";
                now++;
            }
            now--;
            for(ll h = 0; h < i - 1 - j; h++) {
                now += k;
                cout << now << " ";
                k++;
            }
            cout << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1408
def s()
  gets()
end
def i()
  gets.to_i
end
def li()
  gets.split.map(&:to_i)
end
def ili()
  n = gets.to_i
  as = gets.split.map(&:to_i)
  [n, as]
end

def eratosthenes(size)
  prime_list = []
  is_prime = Array.new(size, true)
  is_prime[0] = false
  is_prime[1] = false

  2.upto(size-1){|i|
    if is_prime[i]
      prime_list << i
      (2).upto((size.to_f/i).ceil-1){|j|
        is_prime[j*i] = false
      }
    end
  }
  [prime_list, is_prime]
end


sum = [0]

pl, is_p =  eratosthenes(100003)

like2017 = []
pl[1..-1].each{|i|
  if is_p[(i+1)/2]
    like2017 << i
  end
}

j=0
100003.times{|i|
  if like2017[j] == i
    sum << sum[i]+1
    j += 1
  else
    sum << sum[i]
  end
}
sum = sum[1..-1]

q = i()
lr = []
q.times{
  lr << li()
}

lr.each{|l, r|
  puts sum[r+1] - sum[l-1]
}


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

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

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

int main() {
    ios::sync_with_stdio(false);
    int n;
    string s;
    vector<int> r, g;
    set<int> bs;

    cin >> n >> s;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'R')
            r.push_back(i);
        else if (s[i] == 'G')
            g.push_back(i);
        else
            bs.insert(i);
    }

    if (r.size() == 0 || g.size() == 0 || bs.size() == 0) {
        cout << 0 << endl;
        return 0;
    }

    ll ans = 0;
    for (int i = 0; i < r.size(); i++) {
        for (int j = 0; j < g.size(); j++) {
            int x = r[i];
            int y = g[j];
            int t;
            if (x > y)
                swap(x, y);

            ans += bs.size();
            if ((x + y) % 2 == 0) {
                t = (x + y) / 2;
                if (t <= n && bs.find(t) != bs.end()) {
                    ans--;
                }
            }
            t = y + (y - x);
            if (bs.find(t) != bs.end()) {
                ans--;
            }
            t = x - (y - x);
            if (t >= 0 && bs.find(t) != bs.end()) {
                ans--;
            }
        }
    }

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


Measured memory_bytes: 3748
s_a = list(input())
s_b = list(input())
s_c = list(input())
c = int(len(s_a)+len(s_b)+len(s_c))

b = 0
for i in range(c):
    #print(b)
    if i == 0:
        b = s_a.pop(0)
        continue
    if b == "a":
        if not s_a:
            ans = "A"
            break
        b = s_a.pop(0)
        continue
    if b == "b":
        if not s_b:
            ans = "B"
            break
        b = s_b.pop(0)
        continue
    elif b == "c":
        if not s_c:
            ans = "C"
            break
        b = s_c.pop(0)
        continue
print(ans)


Measured memory_bytes: 38256
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

h, w = na()
mas = []
li = []
for i in range(h):
    col = input()
    if "#" in col:
        mas.append(col)
for i in range(w):
    for j in range(len(mas)):
        if mas[j][i] == ".":
            if j == len(mas) - 1:
                li.append(i)
            continue
        else:
            break
for i in range(len(mas)):
    ans = ""
    for j in range(w):
        if j not in li:
            ans += mas[i][j]
    print(ans)



Measured memory_bytes: 3064
import sys
input = sys.stdin.readline
ri = lambda: int(input())
#rl = lambda: [int(x) if x.isdecimal() else x for x in input().split()]
#rl = lambda: list(input().split()))
rl = lambda: map(int,input().split())
rr = lambda N: [list(l) for l in zip(*[rl() for _ in range(N)])]
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')
OE = lambda x: print('Odd') if x%2 else print('Even')
INF = 10**18
MOD = 10**9+7

N,K=rl()
S=input().rstrip()
dic = dict({'A':'a','B':'b','C':'c'})
print(S[:K-1]+dic[S[K-1]]+S[K:])

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

#define REP(i, n) for (int i=0;i<(n);i++)
#define FOR(i, a, b) for (int i=(a);i<(b);i++)

using namespace std;

int N;

int main()
{
    scanf("%d", &N);
    bool is_prime[55556];
    vector<int> prime;
    REP(i, 55555)
        is_prime[i] = true;
    is_prime[1] = false;

    FOR(i, 2, 55555) {
        if(is_prime[i]) {
            prime.push_back(i);
            REP(j, 55555/i+1)
                is_prime[i*j] = false;
        }
    }

    vector<int> restricted_prime;
    for (auto it=prime.begin(); it!=prime.end(); it++) {
        if((*it)%5==1)
            restricted_prime.push_back(*it);
    }
    /*
    for (auto it=restricted_prime.begin(); it!=restricted_prime.end(); it++)
        cout << *it << endl;
    */
    REP(i, N)
        printf(i==N-1 ? "%d\n" : "%d ", restricted_prime[i]);

    return 0;
}


Measured memory_bytes: 384
from functools import reduce
def gcd_list(n):
    return reduce(gcd, n)
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

n,x = map(int,input().split())
a = list(map(int, input().split())) + [x]
a.sort()
b = []
for i in range(n):
    b.append(a[i+1]-a[i])
print(gcd_list(b))

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

#define pb push_back
#define ll long long
#define mp make_pair

int main()
{	
	// #ifndef ONLINE__JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// #endif
	std::ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);

	ll n;
	cin >> n;
	ll happ[n][3];
	for(int i = 0; i < n; i++)
		cin >> happ[i][0] >> happ[i][1] >> happ[i][2];
	int current = 0;
	for(int i = 0; i < 3; i++)
	{
		if(happ[0][current] < happ[0][i])
			current = i;
	}
	ll dp[n][3];
	for(int i = 0; i < 3; i++)
		dp[0][i] = happ[0][i];

	for(int i = 1; i < n; i++)
	{
		for(int j = 0; j < 3; j++)
			dp[i][j] = happ[i][j] + max(dp[i - 1][(j + 1)%3], dp[i - 1][(j + 2)%3]);
	}
	cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2]));
}

Measured memory_bytes: 4992
//インクルード(アルファベット順)
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <iterator>      //集合演算(積集合,和集合,差集合など)
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列
using namespace std;
typedef long long ll;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#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 FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
signed main()
{
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    //文字列入力
    string s;
    cin >> s;

    ll ans = 0;
    REP(i, 4)
    {
        if (s[i] == '+')
        {
            ans++;
        }
        else
        {
            ans--;
        }
    }
    cout << ans << endl;

    return 0;
}


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

typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define ALL(obj) (obj).begin(), (obj).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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


int main() {
    cout<<fixed<<setprecision(10);


    ll n,k; cin>>n>>k;
    vint p(n); rep(i,n) cin>>p[i];

    sort(ALL(p));
    ll ans = 0;
    rep(i,k) ans += p[i];
    cout<<ans<<endl;

    return 0;

}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int l;
    double i,j,k,m = 0;
    cin>>l;
    if(l%3==0)
    {
       double nn = (1.0*l)/3.0;

        m = nn*nn*nn;

    }
    else
    {
        double nn = (1.0*l)/3.0;
        double mm = (l*1.0) - (nn*2.0);
        m = nn*nn*mm;

    }

    cout<<fixed<<setprecision(12)<<m<<endl;
    return 0;
}



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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

#define SORT_ASC(c) sort((c).begin(), (c).end())
#define SORT_DESC(c) sort((c).begin(), (c).end(), greater<typeof((c).begin())>())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);

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

void Main()
{
	int n,m;
	cin >> n >> m;
	vector<int> a(m);
	vector<int> b(m);
	vector<int> c_bit(m);

	int n_bit = 0;
	REP(i,n){
		n_bit += 1<<i;
	}


	REP(i,m){
		cin >> a[i] >> b[i];
		c_bit[i] = 0;
		REP(j,b[i]){
			int t;
			cin >> t;
			t--;
			c_bit[i] += 1<<t;
		}
	}

	vector<vector<int>> dp(m);
	REP(i,m){
		dp[i].resize(n_bit+1, 1000000009);
	}
	
	dp[0][0] = 0;
	dp[0][c_bit[0]] = a[0];


	for(int i=1;i<m;i++){
		REP(j,n_bit+1){
			dp[i][j] = dp[i-1][j];
		}
		REP(j,n_bit+1){
			dp[i][j|c_bit[i]] = min(dp[i][j|c_bit[i]] , dp[i-1][j] + a[i]);
		}
	}

	if(dp[m-1][n_bit] == 1000000009){
		cout << -1 << endl;
	}
	else{
		cout << dp[m-1][n_bit] << endl;
	}

	return;
}

int main()
{
	//cin.tie(nullptr);
	//ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

Measured memory_bytes: 16256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.run();
    }
    
    // 変数一覧
    String s;

    public void run() {
        // 入力情報取得
        Scanner sc = new Scanner(System.in);
        s = sc.next();
        sc.close();

        // 解答処理
        solve();
    }
    private void solve() {
        if ((s.substring(2, 3).equals(s.substring(3, 4)))
                && s.substring(4, 5).equals(s.substring(5, 6))) {
                    System.out.println("Yes");
                } else {
                    System.out.println("No");
        }
    }
}

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

int main(void){
	int n, m;
	set<string> st;
	cin >> n;
	string s;
	for(int i = 0; i < n; ++i){
		cin >> s;
		st.insert(s);
	}
	cin >> m;
	bool open = false;
	for(int i = 0; i < m; ++i){
		cin >> s;
		if(st.find(s) == st.end()){
			cout << "Unknown ";
		}else{
			if(open){
				cout << "Closed by ";
			}else{
				cout << "Opened by ";
			}
			open = !open;
		}
		cout << s << endl;
	}
	return 0;
}


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

int main() {
  long long S;
  cin >> S;
  int h;
  h = S/3600;
  int m;
  m = (S-3600*h)/60;
  int s;
  s = S-3600*h-60*m;

  cout << h << ":" << m << ":" << s << endl;
  
}

Measured memory_bytes: 1164
X= int(input())


l = [400, 600, 800, 1000, 1200, 1400, 1600, 1800, 2000]
for i in range(len(l) - 1):
    if X >= l[i] and X < l[i+1]:
        ans = 8 - i
        break
print(ans)

Measured memory_bytes: 61632
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define mod 1000000007LL
#define eps 1e-13
// #define PI 3.141592653589793238L
#define INF 1000000011
#define INFLL 1000000000000000011LL
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define mp make_pair
#define F first
#define S second
#define pb push_back
#define fo(i,a,n) for(i = (a); i < (n); i++)
#define gtl(x) getline(cin, (x))
#define flsh fflush(stdout)
#define sws ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define gcd __gcd
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)((a).size())
#define io_file freopen("D:/Coding Problems/Contest/input_file.in", "r", stdin); freopen("D:/Coding Problems/Contest/output_file.out", "w", stdout)

ll modx(ll Base, ll exponent)
{
	ll ans = 1;
	if(Base == 1)
		return Base;
	while(exponent)
	{
		if(exponent & 1)
			ans = (ans * Base)%mod;
		Base = (Base * Base)%mod;
		exponent = exponent >> 1;
	}
	return ans;
}

ll inmodx(ll num)
{
	return (modx(num, mod-2LL));
}

bool cmp(pair < pii, int > a, pair < pii, int > b)//true for a before b
{
	if(a.F.F/300 < b.F.F/300)
		return 1;
	if(a.F.F/300 > b.F.F/300)
		return 0;
	if(a.F.S < b.F.S)
		return 1;
	if(a.F.S > b.F.S)
		return 0;
	if(a.F <= b.F)
		return 1;
	return 0;
}

const int N = (1e2) + 9;
const int M = (1e4) + 9;
const int LOGN = ((int)log2(N)) + 3;
const int LOGM = ((int)log2(M)) + 3;
const int BUCK = 100;
const int SQRT = BUCK+9;



void solve()
{
	ll a, b, c, d, g, x, y;
	cin >> a >> b >> c >> d;
	if(a < b)
	{
		cout << "No\n";
		return;
	}
	a %= b;
	if(a > c)
	{
		cout << "No\n";
		return;
	}
	if(c > b)
	{
		if(d >= b)
			cout << "Yes\n";
		else
			cout << "No\n";
		return;
	}
	g = gcd(b,d);
	
	x = (c-a) / g;
	y = a + (x+1LL)*g;
	if(y < b)
	{
		cout << "No\n";
		return;
	}

	x = a / g;
	y = a - g*x;

	if(y+d < b)
	{
		cout << "No\n";
		return;
	}

	cout << "Yes\n";
	return;
}

int main()
{
	sws;
	clock_t clk;
	clk = clock();
	// io_file;
	// srand (time(NULL));

	//Code here
	int t = 1, cs;
	cout << fixed << setprecision(9);
	cin >> t;
	fo(cs,1,t+1)
	{
		// cout << "Case #" << cs << ": ";
		solve();
	}
	// Code ends here

	clk = clock() - clk;
	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cstdio>
#define int long long

const int mod = 998244353 ;
const int N = 1e6 + 5 ;

int g[N] ;

inline int quick (int a , int p) {
	int res = 1 ;
	while ( p ) {
		if ( p & 1 ) res = ( res * a ) % mod ;
		a = ( a * a ) % mod ; p >>= 1 ;
	}
	return res ;
}

inline int inv (int x) { return quick ( x , mod - 2 ) ; }

inline int C (int n , int m) {
	if ( ! m || n == m ) return 1 ;
	if ( n < m ) return 0 ;
	return ( g[n] * inv ( g[m] ) % mod * inv ( g[n-m] ) % mod ) % mod ;
}

int n , a , b , k , ans ;

signed main () {
	scanf ("%lld%lld%lld%lld" , & n , & a , & b , & k ) ;
	if ( k == 0 ) { puts ("1") ; return 0 ; }
	g[0] = g[1] = 1 ;
	for (int i = 2 ; i < N - 1 ; ++ i) g[i] = ( g[i-1] * i ) % mod ;
	if ( b != 0 ) {
		for (int i = 0 ; i <= n ; ++ i) {
			int t = k - i * a ; if ( t < 0 || t % b ) continue ;
			ans = ( ans + C ( n , i ) % mod * C ( n , t / b ) % mod ) % mod ;
		}
	} else for (int i = 0 ; i <= n ; ++ i) if ( i * a == k ) ans = ( ans + C ( n , i ) ) % mod ;
	printf ("%lld\n" , ans % mod ) ;
	return 0 ;
}

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

int top,S[1000];

void push(int x){
  S[++top]=x;
}

int pop(){
  top--;
  return S[top+1];
}

int main() {
  int a,b;
  top=0;
  char s[100];
  while(scanf("%s",s)!=EOF){
    if(s[0]=='+'){
      a=pop();
      b=pop();
      push(a+b);
    }else if(s[0]=='-'){
      a=pop();
      b=pop();
      push(b-a);
    }else if(s[0]=='*'){
      a=pop();
      b=pop();
      push(a*b);
    }else{
      push(atoi(s));
    }
  }
  cout<<pop()<<endl;
  return 0;
}



Measured memory_bytes: 3256
#include<iostream>
using namespace std;
int main()
{
    int A,B;
    cin >> A >> B;
    if(A<=9 && B<=9)
    {
        int result = A*B;
        cout << result << endl;
    }
    else
    {
        cout << "-1" << endl;
    }
    return 0;
 
 
}

Measured memory_bytes: 3644
N, K = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
dp = ['Second' for _ in range(K + 1)]
i = 0
for i in range(min(a), K + 1):
  for j in range(N):
    if i - a[j] >= 0:
      if dp[i-a[j]] == 'Second':
        dp[i] = 'First'
print(dp[K])

Measured memory_bytes: 45444
#include <iostream>


int main() {
    using namespace std;

    int D, N;
    cin >> D >> N;

    if(D == 0) {
        cout << N % 100 + 101 * (N / 100) << endl;
    } else if(D == 1) {
        cout << 100 * (N % 100 + 101 * (N / 100)) << endl;
    } else {
        cout << 10000 * (N % 100 + 101 * (N / 100)) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.IO;

namespace SolutionCS
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            long k = long.Parse(Console.ReadLine());

            long lmI = 0;
            char nonOne = '1';
            for (int i = 0; i < s.Length; i++)
            {
                if ( s[i] == '1')
                {
                    lmI++;
                }
                else
                {
                    nonOne = s[i];
                    break;
                }
            }

            if (lmI < k)
            {
                Console.WriteLine("{0}", nonOne);
            }
            else
            {
                Console.WriteLine("1");
            }
        }
    }
}

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

class C
{
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		var b = Console.ReadLine().Split().Select(int.Parse).ToArray();

		Console.WriteLine(b[0] + Enumerable.Range(0, n - 2).Sum(i => Math.Min(b[i], b[i + 1])) + b[n - 2]);
	}
}


Measured memory_bytes: 13396
from math import sqrt

N = int(input())
NS = int(sqrt(N))

ret = len(str(N))
for i in range(1, NS + 1):
    if N % i == 0:
        an, bn = (len(str(i)), len(str(N // i)))
        ret = min(max(an, bn), ret)
print(ret)

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

void print(auto x) {
    cout << x << endl;
}

ll sum(auto x) {
    return accumulate(x.begin(), x.end(), 0LL);
}

int main() {
    int N;
    cin >> N;
    if (N % 2 == 0) cout << 0.5 << endl;
    else cout << (N / 2 + 1) / double(N) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
  
int main(void){
  
    int i;
    int al[26];
    char c;
  
    for(i=0;i<26;i++)al[i]=0;
  
    while(scanf("%c",&c)!=EOF){
  
        if(c>='a'&&c<='z')al[c-'a']++;
        else if(c>='A'&&c<='Z')al[c-'A']++;
  
    }
  
    for(i=0;i<26;i++){
        printf("%c : %d\n",'a'+i,al[i]);
    }
  
    return 0;
  
}

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

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

	if (n == 1 && m == 1)
	{
		cout << 1 << endl; return 0;
	}
	else if (n == 1 && m != 1)
	{
		cout << m - 2 << endl; return 0;
	}
	else if(n != 1 && m == 1)
	{
		cout << n - 2 << endl; return 0;
	}
	cout << (n-2)*(m-2) << endl;
	return (0);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define pa pair<int,int>
const int inf=2147483647;
int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
    return x*f;
}
int sg(int x,int k)
{
	if(x<k)return 0;
	int u=x/k;
	if(u!=(x-1)/k)return u;
	int l=1,r=x/(u+1);
	while(l<=r)
	{
		int mid=l+r>>1;
		int y=x-mid*(u+1);
		if(y/k==u)l=mid+1;
		else r=mid-1;
	}
	l--;l=max(l,1);
	return sg(x-l*(u+1),k);
}
int main()
{
	int ans=0,n=read();
	for(int i=1;i<=n;i++)
	{
		int x=read(),k=read();
		int t=sg(x,k);
//		printf("sg=%d\n",t);
		ans^=sg(x,k);
	}
	if(ans)puts("Takahashi");
	else puts("Aoki");
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	ull H, N;
	cin >> H >> N;

	vector<ull> A(N, 0);
	for (int i = 0; i < N; ++i){
		cin >> A[i];
	}

	int sum = 0;
	for (int i = 0; i < N; ++i){
		sum += A[i];
	}

	if (sum >= H){
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 1024
N,D = map(int,input().split())
X = [[0]*D for i in range(N)]

for i in range(N):
    X[i] = list(map(int,input().split()))

c = 0
for i in range(N):
    for j in range(i+1,N):
        dis = 0
        for k in range(D):
            dis += (X[i][k] - X[j][k])**2
        dis **= 1/2
        if dis.is_integer():
            c += 1
        
print(c)

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

using namespace std;

int N, K;
int MapData[101][101];

const int INF = 1000000000;

void updateShortestDist(const int a, const int b) {
	
	//for (int k = 1; k <= N; ++k) {
		for (int i = 1; i <= N; ++i) {
			for (int j = 1; j <= N; ++j) {
				if (i == j) {
					MapData[i][j] = 0;
				}
				//MapData[i][j] = min(MapData[i][j], MapData[i][k] + MapData[k][j]);
				MapData[i][j] = min(MapData[i][j], MapData[i][a] + MapData[a][j]);
				MapData[i][j] = min(MapData[i][j], MapData[i][b] + MapData[b][j]);
				MapData[j][i] = MapData[i][j];
			}
		}
	//}
}

int main() {
	int type, c, d, e;
	
	while (cin >> N >> K, N) {
		fill_n(&MapData[0][0], 101 * 101, INF);
		for (int i = 0; i < K; ++i) {
			cin >> type;
			if (type == 1) {
				cin >> c >> d >> e;
				if (e < MapData[c][d]) {
					MapData[c][d] = e;
					MapData[d][c] = e;
					updateShortestDist(c, d);
				}
				continue;
			}
			cin >> c >> d;
			e = MapData[c][d];
			cout << (e == INF ? -1 : e) << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 3116
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i,n){
        cin >> a[i];
    }
    rep(i,n-k){
        if(a[i+k]>a[i]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }


    return 0;
}

Measured memory_bytes: 3988
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scanner = new Scanner(System.in);
        Integer inputNum = Integer.parseInt(scanner.nextLine());
        String output = "Yes";

        List<TimeAndXY> list = new ArrayList<>();
        list.add(new TimeAndXY(0,0,0));

        for(int i=0; i<inputNum; i++){
            final TimeAndXY nextState = new TimeAndXY(scanner.nextLine());
            list.add(nextState);

        }
        scanner.close();
        for(int i=0; i<inputNum; i++){
            TimeAndXY lastState = list.get(i);
            TimeAndXY nextState = list.get(i+1);
            if( nextState.canMoveFrom(lastState) ){
                lastState = nextState;
            }
            else{
                output = "No";
                break;
            }
        }
        System.out.println(output);
    }

    public static class TimeAndXY {
        private final int time;
        private final int x;
        private final int y;
        public TimeAndXY(String input){
            String[] inputs = input.split(" ");
            this.time = Integer.parseInt(inputs[0]);
            this.x = Integer.parseInt(inputs[1]);
            this.y = Integer.parseInt(inputs[2]);
        }
        @Override
        public String toString(){
            return "t="+time+", x="+x+", y="+y;
        }


        public TimeAndXY(int time, int x, int y){
            this.time = time;
            this.x = x;
            this.y = y;
        }
        public boolean canMoveFrom(TimeAndXY moveFrom){
            int xmove = this.x - moveFrom.x;
            int ymove = this.y - moveFrom.y;
            int duration = this.time - moveFrom.time;
            int xymove = Math.abs(xmove) + Math.abs(ymove);
            if( xymove<=duration ){
                if(xymove%2==duration%2){
                    return true;
                }
            }
            return false;
        }
    }
}


Measured memory_bytes: 120804
#include<iostream>
#include<string>
#include<vector>
#include <map>
#include <cmath>
#define reps(i,n, m) for(int i=int(n); i<int(m);i++)
#define rep(i,n) reps(i,0,n)
using namespace std;
typedef pair<int, int> P;
const int inf = 500000000;
int sx, sy, gx, gy;
int h, w;
vector<string> vec;
vector<P> mp[5];
vector<int> val[5];
int dp[5][5][1010];
int dist(int x1, int y1, int x2, int y2) {
	return abs(x1-x2) + abs(y1-y2);
}
int main() {
	while(cin>>w>>h && h+w) {
		vec.clear();
		rep(i,5) {
			mp[i].clear();
			val[i].clear();
		}
		rep(i,5){
			rep(j,5){
				rep(k,1010)dp[i][j][k] =inf;
			}
		}
		rep(i, h){
			string temp;
			cin>>temp;
			vec.push_back(temp);
			rep(j,w){
				switch(vec[i][j]) {
				case 'S':
					sx = i; sy = j;
					break;
				case 'G':
					gx = i; gy = j;
					break;
				case '.':
					break;
				default:
					int num = (int) (vec[i][j] -'1');
					mp[num].push_back(P(i, j));
					break;
				}
			}
		}
		int ansCol = 0;
		int ansDist = inf;
		rep(rest, 4) {
			for (int col = 0; col<5;col++) {
				rep(i, mp[col].size()){
					if (rest == 0) {
						dp[rest][col][i] = dist(gx, gy, mp[col][i].first, mp[col][i].second);
					} else { //rest<4
						rep(j, mp[(col+1)%5].size()){
							int x1 = mp[col][i].first;
							int y1 = mp[col][i].second;
							int x2 = mp[(col+1)%5][j].first;
							int y2 = mp[(col+1)%5][j].second;
							int d = dist(x1, y1, x2, y2);
							dp[rest][col][i] = min(dp[rest][col][i], dp[rest-1][(col+1)%5][j]+d);
						}
					}
				}
			}
		}
		rep(col, 5) {
			int d = inf;
			int nc = (col+1)%5;
			rep(i, mp[nc].size()) {
				int ds = dist(sx, sy, mp[nc][i].first, mp[nc][i].second);
				d = min(d, dp[3][nc][i]+ds);
			}
			if (d <ansDist){
				ansDist = d;
				ansCol = col;
			}
		}
		if (ansDist == inf) {
			cout<<"NA"<<endl;
		} else {
			cout <<ansCol+1<<" "<<ansDist<<endl;
		}
	}
}

Measured memory_bytes: 2212
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
typedef unsigned long long ll;
typedef pair<ll,ll> P;

vector<P> D(ll n) {
  vector<P> v;
  for(ll i=2; i*i<=n; i++) {
    P p=P(0,i);
    while(n%i==0) {
      n/=i;
      p.F++;
    }
    if(p.F) v.push_back(p);
  }
  if(n>1) v.push_back(P(1,n));
  return v;
}

ll N(char c) {
  if(isdigit(c)) return c-'0';
  return (c-'A')+10;
}

ll C(string s,ll n) {
  ll x=0,y=1;
  for(int i=s.size()-1; i>=0; i--) {
    x+=N(s[i])*y;
    y*=n;
  }
  return x;
}

int main() {
  ll n;
  string s;
  while(cin >> n >> s && n) {
    vector<P> v=D(n);
    ll m=C(s,n);
    ll ans=1uLL<<63;
    for(int i=0; i<v.size(); i++) {
      P p=v[i];
      ll z=0,x=p.S;
      while(1) {
        z+=m/x;
        if(x*p.S>m||x*p.S/p.S!=x) break;
        x*=p.S;
      }
      ans=min(ans,z/p.F);
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3224
#include<iostream>
#include<cstdio>
#include<vector>
#include<cmath>

using namespace std;

int main(int argc, char* argv[])
{
  vector<double> scores;
  double average,distance,number,value;
  while(1)
    {
    average=0;
    distance=0;
    cin >> number;
    if(number==0) break;
    for(int i=0;i<number;i++)
    {
      cin >> value;
      average+=value/number;
      scores.push_back(value);
    }
    for(auto s:scores)
    {
      distance+=pow(s-average,2.0);
    }
    printf("%.8lf\n",sqrt(distance/number));
    scores.clear();
  }
}

Measured memory_bytes: 3244
#include <bits/stdc++.h>
using namespace std;
int main(){
	double a;
	long long b;
	cin>>a>>b;
	double sum=0.0;
	for(int i=1;i<=a;i++){
		double s=1,d=i;
		while(d<b){
			d*=2;
			s*=2;
		}
		double z=1.0/a;
		double v=1.0/s;
		//cout<<s<<endl;
		sum+=z*v;
	}
	cout<<fixed<<setprecision(12)<<sum<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int (i) = 0, i_len = n; (i) < (i_len); ++(i))
#define repp(i,n) for(int (i) = 1, i_len = n; (i) <= (i_len); ++(i))
#define per(i,n) for(int (i) = n-1; (i) >= 0; --(i))
#define perr(i,n) for(int (i) = n; (i) > 0; --(i))
#define sz(x) ((int)(x).size())
#define popcnt __builtin_popcount
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).begin(),(v).end(),greater<>()
#define debug(x) cerr << #x << ':' << x << '\n'
#define Pi 3.1415926535
#define MOD 1000000007
using namespace std;
using ll = long long;
using pint = pair<int,int>;
using itn = int;
using vint = vector<int>;
template<class T,class S> inline bool chmax(T& a, S b){if(a<b){a = b; return true;} return false;}
template<class T,class S> inline bool chmin(T& a, S b){if(a>b){a = b; return true;} return false;}
template<class T> T gcd(T a, T b){return b?gcd(b,a%b):a;}
template<class T> T lcm(T a, T b){return a*b/gcd(a,b);}
void yes(){cout << "Yes" << '\n';}
void no(){cout << "No" << '\n';}

int solve(){
    int n; cin >> n;
    int i = n%10;
    if(i == 2 or i == 4 or i == 5 or i == 7 or i == 9){
        cout << "hon" << endl;
    }
    else if(i == 0 or i == 1 or i == 6 or i == 8){
        cout << "pon" << endl;
    }
    else cout << "bon" << endl;

    return 0;
}

int main(){
    cin.tie(0);
    cout << fixed << setprecision(10);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}


Measured memory_bytes: 3656
#include <iostream>
using namespace std;
int main(void){
    int n,i;
    cin >> n;
    int A[n];
    for(i=0;i<n;i++){
        cin >> A[i];
    }

    int iCount=0;
    int j,minj;
    int swap;
    for(i=0;i<n;i++){
        minj=i;
        for (j=i;j<n;j++){
            if (A[j]<A[minj]){
                minj=j;
            }
        }
            if (minj!=i){
                swap=A[i];
                A[i]=A[minj];
                A[minj]=swap;
                iCount+=1;
            }
        
    }
    
    for(i=0;i<n;i++){
        if (i!=0){
            cout << ' ';
        }
        cout << A[i];
    }
    cout << endl;
    cout << iCount <<endl;
}


Measured memory_bytes: 3104
from math import ceil
inpl = lambda: list(map(int,input().split()))
A, B = inpl()
Amin = int(ceil(A * (100/8)))
Amax = int((A+1)*(100/8) - 0.1)
Bmin = int(ceil(B * (100/10)))
Bmax = int((B+1)*(100/10) - 0.1)
Tmax = min(Amax,Bmax)
Tmin = max(Amin,Bmin)
if Tmax < Tmin:
    print(-1)
else:
    print(Tmin)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define bug1( x ) {cerr << (#x) <<"="<< x << endl;}
#define bug2( x , y ) {cerr << (#x) <<"="<< (x) << "    " << (#y) << "="<< (y) << endl;}
#define bug3( x , y , z ) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << endl;}
#define bug4( x , y , z , w) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << endl;}
#define bug5( x , y , z , w ,p) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << "    " << (#p) <<"="<< p << endl;}
#define bug6( x , y , z , w ,p , q) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << "    " << (#p) <<"="<< p << "    " << (#q) <<"="<< q << endl;}
#define bugn( x , n ) {cerr << (#x) <<":";for(int i=0;i<n;i++)cerr << x[i] <<"  "; cerr << endl;}
#define bugnm( x , n , m ) {cerr << (#x)<<endl;for(int i=0;i<n;i++){cerr << "Row #" << i<< ":";for(int j=0;j<m;j++)cerr << x[i][j] << "   ";cerr << endl;}}
typedef long long ll;
typedef long double ld;
using namespace std;

const int maxn = 2e5+10;
vector<int>g[maxn],a(maxn);
int n,q;
int32_t main(){
	IOS
	cin >> n >> q;
	for(int i = 1; i < n; i++ ){
		int u, v; cin >> u >> v;
		g[ u ].push_back( v );
		g[ v ].push_back( u );
	}
	for(int i=1;i<=q;i++){
		int u, x; cin >> u >> x;
		a[ u ] += x;
	}
	function<void(int,int)> dfs = [&](int u,int p){
		for(auto v:g[u]){
			if( v != p ){
				a[v]+=a[u];
				dfs(v,u);
			}
		}
	};
	dfs( 1 , 0 );
	for(int i = 1; i <= n; i++ ){
		cout << a[i] << endl;
	}

}
/*
 * long long or int?
 * index out of bound? 
 * Tested on own test case?corner?
 * Make more general solution.
 * Read Read Read Read ....
 */


Measured memory_bytes: 37492
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

int main() {
	int N, M;
	cin >> N >> M;
	vector<vector<int>> G(N);
	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}

	vector<int> guide(N);
	guide[0] = 0;
	vector<int> dist(N, -1);
	queue<int> q;
	dist[0] = 0;
	q.push(0);

	while (!q.empty()) {
		int v = q.front();
		q.pop();
		for (int nv : G[v]) {
			if (dist[nv] != -1) continue;
			dist[nv] = dist[v] + 1;
			guide[nv] = v;
			q.push(nv);
		}
	}

	cout << "Yes" << endl;
	for (int i = 1; i < N; i++) {
		cout << guide[i] + 1 << endl;
	}

	return 0;
}


Measured memory_bytes: 10564
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var n=input.trim()-0;
var i=0;
while(true){
   var a=(n-i)+"";
   var A=a.split("").reverse().join("");
   if(a==A)return console.log(a);
   var a=(n+i)+"";
   var A=a.split("").reverse().join("");
   if(a==A)return console.log(a);
   i++;
}

Measured memory_bytes: 7648
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
char c[5];
int main(){
	cin>>c;
	int len=strlen(c);
	for(int i=0;i<len;i++) if(c[i]=='7'){printf("Yes");return 0;}
	printf("No");
	return 0;
}

Measured memory_bytes: 3144