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

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cerr << #a << " = " << a << endl;

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	bool ok = 1;
	int n;
	cin >> n;
	while(n--)
	{
		int x;
		cin >> x;
		if (x & 1) continue;
		ok &= (x % 3 == 0 || x % 5 == 0);
	}
	cout << (ok ? "APPROVED" : "DENIED") << endl;
	
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  int N, M; cin >> N >> M;
  vector<bool> AC(N, false);
  vector<int> WA(N, 0);
  int AC_count = 0, WA_count = 0;
  for(int i = 0; i < M; i++) {
    int p; string s;
    cin >> p >> s;
    p--;
    if(s == "AC") {
      AC.at(p) = true;
    } else {
      if(!AC.at(p)) {
        WA.at(p)++;
      }
    }
  }
  for(int i = 0; i < N; i++) {
    if(AC.at(i)) {
      AC_count++;
      WA_count += WA.at(i);
    }
  }
  cout << AC_count << " " << WA_count << endl;
}


Measured memory_bytes: 640
// finish date: 2018/03/13

#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi vector<vector<vector<int>>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define bigmod 1000000007
#define INF 1050000000
#define pii pair<int,int>


int checkLIS(vector<int> a) {
    vi minVal(a.size() + 1, INF);
    minVal[0] = -INF;
    rep(i, a.size()) {
        *upper_bound(minVal.begin(), minVal.end(), a[i]) = a[i];
    }
    for (int i = minVal.size() - 1; i >= 0; i--) {
        if (minVal[i] != INF) return i;
    }
    return 0;
}


int main() {
    int N, A, B;
    cin >> N >> A >> B;
    vi ans(N, -1);
    if (B > N) {
        cout << -1 << endl;
        return 0;
    }
    int a = 0;
    rep(i, B) ans[B - 1 - i] = i + 1;
    int tempIdx = B;
    a = 1;
    while (tempIdx != N) {
        int kosuu = max(min(a + 1 + N - tempIdx - A, B), 1);
        if (tempIdx + kosuu > N) {
            cout << -1 << endl;
            return 0;
        }
        FOR(i, tempIdx, min(tempIdx + kosuu, N)) {
            ans[2 * tempIdx + kosuu - 1 - i] = i + 1;
        }
        tempIdx += kosuu;
        a++;
    }
    int checkA = checkLIS(ans);
    reverse(ans.begin(), ans.end());
    int checkB = checkLIS(ans);
    reverse(ans.begin(), ans.end());
    if (checkA == A && checkB == B) {
        rep(i, N) cout << ans[i] << " ";
        cout << endl;
    } else {
        cout << -1 << endl;
    }

    return 0;
}

Measured memory_bytes: 3800
#include<stdio.h>

int main(){
	char a,b,c;
	scanf("%c%c%c",&a,&b,&c);
	int flag=1;
	if(a=='A'&&b=='A'&&c=='A')flag=0;
	if(a=='B'&&b=='B'&&c=='B')flag=0;
	if(flag)printf("Yes");
	else printf("No");
	return 0;
} 

Measured memory_bytes: 128
def nex(s):
    ketsu = int(s[-1])
    if ketsu ==0: return ['0','1']
    elif ketsu ==9: return ['8','9']
    else:return list(map(str,[ketsu-1,ketsu,ketsu+1]))



k = int(input())
runrun = ['1','2','3','4','5','6','7','8','9']
point = 0
while True:
    if len(runrun) >= k: break
    else:
        run = runrun[point]
        for i in nex(run):
            runrun.append(run+i)
        point +=1

print(runrun[k-1])

Measured memory_bytes: 10484
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(v) v.begin(),v.end()
#define mem(arr) memset(arr, 0, sizeof(arr))
#define ff first
#define ss second
#define int long long int
const int MOD = 1e9 + 7;
const int INF = 1e18;
const int N = 1e6 + 20;
vector<int> g[N];
vector<int> vis(N);
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tc = 1;
    while(tc--){
        int n, k;
        cin >> n >> k;
        int a[n];
        for(int &it : a){
            cin >> it;
        }
        sort(a, a + n);
        int sum = 0;
        for(int i = 0; i < k; i++){
            sum += a[i];
        }
        cout << sum << '\n';
    }
}

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

using namespace std;

#define COUNTOF(array) (sizeof(array) / sizeof(array[0]))
#define OUT(P) cout << (P) << endl
#define OUT2(P1, P2) cout << (P1) << " " << (P2) << endl
#define PRINT_ARRAY(P) for(int i=0; i<P.size(); i++) cout << P[i] << endl;
#define PRINT_ARRAY_INLINE(P) do { for(int i=0; i<P.size(); i++) cout << P[i] << " "; cout << endl; } while(0)
#define PRINT_ARRAY_WITH_LABEL(L, P) do { cout << L << ": "; PRINT_ARRAY_INLINE(P); cout << endl; } while(0)
typedef long long ll;

int sum_digits(int num);
template <class T>
vector<T> copy_vector(vector<T> vec);
int gcd(int a, int b);

#define WHITE '.'
#define BLACK '#'

int main() {
    int n;
    string s;
    cin >> n >> s;
    
    int num_white = 0;
    for(int i=0; i<n; i++) {
        if(s[i] == WHITE) {
            num_white++;
        }
    }
    int left_black = 0;
    int right_white = num_white;
    int cnt = left_black + right_white;
    for(int i=0; i<n; i++) {
        if(s[i] == WHITE) {
            right_white--;
        } else {
            left_black++;
        }
        int tmp = right_white + left_black; 
        if(cnt > tmp) {
            cnt = tmp;
        }
    }
    cout << cnt << endl;
    return 0;
}

/******************************/
/***** DECRARED FUNCTIONS *****/
/******************************/

int sum_digits(int num) {
    int rtn = 0;
    while(num != 0) {
        int tmp = num % 10; 
        rtn += tmp;
        num /= 10; 
    }   
    return rtn;
}
//int sum_digits(int num) {
//    int rtn = 0;
//    string num_str = to_string(num);
//    for(int i=0; i<num_str.size(); i++) {
//        rtn += num_str[i] - '0';
//    }   
//    return rtn;
//}

// vectorのコピー
template <class T>
vector<T> copy_vector(vector<T> vec) {
    vector<T> rtn;
    rtn.reserve(vec.size());
    copy(vec.begin(), vec.end(), back_inserter(rtn));
    return rtn;
}

// ユークリウッドの互除法
int gcd(int a, int b) {
    if(b==0) return a;
    else return gcd(b, a % b);
}



Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define int ll
#define pb push_back
#define setbits(x)          __builtin_popcountll(x)
#define endl "\n"
typedef long long ll;
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int a,b,c;
  cin>>a>>b>>c;
  swap(b,c);
  swap(a,b);
  cout<<a<<" "<<b<<" "<<c<<endl;
    return 0;
}

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

struct UnionFind{
    vector<int> parent,size;
    
    UnionFind(int n): parent(n,-1),size(n,1){}
    void init(int n){ 
        parent.assign(n,-1);
        size.assign(n,1);
        return;
    }

    int root(int x){
        if (parent[x]<0) return x;
        else return parent[x] = root(parent[x]);
    }

    bool same(int x, int y){
        return root(x)==root(y);
    }

    void unite(int x,int y){
        int gx = root(x);
        int gy = root(y);
        if (gx==gy) return;
        else{
            if(size[gx]<size[gy]){
                size[gy]+=size[gx];
                parent[gx]=gy;
            } else{
                size[gx]+=size[gy];
                parent[gy]=gx;
            }
        }
    }
    int get_size(int x){
        return size[root(x)];
    }    
};

int main(){
    long long n,m; cin >> n >> m;
    vector<int> a(m),b(m);
    for (int i=0;i<m;i++){
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
    }
    UnionFind uf(n);
    long long num = (n-1)*n/2;
    vector<long long> res;
    for (int i=m-1;i>=0;i--){
        res.push_back(num);
        if (uf.same(a[i],b[i])) continue;
        else{
            num -= uf.get_size(a[i]) * uf.get_size(b[i]);
            uf.unite(a[i],b[i]);
        }
    }
    reverse(res.begin(),res.end());
    for (int i=0;i<m;i++){
        cout << res[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define ve vector
#define chmin(x,y) x = min(x,y)

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


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

using namespace std;

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

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

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

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

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

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

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

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

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

int main() {
  int n, s;

  cin >> n;
  REP(i, n) {
    cout << "Case " << i+1 << ':' << endl;
    cin >> s;
    REP(j, 10) {
      s = s*s;
      s = (s%1000000) / 100;
      cout << s << endl;
    }
  } 
}

Measured memory_bytes: 1160
#include <iostream>
#include <queue>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <set>
using namespace std;

int main(void){
    int n;
    int x[4];
    cin>>n;
    for(int i=3;i>=0;i--,n/=10)x[i]=n%10;
    
    for(int i=-1;i<2;i++){
        for(int j=-1;j<2;j++){
            for(int k=-1;k<2;k++){
                if(i&&j&&k&&x[0]+i*x[1]+j*x[2]+k*x[3]==7){
                    cout<<x[0];
                    if(i>0)cout<<'+';
                    else cout<<'-';
                    cout<<x[1];
                    if(j>0)cout<<'+';
                    else cout<<'-';
                    cout<<x[2];
                    if(k>0)cout<<'+';
                    else cout<<'-';
                    cout<<x[3]<<"=7\n";
                    return 0;
                }
            }
        }
    }
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;
int main(){
	for(int i=0;i<5;i++){
		int B[10];
		for(int i=0;i<10;i++){
			cin >> B[i];
			if(B[i] == 0){
				return 0; //プログラムの強制終了
			}
		}

		int sum = 0;

		for(int i=1;i<10;i++){
			sum += B[i];
		}

		cout << B[0] - sum << endl;
	}
	return 0;

}


Measured memory_bytes: 3092
#include <iostream>
#include<list>
#include<algorithm>
using namespace std;

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

	list<int> v;

	while (n--)
	{
		int a;
		cin >> a;
		v.push_back(a);
	}

	int q;
	cin >> q;

	while (q--)
	{
		int b, e;
		cin >> b >> e;

		list<int>::iterator itr1 = v.begin(), itr2 = itr1;
		advance(itr1, b);
		advance(itr2, e);

		reverse(itr1, itr2);
	}

	for (list<int>::iterator itr = v.begin(); itr != v.end(); itr++) {
		if (itr != v.begin()) {
			cout << " ";
		}

		cout << *itr;
	}

	cout << endl;

	return 0;
}


Measured memory_bytes: 3112
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
char f[300][300];
bool used[300][300];
int n;
int ans;
int dx[4]={1,0,1,1};
int dy[4]={0,1,-1,1};
void dfs(int x,int y,int d,int k)
{
	if(x<0||x>=n||y<0||y>=n)return;
	if(used[x][y])return;
	if(f[x][y]=='0')return;
	ans=max(ans,d);
	dfs(x+dx[k],y+dy[k],d+1,k);
	return;
}
void solve(int k)
{
	memset(used,false,sizeof(used));
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			dfs(i,j,1,k);
		}
	}
	return ;
}
int main()
{
	while(1)
	{
		ans=0;
		cin >> n;
		if(n==0)break;
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<n;j++)
			{
				cin >> f[i][j];
			}
		}
		for(int i=0;i<4;i++)solve(i);
		cout << ans << endl;
	}
	return 0;
}

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

int main(void){
  int n, tmp = 0;
  cin >> n;
  vector<int> d(n,0);
  for(int i = 0; i < n; i++){
    cin >> d.at(i);
  }
  for(int i = 0; i < n; i++){
    for(int j = i + 1; j < n; j++){
      tmp += d.at(i) * d.at(j);
    }
  }
  cout << tmp << endl;
  return 0;
}

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

#define LL long long

void solve(long *arr, int len){
    int min_pos = -1, i, n_count = 0;
    long tmp, min = 1e9 + 100;
    LL sum = 0;
    for(i = 0; i < len; ++i) {
        if(arr[i] < 0) { ++n_count; }
    }
    if(n_count % 2 != 0) {
        for(i = 0; i < len; ++i) {
            tmp = arr[i];
            if(tmp < 0) { tmp *= -1; }
            if(tmp < min) { min = tmp; min_pos = i;}
        }

        for(i = 0; i < len; ++i) {
            if(i == min_pos) {
                sum += (arr[i] > 0) ? -1*arr[i] : arr[i];
            }
            else {
                sum += (arr[i] < 0)? -1*arr[i] : arr[i];
            }
        }
    }
    else {
        for(i = 0; i < len; ++i) {
            sum += (arr[i] < 0)? -1*arr[i] : arr[i];
        }
    }
    printf("%lld\n", sum);
}

int main()
{
    int n, i;
    scanf("%d", &n);
    long *a = (long*)malloc((n+7)*sizeof(long));
    for(i = 0; i < n; ++i) { scanf("%ld", &a[i]); }
    solve(a, n);
    return 0;
}

Measured memory_bytes: 896
#include<stdio.h>


int main()
{
	long long int x;
	scanf("%lld",&x);
	long long int i,sum=0;
	for (i=1;1;i++)
	{
		sum += i;
		if (sum>=x)
			break;
	}	
	printf("%lld",i);
	
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define pb push_back
#define pob pop_back
#define vi vector<ll>
#define mp make_pair
#define sz size()
#define rep1(i,n) for(i=1;i<=n;i++)
#define ll long long int
#define rep(i,n) for(i=0;i<n;i++)
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define maxx 10000005
#define en "\n"
#define se second
#define fi first
#define vs vector<string>
#define edge pair<ll,ll>
#define mod 1073741824
using namespace std;
 
 
// ¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++++++++¦¦¦++++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦++++++++++++¦¦¦¦¦¦¦¦¦¦+++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦++++++++¦¦¦¦¦+++++++¦++¦¦
// ¦¦¦¦¦¦¦¦++¦¦¦¦¦¦++++++¦¦¦¦+++++++++++++¦
// ¦¦¦¦¦¦¦++++++¦¦¦++++++¦¦++++++++++++++¦¦
// ¦¦¦¦¦¦¦+++++++¦¦¦+++++++++++++++++++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦++++++¦¦¦¦¦¦¦¦¦++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++¦¦¦¦¦¦¦¦+++++++¦ 
// ¦¦¦¦¦¦¦¦¦¦++¦¦¦¦¦¦¦+++++++++++++++++++¦¦
// ¦¦¦¦¦¦¦++++¦¦¦¦¦¦¦¦+++++++++++++++++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++++++++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++++++++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++++++++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++++++++++¦¦ 
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦++++++++++++++++++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦++++++++++++¦¦+¦++¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++¦¦+++++¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+¦¦¦¦+++¦¦¦¦++++++¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++¦¦+¦¦¦¦¦+++++++¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++++++++++¦¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦++++++++++++++++¦¦¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++¦¦¦¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+¦¦¦+++++++++++¦¦¦¦¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++¦¦¦¦¦¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦++++++++¦¦¦¦¦¦¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦++++++¦¦¦¦¦¦¦¦¦¦¦¦


//ll d[1000007];
int main()
{
	fast;
	ll n;
	cin>>n;
	ll i;
	ll a[n];
	vector<ll>g[n];
	ll f[n+1]={0};
	for(i=2;i<=n;i++)
	{
		cin>>a[i];
		g[a[i]].pb(i);
	}
	for(i=1;i<n;i++)
	{
		cout<<g[i].size()<<endl;
	}
	cout<<0<<endl;
	return 0;
	
}	
//cout<<"YES"<<endl;

//cout<<"NO"<<endl;

Measured memory_bytes: 17640
#include <iostream>
#include <map>
using namespace std;
int main(){
	
	int n,m,k;
	cin>>n>>m>>k;
	int nm=n*m;
	map <int,bool> a;
	for(int i=0;i<=n;i++){
		for(int j=0;j<=m;j++){
			if(n*j+m*i-i*j*2>=0) a[n*j+m*i-i*j*2]=true;
			//if(n*j+m*i-i*j*2>=0) a[n*j+m*i-n*i*2]=true;
		}
	}
	if(a[k]) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

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

int main(int argc, const char * argv[]) {
    int a,b,c;
    cin >> a >> b >> c;
    if (a != b){
        if (b != c){
            if (a != c){
               cout << 3;
            } else {
                cout << 2;
            }
        } else {
            cout << 2;
        }
    } else {
        if (b == c){
            cout << 1;
        } else {
            cout << 2;
        }
    }
    return 0;
} 

Measured memory_bytes: 256
import java.util.Scanner;
public class Main
{
	public static void main(String aeg[])
	{
		Scanner in = new Scanner(System.in);
		int a[]= new int[3];
		while(in.hasNext())
		{
			a[0]=in.nextInt();
			a[1]=in.nextInt();
			a[2]=in.nextInt();
			if((a[0]|a[1]|a[2])==-1)
				return;
			int re=7200-a[0]*3600-a[1]*60-a[2];
			a[0]=re/3600;
			a[1]=(re%3600)/60;
			a[2]=(re%3600)%60;
			String a0 = String.valueOf(a[0]);
			String a1 = String.valueOf(a[1]);
			String a2 = String.valueOf(a[2]);
			if(a0.length()<2)
				a0="0"+a0;
			if(a1.length()<2)
				a1="0"+a1;
			if(a2.length()<2)
				a2="0"+a2;
			System.out.println(a0+":"+a1+":"+a2);
			re*=3;
			a[0]=re/3600;
			a[1]=(re%3600)/60;
			a[2]=(re%3600)%60;
			String b0 = String.valueOf(a[0]);
			String b1 = String.valueOf(a[1]);
			String b2 = String.valueOf(a[2]);
			if(b0.length()<2)
				b0="0"+b0;
			if(b1.length()<2)
				b1="0"+b1;
			if(b2.length()<2)
				b2="0"+b2;
			System.out.println(b0+":"+b1+":"+b2);
		}
	}
}

Measured memory_bytes: 12000
import fractions

n, ma, mb = map(int,input().split())
a = [0] * (n + 1)
b = [0] * (n + 1)
c = [0] * (n + 1)
for i in range(1, n + 1):
    a[i], b[i], c[i] = map(int,input().split())

#iまでの薬品で、aがj(g),bがk(g)となるときの最小コスト
dp = [[[10**15 for i in range(n + 1)] for j in range(401)] \
    for k in range(401)]

dp[0][0][0] = 0
sa = [0] * (n + 1)
sb = [0] * (n + 1)

for i in range(1, n + 1):
    sa[i] = sa[i - 1] + a[i]
    sb[i] = sb[i - 1] + b[i]

for i in range(1, n + 1):
    for j in range(401):
        if j > sa[i]:
            break
        for k in range(401):
            if k > sb[i]:
                break
            # i番目を買うか、買わないか
            if j < a[i] or k < b[i]:
                dp[k][j][i] = dp[k][j][i - 1]
            else:
                dp[k][j][i] = min(dp[k][j][i - 1], \
                    dp[k - b[i]][j - a[i]][i - 1] + c[i])

i = 1
ans = 10 ** 15
while True:
    if i * ma > 400 or i * mb > 400:
        break
    ans = min(ans, dp[i * mb][i * ma][n])
    i += 1

if ans == 10 ** 15:
    ans = -1

print(ans)


Measured memory_bytes: 137176
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define PI 3.14159265359
#define MOD 1000000007
typedef long long LL;

template<class T> inline void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> void print_vector(vector<T> vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << vec[i] << " ";
	}
	cout << "]" << endl;
}
template<class T> void print_pair_vector(vector<pair<T, T> > vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << "(" << vec[i].first << "," << vec[i].second << ") ";
	}
	cout << "]" << endl;
}

const int INF = 1 << 30;

int main(void) {
	LL N;
	cin >> N;

	vector<LL> b(N + 1);
	for (int i = 1; i <= N; i++) {
		cin >> b[i];
	}

	vector<LL> ans;
	while(b.size() != 1){
		for (LL i = LL(b.size()) - 1; i >= 1; i--) {
			if (b[i] == i) {
				ans.push_back(i);
				b.erase(b.begin() + i);
				break;
			}

			if (i == 1) {
				cout << -1 << endl;
				return 0;
			}
		}
	}
	for (int i = ans.size() - 1; i >= 0; i--) {
			cout << ans[i] << endl;
	}
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <queue>
#include <cstring>
#include <map>
#include <cmath>
#include <algorithm>
#include <stack>
using namespace std;


int main()
{
    long long a,b,c,d;
    cin >> a >> b >> c >> d;
    if(abs(a-c) <= d || (abs(a-b) <= d && abs(b-c) <= d)){
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = pow(10, 9) + 7;
//const int MOD = 998244353;
//const int MOD = ;
int mod(int A, int M) {return (A % M + M) % M;}
const int INF = 1LL << 60;
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string abc = "abcdefghijklmnopqrstuvwxyz";
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}

signed main()
{
  int N;
  cin >> N;
  vector<int> h(N);
  for (int i = 0; i < N; i++)
  {
    cin >> h.at(i);
  }
  h.push_back(0);

  int ans = 0;
  while (true)
  {
    bool flg0 = false;
    bool flgfin = true;

    for (int i = 0; i < N + 1; i++)
    {
      if (h.at(i) == 0)
      {
        if (flg0)
        {
          flg0 = false;
          ans++;
        }
      }
      else 
      {
        flgfin = false;
        flg0 = true;
        h.at(i)--;
      }
    }
    
    if (flgfin) break;
  }

  cout << ans << endl;
}

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

typedef long long ll;

ll pow(ll x, int n) {
  if ( n == 0 ) return 1;
  ll res = pow(x*x,n/2);
  if(n&1) res = res*x;
  return res;
}

int main() {
  //cout <<"=====" <<pow(2,3) << endl;
  int N,M; cin >> N >> M;
  int X = 1900*pow(2,M)*M;
  //cout << 1900*pow(2,M) << endl;

  X += (N-M)*100*pow(2,M);    
  // cout << (N-M)*100*pow(2,M) << endl;
  cout << X << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  int a[25],b[25],c[25];
  int ans = 0; 
  cin >> n;
  a[0] = -1;
  for(int i=1; i<=n; i++) cin >> a[i];
  for(int i=1; i<=n; i++) cin >> b[i];
  for(int i=1; i<n; i++) cin >> c[i];

  for(int i=1; i<=n; i++){
    if(a[i] - a[i-1] == 1) ans += c[a[i]-1];
    ans += b[a[i]];
  }

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


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>

using namespace std;

int main(void) {
	int N, K;
	long long int ans = 0, bg = 0, tgt = 0;

	cin >> N >> K;

	vector<int> a(N);

	for (int i = 0; i < N; i++) cin >> a[i];

	for (int i = 0; i < K; i++) tgt += a[i];
	for (int i = K; i < N; i++) bg += max(0, a[i]);

	ans = max(ans, max(bg + tgt, bg));

	for (int i = 0; i < N - K; i++) {
		bg += -max(a[i + K], 0) + max(0, a[i]);
		tgt += a[i + K] - a[i];

		ans = max(ans, max(bg + tgt, bg));
	}

	cout << ans << endl;

	system("pause");
	return 0;
}

Measured memory_bytes: 888
N, x = map(int, input().split())
A = list(map(int, input().split()))
ans = 0
now = A[0]
if now > x:
    ans += now - x
    now = x
for i in range(1, N):
    if now + A[i] > x:
        y = now + A[i] - x
        ans += y
        A[i] = max(0, A[i] - y)
    now = A[i]
print(ans)


Measured memory_bytes: 84760
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
ll n,m;
int main(){
    cin>>n>>m;
    if(n<=m) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
  
#define ll long long
#define all(aaa) aaa.begin(), aaa.end()

const int N = 2005, INF = 1e9;
int dp[N][N], inv_ct[2][N][N], a[N + N], b[N + N];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;

    for (int i = 0; i < 2 * n; i++) {
        char x;
        int y;
        cin >> x >> y;
        y--;
        x = (x == 'B');
        a[i] = x;
        b[i] = y;
    }

    int ans = 0;
    for (int i = 0; i < n + n; i++) {
        for (int j = i + 1; j < n + n; j++) {
            if (a[i] == a[j]) {
                ans += (b[i] > b[j]);
            }
            else {
                inv_ct[a[i]][b[i]][b[j] + 1]++;
            }
        }
    }

    for (int x = 0; x < 2; x++) {
        for (int i = 0; i < n; i++) {
            for (int j = 1; j <= n; j++) {
                inv_ct[x][i][j] += inv_ct[x][i][j - 1];
            }
        }
    }

    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= n; j++) {
            dp[i][j] = INF;
        }
    }

    dp[0][0] = 0;

    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= n; j++) {
            if (i < n) {
                dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + inv_ct[0][i][j]);
            }
            if (j < n) {
                dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + inv_ct[1][j][i]);
            }
        }
    }

    ans += dp[n][n];

    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 47360
#include <stdio.h>

long long int abs(long long int a){return a>0?a:-a;}

int main(void){
    long long int N,Z,W;
    scanf("%lld %lld %lld",&N,&Z,&W);
    long long int a[N];
    for(int i=0;i<N;i++)scanf("%lld",&a[i]);
    if(N==1){printf("%lld",abs(a[0]-W));return 0;}
    long long int po[2][N];//0がX,1がYのばん
    po[0][N-1]=abs(a[N-1]-a[N-2]);
    po[1][N-1]=abs(a[N-1]-a[N-2]);
    for(int i=N-2;i>0;i--){
        po[0][i]=abs(a[N-1]-a[i-1]);
        po[1][i]=abs(a[N-1]-a[i-1]);
        for(int j=i+1;j<N;j++){
            if(po[0][i]<po[1][j])po[0][i]=po[1][j];
            if(po[1][i]>po[0][j])po[1][i]=po[0][j];
        }
    }
    long long int ans=abs(a[N-1]-W);
    for(int i=1;i<N;i++)if(po[1][i]>ans)ans=po[1][i];
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 256
//{{{
#include <bits/stdc++.h>
using namespace std;
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop,~))(__VA_ARGS__)
#define loop(n) rep2(_loop_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define repN(a) repX a
#define repX(a0,a1,a2,x,...) x
#define foreach(x,a) for(auto &x:a)
typedef long long ll;
const ll MOD = 998244353;
//}}}

int main(){
  int A, B;
  cin >> A >> B;
  int ans = A <= 8 && B <= 8;
  puts(ans ? "Yay!" : ":(");
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int S = sc.nextInt();
    int h = S / 3600;
    S = S % 3600;
    int m = S / 60;
    S = S % 60;
    int s = S;
    System.out.println(h + ":" + m + ":" + s);
  }
}



Measured memory_bytes: 26236
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, m; cin >> n >> m;
	int x[100005];
	for(int i=0;i<m;i++){
		cin >> x[i];
	}
	if(n>=m){
		cout << 0 << endl;
		return 0;
	}
	sort(x,x+m);
	vector<int> v;
	for(int i=0;i<m-1;i++){
		v.push_back(x[i+1]-x[i]);
	}
	sort(v.begin(), v.end());
	long long int ans = 0LL;
	for(int i=0;i<m-n;i++){
		ans += v[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1276
import math
num,digit=map(int,input().split())
dot=[list(map(int,input().split())) for _ in range(num)]
count=0
for i in range(num):
    for j in range(i+1,num):
        distance=0
        for a,b in zip(dot[i],dot[j]):
            distance+=(a-b)**2
        if distance==math.floor(math.sqrt(distance))**2:
            count+=1
print(count)

Measured memory_bytes: 38384
import sys
 
sys.setrecursionlimit(100000)
 
 
def dfs1(v, p):
    val = 1
    pre_mul = [1]
    rev_mul = []
    for c in links[v]:
        if c == p:
            pre_mul.append(val)
            rev_mul.append(1)
            continue
        res = 1 + dfs1(c, v)
        val *= res
        val %= m
        pre_mul.append(val)
        rev_mul.append(res)
    dp[v] = val
    for i in range(len(rev_mul) - 2, -1, -1):
        rev_mul[i] *= rev_mul[i + 1]
        rev_mul[i] %= m
    rev_mul.append(1)
    pre_muls[v] = [pre_mul, rev_mul]
    return val
 
 
def dfs2(v, p, a):
    dp[v] = dp[v] * a % m
    pmv = pre_muls[v]
    for i, c in enumerate(links[v]):
        if c == p:
            continue
        pmc = pmv[0][i] * pmv[1][i + 1] % m
        pmc = pmc * a % m
        dfs2(c, v, pmc + 1)
 
 
n, m = map(int, input().split())
links = [[] for _ in range(n)]
dp = [0 for _ in range(n)]
pre_muls = [None for _ in range(n)]
for line in sys.stdin.readlines():
    x, y = map(int, line.split())
    x -= 1
    y -= 1
    links[x].append(y)
    links[y].append(x)
dfs1(0, None)
dfs2(0, None, 1)
print('\n'.join(map(str, dp)))

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

int main(){
    string a;
    cin >> a;
    if(a.at(0) == '7' || a.at(1) == '7' || a.at(2) == '7'){
        cout << "Yes" << endl; 
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3624
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner scan = new Scanner(System.in);
        String testString = scan.next();
        Character one = testString.charAt(0);
        Character two = testString.charAt(1);
        Character three = testString.charAt(2);
        Character four = testString.charAt(3);
        if (one.equals(two) && three.equals(four) && !one.equals(three) && !one.equals(four)) {
            System.out.println("Yes");
        }
        else if (one.equals(three) && two.equals(four) && !one.equals(two) && !one.equals(four)) {
            System.out.println("Yes");
        }
        else if (one.equals(four) && two.equals(three) && !one.equals(two) && !one.equals(three)) {
            System.out.println("Yes");
        }
        else {
            System.out.println("No");
        }
    }
}


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

int cnt = 0;
void  insertionSort(std::vector<int> &a, const int n, const int g){
    for (auto i = g; i < n; ++i){
        auto v = a.at(i);
        auto j = i - g;
        while (j >= 0 and a.at(j) > v){
            a.at(j + g) = a.at(j);
            j -= g;
            ++cnt;
        }
        a.at(j + g) = v;
    }
}
void shellSort(std::vector<int>& vect, const int n){
    cnt = 0;
    std::vector<int> g;
    for (auto m = vect.size() / 3;m > 1; m = (m - 1) / 3)
        g.push_back(m);
    g.push_back(1);
    for (auto v:g)
        insertionSort(vect, n, v);
    std::cout <<  g.size() << '\n' << g.front();
    for (auto i = g.begin() + 1; i != g.end(); ++i)
        std::cout << " " << *i;
    std::cout << '\n' << cnt << '\n';
    for (auto i:vect)
        std::cout << i << '\n';
}
int main(){
    int n;
    std::cin >> n;
    std::vector<int> vect;
    for (auto i = 0; i < n; ++i){
        int temp;
        std::cin >> temp;
        vect.push_back(temp);
    }
    shellSort(vect, n);
}

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

// syntax sugar: `for (int i = 0; i < N; ++i)`
#define rep(i, N) for (int i = 0; i < (int)(N); ++i)
#define rep2(i, startValue, N) for (int i = (int)(startValue); i < (int)(N); ++i)
// syntax sugar: `for (int i = 0; i < N; ++i)`
#define REP(type, name, beginValue, endCondValue) \
  for (type name = beginValue; name < endCondValue; ++name)
// syntax sugar: 多次元vector
#define VECTOR_DIM3(T, name, d1, d2, d3, initValue) \
    std::vector<std::vector<std::vector<T>>> name(d1, std::vector<std::vector<T>>(d2, std::vector<int>(d3, initValue)));
#define VECTOR_DIM2(T, name, d1, d2, initValue) \
    std::vector<std::vector<T>> name(d1, std::vector<T>(d2, initValue));
#define VECTOR_DIM1(T, name, d1, initValue) \
    std::vector<T> name(d1, initValue);
#define ll long long
#define ld long double
#define DUMP(v) "," #v ":" << v

const ll MOD = 1e9+7;

int main(){
  ll n;
  cin >> n;
  vector<ll> a(n, 0);
  ll total = 0;
  rep(i,n) {
    cin >> a[i];
    total += a[i];
    total %= MOD;
  }

  ll ans = 0;
  for(int i = 0; i < n; ++i) {
    total -= a[i];
    if (total < 0) total += MOD;
    ans += a[i] * total;
    ans %= MOD;
  }

  ll ans2 = (ll)ans;
  cout << ans2 << endl;
  return 0;
}


Measured memory_bytes: 4820
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for (int i = (a); i <= (b); ++i)
#define REPD(i,a,b) for (int i = (a); i >= (b); --i)
#define FORI(i,n) REP(i,1,n)
#define FOR(i,n) REP(i,0,int(n)-1)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define SZ(x) int((x).size())
#define DBG(v) cerr << #v << " = " << (v) << endl;
#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
#define fi first
#define se second

int a[100100];

int main() {
	int n,res=0;
	scanf("%d", &n);
	FOR(i,n) scanf("%d", &a[i]);
	FOR(i,n) a[i]--;
	FOR(i,n) if (a[a[i]]==i) res++;
	printf("%d\n", res/2);
	return 0;
}


Measured memory_bytes: 640
N=int(input())
A,B=map(int,input().split())

def one(n,A,B):
    if n%2==0:
        return A-B,B
    else:
        return A,A+B

N=N%12

for i in range(N):
    A,B=one(i,A,B)

print(A,B)
    


Measured memory_bytes: 5600
#include <stdio.h>
int main() {
	int a, b, c;
	int rectangle = 0, diamond = 0;
	while (scanf(" %d,%d,%d", &a, &b, &c) != EOF) {
		diamond += a == b;
		rectangle += a * a + b * b == c * c;
	}
	printf("%d\n%d\n", rectangle, diamond);
	return 0;
}

Measured memory_bytes: 596
//
//  main.cpp
//  AtCoder_code_test
//
//  Created by parsley69 on 2019/05/25.
//  Copyright © 2019 parsley69. All rights reserved.
//
//

#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <chrono>
using namespace std;


int main(int argc, const char * argv[]) {
    
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;
    
    int ans_sugar = 0, ans_water = 0;
    double density = - 1.0;
    
    for (int a = 0; 100 * A * a <= F; a++) {
        for (int b = 0; 100 * (A * a + B * b) <= F; b++) {
            int water = A * a + B * b;
            if (water == 0) continue;
            for (int c = 0; C * c <= water * E && 100 * water + C * c <= F; c++) {
                for (int d = 0; C * c + D * d <= water * E && 100 * water + C * c + D * d <= F; d++) {
                    if (1. * (C * c + D * d) / water > density) {
                        ans_sugar = C * c + D * d;
                        ans_water = water;
                        density = 1. * ans_sugar / ans_water;
                    }
                }
            }
        }
    }
    
    cout << ans_sugar + 100 * ans_water << ' ' << ans_sugar << endl;
    
    return 0;
}


Measured memory_bytes: 256
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n)] #各ノードの親番号
        self.rank = [0] * (n) #各ノードのランク（木の高さ）
        self.root = [-1]*(n+1) # -（各ノードの属するグループの要素数）

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            # node = [x]
            # cur = node[0]
            # while self.par[cur] != cur:
            #     cur = self.par[cur]
            #     node.append(self.par[cur])
            
            # for n in node:
            #     self.par[n] = cur
            
            return self.par[x]

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x==y:
            return
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.root[x] += self.root[y]
            self.root[y] = self.root[x]
        else:
            self.par[y] = x
            self.root[x] += self.root[y]
            self.root[y] = self.root[x]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # 同じ集合に属するか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)
                
    # グループ数
    def groupsize(self):
        cnt = 0
        for i,x in enumerate(self.par):
            if x == i:
                cnt += 1
        return cnt

    # xの属すグループの要素数
    def size(self, x):
        return -self.root[self.find(x)]
    
    # xの属すグループの要素リスト
    def members(self, x):
        ret = []
        rootNode = self.find(x)
        for i in range(len(self.par)):
            if self.find(i) == rootNode:
                ret.append(i)
        return ret
    
    # ルートノードのリストを取得
    def get_roots(self):
        ret = []
        for i,x in enumerate(self.par):
            if x==i:
                ret.append(i)
        return ret
    
    # 各グループ毎の要素リストを取得
    def all_members(self):
        L = len(self.par)
        roots = self.get_roots()
        namedict = [0]*L
        for i,r in enumerate(roots):
            namedict[r] = i
        
        
        ret = [[] for _ in range(len(roots))]
        for i in range(len(self.par)):
            p = namedict[self.find(i)]
            ret[p].append(i)
        return ret
            
    

N,M,K = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(M)]
CD = [list(map(int,input().split())) for _ in range(K)]
    
uf = UnionFind(N)
for a,b in AB:
    uf.union(a-1,b-1)
    
ans = [0]*N
 
for group in uf.all_members():
    L = len(group)-1
    for a in group:
        ans[a] = L
        
# friends = [0]*N
# brock = [0]*N
for a,b in AB:
    ans[a-1] -= 1
    ans[b-1] -= 1
 
for c,d in CD:
    if uf.same_check(c-1,d-1):
        ans[c-1] -= 1
        ans[d-1] -= 1
 
print(*ans)
        
    
    
    
    
    
    
    

Measured memory_bytes: 123224
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N, K, X;
    int length = 0;
    cin >> N >> K;
    for(int i=0; i<N; i++){
        cin >> X;
        if(X > K-X){
            length += 2 * (K-X);
        }
        else{
            length += 2 * X;
        }
    }
    cout << length << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<vector>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=1e5+5;
int h[N],g[N];
int main(){
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++)cin>>h[i];
    while(m--){
        int a,b;
        cin>>a>>b;
        if(h[a]>h[b])g[b]=1;
        if(h[a]<h[b])g[a]=1;
        if(h[a]==h[b])g[a]=g[b]=1;
    }
    ll ans=0;
    for(int i=1;i<=n;i++)if(!g[i])ans++;
    cout<<ans;
return 0;
}


Measured memory_bytes: 4356
/*In the name of Allah*/
#include <bits/stdc++.h>
using namespace std;
#define inf 1000000001
#define MAX 200005
#define mod 1000000007
#define ll long long
#define fr first
#define sc second
bool c[MAX];
vector< pair<int,int> > g[MAX];
void dfs(int u,int par ){
	for(auto v : g[u]){
		if(v.fr != par){
			if(v.sc&1)c[v.fr] = 1 - c[u];
			else c[v.fr] = c[u];
			dfs(v.fr,u);
		}
	}
}

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n,x,y,w;
	cin>>n;
	for(int i = 0; i < n - 1; i++){
		cin>>x>>y>>w;
		g[x].push_back({y,w});
		g[y].push_back({x,w});
	}
	dfs(1,0);
	for(int i = 1; i <= n ;i++)cout<<c[i]<<endl;
	return 0;
}


Measured memory_bytes: 10496
#include<iostream>
using namespace std;
int main()
{
	int a,b,counter=0;
	cin >> a;
	cin >> b;
	for(int i=0;i<2;i++)
	{
		if(a>b)
	{
		counter+=a;
		a--;
	}
	else if(a<b)
	{
		counter+=b;
		b--;
	}
	else if(a==b)
	{
		counter+=a;
	}
	}
	cout << counter << endl;
	
}

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

using namespace std;

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

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

    cout << MAX(C-(A-B),0) << endl;

    return 0;
}

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

int main(){
string s;
cin>>s;
int n;
cin>>n;
vector<string> w(n);
for(int i=0;i<n;i++)cin>>w[i];
int ans =0;
for(int i=0;i<n;i++){
	string t=w[i]+w[i];
	for(int j=0;j<t.size()+1-s.size();j++){
		bool flag =true;
		for(int k=0;k<s.size();k++){
			if(s[k]!=t[j+k]){
				flag =false;
				break;			
			}
		}
		if(flag){
		ans++;
		break;
		}
	}
}
cout<<ans<<endl;
return 0;
}



Measured memory_bytes: 3244
import java.io.*;

public class Main{
    public static void main(String[]args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int time = Integer.parseInt(br.readLine());
        int h = time / 3600;
        int m = (time % 3600) / 60;
        int s = (time % 3600) % 60;

        System.out.println(h +":"+ m +":"+ s);
    }
}

Measured memory_bytes: 24120
//
//  main.cpp
//  CoderProj
//
//  Created by Minoru Hayashi on 2020/03/12.
//  Copyright © 2020 Minoru Hayashi. All rights reserved.
//
//
//
//

#include <bits/stdc++.h>
using namespace std;

#define REP(i,n) for (int i=0; i<(n); i++)
#define REP2(i,x,n) for (int i=x; i<(n); i++)
#define ALL(n) begin(n), end(n)

using ll = long long;

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

// const ll INF = 1LL<<60;
// const int INF = 1<<29;
// const ll MOD = 1000000007;
//#define __DBG__


void solve(void){
  
  int r;
  cin >> r;
  
  cout << 3*r*r << endl;
  
  return;
   
}

#define TESTCASES 1

int main(int argc, const char * argv[]) {


    cin.tie(0);
    ios::sync_with_stdio(false);

    REP(i,TESTCASES){
      solve();
    }
 
    return 0;
}


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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define LL long long

using mint = atcoder::modint998244353;

struct S{
    mint digit;
    mint weight;
};

S op(S a, S b) {
    return S{(a.digit*a.weight+b.digit*b.weight)/(a.weight+b.weight),a.weight+b.weight};
}

S e() {
    return S{0,1};
}

struct F{
    bool rewrite;
    mint f;
};

S mapping(F f,S x){
    return f.rewrite ? S{f.f,x.weight} : x;
}

F composition(F f,F g){
    return f.rewrite ? f : g;
}

F id(){
    return F{false,0};
}

int n,q;

int main() {
    cin>>n>>q;
    vector<S> a;
    mint m = 1;
    REP(i,n){
        a.push_back(S{1,m});
        m *= 10;
    }
    auto seg = atcoder::lazy_segtree<S, op, e, F, mapping, composition, id>(a);
    REP(i,q){
        int l,r,d;
        cin>>l>>r>>d;
        auto f = F{true,d};
        seg.apply(n-r,n-l+1,f);
        auto ret = seg.prod(0,n).digit*seg.prod(0,n).weight;
        cout<<ret.val()<<endl;
    }
}

Measured memory_bytes: 11180
#include <stdio.h>

int gcd(int a, int b){
	int r;
	if(a<b){
		r=a;
		a=b;
		b=r;
	}
	if(b==0){
		return a;
	}
	while(1){
		r=a%b;
		if(r==0){
			return(b);
		}
		a=b;
		b=r;
	}
}

int abs(int a){
	if(a<0){
		return -a;
	}
	return a;
}

int main(){
	int N;
	int X;
	int x[100000];
	scanf("%d",&N);
	scanf("%d",&X);
	int i;
	for(i=0;i<N;i++){
		scanf("%d",&x[i]);
	}
	int D;
	D=0;
	for(i=0;i<N;i++){
		D=gcd(D,abs(X-x[i]));
	}
	printf("%d",D);
}

Measured memory_bytes: 512
a = [[0 for i in range(4)] for j in range(4)]
bb = [0,0,0,0]
for i in range(3):
	n,m = map(int,input().split())
	bb[n-1] += 1
	bb[m-1] += 1
su = 1
for i in range(4):
	su *= bb[i]
if su == 4:
	print("YES")
else:
	print("NO")

Measured memory_bytes: 38384
using System;
using System.Linq;
class Program
{
    static void Main(string[] args)
    {
        var a = Console.ReadLine();
        if (a == "A")
            Console.WriteLine("T");
        else if(a == "C")
            Console.WriteLine("G");
        else if(a == "G")
            Console.WriteLine("C");
        else
            Console.WriteLine("A");

    }
}

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

typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;

#define rep(idx, N) for (u64 idx = 0; idx < N; idx++)

int main() {
  i64 x, y, z;
  cin >> x >> y >> z;

  cout << z << " " << x << " " << y << endl;

  return 0;
}


Measured memory_bytes: 3596
n,k=map(int,input().split())

ans=0
if k%2==0:
    cnt=0
    k_d = k//2

    for i in range(n+1):
        if i%k==k_d:
            cnt+=1

    x=n//k
    ans+=(x**3) +(cnt**3)
else:
    x=n//k
    ans+=x**3

print(ans)

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

using namespace std;

int main()
{
	int i, j;
	string S, T;
	vector<char> sc, tc;
	vector<int> si, ti;

	cin >> S;
	cin >> T;

	sc.push_back(S.front());
	tc.push_back(T.front());
	si.push_back(si.size());
	ti.push_back(ti.size());

	for (i = 1; i < S.size(); i++)
	{
		for (j = 0; j < sc.size(); j++)
		{
			if (S[i] == sc[j])
				break;
		}

		if (j == sc.size())
			sc.push_back(S[i]);

		si.push_back(j);

		for (j = 0; j < tc.size(); j++)
		{
			if (T[i] == tc[j])
				break;
		}

		if (j == tc.size())
			tc.push_back(T[i]);

		ti.push_back(j);
	}

	for (i = 0; i < si.size(); i++)
	{
		if (si[i] != ti[i])
		{
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;
}

Measured memory_bytes: 2428
#include<bits/stdc++.h>
using namespace std;
const int N=200005;
int n,m,a[N],b[N],c[N];
int pd(int x){
	for (int i=1;i<=n;i++)c[i]=(a[i]>=x);
	int gol=m,gor=m;
	while ((gol>1)&&(c[gol]!=c[gol-1]))gol--;
	while ((gor<n)&&(c[gor]!=c[gor+1]))gor++;
	if (c[gol]!=c[gor]){
		if (gol+1<=m)gol++;
		else gor--;
	}
	int k=((gol+gor)>>1);
	if ((gol<=m)&&(m<k))return c[gol-1];
	if ((k<m)&&(m<=gor))return c[gor+1];
	return c[gol];
}
int main(){
	scanf("%d",&m);
	n=m*2-1;
	for (int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		b[i]=a[i];
	}
	sort(b+1,b+1+n);
	int l=1,r=n;
	while (l<r){
		int mid=(l+r+1)/2;
		if (pd(mid)) l=mid;
		else r=mid-1;
	}
	printf("%d\n",b[l]);
	return 0;
}

Measured memory_bytes: 2560
#include <stdio.h>

int main(void){

	int a,b;
    scanf("%d %d", &a ,&b);
    if(a < b){
    	printf("a < b\n");
    }
    else if(a > b){
    	printf("a > b\n");
    }
    else {
	    printf("a == b\n");
    }

	return 0;
}

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

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int N;
int A[110000];
char op[110000];

signed main() {
    cin >> N;
    cin >> A[0];
    for (int i = 1; i < N; i++)cin >> op[i] >> A[i];
    op[N] = '-'; A[N] = 0;

    int sum = A[0], total_minus = 0, cur_minus = 0, min_dec = LLONG_MAX;
    for (int i = 1; i <= N; i++) {
        if (op[i] == '+') {
            if (total_minus > 0)cur_minus += A[i];
        } else {
            if (total_minus > 0)min_dec = min(min_dec, total_minus + cur_minus);
            total_minus += A[i];
            cur_minus = 0;
        }
        sum += A[i];
    }
    if (min_dec == LLONG_MAX)min_dec = 0;
    cout << sum - 2 * min_dec;

}


Measured memory_bytes: 1152