akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
#include <time.h>
#pragma warning(disable:4996) 

typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define LINF3 1000000000000
#define INF 2140000000
//const long long MOD = 1000000007;
const long long MOD = 998244353;

using namespace std;

string strs[4] = { "AC", "WA", "TLE", "RE" };
char str[5];
void solve()
{
    int n;
    scanf("%d", &n);
    int cnt[4] = { 0 };
    int i,k;
    for (i = 0; i < n; i++) {
        scanf("%s", str);
        for (k = 0; k < 4; k++) {
            if (string(str) == strs[k]) {
                break;
            }
        }
        assert(k < 4);
        cnt[k]++;
    }

    for (k = 0; k < 4; k++) {
        printf("%s x %d\n", strs[k].c_str(), cnt[k]);
    }


    return;
}


int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        //printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}


Measured memory_bytes: 3224
#include <iostream>
#include <iterator>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;
int main(void)
{
    
    int N;
    string S;
    vector<string> v;
    vector<string> ans_v;
    int k =0;
    int count = 0;

    cin >> N;

    for ( int i =0; i < N; i++) {
        cin >> S;
        v.push_back(S);
    } 

    sort(v.begin(),v.end());
    /*
    for ( int i =0; i < N; i++) {
        cout << v[i] << " ";
    } 
    */

    while(k < N){
        int now_count = 0;
        //文字列が一致し続ける限り続ける
        while(v[k].compare(v[k+1]) == 0 ){
            now_count++;
            k++;
        }

        //もし登場回数が過去最大なら
        if(now_count > count){
            ans_v.clear();
            count = now_count;
            ans_v.push_back(v[k]);
        }else if(now_count == count){
            ans_v.push_back(v[k]);
        }
        k++;
    }

    decltype(ans_v)::iterator ite = ans_v.begin();

    //std::cout <<std::endl;

    for ( ; ite != ans_v.end(); ++ite) {
        cout << *ite << endl;
    } 

    return 0;
}


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

int main(){
  string S;
  string x = "es";
  cin >> S;
  if (S[S.size()-1] == 's'){
    S += x;
    cout << S << endl;
  }
  else{
    S += 's';
    cout << S << endl;
  }
  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
 
using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;

int main(void) {
    Int n, i;
    cin >> n >> i;
    cout << n - i + 1 << endl;
    return 0;
}



Measured memory_bytes: 3560
import java.io.IOException;
import java.util.Scanner;

public class Main {
	static int time = 0;

	public static void main(String[] args) throws IOException {

		Scanner scan = new Scanner(System.in);
		// Scanner scan = new Scanner(new
		// File("D:\\UserArea\\J0124567\\Downloads\\ALDS1_6_A-in9.txt"));

		int n = scan.nextInt();
		Sns sns = new Sns(n);

		int m = scan.nextInt();
		for (int i = 0; i < m; i++)
			sns.addRel(scan.nextInt(), scan.nextInt());

		int q = scan.nextInt();
		for (int i = 0; i < q; i++)
			if (sns.isFriends(scan.nextInt(), scan.nextInt()))
				System.out.println("yes");
			else
				System.out.println("no");

		scan.close();
		System.exit(0);
	}
}

class Sns {

	int[] leader;
	int[] member;

	public Sns(int n) {
		leader = new int[n];
		member = new int[n];
		for (int i = 0; i < n; i++) {
			leader[i] = i;
			member[i] = 1;
		}
	}

	public boolean isFriends(int s, int t) {
		if (top(s) == top(t))
			return true;
		else
			return false;
	}

	private int top(int s) {
		if (leader[s] == s)
			return s;
		else
			return top(leader[s]);
	}

	public void addRel(int s, int t) {
		if (isFriends(s, t))
			return;
		int tt = top(t);
		int st = top(s);
		if (member[st] < member[tt]) {
			leader[st] = tt;
			member[tt] += member[st];
		} else {
			leader[tt] = st;
			member[st] += member[tt];
		}
	}

}

Measured memory_bytes: 104600
N, X, Y = map(int, input().split())
S = [list(reversed(list(range(1, i+1)))) + list(range(N-i)) for i in range(N)]

S[X-1][Y-1] = 1
S[Y-1][X-1] = 1

for i in range(N):
    for j in range(N):
        x, y = X-1, Y-1
        S[i][j] = min(S[i][j], S[i][x]+1+S[y][j])

#print(S)

dist = [0]*N

from itertools import (
    accumulate,  # 累積和のイテレータ
    groupby,  # 値をkey,同じ値の集まりをgroup
    permutations,  # 順列
    combinations,  # 組み合わせ
    product,  # 重複あり順列（直積, 深いネストにも使える）
)

for i, j in combinations(list(range(N)), 2):
    d = S[i][j]
    dist[d] += 1

#print(dist)

for i in range(1, len(dist)):
    print(dist[i])


Measured memory_bytes: 81944
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<iterator>
#include<unordered_map>
#include<algorithm>
#include<cmath>
#include<climits>
#include<deque>
using namespace std;
using ll = long long int;
ll x[4] = { 0,0,1,-1 };
ll y[4] = { -1,1,0,0 };

bool isValid(ll x, ll y, ll a, ll b, vector<vector<char>>& v) {
    //return x >= 0 && y >= 0 && x < a && y < b && v[x][y] == '.';
    if (x >= 0 && x < a && y >= 0 && y < b && v[x][y] == '.')
        return 1;
    else
        return 0;
}

int main() {
    ll h, w;
    cin >> h >> w;
    ll sx, sy, dx, dy;
    cin >> sx >> sy >> dx >> dy;
    sx--; sy--; dx--; dy--;
    vector<vector<char>> v(h, vector<char>(w));
    vector<vector<ll>> vis(h, vector<ll>(w, 1e6));
    for (ll i = 0; i < h; ++i) {
        for (ll j = 0; j < w; ++j) {
            cin >> v[i][j];
        }
    }
    deque<pair<ll, ll>> dq;
    dq.push_front({ sx,sy });
    vis[sx][sy] = 0;

    while (!dq.empty()) {
        pair<ll, ll> pr = dq.front();
        dq.pop_front();
        for (ll i = 0; i < 4; ++i) {
            if (isValid(pr.first + x[i], pr.second + y[i], h, w, v)) {
                if (vis[pr.first + x[i]][pr.second + y[i]] > vis[pr.first][pr.second]) {
                    vis[pr.first + x[i]][pr.second + y[i]] = vis[pr.first][pr.second];
                    dq.push_front({ pr.first + x[i] , pr.second + y[i] });
                }
            }
        }
        /*for (ll i = -1; i <= 1; i++)
        {
            for (ll j = -1; j <= 1; j++)
            {
                if (abs(i + j) == 1 && isValid(pr.first + i, pr.second + j,h,w,v))
                {
                    if (vis[pr.first + i][pr.second + j] > vis[pr.first][pr.second])
                    {
                        vis[pr.first + i][pr.second + j] = vis[pr.first][pr.second];
                        dq.push_front({ pr.first + i , pr.second + j });
                    }
                }
            }
        }*/
        for (ll i = -2; i <= 2; ++i) {
            for (ll j = -2; j <= 2; ++j) {
                if (isValid(pr.first + i, pr.second + j, h, w, v)) {
                    if (vis[pr.first + i][pr.second + j] > vis[pr.first][pr.second] + 1) {
                        vis[pr.first + i][pr.second + j] = vis[pr.first][pr.second] + 1;
                        dq.push_back({ pr.first + i , pr.second + j });
                    }
                }
            }
        }
        
    }

    if (vis[dx][dy] == 1e6) {
        cout << "-1" << endl;
    }
    else {
        cout << vis[dx][dy] << endl;
    }
    return 0;
}

Measured memory_bytes: 12500
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

using ll = long long;

#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--)

#define input(...) __VA_ARGS__; in(__VA_ARGS__)

template<class T>
void print(vector<T> a) {
  cout << "[ ";
  REP(i, a.size()) cout << a[i] << " ";
  cout << "]" << endl;
}

void print() {
  std::cout << std::endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cout << head << " ";
  print(std::forward<Tail>(tail)...);
}

void in() { }

template <class Head, class... Tail>
void in(Head&& head, Tail&&... tail) {
  cin >> head;
  in(std::forward<Tail>(tail)...);
}

int main() {
  ll input(n);
  vector<ll> s(n);
  REP(i, n) cin >> s[i];
  sort(s.begin(), s.end());

  ll input(q);
  ll ans = 0;
  REP(i, q) {
    ll input(t);
    auto it = lower_bound(s.begin(), s.end(), t);
    if (distance(s.begin(), it) != n) {
      if (*it == t) ans++;
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 3556
#include <bits/stdc++.h>
#define IOS                                                                    \
  ios::sync_with_stdio(0);                                                     \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<ll, ll>;
const int INF = 0x3f3f3f3f;
ll bpow(ll b, ll p, ll m) {
  ll rt = 1;
  for (; p; p >>= 1, b = b * b % m)
    if (p & 1)
      rt = rt * b % m;
  return rt;
}
int main() {
  IOS;
  string s, t;
  cin >> s >> t;
  int ans = 0;
  for (int i = 0; i < s.length(); i++)
    ans += (s[i] != t[i]);
  cout << ans << endl;
}

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

using namespace std;

int main(){
  int n;
  cin >> n;
  string ans="No";
  for(int i=1;i<=9;i++){
    for(int j=1;j<=9;j++){
      if(i*j==n){
        ans="Yes";
      }
    }
  }
  cout << ans << endl;
}


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

using namespace std;

int main() {
    int n;
    cin >> n;
    bool flag = false;
    for(int i = 0; i <= n/4; i++) {
        for(int j = 0; j <= n/7; j++) {
            if(n == 4*i + 7*j) {
                flag = true;
            }
        }
    }
    if(flag == true) {
        cout << "Yes";
    }else {
        cout << "No";
    }
    return 0;
}


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

int main() {
    int D, N, n;
    cin >> D >> N;
    D = pow(100,D);
    n = N;
    while(n % 10 == 0) {
        n /= 10;
        N = N + (n / 10);
    }
    cout << N * D << endl;
}


Measured memory_bytes: 508
#include <bits/stdc++.h>
#pragma GCC optimize "Ofast,omit-frame-pointer,inline"
using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VP vector<pair<int,int>>
#define VPP vector<pair<int,pair<int,int>>>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)
typedef pair <int, int> P;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int  INF = (1 << 30) - 1;
const ll INFL = 1LL << 60;
const ll mod = 998244353;



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

	map<ll, ll> m;

	ll sum = 0;

	REP(i, n) {
		ll a;
		cin >> a;
		m[a]++;
		sum += a;
	}

	int q;
	cin >> q;

	REP(qi, q) {
		ll a, b;
		cin >> a >> b;
		ll tmp = m[a];
		sum -= tmp * a;
		sum += tmp * b;
		m[b] += tmp;
		m[a] = 0;
		//cerr << "=====";

		cout << sum << endl;

	}



}

Measured memory_bytes: 9440
#include <iostream>
#include <vector>
#include <cstring>
#include <cctype>
#include <string>
using namespace std;

int main(){
	string st;
	int sum;
	while (1){
		sum = 0;
		cin >> st;
		if (st == "0")
			break;
		for (int i = 0;i<st.length(); i++){
			sum += st[i] - '0';
		}
		cout << sum << endl;
	}

	return 0;
}

Measured memory_bytes: 1192
//
//  Disjoint Set of Common Divisors.cpp
//  National Olympiad in Informatics in Provinces
//
//  Created by 黄子齐 on 2019/9/28.
//  Copyright © 2019 黄子齐. All rights reserved.
//

#include <stdio.h>
#define ll long long
ll a, b;
ll gcd(ll x, ll y) {
    if (!y) return x;
    return gcd(y, x%y);
}
int main() {
//    freopen("mytestdata.in", "r", stdin);
    scanf("%lld%lld", &a, &b);
//    printf("%lld\n", gcd(a, b));
    ll x = gcd(a, b);
    ll sum=0;
    for (ll i=2; i*i<=x; i++) {
        if (!(x%i)) {
            sum++;
            while (!(x%i)) {
                x /= i;
            }
        }
    }
    if (x > 1) {
        sum ++;
    }
    printf("%lld\n", sum+1);
    return 0;
}


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

int main(){
  string day[7]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
  string S; cin >> S;
  int i=-1,j=0;
  while(i<0){
    if(day[j]==S) i=j;
    j++;
  }
  cout << 7-i << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
#define mk make_pair

using namespace std;

const int N = 1e5 + 5;

int h[N], dp[N];

int32_t main()
{
    ios::sync_with_stdio(false);
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    int n;
    cin >> n;
    for(int i = 0;i < n; ++i)
    {
        cin >> h[i];
    }
    dp[0] = 0;
    for(int i = 1;i < n; ++i)
    {
        int x = abs(h[i] - h[i-1]);
        int y = 1e9;
        if(i != 1)
            y = abs(h[i] - h[i-2]);
        if(i == 1)
            dp[i] = dp[i-1] + x;
        else
            dp[i] = min(dp[i-1] + x, dp[i-2] + y);
    }
    cout << dp[n-1];
}

Measured memory_bytes: 1152
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<int(n); i++)
#define all(c) (c).begin(), (c).end()
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int H, W;
char S[8][8];
bool V[8][8];
int DX[4] = {-1, 0, 1, 0};
int DY[4] = {0, -1, 0, 1};

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> H >> W;
  int c = 0;
  rep(y, H) {
    rep(x, W) {
      cin >> S[x][y];
      if (S[x][y] == '#') c++;
    }
  }
  if (c != W+H-1) {
    cout << "Impossible\n";
  }
  else {
    queue<P> q;
    q.push(P(0, 0));
    V[0][0] = true;
    while (!q.empty()) {
      int x = q.front().first,
          y = q.front().second; q.pop();
      rep(k, 4) {
        int nx = x+DX[k], ny = y+DY[k];
        if (nx<0 || nx>=W || ny<0 || ny>=H) continue;
        if (V[nx][ny]) continue;
        q.push(P(nx, ny));
        V[nx][ny] = true;
      }
    }
    if (V[W-1][H-1]) {
      cout << "Possible\n";
    }
    else {
      cout << "Impossible\n";
    }

  }
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
	EACH(x,vec) is >> x;
	return is;
}
/*
template<class... T>
ostream& operator<<(ostream& os, tuple<T...>& t) {
	for (size_t i = 0; i < tuple_size< tuple<T...> >::value; ++i) {
		if (i) os << " ";
		os << get<0>(t);
	}
	return os;
}
*/
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
	REP(i,vec.size()) {
		if (i) os << " ";
		os << vec[i];
	}
	return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
	REP(i,vec.size()) {
		if (i) os << endl;
		os << vec[i];
	}
	return os;
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int N, M;
	while ( cin >> N >> M, N || M ) {
		vector< tuple<int, int, int> > v;
		REP(i, M) {
			int t, from, to; cin >> t >> from >> to; --from, --to;
			v.emplace_back(t, from, to);
		}
		sort( ALL(v) );
		vector<bool> isInfected(N, false); isInfected[0] = true;
		REP(i, M) {
			int t, from, to; tie(t, from, to) = v[i];
			if (isInfected[from]) isInfected[to] = true;
		}
		int ans = 0;
		REP(i, N) {
			ans += isInfected[i];
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 3468
N, K = map(int, input().split())
Alist = list(map(int, input().split()))

cnt = 0
for i in range(N):
    if Alist[i]==1:
        cnt = i+1
        break

if K==2:
    print(N-1)
else:
    n = (N-1) // (K-1) + int((N-1)%(K-1)!=0)
    print(n)

Measured memory_bytes: 52780
import sys
#import numpy as np

stdin = sys.stdin

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split())) # applies to numbers only
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N = ri()
A = [ri() for _ in range(N)]
x_to_i = {x:i for i, x in enumerate(sorted(A))}
rank = [x_to_i[x] for x in A]
answer = sum((i^x)&1 for i,x in enumerate(rank)) // 2
print(answer)


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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    int N; cin >> N;
    for(int i = 0; i <= N / 4; i++)
    {
        if((N - 4*i) % 7 == 0)
        {
            cout << "Yes" << endl;
            return;
        }
    }
    cout << "No" << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

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

void chmin(long &a, long b) {
  if (a > b) a = b;
}

int main() {
  const long long INF = 1LL << 60;
  int n;
  cin >> n;
  vector<long> h(n);
  for (int i = 0; i < n; i++) cin >> h[i];

  vector<long> dp(n, INF);
  dp[0] = 0;

  for(int i = 1; i < n; i++) {
    chmin(dp[i], dp[i-1] + abs(h[i-1] - h[i]));
    if (i > 1) chmin(dp[i], dp[i-2] + abs(h[i-2] - h[i]));    
  }

  cout << dp[n-1] << endl;
}


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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

int main() {
  ll a, b, q;
  cin >> a >> b >> q;
  vector<ll> s(a), t(b), x(q);
  for (int i = 0; i < a; i++) cin >> s[i];
  for (int i = 0; i < b; i++) cin >> t[i];
  for (int i = 0; i < q; i++) cin >> x[i];
  s.push_back(0);  // 番兵
  s.push_back(INFL);
  t.push_back(0);
  t.push_back(INFL);
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  for (int i = 0; i < q; i++) {
    ll ls = *--lower_bound(s.begin(), s.end(), x[i]);
    ll lt = *--lower_bound(t.begin(), t.end(), x[i]);
    ll rs = *upper_bound(s.begin(), s.end(), x[i]);
    ll rt = *upper_bound(t.begin(), t.end(), x[i]);
    ll res = INFL;
    if (ls != 0 && lt != 0)  // ずっと左へ
      res = min(res, x[i] - min(ls, lt));
    if (ls != 0 && rt != INFL)  // 左の神社、右の寺
      res = min(res, rt - ls + min(rt - x[i], x[i] - ls));
    if (rs != INFL && lt != 0)  // 右の神社、左の寺
      res = min(res, rs - lt + min(rs - x[i], x[i] - lt));
    if (rs != INFL && rt != INFL)  // ずっと右へ
      res = min(res, max(rs, rt) - x[i]);
    cout << res << endl;
  }
}


Measured memory_bytes: 3680
a = int(input())
b = int(input())
c = int(input())
X = int(input())
cnt = 0

for i in range(a+1):
    for j in range(b+1):
        rem = X - 500*i - 100*j
        if rem < 0: continue
        if rem%50 == 0 and 50*(rem//50) == rem and rem//50 <= c:
            cnt += 1

print(cnt)

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

using namespace std;

#define REP(i, N) for (int i = 0; i < (int)N; i++)
#define RREP(i, N) for (int i =(int)N-1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define INF (1 << 30)
#define LLINF (1LL << 62)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

typedef long long ll;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;


int main(){
  int a,b;
  cin>>a>>b;
  int sum=a;
  int ans=1;
  if(b==1){
    cout<<0<<endl;
    return 0;
  }
  while(sum<b){
    sum+=a-1;
    ans++;
  }
  cout<<ans<<endl;
}


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

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define sc(a) scanf("%d", &a)
#define sc2(a,b) scanf("%d%d", &a, &b)
#define sc3(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define pri(x) printf("%d\n", x)
#define mp make_pair
#define pb push_back
#define BUFF ios::sync_with_stdio(false);
#define imprime(v) for(int X=0;X<v.size();X++) printf("%d ", v[X]); printf("\n");
#define endl "\n"
const int INF= 0x3f3f3f3f;
const long double pi= acos(-1);
typedef long long int ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector< vector< int > > vvi;
const int MOD=1e9+7;
const ll LINF=0x3f3f3f3f3f3f3f3f;

int main() {
  int n, a, b;
  sc3(n, a, b);
  if((b - a) % 2 == 1) puts("Borys");
  else puts ("Alice");
  return 0;
}

Measured memory_bytes: 256
import sys 
a,b,c,k = map(int,input().split())
max=0
if(a==k):
    print(a)
elif(a>k):
    print(k)
else:
    if(a<k):
        max+=a
        k=k-a
    if(b>k):
        print(max)
    else:
        k=k-b
        if(k<=0):
            print(max)
        else:
            if(c>=k):
                max-=k
                print(max)
            elif(c<k):
                max-=c
                print(max)




Measured memory_bytes: 9160
#include<bits/stdc++.h>
using namespace std;
namespace mine
{
    typedef long long ll;
    #define pr pair<int,int>
    #define FR first
    #define SE second
    #define MP make_pair
    #define PB push_back
    #define vc vector
    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())
    #define bin(x) (1ll<<(x))
    #define GG(x) if(x) puts("error")
    ll qread()
    {
        ll ans=0,f=1;char c=getchar();
        while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
        while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
        return ans*f;
    }
    void write(ll num)
    {
        if(num<0) putchar('-'),num=-num;
        if(num>=10) write(num/10);
        putchar('0'+num%10);
    }
    void write1(ll num){write(num);putchar(' ');}
    void write2(ll num){write(num);putchar('\n');}
    template<typename T> void chmax(T &x,const T y) {x=(x>y?x:y);}
    template<typename T> void chmin(T &x,const T y) {x=(x<y?x:y);}
    ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

    const int INF=0x3f3f3f3f;
    const int MOD=1e9+7;
    inline int mm(const int x){return x>=MOD?x-MOD:x;}
    template<typename T> inline void add(T &x,const T y){x=mm(x+y);}
    inline ll qpower(ll x,ll e)
    {
        ll ans=1;GG(e<0);
        while(e){if(e&1)ans=ans*x%MOD;x=x*x%MOD;e>>=1;}return ans;
    }
    ll invm(ll x){return qpower(x,MOD-2);}
    const int N=2e3+10;

    int C[N][N],pp[N][N],solve1[N][N];
    void main()
    {
        C[0][0]=1;for(int i=0;i<N;i++) pp[0][i]=solve1[0][i]=1;
        for(int i=1;i<N;i++)
        {
            C[i][0]=pp[i][0]=solve1[i][0]=1;
            for(int j=1;j<N;j++)
            {
                C[i][j]=mm(C[i-1][j-1]+C[i-1][j]);
                pp[i][j]=mm(pp[i][j-1]+C[i][j]);
            }
        }
        for(int i=1;i<N;i++) for(int j=1;j<N;j++) solve1[i][j]=mm(solve1[i-1][j]+pp[j-1][i]);

        int A=qread(),B=qread();ll ans=0;
        for(int t=1;t<=A+1;t++) for(int i=0;i<=t-1;i++) add(ans, 1ll*C[B-1][i]*solve1[t-1-i][i]%MOD );write(ans);
    }//(ans+MOD)%MOD
};
int main()
{
    srand(time(0));
    mine::main();
}


Measured memory_bytes: 47744
#include<cstdio>
long long n,m,a,i=1;
int main(){
    scanf("%lld%lld",&n,&m);n--;
    if(((n+3)%4^(m+3)%4)>1)a=1;
    for(;m>>i;i++)if(n>>i&n+1&1^m>>i&m+1&1)a+=1ll<<i;
    printf("%lld\n",a);
}

Measured memory_bytes: 128
require "prime"
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

n=gets.to_i
max=1
ans=1
for i in 2..n
  count=i.prime_division
  if count[0][0]==2 and count[0][1]>=max
    max=count[0][1]
    ans=i
  end
end
puts ans

Measured memory_bytes: 2044
s = list(input())
s = [int(_) for _ in s]
if len(s)%2 == 0:
    li1 = [0,1]*(len(s)//2)
    li2 = [1,0]*(len(s)//2)
if len(s)%2 == 1:
    li1 = [0,1]*(len(s)//2) + [0]
    li2 = [1,0]*(len(s)//2) + [1]
cnt1,cnt2 = 0,0
for i in range(len(s)):
    if s[i] != li1[i]:
        cnt1 += 1
    if s[i] != li2[i]:
        cnt2 += 1

print(min(cnt1,cnt2))

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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...) 6;
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n;
    cin >> n;
    vector<int> p(n), q(n);
    for (int i=0; i<n; i++)
        cin >> p[i];
    for (int i=0; i<n; i++)
        cin >> q[i];

    int a, b, i = 0;
    vector<int> perm(n);
    iota(perm.begin(), perm.end(), 1);
    do {
        if (perm == p)
            a = i;
        if (perm == q)
            b = i;
        i++;
    } while (next_permutation(perm.begin(), perm.end()));

    cout << abs(a - b) << "\n";

    return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
const double pi=3.14159265358979323846;
using namespace std;
int main() {
int a,b,h,m;
cin >> a >> b >> h >> m;
double radA, radB, l;
radA = (60*h+m)*2*pi/(60*12);
radB = 2*pi*m/60;
l = sqrt(a*a+b*b-2*a*b*cos(radA-radB));
cout  << setprecision(20) << l << endl;
}

Measured memory_bytes: 4164
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;
import java.util.TreeSet;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	private TreeSet<Long> divisors(long n) {
		TreeSet<Long> result = new TreeSet<>();

		for (long i = 1; i * i <= n; i++) {
			if (n % i == 0) {
				result.add(i);
				result.add(n / i);
			}
		}

		return result;
	}

	private int keta(long x) {
		if (x == 0) {
			return 1;
		}
		int keta = 1;
		while (x >= 10) {
			x /= 10;
			keta++;
		}
		return keta;
	}

	private int F(long a, long b) {
		return Math.max(keta(a), keta(b));
	}

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		long N = sc.nextLong();

		sc.close();

		TreeSet<Long> s = divisors(N);

		int ans = Integer.MAX_VALUE;

		for (long a : s) {
			long b = N / a;
			ans = Math.min(ans, F(a, b));
		}

		out.println(ans);
	}

	public static void main(String[] args) {
		new Main()._main(args);
	}
}


Measured memory_bytes: 21844
import java.util.*;

public class Main {
    private static final Scanner scn = new Scanner(System.in);
    
    public static void main(String[] args) {
        int h, w;
        while((h = scn.nextInt()) != 0 | (w = scn.nextInt()) != 0) {
            check(h, w);
            System.out.println();
        }
    }
    
    private static void check(int h, int w) {
        for(int i = 0; i < h; i++) {
            for(int j = 0; j < w; j++) {
                if((i + j) % 2 > 0) {
                    System.out.print(".");
                } else {
                    System.out.print("#");
                }
            }
            System.out.println();
        }
    }
}

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

int main()
{
  int a,b,c,k;
  cin >> a >> b >> c >> k;
  int sum = a;
  if(k <= a) sum = k;
  else if(a < k && k <= a + b) sum = a;
  else if(a + b < k && k <= a + b + c) sum = a-(k - a - b);
  cout << sum << endl;
}


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

template <int64_t N>
class modint {
    int64_t x;

public:
    modint(int64_t x = 0) : x((x % N + N) % N) {}
    modint operator-() const { return modint(-x); }
    modint& operator+=(const modint& a) {
        if ((x += a.x) >= N) x -= N;
        return *this;
    }
    modint& operator-=(const modint& a) {
        if ((x += N - a.x) >= N) x -= N;
        return *this;
    }
    modint& operator*=(const modint& a) {
        (x *= a.x) %= N;
        return *this;
    }
    modint operator+(const modint& a) const {
        return modint(*this) += a;
    }
    modint operator-(const modint& a) const {
        return modint(*this) -= a;
    }
    modint operator*(const modint& a) const {
        return modint(*this) *= a;
    }
    modint pow(int64_t t) const {
        if (not t) return 1;
        modint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }
    // for prime mod
    modint inv() const { return pow(N - 2); }
    modint& operator/=(const modint& a) {
        return (*this) *= a.inv();
    }
    modint operator/(const modint& a) const {
        return modint(*this) /= a;
    }
    friend ostream& operator<<(ostream& os,
                               const modint& m) {
        os << m.x;
        return os;
    }
};

const int64_t mod = 998244353;
using mint = modint<mod>;
int main() {
    int64_t n, k;
    cin >> n >> k;
    vector<pair<int64_t, int64_t>> s(k);
    for (auto i = 0; i < k; i++) {
        cin >> s[i].first >> s[i].second;
    }
    vector<mint> m(n + 1, 0);
    m[0] = 1;
    m[1] = -1;
    for (auto i = 0; i < n; i++) {
        if (i > 0) m[i] += m[i - 1];
        for (auto j = 0; j < k; j++) {
            m[min(i + s[j].first, n)] += m[i];
            m[min(i + s[j].second + 1, n)] -= m[i];
        }
        // for (auto& elm : m) cout << elm << " ";
        // cout << endl;
    }
    cout << m[n - 1] << endl;
    return 0;
}


Measured memory_bytes: 4832
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<string>
#include<vector>
#include<climits>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

#define	mp	make_pair
#define	pb	push_back
#define	pos		first
#define	X		first.first
#define	Y		first.second
#define	step	second

using namespace std;

typedef	pair<int,int>	pii;

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

int w,h,wall[60][30];

bool ismovable(pii a,pii b)
{
	int x0=a.first,y0=a.second,x1=b.first,y1=b.second;

	if(x1<0||w<=x1||y1<0||h<=y1)	return false;

	if     (x1-x0==1)	return !wall[2*y0][x0];		// right
	else if(x1-x0==-1)	return !wall[2*y0][x1];		// left
	else if(y1-y0==1)	return !wall[2*y0+1][x0];	// down
	else if(y1-y0==-1)	return !wall[2*y1+1][x0];	// up
}

int main()
{
	for(;cin>>w>>h,w;){
		for(int i=0;i<2*h-1;i++){
			if(i%2)	for(int j=0;j<w;j++)	cin>>wall[i][j];
			else	for(int j=0;j<w-1;j++)	cin>>wall[i][j];
		}

		int ans=0;
		bool visited[30][30]={};
		queue< pair<pii,int> > qu;	qu.push(mp(mp(0,0),1));
		while(!qu.empty()){
			pair<pii,int> a=qu.front();	qu.pop();
			if(a.pos==mp(w-1,h-1)){
				ans=a.step;
				break;
			}
			if(visited[a.Y][a.X])	continue;

			visited[a.Y][a.X]=true;
			for(int i=0;i<4;i++){
				pair<pii,int> b=mp(mp(a.X+dx[i],a.Y+dy[i]),a.step+1);
				if(ismovable(a.pos,b.pos))	qu.push(b);
			}
		}
		cout<<ans<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
import sys, math
from collections import defaultdict
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 1000000007
sys.setrecursionlimit(1000000)

N = ri()
A = []
for i in range(N):
	A.append(ri())
m = max(A)
if len([a for a in A if a == m]) > 1:
	for i in range(N):
		print(m)
else:
	m2 = -1
	i2 = -1
	for i, a in enumerate(A):
		if a == m:
			continue
		if m2 < a:
			m2 = a
			i2 = i
	for a in A:
		if a == m:
			print(m2)
		else:
			print(m)


Measured memory_bytes: 93428
def sgs(str,limit)
  if str.to_i > limit
    return 0
  end
  if str.include?("3") && str.include?("5") && str.include?("7")
    return sgs(str+"3",limit) + sgs(str+"5",limit) + sgs(str+"7",limit) + 1
  else
    return sgs(str+"3",limit) + sgs(str+"5",limit) + sgs(str+"7",limit)
  end
end

n = gets.to_i
puts sgs("",n)


Measured memory_bytes: 3836
#include <iostream>
#include <vector>
#include <map>

using namespace std;

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

	vector<vector<int>> d(nc, vector<int>(nc, 0));
	for (int i = 0; i < nc; i++) {
		for (int j = 0; j < nc; j++) {
			int dd;
			cin >> dd;
			d[i][j] = dd;
		}
	}

	vector<vector<int>> c(n, vector<int>(n, 0));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			int cc;
			cin >> cc;
			c[i][j] = cc;
		}
	}
			
	vector<vector<int>> cost(nc, vector<int>(3, 0));

	for (int ic = 0; ic < nc; ic++) {
		int t0 = 0;
		for (int i = 0; i < n; i++) {
			int tt = 1 - i % 3;
			if (tt < 0) tt += 3;
			for (int j = tt; j < n; j+=3) {
				t0 += d[c[i][j]-1][ic];
			}
		}
		int t1 = 0;
		for (int i = 0; i < n; i++) {
			int tt = 2 - i % 3;
			if (tt < 0) tt += 3;
			for (int j = tt; j < n; j+=3) {
				t1 += d[c[i][j]-1][ic];
			}
		}
		int t2 = 0;
		for (int i = 0; i < n; i++) {
			int tt = 0 - i % 3;
			if (tt < 0) tt += 3;
			for (int j = tt; j < n; j+=3) {
				t2 += d[c[i][j]-1][ic];
			}
		}
		cost[ic][0] = t0;
		cost[ic][1] = t1;
		cost[ic][2] = t2;
	}

	int ans = 750000000;
	for (int i = 0; i < nc; i++) {
		for (int j = 0; j < nc; j++) {
			for (int k = 0; k < nc; k++) {
				if (i == j || j == k || k == i) continue;
				int t = cost[i][0] + cost[j][1] + cost[k][2];
				if (t < ans) ans = t;
			}
		}
	}

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


Measured memory_bytes: 1280
from sys import stdin
import numpy as np
import math

N, D = [int(x) for x in stdin.readline().rstrip().split()]

X = list()
for y in range(N):
    X.append([int(z) for z in stdin.readline().rstrip().split()])

count = 0

for i in range(N):
    for j in range(N):
        if i >= j:
            continue
            
        # 平方和の取り方
        # [分散, 標準偏差ぐらいまでの統計 \- Qiita](https://qiita.com/tiny/items/aefc87f7fec913864623)
        s = sum((X[i][d] - X[j][d])**2 for d in range(D))
        distance = math.sqrt(s)

        # [Pythonで数値が整数か小数かを判定 \| note\.nkmk\.me](https://note.nkmk.me/python-check-int-float/)
        if distance.is_integer():
            count += 1

print(count)


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

int add(int x, int y){
    return x+y;
}

int main (){
    int a, b;
    cin >> a >> b;
    if (add(a,b)%3==0 || a%3 ==0 || b%3==0){
        cout << "Possible" << endl;
    }else {
        cout << "Impossible" << endl;
    }
}


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

typedef vector<vector<int> > Graph;

typedef long long lli;

const lli MAXN = 500001;
const lli INF = 1LL<<60;

lli N, V;
Graph G;

int num[MAXN], depth[MAXN];
lli cost[MAXN], mem[MAXN];

/*
pair<lli, lli> dfs(lli v, lli d) {
  depth[v] = d;
  if(v >= N-1) {
    num[v] = 1;
    cost[v] = d;
    return make_pair(num[v], cost[v]);
  }
  num[v] = 0;
  cost[v] = 0;
  for(lli i = 0; i < G[v].size(); ++i) {
    pair<lli, lli> p = dfs(G[v][i], d + 1);
    num[v] += p.first;
    cost[v] += p.second;
  }
  return make_pair(num[v], cost[v]);
}

lli rec(lli v) {
  lli &res = mem[v];
  if(res != -1) return res;
  if(v >= N-1) return res = 0;
  res = INF;
  lli a = G[v][0];
  lli b = G[v][1];
  lli smallA = cost[a] - num[a] * depth[v];
  lli smallB = cost[b] - num[b] * depth[v];
  res = min(res, smallA + rec(b) + 1);
  res = min(res, rec(a) + smallB + 1);
  res = min(res, rec(a) + rec(b) + depth[v] + 2);
  return res;
}
*/

int main() {
  while(cin >> N) {
    V = N - 1;
    G = Graph(V);
    for(lli i = 0; i < N - 1; ++i) {
      lli a, b; cin >> a >> b;
      --a; --b;
      G[i].push_back(a);
      G[i].push_back(b);
    }

    {
      queue<lli> que;
      que.push(0);
      depth[0] = 0;
      while(que.size()) {
        lli v = que.front();
        que.pop();
        for(lli i = 0; i < G[v].size(); ++i) {
          lli nv = G[v][i];
          if(nv == N-1) continue;
          que.push(nv);
          depth[nv] = depth[v] + 1;
        }
      }
    }

    vector<pair<lli, lli> > w;
    for(lli i = 0; i < V; ++i) {
      w.push_back(make_pair(-depth[i], i));
    }
    sort(w.begin(), w.end());

    for(lli i = 0; i < V; ++i) {
      lli v = w[i].second;
      if(G[v].empty()) {
        assert(false);
        cost[v] = depth[v];
        num[v] = 1;
      } else {
        lli a = G[v][0];
        lli b = G[v][1];
        cost[v] = num[v] = 0;
        if(a == N-1) {
          cost[v] += depth[v] + 1;
          num[v] += 1;
        } else {
          cost[v] += cost[a];
          num[v] += num[a];
        }
        if(b == N-1) {
          cost[v] += depth[v] + 1;
          num[v] += 1;
        } else {
          cost[v] += cost[b];
          num[v] += num[b];
        }
      }
    }

    mem[N-1] = 0;
    for(lli i = 0; i < V; ++i) {
      lli v = w[i].second;
      lli &res = mem[v];
      res = INF;
      lli a = G[v][0];
      lli b = G[v][1];
      lli smallA = 0, smallB = 0;
      if(a == N-1) {
        smallA = depth[v] + 1 - 1 * depth[v];
      } else {
        smallA = cost[a] - num[a] * depth[v];
      }

      if(b == N-1) {
        smallB = depth[v] + 1 - 1 * depth[v];
      } else {
        smallB = cost[b] - num[b] * depth[v];
      }
      res = min(res, smallA + mem[b] + 1);
      res = min(res, mem[a] + smallB + 1);
      res = min(res, mem[a] + mem[b] + depth[v] + 2);
    }

    cout << mem[0] << endl;
  }
  return 0;
}

Measured memory_bytes: 56712
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <sstream>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <queue>
#include <random>

using namespace std;

#define min(a,b) ((a)<(b) ? (a):(b))
#define max(a,b) ((a)>(b) ? (a):(b))

int gcd(int a, int b){
    while( b ){
        int m = a % b;
        a = b;
        b = m;
    }
    return a;
}

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

int isPrim(int a){
    if(a==1){
        return 0;
    }
    for(int i=2;i<=(a+1)/2;i++){
        if(a%i==0){
            return 0;
        }
    }
    return 1;
}

long long mod_pow(long long x, long long n, long long mod){
    //x???n???????¨????????????????n??????2?????¨?¨???????????¨????
    //x^22 = x^16 + x^4 + x^2
    long long ret=1;
    while(n>0){
        if(n%2==1){
            ret=(ret*x)%mod;//???????????????
        }
        x=(x*x)%mod;//2???
        n=n/2;
    }
    return ret;
}

struct VV{
    int x;
    int y;
    int z;
};

class LessInt {
public:
    bool operator()(const VV& riLeft, const VV& riRight) const {
        if(riLeft.x == riRight.x){
            return riLeft.y > riRight.y;
        }
        return riLeft.x > riRight.x;
        
    }
};

class indInt {
public:
    bool operator()(const VV& riLeft, const VV& riRight) const {
        return riLeft.x < riRight.x;
        
    }
};

struct XX{
    int zenbu=0;
    int kidoku=0;
};

class xxIntu {
public:
    bool operator()(const VV& riLeft, const VV& riRight) const {
        //?¬¬1?????¶
        if(riLeft.z != riRight.z){
            return riLeft.z > riRight.z;//<:??????(?°??????????)???>:??????(??§?????????)
        }
        //?¬¬2?????¶
        return riLeft.y < riRight.y;
    }
};
bool operator< (const VV &riLeft, const VV &riRight){
    return riLeft.z < riRight.z;
};
/*bool operator> (const XX &riLeft, const XX &riRight){
    return riLeft.a > riRight.a;
};*/



int main(int argc, const char * argv[])
{
    //std::ios::sync_with_stdio(false);
    //scanf("%s",S);
    //scanf("%d",&N);
    //getline(cin, target);
    //cin >> x >> y;
    //????????????
    
    int N,W;
    cin >> N>> W;
    int v[100];
    int w[100];
    for(int i=0;i<N;i++){
        cin >>v[i]>> w[i];
    }
    int dp[10001];//?????????W??\?????§?????????????????§??????
    dp[0]=0;
    for(int i=1;i<=W;i++){
        int mmax=0;
        for(int j=0;j<N;j++){
            if(i-w[j]<0){
                continue;
            }
            if(mmax<dp[i-w[j]]+v[j]){
                mmax=dp[i-w[j]]+v[j];
            }
        }
        dp[i]=mmax;
    }
    
    cout << dp[W] << endl;
    
    //???????????§
    //cout << "ans" << endl;????????????
    //printf("%.0f\n",ans);//?°???°?????\?????¨?????????
    //printf("%.7f\n",p);
    //printf("%f\n",pow(2,ans.size()));
    
    return 0;
}

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

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	int m; cin >> m;
	vector<int> a(m);
	for(int i=0;i<m;i++){
		cin >> a[i];
	}
	int cnt[n];
	for(int i=0;i<n;i++){
		cnt[i]=0;
	}
	for(int i=0;i<m;i++){
		int cn=0;
		for(int j=0;j<n;j++){
			int x; cin >> x;
			if(x==a[i]){
				cnt[j]++;
			}
			else{
				cn++;
			}
		}
		cnt[a[i]-1]+=cn;
	}
	for(int i=0;i<n;i++){
		cout << cnt[i] << endl;
	}
}


Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
typedef long long ll;
typedef long double  ld;
#define pii pair<ll,ll> 
#define pic pair<ll,char>
#define vi vector< ll > 
#define vvi vector< vi > 
#define vpi vector< pii > 
#define vvpi vector< vpi > 
#define st  set <ll, greater <ll> >
#define mst  multiset <ll, greater <ll> >
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mapp  unordered_map <ll, ll>
#define ppii pair< pii, pii > 
#define test(t) ll t;cin>>t;while(t--)
#define inarr(n) ll arr[n];for(ll i=0;i<n;i++)cin>>arr[i];
#define ingra(m) vvi arr(100005);for(ll i=0;i<m;i++){ll u,v;cin>>u>>v;arr[u].pb(v);arr[v].pb(u);}
#define mem(a,b) memset(a,b,sizeof(a))
#define inn freopen("input.txt", "r", stdin)
#define outt freopen("output.txt", "w", stdout)
#define all(arr) arr.begin(),arr.end()
ll power(ll x,ll y){ll res = 1;while(y){if(y&1) res = (res*x)%mod;y=y/2,x=(x*x)%mod;}return res%mod;}
signed main()
{
    fast;
    ll n;
    cin>>n;
    ll dp[n+1][n+1];
    ll arr[n+1];
    ll pref[n+1];
    pref[0] = 0;
    ll i,j;
    for(i=1;i<=n;i++)
        cin>>arr[i],pref[i] = pref[i-1]+arr[i];
    for(i=0;i<=n;i++)
        for(j=0;j<=n;j++)
            dp[i][j] = 1e18;
    for(i=1;i<n;i++)
        dp[i][i+1] = arr[i]+arr[i+1],dp[i][i] = 0;
    dp[n][n] = 0;
    for(i=2;i<n;i++)
    {
        ll j,k;
        for(j=1;j<=n;j++)
        {
            ll end = j+i;
            if(end>n)
                break;
            for(k=j;k<end;k++)
            {
                dp[j][end] = min(dp[j][end],dp[j][k]+dp[k+1][end]-pref[j-1]+pref[end]);
            }
        }
    }
    cout<<dp[1][n];
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
#define int long long int
using namespace std;
bool comp(int a, int b) 
{ 
    return (a < b); 
} 
signed main()
{
	int r,d ,x;
	cin>>r>>d>>x;
	for (int i = 0; i < 10; ++i)
	{
		x = r*x - d;
		cout<<x<<endl;
	}

}

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

bool prime[10000001];
bool dp[10000001];
int menu[30];
int n,x;

void make_prime()
{
  memset(prime,true,sizeof(prime));
  prime[0]=prime[1]=false;
  for(int i=2;i<10000001;i++)
    {
      if(prime[i])
	{
	  for(int j=i+i;j<10000001;j+=i)
	    prime[j]=false;
	}
    }
}

int main()
{
  make_prime();
  for(;cin>>n>>x,n;)
    {
      memset(dp,false,sizeof(dp));
      for(int i=0;i<n;i++)
	{
	  cin>>menu[i];
	  dp[menu[i]]=true;	  
	}
      int ans=-1;
      for(int i=0;i<=x;i++)
	{
	  if(dp[i])
	    for(int j=0;j<n;j++)
	      if(i+menu[j]<=x)
		dp[i+menu[j]]=true;	  
	}
      for(int i=x;i>0;i--)
	if(prime[i]&&dp[i])
	  {
	    ans=i;
	    break;
	  }
      if(ans!=-1)
	cout<<ans<<endl;
      else
	cout<<"NA"<<endl;
    }
}

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

using namespace std;

int main( )
{
	double x1, y1, x2, y2;

	cin>>x1>>y1>>x2>>y2;

	double distance = 0;
	distance = sqrt( pow( ( x1-x2 ), 2 ) + pow( ( y1-y2 ), 2 ) );
	cout.setf( ios::fixed );
	cout<<distance<<endl;
		
	return 0;
}

Measured memory_bytes: 1284
// #include<iostream>
// #include<vector>
// #include<algorithm>
// #include<map>
// #include<cstring>
// #include<math.h>
// #include<bitset>
// #include<queue>
// #include<set>
// #include<iomanip>
// #include<math.h>
// #include<assert.h>
// #include<string>
// #include<cstdlib>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr ll INF = 1LL << 40;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// ----------------------------------------------------------------------------
ll dp[100010][4];
int main(){
  string S;
  cin >> S;
  int N;
  N = S.size();
  for(int i=0; i<10010; i++){
    for(int j=0; j<4; j++){
      dp[i][j] = 0;
    }
  }
  for(int i=N; i>=0; i--){
    for(int j=3; j>=0; j--){
      if(i == N){
        if(j == 3){
          dp[i][j] = 1;
        }else{
          dp[i][j] =0;
        }
      }else{
        if(S[i] == '?'){
          dp[i][j] = dp[i+1][j] * 3LL;
        }else{
          dp[i][j] = dp[i+1][j];
        }
        if(j < 3 && S[i] == '?' || S[i] == "ABC"[j]){
          dp[i][j] += dp[i+1][j+1];
        }
        dp[i][j] %= mod;
      }
    }
  }
  cout << dp[0][0] << endl;
  return 0;
}


Measured memory_bytes: 3584