akhauriyash/Code-Regression huggingface dataset:
h,w,k = map(int,input().split())
A = [input() for i in range(h)]

B = [[0] * w for i in range(h)]
it=[0,0]
n = 0
for i in range(h):
    a = 0
    for j in range(w):
        if A[i][j] == "#":
            n += 1
            it = [i,j]
            if a == 0:
                a = n
            else:
                a += 1
        B[i][j] = a
for i in range(h):
    for j in range(w-2,-1,-1):
        if B[i][j] == 0:
            B[i][j] = B[i][j+1]

for i in range(it[0]+1,h):
    if sum(B[i]) == 0:
        B[i] = B[i-1]
for i in range(it[0]-1,-1,-1):
    if sum(B[i]) == 0:
        B[i] = B[i+1]

# print(B)
for i in range(h):
    print(" ".join([str(j) for j in B[i]]))

Measured memory_bytes: 43632
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;

int main(){
  
  int a,b,c,d,p;
  int x,y;

  scanf("%d %d %d %d %d",&a,&b,&c,&d,&p);

  x=a*p;

  if(p<=c) y=b;
  else{
    y=b;
    y+=d*(p-c);
  }

  if(x>y) x=y;

  printf("%d\n",x);

  return 0;
}

Measured memory_bytes: 1188
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<ctime>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
ll p = 1e9 + 7;
ll fac[4000010];
ll ifac[4000010];
ll inv[4000010];
void init(int n) {
    int i;
    fac[0] = fac[1] = ifac[0] = ifac[1] = inv[0] = inv[1] = 1;
    for(i = 2; i <= n; i++) {
        inv[i] = -(p / i) * inv[p % i] % p;
        fac[i] = fac[i - 1] * i % p;
        ifac[i] = ifac[i - 1] * inv[i] % p;
    }
}

ll c(int x, int y) {
    if(x < y)
        return 0;
    return fac[x] * ifac[y] % p * ifac[x - y] % p;
}

ll f[2010][2010];
int main() {
    int n, k;
    scanf("%d%d", &n, &k);
    if(k <= 1) {
        printf("1\n");
        return 0;
    }
    init(n * k);
    int i, j;
    f[0][0] = 1;
    for(i = 1; i <= n; i++)
        for(j = n; j >= 0; j--) {
            if(j <= i)
                f[i][j] += f[i - 1][j - 1] * c(k * i - j - 1, k - 2) % p;
            f[i][j] = (f[i][j] + f[i][j + 1]) % p;
        }
    ll ans = (f[n][0] % p + p) % p;
    ans = ans * fac[n] % p;
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 125440
#include <iostream>
#include <vector>
#include <algorithm>
#include<stdio.h>
using namespace std;
typedef long long ll;
int main() {
    int A;
    int P;
    cin >> A >> P ;
    int ans;
    ans=(A*3+P)%2;
    if (ans==0){
        ans=(A*3+P)/2;}
    else{ans=(A*3+P-1)/2;}


    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
const int N = 1e6+6;
int p[N];
int a[N];
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    for(int i=0;i<n;i++){
        if(p[a[i]])continue;
        if(i>0 and a[i]==a[i-1])p[a[i]] = 1;
        for(int j=a[i]+a[i];j<N;j+=a[i])p[j] = 1;
    }
    int ans = n;
    for(int i=0;i<n;i++){
        ans-=p[a[i]];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 8336
N=int(input())
A=list(map(int,input().split()))
count = 0
position = 0
while position < N:
  for j in range(1,N+1):
    for i in range(position,N):
      if A[i] == j:
        count = count + 1
        position += 1
        break
      else:
        position = position + 1

if count != 0:
    print(N-count)
else:
    print(-1)



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

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


Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {

	final int INF = 1 << 29;

	private void doit() {
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			int m = sc.nextInt();
			if(n == 0 && m == 0){
				break;
			}
			int [][] cost = new int[n][n];
			int [] mincost = new int[n];
			boolean [] used = new boolean[n];
			for(int i =0 ; i < n ;i++){
				for(int j = 0; j < n; j++){
					if(i == j){
						cost[i][j] = 0;
					}
					else{
						cost[i][j] = INF;
					}
				}
			}

			for(int i = 0; i < m; i++){
				int from = sc.nextInt();
				int to = sc.nextInt();
				int value = sc.nextInt();
				cost[from][to] = value;
				cost[to][from] = value;
			}

			for(int i= 0; i < n; ++i){
				mincost[i] = INF;
				used[i] = false;
			}

			mincost[0] = 0;
			int res = 0;

			while(true){
				int v = -1;

				for(int u = 0; u < n; u++){
					if(! used[u] && (v == -1 || mincost[u] < mincost[v])){
						v = u;
					}

				}

				if(v == -1) break;
				used[v] = true;
				res += mincost[v];

				for(int u = 0; u < n; u++){
					mincost[u] = Math.min(mincost[u], cost[v][u]);
				}
			}
			System.out.println(res);

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

	}

}

Measured memory_bytes: 12000
#include<iostream>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int A[n],i,flag=0;
  for(i=0;i<n;i++)
  {
    cin>>A[i];
  }
  for(i=0;i<n;i++)
  {
  
    if(A[i]%2==0)
    {
      if((A[i]%3==0)||(A[i]%5==0))
        flag=0;
      else
      flag=1;
    }
    if(flag==1)
    break;
  }
    if(flag==0)
      cout<<"APPROVED"<<endl;
    else
      cout<<"DENIED"<<endl;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxx = 1010;
int c[maxx][maxx];

int lcs(char s1[],char s2[]) {
    int m = strlen(s1), n = strlen(s2);
    for (int i = 0; i <= m; i++)
    c[i][0] = 0;
    for (int i = 0; i <= n; i++)
    c[0][i] = 0;
    
    for (int i = 0; i < m; i++) {
        for (int j = 0; j < n; j++) {
            if (s1[i] == s2[j])
            c[i+1][j+1] = c[i][j] + 1;
            else
            c[i+1][j+1] = max(c[i][j+1], c[i + 1][j]);
        }
    }
    return c[m][n];
}
int main()
{
    char s1[maxx], s2[maxx];
    int t;
    scanf("%d", &t);
    for (int i = 0; i < t; i++) {
        scanf("%s %s", s1, s2);
        printf("%d\n",lcs(s1,s2));
    }
    
    return 0;
}



Measured memory_bytes: 7132
// Optimise
#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;

// #define MULTI_TEST
#ifdef LOCAL
#include "/home/shahraaz/bin/debug.h"
#else
#define db(...)
#define pc(...)
#endif

#define f first
#define s second
#define pb push_back
#define all(v) v.begin(), v.end()
auto TimeStart = chrono::steady_clock::now();
auto seed = TimeStart.time_since_epoch().count();
std::mt19937 rng(seed);
using ll = long long;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using Random = std::uniform_int_distribution<T>;

const int NAX = 2e5 + 5, MOD = 1000000007;

class Solution
{
private:
public:
    Solution() {}
    ~Solution() {}
    void solveCase()
    {
        int n;
        cin >> n;
        vector<int> a(n);
        map<int, ll> cnt;
        ll res = 0;
        for (auto &x : a)
        {
            cin >> x;
            res -= cnt[x] * (cnt[x] - 1) / 2;
            cnt[x]++;
            res += cnt[x] * (cnt[x] - 1) / 2;
        }
        for (auto &x : a)
        {
            res -= cnt[x] * (cnt[x] - 1) / 2;
            cnt[x]--;
            res += cnt[x] * (cnt[x] - 1) / 2;
            cout << res << ' ';
            res -= cnt[x] * (cnt[x] - 1) / 2;
            cnt[x]++;
            res += cnt[x] * (cnt[x] - 1) / 2;
        }
    }
};

int32_t main()
{
#ifndef LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif
    int t = 1;
#ifdef MULTI_TEST
    cin >> t;
#endif
    Solution mySolver;
    for (int i = 1; i <= t; ++i)
    {
        mySolver.solveCase();
#ifdef TIME
        cerr << "Case #" << i << ": Time " << chrono::duration<double>(chrono::steady_clock::now() - TimeStart).count() << " s.\n";
        TimeStart = chrono::steady_clock::now();
#endif
    }
    return 0;
}

Measured memory_bytes: 11776
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int b[200000];
bool prime(int n){
	if(n==1)return false;
	for(int i=2;i*i<=n;i++){
		if(n%i==0)return false;
	}
	return true;
}
signed main(){
	int q;scanf("%d",&q);
	for(int i=1;i<200000;i+=2){
		if(prime(i)&&prime((i+1)/2)){
			b[i]=true;
		}
	}
	for(int i=1;i<200000;i++){
		b[i]+=b[i-1];
	}
	rep(i,q){
		int l,r;scanf("%d%d",&l,&r);
		cout<<b[r]-b[l-1]<<endl;
	}
}

Measured memory_bytes: 1408
#include <stdio.h>

int main(void)
{
	int a, b, c;
	scanf( "%d %d", &a, &b );
	if( ( b % a ) == 0 )
	{
		c = b / a;
	}
	else
	{
		c = ( b / a ) + 1;
	}
	printf( "%d\n", c );
	return 0;
}


Measured memory_bytes: 2056
def solve():
    N,X = map(int,input().split())
    L = list(map(int, input().split()))
    D = 0
    count = 1
    for i in range(N):
        D += L[i]
        count += 1 if D <= X else 0

    print(count)

if __name__ == '__main__':
    solve()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
#define MOD 1000000007 
using namespace std;
void solve(){
    ll n;
    cin>>n;
    unordered_map<string,ll>freq;
    for(auto i:freq)i.second=0;
    while(n--){
        string s;
        cin>>s;
        freq[s]++;
    }
    cout<<"AC x "<<freq["AC"]<<endl;
    cout<<"WA x "<<freq["WA"]<<endl;
    cout<<"TLE x "<<freq["TLE"]<<endl;
    cout<<"RE x "<<freq["RE"]<<endl;
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt","r", stdin);
    freopen("output.txt","w", stdout);
#endif
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    solve();
    return 0;
}

Measured memory_bytes: 3648
#include <stdio.h>

typedef unsigned long long ull;

#define N 1000000007

ull powmod(ull m, ull n)
{
    if(n == 0) return 1;
    if(n == 1) return m;
    return powmod(m * m % N, n / 2) * (n % 2 ? m : 1) % N;
}

int main(void)
{
    ull m, n;
    
    scanf("%llu %llu", &m, &n);
    printf("%llu\n", powmod(m, n));
    
    return 0;
}

Measured memory_bytes: 604
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define BUGAVOID(x) x
#define rep(...) BUGAVOID(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define sz(c) (int)(c.size())
#define all(c) c.begin(),c.end()
#define ms(a,v) memset(a,v,sizeof(a))
#define mp make_pair
#define write(x) cout<<(x)<<endl
using namespace std; typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; }return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; }return 0; }
const int INF = 1 << 28; const ll LINF = 1ll << 60;
const int MAX = 1e5 + 5; const int MOD = 1e9 + 7; const double EPS = 1e-6;
const int dy[4] = { 0,1,0,-1 }; const int dx[4] = { 1,0,-1,0 };
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;

int N;
vector<pair<int, int>> red, blue;
int ans = 0;

int main() {
    cin >> N;
    red.reserve(N); blue.reserve(N);
    rep(i, N) {
        int a, b; cin >> a >> b;
        red.emplace_back(a, b);
    }
    rep(i, N) {
        int a, b; cin >> a >> b;
        blue.emplace_back(a, b);
    }
    sort(all(red)); sort(all(blue));

    vector<bool> paired(N);
    for (int b = 0; b < N; ++b) {

        int imax = -1;
        for (int i = 0; i < N; ++i) {
            if (red[i].first >= blue[b].first) break;
            if (!paired[i] && red[i].second < blue[b].second) {
                if (imax != -1 && red[i].second > red[imax].second) imax = i;
                else if (imax == -1) imax = i;
            }
        }

        if (imax != -1) {
            paired[imax] = true;
        }
    }

    ans = count(all(paired), true);
    write(ans);
}

Measured memory_bytes: 256
S = input()
T = input()
n, m =  len(S), len(T)
ans = n
for i in range(n - m + 1):
    cnt = 0
    subS = S[i: i + m]
    for s, t in zip(subS, T):
        if s != t:
            cnt += 1
    if ans > cnt:
        ans = cnt
print(ans)

Measured memory_bytes: 9124
#include<stdio.h>
 
int main()
 {
   double r;
double a,c;
 double pi=3.141592653589;
   
   scanf("%lf", &r);
 
   a =  pi* r * r;
   c = 2*pi*r;
    printf("%.6f %.6f\n",a,c);
 
   return (0);
}


Measured memory_bytes: 2044
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <numeric>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long
#define vint vector<int>
#define pint pair<int,int>
#define pb(a) push_back(a)
#define all(v) v.begin(),v.end()
#define dbg(x) cerr << #x << " = " << (x) << endl
#define yn(b) cout << ((b) ? "Yes" : "No") << endl
#define YN(b) cout << ((b) ? "YES" : "NO") << endl

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

struct sushi{
	int x, v;
};

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

	int a,b,h;
	cin>>a>>b>>h;
	cout << (a + b) * h / 2 << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define INF 2e9
#define mo 1000000007
using namespace std;
struct Info{ll p1,p2;};
int a[1010],n;
ll po(ll x,ll y){ll z=1;while (y){if (y%2==1)z=(x*z)%mo;x=(x*x)%mo;y/=2;}return z;}
Info work(int l,int r,int x){
	int mi=INF;
	Info z,y;
	ll c1=1,c2=1,c3=0;
	for(int i=l;i<=r;i++)mi=min(mi,a[i]);
	for(int i=l;i<=r;i++)if(a[i]==mi)c3++;
	for(int i=l,j;i<=r;i=j+1){
		j=i;
		if (a[i]>mi){while (a[j+1]>mi)j++;y=work(i,j,mi);c1=c1*y.p1%mo,c2=c2*(y.p1+y.p2)%mo;}
	}
	z.p1=c1*po(2,mi-x)%mo;
	z.p2=(c2*po(2,c3)+c1*(po(2,mi-x)-2+mo))%mo;
	return z;
}
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	cout<<work(1,n,0).p2<<endl;
	return 0;
}

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

using namespace std;

using ll = long long;

using ull = unsigned long long;

int main(void) {

  int n;

  cin >> n;

  cin.ignore();

  ll a[n];

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

  cin.ignore();

  ll cnt = 0;

  bool flag = true;

  while(flag){
    for (int i = 0; i < n; i++){
      if(a[i] % 2 == 1) {
        flag = false;
        break;
      }
      a[i] /= 2;
    }
    if(flag) cnt ++;
  }

  cout << cnt << endl;
  return 0;
}


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

typedef complex<double> P;

double cross(P a, P b){ return imag( conj(a) * b );};

P p[64];

int main() {
  int tno = 0;
  for(int N; cin >> N, N; ) {
    for(int i = 0; i < N; i++) {
      int x, y;
      cin >> x >> y;
      p[i] = P(x,y);
    }

    double sum = 0;
    for(int i = 0; i < N; i++) {
      sum += cross( p[i], p[(i+1) % N]);
    }
    printf("%d %.1f\n", ++tno, abs(sum / 2.0));
  }
}

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

#define ff first
#define ss second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define boost ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define debug(x) cout << #x << " : " << (x) << endl
#define all(v) v.begin(),v.end() 
#define allr(v) v.rbegin(),v.rend() 
//#define endl '\n'  
typedef  long long ll; 
typedef  unsigned long long ull; 
typedef vector< ll > edge; 
typedef pair< ll , ll > mypair;
typedef priority_queue <ll> max_heap;
typedef priority_queue <ll, vector<ll>, greater<ll> > min_heap;
const ll mod=1000000007;
const ll inf=1e15;
const ll N=2e5+10;

int main()
{
  boost;
  ll n,m;
  cin>>n>>m;
  ll l=-inf,r=inf;
  while(m--)
  {
  	ll x,y;
  	cin>>x>>y;
  	l=max(l,x);
  	r=min(r,y);
  }
  if(r>=l) cout<<r-l+1;
  else cout<<"0";
  return 0;
}

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

int main(){
  char zu[6][5];
  string bun;
  char x='a';
  int nagasa;
  int smp1,smp2;
  for(int i=0;i<6;i++){
    for(int j=0;j<5;j++){
      zu[i][j] = x;
      x++;
    }
  }
  zu[5][1]='.';
  zu[5][2]='?';
  zu[5][3]='!';
  zu[5][4]=' ';
  while(cin >> bun){
    nagasa = bun.size();
    int flag=0;
    for(int i=0;i<nagasa;i=i+2){
      smp1 = bun[i]-'0'-1;
      smp2 = bun[i+1]-'0'-1;
      if(smp1 > 5 || smp2 > 4 || smp1 <= -1 || smp2 <= -1){
	flag = 1;
      }
    }
    int a = nagasa%2;
    if(a == 0 && flag == 0){
      for(int i=0;i<nagasa;i=i+2){
	smp1 = bun[i]-'0'-1;
	smp2 = bun[i+1]-'0'-1;
	cout << zu[smp1][smp2];
      }
      cout << endl;
    }
    else{
    cout << "NA" << endl;
    }
  }
}

Measured memory_bytes: 1176
using System;
using System.Collections.Generic;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("2");
            //8
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("1");
            //1
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        int N = int.Parse(InputList[0]);
        int Answer = 1;
        for (int I = 1; I <= 3; I++) {
            Answer *= N;
        }
        Console.WriteLine(Answer);
    }
}


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

int main(){
  string s; cin>>s;
  int c=0,e=0;
  
  for(int i=0;i<s.length();i++){
    if(i==0){
      if(s[i]!='A'){
        cout<<"WA"<<endl;
        return 0;
      }
    }
    else if(i==1 || i==s.length()-1){
      if(s[i]>='A' && s[i]<='Z'){
        cout<<"WA"<<endl;
        return 0;
      }
    }
    
    else{
      if(s[i]=='C') c += 1;
      else if(s[i]>='A' && s[i] <='Z'){
        cout<<"WA"<<endl;
        return 0;
      }
    }
  }
      
  if(c==1) cout<<"AC"<<endl;
  else cout<<"WA"<<endl;
  
  return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}

struct UnionFindTree{
	vector<int>par,sz;
	UnionFindTree(int n){
		par.resize(n);
		sz.resize(n);
		for(int i=0;i<n;i++){
			par[i]=i;
			sz[i]=1;
		}
	}
	int find(int x){
		return x==par[x]?x:par[x]=find(par[x]);
	}
	void unite(int x,int y){
		x=find(x);y=find(y);
		if(x==y)return;
		if(sz[x]<sz[y])swap(x,y);
		sz[x]+=sz[y];
		par[y]=x;
	}
	bool areSame(int x,int y){
		return find(x)==find(y);
	}
	int size(int x){
		return sz[find(x)];
	}
};

signed main(){
	int N,M;
	cin>>N>>M;
	UnionFindTree uf(N);
	rep(i,M){
		int a,b,z;
		cin>>a>>b>>z;
		a--;b--;
		uf.unite(a,b);
	}

	int ans=0;
	rep(i,N)if(uf.find(i)==i)ans++;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#include <iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
const double PI=3.14159265358979323846;

int main(){
  double a,b,h,m;
  cin >> a >> b>> h >> m;
  double a_2=a*a,b_2=b*b;
  double a_b = 2*a*b;
  double theta = (60*h-11*m)*PI/360;
  double cos_t = cos(theta);
  double ans = a_2+b_2-a_b*cos_t;
  ans = sqrt(ans);
  cout << setprecision(20);
  cout << ans << endl;
}

Measured memory_bytes: 4136
#include "bits/stdc++.h"
#define _USE_MATH_DEFINES
#include <math.h>
 
using namespace std;
 
using LL = long long;
using VLL = std::vector<LL>;
using VVLL = std::vector<VLL>;
using VVVLL = std::vector<VVLL>;
using LD = long double;
using VLD = std::vector<LD>;
using VVLD = std::vector<VLD>;
using VVVLD = std::vector<VVLD>;
using BL = bool;
using VBL = std::vector<BL>;
using VVBL = std::vector<VBL>;
using VVVBL = std::vector<VVBL>;


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

//template<class T=LL> inline vector<T> cinv(LL N){ vector<T> v(N); REP(i, N)cin>>v[i]; return move(v);}
//template<class T=LL> inline vector<T> cinv(LL N){ vector<T> v(N); REP(i, N)cin>>v[i]; return move(v);}
#define REP(i,n) for(LL (i)=0;(i)<(n);(i)++)
#define REPM(i,n,m) for(LL (i)=m;(i)<(n);(i)++)
#define ALL(v) v.begin(), v.end()
#define PRINTLN(v) {LL i=0; for(auto (a): v ){   cerr <<i << " : "<<  a << endl; i++;}}
//#define PRINTSP(v) for(auto (a): v ) {cerr << a << " ";} cerr << endl

template<class T> 
void PRINTSP(vector<T> v, size_t w=3){
  for(auto (a): v ) {cerr <<setw(w)<< a << " ";} cerr << endl;
} 

template<typename TTT>
vector<LL> arg_sort(vector<TTT> A, bool ascend = true) {
  vector<LL> index(A.size());
  iota(index.begin(), index.end(), 0);
  if (ascend) {
    std::sort(index.begin(), index.end(), [&A](TTT i1, TTT i2) {
      return A[i1] < A[i2];
      });
  }
  else {
    std::sort(index.begin(), index.end(), [&A](TTT i1, TTT i2) {
      return A[i1] > A[i2];
      });
  }

  return index;
}

#define cmax(a,b) {if(a<b){a=b;}}
#define cmin(a,b) {if(a>b){a=b;}}
#define EACH(a,A) for(auto a: A)
//#define cmax(a,b) a = (a>b ? a:b)
//#define cmin(a,b) a = (a<b ? a:b) 
//cin,cout高速化のおまじない＋桁数指定
inline VLL cinvll(LL N, LL minus = 0){
  VLL A(N);
  REP(i,N){
    cin >> A[i];
    A[i] -= minus;
  }
  return move(A);
}
inline VVLL zerosll(LL H, LL W, LL val=0){
  VVLL A(H,VLL(W,val));
  return move(A);
}
struct Fast{
	Fast(){
		cin.tie(0);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(std::numeric_limits<double>::max_digits10);
	}
} fast;



VVVLL X;
vector<bool> C;

void dfs(LL me,bool iro, LL oya){
  C[me] = iro;
  //cerr << "me "<< me<< " cost" << cost<<endl; 
  //PRINTSP(D);
  for(LL i=0; i< X[me].size();++i){
    LL to = X[me][i][0];
    LL dist  = X[me][i][1];
    if(to==oya){
      continue;
    }
    if(dist==0){
      dfs(to,iro ,me);
    }
    else{
      dfs(to,not iro ,me);
    }

  }

}

void func(){
  LL N;
  cin >> N;
  X.resize(N);
  C.resize(N,false);
  
  REP(i,N-1){
    LL a,b,c; 
    cin >> a;
    cin >> b;
    cin >> c;
    a--;
    b--;
    c = c%2;
    X[a].push_back({b,c});
    X[b].push_back({a,c});
  }

  dfs(0, false,-1);
  //PRINTSP(C);
  REP(i,N){
    cout << (LL)C[i] << endl;
  }

}
int main()
{
  func();
  return 0;
}
 

Measured memory_bytes: 18176
import sys
sys.setrecursionlimit(10 ** 6)

def jump(k, h, res):
    if k == 0:
        return 0

    if ( res[k] == -1 ):
        res[k] = jump(k - 1, h, res) + abs(h[k] - h[k - 1])
        if k >= 2:
            res[k] = min(res[k], jump(k - 2, h, res) + abs(h[k] - h[k - 2]))

    return res[k]


def main():
    n = int(input())
    h = list(map(int, input().split(" ")))

    res = [ -1 ] * len(h)
    print(jump(n-1, h, res))


if __name__ == '__main__':
    main()

Measured memory_bytes: 94100
n = int(input())
ls = list(map(int, input().split()))
res = 0
for i in range(n - 1):
    if ls[i] == i + 1:
        ls[i], ls[i + 1] = ls[i + 1], ls[i]
        res += 1
if ls[n - 1] == n:
    res += 1
print(res)

Measured memory_bytes: 13880
n, m, k = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
pa, pb = [0] * (n+1), [0] * (m+1)
for i in range(n):
    pa[i+1] = pa[i] + a[i]
for i in range(m):
    pb[i+1] = pb[i] + b[i]
mx = 0
j = m
for i in range(n+1):
    if pa[i] > k:
        break
    v = k - pa[i]
    while pb[j] > v:
        j -= 1
    mx = max(mx, i+j)
print(mx)


Measured memory_bytes: 47612
// 去吧！皮卡丘! 把AC带回来！
//      へ　　　　　／|
// 　　/＼7　　　 ∠＿/
// 　 /　│　　 ／　／								AC		AC		AC		AC
//    │　Z ＿,＜　／　　 /`ヽ						AC		AC		AC		AC
//    │　　　　　ヽ　　 /　　〉					AC		AC		AC		AC
// 　Y　　　　　`　 /　　/  /						AC		AC		AC		AC
// 　亻●　.　●　　〈　/　/						AC		AC		AC		AC
// 　()　 へ　　　　|　＼〈							AC		AC		AC		AC
// 　　>- ._　 ィ　 │ ／／							AC		AC		AC		AC
// 　 / へ　　 /　/＜| ＼＼							AC		AC		AC		AC
// 　 ヽ_/　　(_／　 │／／							AC		AC		AC		AC
// 　　 7　　　　　　　|／							AC		AC		AC		AC
// 　　 ＞―r￣￣`-―＿/							AC		AC		AC		AC
//**************************************Accepted*****************************************//

#include<bits/stdc++.h>

#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define Unique(x) x.erase(unique(all(x)),x.end());

using namespace std;

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

const int Days[]={-1,31,28,31,30,31,30,31,31,30,31,30,31};

inline int read()
{
	#define gc getchar
	int ans=0;
	bool f=1;
	char ch=gc();
	
	while(!isdigit(ch))f^=ch=='-',ch=gc();
	
	while(isdigit(ch))ans=((ans<<2)+ans<<1)+(ch^48),ch=gc();
	
	return f?ans:-ans;
	
	#undef gc
}

typedef long long ll;

queue<ll> v;

int main(int argc, char const *argv[])
{
	ios::sync_with_stdio(false);
	
	ll k;
	scanf("%lld",&k);
	double st=clock();
	
	v.push(1ll);
	v.push(2ll);
	v.push(3ll);
	v.push(4ll);
	v.push(5ll);
	v.push(6ll);
	v.push(7ll);
	v.push(8ll);
	v.push(9ll);
	
	for(ll i=1;i<k;i++)
	{
		ll x=v.front();v.pop();
		
		if(x%10!=0)v.push(10*x+(x%10)-1);
		v.push(10*x+(x%10));
		if(x%10!=9)v.push(10*x+(x%10)+1);
	}
	
	printf("%lld\n",v.front());
	
//	printf("Time used = %.3f s",(double)(clock()-st)/CLOCKS_PER_SEC);
	return 0;
}

/*  GOD BLESS  */


Measured memory_bytes: 1792
#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);
	
	int n;
	cin >> n;
	
	map<PII, int> mp;
	
	FOR(i, 1, n + 1)
	{
		int t = i;
		VI d;
		while(t)
		{
			d.PB(t % 10);
			t /= 10;
		}
		
		mp[MP(d[0], d.back())]++;
	}

	LL ans = 0;
	FOR(i, 1, 10) FOR(j, 1, 10)
		ans += mp[MP(i, j)] * (LL) mp[MP(j, i)];
	
	//FOR(i, 1, 10) if (i <= n) ans -= mp[MP(i, i)];	
	cout << ans << endl;
	
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int n;
    int a[101];
    int cnt = 0;
    int current = 0;

    cin >> n;

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

    for (int i = 0; i < n; i++) {
        if (a[i] == 1) {
            current++;
        }
        else {
            if (cnt < current) {
                cnt = current;
            }
            current = 0;
        }
    }

    if (cnt < current) {
        cnt = current;
    }
    cout << cnt + 1 << endl;
}
        



Measured memory_bytes: 3136
<?php
$n=trim(fgets(STDIN));

$ai=array('S'=>0,'H'=>1,'C'=>2,'D'=>3);
$ia=array('S','H','C','D');

$fl=[];
for($i=0;$i<4;$i++){
  $fl[$i]=[];
  for($j=1;$j<=13;$j++){$fl[$i][$j]=1;}
}

for($i=0;$i<$n;$i++){
  list($a,$b)=explode(' ',trim(fgets(STDIN)));
  $fl[$ai[$a]][$b]=0;
}

$o='';
for($i=0;$i<4;$i++){
  for($j=1;$j<=13;$j++){
    if($fl[$i][$j]){
      $o.=$ia[$i].' '.$j.PHP_EOL;
    }
  }
}
print $o;

Measured memory_bytes: 15468
def shave(n):
    n_root = int(n**0.5)
    candidate = [i for i in range(3,n+1,2)]
    for i in range(3,n_root+2,2):
        candidate = [ j for j in candidate if j == i or j % i != 0]   
    candidate = [2] + candidate
    return candidate

mod = 10**9+7
n = int(input())
factor_list = shave(n)
lf = len(factor_list)
num_list = [ 0 for i in range(lf) ]

ans = 1

if n > 1:
	k = 0
	for i in factor_list:
		a = i
		
		for j in range(10):
			if a > n:
				break
			else:
				num_list[k] += (n // a)
				a *= i
		k += 1

	for i in num_list:
		ans = ( ans * (i+1) ) % mod

print(ans)	



Measured memory_bytes: 3064
// 基本テンプレート
#define _GLIBCXX_DEBUG // for STL debug
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

signed main() {
    int N, T; cin >> N >> T;
    int start = 0, ma = 0;
    for(int i=0; i<N; i++) {
        int w; cin >> w;
        ma = max(ma, w);

        int rest = max(0LL, T - start);
        int ans = rest / ma + 1;
        int mod = rest % ma;
        if(w < ma and mod >= w) ans++;
        cout << ans << endl;
        
        start += w;
    }
    return 0;
}



Measured memory_bytes: 3116
#include <iostream>
#include <vector>
#include <stack>
#include <map>
#include <string>

using Edge = std::map< std::string, int>;
using Tree = std::map<int, std::vector<Edge> >;

int main(int argc, char *argv[]){
    int N, Q;
    std::cin >> N >> Q;

    int a,b;
    Tree tree;
    Edge edge;
    for(int i=0; i<N-1; ++i){
        std::cin >> a >> b;
        edge.clear();
        edge["child"] = b;
        tree[a].emplace_back(edge);
        edge["child"] = a;
        tree[b].emplace_back(edge);
    }

    std::vector<int> X(N,0);
    int p,x;
    for(int i=0; i<Q; ++i){
        std::cin >> p >> x;
        X[p-1] += x;
    }


    std::vector<bool> isVisited(N,false);
    std::vector<int> sum(N);
    std::stack<int> stack;
    int parent = 1;
    sum[parent-1] = X[parent-1];
    isVisited[parent-1]=true;
    stack.push(parent);
    int child;
    while(!stack.empty()){
        parent = stack.top();
        stack.pop();
        for(auto &edge : tree[parent]){
            child = edge["child"];
            if(!isVisited[child-1]){
                sum[child-1] = sum[parent-1]+X[child-1];
                isVisited[child-1] = true;
                stack.push(child);
            }
        }
    }

    for(int i=0; i<N; ++i){
        std::cout << sum[i] << " ";
    }
    std::cout << std::endl;
    return 0;
}

Measured memory_bytes: 80000
/**
*author: Ritchie Zhang
*date:2020/5/10
**/
#include <bits/stdc++.h>
using namespace std;
int main() 
{
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	int max = 0;
	if (a>=k)
	{
		max = max + k;
	}
	else if (a + b >= k) 
	{
		max = max + a;
	}
	else
	{
		max = max + a;
		for (int i = 0; i < k-a-b; i++)
		{
			max = max - 1;
		}
		
	}
	
	cout << max << endl;
	return 0;
}

Measured memory_bytes: 3636
package main

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

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func main() {
	var scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	var n, x int
	if scanner.Scan() {
		tmp := scanner.Text()
		n, _ = strconv.Atoi(tmp)
	}
	if scanner.Scan() {
		tmp := scanner.Text()
		x, _ = strconv.Atoi(tmp)
	}

	var xs []int
	xs = append(xs, x)
	for i := 0; i < n; i++ {
		if scanner.Scan() {
			tmp := scanner.Text()
			x, _ = strconv.Atoi(tmp)
			xs = append(xs, x)
		}
	}
	sort.Ints(xs)

	var ds []int
	for i := 0; i < n; i++ {
		ds = append(ds, xs[i+1]-xs[i])
	}

	ret := ds[0]
	for i := 1; i < n; i++ {
		ret = gcd(ret, ds[i])
	}
	fmt.Println(ret)
}


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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vll = vector<ll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	for (auto &u : v) os << u << el;
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}

int main() {
	int sq[3][3];
	int X;
	cin >> sq[0][0] >> sq[0][1] >> sq[1][1];
	X = 3 * sq[1][1];
	sq[0][2] = X - sq[0][0] - sq[0][1];
	sq[2][1] = X - sq[0][1] - sq[1][1];
	sq[2][2] = X - sq[0][0] - sq[1][1];
	sq[1][2] = X - sq[0][2] - sq[2][2];
	sq[2][0] = X - sq[2][1] - sq[2][2];
	sq[1][0] = X - sq[1][1] - sq[1][2];
	for (int i = 0; i < 3; i++) {
		cout << sq[i][0];
		for (int j = 1; j < 3; j++) cout << " " << sq[i][j];
		cout << el;
	}
	return (0);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <string>
#include <climits>
#include <map>
#include <set>
using namespace std;
#define Rep(i, n) for (int i = 0; i < (n); ++i)
#define InitRep(i, begin, n) for (int i = (begin); i < (n); ++i)
#define RepItr(it, begin, end) for (auto it = (begin); it != (end); ++it)
using int64 = long long;
using vint = vector<int>;
using vint64 = vector<int64>;

static double pi = ::acos(-1);

int main()
{
    double a, b, x;
    cin >> a >> b >> x;
    double rad;
    if (2 * x > a * a * b)
    {
        rad = ::atan(2 * (a * a * b - x) / (a * a * a));
        
    }
    else
    {
        rad = ::atan(a * b * b / 2 / x);
    }
    double deg = rad * 180 / pi;
    cout << setprecision(10) << deg << endl;

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int main(void){
	int n,i,b[100100],ans;
	cin >> n;
	for(i=1; i<n; ++i){
		cin >> b[i];
	}
	ans = b[1]+b[n-1];
	for(i=2; i<n; ++i){
		ans += min(b[i-1],b[i]);
	}
	cout << ans << endl;
	return 0;
}


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


struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  
  while(x->left != NIL){
    x = x -> left;
  }
  return x;
  
}

Node treeSearch(Node u, int k){
  
  if(u == NIL || k == u->key){
    return u;
  }
  
  if(k < u->key){
    return treeSearch(u->left,k);
  }
  else {
    return treeSearch(u->right,k);
  }

}

Node treeSuccessor(Node x){
  
  Node y;

  if(x->right != NIL){
    return treeMinimum(x->right);
  }
  
  y = x->parent;
  
  while(y != NIL && x == y->right){
    x = y;
    y = y->parent;
  }
  return x;
  
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y

  if (z->left == NIL || z->right == NIL){ 
       y = z;
  }
  else {
    y = treeSuccessor(z);
  } 

  if (y->left != NIL){
    x = y->left;
  }
  else {
    x = y->right;
  }
  

  if (x != NIL){
    x->parent = y->parent; 
  }

  if (y->parent == NIL){
      root = x;
  } 
  else if(y == y->parent->left){ 
    y->parent->left = x;
  }
  else{                  
    y->parent->right = x;
  }

  
  if (y != z){
    z->key = y->key;
  }
  
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
  
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  
  while(x != NIL){
    y = x;
    
    if(z->key < x->key){
      x = x->left;
    }     
    else {
      x = x->right;
    }
  }

  z->parent = y;
  
  if(y == NIL){
    root = z;
  }
  else if(z->key < y->key){
    y->left = z;
  }
  else {
    y->right = z;
  }
  
}

void inorder(Node u){
  if(u != NIL){
    
    
    
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
    
  }
}
void preorder(Node u){
 if(u != NIL){
   printf(" %d",u->key);
   preorder(u->left);
   preorder(u->right);
  
 }
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
  
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }
  return 0;
}

Measured memory_bytes: 24040
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();
        System.out.println(c + " " + a + " " + b);
    }
}


Measured memory_bytes: 22356
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

int n,t;
int a[3010],b[3010];
int dp1[3010][3010],dp2[3010][3010];

void solve(){
    cin >> n >> t;
    rep(i,n){
        cin >> a[i] >> b[i];
    }
    rep(i,n){
        rep(j,t){
            if(j+a[i]<t) dp1[i+1][j+a[i]]=max(dp1[i+1][j+a[i]],dp1[i][j]+b[i]);
            dp1[i+1][j]=max(dp1[i+1][j],dp1[i][j]);
        }
    }
    per(i,n){
        rep(j,t){
            if(j+a[i]<t) dp2[i][j+a[i]]=max(dp2[i][j+a[i]],dp2[i+1][j]+b[i]);
            dp2[i][j]=max(dp2[i][j],dp2[i+1][j]);
        }
    }
    rep(i,n+1){
        Rep(j,1,t){
            dp1[i][j]=max(dp1[i][j],dp1[i][j-1]);
            dp2[i][j]=max(dp2[i][j],dp2[i][j-1]);
        }
    }
    int ans=0;
    rep(i,n){
        rep(k,t){
            ans=max(ans,dp1[i][k]+dp2[i+1][t-k-1]+b[i]);
        }
    }
    cout << ans << endl;
}

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

Measured memory_bytes: 70912
mid = 0
end = 0
re = 0

while(1):
    mid, end, re = map(int, input().split() )
    if (mid == -1) and (end == -1) and (re == -1) :
        break

    if (mid == -1) or (end == -1):
        print("F")
    elif mid + end >= 80:
        print("A")
    elif mid + end >= 65:
        print("B")
    elif mid + end >= 50:
        print("C")
    elif mid + end >= 30:
        if re >= 50:
            print("C")
        else: print("D")
    else: print("F")


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

int main()
{
    //ios_base::sync_with_stdio(false);
    //cin.tie(0);
    long long n;
    while(cin >> n)
    {
        long long p = n;
        long long sum  = 0;
        while(p > 0)
        {
            sum += p % 10;
            p /= 10;
         //   cout<<sum<<" "<<p<<endl;
        }
        if(n % sum == 0)cout<<"Yes\n";
        else cout<<"No\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define db(x) cout<<x<<" "
#define db1(x) cout<<x<<'\n'
#define db2(x,y) cout<<x<<" "<<y<<'\n'
#define db3(x,y,z) cout<<x<<" "<<y<<" "<<z<<'\n'
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pair(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define ll  long long int
#define vi vector<ll>
#define pi pair<ll,ll>
#define vpi vector<pair<ll,ll>>
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define mod 1000000007
#define MAX_N 100000
using namespace std;
// int dx[4] = {1,-1,0,0};
// int dy[4] = {0,0,1,-1};
int n;
int mat[22][22];
bool boy[21];
bool girl[21];
ll dp[22][1<<22];
ll check(ll i,ll w){
    if(i==n){
        return w==0;
    }

    if(dp[i][w]!=-1)
        return dp[i][w];

    ll ans = 0;
    for(int k=0;k<n;k++){
        ll mask = (1<<k);
        if((w&mask)!=0 && mat[i][k]==1){
            w = w^mask;
            ans+=check(i+1,w);
            ans%=mod;
            w = w^mask;
        }
    }
    return dp[i][w] = ans;
}

void solve(){

    cin>>n;
    rep(i,n){
        rep(j,n){
            cin>>mat[i][j];
        }
        boy[i]=false;
        girl[i]=false;
    }
    memset(dp,-1,sizeof(dp));
    ll ans = check(0,(1<<n)-1);
    db1(ans);
}
int main(){ 

int t=1;
//cin>>t;
while(t--){
 solve();
}
  return 0; 
}


Measured memory_bytes: 721152
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#include <bits/stdc++.h>
 
using namespace std;
 
int main(void) {
    ll n, k, ans = 0;
    cin >> n >> k;
    bool sunuke[n];
    rep(i, n){
        sunuke[i] = false;
    }
    rep(i, k){
        ll d;
        cin >> d;
        rep(j, d){
            ll a;
            cin >> a;
            sunuke[a-1] = true;
        }
    }
    rep(i, n){
        if(!sunuke[i]){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define res(n) resize(n)
#define rev(v) reverse(v.begin(),v.end())
#define sor(v) sort(v.begin(),v.end())
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define vector ve
#define priority_queue pq
using namespace std;
typedef long long ll;


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

    double ans = 0;

    ll a = 0;
    if (d == 0) a = n;
    else if(1+d <= n-d) a = 2*d + (n-2*d)*2;
    else a = (n+1-(1+d)) + (n-d);

    //out(a);


    ans = (double(m)-1)/double(n)/double(n)*a;
    cout << fixed << setprecision(10);
    out(ans);

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){

  int debt=100000;
  int n,i,rs=0,tmp=0,ans=0;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    debt=debt*1.05;
    if(debt%1000!=0){
      debt=(debt/1000+1)*1000;
    }
  }
  printf("%d\n",debt);
  return 0;
}


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

const int INF = (int)1e9;
struct dat {
    int x, y, d;
};

int H, W;
char grid[1000][1000];
int dist[1000][1000];
int ans = 0;

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

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

    queue<dat> que;
    cin >> H >> W;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> grid[i][j];
            dist[i][j] = INF;
            if (grid[i][j] == '#') {
                que.push({i, j, 0});
                dist[i][j] = 0;
            }
        }
    }

    while (que.size()) {
        dat from = que.front(); que.pop();

        for (int i = 0; i < 4; i++) {
            int nx = from.x+dx[i], ny = from.y+dy[i];
            if (0 <= nx && nx < H && 0 <= ny && ny < W && dist[nx][ny] == INF) {
                que.push({nx, ny, from.d+1});
                dist[nx][ny] = from.d+1;
                ans = max(ans, dist[nx][ny]);
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 17296
import java.util.*;
import java.lang.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		long NN = sc.nextLong();
		long a = 0;
		long b = 0; 
		String S = String.valueOf(NN);
		int R = S.length()/2+S.length()%2;
		if( S.length()<5 ){
			R = S.length();
		}    
		if( NN==1000000000000L ){
			R = 6;          
        }          
		long c = 1;
		for( int i=0; i<R; i++ ){
			c = c*10;
		}
		long A = 0,B = 0;      
		for( int i=1; i<=c; i++ ){
			a++;
			b = NN/a;
			if( NN%a==0 ){
				A = a;
				B = b;              
			}
			if( a>=b ){
				break;              
            }              
			if( i==c ){
				A = NN;
				B = 1;
			}
		}
		System.out.println((A-1)+(B-1));
	}
}


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

using namespace std;

using ll = long long;

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

    int n;

    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; ++i)
        cin >> a[i];

    ll ans = 0;
    for (int i = 0; i < n; ++i)
        for (int j = i + 1; j < n; ++j)
            ans = max(ans, abs(a[i] - a[j]));

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
<?php

ini_set('error_reporting', E_ALL & ~E_NOTICE & ~E_WARNING);
ini_set('display_errors', 'Off');

// define('DEBUG', true);
define('DEBUG', false);

$GroupA = array(1, 3, 5, 7, 8, 10, 12);
$GroupB = array(4, 6, 9, 11);

fscanf(STDIN, "%d %d", $x, $y);
if (in_array($x, $GroupA) && in_array($y, $GroupA)) {
    echo "Yes\n";
} else if (in_array($x, $GroupB) && in_array($y, $GroupB)) {
    echo "Yes\n";
} else {
    echo "No\n";
}


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

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}



void _main() {
        int a, b, x; cin >> a >> b >> x;
        if (x < a || x > a + b) cout << "NO";
        else cout << "YES";
}



signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}


Measured memory_bytes: 3600