akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> P1;
typedef pair<P, P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i, x) for (long long i = 0; i < x; i++)
#define repn(i, x) for (long long i = 1; i <= x; i++)
#define SORT(x) sort(x.begin(), x.end())
#define ERASE(x) x.erase(unique(x.begin(), x.end()), x.end())
#define POSL(x, v) (lower_bound(x.begin(), x.end(), v) - x.begin())
#define POSU(x, v) (upper_bound(x.begin(), x.end(), v) - x.begin())
vector<pair<string, P> > vec;
// vector<vector<int>> data(3, vector<int>(4));

void solve(long long A, long long B, long long C, long long K) {
    ll n = K, res = 0;
    if (n >= 0) res += min(A, n);
    n -= A;
    n -= B;
    if (n >= 0) res -= min(C, n);
    cout << res << endl;
}

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


Measured memory_bytes: 3760
#include <iostream>
#include <map>

using namespace std;

int N, D, res = 0;
int X[10][10];
map<int, bool> M;

int main() {

	for (int i = 1; i * i <= 16000; i++ ) {
		M[i * i] = true;
	}

	scanf("%d %d", &N, &D);

	for ( int i = 0; i < N; i++ ) {
		for ( int j = 0; j < D; j++ ) {
			int d;
			scanf("%d", &d);
			X[i][j] = d;
		}
	}

	for ( int i = 0; i < N; i++ ) {
		for ( int j = i + 1; j < N; j++ ) {
			int dist = 0;
			for (int k = 0; k < D; k++) {
				dist += (X[j][k] - X[i][k]) * (X[j][k] - X[i][k]);
			}
			if (M[dist]) res++;
		}
		
	}
	printf("%d\n", res);

}

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


int main() {
  
  int N;
  cin >> N;
  
  map<int, int> Map;
  
  for (int i = 1; i <= N; i++) {
    int A;
    cin >> A;
    Map[A] = i;
  }
  
  for (int i = 1; i <= N; i++) {
    cout << Map[i] << " ";
  }
    
  
  
  
}

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll A[3][3];
    rep (i, 3) {
        rep (j, 3) {
            cin >> A[i][j];
        }
    }

    ll N;
    cin >> N;

    vector<ll> b(N);
    rep (i, N) {
        cin >> b[i];
    }

    bool ans[3][3];
    rep (i, 3) {
        rep (j, 3) {
            ans[i][j] = false;
        }
    }

    rep (k, N) {
        rep (i, 3) {
            rep (j, 3) {
                if (A[i][j] == b[k]) {
                    ans[i][j] = true;
                }
            }
        }
    }

    bool f = false;
    if (ans[0][0] && ans[1][1] && ans[2][2]) {
        f = true;
    }
    if (ans[0][2] && ans[1][1] && ans[2][0]) {
        f = true;
    }
    
    if (ans[0][0] && ans[1][0] && ans[2][0]) {
        f = true;
    }
    if (ans[0][1] && ans[1][1] && ans[2][1]) {
        f = true;
    }
    if (ans[0][2] && ans[1][2] && ans[2][2]) {
        f = true;
    }

    if (ans[0][0] && ans[0][1] && ans[0][2]) {
        f = true;
    }
    if (ans[1][0] && ans[1][1] && ans[1][2]) {
        f = true;
    }
    if (ans[2][0] && ans[2][1] && ans[2][2]) {
        f = true;
    }

    if (f) {
        Yes;
    } else {
        No;
    }

    return 0;
}

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

    class Program
    {
        static void Main()
        {
            var n = System.Console.ReadLine();
            try
            {
                foreach (char c in n)
                {
                    if (Char.IsUpper(c))
                    {
                        Output("A".ToString());
                    }
                    else
                    {
                        Output("a".ToString());
                    }
                }
            }
            catch
            {
                Output("a".ToString());
            }
        }
        private static void Output(string str)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            Console.WriteLine(str);

            Console.Out.Flush();
        }
    }

Measured memory_bytes: 25788
#include<bits/stdc++.h>
#define int long long
#define ld long double
#define ri register int
#define il inline
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define vi vector<int>
#define all(x) x.begin(),x.end() 
#define rep(i,a,b) for(ri i=(a);i<=(b);++i)
#define per(i,a,b) for(ri i=(a);i>=(b);--i)
#define ls (x<<1)
#define rs (x<<1|1)
#define mid (l+r>>1)
#define db(x) cout << "#x:" << x << endl
#define dd() cout << "Out put!\n"
const int mod=1e9+7,eps=1e-6,pi=acos(-1.0),maxn=1000010;
const int inf=0x7f7f7f7f7f7f7f7f;
using namespace std;
int a[maxn],b[maxn],c[maxn];
string s; 
signed main()
{
	int n;
	cin >> n;
	rep(i,1,n)
	{
		cin >> a[i] >> b[i];
	}
	sort(a+1,a+1+n);
	sort(b+1,b+1+n);
	if(n&1)
	{
		cout << b[n+1>>1] - a[n+1>>1]+1;
	}
	else
	{
		cout << b[n/2+1]-a[n/2+1] + b[n/2] - a[n/2]+1<<endl;
	}
	return 0;
}

Measured memory_bytes: 6728
#include <iostream>
#include <vector>

using namespace std;

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

	vector<vector<int>> A(n, vector<int>(m));
	vector<int> b(m);

	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)
			cin >> A[i][j];

	for (int i = 0; i < m; i++)
		cin >> b[i];

	for (int i = 0; i < n; i++){
		int ans = 0;
		for (int j = 0; j < m; j++){
			ans += A[i][j] * b[j];
		}
		cout << ans << endl;
	}

	return 0;
}



Measured memory_bytes: 3176
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vb=vector<bool>;
using pii=pair<int,int>;
using vpii=vector<pair<int,int>>;

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

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
//試験導入
#define irep(i, end_i, begin_i) for (ll i = (ll)begin_i-1; i >= (ll)end_i; i--)
vll yakusu(ll x){
    vll ret;
    for(ll i=1;i*i<=x;i++){
        if(x%i==0)
                ret.push_back(i);
    }
    return ret;
}
long long INF = 1LL<<60;
int main( ){
    ll x;
    cin>>x;
    rep(a,-120,120){
        rep(b,-120,120){
            if(llpow(a,5)-llpow(b,5)==x){
                cout<<a<<" "<<b<<endl;
                return 0;
            }
        }
    }
    return 0;
}




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

int main(){
    int n;
    cin>>n;
    int F[50];
    F[0]=F[1]=1;
    for (int i=2;i<=n;i++) F[i]=F[i-1]+F[i-2];
    
    cout<<F[n]<<endl;
    
    return 0;
    
}


Measured memory_bytes: 3116
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>

#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;



int main() {
    string s;
    cin >> s;
    int ans;
    if (s == "SUN"){
        ans = 7;
    }else if (s== "MON"){
        ans = 6;
    }else if (s== "TUE"){
        ans = 5;
    }else if (s== "WED"){
        ans = 4;
    }else if (s== "THU"){
        ans = 3;
    }else if (s== "FRI"){
        ans = 2;
    }else{
        ans = 1;
    }
    cout << ans << endl;
    return 0;
}


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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

int main()
{
    int n; cin >> n;
    vector<int> to[n];
    rep(_,n){
        int u; cin >> u; --u;
        int k; cin >> k;
        rep(i,k){
            int v; cin >> v; --v;
            to[u].push_back(v);
        }
    }

    int dist[n];
    rep(i,n) dist[i] = -1;

    queue<int> q;
    q.push(0);
    dist[0] = 0;

    while(!q.empty()){
        int u = q.front(); q.pop();
        for(int v: to[u]){
            if(dist[v] == -1){
                dist[v] = dist[u]+1;
                q.push(v);
            }
        }
    }
    rep(i,n){
        printf("%d %d\n", i+1, dist[i]);
    }
}


Measured memory_bytes: 3228
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>


using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define CLEAR(arr, val) memset(arr, val, sizeof(arr))

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

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

typedef long long ll;
typedef pair<int, int> pint;

const double EPS = 1e-8;
const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };
bool valid_pos(int x, int y, int w, int h) { return 0 <= x && x < w && 0 <= y && y < h; }


ll mod_mul(ll x, ll n, ll mod)
{
	if (n == 0)
		return 0;
	if (x < 0)
		x = (x + mod) % mod;

	bool nega = n < 0;
	if (nega)
		n = -n;

	ll res = 0;
	while (n > 0)
	{
		if (n & 1)
			res = (res + x) % mod;
		x = x * 2 % mod;
		n /= 2;
	}

	if (nega)
		res = (mod - res) % mod;
	return res;
}
ll ext_gcd(ll a, ll b, ll &x, ll &y)
{
	if (b)
	{
		ll g = ext_gcd(b, a % b, y, x);
		y -= (a / b) * x;
		return g;
	}
	else
	{
		x = 1, y = 0;
		return a;
	}
}
ll mod_inverse(ll a, ll mod)
{
	ll x, y;
	if (ext_gcd((a + mod) % mod, mod, x, y) == 1)
		return (mod + x % mod) % mod;
	else
		return 0;
}
int main()
{
	ios::sync_with_stdio(false);

	const ll mod = 9999999967LL;

	int n;
	cin >> n;
	ll x = 0;
	while (n--)
	{
		int o, y;
		cin >> o >> y;
		if (o == 1)
			x += y;
		else if (o == 2)
			x -= y;
		else if (o == 3)
			x = mod_mul(x, y, mod);
		else
			x = mod_mul(x, mod_inverse(y, mod), mod);

		x = (x + mod) % mod;
	}
	if (x >= 1LL << 31)
		x -= mod;
	cout << x << endl;
}

Measured memory_bytes: 900
/*
これを入れて実行
g++ code.cpp
./a.out
*/

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = { -1, 0, +1, 0 };
int dx4[4] = { 0, +1, 0, -1 };
int dy8[8] = { -1, -1, 0, 1, 1, 1, 0, -1 };
int dx8[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
	return f.second > s.second;
}

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

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

ll nCr(ll n, ll r){
	if (r == 0 || r == n){
		return 1;
	}
	else if (r == 1){
		return n;
	}
	return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}

ll nPr(ll n, ll r){
	r = n - r;
	ll ret = 1;
	for (ll i = n; i >= r + 1; i--) ret *= i;
	return ret;
}

//-----------------------ここから-----------

int main(void){
	int n, k;
	cin >> n >> k;
	string s;
	cin >> s;

	vector<pair<char, int>> g;



	for (int i = 0; i < n; i++){
		int cnt = 1;
		for (int j = i + 1; j < n; j++){
			if (s[j] == s[i]){
				cnt++;
				if (j == n - 1){
					i = j;
					break;
				}
			} else {
				i = j - 1;
				break;
			}
		}
		g.push_back(make_pair(s[i], cnt));
	}

	//for (int i = 0; i < g.size(); i++){
	//	cout << g[i].first << " " << g[i].second << endl;
	//}

	int r = 1;
	int cnt = 0;
	int total = 0;
	int ans = 0;
	int f;
	if (g[0].first != '1'){
		cnt = 1;
	}

	total += g[0].second;
	for (int l = 0; l < g.size(); l++){
		while (r < g.size() && cnt <= k){
			if (g[r].first == '0'){
				if (cnt == k){
					break;
				}
				cnt++;
			}
			total += g[r].second;
			r++;
		}

		ans = max(ans, total);

		total -= g[l].second;

		if (g[l].first == '0'){
			cnt--;
		}

	}

	cout << ans << endl;
	
} 


Measured memory_bytes: 1528
#include <bits/stdc++.h>
#define MOD 100000007
#define PI 3.141592653589793238
#define pb push_back
#define ALL(V) (V).begin(), (V).end()
#define rep(i, a, b) for(int i = (a); i < (b); ++i)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long long int lint;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
inline ll gcd(ll a, ll b) { return (a % b == 0 ? b : gcd(b, a % b)); }
inline ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
inline ll char_to_ll(char c) { return (int)(c - '0'); }
inline ll string_to_ll(string s) { return atoi(s.c_str()); }
inline bool is_prime(ll x){ if(x <= 1) return false; for(ll i = 2; sqrt(i) <= x; i++) if(x % i == 0) return false; return true; }

int main(){
    ll A, B, C, D;
    cin >> A >> B >> C >> D;

    while(A > 0 && C > 0){
        C -= B;
        if(C > 0){
            A -= D;
        }
    }

    if(C <= 0) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3628
n=int(input())
dic={i:0 for i in range(1,n+1)}
for x in range(1,100):
  for y in range(1,x+1):
    for z in range(1,y+1):
      k=x**2+y**2+z**2+x*y+y*z+z*x
      if k<=n:
        if x==y==z: dic[k]+=1
        elif x==y or y==z: dic[k]+=3
        else: dic[k]+=6
for l in range(n):
  print(dic[l+1])


Measured memory_bytes: 9708
#include <stdio.h>

int main(void){
    long int h, w, ans;

    scanf("%ld", &h);
    scanf("%ld", &w);

    if(h == 1 || w == 1){
        ans = 1;
        printf("%ld\n", ans);
    }

    else {
        if(h % 2 == 0){
            ans = w * h / 2;
        }

        else{
            if(w % 2 == 1){
                ans = (w * (h / 2)) + (w / 2 + 1);
            }

            else{
                ans = (w * (h / 2)) + (w / 2);
            }
        }

        printf("%ld\n", ans);

    }

    
    return 0;

}

Measured memory_bytes: 128
S = input()

save = []
flag = False
modori_flag = False
count = 0
for idx, s in enumerate(S):
    if modori_flag:
        modori_flag = False
    elif flag:
        flag = False
        continue
            
    this_ = int(s)
    if len(save) > 0 and this_ + save[-1] == 1:
        modori_flag = True
        del save[-1]
        count += 2
        continue
    if idx == len(S) -1:
        break
    next_ = int(S[idx+1])
    if this_ + next_ == 1:
        flag = True
        count += 2
        continue
        
    save.append(this_)
    
print(count)


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

inline void upmax(short &x,const short &y){if(y>x) x=y;}

const int N=105;
short f[N][N][N][N];
short sum1[N][N],sum2[N][N];
int n,m,tx,ty;

void gao()
{
    int limu=tx-1,limd=n-tx,liml=ty-1,limr=m-ty;
    for(int u=0;u<=limu;u++)
        for(int d=0;d<=limd;d++)
            for(int l=0;l<=liml;l++)
                for(int r=0;r<=limr;r++)
                {
                    int L=max(ty-l,r+1),R=min(ty+r,m-l);
                    if(L<=R)
                    {
                        upmax(f[u+1][d][l][r],f[u][d][l][r]+(tx-u-1>=d+1?sum1[tx-u-1][R]-sum1[tx-u-1][L-1]:0));
                        upmax(f[u][d+1][l][r],f[u][d][l][r]+(tx+d+1<=n-u?sum1[tx+d+1][R]-sum1[tx+d+1][L-1]:0));
                    }
                    L=max(tx-u,d+1),R=min(tx+d,n-u);
                    if(L<=R)
                    {
                        upmax(f[u][d][l+1][r],f[u][d][l][r]+(ty-l-1>=r+1?sum2[R][ty-l-1]-sum2[L-1][ty-l-1]:0));
                        upmax(f[u][d][l][r+1],f[u][d][l][r]+(ty+r+1<=m-l?sum2[R][ty+r+1]-sum2[L-1][ty+r+1]:0));
                    }
                }
    printf("%d\n",f[limu][limd][liml][limr]);
}

int main()
{
    static char s[105];
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
    {
        scanf("%s",s+1);
        for(int j=1;j<=m;j++)
        {
            if(s[j]=='E') tx=i,ty=j;
            sum1[i][j]=sum1[i][j-1]+(s[j]=='o');
            sum2[i][j]=sum2[i-1][j]+(s[j]=='o');
        }
    }
    gao();
    return 0;
}

Measured memory_bytes: 207360
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N, K;
    cin >> N >> K;

    string S;
    cin >> S;
    //string small = tolower(S, l);

    for(int i = 0; i < N; i++){
      if(i == K-1){
        transform (S.begin (), S.end (), S.begin (), ::tolower);
        cout << S[i];
        transform (S.begin (), S.end (), S.begin (), ::toupper);
      }
      else cout<<S[i];
    }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; 
int main() {
  long long N,A,B;
  cin >>N>>A>>B;
  long long count=0; 
  if((B-A)%2==0){
    count=(B-A)/2;
  }else{
    if((B+A)%2==1){
      count=(B+A-1)/2;
      count=min(count,(2*N-A-B+1)/2);
    }else{
      count=(B+A)/2;
      count=min(count,(2*N-A-B)/2);
    }
    count=min(count,min(B-1,N-A));
  }
  cout <<count<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<utility>

struct edge{
  int to;
  int ind;
};

class C{
  int N;
  std::vector<std::vector<edge>> G;
public:
  void input();
  void solve();
  void dfs(int v,int par,int par_col, std::vector<int>& color);
};

void C::input(){
  std::cin>>N;
  G.resize(N);
  for(int i=0;i<N-1;i++){
    int A,B;
    std::cin>>A>>B;
    A--,B--;
    G[A].push_back({B,i});
    G[B].push_back({A,i});
  }
}

void C::dfs(int v,int par, int par_col,std::vector<int>& color){
  int col=1;
  for(edge& u:G[v]){
    if(u.to==par) continue;
    if(col==par_col) col++;
    color[u.ind]=col;
    C::dfs(u.to,v,col++,color);
  }
}

void C::solve(){
  C::input();
  int ans=0;
  for(int i=0;i<N;i++){
    ans=std::max(ans,(int)G[i].size());
  }
  std::cout<<ans<<"\n";
  std::vector<int> color(N-1);
  C::dfs(0,-1,-1,color);
  for(int& c:color) std::cout<<c<<"\n";
}

int main(){
  C c;
  c.solve();
  return 0;
}

Measured memory_bytes: 8320
#include <iostream>
using namespace std;
static const int MAX = 100;
static const int INFTY = (1<<21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;
int n,M[MAX][MAX];
void Dijkstra(){
int min;
int d[MAX],color[MAX];
  for(int i=0;i<n;i++){
    d[i]=INFTY;
    color[i]=WHITE;
  }
  d[0]=0;
  color[0]=GRAY;
  while(GRAY){
    min=INFTY;
    int u=-1;
    for(int i=0;i<n;i++){
      if(min>d[i] && color[i]!=BLACK){
	u=i;
	min=d[i];
      }
    }
    if(u==-1) break;
    color[u] = BLACK;
    for(int v=0;v<n;v++){
      if(color[v]!=BLACK && M[u][v]!=INFTY){
	if(d[v]>d[u]+M[u][v]){
	  d[v]=d[u]+M[u][v];
	  color[v]=GRAY;
	}
      }
    }
  }
  for(int i=0;i<n;i++){ 
    cout << i <<" " << (d[i]==INFTY ? -1 : d[i]) << endl;
  }
}
int main(){
  cin >> n;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      M[i][j]=INFTY;
    }
  }
  int k,c,u,v;
  for(int i=0;i<n;i++){
    cin >> u >> k;
    for(int j=0;j<k;j++){
      cin >> v >> c;
      M[u][v]=c;
    }
  }
  Dijkstra();
  return 0;
}



Measured memory_bytes: 3128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <utility>
#include <climits>
#include <functional>

using namespace std;

#define int long long
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define rep1(i,n) for(int i=1;i<=(int)n;++i)
#define all(a) begin(a),end(a)

const int inf = 1e9 + 10;

int N,K,Q;
vector<int> A;

int f(int x)
{
	vector<vector<int>> arr;

	{
		vector<int> cur;
		rep(i, N) {
			if (A[i] < x) {
				if (cur.size() >= K) arr.push_back(cur);
				cur = vector<int>();
			} else {
				cur.push_back(A[i]);
			}
		}

		if (cur.size() >= K) {
			arr.push_back(cur);
			cur = vector<int>();
		}
	}

	for (vector<int> &a : arr) sort(all(a));

	vector<int> cand;

	for (vector<int> &a : arr) {
		for (int i = 0; i <= (int)a.size() - K; ++i) {
			cand.push_back(a[i]);
		}
	}

	if (cand.size() < Q) return inf;

	sort(all(cand));

	return cand[Q-1] - cand[0];
}

signed main()
{
	cin >> N >> K >> Q;
	A.resize(N);
	rep(i, N) cin >> A[i];

	int ans = inf;

	rep(i, N) {
		ans = min(ans, f(A[i]));
	}

	cout << ans << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  int a = S.size();
  if(S.at(a-1)=='s'){
    cout << S << "es" << endl;
  }
  else{
    cout << S << "s" << endl;
  }
}

Measured memory_bytes: 3596
#include<iostream>
#include<math.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int main() {
	int n;
	cin >> n;
	ll sum = 0;
	for (int i = 1; i <= n; i++) {
		if (i % 3 != 0 && i % 5 != 0) {
			sum += i;
			
		}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define int long long int
int32_t main() {
	string s;
	cin >> s;
	int f = 0;
	for (int i = 0; i < 3; ++i)
		if (s[i] == '7')
			f = 1;
	if (f)
		cout << "Yes";
	else
		cout << "No";
}


Measured memory_bytes: 3624
def palindrome(string): return 1 if string == string[::-1] else 0


s = input()
N = len(s)
# print(s[0:(N - 1) // 2])
# print(s[(N + 3) // 2 - 1:N])

if palindrome(s[0:(N - 1) // 2]) and palindrome(s[(N + 3) // 2 - 1:N]) and palindrome(s):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main()
{
    int N, K, d;
    double a, c = 0;
    cin >> N >> K;
    for (int n = 1; n <= N; n++)
    {
        for (int b = 1;; b *= 2)
        {
            d = n * b;
            if (d >= K)
            {
                a = 1.0 / (N * b);
                break;
            }
        }
        c = c + a;
    }
    printf("%.12lf\n", c);
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        final int number = new Scanner(System.in).nextInt();
        int[][] array = new int[10][10];
        /*
        - 123456789
        1 2
        2
        3
        4
        5
        6
        7
        8
        9
         */
        for (int i = 1; i <= number; i++) {
            int start = i;
            while(start >= 10) {
                start /= 10;
            }
            int end = i % 10;
            array[start][end]++;
        }
        long answer = 0;
        for(int i = 1; i <= 9; i++) {
            for(int j = 1; j <= 9; j++) {
                answer += array[i][j] * array[j][i];
            }
        }
        System.out.println(answer);
    }
}

Measured memory_bytes: 21844
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.Comparator;
import java.util.ArrayList;

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

    static class CDifferentStrokes {
        public void solve(int testNumber, Scanner in, PrintWriter out) {

            // 高橋君にとって、各皿は食べることによってa+bの価値があるのでその順に食えばいい
            // 青木にとってもそれは同じ

            int n = in.nextInt();
            ArrayList<Pair> p = new ArrayList<>();
            for (int i = 0; i < n; i++) {
                int a = in.nextInt();
                int b = in.nextInt();
                p.add(new Pair(a, b));
            }

            p.sort(Comparator.comparing(q -> -(q.x + q.y)));

            long res = 0;
            for (int i = 0; i < n; i++) {
                if (i % 2 == 0) {
                    res += p.get(i).x;
                } else {
                    res -= p.get(i).y;
                }
            }

            out.println(res);


        }

    }

    static class Pair {
        public long x;
        public long y;

        public Pair(long x, long y) {
            this.x = x;
            this.y = y;
        }

        public String toString() {
            return "Pair{" +
                    "x=" + x +
                    ", y=" + y +
                    '}';
        }

    }
}



Measured memory_bytes: 87020
#include<cstdio>
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
string s;
int main()
{
    cin>>s; 
    int len=s.size(); 
    for(int i=0;i<=len;i++) 
    {
        if(s[i]=='C') 
        {
            for(int j=i;j<=len;j++) 
            {
                if(s[j]=='F') 
                {
                    cout<<"Yes"<<endl; 
                    return 0;  
                }
            }
        }
    }
    cout<<"No"<<endl; 
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

long long n, a[200009], pre[200009], b, c;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		pre[i] = a[i];
		if (i) pre[i] += pre[i - 1];
	}
	long long hf = pre[n - 1] / 2;
	long long ans = 1e18;
	for (int i = 0; i < n - 1; i++) {
		long long tmp;
		if (pre[i] <= hf) {
			tmp = (hf - pre[i]) * 2;
			if (pre[n - 1]%2) tmp++;
		}
		else {
			tmp = (pre[i] - hf) * 2;
			if (pre[n - 1]%2) tmp--;
		}
		ans = min(ans, tmp);
	}
	cout << ans << E;
	//system("pause");
	return 0;
}

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

int main(){
  string s;
  cin >> s;
  int n = sz(s);
  int l = 0, r = 0;
  bool ok = false;
  rep(i,n-1) {
    if (s[i] == s[i+1]) {
      l = i + 1;
      r = i + 2;
      ok = true;
      break;
    }

    if (i < n -2 && s[i] == s[i+2]) {
      l = i + 1;
      r = i + 3;
      ok = true;
      break;
    }
  }
  if (ok) cout << l << " " << r << endl;
  else cout << -1 << " " << -1 << endl;
  return 0;
} 

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define FOR(i, i0, n) for(int i = (i0); i < (n); i ++)
#define COUT(val) cout << (val) << "\n";
using namespace std;

int main(void){
    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n);
    FOR(i, 0, n) cin >> a[i] >> b[i] >> c[i];
    
    vector<int> dpa(n), dpb(n), dpc(n);
    dpa[0] = a[0], dpb[0] = b[0], dpc[0] = c[0];
    
    FOR(i, 1, n){
        dpa[i] = max(dpb[i-1], dpc[i-1]) + a[i];
        dpb[i] = max(dpa[i-1], dpc[i-1]) + b[i];
        dpc[i] = max(dpa[i-1], dpb[i-1]) + c[i];
    }
    
    COUT(max(max(dpa[n-1], dpb[n-1]), dpc[n-1]));
}

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

using namespace std;

#define int long long

const int mod = 1e9 + 7;

void solve() {
    int s;
    cin >> s;
    vector <int> dp(s + 1);
    dp[0] = 1;
    for (int i = 1; i <= s; ++i) {
        for (int j = 3; j <= i; ++j) {
            dp[i] = (dp[i] + dp[i - j]) % mod;
        }
    }
    cout << dp[s];
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	solve();
	return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
//g++ -std=c++11 

using namespace std;
typedef long long ll;

#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define DIV 1000000007 //10^9+7

long long kaidan[10000000];

void kaical(long long n){
	kaidan[0] = 1;
	for(long long i = 1; i < n; i++){
		kaidan[i] = kaidan[i-1] * i;
		kaidan[i] %= DIV;
	}
}

long long modpow(long long ori, long long po){
	long long res = 1;
	while(po > 0){
		if(po&1){
			res *= ori;
			res %= DIV;
		}
		ori *= ori;
		ori %= DIV;
		po >>= 1;
	}
	return res;
}

//nCk
long long combination(long long n, long long k){
	if(n == 0 && k == 0)return 1;
	if(n < k || n < 0)return 0;
	long long n_kai = kaidan[n];
	long long k_kai = kaidan[k];
	long long nmk_kai = kaidan[n-k];

	long long ans = n_kai * modpow(k_kai, DIV - 2);
	ans %= DIV;
	ans *= modpow(nmk_kai, DIV-2);
	ans %= DIV;
	return ans;
}

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

	kaical(N*M);

	ll ans = 0;
	for(ll x = 1; x < M; x++) {
		ans += x * (M - x) * N * N * combination(N * M - 2, K - 2);
		ans %= DIV;
	}

	for(ll y = 1; y < N; y++) {
		ans += y * (N - y) * M * M * combination(N * M - 2, K - 2);
		ans %= DIV;
	}

	cout << ans << endl;
}

Measured memory_bytes: 5144
#include<cstdio>
#include<algorithm>
int ans = 0;
int x[] = {0,1,0,-1},y[] = {-1,0,1,0};
int in[100][100] = {{0}};
int s[100][100] = {{0}};
int n,m;
using namespace std;
int func(int i,int j,int cnt);
int main(){
    while(1){
        scanf("%d%d",&n,&m);
        ans = 0;
        if(n == 0 && m == 0)break;
        for(int i = 0;i < n; i++){
            for(int j = 0;j < m; j++){
                scanf("%d",&in[i][j]);
            }
        }
        int a = 0,b = 0;
        for(int i = 0;i < n; i++){
            for(int j = 0;j < m; j++){
                if(in[i][j] == 1)ans = max(ans,func(i,j,1));
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}
int func(int i,int j,int cnt){
    in[i][j] = 0;
    if(cnt > ans){
        ans = cnt;
    }

    for(int k = 0;k < 4; k++)if(in[i+x[k]][j+y[k]] && i+x[k] >= 0&& i+x[k] < n && j+y[k] >= 0 && j+y[k] < m){
                                    func(i+x[k],j+y[k],cnt+1);
                                }
    in[i][j] = 1;
    return ans;
}

Measured memory_bytes: 1068
int n;
char G[100][100]; // grid
static int di[4] = {-1, 0, 1, 0};
static int dj[4] = {0, 1, 0, -1};

int main(){
    int dir, width, i, j, a, w;
    int tcase; scanf("%d", &tcase);
    for ( int t = 0; t < tcase; t++ ){
      if ( t ) printf("\n");
      scanf("%d", &n);
      
      for ( i = 0; i < n; i++ )
        for ( j = 0; j < n; j++ ) G[i][j] = ' ';
      
      width = n - 1;
      i = width; j = dir = 0;
      
      for ( a = 1; a <= (n + n % 2); a++, dir = (dir + 1) % 4 ){
        for ( w = 0; w <= width; w++ ) G[i+di[dir]*w][j+dj[dir]*w] = '#';
        i += di[dir] * width;
        j += dj[dir] * width;
        if ( a % 2 == 1 && a >= 3 ) width -= 2;
      }
      
      for ( i = 0; i < n; i++ ){
        for ( j = 0; j < n; j++ ) printf("%c", G[i][j]);
        printf("\n");
      }
    }
}

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

#define int long long

using namespace std;

const int MOD = 1e9 + 7;

int n, m, x, y, ans, f[2000005];

int binpow(int a , int b){
	if(b == 0) return 1;
	if(b % 2 == 1) return (binpow(a, b - 1) * a) % MOD;
	int x = binpow(a, b / 2);
	return (x * x) % MOD;
}

main(){
    cin >> n >> m;
    f[0] = 1;
    for(int i = 1; i <= 2e6; i++){
    	f[i] = (i * f[i - 1]) % MOD;
    }
    for(int i = 0; i <= n; i++){
    	int a = i, b = (m - (2 * a));
    	x += a + 2 * b;
    	y += 2 * a + b;
    	if(x == n && y == m){
    		int o = a + b, k = (f[a] * f[b]) % MOD;
    		ans += (f[o] * binpow(k, MOD - 2)) % MOD;
    		ans %= MOD;
    	}
    	x = 0;
    	y = 0;
    }
    cout << ans % MOD;
}

Measured memory_bytes: 15872
#include<iostream>
using namespace std;
long long f(int sum, int end, long long (&data)[5100][55], int (&x)[55]);

int main()
{
    int n, a;
    cin >> n >> a;
    int x[55];
    for(int i = 0; i < n; i++){
        cin >> x[i];
        x[i] = x[i] - a;
    }
    long long data[5100][55];
    for(int i = 0; i < 5100; i++){
        for(int j = 0; j < 55; j++){
            data[i][j] = -1;
        }
    }
    int answer = 0;
    cout << f(0, n - 1, data, x) - 1 << endl;
    return 0;
}

long long f(int sum, int end, long long (&data)[5100][55], int (&x)[55])
{
    if(end == 0){
        int ans = 0;
        if(sum == x[0]){
            ans++;
        }
        if(sum == 0){
            ans++;
        }
        return ans;
    }
    if(data[sum + 2550][end] == -1){
        data[sum + 2550][end] = f(sum, end - 1, data, x) + f(sum - x[end], end - 1, data, x);
    }
    return data[sum + 2550][end];
}

Measured memory_bytes: 2432
var reader = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout
});

var line;
reader.on('line', (l) => {
  line = l;
});

reader.on('close', () => {
  var elems = line.split(' ');
  var A = elems[1];
  var B = elems[2];
  var win = Math.abs(B - A - 1) % 2 ? 'Alice' : 'Borys';
  console.log(win);
});

Measured memory_bytes: 11596
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>    // for pair
using namespace std;

#define rep(i,n) for(ll i = 0; i < (n); ++i)
#define rep1(i, n) for(ll i = 1; i < (n); ++i)
#define rep4(i, start, end, step) for (ll i = (start); i < (end); i += (step))

#define BIG_PRIME 1000000007
#define BP_remainder(x) ((x) % BIG_PRIME)

#define INF 0x3fffFFFF
#define INF_NEG (INF * -1)
#define INF_LONG (INF << 32)
#define INF_LONG_NEG (INF_LONG * -1L)

typedef long long ll;
typedef pair<ll, ll> lpair;
typedef char str255[256];
// char *用、strlen の ll 版
ll StrLen(char *s) { for(ll ptr = 0L;; ++ptr) if(!s[ptr]) return ptr; } 
// char * の後ろから n 文字削除, 削除後の文字数を返す
ll StrDel(char *s, int n) { ll l = StrLen(s); s[l - n + 1L] = '\0'; return l - n; }
// 正の整数の桁数
ll NumDigits(ll l){ char s[30]; sprintf(s, "%lld", l); return StrLen(s); }

int isFirst = 1;
template <class T> 
void print(T t) { if (isFirst) cout << t, isFirst = 0; else cout << " " << t; }

void chmin(ll& a, ll b) { if (a > b) a = b; }
void chmax(ll& a, ll b) { if (a < b) a = b; }

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

signed main()
{
    ll N, K; cin >> N >> K;
    ll md = N % K;
    ll md2 = abs(md - K);
    ll ans = min(md, md2);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int P[3][3],tmp[3][3];
int Dx[4] = {0,1,0,-1};
int Dy[4] = {1,0,-1,0};
void emp(int *x,int *y) {
  int i,j;
  for(i=0; i<3; i++) {
    for(j=0; j<3; j++) {
      if(!P[i][j]) {
	*x = j;
	*y = i;
      }
    }
  }
}
void swap(int *s,int *v){
  int tmp;
  tmp = *s;
  *s = *v;
  *v = tmp;
}   
int calc(){
  int i,t,sum=0; 
  for(i=0; i<9; i++){
    t = P[i/3][i%3];
    if(t){
      t--;
      sum += abs(i/3 - t/3) + abs(i%3 - t%3);
    }
  }    
  return sum;
}
int dfs(int x,int y,int p,int d,const int lim){
  int i,hi,x2,y2,res;   
  hi = calc();
  if(hi==0) {
    return d;
  }
  if(d+hi>lim) {
    return -1;
  }
  for(i=0; i<4; i++){
    x2 = x+Dx[i];
    y2 = y+Dy[i];      
    if(~p && i==(p+2)%4) continue;
    if(!(0<=x2 && x2<3 && 0<=y2 && y2<3)) continue;    
    swap(&P[y][x],&P[y2][x2]);
    res = dfs(x2,y2,i,d+1,lim);
    if(~res) {
      return res;
    }
    swap(&P[y][x],&P[y2][x2]);
  }   
  return -1;
}    
int main() {
  int i,j,l,ans,x,y;
        
  for(i=0; i<3; i++){
    for(j=0; j<3; j++) scanf("%d",&P[i][j]);
  }
         
  emp(&x,&y);
  for(l=0; l<100; l++){
    for(i=0; i<3; i++){
      for(j=0; j<3; j++) tmp[i][j] = P[i][j];
    }
            
    ans = dfs(x,y,-1,0,l);
    if(ans!=-1){
      printf("%d\n",ans);
      break;
    }
            
    for(i=0; i<3; i++){
      for(j=0; j<3; j++) P[i][j] = tmp[i][j];
    }
            
    ans = -1;
    if(l==99) printf("%d\n",ans);
  }
        
  return 0;
}



Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
int  main(){
	int n,flag=0;
	cin>>n;
	while(n){
		int x=n%10;
		n/=10;
		if(x==7){
			flag=1;
			break;
		}
	}
	if(flag==1)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 3616
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#pragma warning(disable:4786)
#pragma warning(disable:4996)
#include <ctime>
#include<list>
#include <numeric>
#include<bitset>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<functional>
#include<string>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<utility>
#include<fstream>
#include<sstream>
#include<cmath>
#include<stack>
#include<assert.h>
#include<unordered_map>
#include<unordered_set>
using namespace std;

#define MEM(a, b) memset(a, (b), sizeof(a))
#define CLR(a) memset(a, 0, sizeof(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )
#define S(X) ( (X) * (X) )
#define SZ(V) (int )V.size()
#define FORN(i, n) for(int i = 0; i < n; i++)
#define FORAB(i, a, b) for(int i = a; i <= b; i++)
#define ALL(V) V.begin(), V.end()
#define IN(A, B, C)  ((B) <= (A) && (A) <= (C))
#define AIN(A, B, C) assert(IN(A, B, C))

//typedef int LL;
typedef long long int LL;
//typedef __int128 LL;
//typedef __int64 LL;

typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<long double, long double> PDD;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII > VP;
typedef vector<double> VD;
typedef vector<LL> VL;
typedef long double ld;

void solve(int ks) {
	int n;
	char s[3][1003];
	scanf("%d", &n);
	for (int i = 0; i < 3; i++) scanf("%s", s[i]);
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (s[0][i] == s[1][i] && s[0][i] == s[2][i]) continue;
		else if (s[0][i] == s[1][i] || s[0][i] == s[2][i] || s[1][i] == s[2][i]) {
			ans++;
		}
		else {
			ans += 2;
		}
	}
	printf("%d\n", ans);
}

int main()
{
#ifdef LOCAL
	double start_time = clock();
	freopen("C:\\Home\\ContestCodes\\sample.in", "r", stdin);
	//	freopen("out.out", "w", stdout);
#endif

	if (0) {
		int T;
		scanf("%d", &T);
		for (int ks = 1; ks <= T; ks++) solve(ks);
	}
	else {
		solve(0);
	}

#ifdef LOCAL
	double end_time = clock();
	fprintf(stderr, "Time = %lf\n", (end_time - start_time) / CLOCKS_PER_SEC);
#endif

	return 0;
}


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

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

    cout << h << ":" << i << ":" << s << endl;

    return 0;
}


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

 
int main() {
  string s,t;
  int f=0;
  cin >> s >> t;
  for(int i=0;i<s.length();i++){
    if(s.at(i)!=t.at(i))
      f=1;
  }
  if(s.length()+1!=t.length())
    f=1;
  
  if(f==0){
    cout << "Yes" << endl;
  }else{
    cout << "No"<< endl;
  }
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using mii = map<int, int>;
using mll = map<ll, ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vpi = vector<pii>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpl = vector<pll>;
using vs = vector<string>;

int main()
{
    int n, m, x;
    cin >> n >> m >> x;
    vector<pair<int, vi>> mp;
    for(int i=0; i<n; i++)
    {
        int c;
        cin >> c;
        vi as;
        for(int j=0; j<m; j++)
        {
            int a;
            cin >> a;
            as.push_back(a);
        }
        mp.push_back(make_pair(c, as));
    }

    int nax = 1300000;
    for(int bit=0; bit < (1<<n); bit++)
    {
        int cost = 0;
        vi t(m, 0);
        for(int i=0; i<n; i++)
        {
            if(bit & (1<<i))
            {
                cost += mp.at(i).first;
                for(int j=0; j<m; j++)
                {
                    t.at(j) += mp.at(i).second.at(j);
                }
            }
        }
        bool h = true;
        for(auto num : t)
        {
            if(num < x) h = false;
        }
        if(h && nax > cost)
        {
            nax = cost;
        }
    }
    if(nax == 1300000) cout << -1 << endl;
    else cout << nax << endl;

    return 0;
}


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

int main(void)
{
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    
    int t_die, a_die;

    t_die = A/D;
    if (A%D)
    {
        t_die++;
    }
    a_die = C/B;
    if (C%B)
    {
        a_die++;
    }
    
    

    if (t_die >= a_die)
    {
        cout << "Yes" << endl;
    }else
    {
        cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3628
n,k = map(int,input().split())
r,s,p = map(int,input().split())
t=input()
text = {"r":"p","s":"r","p":"s"}
tokutenn = 0
def dasu(te):
  if te=="r":
    return r
  if te=="s":
    return s
  if te=="p":
    return p
nons = list(range(n))
for i in range(n):
  non = "" if (i < k or nons[i-k][1]=="2") else nons[i-k][0]
  tei = text[t[i]]
  ts=dasu(tei)
  if k==i+1:
    tokutenn+=ts
    nons[i]=text[t[i]]+"0"
  else:
    if tei!=non:
      tokutenn+=ts
      nons[i]=text[t[i]]+"1"
    else:
      nons[i]=text[t[i]]+"2"
print(tokutenn)

Measured memory_bytes: 9588
#include <bits/stdc++.h>
#include <algorithm>
#include <stdio.h>
#include <math.h>
using namespace std;

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)

typedef long long ll;
typedef pair<int,int> P;
typedef pair<P,int> PP;

struct edge {
	int to,cost;
	edge(int t,int c):to(t),cost(c) {}
};

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

ll mypow(ll x,ll n,ll m) {	//xのn乗をmで割った余り
	if(n==0) return 1;
	if(n%2==0) return mypow(x*x%m,n/2,m);
	else return x*mypow(x,n-1,m)%m;
}

//-----------------------------------------------------------------------------

int n;
vector<int> ta,ha;
set<int> st;
bool used[201];
int ct,ch;

void dfs(int now,int turn) {
	if(ct==0) {
		cout<<ch<<endl<<0<<endl;
		return;
	}
	if(ch==0) {
		cout<<0<<endl<<ct<<endl;
		return;
	}
	if(turn==0) {
		bool flg=false;
		REP(i,ta.size()) {
			if(used[ta[i]]) continue;
			if(ta[i]>now) {
				used[ta[i]]=true;
				flg=true;
				ct--;
				dfs(ta[i],1);
				break;
			}
		}
		if(!flg) {
			dfs(0,1);
		}
	}
	else {
		bool flg=false;
		REP(i,ha.size()) {
			if(used[ha[i]]) continue;
			if(ha[i]>now) {
				used[ha[i]]=true;
				flg=true;
				ch--;
				dfs(ha[i],0);
				break;
			}
		}
		if(!flg) {
			dfs(0,0);
		}
	}
}

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

    while(true) {
	cin>>n;
	ta.clear(),ha.clear();
	st.clear();
	REP(i,201) used[i]=false;
	ct=0,ch=0;
	if(n==0) break;
	REP(i,n) {
		int vv;cin>>vv;
		st.insert(vv);
	}
	FOR(i,1,2*n+1) {
		if(st.find(i)==st.end()) ha.pb(i);
		else ta.pb(i);
	}
	ct=n,ch=n;
	dfs(0,0);
    }

	return 0;
}



Measured memory_bytes: 3128
import java.util.Scanner;

public class Main {
	int[] A;
	int[] m;
	int n;

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

	void run() {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		A = new int[n];
		for (int i = 0; i < n; i++) {
			A[i] = sc.nextInt();
		}

		int q = sc.nextInt();
		m = new int[q];
		for (int i = 0; i < q; i++) {
			m[i] = sc.nextInt();
		}

		for (int i = 0; i < q; i++) {
			if (rec(0, m[i])) {
				System.out.println("yes");
			} else {
				System.out.println("no");
			}
		}

		sc.close();
	}

	boolean rec(int i, int num) {
		if (i == n) {
			if (num == 0) {
				return true;
			} else {
				return false;
			}
		}

		boolean res = false;
		res = rec(i + 1, num) || rec(i + 1, num - A[i]);

		return res;
	}
}

Measured memory_bytes: 26720
#include <bits/stdc++.h>
#define itn int
#define gI gi
#define int long long

using namespace std;

typedef long long ll;

inline int gi()
{
	int f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

inline ll gl()
{
	ll f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

const int N = 200003, maxn = 16003, maxm = 5003, mod = 1000000007;

int inv[maxn], jc[maxn], f[maxm][maxm];
int n, m, x[N], y[N], ans;

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

inline int C(int x, int y) 
{
	return jc[x] % mod * inv[y] % mod * inv[x - y] % mod;
}

signed main()
{
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	n = gi();
	int ds = 2002;
	jc[0] = 1;
	for (int i = 1; i <= 8000; i+=1) jc[i] = jc[i - 1] * i % mod;
	inv[8000] = qpow(jc[8000], mod - 2);
	for (int i = 7999; i >= 0; i-=1) inv[i] = inv[i + 1] * (i + 1) % mod;
	for (int i = 1; i <= n; i+=1) 
	{
		x[i] = gi(), y[i] = gi();
		++f[ds - x[i]][ds - y[i]];
	}
	for (int i = 1; i <= ds + 2000; i+=1)
	{
		for (int j = 1; j <= ds + 2000; j+=1)
		{
			f[i][j] = (1ll * f[i][j] + f[i - 1][j] + f[i][j - 1]) % mod;
		}
	}
	for (int i = 1; i <= n; i+=1)
	{
		(ans += f[ds + x[i]][ds + y[i]]) %= mod;
		//cout << ans << endl;
		(ans -= C(x[i] * 2 + y[i] * 2, x[i] * 2)) %= mod;
		//cout << ans << endl << endl;
	}
	(ans += mod) %= mod;
	(ans *= 500000004) %= mod;
	printf("%lld\n", ans % mod);
	return 0;
}

Measured memory_bytes: 160128
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template<typename key>
using ordered_set = tree<key, null_type, less<key>, rb_tree_tag, tree_order_statistics_node_update>;
#define F first
#define S second
#define T second.first
//#define C second.second
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);
#define all(v) v.begin(),v.end()
#define OO 0x3f3f3f3fLL
#define INF 0x3f3f3f3f3f3f3f3fLL
#define sz(s) (int)(s.size())
#define RT(s) return cout<<s,0
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef pair<ll,pair<ll,ll>> piii;
const int N = 2e5+5, M= 20, mod = 1000000000;
const double EPS = 1e-10;


int main(){
    FIO
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    string s, t;
    cin>>s>>t;
    int ans = 0;
    for(int i=0; i<sz(s); i++){
        if(s[i] != t[i])ans++;
    }
    cout<<ans;

}


Measured memory_bytes: 3872