akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <bitset>
#include <cmath>
#include <vector>
#include <algorithm>
#include <queue>
#include <string>

using namespace std;
typedef long long ll;

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

int main(){
    int n,ans;
    bool Smode=false;
    string s;
    cin >> s;
    n = s.length();
    ans = n;
    int sc = 0;
    if(s[0]=='S'){Smode = true; sc=1;}

    for(int i=1;i<n;i++){
        if(Smode){
            if(s[i]=='T'){
                Smode = !Smode;
                if(sc>0){
                    sc--;
                    ans-=2;
                }     
            }else{
                sc++;
            }
        }
        else{
            if(s[i]=='S'){
                Smode = !Smode;
                sc++;
            }
            else{
                if(sc>0){
                    sc--;
                    ans-=2;
                }     
            }

        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
INF = 1000000

dp = [INF for i in range(100040)]

dp[0]= 0

a = [1]
n = 6
while True:
    a.append(n)
    n *= 6
    if n > 100000:
        break
n= 9
while True:
    a.append(n)
    n *= 9
    if n > 100000:
        break

for i in range(len(a)):
    a_ =  a[i]
    for j in range(a[i],len(dp)):
        dp[j] = min(dp[j],dp[j-a_] + 1)

print(dp[int(input())])


Measured memory_bytes: 7064
import sys
input = sys.stdin.readline
 
H, W = map(int, input().split())
mark_matrix = [[True]*(W+2)]
mark_matrix.extend([[True]+[x!='.' for x in input()] for _ in range(H)])
mark_matrix[H].append(True)
mark_matrix.append([True]*(W+2))

queue = []
for i in range(1,H+1):
  for j in range(1,W+1):
    if mark_matrix[i][j]:
      queue.append((i,j))
 
max_value = 0
while(True):
  if len(queue) == 0:
    break
  
  new_queue = []
  for i,j in queue:
  
    if not mark_matrix[i-1][j]:
      mark_matrix[i-1][j] = True
      new_queue.append((i-1,j))
    if not mark_matrix[i+1][j]:
      mark_matrix[i+1][j] = True
      new_queue.append((i+1,j))
    if not mark_matrix[i][j-1]:
      mark_matrix[i][j-1] = True
      new_queue.append((i,j-1))
    if not mark_matrix[i][j+1]:
      mark_matrix[i][j+1] = True
      new_queue.append((i,j+1))
 
  if len(new_queue) == 0:
    break
  else:
    queue = new_queue
    max_value += 1
  
print(max_value)


Measured memory_bytes: 110112
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i<(int)n; i++)

int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    rep (i,n) cin>>p[i];
    int k = 0;
    rep (i,n) if (p[i] != i+1) k++;
    if (k<=2) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
    }

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
using static System.Math;
using Debug = System.Diagnostics.Debug;

class P
{
    static void Main()
    {
        var abc = Console.ReadLine().Split().Select(int.Parse).ToList();
        Console.WriteLine(Min(abc[1] / abc[0], abc[2]));
    }
}


Measured memory_bytes: 11220
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cstdio>
using namespace std;
#define ms(a,b) memset(a,b,sizeof(a))
typedef long long ll;
const int MAXN=1e5+5;
const double EPS=1e-8;
const int INF=0x3f3f3f3f;
int n,tmp;
int t,t2,t4;
int main(){
	scanf("%d",&n);
	for(int i =0;i<n;i++){
		scanf("%d",&tmp);
		if(tmp%4==0)	t4++;
		else if(tmp%2==0)	t2++;
		else	t++;
	}
	if(t4>=t || (t4==t-1 && t2==0))	printf("Yes\n");
	else	printf("No\n");

	return 0;
}

Measured memory_bytes: 256
def resolve():
    class UnionFind():
        def __init__(self, n):
            self.n = n
            self.parents = [-1] * n

        def find(self, x):
            if self.parents[x] < 0:
                return x
            else:
                self.parents[x] = self.find(self.parents[x])
                return self.parents[x]

        def union(self, x, y):
            x = self.find(x)
            y = self.find(y)

            if x == y:
                return

            if self.parents[x] > self.parents[y]:
                x, y = y, x

            self.parents[x] += self.parents[y]
            self.parents[y] = x

        def size(self, x):
            return -self.parents[self.find(x)]

        def same(self, x, y):
            return self.find(x) == self.find(y)

        def members(self, x):
            root = self.find(x)
            return [i for i in range(self.n) if self.find(i) == root]

        def roots(self):
            return [i for i, x in enumerate(self.parents) if x < 0]

        def group_count(self):
            return len(self.roots())

        def all_group_members(self):
            return {r: self.members(r) for r in self.roots()}

        def __str__(self):
            return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

    n, m = map(int, input().split())
    UF = UnionFind(n)
    for i in range(m):

        a, b = map(int, input().split())
        a -= 1
        b -= 1
        UF.union(a,b)
    grp = UF.group_count()
    if grp == 1:
        print(0)
    else:
        print(grp-1)

resolve()

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

ll gcd(ll a,ll b) //最大公約数
{
    if(a%b==0)
    {
        return b;
    }
    else
    {
        return (gcd(b, a % b));
    }
}



map<ll,ll> factrize(ll n)
{
    map<ll, ll> ans;
    for (ll i = 2; i * i <= n;i++)
    {
        if(n%i!=0)
            continue;
        ans[i] = 0;
        while (n%i==0)
        {
            n /= i;
            ans[i] += 1;
        }
    }

    if(n!=1)
        ans[n] = 1;
    return ans;
}

int main() 
{
    ll a, b;
    cin >> a >> b;
    ll max = gcd(a, b);
    auto g = factrize(max);
    int cnt = 0;
    for(auto i : g)
    {
        if(i.second!=0)
        {
            cnt += 1;
        }
    }

    cout << cnt + 1 << endl;

    return 0;
}



Measured memory_bytes: 256
# Problem D - Sum of Large Numbers

# input
N, K = map(int, input().split())

# initialization
mae_list = [i for i in range(N+1)]
ushiro_list = [i for i in range(N, -1, -1)]
ans = 0
MOD = 10**9 + 7

# count
for i in range(1, N+1):
    mae_list[i] += mae_list[i-1]
    ushiro_list[i] += ushiro_list[i-1]

for k in range(K-1, N+1):
    ans += (ushiro_list[k] - mae_list[k] + 1)%MOD

# output
print(ans%MOD)


Measured memory_bytes: 30276
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define pp pop_back
#define in insert
#define ff first
#define ss second
#define  show for(int j=0;j<v.size();j++) cout<<v[j]<<" ";
#define ld long double
#define e endl
#define bc __builtin_popcount
#define MOD 1000000007
#define INT_SIZE 32
#define me(x) memset(x,0,sizeof(x))
#define MAX 10000003
int main()
{
    int n;
    cin>>n;
    int mini[n],p[n],i;
      for(i=0;i<n;i++)
        {cin>>p[i];
        }
        mini[0]=p[0];
        for(i=1;i<n;i++)
        {
            mini[i]=min(mini[i-1],p[i]);
        }
        int c=0;
        for(i=0;i<n;i++)
        {
            if(p[i]>mini[i])
            c++;
        }
        cout<<n-c<<e;
}


Measured memory_bytes: 1792
N, M = gets.chomp.split(" ").map(&:to_i)

li = []
ri = []

for i in 0...M do
  l, r = gets.chomp.split(" ").map(&:to_i)
  li[i] = l
  ri[i] = r
end

# liの最大値 - riの最小値が答え

if (ri.min - li.max) >= 0 then
  puts ri.min - li.max + 1
else
  puts 0
end


Measured memory_bytes: 3440
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1<<30;
vvi in;
vi visit;
int out=1;
void dfs(int a,int c){
	out=max(out,c+1);
	rep(i,in[a].size()){
		int t=in[a][i];
		if(!visit[t]){
			visit[t]=true;
			dfs(t,c+1);
			visit[t]=false;
		}
	}
}
int main(){
	int n;
	while(cin>>n,n){
		in=vvi(101);
		rep(i,n){
			int a,b;
			cin>>a>>b;
			a--;b--;
			in[a].pb(b);
			in[b].pb(a);
		}
		int mi=inf;
		rep(i,101)if(in[i].size()){
			int t=in[i].size();
			mi=min(mi,t);
		}
		out=0;
		rep(i,101){//if(mi==in[i].size()){
			visit=vi(101);
			visit[i]=true;
			dfs(i,0);
		}
		cout<<out<<endl;
	}
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;

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

char f[55][55];
int  ans[55][55];

int main(){
	int h,w;
	cin >> h >> w;
	for(int i = 0; i < h; i++){
		for(int j =0; j < w; j++){
			cin >> f[i][j];
		}
	}

	for(int i = 0; i < h; i++){
		for(int j =0; j < w; j++){
			int cnt = 0;
			if(f[i][j] != '#'){
				for(int dir = 0; dir < 8; dir++){
					int nx = i + dx[dir];
					int ny = j + dy[dir];
					if(nx < 0 || nx >= h || ny < 0 || ny >= w){
						continue;
					}
					if(f[nx][ny] == '#'){
						cnt++;
					}
				}
				ans[i][j] = cnt;
			}else{
				ans[i][j] = 10;
			}
		}
	}

	for(int i = 0; i < h; i++){
		for(int j =0; j < w; j++){
			if(ans[i][j] != 10){
				cout << ans[i][j];
			}else{
				cout << "#";
			}
		}
		cout << endl;
	}


}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;
#define endl '\n'
#define PB push_back
#define MP make_pair
#define first F
#define second S
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1   e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

int main(){
    cin.sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

    int64 k , x ;
    cin>>k>>x ;
    if(k * 500 >= x)
          cout << "Yes" ;
    else
        cout<<"No" ;
    
    
    return 0 ;    
}



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

int main() {
	
	int n = 0;
	cin >> n;
	long height = 0;

	int arr[n];

	for(int i=0; i<n; i++) {
		cin >> arr[i];
	}

	for(int i=1; i<n; i++) {
		if(arr[i] < arr[i-1]) {
			height += arr[i-1] - arr[i];
			arr[i] = arr[i-1];
		}

	}

	cout << height << "\n";
}


Measured memory_bytes: 4336
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define all(v) v.begin(), v.end()
#define pb push_back
#define rep(p, a, b) for (ll p = a; p < b; p++)
#define F first
#define S second
using namespace std;

int main()
{
    ll t, i, j, k, ans, n;

    //cin>>t;
    t = 1;
    while (t--)
    {
        string s;
        cin>>n>>s;

        ans=0;
        i=0;j=n-1;
        while(i<j)
        {
            while(s[i]=='R' && i<j)i++;
            while(s[j]=='W' && i<j)j--;

            if(i<j && s[i]=='W' && s[j]=='R'){ans++;swap(s[i],s[j]);}
        }

        cout<<ans;
    }

    return 0;
}

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

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

    int ma = 0;
    int sum = 0;

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

        if(ma <= h){
            sum++;
            ma = h;
        }
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, start, n) for (int i = (int)(start); i < (int)(n); ++i)
static const int INFTY = (1 << 30);
int N, K;
void func()
{
    cin >> N >> K;
    int p[N];
    int ans(0);
    rep(i, 0, N) cin >> p[i];
    sort(&p[0], &p[N]);
    rep(i, 0, K) { ans += p[i]; }
    cout << ans << endl;
}
int main()
{
    func();
}

Measured memory_bytes: 3652
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
#include<map>
using namespace std;
int main(){
    long long int x,y;
    cin>>x>>y;
    int ans = 1;
    while(1){
        x*=2;
        if(x>y){
            break;
        }
        ans++;
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<math.h>
using namespace std;

#define MAX 256

int main(void){
	
	int n, x;

	scanf("%d", &n);

	int a[n];
	
	for (int i = 0; i < n; i++){
		scanf("%d", &a[i]);
	}

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

	printf("%d", a[0]);
	for (int i = 1; i < n; i++){
		printf(" %d", a[i]);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 3184
#include<iostream>
#include<string>
using namespace std;
int main(){
    string a;
    cin >> a;
    int str[3];
    for(int i=0;i<3;i++){
        str[i]=a[i]-'0';
    }
    int sum=0;
    for(int i=0;i<3;i++){
        sum+=str[i];
    }
    cout << sum;
    return 0;
    
}

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

int main() {
    int N;
    cin >> N;
    vector<int> p(N+1);
    for(int i=1; i<=N; ++i) cin >> p[i];

    int res = 0;
    for(int i=1; i<=N; ++i) {
        if(p[i] == i) {
            if(i < N) swap(p[i], p[i+1]);
            ++res;
        }
    }
    cout << res << endl;
}

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

using namespace std;
int ans = 0;
int N, M;
vector<vector<int>> ss;
vector<int> p;

void dfs(int i, vector<bool> onoff) {
  if (i == N) {
    bool is_valid = true;
    for (int j = 0; j < M; ++j) {
      int cnt = 0;
      for (int k = 0; k < (int)ss[j].size(); ++k) {
	if (onoff[ss[j][k] - 1]) cnt++;
      }
      if (cnt % 2 != p[j]) {
	is_valid = false;
	break;
      }
    }
    if (is_valid) ans++;
    return;
  }

  dfs(i + 1, onoff);
  onoff[i] = true;  
  dfs(i + 1, onoff);
  
}

int main() {
  cin >> N >> M;
  int k;
  for (int i = 0; i < M; ++i) {
    cin >> k;
    vector<int> s(k);
    for (int j = 0; j < k; ++j) {
      cin >> s[j];
    }
    ss.push_back(s);
  }
  for (int i = 0; i < M; ++i) {
    int tmp;
    cin >> tmp;
    p.push_back(tmp);
  }
  vector<bool> onoff(N, false);
  dfs(0, onoff);
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#define nmax_def 110000
#define Cmax_def 2200
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
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;

int main() {
	int N, M;
	priority_queue<int> que;
	cin >> N >> M;
	rep(i, N) {
		int Atmp;
		cin >> Atmp;
		que.push(Atmp);
	}
	rep(i, M) {
		int Atop = que.top();
		que.pop();
		Atop /= 2;
		que.push(Atop);
	}
	ll ans = 0;
	rep(i, N) {
		ans += que.top();
		que.pop();
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 892
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int32_t N;
uint32_t V[300000];
uint32_t XOR;
uint32_t SUM;

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> N;
	for (size_t i = 0; i < N; i++)
	{
		in >> V[i];
	}
	uint64_t res = 0;
	uint64_t last_index = 0;
	uint64_t len = 0;
	for (size_t i = 0; i < N; i++)
	{
		++len;
		SUM += V[i];
		XOR ^= V[i];
		while (SUM != XOR) {
			SUM -= V[last_index];
			XOR ^= V[last_index];
			++last_index;
			--len;
		}
		res += len;
	}
	out << res << endl;

	return 0;
}
#endif


Measured memory_bytes: 1152
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
//#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define pii pair<int,int>
#define N 500500
#define dracarys ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);

int n, m, k;
char c[10][10];


int calc(int mask) {
    int result = 0;
    for (int i = 0; i < n; ++i) for (int j = 0; j < m; ++j) {
        if (c[i][j] == '.') continue;
        if ((mask & (1 << i)) || (mask & (1 << (j + n))))
            ++result;
    }
    return result;
}

void solve() {
    cin >> n >> m >> k;

    int B = 0;
    for (int i = 0; i < n; ++i) for (int j = 0; j < m; ++j) {
        cin >> c[i][j];
        if (c[i][j] == '#') ++B;
    }

    int ans = 0;
    for (int mask = 0; mask < (1 << (n + m)); ++mask) {
        if (calc(mask) == B - k)
            ++ans;
    }

    cout << ans << "\n";
}

int main() {
//    freopen("sample.in", "r", stdin);
    dracarys
    int t = 1;
//    cin >> t;
    for (int i = 1; i <= t; ++i) {
//        cout << "Case #" << i << ": ";
        solve();
    }
    return 0;
}


Measured memory_bytes: 3652
let () =
  Scanf.scanf "%d\n" @@ fun n ->
  let a = if n mod 10 = 2 then 1 else 0 in
  let b = if (n mod 100) / 10 = 2 then 1 else 0 in
  let c = if (n mod 1000) / 100 = 2 then 1 else 0 in
  let d = if n / 1000 = 2 then 1 else 0 in
  Printf.printf "%d\n" (a+b+c+d)

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

struct Card { char suit, value; };

void bubble(struct Card A[], int N) {
  for ( int i = 0; i < N; i++ )
    for ( int j = N - 1; j >= i + 1; j-- )
      if ( A[j].value < A[j - 1].value )
        swap(A[j], A[j - 1]);
}

void selection(struct Card A[], int N) {
  for ( int i = 0; i < N; i++ ) {
    int minj = i;
    for ( int j = i; j < N; j++ )
      if ( A[j].value < A[minj].value ) minj = j;
    Card t = A[i]; A[i] = A[minj]; A[minj] = t;
  }
}

void print(struct Card A[], int N) {
  for ( int i = 0; i < N; i++ ) {
    if ( i > 0 ) cout << " ";
    cout << A[i].suit << A[i].value;
  }
  cout << endl;
}

bool isStable(struct Card C1[], struct Card C2[], int N) {
  for ( int i  = 0; i < N; i++ )
    if ( C1[i].suit != C2[i].suit ) return false;
  return true;
}

int main() {
  Card C1[100], C2[100];
  int N;
  char ch;

  cin >> N;
  for ( int i = 0; i < N; i++ )
    cin >> C1[i].suit >> C1[i].value;

  for ( int i = 0; i < N; i++ ) C2[i] = C1[i];

  bubble(C1, N);
  selection(C2, N);

  print(C1, N);
  cout << "Stable" << endl;
  print(C2, N);
  if ( isStable(C1, C2, N) )
    cout << "Stable" << endl;
  else
    cout << "Not stable" << endl;

  return 0;
}


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

int main(){
  int N;
  cin >> N;
  
  bool a = false;
  for(int i=1; i<10; i++){
    if(N%i == 0 && N/i >0 && N/i <10){
      a = true;
      break;
    }
  }
  
  if(a) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}


Measured memory_bytes: 256
import java.io.*;
public class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader bf = 
            new BufferedReader(new InputStreamReader(System.in));        
        int N = Integer.parseInt(bf.readLine());
        int[] H = new int[N];
        String[] str = bf.readLine().split(" ");
        for(int i = 0; i < N; i++){
            H[i] = Integer.parseInt(str[i]);
        }
        int num = 1;
        loop: for(int i = 1; i < N; i++){
            for(int j = 0; j < i; j++){
                if(H[i] < H[j]){
                    continue loop;
                }
            }
            num++;
        }
        System.out.println(num);
    }
}

Measured memory_bytes: 22100
void main()
{
    dchar[] s = readln.chomp.to!(dchar[]);

    if (s.length == 3) reverse(s);
    s.writeln;
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
N, K = map(int, input().split())

MOD = 10 ** 9 + 7

cache = {1: 1}
def f(k, n):
    if k in cache:
        return cache[k]
    result = pow(k, n, MOD)
    for i in range(2, k + 1):
        result -= f(k // i, n)
        result %= MOD
    cache[k] = result
    return result


result = 0
for i in range(1, K + 1):
    result += f(K // i, N) * i
    result %= MOD
print(result)


Measured memory_bytes: 9228
import java.util.*;
// warm-up
public class Main {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt(),B = sc.nextInt(),C = sc.nextInt(),D = sc.nextInt();
		System.out.println((A+B==C+D) ? "Balanced" : (A+B<C+D) ? "Right" : "Left");
		sc.close();		
	}

	public static void main(String args[]) {
		solve();
	}

}

Measured memory_bytes: 35552
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
	int n, m;
	cin >> n >> m;
	vector<vector<pair<long long, int>>> mm(n);
	for (int i = 0; i < m; i++) {
		int p;
		long long y;
		cin >> p >> y;
		mm[p-1].push_back(make_pair(y, i));
	}
	for (int i = 0; i < n; i++) {
		sort(mm[i].begin(), mm[i].end());
	}
	vector<pair<int, long long>> ans;
	for (long long i = 0; i < n; i++) {
		for (auto it = mm[i].begin(); it != mm[i].end(); it++) {
			ans.push_back(make_pair(it->second, (i+1)*1000000 + distance(mm[i].begin(), it)+1));
		}
	}
	sort(ans.begin(), ans.end());
	for (auto e : ans) {
		printf("%012lld\n", e.second);
	}

	return 0;
}

Measured memory_bytes: 10636
#include<cstdio>
#define ll long long
using namespace std;
int sum[10][10];
ll ans=0;
int main(){
	int n;
	scanf("%d",&n);
	for (int i=1; i<=n; i++){
		int x=i,y=i%10;
		for (; x>=10; x/=10);
		sum[x][y]++;
	}
	for (int i=1; i<=n; i++){
		int x=i,y=i%10;
		for (; x>=10; x/=10);
		ans+=sum[y][x];
	}
	printf("%lld\n",ans);
	return 0;
}

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

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin>>n;
  int arr[n]={0};
  int arrr[n]={0};
  for(int i=0;i<n-1;i++){
    cin>>arr[i];
}
  for(int i=0;i<n;i++){
  	arrr[arr[i]-1]++;
    //if(arr[i]==i){
      //arrr[i]++;
  }
  for(int i=0;i<n;i++)
    cout<<arrr[i]<<endl;
return 0;
}
  

Measured memory_bytes: 5208
sub f{print"? @_
"}$L=0,$|=$R=10,$_.=${f(($_.($%=$L+$R>>1))*1e9),<>=~Y?$R:$L=$%while$R-$L>1;L}while$i++<9;f++$_+s/0*$//;f 1+($_.=0)while<>=~(/^9*$/?Y:N);print"! $_
"

Measured memory_bytes: 852
s = input()
k = int(input())
n = len(s)

ans = []

for i in range(n):
    for j in range(1,k+1):
        if i + j > n:
            continue
        ans.append(s[i:i+j])

ans = set(ans)
ans = sorted(ans)
print(ans[k-1])

Measured memory_bytes: 4980
local n = io.read("*n")
local tasks = {}
table.insert(tasks, {"a", 1})
local ret = {}
while 0 < #tasks do
  local task = tasks[#tasks]
  local w, used = task[1], task[2]
  table.remove(tasks)
  if #w == n then
    table.insert(ret, w)
  else
    for i = 1, used + 1 do
      local z = i <= used and used or used + 1
      table.insert(tasks, {w .. string.char(96 + i), z})
    end
  end
end
for i = #ret, 1, -1 do
  print(ret[i])
end


Measured memory_bytes: 11504
#include <bits/stdc++.h> 
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
#define MAX 100005
#define DEBUG 0 
#define LIMIT (LONG_MAX / 10)
#define POSITIVE_LAST_D (LONG_MAX % 10)
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;

int main(){
    int n,x,y;
    cin>>n>>x>>y;
    --x;--y;
    Graph g(n);
    for(int i=0;i<n-1;i++){
        g[i].push_back(i+1);
        g[i+1].push_back(i);
    }
    g[x].push_back(y);
    g[y].push_back(x);

    vector<int> ans(n);
    rep(i,n){
        vector<int> dist(n,-1);
        queue<int> q;
        dist[i]=0;
        q.push(i);

        while(!q.empty()){
            int v=q.front();
            q.pop();
            for(int nv:g[v]){
                if(dist[nv]!=-1)continue;
                dist[nv]=dist[v]+1;
                q.push(nv);
            }
        }
        rep(i,n){
            ans[dist[i]]++;
        }

    }
    rep(i,n-1){
        cout<<ans[i+1]/2<<endl;
    }
    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000000

template <typename T,typename U>
struct compressor{
	vector<pair<T,U>> v;
	void add(T x,U y){
		v.emplace_back(x,y);
	}
	
	void compress(){
		
		sort(v.begin(),v.end(),[&] (pair<T,U> a,pair<T,U> b){
			return a.first < b.first;
		}
		);
		
		vector<pair<T,U>> t;
		rep(i,v.size()){
			if(t.size()!=0 && t.back().first == v[i].first){
				t.back().second = func(t.back().second,v[i].second);
			}
			else{
				t.push_back(v[i]);
			}
		}
		swap(v,t);
		
	}

	U func(U a,U b){
		return a+b;
	}

	U e(){
		return 0;
	}

	int size(){
		return v.size();
	}
	
	U get(int p){
		return v[p].second;
	}
	
	U operator[] (T &x){
		auto it = lower_bound(v.begin(),v.end(),make_pair(x,0));
		if(it==v.end() || it->first!=x){
			if(it!=v.begin()){
				it--;
			}
		}
		if(it==v.end() || it->first!=x){
			return e();
		}
		else return it->second;
	}
};

bool f = false;
compressor<pair<string,string>,int> get(string S){
	int N = S.size();
	compressor<pair<string,string>,int> C;
	for(int i=0;i<(1<<N);i++){
		string s="",t="";
		for(int j=0;j<N;j++){
			if((i>>j)&1)s+=S[j];
			else t+=S[j];
		}
		reverse(t.begin(),t.end());
		if(f)swap(s,t);
		C.add(make_pair(s,t),1);
	}
	f=true;
	C.compress();
	return C;
}
 
int main(){
	
	int N;
	cin>>N;
	
	string S;
	cin>>S;
	
	compressor<pair<string,string>,int> C0 = get(S.substr(0,N)),C1 = get(S.substr(N));
	
	long long ans = 0;
 
	for(auto a:C0.v){
		ans += (long long)a.second * C1[a.first];
	}
	
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 86128
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi M_PI
#define EPS 1e-6
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int par[1000];

void init(int n){
    REP(i,n){
        par[i] = i;
    }
}

int find(int x){
    if (par[x] == x){
        return x;
    }else{
        return par[x] = find(par[x]);
    }
}

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

void merge(int x, int y){
    x = find(x);
    y = find(y);
    if (x==y) return;
    par[x] = y;
}

struct edge{ int u, v; double cost; };

vector<edge> es;
int n;

bool comp(const edge &e1, const edge &e2){
    return e1.cost < e2.cost;
}

double kruskal(){
    sort(es.begin(), es.end(), comp);
    init(n);
    double res = 0;
    REP(i,es.size()){
        edge e = es[i];
        if (!same(e.u, e.v)){
            merge(e.u, e.v);
            res += e.cost;
        }
    }
    return res;
}

int main() {
    while (cin >> n && n){
        es.clear();
        vector<double> x(n), y(n), z(n), r(n);
        REP(i,n) cin >> x[i] >> y[i] >> z[i] >> r[i];
        REP(i,n) REP(j,n) {
            edge e;
            e.u = i;
            e.v = j;
            double d = sqrt(pow(x[i]-x[j],2) + pow(y[i]-y[j],2) + pow(z[i]-z[j],2));
            d -= r[i] + r[j];
            if (d < 0) d = 0;
            e.cost = d;
            es.push_back(e);
        }
        printf("%.3f\n", kruskal());
    }
    return 0;
}

Measured memory_bytes: 3332
import * as fs from 'fs';


// a→b b→c c→a
//in
// 6 2 2
//out
// 5
const main = (inp: string) => {

    const [a, b, c]: number[] = inp.split(' ').map(Number);
    const route1: number = a + b;
    const route2: number = b + c;
    const route3: number = c + a;

    console.log(Math.min(route1, route2, route3));
};

main(fs.readFileSync('/dev/stdin', 'utf8').trim());

Measured memory_bytes: 7372
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
	ios::sync_with_stdio(false); cin.tie(0);
	int h, w;
	cin >> h >> w;
	int r = -1;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			char c;
			cin >> c;
			if (c == '#' && j < r) {
				cout << "Impossible" << endl;
				return 0;
			}
			if (c == '#') r = j;
		}
	}
	cout << "Possible" << endl;
	return 0;	
}


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

int main(){

  int n;
  cin >> n;

  n %= 10;
  if(n == 3) puts("bon");
  else if(n == 0 || n == 1 || n == 6 || n == 8) puts("pon");
  else puts("hon");

}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

vector<int> f(100, -1);

int fib(int n) {
    if (n == 0) return 1;
    if (n == 1) return 1;
    if (f[n] != -1) return f[n];
    f[n] = fib(n - 1) + fib(n - 2);
    return f[n];
}

int main() {
    int n;
    cin >> n;
    cout << fib(n) << endl;
    return 0;
}



Measured memory_bytes: 3096
#include <stdio.h>
#include <string.h>

int main(void)
{
	char str[1001];
	int i;

	scanf("%s", str);

	for (i = 0; i < strlen(str); i++){
		if (str[i] >= 'D' && str[i] <= 'Z'){
			str[i] -= 0x3;
		}
		else if (str[i] >= 'A' && str[i] <= 'C'){
			str[i] += 0x17;
		}
	}

	printf("%s\n", str);

	return (0);
}

Measured memory_bytes: 524
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
const ll MOD = 1e9+7;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(int i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
#define fs first
#define sc second


const int INF = 1e9;
const ll LLINF = 1e16;

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...));
}
 
template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}
 
template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}
 
template<typename T>
T gcd(T a,T b){return b?gcd(b,a%b):a;}

template<typename T>
T ngcd(vector<T> a){
    T res;
    res = a[0];
    for(int i = 1; i < a.size() && res != 1; i++) {
        res = gcd(a[i], res);
    }
    return res;
}
 
template<typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

template<typename T>
T nlcm(vector<T> numbers) {
    T res;
    res = numbers[0];
    for (int i = 1; i < numbers.size(); i++) {
        res = lcm(res, numbers[i]);
    }
    return res;
}

// 割り算の切り上げ処理
template<typename T>
T round_up(T a, T b) {
  return (a + b - 1) / b;
}

// 約数列挙
template<typename T>
vector<T> calc_divisor(T n) {
   vector<T> res;
   for (T i = 1LL; i*i <= n; ++i) {
       if (n % i == 0) {
           res.push_back(i);
           T j = n / i;
           if (j != i) res.push_back(j);
       }
   }
   sort(res.begin(), res.end());
   return res;
}

// 素数判定
template<typename T>
bool isPrime(T x){
    T i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}

using pint = pair<int, int>;
using pll = pair<ll, ll>;


int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    vector<int> ans = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;
    print(ans[k - 1]);
    
}


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

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, k;
    cin >> n >> k;
    int a[n + 1], dp[n + 1];
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
        dp[i] = INT_MAX;
    }
    dp[1] = 0;
    dp[2] = abs(a[2] - a[1]);
    for(int i = 3; i <= n; i++) {
        for(int j = i - 1; j >= (i - k); j--) {
            //cout << j << endl;
            if(j == 0)
                break;
            dp[i] = min(dp[j] + abs(a[j] - a[i]), dp[i]);
        }
    }
    cout << dp[n] << endl;
    return 0;
}


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

using namespace std;

long long sum(long long l, long long r)
{
    return (l + r)*(r - l + 1) / 2;
}

int main(void)
{
    long long N, K;
    cin >> N >> K;

    // 10^100 : 10^9 + 7 is relatively prime
    // 10^ 9 + 7 is prime
    // 10 ^ 100 = (10 ^ 10) ^ 10
    // Fermet: a * b^n-1 mod n = a mod n
    // (a + b) mod n = (a mod n + b mod n) mod n
    // a*b mod n = ((a mod n ) *( b mod n )) mod n
    // (a mod n) mod n = a mod n
    // 10^ 100 = (10 mod n) ^ 100

   vector<int> v(N);
   for(int i = 0; i<N + 1;i++) {
       v[i] = i;
   }

   long long max = 0;
   long long min = 0;
   long long ans = 0;
   for (long long j = K;j <= N+1;j++) {
       min = sum(0,j-1);
       max = sum(N - j + 1,N);
       ans += (max - min + 1);
       ans = ans % 1000000007;
   }
   cout << ans << endl;
   return 0 ;
}

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

#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

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

ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    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;
    }
}
ll 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;
}

ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N=in();
    int M=in();
    vector<pair<int,int>> bridge;
    int a,b;
    REP(i,M){
        cin>>a>>b;
        if(b<a)swap(a,b);
        bridge.pb(mp(a,b));
    }
    sort(all(bridge),compare_by_b);
    int broken;broken=0;//直前に壊された橋　broken=2のとき 1-2の橋が壊されている。
    int ans;ans=0;
    REP(i,M){
        if(broken==0){
            broken=bridge[i].second;
            //debug(broken);
            ans++;
        }else{
            if(broken<=bridge[i].first){
                broken=bridge[i].second;
                ans++;
            }
        }
    }
    print(ans);
    return 0;
}

Measured memory_bytes: 1400
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <list>
#include <ctime>
#include <sstream>
#include <queue>
#include <stack>
#include <bitset>
#include <numeric>
#include <cassert>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;
#define FOR(x, b, e) for(int x=(b); x<=(e); ++x)
#define FORD(x, b, e) for(int x=((int)(b))-1; x>=(e); --x)
#define REP(x, n) for(int x=0; x<(n); ++x)
#define ALL(c) c.begin(),c.end()
#define sz(x) ((int)((x).size()))
#define pb push_back
#define st first
#define nd second
#define mp(x,y) make_pair(x,y)
typedef short int sint;

#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 << ((it != d.b) ? ", " : "") << *it;
  }
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const int N = 101010;
int p[N], r[N], roz[N], blInside[N], frInside[N];
pii ed[N];
vi za[N];

int find(int x) {
	if (x != p[x]) {
		p[x] = find(p[x]);
	}
	return p[x];
}

void lacz(int x, int y) {
	int a = find(x), b = find(y);
	if (a == b) {
		return;
	}
	if (r[a] > r[b]) {
		p[b] = a;
		roz[a] += roz[b];
	} else {
		p[a] = b;
		roz[b] += roz[a];
		if (r[a] == r[b]) {
			++r[b];
		}
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	int n, m, k;
	cin >> n >> m >> k;
	FOR(i, 1, n) {
		p[i] = i;
		roz[i] = 1;
	}
	REP(i, m) {
		int x, y;
		cin >> x >> y;
		lacz(x, y);
		ed[i] = mp(x, y);
	}
	REP(i, k) {
		int x, y;
		cin >> x >> y;
		int a = find(x), b = find(y);
		if (a == b) {
			++blInside[x];
			++blInside[y];
		}
	}
	REP(i, m) {
		int x = ed[i].st, y = ed[i].nd;
		int a = find(x), b = find(y);
		if (a == b) {
			++frInside[x];
			++frInside[y];
		}
	}
	FOR(i, 1, n) {
		int res = roz[find(i)] - blInside[i] - frInside[i];
		printf("%d ", res - 1);
	}
	printf("\n");
}

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

typedef long long ll;

ll gcd(ll n,ll m){
  if(m==0){
    return n;
  }
  else{
    return gcd(m,n%m);
  }
}

int main(){
  ll n,m;
  string s1,s2;
  cin >> n >> m >> s1 >> s2;
  bool ans=true;
  ll k=gcd(n,m);
  for(ll i=0;i<n;i+=n/k){
    ll j=i/(n/k)*(m/k);
    if(s1.at(i)!=s2.at(j)){
      ans=false;
    }
  }
  cout << (ans?m/k*n:-1) << endl;
}

Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <vector>
#include <string>
#include <bitset>
#include <stack>
#include <queue>
#include <tuple>
#include <regex>
#include <cmath>
#include <map>
#include <set>
#include <functional>
#include <cstring>

using namespace std;

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

using ll = long long;
using Pint = pair<int, int>;
using Pll  = pair<ll, ll>;

#define eb emplace_back
#define pb push_back
#define mp make_pair

#define F first
#define S second

#define popcnt __builtin_popcountll

#define rep( i, n ) for ( ll i = 0; i < (ll)( n ); ++i )
#define reps( i, n ) for ( ll i = 1; i <= (ll)( n ); ++i )
#define rrep( i, n ) for ( ll i = (ll)( ( n ) - 1 ); i >= 0; --i )
#define rreps( i, n ) for ( ll i = (ll)( ( n ) ); i > 0; --i )
#define arep( i, v ) for ( auto &&i : ( v ) )

#define ALL( c ) ( c ).begin(), ( c ).end()
#define RALL( c ) ( c ).rbegin(), ( c ).rend()
#define UNIQUE( c ) ( c ).erase( unique( ( c ).begin(), ( c ).end() ), ( c ).end() )

template<typename T = ll> constexpr T MAX = numeric_limits<T>::max();
template<typename T> T gcd( const T a, const T b ) { return ( b ? gcd( b, a % b ) : a ); }
template<typename T> T lcm( const T a, const T b ) { return ( a / gcd( a, b ) * b ); }


int main()
{
	ll H, W, m;
	cin >> H >> W >> m;
	map<Pll, ll> mm;
	map<ll, ll> mh, mw;
	rep( i, m )
	{
		ll h, w; cin >> h >> w;
		--h; --w;
		mh[h]++; mw[w]++;
		mm[mp( h, w )]++;
	}

	vector<ll> tmphv, tmpwv;
	ll tmph = 0, tmpw = 0;
	ll hnum = 0, wnum = 0;
	rep( i, H )
	{
		if ( chmax( hnum, mh[i] ) )
		{
			tmph = i;
			tmphv.clear();
		}
		else if ( hnum == mh[i] )
		{
			tmphv.eb( tmph );
			tmphv.eb( i );
		}
	}
	rep( i, W )
	{
		if ( chmax( wnum, mw[i] ) )
		{
			tmpw = i;
			tmpwv.clear();
		}
		else if ( wnum == mw[i] )
		{
			tmpwv.eb( tmpw );
			tmpwv.eb( i );
		}
	}

	tmphv.eb( tmph );
	tmpwv.eb( tmpw );

	ll ans = mh[tmph] + mw[tmpw];
	if ( mm[mp( tmph, tmpw )] ) --ans;
	arep( ith, tmphv )
	{
		arep( itw, tmpwv )
		{
			if ( mm[mp( ith, itw )] == 0 )
			{
				ans = mh[ith] + mw[itw];
				cout << ans << endl;
				return ( 0 );
			}
		}
	}
	cout << ans << endl;

	return ( 0 );
}


Measured memory_bytes: 76016
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define loop(i,a,b) for(ll i=a; i<b; i++)
#define revloop(i,a,b) for(ll i=a; i>=b; i--)
#define pb push_back
#define vl vector<ll>
#define vvl vector<vl>
#define pl pair<ll,ll>
#define vpl vector<pl>
#define all(c) (c).begin(), (c).end()
#define sz(a) ll((a).size())
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i!=(c).end(); i++))
#define mp make_pair
int main()
{
    ll n,W;
    cin>>n>>W;
    vl w(n), v(n);
    loop(i,0,n) cin>>w[i]>>v[i];
    ll dp[n+1][W+1];
    loop(i,0,n+1)
    {
    	loop(j,0,W+1)
    	{
    		if(i==0 || j==0) dp[i][j]=0;
    		else if(w[i-1]<=j) dp[i][j] = max(v[i-1]+dp[i-1][j-w[i-1]], dp[i-1][j]);
    		else dp[i][j] = dp[i-1][j];
		}
	}
	cout<<dp[n][W];
	return 0;
}

Measured memory_bytes: 79104
using System;
using System.Linq;
 
namespace aizu
{
    class OnlineJudge
    {
        static void Main()
        {
            string[] data;
            while((data = Console.ReadLine().Split())[0] != "0" || data[1] != "0") {
                int hit = 0, blow = 0;
                for(int i=0; i < data[0].Length; ++i) {
                    if(data[0][i] == data[1][i]) {
                        ++hit;
                    }
                    if(data[0].Contains(data[1][i])) {
                        ++blow;
                    }
                }
                Console.WriteLine("{0} {1}", hit, blow - hit);
            }
        }
    }
}

Measured memory_bytes: 6384
#include<stdio.h>
int main(void)
{
	int a,b,c,d,p,x,y,n;
	scanf("%d %d %d %d %d",&a,&b,&c,&d,&p);
	x=p*a;
	if(p>c){
		n=p-c;
		y=b+n*d;
		
	}
	else if(p<=c){
		y=b;
	}
	if(x<y){
		printf("%d\n",x);
	}
	else{
		printf("%d\n",y);
	}
	return 0;
}


Measured memory_bytes: 2748
#include <stdio.h>
#include <math.h>

int main(){
    int n;

    while(1){
        scanf("%d", &n);
        if(n == 0) break;

        int i;
        double total = 0;
        double score[1005] = {0};
        for(i=0; i<n; i++){
            scanf("%lf", &score[i]);
            total += score[i];
        }
        double average = total / n;
        
        double square = 0;
        for(i=0; i<n; i++){
            square += pow(score[i] - average, 2);    
        }

        double standard_deviation = sqrt(square/n);
        printf("%.8lf\n", standard_deviation);
    }
}



Measured memory_bytes: 2048
#include <bits/stdc++.h>
#include <math.h>//pow(x,y)=x^y
#include <algorithm>//sort(a.begin(), a.end());reverse(a.begin(), a.end());
#define rep(init,i,n) for (int i=init; i <(n);i++)
#define ll long long
using namespace std;

string bigint_to_string(vector<int> digit) {
    int N = digit.size(); // N = (配列 digit の長さ)
    string str = "";
    for(int i = N - 1; i >= 0; --i) {
        str += digit[i] + '0';
    }
    return str;
}

vector<int> string_to_bigint(string S) {
    int N = S.size(); // N = (文字列 S の長さ)
    vector<int> digit(N);
    for(int i = 0; i < N; ++i) {
        digit[i] = S[N - i - 1] - '0'; // 10^i の位の数
    }
    return digit;
}

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

int N = n.size(); // N = (文字列 S の長さ)
    vector<int> digit(N);
    for(int i = 0; i < N; ++i) {
        digit[i] = n[N - i - 1] - '0'; // 10^i の位の数
    }

int sum = 0;
int temp;
rep(0,i,N){
    temp = (int)digit.at(i);
    sum += temp;
}
if(sum%9==0){
    cout<<"Yes"<<endl;
}else{
    cout<<"No"<<endl;
}
}

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> lx(n);
  vector<int> pairs(m), nums(m);
  map<int, int> cards;
  for (int &x: lx) {
    cin >> x;
    cards[x] += 1;
  }
  for (auto it: cards) {
    int x = it.first;
    pairs[x%m] += it.second/2;
    nums[x%m] += it.second;
    // cerr << x << " " << pairs[x%m] << " " << nums[x%m] << endl;
  }
  int ans = nums[0]/2;
  if (m%2 == 0) {
    ans += nums[m/2]/2;
  }
  for (int i = 1; i < (m+1)/2; ++i) {
    // 同じ数字でない者同士でまずpairをつくる
    int diff_pair = min(nums[i]-pairs[i]*2, nums[m-i]-pairs[m-i]*2);
    ans += diff_pair;
    nums[i] -= diff_pair;
    nums[m-i] -= diff_pair;
    // cout << i << " " << nums[i] << " " << nums[m-i] << " " << pairs[i] << " " << pairs[m-i] << " " << ans << endl;
    if (nums[i] < nums[m-i]) {
      swap(nums[i], nums[m-i]);
      swap(pairs[i], pairs[m-i]);
    }
    // 余っている方の同じ数字同士でpairを作る
    int pair2 = min((nums[i]-nums[m-i])/2, pairs[i]);
    ans += pair2;
    nums[i] -= pair2*2;
    // 残りでpairを作る
    ans += min(nums[i], nums[m-i]);
    // ans += pair*2;
    // pairs[i] -= pair;
    // pairs[m-i] -= pair;
    // nums[i] -= pair*2;
    // nums[m-i] -= pair*2;
    // int pair2 = min(nums[i], nums[m-i]); 
    // ans += pair2;
    // nums[i] -= pair2;
    // nums[m-i] -= pair2;
    // cout << i << " " << ans << endl;
    // if (nums[i] > 0 && pairs[i] > 0) {
    //   ans += min(nums[i]/2, pairs[i]);
    // }
    // cout << i << " " << ans << endl;
  }
  cout << ans << endl;
}



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

int main(){

char a;
long long int acount = 0;
long long int ans=0;
bool BandC=false;
while(cin>>a){
	if(a=='A'){
		if(BandC==true){BandC=false;acount=1;}
		else{acount++;}
	}
	if(a=='B'){
		if(BandC==true){BandC=false;acount=0;}
		else{BandC=true;}
	}
	if(a=='C'){
		if(BandC==false){BandC=false;acount=0;}
		else{BandC=false;ans+=acount;}
	}
}
cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 256