akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
public class Main {
		
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		for(int i = 0; i < 3; i++) {
			int s1 = 0;
			int s2 = 0;
			
			s1 += stdIn.nextInt() * 3600;
			s1 += stdIn.nextInt() * 60;
			s1 += stdIn.nextInt();
			
			s2 += stdIn.nextInt() * 3600;
			s2 += stdIn.nextInt() * 60;
			s2 += stdIn.nextInt();
			
			s1 = s2 - s1;
			
			int h = s1 / 3600;
			s1 -= h*3600;
			int m = s1 / 60;
			s1 -= m*60;
			
			System.out.println(h + " " + m + " " + s1);
			
			
		}
		
		
		
	}
}

Measured memory_bytes: 15344
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define INF  1e9
int main(){
    int N,C; cin>>N>>C;
    vector<vector<int>>dp(C+10,vector<int>(100*100+100,-INF));
    using pii= pair<int, int>;
    using piii = pair<pii,int>;
    vector<piii>v;
    vector<int>sum(N,0);
    rep(i,N){
        int a,b,c; cin>>a>>b>>c;
        v.push_back(piii(pii(a,b),c));
        sum[i]+=(a+b);
        if(i)sum[i]+=sum[i-1];
    }
    dp[C][0]=0;
    for(int i=0; i<N;i++){
        for(int cost=0;cost<=C;cost++){
            for(int val=100*100+10;val>=0;val--){
                if(dp[cost][val]==-INF)continue;
                if(cost-v[i].second<0)continue;
                if(val+dp[cost][val]>sum[i])continue;
                dp[cost-v[i].second][val+v[i].first.first]
                =max(dp[cost-v[i].second][val+v[i].first.first],dp[cost][val]+v[i].first.second);
                dp[cost-v[i].second][val+v[i].first.second]
                =max(dp[cost-v[i].second][val+v[i].first.second],dp[cost][val]+v[i].first.first);
            }
        }
    }
    int ans=0;
    rep(j,C+1){
        rep(i,100*100+100){
            if(dp[j][i]!=INF)ans=max(ans,min(i,dp[j][i]));
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 7360
import java.util.Scanner;
public class Main{
	int n,p,d1,d2,maxp,max;
	int sw=1;
	public void inout(){
		Scanner sc = new Scanner(System.in);
		while(sw==1){
			n= sc.nextInt();
			if(n==0){
				break;
			}else{
				max=-1;
				for(int i =0;i<n;i++){
					p=sc.nextInt();
					d1=sc.nextInt();
					d2=sc.nextInt();
					
					if(max<d1+d2){
						max=d1+d2;
						maxp=p;
					}
				}
				System.out.println(maxp+" "+max);
			}
		}
	}
	public static void main(String[] args){
		Main obj = new Main();
		obj.inout();
	}
}

Measured memory_bytes: 157784
n,k = map(int,input().split())
a = list(map(int,input().split()))

ng = 0
ok = 10**9

while ng < ok-1:
    mid = (ng+ok)//2
    
    count = sum((ai-1)//mid for ai in a)
    if count<=k: ok = mid
    else: ng = mid

print(ok)

Measured memory_bytes: 30924
def main():
    N, K = [int(x) for x in input().strip().split()]
    line = [int(x) for x in input().strip().split()]
    counter = K - 1
    result = 0
    while counter < N:
        counter += K - 1
        result += 1
    if counter - (K - 1) < N - 1:
        result += 1
    print(result)


if __name__ == '__main__':
    main()


Measured memory_bytes: 13880
import Data.List

main :: IO ()
main = do
    [a,b,c] <- map read.words <$> getLine :: IO [Int]
    putStrLn $ if (length(findIndices (==5) [a,b,c])==2 && length(findIndices (==7) [a,b,c])==1) then "YES" else "NO"
     
            

Measured memory_bytes: 508
N = int(input())
s = []
for i in range(N):
    s.append(input())
M = int(input())
t = []
for i in range(M):
    t.append(input())

ans = 0
while len(s) > 0:

    i += 1
    s_tmp = s[0]
    ans_tmp = s.count(s_tmp) - t.count(s_tmp)

    while s.count(s_tmp) > 0:
        s.remove(s_tmp)
    while t.count(s_tmp) > 0:
        t.remove(s_tmp)

    if ans_tmp > ans:
        ans = ans_tmp

print (max(ans, 0))


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

const int MAX = 1000000;
vector<int> euler_phi_table(const int n = MAX + 1) {
	vector<int> euler;
	for(int i = 0; i < n; ++i)
		euler.push_back(i);

	for(int i = 2; i < n; ++i)
		if(euler[i] == i)
			for(int j = i; j < n; j += i)
				euler[j] = euler[j] / i * (i - 1);

	return euler;
}

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

	vector<int> euler = euler_phi_table();
	vector<long long> f(1, 1);
	for(int i = 1; i <= MAX; ++i)
		f.push_back(f[i - 1] + euler[i]);

	int t;
	cin >> t;

	for(int i = 0; i < t; ++i) {
		int n;
		cin >> n;

		cout << f[n] << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 14876
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define sd(x)   scanf("%g",&x)
#define ss(s)	scanf("%s",s)
#define pd(x)   printf("%g\n",x)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define nline   printf("\n")
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define fitr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
int main()
{
    int n,i;
    si(n);
    ll int temp,mtn,res=0;
    sl(temp);
    mtn = temp;
    Fo(i,1,n)
    {
        sl(temp);
        if(temp>mtn)
        mtn = temp;
        if(temp<mtn)
        res = res+(mtn-temp);
    }
    pl(res);
}

Measured memory_bytes: 3748
#include<stdio.h>

int main (void) {

int a,b,c,d ;

/*printf("??´??°?????\?????????????????????");*/


scanf("%d",&a);

scanf("%d",&b);

c=a*b;


d=(2*a)+(2*b);


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


return 0 ;


}

Measured memory_bytes: 596
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>

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

const int INF = 1 << 24;
const int dx[4] = {0, 0, 1, -1}, dy[4] = {1, -1, 0, 0};

typedef unsigned long long ull;

int N, T, S;
int A[3000], B[3000], dp[3000][3001];

int main(){
    std::cin >> N >> T >> S;
    
    REP(i, N){
        std::cin >> A[i] >> B[i];
    }

    REP(i, T+1){
        dp[0][i] = 0;
    }

    REP(i, T+1){
        if(i+B[0] <= T && (i+B[0] <= S || S <= i)){
            dp[0][i+B[0]] = A[0];
        }
    }

    REP(i, N-1){
        REP(j, T+1){
            dp[i+1][j] = std::max(dp[i+1][j], dp[i][j]);
            if(j+B[i+1] <= T && (j+B[i+1] <= S || S <= j)){
                dp[i+1][j+B[i+1]] = std::max(dp[i+1][j+B[i+1]], dp[i][j] + A[i+1]);
            }
        }
    }
    
    int res = 0;
    REP(i, T+1){
        res = std::max(res, dp[N-1][i]);
    }
    
    std::cout << res << std::endl;
}

Measured memory_bytes: 36352
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
int main() {
	int H, W, N;
	cin >> H >> W >> N;
	vector<vector<int> > G(H + 1);
	G[H].push_back(0);
	for (int i = 0; i < N; ++i) {
		int X, Y;
		cin >> X >> Y;
		if (X >= Y) G[X - 1].push_back(Y - 1);
	}
	for (int i = 0; i <= H; ++i) {
		sort(G[i].begin(), G[i].end());
	}
	int lim = 0, ans = -1;
	for (int i = 0; i < H && ans == -1; ++i) {
		for (int j = G[i].size() - 1; j >= 0; --j) {
			if (lim <= i - G[i][j] && i - G[i][j] <= lim + 1) lim = i - G[i][j] + 1;
		}
		for (int j = 0; j < G[i + 1].size(); ++j) {
			if (i - G[i + 1][j] >= lim) {
				ans = i + 1;
				break;
			}
		}
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 10240
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)
#define REV(X, Y, Z) for (ll(X) = (Y); (X) > (Z); (X)--)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMod = 1e9 + 7;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

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

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  string S;
  cin >> S;
  const char* s = S.c_str();
  unordered_map<char, ll> R;
  REP(i, 0, S.size()) {
    if (R.find(s[i]) != R.end()) {
      R[s[i]]++;
    } else {
      R.emplace(s[i], 1);
    }
  }
  ll ok = true;
  for (const auto& r : R) {
    if (r.second % 2 != 0) {
      ok = false;
      break;
    }
  }
  if (ok) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N;
ll X[int(1e5+5)], Y[int(1e5+5)];
Pli P[int(1e5+5)];
bool visited[int(1e5+5)];
vector <Pli> Graph[int(1e5+5)];

int main(){
  cin >> N;
  for (int i = 0; i < N; i++){
    cin >> X[i] >> Y[i];
    P[i] = {X[i], i};
  }
  sort(P, P + N);
  for (int i = 0; i < N-1; i++){
    ll D = abs(P[i].fi - P[i+1].fi);
    Graph[P[i].se].push_back({D, P[i+1].se});
    Graph[P[i+1].se].push_back({D, P[i].se});
  }

  for (int i = 0; i < N; i++) P[i] = {Y[i], i};
  sort(P, P + N);
    for (int i = 0; i < N-1; i++){
    ll D = abs(P[i].fi - P[i+1].fi);
    Graph[P[i].se].push_back({D, P[i+1].se});
    Graph[P[i+1].se].push_back({D, P[i].se});
  }

  priority_queue <Pli, vector<Pli>, greater<Pli> > que;
  que.push({0, 0});
  ll ans = 0;
  while (!que.empty()){
    Pli Q = que.top(); que.pop();
    if (visited[Q.se]) continue;
    visited[Q.se] = true;
    ans += Q.fi;
    for (int i = 0; i < Graph[Q.se].size(); i++){
      Pli next = Graph[Q.se][i];
      if (visited[next.se]) continue;
      que.push(next);
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 19832
# 埋める配列
# dp[i][w] : i番目までのお菓子で、重さの総和がw以下となる選び方の最大値

# 計算方法
# dp[0][j] = 0
# dp[i][j] = max(dp[i - 1][j],              #i番目のお菓子を使わないパターン
#               dp[i - 1][j - wi] + vi)     #i番目のお菓子を使ったパターン

# 埋める順序
# iが小さい順、jは好きな順

N, W = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(N)]

dp = [[0 for w in range(W + 1)] for i in range(N + 1)]

for i in range(1, N + 1):
    wi, vi = wv[i - 1]
    for j in range(W + 1):
        dp[i][j] = dp[i - 1][j]
        if j - wi >= 0:
            dp[i][j] = max(dp[i- 1][j], dp[i - 1][j - wi] + vi)

answer = -1
for d in dp:
    answer = max(answer, max(d))
print(answer)

Measured memory_bytes: 171656
#include <bits/stdc++.h>
#define lol long long
using namespace std;
int main(){
  lol n,m[200010],ans=0;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>m[i];
  }
  sort(m,m+n);
  for(int i=0;i<n-1;i++){
    if(m[i]==m[i+1]){
      ans=1;
      break;
    }
  }
  if(ans==0) cout<<"YES\n";
  else cout<<"NO\n";
  return(0);
}


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

int main(){
  int N, K;
  cin >> N >> K;
  int A_tmp, A[N]={0};
  for (int i=0;i<N;i++){
    cin >> A_tmp;
    A[A_tmp-1]++;
  }
  sort(A, A+N, greater<int>());
  
  int64_t retval = 0;
  for (int i=K;i<N;i++){
    retval += A[i];
  }

  cout << retval << endl;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {

	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int x = 1;
		for (int i = 0; i < n; i++) {
			if (x * 2 > x + k) {
				x += k;
			} else {
				x *= 2;
			}
		}
		System.out.println(x);
	}
}


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

bool check(int N) {
    for (int i = 1; i < 10; i++) {
        for (int j = 1; j < 10; j++) {
            if (N == i * j) return true;
        }
    }
    return false;
}

int main() {
    int N;
    cin >> N;
    if (check(N)) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int lli;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    lli N;
    cin >> N;
    vector<lli> X(N);
    REP(i, 0, N) {
        cin >> X[i];
    }
    sort(begin(X), end(X));
    lli ans = 0;
    if (N % 2 == 0) {
        vector<int> sng(N);
        REP(i, 0, N / 2) {
            sng[2 * i] = 2;
            sng[2 * i + 1] = -2;
        }
        sng[0] = 1;
        sng[1] = -1;
        sort(begin(sng), end(sng));
        REP(i, 0, N) {
            ans += sng[i] * X[i];
        }
    } else {
        vector<int> sng(N);
        REP(t, 0, 2) {
            REP(i, 0, N / 2) {
                sng[2 * i] = 2;
                sng[2 * i + 1] = -2;
            }
            sng[0] = (1 - 2 * t);
            sng[1] = (1 - 2 * t);
            sng[N - 1] = (2 * t - 1) * 2;
            sort(begin(sng), end(sng));
            lli tmp = 0;
            REP(i, 0, N) {
                tmp += sng[i] * X[i];
            }
            ans = max(ans, tmp);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <cmath>
using namespace std;
int main(){
	long N,i,x;
 	cin>>N;	
  long min=sqrt(N);
  	for(i=1;i<=sqrt(N)&&i<=1000000;i++){
  	if(N%i==0){
      x=(i-1)+(N/i-1);
     if(min>x)min=x;
    }	
  }
  cout<<x;
  cout<<endl;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(void){
    int A,B,C,X,cnt=0;
    cin >> A >>B >>C >>X;
    for(int i=0;i<=A;i++){
        for(int j=0;j<=B;j++){
            int sa = X - i*500 - j*100;
            if((sa>=0) && (sa<=C*50)) cnt++;
        }
    }
    cout<<cnt;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define max(a, b)	(((a) > (b)) ? (a) : (b))		/* ２個の値の最大値 */
#define min(a, b)	(((a) < (b)) ? (a) : (b))		/* ２個の値の最小値 */
#define ENTER		printf("\n")					/* 改行プリント */
int DBG = 1;										/* デバッグプリント 提出時は0 */
/* main *************************************************************/
int main()
{
	int		a,b,c,i,j,k,n,m,x,y,ans = 0;
	char	str[256];
	
	scanf("%d", &a);
	scanf("%s", str);
	if (a>=3200) printf("%s\n",str);
	else printf("red\n");


	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int countSumOfDigits(int num){
    int sum = 0;    
    while(num > 0){
        int rem = 0;
        
        rem = num % 10;
        sum += rem;

        num /= 10;
    }
    return sum;
}

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

    int S = countSumOfDigits(N);

    if(N % S == 0) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector <vector< int> > vvi;
typedef vector<ll> vl;
typedef vector <vector< ll> > vvl;

#define endl "\n"
#define sp " "
#define M 1000000007
#define PI acos(-1.0)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

#define ini(a,i) memset(a, i, sizeof(a))
#define forf(n,x) for(int x = 0; x < n; ++x)
#define forb(n,x) for(int x = n-1; x >= 0; --x)
#define fori(n,x,i) for(int x=i; x<n; ++x)
#define vin(arr,n) forf(n,_) cin>>arr[_]
#define vout(arr,n) {forf(n,_) cout<<arr[_]<<sp; cout<<endl;}

#define all(c) c.begin(), c.end()
#define itr(c,it) for( auto it = c.begin(); it != c.end(); ++it)

typedef priority_queue <int> pq;

ll modInv(ll a)
{
    ll y = M-2;
    ll ans = 1;
    
    a %= M;
    while (y > 0) 
    { 
        if (y & 1) 
            ans = (ans*a) % M; 
  
        y = y>>1;
        a = (a*a) % M; 
    } 
    return ans;
    
}

int main()
{
	fastio;
	/*
	int quer;
	cin>>quer;
	forf(quer,qe)
	{

	}
	*/
	string a,b;
	cin>>a>>b;
	if(b.length() == a.length()+1 && b.substr(0,a.length()) == a)
	{
			cout<<"Yes";
	}
	else
	{
			cout<<"No";
	}
		
	return 0;
}


Measured memory_bytes: 3656
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>
#include <iomanip>

using namespace std;

int main() {


	int n, m;
	cin >> n >> m;
	if (n <= m) {
		string ans = "";
		for (int i = 0; i < m; i++) {
			ans += ('0' + n);
		}
		cout << ans << endl;
	}
	else {
		string ans = "";
		for (int i = 0; i < n; i++) {
			ans += ('0' + m);
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

int n,k;

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

Measured memory_bytes: 256
#include <iostream>
#include <random>
#include <algorithm>
# define Dice_not_equal dice[j].A_One != dice[k].A_One || dice[j].B_Two != dice[k].B_Two ||dice[j].C_Three != dice[k].C_Three || dice[j].D_Four != dice[k].D_Four ||dice[j].E_Five != dice[k].E_Five || dice[j].F_Six != dice[k].F_Six
const int HOUSES = 4;
const int STORIES = 3;
const int ROOMS = 10;
int house[HOUSES][STORIES][ROOMS];
struct Die
{
	int A_One;
	int B_Two;
	int C_Three;
	int D_Four;
	int E_Five;
	int F_Six;
};
Die GoNorth(Die pips)
{
	int tmp = pips.A_One;
	pips.A_One = pips.B_Two;
	pips.B_Two = pips.F_Six;
	pips.F_Six = pips.E_Five;
	pips.E_Five = tmp;
	return pips;
}
Die GoSouth(Die pips)
{
	int tmp = pips.A_One;
	pips.A_One = pips.E_Five;
	pips.E_Five = pips.F_Six;
	pips.F_Six = pips.B_Two;
	pips.B_Two = tmp;
	return pips;
}
Die GoEast(Die pips)
{
	int tmp = pips.D_Four;
	pips.D_Four = pips.F_Six;
	pips.F_Six = pips.C_Three;
	pips.C_Three = pips.A_One;
	pips.A_One = tmp;
	return pips;
}
Die GoWest(Die pips)
{
	int tmp = pips.A_One;
	pips.A_One = pips.C_Three;
	pips.C_Three = pips.F_Six;
	pips.F_Six = pips.D_Four;
	pips.D_Four = tmp;
	return pips;
}
Die Roll(Die die, char c)
{
	if (c == 'N')
	{
		die = GoNorth(die);
	}
	else if (c == 'W')
	{
		die = GoWest(die);
	}
	else if (c == 'S')
	{
		die = GoSouth(die);
	}
	else
	{
		die = GoEast(die);
	}
	return die;
}
Die RandomShake(Die die)
{
	std::random_device rnd;
	if (rnd() % 2 == 1)
	{
		return GoNorth(die);
	}
	else
	{
		return GoWest(die);
	}
}
bool authDice(std::vector<Die> dice)
{
	for (auto k = 0;k < dice.size();++k)
	{
		bool IsSame = false;
		for (auto j = 0;j < k;++j)
		{
			for (auto i = 0;Dice_not_equal;++i)
			{
				dice[k] = RandomShake(dice[k]);
				if (i > 100)
				{
					IsSame = true;
					break;
				}
			}
			if (!IsSame)
			{
				return false;
			}
		}
	}
	return true;
}
int main()
{
	int in;
	std::cin >> in;
	std::vector<Die> dice;
	while (in--)
	{
		int a, b, c, d, e, f;
		std::cin >> a >> b >> c >> d >> e >> f;
		dice.push_back({ a,b,c,d,e,f });
	}
	std::string ans;
	if (authDice(dice))
	{
		ans = "Yes";
	}
	else
	{
		ans = "No";
	}
	std::cout << ans << std::endl;;
	return 0;
}


Measured memory_bytes: 3200
//#include "stdafx.h"
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <assert.h>
#include <functional>
#include <unordered_map>
#include <cstdint>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define REP(i, n)				for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)			for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF						2e9
#define MOD						(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)				(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)				(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)			((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)				(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)				(!IsOdd((x)))						
#define	BitSetV(Val,Bit)		((Val) |= (Bit))			
#define	BitTstV(Val,Bit)		((Val) & (Bit))				
#define ArrayLength(x)			(sizeof( x ) / sizeof( x[ 0 ]))
#define	MAX_QWORD				((QWORD)0xFFFFFFFFFFFFFFFF)
#define M_PI					3.14159265358979323846
typedef long long				ll;
typedef unsigned long long int	QWORD;
typedef unsigned long long		SQWORD;
typedef pair<ll, ll>			P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
int main()
{
	int N;
	double T, A;

	cin >> N;
	cin >> T >> A;
	vector<double> H(N);
	REP(i, N) cin >> H[i];

	int ansIdx = 0;
	double ansVal = INF;
	REP(i, N) {
		double temp = T - H[i] * 0.006;
		double diff = abs(temp - A);
		if (diff < ansVal) {
			ansIdx = i;
			ansVal = diff;
		}
	}
	cout << ansIdx + 1 << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

template<int Modulo = MOD> struct Mint {
	Int val;
	constexpr Mint(Int v = 0) noexcept : val(v% Modulo) {
		if (val < 0) v += Modulo;
	}
	constexpr int getmod() { return Modulo; }
	constexpr Mint operator - () const noexcept { return val ? Modulo - val : 0; }
	constexpr Mint operator + (const Mint& r) const noexcept { return Mint(*this) += r; }
	constexpr Mint operator - (const Mint& r) const noexcept { return Mint(*this) -= r; }
	constexpr Mint operator * (const Mint& r) const noexcept { return Mint(*this) *= r; }
	constexpr Mint operator / (const Mint& r) const noexcept { return Mint(*this) /= r; }
	constexpr Mint& operator += (const Mint& r) noexcept {
		val += r.val;
		if (val >= Modulo) val -= Modulo;
		return *this;
	}
	constexpr Mint& operator -= (const Mint& r) noexcept {
		val -= r.val;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr Mint& operator *= (const Mint& r) noexcept {
		val = val * r.val % Modulo;
		return *this;
	}
	constexpr Mint& operator /= (const Mint& r) noexcept {
		Int a = r.val, b = Modulo, u = 1, v = 0;
		while (b) {
			Int t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		val = val * u % Modulo;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr bool operator == (const Mint& r) const noexcept {
		return this->val == r.val;
	}
	constexpr bool operator != (const Mint& r) const noexcept {
		return this->val != r.val;
	}
	friend ostream& operator << (ostream& os, const Mint<Modulo>& x) noexcept {
		return os << x.val;
	}
	friend istream& operator >> (istream& is, Mint<Modulo>& x) noexcept {
		Int tmp; is >> tmp;
		x = Mint<Modulo>(tmp);
		return is;
	}
	friend constexpr Mint<Modulo> modpow(const Mint<Modulo>& a, Int n) noexcept {
		Mint res(1), tmp = a;
		while (n > 0) {
			if (n & 1) res *= tmp;
			tmp *= tmp;
			n >>= 1;
		}
		return res;
	}
};

using mint = Mint<>;

int main() {

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

	int x;
	cin >> x;

	if (x == 3)printf("YES\n");
	else if (x == 5)printf("YES\n");
	else if(x == 7)printf("YES\n");
	else printf("NO\n");


}

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


string solve(){
  vector<int> a;
  for(int i=0;i<3;i++){
    int tmp;
    cin>>tmp;
    a.push_back(tmp);
  }

  for(int i=0;i<a.size();i++){
    if(a[i]==100)return "A";
  }
  if(a[0]+a[1]>=90*2)return "A";
  int ave = (a[0]+a[1]+a[2])/3;
  if(ave>=80)return "A";
  if(ave>=70)return "B";
  if(ave>=50)if(a[0]>=80||a[1]>=80)return "B";
  return "C";
}


int main(){
  int n;
  while(cin>>n,n!=0){
    for(int i=0;i<n;i++){
      cout<<solve()<<endl;
    }
  }
}

Measured memory_bytes: 1212
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    class AtCodeeeeeeeeeeeeeeeeeeeer
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            long K = long.Parse(s[0]);
            long A = long.Parse(s[1]);
            long B = long.Parse(s[2]);
            long Biscuit = 1;
            long umami = 0;
            for (int i = 1; i <= K; i++)
            {
                umami = B - A;
                if (umami > 2)
                {
                    if((K - i)+1>=2 && Biscuit >= A)
                    {
                        Biscuit += umami;
                        i++;//2ターン消費させる
                    }
                    else
                    {
                        Biscuit++;
                    }
                }
                else
                {
                    Biscuit++;
                }
            }
            Console.WriteLine(Biscuit);
        }
    }
}


Measured memory_bytes: 11092
#include<stdio.h>

int swap(g, h) {
    int d;
    d = g;
    g = h;
    h = d;
    
    return g, h;
}

		int gcd(x, y) {
			int i;
			if ( x < y ) {
				swap(x, y);
			}
			while ( y > 0 ) {
				i = x % y;
				x = y;
				y = i;
			}
			return x;
}

    int main() {
		int a, b, c;
		scanf("%d %d", &a, &b);
		c = gcd(a, b);
		printf("%d\n", c);
    
    return 0;
}


Measured memory_bytes: 2064
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let (N, M): (usize, usize) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap()
        )
    };
    let (L, R, C): (Vec<usize>, Vec<usize>, Vec<i64>) = {
        let (mut L, mut R, mut C) = (vec![], vec![], vec![]);
        for _ in 0..M {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            L.push(iter.next().unwrap().parse().unwrap());
            R.push(iter.next().unwrap().parse().unwrap());
            C.push(iter.next().unwrap().parse().unwrap());
        }
        (L, R, C)
    };

    struct SegmentTree<T: Clone + Copy>{
        n: usize,
        f: fn(T, T) -> T,
        e: T,
        x: Vec<T>
    }

    impl<T: Clone + Copy> SegmentTree<T> {
        fn new(n: usize, f: fn(T, T) -> T, e: T) -> SegmentTree<T> {
            let m = 1 << format!("{:b}", n).len();
            SegmentTree { n: m, f: f, e: e, x: vec![e; 2 * m - 1] }
        }
        fn update(&mut self, i: usize, y: T) {
            let mut j = i + self.n - 1;
            self.x[j] = y;
            while j > 0 {
                j = (j - 1) / 2;
                self.x[j] = (self.f)(self.x[2 * j + 1], self.x[2 * j + 2]);
            }
        }
        fn find(&self, s: usize, t: usize) -> T { self.q(0, 0, self.n, s, t) }
        fn q(&self, i: usize, l: usize, r: usize, s: usize, t: usize) -> T {
            if l >= t || r <= s { self.e }
            else if s <= l && r <= t { self.x[i] }
            else {
                (self.f)(
                    self.q(2 * i + 1, l, (l + r) / 2, s, t),
                    self.q(2 * i + 2, (l + r) / 2, r, s, t)
                )
            }
        }
    }

    const INF: i64 = 1_000_000_000_000_000;
    let mut dp = SegmentTree::new(N + 1, std::cmp::min, INF);
    dp.update(1, 0);
    let mut E = (0..M).map(|i| (L[i], C[i], R[i])).collect::<Vec<_>>();
    E.sort();
    for &(l, c, r) in &E {
        let x = dp.find(l, N + 1);
        if x + c < dp.find(r, N + 1) {
            dp.update(r, x + c);
        }
    }
    let res = dp.find(N, N + 1);
    let ans = if res < INF { res } else { -1 };
    // for i in 1..(N + 1) {
    //     println!("{}: {}", i, dp.find(i, N + 1));
    // }

    println!("{}", ans);
}


Measured memory_bytes: 18612
#include <iostream>
#include <set>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <map>
using namespace std;

//dp用関数
long long dp_Func(long long h[],long i,long long ans[]){
    long abs_a,abs_b;
    abs_a=ans[i-1]+abs(h[i-1]-h[i]);
    abs_b=ans[i-2]+abs(h[i-2]-h[i]);
    return min(abs_a,abs_b);
}

int main(){
    
    //入力関係
    long n;
    cin >> n;
    long long h[110000];
    for(int i=0;i<n;i++){
        cin >> h[i];
    }
    long long ans[110000];
    
    //dp配列の初項,第2項
    ans[1]=abs(h[0]-h[1]);
    ans[2]=min(abs(h[0]-h[2]),ans[1]+abs(h[1]-h[2]));
    for(int i=3;i<n;i++){
        ans[i]=dp_Func(h,i,ans);
    }
    
    cout << ans[n-1];
}

Measured memory_bytes: 1792
// c++ -std=c++14 atcoder.cpp
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cmath>

using namespace std;

int main() {
    int x, y, z;
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <sstream>
#include <algorithm>
#include <bitset>
#include <limits>
#include <map>
#include <set>
#include <iomanip>
#include <cmath>

using namespace std;

typedef long long int ll;
typedef std::numeric_limits<double> dbl;
const long long int LL_INF=1LL<<60;

vector<string> split(const string& input, char delimiter)
{
    stringstream stream(input);
    
    string field;
    vector<string> result;
    while (getline(stream, field, delimiter)) {
        result.push_back(field);
    }
    return result;
}

//#define DEBUG

ll A, B, M, N, D, K, Q, W, H, T, X, Y;

void minimize(ll &minimum)
{
    for (int h = 1; h < H; ++h) {
        ll restH = H - h;
        ll top = W * h;
        if (restH % 2 == 0) {
            ll rTop = restH / 2 * W;
            minimum = min(minimum, abs(top - rTop));
        } else {
            for (int i = 0; i < 2; ++i) {
                ll rTop = (restH / 2 + i) * W;
                ll rBottom = (H * W - top) - rTop;
                minimum = min(minimum, max(top, max(rTop, rBottom)) -
                                        min(top, min(rTop, rBottom)));
            }
        }
        if (W % 2 == 0) {
            ll left = W / 2 * restH;
            minimum = min(minimum, abs(top - left));
        } else {
            for (int i = 0; i < 2; ++i) {
                ll left = (W / 2 + i) * restH;
                ll right = (H * W - top) - left;
                //cout << top << " " << left << " " << right << endl;
                minimum = min(minimum, max(top, max(left, right)) -                    
                                        min(top, min(left, right)));
            }
        }
    }
}

int main()
{
    cin >> H >> W;

    if (H % 3 == 0 || W % 3 == 0)
        cout << 0 << endl;
    else {

        ll minimum = INT64_MAX;

        minimize(minimum);

        swap(W, H);

        minimize(minimum);

        cout << minimum << endl;

    }
    //cout << fixed << setprecision(10) << M_PI * (double)rad << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <stdio.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
#include <cctype>

using namespace std;

#define Int int64_t

void printVec(std::vector<int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
	vector.erase(vector.begin() + index);
}

int vector_finder(std::vector<string> vec, string number) {
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}

#include <sstream> 
std::vector<std::string> StringSplit(const std::string& str, char sep)
{
	std::vector<std::string> v;
	std::stringstream ss(str);
	std::string buffer;
	while (std::getline(ss, buffer, sep)) {
		v.push_back(buffer);
	}
	return v;
}



int main() {
	string str; cin >> str;
	cout << str[0] << str.size() - 2 << str[str.size() - 1];

	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
const int INT__MAX = 2147483647;
const int MOD = 1000000007;
long long int gcd(long long int num1, long long int num2) {
long long int a, b, qwe;
if (num1 > num2) {

    a = num1;
    b = num2;

}
else {

    a = num2;
    b = num1;

}
qwe = a%b;
while (qwe != 0) {

    a = b;
    b = qwe;
    qwe = a%b;

}
return b;
}
int main() {
int N;
long long int T[105];
long long int hoge, fuga;

cin >> N;
for (int i = 1; i <= N; i++) {

    cin >> T[i];

}
if(N==1){

cout<<T[1]<<endl;

}else{
hoge = gcd(T[1], T[2]);
fuga = (T[1] / hoge)*T[2];
for (int i = 1; i < N; i++) {

    hoge = gcd(fuga, T[i + 1]);
    fuga = (fuga / hoge)*T[i + 1];

}

cout << fuga << endl;

}
return 0;
}


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

#define INF (INT32_MAX)
#define MOD (1000000000+7)
#define MAX 100000

int main() {
	int N, K, X, Y;

	cin >> N >> K >> X >> Y;

	int ans = min( N, K ) * X;
	if( N > K ) {
		ans += (N - K) * Y;
	}

	cout << ans << endl;

	return 0;
}


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

int main(){
  int N;
  bool zero=false;
  int count=0;
  int min=1000000000;
  cin>> N;
  long sum=0;
  for(int i=0; i<N; i++){
    int a; cin >> a;
    if(a==0) zero=true;
    if(a<0) count++;
    if(min>abs(a)) min=abs(a);
    sum+=abs(a);
  }
  if(!(zero || count%2==0)) sum-=2*min;
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
int n,h[maxn],f[maxn];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&h[i]);
	}
	f[1]=0;
	f[2]=abs(h[2]-h[1]);
	for(int i=3;i<=n;i++){
		f[i]=min(f[i-1]+abs(h[i-1]-h[i]),f[i-2]+abs(h[i-2]-h[i]));
	}
	printf("%d",f[n]);
} 

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

#define rep(i,n) for(int i=0;i<n;i++)
///1<<3シフト演算子 とは　0001の1を三つずらして1000にする, これは8を表しておりつまりbitは0から7まで
#define all(x) (x).begin(),(x).end()
#define cyes cout<<"Yes"<<endl
#define cno cout<<"No"<<endl
#define sp <<" "<<
#define CST(x) cout<<fixed<<setprecision(x)
#define PI 3.14159265359
#define MOD 1000000007
using namespace std;
using ll = long long;
using ld = long double;

//条件式 ? 真の場合の文 : 偽の場合の文
//abs(x) = (x の絶対値)
//string S  S,at(i),S += T,S += c,S.size(),S.substr(l)l文字目から最後まで,
///S.substr(l, r)l文字目からl+r-1文字目 n文字目から0個で空列を返せる
//*min_element(all(x)) *max_element(all(x))
//vi x; x.back(),x.front(),x.push_back(),x.pop_back()
//swap(a, b)    c
//gcd(a, b)最大公約数
//sort(all(x)),reverse(all(x)),sort(x.begin()+l,a.begin()+r)lからrまで
//stack<int> a; a.push(x),a.pop(),a.top(),a.empty()bool
//queue<int> b; b.push(x),b.pop(),b.front(),b.empty()bool,b.size() 要素が小さい順
//priority_queue<int, vector<int>, greater<int>> c,c.top()
//map<int, int> M1; 変数[key] = value; 変数.erase(key); 変数.at(key); 変数.count(key)所属判定　変数.size()
//find(all(x), key)boolソート済みのベクトル
//*lower_bound(all(x),k)以上の最小の要素,*uppper_bound(all(x),k)より大きい最小の要素
//char('0'+cnt) 数字cntからcharへの変換
//int(char-'0') charからintへの変換

double key;

bool isOK(double mid) {
    if (tan(mid) > key) return true;
    else return false;
}

// 汎用的な二分探索のテンプレ
double binary_search(int key) {
    double left = 0; //「index = 0」が条件を満たすこともあるので、初期値は -1
    double right = PI/2; // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

    /* どんな二分探索でもここの書き方を変えずにできる！ */
    while (right - left > 0.00000001) {
        double mid = left + (right - left) / 2;

        if (isOK(mid)) right = mid;
        else left = mid;
    }

    /* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
    return right;
}


int main(){
    
    double a,b,x;
    cin >> a >> b >> x;
    double s = x/a;
    double X,Y;
    if(s >= a * b / 2) {
        X = a;
        Y = 2 * (a * b - s) / a;
    }
    else{
        X = 2 * s / b;
        Y = b;
    }
    key = Y / X;
     CST(8) << binary_search(key) * 360 / 2 / PI << endl;

}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
using namespace std;
int main( void )
{
  while( 1 ){
    int n, a;
    cin >> n;
    if( n == 0 ) break;
    int minv = 1001;
    int maxv = -1;
    int s = 0;
    for( int i=0; i<n; i++ ){
      cin >> a;
      s += a;
      minv = min( minv, a );
      maxv = max( maxv, a );
    }
    cout << (s - minv - maxv) / (n - 2) << endl;
  }
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	
	int n; int  l; 
	cin>>n>>l;  
	vector<string> v;
	string x;
	for(int i = 0; i < n; i++){
		cin>>x;
		v.push_back(x);
	}
	
	sort(v.begin(),v.end());
	for(auto xx : v) cout<<xx;
	cout<<"\n";
}

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

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

class UnionFind {
 public:
  vector<ll> parent;
  vector<ll> group_size;

  UnionFind(ll size_) : parent(size_), group_size(size_, 1) {
    iota(parent.begin(), parent.end(), 0);
  }

  ll root(ll x) { return parent[x] == x ? x : parent[x] = root(parent[x]); }

  void merge(ll x, ll y) {
    x = root(x);
    y = root(y);
    if (x == y) return;

    if (group_size[x] < group_size[y]) swap(x, y);
    group_size[x] += group_size[y];
    parent[y] = x;
  }

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

  ll size(ll x) { return group_size[root(x)]; }
};

void solve(ll N, ll M, ll K, vector<ll> A, vector<ll> B, vector<ll> C,
           vector<ll> D) {
  // friends
  vector<set<int>> friends(N);
  UnionFind u(N);
  for (int i = 0; i != M; ++i) {
    auto a = A[i] - 1;
    auto b = B[i] - 1;
    friends[a].insert(b);
    friends[b].insert(a);
    u.merge(a, b);
  }

  vector<set<int>> blocks(N);
  for (int i = 0; i != K; ++i) {
    auto c = C[i] - 1;
    auto d = D[i] - 1;
    blocks[c].insert(d);
    blocks[d].insert(c);
  }

  for (int i = 0; i != N; ++i) {
    auto ans = u.size(i) - 1;
    for (auto x: friends[i]) {
      if (u.same(i,x)) --ans;
    }
    for (auto x: blocks[i]) {
      if (u.same(i,x)) --ans;
    }
    cout << (i ? " " : "") << ans;
  }
  cout << endl;
}

int main() {
  ll N;
  cin >> N;
  ll M;
  cin >> M;
  ll K;
  cin >> K;
  vector<ll> A(M);
  vector<ll> B(M);
  for (int i = 0; i < M; i++) {
    cin >> A[i];
    cin >> B[i];
  }
  vector<ll> C(K);
  vector<ll> D(K);
  for (int i = 0; i < K; i++) {
    cin >> C[i];
    cin >> D[i];
  }
  solve(N, M, K, move(A), move(B), move(C), move(D));
  return 0;
}


Measured memory_bytes: 33664
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    a,b,c=sort(parseMap(split(readline())))
    k=parseInt(readline())
    c=c*(2^k)
    println(sum([a,b,c]))
end
main()

Measured memory_bytes: 168340
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

int main() {
  ll k,a,b;
  cin>>k>>a>>b;
  if(b-a<=2 or a>=k){
    cout<<k+1<<endl;
    return 0;
  }
  ll ans=((k-a+1)%2==0 ? a+(b-a)*((k-a+1)/2) : a+1+(b-a)*((k-a+1)/2));
  cout<<ans<<endl;
  return 0;
}


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

using namespace std;

#define PI  3.14159265358979323846

double cosin(double a, double b, double angle){
	return a*a + b*b - 2 * a * b * cos(angle);
}


double calcAngle(double h, double m)  
{  
    if (h == 12) h = 0;  
    if (m == 60) m = 0;  
  	double hour_angle = 0.5 * (h * 60 + m);  
    double minute_angle = 6 * m;  
    double angle = fabs(hour_angle - minute_angle);  
    angle = min(360.0 - angle, angle);  
    return angle;  
}  


int main(){
	double a,b,h,m;
	cin >> a >> b >> h >> m;
	double angle = calcAngle(h,m) * PI / 180.0;
	double dis = sqrt(cosin(a,b,angle));
	cout << fixed << setprecision(12) << "\n"; 
	cout << dis  << "\n";
	return 0;
}


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

#define fi first
#define se second
#define be begin
#define en end
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(a) (a).be() , (a).en()
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)        //repeat n times
#define REP2(i,s,n) for(int (i)=(s);(i)<(n);(i)++)   //repeat from s to n 
#define REPD(i,n) for(int (i)=(n);(i)>=0;(i)--)      //repeat from n to 0
#define REPD2(i,s,e) for(int (i)=(s);(i)>=(e);(i)--) //repeat from s to e
#define RANGE(i,v) for(auto &(i):v)                  //repeat range
#define ASIZE(a) (sizeof(a) / sizeof(a[0]))          //array size

using LL = long long;

template<typename T> using V = vector< T >;
using Vi = V<int>;
using Vll = V<LL>;
using Vs = V<string>;

template<typename T1,typename T2> using M = map< T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;
using Mci = M<char, int>;

const LL MOD = 1000000007;

//Bipartite method : x^n
LL BMPow(int x,int n,int m=0){
    LL ans=1;LL p=x;
    if(m==0){ while(n>0){if(n&1==1){ans*=p;} p*=p; n>>=1;}}
    else{ while(n>0){if(n&1==1){ans=(ans*p)%m;} p=(p*p)%m ;n>>=1;}}
    return ans;
}

//x^-1=x^(m-2) mod m
LL modInv(LL x,int m){return BMPow(x,m-2,m);}

class Combination{
    V<LL> fact,fact_inv;
    LL mod;
    public:
        Combination(int n,int m): fact(n+1),fact_inv(n+1) {
            mod = m;
            fact[0] = 1;
            for(int i=1; i<=n; i++) fact[i] = (fact[i-1]*i)%mod;
            fact_inv[n] = modInv(fact[n],mod);
            for(int i=n; i>=1; i--) fact_inv[i-1] = (fact_inv[i]*i)%mod;
        }

        LL operator()(int n,int k){
            if(k<0 || k>n) return 0;
            return (((fact[n]*fact_inv[k])%mod)*fact_inv[n-k])%mod;
        }
};

int main(){
    LL n,k;
    cin>>n>>k;

    Combination C(n,MOD);

    REP(i,k){
        cout<<(C(n-k+1,i+1)*C(k-1,i))%MOD<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Graph=vector<vector<int>>;
int main(){
  int N,M;
  cin>>N>>M;
  Graph G(N);
  for(int i=0;i<M;i++){
  int u,v; cin>>u>>v; u--;v--;
    G[u].push_back(v);
  }int s,t;cin>>s>>t; s--; t--;
  vector<vector<int>>dist(3,vector<int>(N,-1));
  dist[0][s]=0;
  vector<int>dist1(N,-1); dist1[s]=0;
  queue<pair<int,int>>que;pair<int,int>p(s,0);que.push(p);
  while(!que.empty()){
  pair<int,int>q=que.front();
    que.pop();int v=q.first;
    for(auto u:G[v]){
      int x=q.second+1;
    int i=x%3;
      if(dist[i][u]!=-1)
        continue;
      else{
      dist[i][u]=x;
        dist1[u]=x;
        pair<int,int>r(u,x);
        que.push(r);
      }
    }
  
  }if(dist[0][t]==-1)
    cout<<-1<<endl;
  else
    cout<<dist[0][t]/3<<endl;
  
  return 0;
}

Measured memory_bytes: 10364
#include <bits/stdc++.h>
 
#define debug(x) cout << '>' << #x << ':' << x << endl
using namespace std;
using ll = long long;
const int M = (int)1e9+ 7;

void solve() {
    ll n, k;
    cin >> n >> k;

    ll ans = 0;
    for (ll i = k; i <= n; ++i) {
        ans = (ans + n*i - i*(i - 1) + 1) % M;
    }
    cout << ans + 1 << "\n";
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int T;
    T = 1;
    // cin >> T;
    for (int t = 1; t <= T; t++){
        // cout << "Case #" << t << ": ";
        solve();
    }
	return 0;
}


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

#pragma GCC optimize("O2")

#define pb push_back
#define mp make_pair
#define ll long long
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REFOR(i, a, b) for(int i = (a); i > (b); i--)

int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0);
    int n, cnt = 0, noc = 0;
    string s;
    cin >> n >> s;
    FOR(i, 0, n)
    	if(s[i] == 'W')
    		cnt++;
    FOR(i, n - cnt, n)
    	if(s[i] == 'W')
    		noc++;
    cout << cnt - noc << "\n";
    
    return 0;
}


Measured memory_bytes: 3716
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <vector>
#include <string>
#include <cmath>
#include <map> 
#include <bitset>
#include <sstream>
#include <cstdio>
#include <complex>
#include <cstring>
using namespace std;
 
const int MAX= 10000100;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()
#define ll long long int
#define gcd(a,b) __gcd(a,b)
#define vi vector<int> 
#define pb(a) push_back(a)
int GCD(int a, int b) {if(!b) return a; return gcd(b, a%b);}
int lcm(int a, int b) {return a*b / gcd(a, b);}

int main(void){
  string s;
  int x,y;
  cin>>s>>x>>y;

  vi dx, dy;
  int rl = 0;
  bool isx = true;

  rep(i, s.size()){
    if(s[i] == 'F'){
      rl ++;
    } else {
      if(isx){
	dx.pb(rl);
      } else {
	dy.pb(rl);
      }
      rl = 0;
      isx = !isx;
    }
  }

  if(isx){
    dx.pb(rl);
  } else {
    dy.pb(rl);
  }
  const int geta = 8000;

  bitset<16010> dpx, dpy;
  dpx.set(dx[0] + geta);
  dpy.set(0+geta);

  dx.erase(dx.begin());

  rep(i,dx.size()){
    dpx = (dpx << dx[i]) | (dpx >> dx[i]);
  }

  rep(i,dy.size()){
    dpy = (dpy << dy[i]) | (dpy >> dy[i]);
  }

  bool res = dpx[x + geta] && dpy[y + geta];

  cout<<(res?"Yes":"No")<<endl;
}


Measured memory_bytes: 256