akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>

using namespace std;

const int MOD = 1e9+7;
const int MAX = 510000;

long long fac[MAX], finv[MAX], inv[MAX];

vector<pair<long long, long long> > prime_factorization(long long N){
    vector<pair<long long, long long> > res;
    for(long long i=2; i*i <= N; ++i){
        if(N % i != 0)continue;
        long long ex = 0;

        while( N%i == 0){
            ex++;
            N /= i;
        }
        res.push_back({i, ex});
    }
    if(N != 1){
        res.push_back({N,1});
    }
    
    return res;
}

// //テーブルを作る前処理
void COMinit(){
    fac[0]  = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;

    for(int i=2; i < MAX; ++i){
        fac[i] = fac[i-1] * i %MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}

// //二項係数
long long COM(int n, int k){
    if( n < k) return 0;
    if(n<0 || k < 0)return 0;
    return fac[n] * (finv[k] * finv[n-k] %MOD) %MOD;
}

int main(){
    long long N, M;
    cin >> N >> M;
    COMinit();

    const auto& res = prime_factorization(M);
    long long ans = 1;
    for(auto prime_ex: res){
        ans *= COM( prime_ex.second+N-1, N-1);
        ans %= MOD;
    }

    cout << ans << endl;
}

Measured memory_bytes: 12288
"""
    こんにちは。これはクシャルです
    
    Author : thekushalghosh (クシャル)
    Team   : CodeDiggers
 
    I prefer Python language over the C++ language :p :D
        
    Visit my website : thekushalghosh.github.io
"""
import sys,math,cmath,time,itertools
start_time = time.time()
##########################################################################
################# ---- THE ACTUAL CODE STARTS BELOW ---- #################
    
def solve():
    a,b,c = invr()
    k = inp()
    q = 0
    while b <= a:
        b = b * 2
        q = q + 1
    w = 0
    while c <= b:
        c = c * 2
        w = w + 1
    if q + w <= k:
        qw = "Yes"
    else:
        qw = "No"
    print(qw)
    
################## ---- THE ACTUAL CODE ENDS ABOVE ---- ##################
##########################################################################
 
def main():
    global tt
    if not ONLINE_JUDGE:
        sys.stdin = open("input.txt","r")
        sys.stdout = open("output.txt","w")
    t = 1
    for tt in range(t):
        solve()
    if not ONLINE_JUDGE:
        print("Time Elapsed :",time.time() - start_time,"seconds")
        sys.stdout.close()
    
#---------------------- USER DEFINED INPUT FUNCTIONS ----------------------#
def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    return(input().strip())
def invr():
    return(map(int,input().split()))
 
#------------------ USER DEFINED PROGRAMMING FUNCTIONS ------------------#
def counter(a):
    q = [0] * max(a)
    for i in range(len(a)):
        q[a[i] - 1] = q[a[i] - 1] + 1
    return(q)

def counter_elements(a):
    q = dict()
    for i in range(len(a)):
        if a[i] not in q:
            q[a[i]] = 0
        q[a[i]] = q[a[i]] + 1
    return(q)

def string_counter(a):
    q = [0] * 26
    for i in range(len(a)):
        q[ord(a[i]) - 97] = q[ord(a[i]) - 97],1
    return(q)
 
def factors(n):
    q = []
    for i in range(1,int(n ** 0.5) + 1):
        if n % i == 0: q.append(i); q.append(n // i)
    return(list(sorted(list(set(q)))))
 
def prime_factors(n):
    q = []
    while n % 2 == 0: q.append(2); n = n // 2
    for i in range(3,int(n ** 0.5) + 1,2):
        while n % i == 0: q.append(i); n = n // i
    if n > 2: q.append(n)
    return(list(sorted(q)))

def transpose(a):
    n,m = len(a),len(a[0])
    b = [[0] * n for i in range(m)]
    for i in range(m): 
        for j in range(n): 
            b[i][j] = a[j][i]
    return(b)

#-----------------------------------------------------------------------#
        
ONLINE_JUDGE = __debug__
if ONLINE_JUDGE:
    input = sys.stdin.readline
main()

Measured memory_bytes: 63168
#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <map>
#include <string>
#include <math.h>
#include <vector>
#include <cstdlib>
#include <queue>

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

using namespace std;

int main()
{
    int r, g, b;
    cin >> r >> g >> b;
    cout << ((r * 100 + g * 10 + b) % 4 == 0 ? "YES" : "NO") << endl;

    return 0;
}


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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define show(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define show(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
template<typename T> using vec=std::vector<T>;

const int inf=1<<30;
const long long int infll=1LL<<62;
const double eps=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    int n,m;
    cin >> n >> m;
    vector<vector<int>> graph(n,vector<int>(n));
    rep(i,0,m){
        int u,v,f;
        cin >> u >> v >> f;
        --u;
        --v;
        graph[u][v]=graph[v][u]=f;
    }

    int ans=0;
    rep(i,2,inf){
        if(i*(i-1)/2>m) continue;
        map<set<int>,int> memo;
        map<set<int>,bool> done;
        function<int(int,set<int>)> rec=[&](int num,set<int> s){
            int &res=memo[s];
            if(done[s]) return res;
            done[s]=true;
            if(num==0){
                for(int v:s){
                    int tmp=inf;
                    for(int u:s){
                        if(u==v) continue;
                        tmp=min(tmp,graph[v][u]);
                    }
                    res+=tmp;
                }
                return res;
            }
            rep(v,0,n){
                if(s.find(v)!=s.end()) continue;
                bool ok=true;
                for(int u:s){
                    if(graph[v][u]!=0) continue;
                    ok=false;
                    break;
                }
                if(!ok) continue;
                set<int> s_=s;
                s_.insert(v);
                res=max(res,rec(num-1,s_));
            }
            return res;
        };
        int tmp=rec(i,set<int>());
        if(tmp==0) break;
        ans=max(ans,tmp);
    }
    cout << ans << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}

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

int main() {
	ios_base::sync_with_stdio( false );

	int N, M;
	cin >> N >> M;

	unordered_map<int, unordered_set<int>> mp;
	for( int i = 0; i < M; ++i ) {
		int a, b;
		cin >> a >> b;
		mp[a].insert( b );
		mp[b].insert( a );
	}

	bool result = false;
	for( auto v: mp[1] ) {
		if( mp[v].find( N ) != mp[v].end() ) {
			result = true;
		}
	}

	cout << (result ? "POSSIBLE" : "IMPOSSIBLE") << endl;
	return 0;
}


Measured memory_bytes: 38672
#include <stdio.h>

#define MAX 64
char s[MAX][MAX];
int h,w;

int is_bomb(int y,int x);

int main(void)
{
	int i,j;

	// input
	scanf("%d %d",&h,&w);
	for (i=0;i<h;++i)
	{
		scanf("%s",s[i]);
	}


	// process
	for (i=0;i<h;++i)
	{
		for (j=0;j<w;++j)
		{
			if (s[i][j]=='.')
			{
				s[i][j]=is_bomb(i-1,j-1)+is_bomb(i-1,j)+is_bomb(i-1,j+1)+is_bomb(i,j-1)+is_bomb(i,j+1)+is_bomb(i+1,j-1)+is_bomb(i+1,j)+is_bomb(i+1,j+1)+'0';
			}
		}
	}

	// output
	for (i=0;i<h;++i)
	{
		for (j=0;j<w;++j)
		{
			printf("%c",s[i][j]);
		}
		printf("\n");
	}

	return 0;
}

int is_bomb(int y,int x)
{
	return (x>=0)&&(x<w)&&(y>=0)&&(y<h)&&(s[y][x]=='#');
}




Measured memory_bytes: 128
import std.algorithm;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

bool check (int n) {
  int last = n % 10;
  n /= 10;
  while (n > 0) {
    int x = n % 10;
    if (abs (x - last) != 1) return false;
    n /= 10;
  }
  return true;
}

void main() {
  int k;
  readf (" %d", &k);
  auto q = iota (1U, 10U).array;
  int left = 0;
  while (q.length <= k) {
    uint i = q[left++];
    int j = (i % 10);
    for (int d = -1; d <= 1; ++d) {
      int o = j + d;
      if (o < 0 || o > 9) continue;
      q ~= i * 10 + o; 
    }
  }
  //debug stderr.writeln (q);
  writeln (q[k-1]);
}



Measured memory_bytes: 2556
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Scanner;

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

    static class TaskB {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            final int n = in.nextInt();

            HashSet<String> a = new HashSet<>();
            for (int i = 0; i < n; i++) a.add(in.next());

            String ans = a.size() == 3 ? "Three" : "Four";
            out.println(ans);
        }

    }
}



Measured memory_bytes: 23764
A, B, C = input().strip().split()
A, B, C = [int(A), int(B), int(C)]

L=[]
for i in range(min(A,B)):
    if A%(i+1) == 0 and B%(i+1) == 0:
        L.append(i+1)
print(L[len(L)-C])

Measured memory_bytes: 9212
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define debug(var)  do{std::cout << #var << " : "; view(var);}while(0)
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){for(const auto& v : vv){ view(v); } }
template<typename T> void view(const T arr[], int n){std::cout << "["; for(int i = 0; i < n; ++i){ std::cout << arr[i] << ", "; } std::cout << "]" << std::endl;}
template<typename T> void view(T e){std::cout << e << std::endl;}
using namespace std;
typedef long long ll;

int main() {
    string s, t;
    cin >> s >> t;
    cout << t + s << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define init(a,i) for(int k=0;k<(i);k++)(a)[k]=0
#define in(a,i) for(int k=0;k<(i);k++)cin>>(a)[k]
#define all(a)  (a).begin(),(a).end()
#define el(a) (a).end()-(a).begin()
#define mod 1000000007
#define inf 2147483647
#define range(x,a,b) (a)<=x&&x<=(b)
int main(){
	ll n,k;
	cin>>n>>k;
	ll a[n];
	in(a,n);
	rep(i,n)a[i]--;
	ll loop=1,town=0,visit[n];
	init(visit,n);
	while(visit[town]==0){
		visit[town]=loop;
		town=a[town];
		loop++;
	}
	loop=loop-visit[town];
	if(k<visit[town]){
		town=0;
		rep(i,k)town=a[town];
		cout<<town+1;
		return 0;
	}
	k-=visit[town]-1;
	k%=loop;
	rep(i,k)town=a[town];
	cout<<town+1;
	return 0;
}

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

int main(){
  string a;
  cin >> a;
  if(a=="000"){
    cout << 0 << endl;
  }else if(a=="001"||a=="010"||a=="100"){
    cout << 1 << endl;
  }else if(a=="011"||a=="101"||a=="110"){
    cout << 2 << endl;
  }else{
    cout << 3 << endl;
  }
}

Measured memory_bytes: 256
/*||>>>> Praveen Ojha <<<<>>>> 29 August 2019 <<<<>>>> 18:19:00 <<<<||*/
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize("unroll-loops")
// #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define F first
#define S second
#define mod 1000000007
#define inf (int)1e18+5
#define sz(x) (int)x.size()
#define PI 3.141592653589793238510
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define __ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define vi vector<int>
#define vpii vector<pair<int,int> > 
#define vvi vector<vector<int> >
#define PRINT_TIME cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." <<endl;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename   enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long double ld;
typedef pair<int,int> pii;
//Read Problems Carefully & Check for corner cases N=0,1 ?
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
string s;
int d,n,dp[10001][101][2];
void add(int &a,int b){
	a+=b;
	if(a>=mod)
		a-=mod;
}
int solve(int ind,int sumi,int lim){
	if(ind==n){
		if(sumi%d==0)
			return 1;
		else
			return 0;
	}
	int &ans=dp[ind][sumi][lim];
	if(ans!=-1)
		return ans;
	ans=0;
	if(lim){
		int lst=s[ind]-'0';
		for(int i=0;i<=lst;i++){
			add(ans,solve(ind+1,(sumi+i)%d,i==lst));
		}
	}
	else{
		for(int i=0;i<=9;i++){
			add(ans,solve(ind+1,(sumi+i)%d,lim));
		}
	}
	return ans;
}
int32_t main(){__
	cin>>s>>d;
	n=sz(s);
	memset(dp,-1,sizeof dp);
	int ans=solve(0,0,1)-1;
	if(ans<0)
		ans+=mod;
	cout<<ans<<"\n";
return 0;
}

Measured memory_bytes: 16896
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=1e9+7;
int main(){
    ll h,w;cin>>h>>w;
    ll a,b;cin>>a>>b;
    rep(i,h){
        rep(j,w){
            if(i<h-b&&j<a)cout<<0;
            else if(i<h-b)cout<<1;
            else if(j<a)cout<<1;
            else cout<<0;
        }
        cout<<endl;
    }
}

Measured memory_bytes: 1280
import collections

N = int(input())
S = input()

c = collections.Counter(S)
if 'R' in c.keys() and 'G' in c.keys() and 'B' in c.keys():
    ans = c['R'] * c['G'] * c['B']

    for i in range(N-2):
        for x in range(((N-i)-1)//2):
            if S[i] != S[i+x+1] and S[i] != S[i+2*(x+1)] and S[i+x+1] != S[i+2*(x+1)]:
                ans -= 1
else:
    ans = 0
print(ans)

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

using namespace std;


void solve() {
    int n, K;
    cin >> n >> K;
    vector<bool> dis(10, false);
    for (int _ = 0; _ < K; _++) {
        int x; cin >> x;
        dis[x] = true;
    }
    for (int i = n; ;i++) {
        bool has = false;
        int x = i;
        while (x) {
            has |= dis[x%10];
            x /= 10;
        }
        if (!has) {
            cout << i; return;
        }
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


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

using namespace std;

int main() {
	int n;
	int t;
	vector<int> m;
	cin >> n;
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		cin >> t;
		m.push_back(t);
	}
	for (int i = 0; i < n; i++) {
		if (m[m[i] - 1] - 1 == i) cnt++;
	}
	cout << cnt / 2 << endl;
}

Measured memory_bytes: 892
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

using namespace std;

#define fori(x) for (int i = 0; i < x; ++i)
#define forj(x) for (int j = 0; j < x; ++j)

typedef long long ll;

const int INF = 2e9 + 5;
const int alength=100100;

int main() {
	int n,a[alength]={};
	cin>>n;
	fori(n){
		int hoge;
		cin>>hoge;
		++a[hoge];
	}

	int ans=0;
	for(int i=1;i<100000;++i){
		ans=max(ans,a[i-1]+a[i]+a[i+1]);
	}
	cout<<ans;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<string>

using namespace std;

int main() {
	int A, B, C, X;
	cin >> A >> B >> C >> X;
	int baai = 0;
	for (int a = 0; a <= A; a++) {
		for (int b = 0; b <= B; b++) {
			for (int c = 0; c <= C; c++) {
				int count = 500 * a+ 100 * b + 50 * c;
				if (count == X) {
					baai++;
				}
			}
		}
	}
	cout << baai << endl;
	return 0;
}

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

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

bool a[26], b[26];
int cnt = 0;
set<string> st;

int main() {
  // 入力
  string s;
  cin >> s;

  for (char c : s) {
    if (!a[c-'a']) {
      a[c-'a'] = 1;
      cnt++;
    }
  }

  if (cnt == 26) {
    bool flag = false;
    for (char c = 'a'; c <= 'z'; c++) {
      for (int i = 1; i < s.size(); i++) {
        if (s[i] == c) {
          for (int j = 0; j < i; j++) b[s[j]-'a'] = 1;
          for (char d = 'a'; d <= 'z'; d++) {
            if (!b[d-'a'] && s[i-1] < d) {
              char tmp = s[i-1];
              s[i-1] = d;
              st.insert(s.substr(0, i));
              s[i-1] = tmp;
              flag = true;
              break;
            }
          }
          fill(b, b + 26, false);
          break;
        }
      }
    }
    if (!flag) {
      cout << -1 << endl;
    } else {
      set<string>::iterator it = st.begin();
      cout << *it << endl;
    }
  } else {
    cout << s;
    for (char c = 'a'; c <= 'z'; c++) if (!a[c-'a']) {
      cout << c << endl;
      break;
    }
  }

  return 0;
}


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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
#define chmax(x, v) do { x = max(x, v); } while (0)
#define chmin(x, v) do { x = min(x, v); } while (0)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;


signed main() {
  string s;
  cin >> s;
  bool ok = false;
  rep(i,3)
    if (s[i]=='7')
      ok = true;
  cout << (ok ? "Yes" : "No" ) << endl;

  return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
int const INF = 1001001001;

struct UnionFind
{
    vector<int> par; //par[i]:= iの親の番号
    vector<int> siz; //siz[i]:= iの属する連結成分の大きさ
    UnionFind(int N) {
        par.resize(N);
        for(int i = 0; i < N; ++i) {
            par[i] = i;
        }
        siz.resize(N,1);
    }

    int root(int x){ // xが属する木の根を再帰で得る：root(x) = {xの木の根}
    if(par[x] == x) return x;
    else return par[x] = root(par[x]);
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        return root(x) == root(y);
    }

    bool unite (int x, int y) { // xとyの木を併合
        x = root(x); y = root(y);
        if (x == y) return false;
 
        if (siz[x] < siz[y]) swap(x, y); // merge technique 小を大にくっつける
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    int size(int x) { // xの属する木の大きさを得る
        return siz[root(x)];
    }
};

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

int N,M,K;
cin >> N >> M >> K;

// 頂点iと同じ連結成分内の頂点のうち、iと辺を共有する頂点の管理⇒set型で表現する
// dame[i]:=  i と同じ連結成分内の人であって、i と友達またはブロック関係にある人を格納した集合
vector<set<int>> dame(N);
UnionFind uf(N);
rep(i,M) {
    int a,b; cin >> a >> b; --a; --b;
    dame[a].insert(b);
    dame[b].insert(a);
    uf.unite(a,b);
}
rep(i,K) {
    int c,d; cin >> c >> d; --c; --d;
    if(!uf.same(c,d)) continue;
    dame[c].insert(d);
    dame[d].insert(c);
}
rep(i,N) {
    int ans = uf.size(i) - 1;
    ans -= dame[i].size();
    cout << ans << ' ';
}
cout << endl;
return 0;
}

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

int main(){

    int a, b, c, d;
    cin >> a >> b >> c >> d;

    while(1){
        if(c-b<=0){
            cout << "Yes" << endl;
            break;
        }else{
            c = c-b;
        }

        if(a-d<=0){
            cout << "No" << endl;
            break;
        }else{
            a = a-d;
        }

    }
    return 0;
}

Measured memory_bytes: 3624
import sys, math
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

S = rs()

t2i = {'Sunny':0, 'Cloudy':1, 'Rainy':2}
i2t = ['Sunny', 'Cloudy', 'Rainy']

i = (t2i[S]+1)%3
print(i2t[i])


Measured memory_bytes: 38384
#include <iostream>
#include <string.h>
using namespace std;
int main(){
  int n , m , i ;
  string x[10000] , y[10000] ;
  string str  , st ;
  string s;
  while(1){
    cin >> n ;
    str = "";
    if ( n== 0) break;
    for( i=0 ; i<n ; i++ ){
      cin >> x[i] >> y[i] ;
    }
    cin >> m ;
    for( i=0 ; i<m ; i++ ){
      cin >> st;
      s = st;
      for( int j=0 ; j<n ; j++ ){
        if( st == x[j] ){
          s = y[j] ;
          continue ;
        }
      }
        str += s;
    }
    cout << str << endl;
  }
}

Measured memory_bytes: 3300
#include <stdio.h>
#include <memory.h>
#include <string.h>

typedef struct _wordindex {
	char word[100];
	int page[100];
	int size;
} wordindex;

wordindex wi[105];
int wi_size=0;

void add_wordindex(char* word, int page) {
	int i;
	for(i=0;i<wi_size;i++) {
		if(strcmp(wi[i].word, word) == 0) {
			wi[i].page[wi[i].size] = page;
			wi[i].size++;
			return;
		}
	}
	
	strcpy(wi[wi_size].word, word);
	wi[wi_size].page[0] = page;
	wi[wi_size].size = 1;
	wi_size++;
}

void word_index_sort() {
	int i, j;
	wordindex t;
	for(i=0;i<wi_size-1;i++) {
		for(j=i+1;j<wi_size;j++) {
			if(strcmp(wi[i].word,wi[j].word)>0) {
				memcpy((char*)&t, (char*)&wi[i], sizeof(t));
				memcpy((char*)&wi[i], (char*)&wi[j], sizeof(t));
				memcpy((char*)&wi[j], (char*)&t, sizeof(t));
			}
		}
	}
	
	for(i=0;i<wi_size;i++) {
		_sort(wi[i].page, wi[i].size);
	}
}

void _sort(int A[], int n) {
	int i, j, t;
	for(i=0;i<n-1;i++) {
		for(j=i+1;j<n;j++) {
			if(A[i] > A[j]) {
				t = A[i];
				A[i] = A[j];
				A[j] = t;
			}
		}
	}
}

int main(void) {
	int page, i, j;
	char word[105];
	
	while(scanf("%s %d\n", word, &page)==2) {
		add_wordindex(word, page);
	}
	
	word_index_sort();
	
	for(i=0;i<wi_size;i++) {
		printf("%s\n", wi[i].word);
		for(j=0;j<wi[i].size;j++) {
			printf("%d", wi[i].page[j]);
			
			if(j<wi[i].size-1) {
				printf(" ");
			} else { 
				printf("\n");
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 660
x=gets.strip.to_i

puts 8 if x >= 400 && x <= 599
puts 7 if x >= 600 && x <= 799
puts 6 if x >= 800 && x <= 999
puts 5 if x >= 1000 && x <= 1199
puts 4 if x >= 1200 && x <= 1399
puts 3 if x >= 1400 && x <= 1599
puts 2 if x >= 1600 && x <= 1799
puts 1 if x >= 1800 && x <= 1999


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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if(a == b && b == c) cout << 1 << endl;
    else if(a == b || b == c || c == a) cout << 2 << endl;
    else cout << 3 << endl;
    return 0;
}

Measured memory_bytes: 256
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

int main(){
  int n , a;
  cin >> n;
  map<int,int> times;
  rep(i,0,n) {
    cin >> a;
    times[a]++;
  }
  int ans = 0;
  for(auto e : times) {
    if(e.se >= e.fi)
      ans += e.se - e.fi;
    else
      ans += e.se;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4736
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int a = in.nextInt();
        int b = in.nextInt();
        int c = in.nextInt();
        int x = in.nextInt();
        int y = in.nextInt();

        int mx = Math.max(x, y);
        int mn = Math.min(x, y);

        int ans = 0;
        if (2 * c < a + b) {
            ans += 2 * c * mn;
        } else {
            System.out.println(a * x + b * y);
            return;
        }

        if (x > y) {
            if (a < 2 * c) {
                ans += (x - y) * a;
            } else {
                ans += (x - y) * 2 * c;
            }
        } else {
            if (b < 2 * c) {
                ans += (y - x) * b;
            } else {
                ans += (y - x) * 2 * c;
            }
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 35720
import java.util.*;

class Main{
    //150a
    static final long DIV = 100000007L;
    static final int MAX = 2000000000;
    //static long[] fac = new long[MAX];
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        boolean[] collect = new boolean[n];
        int ans = 0;
        int penans = 0;
        int[] pen = new int[n];
        for(int i = 0;i < m;i++){
            int pi = sc.nextInt();
            String s = sc.next();
            if(!collect[pi-1]){
                if(s.equals("WA")){
                    pen[pi-1]++;
                }else if(s.equals("AC")){
                    collect[pi-1] = true;
                    ans++;
                }
            }     
        }
        for(int i = 0;i < n;i++){
            if(collect[i])penans += pen[i];
        }
        System.out.println(ans + " " + penans);
    }
}

Measured memory_bytes: 64616
#include <iostream>
#include <vector>
#define REP(i, a, n) for(int i = (a); i < (n); i++)
#define INF 100000000
using namespace std;
typedef long long ll;

int N, M, S, G1, G2, A, B, D;
ll d[100][100];

int main(void) {
  while(cin >> N >> M >> S >> G1 >> G2, N || M || S || G1 || G2) {
    REP(i, 0, N) REP(j, 0, N) d[i][j] = INF;
    REP(i, 0, N) d[i][i] = 0;
    REP(i, 0, M) {
      cin >> A >> B >> D;
      d[A - 1][B - 1] = D;
    }

    REP(k, 0, N) REP(i, 0, N) REP(j, 0, N) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);

    ll ans = INF;
    REP(i, 0, N) ans = min(ans, d[S - 1][i] + d[i][G1 - 1] + d[i][G2 - 1]);
    cout << ans << endl;
  }

  return 0;
}

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

#define rep(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rrep(i, a, b) for (int i = (a); i >= (int)(b); i--)
#define all(x) (x).begin(), (x).end()
using i32 = int32_t;
using i64 = int64_t;
using f32 = float;
using f64 = double;
using P   = pair<int, int>;

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

template <class T>
void dump_vec(const vector<T>& v) {
    auto len = v.size();
    rep(i, 0, len) {
        cout << v[i] << (i == (int)len - 1 ? "\n" : " ");
    }
}

struct FastIO {
    FastIO() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} FASTIO;

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

map<i64, i64> prime_factors(i64 n) {
    map<i64, i64> res; // factor, num
    for (i64 p = 2; p * p <= n; p++) {
        while (n % p == 0) {
            res[p]++;
            n /= p;
        }
    }
    if (n != 1) res[n] = 1;
    return res;
}
//---------------------------------------------------------------------------------------------------

signed main() {
    int n;
    cin >> n;
    auto mp = prime_factors(n);
    vector<i64> ans;
    for (auto p : mp) {
        rep(i, 0, p.second) {
            ans.push_back(p.first);
        }
    }
    cout << n << ": ";
    dump_vec(ans);
}



Measured memory_bytes: 3216
import java.util.Scanner;

public class Main{
    public static void main(String args[]){
        Scanner input = new Scanner(System.in);
        int mi = 0;
        int fi = 0;
        int re = 0;
        do{
            mi = input.nextInt();
            fi = input.nextInt();
            re = input.nextInt();
            judge(mi, fi, re);
        }while(input.hasNext());
    }
    
    public static void judge(int m, int f, int r){
        if((m + f) >= 80 && ((m > 0) && (f > 0)))
            System.out.println("A");
        else if(((m + f) < 80) && ((m + f) >= 65) && ((m > 0) && (f > 0)))
            System.out.println("B");
        else if(((m + f) < 65 && (m + f) >= 50) ||((m + f) < 50 && (m + f) >= 30 && r >= 50) && ((m > 0) && (f > 0)))
            System.out.println("C");
        else if(((m + f) < 50) && ((m + f) >= 30) && (r < 50) && ((m > 0) && (f > 0)))
            System.out.println("D");
        else if(m < 0 && f < 0 && r < 0);
        else if((m < 0) || (f < 0) || (((m + f) < 30) && (r < 50)))
            System.out.println("F");

    }
}


Measured memory_bytes: 26288
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <set>
//#inlcude<stringstream>
#define ll long long
#define MODD 1000000007
using namespace std;
ll arr[1000000]={0};
ll brr[1000000]={0};
int main() {

    int a,b,c;cin >>a>>b>>c;
    int ma = max(a,max(b,c));
    if(ma%2==0){
        if(a ==ma)
        a = b;
        else if(c==ma)
        c = b;
        if(a%2==0&&c%2==0){
            cout<<(ma-a)/2+(ma-c)/2<<endl;
        }
        else {
            if(a%2&&c%2==0){
                cout<<(ma+1-a)/2+(ma-c)/2+1<<endl;
            }
            else if(c%2&&a%2==0){
                cout<<(ma-a)/2+(ma+1-c)/2+1<<endl;
            }
            else {//ji ji
                cout<<(ma-a-1)/2+(ma-c-1)/2+1<<endl;
            }
        }
    }
    else {//ji
        if(a ==ma)
        a = b;
        else if(c==ma)
        c = b;
        if(a%2&&c%2){
            cout<<(ma-a)/2+(ma-c)/2<<endl;
        }
        else {
            if(a%2==0&&c%2){
                cout<<(ma+1-a)/2+(ma-c)/2+1<<endl;
            }
             else if(c%2==0&&a%2){
                cout<<(ma-a)/2+(ma+1-c)/2+1<<endl;
            }
            else {
                cout<<(ma-a-1)/2+(ma-c-1)/2+1<<endl;
            }
        }
    }
    return 0;
}


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

#define check cnt=0;for(j=0;j<6;j++)if(d1[j]==d2[j])cnt++;
#define r tmp=d2[1];d2[1]=d2[3];d2[3]=d2[4];d2[4]=d2[2];d2[2]=tmp;
#define y tmp=d2[0];d2[0]=d2[3];d2[3]=d2[5];d2[5]=d2[2];d2[2]=tmp;

int main(){
 int d1[6],d2[6],tmp,cnt,j,a=1,i,k;

 for(int i=0;i<6;i++){
  cin >> d1[i] ;
 }
 for(int i=0;i<6;i++){
  cin >> d2[i] ;
 }

 check
   if(cnt==6)a=0;

 while(a){
  for(i=0;i<5;i++){
   for(k=0;k<4;k++){
    check
    if(cnt==6)break;
    r
   }
   check
   if(cnt==6)break;
   tmp=d2[0];
   d2[0]=d2[1];
   d2[1]=d2[5];
   d2[5]=d2[4];
   d2[4]=tmp;
  }
  if(cnt==6)break;
  y
  for(k=0;k<4;k++){
   check
   if(cnt==6)break;
   r
  }
  if(cnt==6)break;
  y
  y
  for(k=0;k<4;k++){
   check
   if(cnt==6)break;
   r
  }
  check
  if(cnt==6)break;
  a=0;
 }

 if(cnt==6)cout << "Yes" << endl ;
 else cout << "No" << endl ;

 return 0;
}

Measured memory_bytes: 3088
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
//#include <tuple>

#define break break
#define continue continue
#define INF INT_MAX>>1 
#define SIZE 100010
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep2(i, from, to) for(int i=(from); i<(int)(to); i++)
#define all(obj) (obj).begin(), (obj).end()
#define lpair pair<ll, ll>
#define vint vector<ll>
#define vinput(name) for(int i=0; i<(int)(name.size()); i++) cin >> name[i];
#define voutput(name) for(int i=0; i<(int)(name.size()); i++) cout << name[i] << endl;
typedef long long ll;

using namespace std;

ll ans = 0;

int main(void){
	int h, w, n; cin >> h >> w >> n;
	int c = max(h, w);
	ans = n/c;
	if(n%c != 0) ans++;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.IOException
import java.lang.NumberFormatException
import java.lang.StringBuilder
import kotlin.math.max

object BMain{
    fun solve(){
        val n = nextInt()
        val c = next()
        val numw = c.count { it == 'W' }
        val numr = n - numw
        var tnumw = 0
        var tnumr = 0
        var ttnumr = 0
        var ans = 0

        if(numw == 0 || numr == 0){
            println(0)
            return
        }

        for(i in 0 until n){
            if(c[i] == 'R'){
                tnumr++
            }else{
                tnumw++
                ttnumr++
                ans++
            }
            if(tnumr + ttnumr == numr) break
        }
        println(ans)
    }





    // Scanner based on uwi-san's Java code
    val stream = System.`in`
    val buffer = ByteArray(1024)
    var ptr = 0
    var buflen = 0

    fun hasNextByte(): Boolean{
        if(ptr < buflen){
            return true
        }else{
            ptr = 0
            try{
                buflen = stream.read(buffer)
            }catch (e: IOException){
                e.printStackTrace()
            }
            if(buflen <= 0){
                return false
            }
        }
        return true
    }

    fun readByte() =
        if(hasNextByte()) buffer[ptr++]
        else -1

    fun isPrintableChar(c: Byte) = c in 33..126

    fun hasNext(): Boolean{
        while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++
        return hasNextByte()
    }

    fun next(): String{
        if(!hasNext()) throw NoSuchElementException()
        val sb = StringBuilder()
        var b = readByte()
        while(isPrintableChar(b)){
            sb.appendCodePoint(b.toInt())
            b = readByte()
        }
        return sb.toString()
    }

    fun nextLong(): Long{
        if(!hasNext()) throw NoSuchElementException()
        var n = 0L
        var minus = false
        var b = readByte()
        if(b == '-'.toByte()){
            minus = true
            b = readByte()
        }
        if(b !in '0'.toByte()..'9'.toByte())
            throw NumberFormatException()
        while(true){
            if(b in '0'.toByte()..'9'.toByte()){
                n *= 10
                n += b - '0'.toByte()
            }else if(!isPrintableChar(b)){
                return if(minus) -n else n
            }else{
                throw NumberFormatException()
            }
            b = readByte()
        }
    }

    fun nextInt(): Int{
        val n1 = nextLong()
        if(n1 !in Int.MIN_VALUE..Int.MAX_VALUE)
            throw NumberFormatException()
        return n1.toInt()
    }

    fun NextDouble() = next().toDouble()
}

fun main(){
    BMain.solve()
}



Measured memory_bytes: 35352
#include<iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>

#define R 1000000007

using namespace std;

int main()
{
    long long n;
    pair<long long , long long> p;
    cin >> n;
    for(long long i = 1; i <= sqrt(n); i++)
    {
        if(n % i == 0)
        {
            p.first = i;
            p.second = n / i;
        }
    }
    cout << p.first - 1 + p.second - 1 << '\n';
}


Measured memory_bytes: 256
n=input()
x=map(float,raw_input().split())
y=map(float,raw_input().split())
d1=0
for i in range(n):
    d1+=abs(x[i]-y[i])
d2=0
for i in range(n):
    d2+=abs(x[i]-y[i])**2
d2=d2**(0.5)
d3=0
for i in range(n):
    d3+=abs(x[i]-y[i])**3
d3=d3**(0.3333333333333)
dinf=0
for i in range(n):
    if dinf<abs(x[i]-y[i]):
        dinf=abs(x[i]-y[i])

print d1
print d2
print d3
print dinf


Measured memory_bytes: 4780
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <climits>
#include <map>
#include <queue>
#include <stack>
#include <vector>

using namespace std;

using Pair = pair<int, int>;
using lint = long long;

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

// const int mod = 1e9 + 7;
// const int mod = 998244353;

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

template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) {
  return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
#include <iostream>
inline void Yes(bool condition) {
  if (condition) {
    std::cout << "Yes" << std::endl;
  } else {
    std::cout << "No" << std::endl;
  }
}

int main(){
  int n;
  cin>>n;
  vector<int> a(n * 2);
  int cnt = 0;
  bool ret = false;
  rep(i, n) {
    cin >> a[2 * i] >> a[2 * i + 1];
    if (a[2 * i] == a[2 * i + 1]) cnt++;
    else
      cnt = 0;
    if (cnt == 3) ret = true;
  }
  Yes(ret);
}


Measured memory_bytes: 3628
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

int main(){
        
    ios_base::sync_with_stdio(0);
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int turn =0;
    while(a>0 && c>0){
        if(turn==0){
            c -= b;
            turn = 1;
        }
        else if(turn==1){
            a -= d;
            turn=0;
        }
    }
    if(c<=0){
        cout<<"Yes\n";
    }
    else{
        cout<<"No\n";
    }
    return 0;
}



Measured memory_bytes: 3644
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    a,b = INTM()
    c =min(a,b)
    d=max(a,b)
    if d%c ==0:
        print(int(d))
    else:
        while d%c!=0:
            e = d%c
            d = c
            c = e
#            print(e)
        print(int(a*b/e))
if __name__ == '__main__':
    do()

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

using namespace std;

int main(){
    int n, x;
    cin >> n >> x;
    if(n == 1){
        if(x == 1){
            cout << " Yes\n" << 1;
        }
        else{
            cout << "No";
        }
    }
    else if(n == 2){
        if(x == 2){
            cout << "Yes\n" << 1 << endl << 2 << endl << 3;
        }
        else{
            cout << "No";
        }
    }
    else{
        if(x == 2 * n - 1|| x == 1){
            cout << "No";
        }
        else{
            int base[2*n];
            for(int i = 1; i < 2*n; i++){
                base[i] = i;
            }
            swap(base[x],base[n]);
            if(x > n){
                swap(base[n+1],base[2*n - 1]);
            }
            else{
                if(x < n){
                    swap(base[1],base[n+1]);
                }
            }
            cout << "Yes\n";
            for(int i = 1; i < 2*n; i++){
                cout << base[i] << endl;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 2304
#include <stdio.h>

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


Measured memory_bytes: 2120
MOD = 10 ** 9 + 7


def combination(n, r, mod=10**9+7):
    n1, r = n+1, min(r, n-r)
    numer = denom = 1
    for i in range(1, r+1):
        numer = numer * (n1-i) % mod
        denom = denom * i % mod
    return numer * pow(denom, mod-2, mod) % mod


X, Y = map(int, input().split())

# a := →→↑ の個数
# b := →↑↑ の個数
# 2a + b = X
# a + 2b = Y より、
a = (2 * X - Y) / 3
b = (2 * Y - X) / 3

if a < 0 or b < 0 or not a.is_integer() or not b.is_integer():
    print(0)
    exit(0)

ans = combination(int(a + b), int(a), mod=MOD)
print(ans)


Measured memory_bytes: 38512
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.nextInt();
		ArrayList<String> s = new ArrayList<>();
		for(int i = 0; i < n; i++) {
			s.add(sc.next());
		}
		s.sort(null);
		StringBuilder sb = new StringBuilder();
		for(int i = 0; i < n; i++) {
			sb.append(s.get(i));
		}
		System.out.println(sb.toString());
		sc.close();
	}

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

Measured memory_bytes: 24020
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> VI;
typedef vector<VI> VVI;//例: VVI dp(10, vector<int>(10, INF);
typedef priority_queue<int, vector<int>, less<int> > QUE_int;
const int INF = pow(10, 5) + 1;//+1しないとREになる(out of rangeになるんかな?? )

vector<int> dx = { -1, 0, 1, 0, -1, -1, 1, 1 };
vector<int> dy = { 0, -1, 0, 1, -1, 1, -1, 1 };
int main(void) {
	int H, W;
	cin >> H >> W;
	vector<string> maze(H);
	for (int i = 0; i < H; i++) cin >> maze[i];

	VVI far(H, vector<int>(W, INF));
	far[0][0] = 0;
	queue<P> q;
	q.push(P(0, 0));
	while (!q.empty()) {
		int now_x = q.front().first;
		int now_y = q.front().second;
		q.pop();
		for (int i = 0; i < 4; i++) {
			int next_x = now_x + dx[i];
			int next_y = now_y + dy[i];
			if (next_x < 0 || H <= next_x || next_y < 0 || W <= next_y) continue;
			if (maze[next_x][next_y] == '#') continue;
			if (far[next_x][next_y] != INF) continue;
			far[next_x][next_y] = far[now_x][now_y] + 1;
			q.push(P(next_x, next_y));
		}
	}

	////////////////解1////////////////////////////////////////
	int ans = 0;
	int forcus_num = 1;//forcus_num
	for (int forcus_num = 1; forcus_num <= H * W; forcus_num++) {
		int count = 0;
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				if (far[i][j] == forcus_num) {
					if (forcus_num > far[H - 1][W - 1]) ans++;			
					else{
						count++;
						if (count >= 2) {
							ans++;
							//far[i][j] = -1*ans;
						}
					}
				}
			}
		}
	}
	//cout << " tmp ans " << ans << endl;
	int num_INF = 0;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (maze[i][j] != '#') {
				if (far[i][j] == INF) num_INF++;
			}

		}
	}
	//cout << "num_INF : " << num_INF << endl;
	ans += num_INF;

	///////////////////解2////////////////////////////////////////
	//int num_sharp = 0;
	//for (int i = 0; i < H; i++) {
	//	for (int j = 0; j < W; j++) {
	//		if (maze[i][j] == '#') num_sharp++;
	//	}
	//}
	////cout << " num_sharp : " << num_sharp << endl;
	////int ans = H * W - num_sharp - far[H - 1][W - 1]-1;
	//int ans = H * W - num_sharp - (far[H - 1][W - 1]+1);
	

	if (far[H - 1][W - 1] == INF) {
		cout << "-1" << endl;
		return 0;
	}
	cout << ans << endl;
	/*
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cout << maze[i][j] << "        ";
		}
		cout << endl;
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cout << far[i][j] << "        ";
		}
		cout << endl;
	}*/
}


Measured memory_bytes: 256
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		String a = sc.next();
		String b = sc.next();
		String c = sc.next();
		
		// 計算
		String result = a.substring(0, 1) + b.substring(1, 2) + c.substring(2, 3);
		
		// 出力
		System.out.println(result);
	}
}




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

int main() {
	int N;
	cin >> N;
	int tmp = 0;
	bool flag = true;
	for (int n = 0; n < N; n++) {
		int H;
		cin >> H;
		if (tmp <= H - 1) tmp = H - 1;
		else if (tmp == H) tmp = H;
		else flag = false;
	}
	if (flag) cout << "Yes\n";
	else cout << "No\n";

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define db double
#define RE register
#define ll long long
#define P 1000000007
#define INF 1000000000
#define get(x) x=read()
#define PLI pair<ll,int>
#define PII pair<int,int>
#define pb(x) push_back(x)
#define ull unsigned long long
#define put(x) printf("%d\n",x)
#define getc(a) scanf("%s",a+1)
#define putl(x) printf("%lld\n",x)
#define rep(i,x,y) for(RE int i=x;i<=y;++i)
#define fep(i,x,y) for(RE int i=x;i>=y;--i)
#define go(x) for(int i=link[x],y=a[i].y;i;y=a[i=a[i].next].y)
using namespace std;
const int N=2e5+10;
int n;
ll sum[N],ans,g[N];
char c[N];
inline int read()
{
	int x=0,ff=1;
	char ch=getchar();
	while(!isdigit(ch)) {if(ch=='-') ff=-1;ch=getchar();}
	while(isdigit(ch)) {x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
	return x*ff;
}

inline ll power(ll x,ll y)
{
	ll ans=1;
	while(y)
	{
		if(y&1) ans=ans*x%2019;
		y>>=1;
		x=x*x%2019;
	}
	return ans;
}

int main()
{
//	freopen("1.in","r",stdin);
	getc(c);n=strlen(c+1);
	sum[0]=1;
	fep(i,n,1) g[i]=(g[i+1]+(c[i]-'0')*power(10,(n-i)))%2019;	
	fep(i,n,1) 
	{
		ans+=sum[g[i]];
		sum[g[i]]++;
	}
	putl(ans);
	return 0;
}





Measured memory_bytes: 5620
#define _GLIBCXX_DEBUG
#include"bits/stdc++.h"

using namespace std;

//loops
#define REP(i,n) for(int i=0;i<(ll)(n);i++)
#define REPD(i,n) for(int i=(ll)(n)-1;i>=0;i--)
#define OneToN(i,n) for(int i=1;i<(ll)(n+1);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)

//arrays
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define add push_back

//pair
#define fir first
#define sec second

//types
#define ll long long
#define vec vector
//UNCOMMENT WHEN NEEDED
//#define int ll

//input
template <class T> T get(){ T s; cin >> s; return(s);}
#define gi get<int>()
#define gs get<string>()

template <class T> vector<T> getv(int n) { vec<T> v(n); REP(i, n) cin >> v[i]; return v; }
#define gim(n) getv<int>(n)
#define gsm(n) getv<string>(n)

//output
void print(int a){ cout << a << endl; }
void print(string a){ cout << a << endl; }
void print(double a, int dig){ cout << std::setprecision(dig) << a << endl; }

template <class T = int>
void print(vec<T> v){ for (T item: v) { cout << item << " "; } cout << endl; }

void YesNo1(bool i = true){ return print(i?"Yes":"No"); }
void YESNO2(bool i = true){ return print(i?"Yes":"N1010o"); }

//debug output
#define var_name(var) #var
template <class T> void debug(T &var, int nest = 0, string before = "") { cout << string("          ", nest) << before; print(var); }

//name replacement
#define y0 y0__
#define y1 y1__
#define j0 j0__
#define j1 j1__
#define next next__
#define prev prev__

//bool lambdas
#define lamb(exp) [](auto i){return exp;}
#define isEven [](int i){return i % 2 == 0;}
#define isOdd [](int i){return i % 2 != 0;}

//constants
const ll INF = 1e18;
const int MOD = 10000007;

void Main() {
    //code here
    int n = gi;
    vec<int> nums = gim(n);
    set<int> vals;
    for(int n: nums) {
        vals.insert(n);
    }
    print(vals.size());
}

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

Measured memory_bytes: 256