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

int main(){
  int H, W;
  int i, j, k, l;
  cin >> H >> W;

  char S[H][W], T[H][W];
  
  for(i = 0; i < H; i++){
    for(j = 0; j < W; j++){
      cin >> S[i][j];
    }
  }
  
  for(i = 0; i < H; i++){
    for(j = 0; j < W; j++){
      int c = 0;
      if(S[i][j] != '#'){
	for(k = 0; k < 3; k++){
	  for(l = 0; l < 3; l++){
	    if(i + l - 1 < 0 || j + k - 1 < 0 || i + l - 1 >= H || j + k - 1 >= W)
	      continue;
	    if(S[i + l - 1][j + k - 1] == '#')
	      c++;
	  }
	}
	T[i][j] = '0'+ c;
      }
      else
	T[i][j] = '#';
    }
  }
  
  for(i = 0; i < H; i++){
    for(j = 0; j < W; j++){
      cout << T[i][j];
    }
    cout << endl;
  }
}


Measured memory_bytes: 384
#include <iostream>
int main(int argc, char const *argv[]) {
    long long s,c;std::cin >> s >> c;
    if (2*s>=c) {
        std::cout << c/2 << '\n';
    }else{
        std::cout << s+(c-2*s)/4 << '\n';
    }
    return 0;
}


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

using namespace std;

#define forn(i,n) for ( int i=0 ; i < n ; i++ )
#define all(a) (a).begin(), (a).end()
#define boost ios::sync_with_stdio(0);cin.tie(0);
#define lb lower_bound
#define ub upper_bound
#define vi vector<int >
#define pii pair<int, int>
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define SQ(a) (a)*(a)
#define ll long long
#define lli long long int
#define ull unsigned long long
#define endl '\n'
#define Pi(a) printf("%d\n",a);
#define debug2(a,b) printf("%d\t%d\n",a,b);
#define debug1(a) printf("%d\n",a);
#define Si(a) scanf("%d",&a);
#define mod 1000000007
#define w(n) while(n--)

ll val[27];

int main()
{
    boost
    //code;
    int n;
    string s;
    cin >> n >> s;
    ll ans = 1;
    for(auto it:s) val[it-'a']++;
    for(int i=0;i<26;i++){
    	ans *= (val[i]+1);
    	ans %= mod;
    }
    ans = (ans - 1 + mod)%mod;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
right = input()
Q = int(input())
flag = 0b1
left = ""
for i in range(Q):
    q = input()
    if q == "1":
        flag ^= 1
        continue
    m,f,c = q.split(" ")
    f = int(f)
    left += c*(1-flag)*(f-1)
    right += c*flag*(f-1)
    left += c*flag*(2-f)
    right += c*(1-flag)*(2-f)
if flag == 1:
    print(left[::-1]+right)
else:
    print(right[::-1]+left)

Measured memory_bytes: 4480
import sys
import bisect as bi
import math
from collections import defaultdict as dd
import heapq
import itertools
input=sys.stdin.readline
##import numpy as np
#sys.setrecursionlimit(10**7)
mo=10**9+7
def cin():
    return map(int,sin().split())
def ain():            
    return list(map(int,sin().split()))
def sin():
    return input()
def inin():
    return int(input())
##def power(x, y):
##    if(y == 0):return 1
##    temp = power(x, int(y / 2))%mo
##    if (y % 2 == 0):return (temp * temp)%mo 
##    else:
##        if(y > 0):return (x * temp * temp)%mo 
##        else:return ((temp * temp)//x )%mo
##
for _ in range(1):
    n=inin()
    l=ain()
    ans=0
    curr=l[0]
    for i in range(1,n):
        if(l[i]<curr):
            ans+=curr-l[i]
        curr=max(curr,l[i])
    print(ans)

Measured memory_bytes: 33724
/*⠀⠀, --- 、⠀⠀⠀゜
⠀⠀⠀/;;;;;;;;;;;;', 　゜
⠀⠀⠀i二二二i     ゜
⠀⠀  , ' 　    　ヽ 
⠀⠀i　ﾉﾉﾉﾉﾉﾍ .', ⠀⠀<I can't solve...
⠀  〉ﾘi'= _ =ﾉﾚく　 <WAyon....
○⊂}〈lﾄ--ｲl〉{つ● 　　
⠀⠀⠀,ｒ/ー i-ヽヽ 　　　
⠀⠀｀｀i_⊃i_⊃ */
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N,M;
  cin >> N >> M;
  if(N<M){
    for(int i=0;i<M-1;i++){
    cout << N;
    }
    cout << N << endl; 
  }
  else{
      for(int i=0;i<N-1;i++){
    cout << M;
    }
    cout << M << endl;
  }
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;



namespace Test1 {

    class ClassMain {

        public static void Main(String[] args) {
            string line;

            while ((line = Console.ReadLine()) != null) {
                int n = int.Parse(line);
                n %= 39;
                if(n==0)Console.WriteLine("3C39");
                else if(n<=9)  Console.WriteLine("3C0" + n);
                else Console.WriteLine("3C"+n);

            }
        }
    }

}

Measured memory_bytes: 5592
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
bool odd(const int &n) { return n & 1; }
bool even(const int &n) { return ~n & 1; }
template<typename T> int len(const T &v) { return v.size(); }
template<typename T = int> T in() { T x; cin >> x; return x; }
template<typename T = int> T in(T &&x) { T z(forward<T>(x)); cin >> z; return z; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> istream &operator>>(istream &is, pair<A, B> &p) { return is >> p.first >> p.second; }
template<typename T> ostream &operator<<(ostream &os, const vector<vector<T>> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : "\n"); return os; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : " "); return os; }
template<typename A, typename B> ostream &operator<<(ostream &os, const pair<A, B> &p) { return os << p.first << ' ' << p.second; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
// clang-format on

main() {
  int n = in();
  vector<int> a(n);
  cin >> a;
  int q = in();
  a.erase(unique(all(a)), a.end());
  cout << a << endl;
}



Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
typedef long long ll;
typedef long double ld;
int main(){
    ll n,m;cin>>n>>m;
    cout<<(n-1)*(m-1)<<endl;
    return 0;
}


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

int main()
{
    int n;
    int ans = 0;
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        if (to_string(i).length() % 2)
        {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <limits.h>
#include <cstring>
#include <tuple>
#include <cassert>
#include <numeric>
using namespace std;
// type alias
typedef long long LL;
typedef vector < int > VI;
typedef unordered_map < int, int > MAPII;
typedef unordered_set < int > SETI;
typedef pair< int , int > II;
typedef tuple< int, int, int > III;
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// minmax
#define SMAX(a,b) a = max(a,b)
#define SMIN(a,b) a = min(a,b)
// debug cerr
#define TRACE true
#define dump(x) if(TRACE) { cerr << #x << " = " << (x) << endl; }
#define dump2(x,y) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << endl; }
#define dump3(x,y,z) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << endl; }
#define dump4(x,y,z,a) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << ", " << #a << " = " << (a) << endl; }
#define dumpAR(ar) if(TRACE) { FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }

// 16:05-16:27 analysis

// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG x.cpp && ./a.out
const int MAX_N=1e5+1;
int N;
LL X[MAX_N];
LL A,B;
void solve() {
  LL res=0;
  REP(i,N-1) res+=min(A*(X[i+1]-X[i]), B);
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  cin>>N>>A>>B;
  REP(i,N) cin>>X[i];
  solve();
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> istream& operator>>(istream& is,vector<T>& v) { for(T& t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream& os,const vector<T>& v) { for(T t:v){os<<t<<" ";} os<<"\n"; return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int h,w;
    cin >> h >> w;
    vs s(h);
    cin >> s;
    rep(i,h) rep(j,w) {
        if(s[i][j] == '.') continue;
        bool ok = false;
        rep(k,4) {
            int ni = i+dx[k],nj = j+dy[k];
            if(ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
            if(s[ni][nj] == '#') ok = true;
        }
        if(!ok) {
            Yes(0);
            return 0;
        }
    }
    Yes(1);
}


Measured memory_bytes: 892
import numpy as np
from collections import defaultdict,deque
N,K= map(int,input().split())
A = np.array([1]+list(map(int,input().split())))-1

Acs = np.cumsum(A)
Acs %= K

ans = 0
cnt = defaultdict(deque)
for i,c in enumerate(Acs):
    cnt[c].append(i)
    while cnt[c]:
        if i-cnt[c][0]> K-1:
            cnt[c].popleft()
        else:
            break
    ans += len(cnt[c]) - 1
print(ans)




Measured memory_bytes: 164120
#include "bits/stdc++.h"
#include <cmath>
#include <iomanip>
using namespace std;
 
#define f first
#define s second
 
#define pb push_back
#define pp pop_back
#define mp make_pair
 
#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))
 
#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)
#define reflex ios_base::sync_with_stdio(false)
 
#define nl '\n'
#define ioi exit(0);
 

#define PI 3.14159265

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
 
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int N= (int)2e5 + 7;
const int inf = (int)1e9 + 7;
//const int mod = (int)1e9 + 7;
//const int mod = 1000000007;
const ll linf = (ll)1e18 + 7;
 
const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int kx[] = {-1,1,2,2,1,-1,-2,-2};
const int ky[] = {2,2,1,-1,-2,-2,-1,1};

const int mod = 998244353;

struct dsu{
	int parent[N];
	int cont;
	void make_set(int n){
		for(int i = 1; i <= n; i++)
			parent[i] = i;
		cont = n;
	}
	
	int find_set(int v){
		if(v == parent[v])
			return v;
		return find_set(parent[v]);
	}
	
	void union_sets(int a, int b){
		a = find_set(a);
		b = find_set(b);
		if(a != b){
			parent[b] = a;
			cont--;
		}
	}
};

int m[13] ={0, 31,28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };

int main(){
	int m1, d1; cin>> m1>> d1;
	int m2, d2; cin>> m2 >> d2;
	
	if(m[m1] == d1)
		cout<< 1;
	else
		cout<<0;
	
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
} P;

P Q[LEN];
int head,tail,n;

void enqueue(P x){
  Q[tail]=x;
  tail=(tail+1)%LEN;
}

P dequeue(){
  P x=Q[head];
  head=(head+1)%LEN;
  return x;
}

int min(int a,int b){
  if(a<b)return a;
  else return b;
}

int main(){
  int elaps=0,c;
  int i,q;
  P u;
  scanf("%d %d",&n,&q);
  for(i=1;i<=n;i++){
    scanf("%s",Q[i].name);
    scanf("%d",&Q[i].t);
  }
  head=1;tail=n+1;

  while(head!=tail){
    u=dequeue();
    c=min(q,u.t);
    u.t-=c;
    elaps+=c;
    if(u.t>0)enqueue(u);
    else printf("%s %d\n",u.name,elaps);
  }
  return 0;
}



Measured memory_bytes: 11996
#include <stdio.h> 
int main(void)
{
	int card[4][13];
	int n, j, i, card1, a, b;
	char mark;
	for (a= 0;a < 4;a++)
	{
		for (b = 0;b < 13;b++)
		{
			card[a][b] = 0;
		}
	}
	scanf("%d", &n);
	for(i = 0;i < n*2;i++)
	{
		scanf("%c %d", &mark, &card1);
		if (mark == 'S')
		{
			card[0][card1-1] = 1;
		}
		else if (mark == 'H')
		{
			card[1][card1-1] = 1;
		}
		else if (mark == 'C')
		{
			card[2][card1-1] = 1;
		}
		else if (mark == 'D')
		{
			card[3][card1-1] = 1;
		}
	}
	for(i=0;i<4;i++)
	{
		for (j = 0;j < 13;j++)
		{
			if (card[i][j] == 0)
			{
				if (i == 0)
				{
					printf("S %d\n",j+1);
				}
				else if (i == 1)
				{
					printf("H %d\n",j+1);
				}
				else if (i == 2)
				{
					printf("C %d\n",j+1);
				}
				else if (i == 3)
				{
					printf("D %d\n",j+1);
				}
			}
		}
	}

	return 0;
}

Measured memory_bytes: 596
#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<int64_t> vec(110);
  for(int i = 1; i < N; i++){
    cin >> vec.at(i);
  }
  vec.at(0) = vec.at(1);
  vec.at(N) = vec.at(N-1);
  
  int64_t ans = 0;
  for(int i = 0; i < N; i++){
    ans += min(vec.at(i), vec.at(i+1));
  }
  
  cout << ans << endl;

}

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

using namespace std;


int main()
{
    long long N,b,ans=0,i;
    cin>>N;
    vector<long long> a(N);
	for(i=0;i<N;++i)
	{
		cin>>a[i];
		a[i]= a[i]-(i+1);
	}
	sort(a.begin(),a.end());
	b=a[(N)/2];
	for(i=0;i<N;++i){
	    ans+=abs(a[i]-b);
    }
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define int ll
//const ll mod = 1000000007;

int a,b;


int f(int x) {
    int y = (x+1)/2; // 2n, 2n-1 の n
    if (x%2 == 0) {
        if (y%2 == 0) return x;
        else return x+1;
    }
    else {
        if (y%2 == 0) return 0;
        else return 1;
    }
}
signed main() {
    cin >> a >> b;
    int ans = f(a-1) ^ f(b);
    cout << ans << endl;
}



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

int main()
{
	std::string a;
	std::cin >> a;
	if (a.length() <= 2)
	{
		std::cout << a;
	}
	else
	{
		std::string b = "";
		for (int i = a.length() - 1; i >= 0; i--)
		{
			b += a[i];
		}
		std::cout << b;
	}
}

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

using namespace std;
using ll = long long int;

int main()
{
    int n, d;
    cin >> n >> d;
    int total = n / (2 * d + 1);
    if(n % (2 * d + 1) != 0){
        total++;
    }
    cout << total << endl;
}

Measured memory_bytes: 256
#region Using directives
using System;
using static System.Console;
using static System.Convert;
using System.Collections.Generic;
#endregion

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = ToInt32(ReadLine());
            int k = ToInt32(ReadLine());
            string[] input = ReadLine().Split();
            List<int> arr = new List<int>();
            foreach (string s in input)
                arr.Add(ToInt32(s));
            List<int> answ = new List<int>();
            for(int i = 1; i <= n; i++)
            {
                int f = arr[i - 1] * 2;
                int s = (k - arr[i - 1]) * 2;
                answ.Add(System.Math.Min(f, s));
            }
            int ans = 0;
            foreach (int x in answ)
                ans += x;
            WriteLine(ans);
            ReadKey();
        }
    }
}



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

int main() {
  int N,k[201];
  int count = 0;
  cin >> N;
  
  for(int i = 0; i < N; i++) {
    cin >> k[i];
  }
  
  while(true) {
    bool judge = false;
    for(int i  = 0; i < N; i++) {
      if(k[i] % 2 != 0) {
        judge = true;
      } 
    }
    
    if(judge == true) {
      break;
    }
    
    for(int i = 0; i < N; i++) {
      k[i] /= 2;
    }
    
    count ++;
  }
  
  cout << count << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#include<queue>
#include<set>
#include<iomanip>
#define rep(i,n) for(ll i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,ll>P;





ll gcd(ll a,ll b)
{
    if(a!=0 && b==0)
    {
        return a;
    }
    if(a%b==0)
    {
        return b;
    }
    else
    {
        return(gcd(b,a%b));
    }
    
}


map<ll,ll> prime_factor(ll n)
{
    map<ll,ll>res;
    for(ll i=2;i*i<=n;i++)//i以下はすでに試しているからi*iよりnが小さかったらもう割り切れるものはない
    {
        while(n%i==0)
        {
            ++res[i];
            n/=i;
        }
    }
    if(n!=1)res[n]=1;
    return res;
}

int main()
{
    ll a,b;
    cin>>a>>b;
    ll g=gcd(a,b);
    auto st=prime_factor(g);
    cout<<st.size()+1;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <atcoder/all>
#define rep(i, n) for (int i=0; i < (n); i++)
using namespace std;
//using namespace atcoder;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int NIL = -1;
const int MAX = 10000;
const int MOD = 1000000007;
const double pi = 3.141592653589;

int main() {
    int n;
    cin >> n;
    int ans = 0;
    rep(i,n){
        int b; 
        cin >> b;
        if (b % 2 == 1)continue;
        while (b % 2 == 0){
            b /= 2;
            ans += 1; 
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
cnt = 0
loop do
    input = gets.split(" ").map do |i| i.to_i end
    if input[0] == 0 && input[1] == 0
        break
    else
        (1..input[0]).each do |n1|
            (n1+1..input[0]).each do |n2|
                (n2+1..input[0]).each do |n3|
                    if n1 + n2 + n3 == input[1]
                        cnt += 1
                    end
                end
            end
        end
    end
    puts cnt
    cnt = 0
end

Measured memory_bytes: 8768
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back

typedef long long LL;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<LL> VL;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;

map<LL, int> prime_factor(LL n) {
	map< LL, int > ret;
	for (LL i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}

int main() {
	int n; cin >> n;
	cout << n << ":";
	for (auto p : prime_factor(n))
		while (p.second--)cout << " " << p.first;
	puts("");
}


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

typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define chmax(a,b) a=max(a,b)
#define chmin(a,b) a=min(a,b)
#define mp1(a,b,c) P1(a,P(b,c))

int RET=0;

vector<P1> f(const vector<P> &vec,int W,int H){
	//sort(vec.begin(),vec.end());
	vector<P1> ret;
	set<int> S;
	S.insert(0);
	S.insert(H);
	for(P p: vec){
		auto itr=S.lower_bound(p.sc);
		int x=*itr; int y=*--itr;
		ret.push_back(mp1(y,x,p.fr));
		S.insert(p.sc);
	}
	auto itr=S.begin();
	while(1){
		int x=*itr;
		itr++;
		if(itr==S.end())break;
		int y=*itr;
		ret.push_back(mp1(x,y,W));
	}
	sort(ret.begin(),ret.end());
	return ret;
}

int solve(int W,int H,int N,vector<P> p){
	if(RET>=2*(W+H))return 0;
	if(N==0)return 2*(W+H);
	vector<P> L,R;
	int m;
	if(1){
		/*vector<int> X;
		for(int i=0;i<N;i++){
			X.push_back(p[i].fr);
		}
		sort(X.begin(),X.end());
		X.erase(unique(X.begin(),X.end()),X.end());*/
		if(p[0].fr==p[N-1].fr){
			int ret=0;
			vector<int> Y;
			Y.push_back(0);
			Y.push_back(H);
			for(int i=0;i<N;i++){
				Y.push_back(p[i].sc);
			}
			sort(Y.begin(),Y.end());
			for(int i=0;i+1<Y.size();i++){
				chmax(ret,Y[i+1]-Y[i]);
			}
			chmax(RET,max(2*(H+max(W-p[0].fr,p[0].fr)),2*(ret+W)));
			return max(2*(H+max(W-p[0].fr,p[0].fr)),2*(ret+W));
		}
		//m=X[(X.size()-1)/2];
		m=p[(p.size()-1)/2].fr;
		for(int i=0;i<N;i++){
			if(p[i].fr<=m){
				p[i].fr=m-p[i].fr;
				L.push_back(p[i]);
			}
			else {
				p[i].fr-=m+1;
				R.push_back(p[i]);
			}
		}
	}
	reverse(L.begin(),L.end());
	int ret=0;
	vector<P1> vec[2]={f(L,m,H),f(R,W-m-1,H)};
	map<int,int> M[2];
	int k[2]={};
	while(k[0]<vec[0].size()||k[1]<vec[1].size()){
		int t;
		if(k[0]==vec[0].size())t=1;
		else if(k[1]==vec[1].size())t=0;
		else if(vec[0][k[0]].fr<=vec[1][k[1]].fr)t=0;
		else t=1;
		P1 pp=vec[t][k[t]]; k[t]++;
		auto itr=M[1-t].lower_bound(pp.sc.fr);
		if(itr!=M[1-t].end()){
			chmax(ret,2*((pp.sc.fr-pp.fr)+itr->sc+pp.sc.sc)+2);
		}
		if(itr!=M[1-t].begin()){
			--itr;
			chmax(ret,2*((itr->fr-pp.fr)+itr->sc+pp.sc.sc)+2);
		}
		itr=M[t].lower_bound(pp.sc.fr);
		while(itr!=M[t].end()&&itr->fr+itr->sc<=pp.sc.fr+pp.sc.sc)M[t].erase(itr++);
		bool ok=itr==M[t].begin();
		if(!ok){
			--itr;
			ok=itr->fr+itr->sc<pp.sc.fr+pp.sc.sc;
		}
		if(ok)M[t].insert(pp.sc);
	}
	chmax(RET,ret);
	chmax(ret,solve(m,H,L.size(),L));
	chmax(ret,solve(W-m-1,H,R.size(),R));
	return ret;
}

int main(){
	int w,h,n;
	vector<P> vec;
	scanf("%d%d%d",&w,&h,&n);
	for(int i=0;i<n;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		vec.push_back(P(a,b));
	}
	/*w=h=100000000;
	n=10000;
	for(int i=0;i<n;i++){
		int a=rand()%(w+1);
		int b=rand()%(w+1);
		vec.push_back(P(a,b));
	}*/
	sort(vec.begin(),vec.end());
	cout<<solve(w,h,n,vec)<<endl;
}


Measured memory_bytes: 62612
#!/usr/bin/env python3
import sys


def solve(N: int, A: "List[int]"):
    x = sorted([[i,A[i]] for i in range(N)], key=lambda x:x[1])
    ans = [i+1 for i,j in x]
    print(' '.join(map(str,ans)))

    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


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

#define rep( i, n ) for( int i = 0; i < ( n ); i++ )
#define PI 3.14159265
typedef long long ll;

struct Dice {
    int num[ 6 ];
    //転がす処理
    void roll( char c ) {
        int temp; //置き換え用
        if( c == 'E' ) {
            temp     = num[ 0 ];
            num[ 0 ] = num[ 3 ];
            num[ 3 ] = num[ 5 ];
            num[ 5 ] = num[ 2 ];
            num[ 2 ] = temp;
        } else if( c == 'W' ) {
            temp     = num[ 0 ];
            num[ 0 ] = num[ 2 ];
            num[ 2 ] = num[ 5 ];
            num[ 5 ] = num[ 3 ];
            num[ 3 ] = temp;
        } else if( c == 'N' ) {
            temp     = num[ 0 ];
            num[ 0 ] = num[ 1 ];
            num[ 1 ] = num[ 5 ];
            num[ 5 ] = num[ 4 ];
            num[ 4 ] = temp;
        } else if( c == 'S' ) {
            temp     = num[ 0 ];
            num[ 0 ] = num[ 4 ];
            num[ 4 ] = num[ 5 ];
            num[ 5 ] = num[ 1 ];
            num[ 1 ] = temp;
        }
    }
    bool search( int dice[] ) {
        string s =
            "NNNNWNNNWNNNENNNENNNWNNN"; //縦確認→右→3つ確認→右→3つ確認（スタートに戻る）、同様に左チェック
        rep( i, s.length() ) {
            roll( s.at( i ) );
            rep( j, 6 ) {
                if( num[ j ] != dice[ j ] ) break;
                if( j == 5 ) return true;
            }
        }
        return false;
    }

    int top() { return num[ 0 ]; }
};

//*******************
//エントリーポイント
//*******************
int main( void ) {

    int n;
    cin >> n;

    // Diceの配列を作る
    Dice Ds[ n ];
    rep( i, n ) rep( j, 6 ) cin >> Ds[ i ].num[ j ];

    bool dif = false;

    for( int i = 0; i < n - 1; i++ ) {
        for( int j = i + 1; j < n; j++ ) {

            dif = Ds[ i ].search( Ds[ j ].num );
            if( dif ) {
                printf( "No\n" );
                return 0;
            }
        }
    }
    printf( "Yes\n" );
    return 0;
}



Measured memory_bytes: 3192
#include "bits/stdc++.h"
using namespace std;
struct valt{
	long long p0, p1, sum1, mdiff;
	valt(){
		p0 = 0;
		p1 = 0;
		sum1 = 0;
		mdiff = 0;
	}
	valt(long long a, long long b){
		p0 = a; p1 = b;
		sum1 = p1;
		mdiff = p1 - p0;
	}
	valt operator + (valt other){
		valt ans;
		ans.sum1 = sum1 + other.sum1;
		ans.mdiff = max(mdiff, other.mdiff);
		return ans;
	}
};
struct tree{
	multiset<long long> values;
	long long sum1;
	void add(valt a){
		sum1 += a.sum1;
		values.insert(a.mdiff);
	}
	void rem(valt a){
		sum1 -= a.sum1;
		values.erase(values.find(a.mdiff));
	}
	valt getFull(){
		valt ans;
		ans.sum1 = sum1;
		if(!values.empty()) ans.mdiff = *(--values.end());
		return ans;
	}
};
const int maxn = 100100;
vector<int> tr[maxn];
tree mtree[maxn];
char s[maxn];
int ty[maxn], ms[maxn];
long long d[2][maxn];
void add(int cur, int vert, valt val){
	int pos = lower_bound(tr[cur].begin(), tr[cur].end(), vert) - tr[cur].begin();
	mtree[cur].add(val);
}
void rem(int cur, int vert, valt val){
	int pos = lower_bound(tr[cur].begin(), tr[cur].end(), vert) - tr[cur].begin();
	mtree[cur].rem(val);
}
void calc(int cur, int par, int sons){
	int ru = par != -1;
	int letdown = max(sons - 1, 0);
	valt incur = mtree[cur].getFull();
	d[0][cur] = sons + letdown + incur.sum1 - incur.mdiff + ((ty[cur] + letdown + ru)%2);
	d[1][cur] = 2 * sons + incur.sum1 + ((ty[cur] + sons + ru)%2);
}
void solve(int cur, int par){
	int sons = 0;
	for(int nxt : tr[cur]){
		if(nxt == par) {
			continue;
		}
		solve(nxt, cur);
		valt pnxt = valt(d[0][nxt], d[1][nxt]);
		add(cur, nxt, pnxt);
		sons++;
	}
	ms[cur] = sons;
	calc(cur, par, sons);
}
void fix(int cur, int par){
	if(par != -1){
		valt before = valt(d[0][cur], d[1][cur]);

		rem(par, cur, before);
		calc(par, cur, tr[par].size() - 1);

		add(cur, par, valt(d[0][par], d[1][par]));
		calc(cur, -1, tr[cur].size());

		add(par, cur, before);

		calc(par, -1, tr[par].size());
	}
	for(int nxt : tr[cur]){
		if(nxt == par) continue;
		fix(nxt, cur);
	}
}
int deg[maxn];
set<int> pk[maxn], stl;
int main(){
	int n;
	scanf("%d", &n);
	for(int e = 0; e < n - 1; e++){
		int x, y; scanf("%d %d", &x, &y); x--; y--;
		pk[x].insert(y);
		pk[y].insert(x);
		deg[x]++; deg[y]++;
	}
	scanf("%s", s);
	for(int e = 0; e < n; e++) ty[e] = s[e] == 'W';
	queue<int> q;
	for(int e = 0; e < n; e++) stl.insert(e);
	for(int e = 0; e < n; e++) if(deg[e] == 1 && ty[e] == 0) q.push(e);
	while(!q.empty()){
		int u = q.front(); q.pop();
		stl.erase(u);
		for(int v : pk[u]){
			deg[v]--;
			pk[v].erase(u);
			if(deg[v] == 1 && ty[v] == 0) q.push(v);
		}
		pk[u].clear();
	}
	if(stl.empty()){
		cout << 0 << endl;
		return 0;
	}
	int rt = *(stl.begin());
	for(int v : stl){
		for(int u : pk[v]){
			tr[v].push_back(u);
		}
	}
	solve(rt, -1);
	// cerr << "before" << endl;
	// for(int e = 0; e < n; e++) cerr << d[0][e] << " " << d[1][e] << endl;
	fix(rt, -1);
	// cerr << "after" << endl;
	// for(int e = 0; e < n; e++) cerr << d[0][e] << " " << d[1][e] << endl;
	long long ans = 1ll<<60;
	for(int v : stl) ans = min(ans, d[0][v]);
	cout << ans << endl;
    return 0;
}


Measured memory_bytes: 53248
#include <stdio.h>
 
int main(){
  int N,a,b,c;
  scanf("%d",&N);
  a=N/100;
  N=N-100*a;
  b=N/10;
  c=N-10*b;
  if(a!=7&&b!=7&&c!=7){
    printf("No");
  }else{
    printf("Yes");
  }
  return 0;
}
    
  


Measured memory_bytes: 1736
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=105,p=1000000007;
int read(){
	int f=1,g=0;
	char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-1;
	for (;isdigit(ch);ch=getchar()) g=g*10+ch-'0';
	return f*g;
}
int T,k;
ll n,m,f[N],ans;
struct num{
	ll x,y;
	num(ll _x=0,ll _y=0){x=_x;y=_y;}
}a[N][N];
int main(){
//	freopen("a.txt","r",stdin);
//	freopen("a.out","w",stdout);
	f[0]=f[1]=1;
	for (int i=2;i<=90;i++) f[i]=f[i-1]+f[i-2];
	a[0][1]=num(1,1);
	for (int i=1;i<90;i++){
		for (int j=1;j<=i;j++)
		a[i][j]=num(a[i-1][j].x+a[i-1][j].y,a[i-1][j].x);
		a[i][i+1]=num(a[i-1][1].x*2+a[i-1][1].y,a[i-1][1].x);
	}
	T=read();
	while (T--){
		scanf("%lld %lld",&n,&m);
		if (n>m) swap(n,m);
		if (n==1){printf("1 %lld\n",m%p);continue;}
		else if (m==2) {puts("1 4");continue;}
		ans=0;
		for (k=1;(f[k+1]<=n)&&(f[k+2]<=m);k++);
		for (int i=1;i<=k;i++){
			ll x=a[k-1][i].x,y=a[k-1][i].y;
			if ((x<=n)&&(y<=m)) ans=(ans+(m-y)/x)%p;
			if ((x<=m)&&(y<=n)) ans=(ans+(n-y)/x)%p;
		}
		printf("%d %lld\n",k,ans);
	}
	return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

int cnt, A[500010];

void merge(int left, int right) {
  sort(A + left, A + right);
  cnt += right - left;
}

void mergeSort(int left, int right) {
  if (left + 1 < right) {
    int mid = (left + right) / 2;
    mergeSort(left, mid);
    mergeSort(mid, right);
    merge(left, right);
  }
}

int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N;
  cin >> N;
  REP(i, N) cin >> A[i];
  mergeSort(0, N);
  REP(i, N) {
    cout << A[i] << (i == N-1 ? '\n' : ' ');
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 3168
#include<iostream>
#include<stack>
#include<iomanip>
#include<algorithm>
#include<string>
#include<string.h>
#include<cmath>
#include<set>
#include<vector>
#include<queue>
#include<map>
#include<time.h>
using namespace std;
// using ll = long long;
const int INF = 2e9 + 10;
// using pii = pair<int, int>;
// using vi = vector<int>;
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define mp make_pair 
#define pb push_back
#define clr(x, v) memset(x, v, sizeof (x))
#define all(x) x.begin(), x.end()
#define fi first
#define se second
const int N = 1e6 + 10;
int n, m, x;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    while (cin >> n >> x) {
        vector<int> a(n);
        for (int i = 0; i < n; i++) cin >> a[i];
        sort(a.begin(), a.end());
        vector<int> b(n);
        for (int i = 0; i < n; i++) {
            b[i] = min(x, a[i]);
            x -= b[i];
        }
        b.back() += x;
        int res = 0;
        for (int i = 0; i < n; i++) {
            res += (a[i] == b[i]);
        }
        cout << res << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
using P = pair<int,int>;
static const int INF = 10000000;
using ll = long long;

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	if(a == b) cout << c << endl;
	if(b == c) cout << a << endl;
	if(a == c) cout << b << endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int n,m,a,b,ans=0;
  cin>>n>>m;
  vector<bool>z(n,true);
  vector<int>h(n);
  for(auto& i:h){
    cin>>i;
  }
  for(int i=0;i<m;i++){
    cin>>a>>b;
    if(h[a-1]==h[b-1]){
      z[a-1]=false;
      z[b-1]=false;
    }else if(h[a-1]<h[b-1]){
      z[a-1]=false;
    }else{
      z[b-1]=false;
    }
  }
  for(auto i:z){
    if(i){
      ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3784
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(){
  char s[100001];
  int n,k;
  scanf("%s",s);
  n=strlen(s);
  k=n;
  for(int i=0;i<n-1;i++)
    if(s[i]!=s[i+1])
      k=min(k,max(i+1,n-i-1));
  printf("%d\n",k);
}

Measured memory_bytes: 384
distance :: [Double] -> Double
distance (x1 : y1 : x2 : y2 : _) = sqrt $ (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)

judge :: [Double] -> String
judge [xa, ya, ra, xb, yb, rb]
    | d > (ra + rb)                      = "0"
    | abs (ra - rb) <= d && d <= (ra + rb) = "1"
    | d < abs(ra - rb)                   = if ra > rb then "2" else "-2"
    where
        d = distance [xa, ya, xb, yb]

main :: IO ()
main = do
    _ <- getLine
    interact (unlines . map judge . map (map read) . map words . lines)

Measured memory_bytes: 4428
#include <stdio.h>

int main(void) {
	int N,M,r,q,t,n,m,s,ts,te;
    int i,j,ans;

    while(1){
        char time[10000][720]={};
        int PC[1000];
        scanf("%d %d",&N,&M);
        if(N==0&&M==0)break;

        scanf("%d",&r);
        for(i=0;i<r;i++){
            scanf("%d %d %d %d",&t,&n,&m,&s);
            if(s==1){PC[n-1]=t-540;}
            if(s==0){
                for(j=PC[n-1];j<t-540;j++){
                    time[m][j]=1;
                }
            }
        }

        scanf("%d",&q);
        for(i=0;i<q;i++){
            scanf("%d %d %d",&ts,&te,&m);
            ans=0;
            for(j=ts-540;j<te-540;j++){
                ans+=time[m][j];
            }
            printf("%d\n",ans);
        }
    }
    
	return 0;
}

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

int main() {
std::vector<int> vs(3);
for(int i=0; i<3;i++)std::cin >> vs[i];
sort(vs.begin(), vs.end());
vs.erase(unique(vs.begin(), vs.end()), vs.end());
std::cout << vs.size() << std::endl;
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;

int main(){
  int n; cin >> n;
  if(0<n%100 && n%100<=12){
    if(0<n/100 && n/100<=12){
      cout << "AMBIGUOUS" <<endl; return 0;
    } else {
      cout << "YYMM" <<endl; return 0;
    }
  } else {
    if(0<n/100 && n/100<=12){
      cout << "MMYY" <<endl; return 0;
    } else {
      cout << "NA" <<endl; return 0;
    }
  }
}


Measured memory_bytes: 256
import sys
input=sys.stdin.readline
from collections import deque
from heapq import heappush,heappop
import re

def int_raw():
    return int(input())
 
def ss_raw():
    return input().split()
 
def ints_raw():
    return tuple(map(int, ss_raw()))


N = int_raw()
tree = [[] for _ in range(N)]
for _ in range(N-1):
    a,b = ints_raw()
    tree[a-1].append(b-1)
    tree[b-1].append(a-1)

Cs = list(ints_raw())
Cs.sort(reverse=True)
ans_node = [-1]*N
def main():
    max_deg_idx = 0
    max_deg = len(tree[0])
    for idx in range(N):
        if max_deg < len(tree[idx]):
            max_deg = len(tree[idx])
            max_deg_idx = idx
    cur_node_idx = max_deg_idx
    neighbour = []
    ans_node[cur_node_idx] = Cs[0]
    ans = 0
    for c in Cs[1:]:    
        for a in tree[cur_node_idx]:
            if ans_node[a]==-1:
                heappush(neighbour,[-len(tree[a]),a])
        cur_node_idx = heappop(neighbour)[1]
        ans_node[cur_node_idx] = c
        ans += c
    print (ans)
    print (*ans_node,sep=" ")


main()


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

int main(void){
    string S;
    cin >> S;
    
    for(int i = 0; i < 3; i++){
        if(S[i] == '1'){
            S[i] = '9';
        }else{
            S[i] = '1';
        }
    }
    
    cout << S << endl;
}

Measured memory_bytes: 3584
l= input().split(" ")
n = int(l[0])
m = int(l[1])
shops = []
money =0
for i in range(n):
    shop = input().split(" ")
    shop[0]=int(shop[0])
    shop[1]=int(shop[1])
    shops.append(shop)
shops.sort()
for i in range(n):
    if(m>shops[i][1]):
        m = m- shops[i][1]
        money = money + shops[i][1]*shops[i][0]
    else:
        money = money + m*shops[i][0]
        break
print(money)

Measured memory_bytes: 27856
from collections import deque
n, m = map(int, input().split())
node = [list(map(int, input().split())) for _ in range(m)]
graph = [[] for _ in range(n+1)]
for i in range(m):
    a, b = node[i]
    graph[a].append(b)
    graph[b].append(a)

ans = 0
for i in range(m):
    x, y = node[i]
    q = deque([1])
    visited = [0] * (n+1)
    while q:
        now = q.popleft()
        visited[now] = 1
        for g in graph[now]:
            if now == x and g == y:
                continue
            if now == y and g == x:
                continue
            if visited[g]:
                continue
            else:
                q.append(g)
    if sum(visited) == n:
        pass
    else:
        ans += 1
print(ans)

Measured memory_bytes: 3316
//082B
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)

using namespace std;
int main(void){
   string s,t,td;
   cin >> s >> t;
   sort(s.begin(), s.end()); //文字列ソート
   
   sort(t.begin(), t.end());
   for(int i=t.size()-1; i>=0; i--){
       td+=t[i];
   }
   if(s<td){ //辞書順比較
       cout << "Yes" << endl;
   }else{
       cout << "No" << endl;
   }
}

Measured memory_bytes: 256
//Twitter@KonoLv1 2020年春からエンジニア見習いデビュー！
 
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
 
int main(void){
    int i,j;            //  ループ文に使用
    int x,y,z; 
    int count1,count2,count;   //  カウント用に使用
    int flg,mode;
    i = j = x = y = z = count1 = count2 = count = flg = mode = 0;
    int n;
    double dx,dy;
    int box[1024] = {};
    int box2[1024] = {};
    char s[200001] = {};        //  文字列
    char s2[200001] = {};        //  文字列

 
    //  入力処理
    
    // scanf("%s",s); // 文字列
     scanf("%lf",&dy); // 整数
    // scanf("%lf",dx); // 小数
    
    /*
    for (i = 0; i < n; i++){
        scanf("%d"  
    }
    */
    //  計算処理
    dx = 1;
    dx = dx * dx * 3.14;
    dy = dy * dy * 3.14;
    //  出力処理
 

    printf("%.0f",dy / dx);
}



    /* 資材置き場 */
    /*
    「dx」に入っているDouble型の数値の下1桁（それ以下四捨五入）表示
     printf("%.1f",dx);
    
    
    文字列[s]に入っている文字に「a」が含まれる場合、全て「b」に変更する
    while(1){
        if (s[i] == '\0'){
            break;
        }
        
        if (s[i] == 'a'){
            s[i] = 'b';
        }
        i++;
    }
    
    
    */



Measured memory_bytes: 128
import java.util.Scanner;
class Main{
    public static void main(String[] args) {
        String str = new Scanner(System.in).nextLine();
        String[] strs = str.split(" ");
        int[] strss = new int[3];
        for(int i=0;i<strs.length;i++) {
            strss[i]= Integer.parseInt(strs[i]);
        }
        for (int i = 0; i < strss.length; i++) {
      for(int j=i+1;j<strss.length;j++) {
      if(strss[i]>strss[j]) {
        int temp;
        temp=strss[j];
        strss[j]=strss[i];
        strss[i]=temp;
      }
    }
    }
    for (int i = 0; i < strss.length; i++) {
        if(i==2){
      System.out.println(strss[i]);
        }else{
            System.out.print(strss[i]+" ");
        }
    }
      }
  }



Measured memory_bytes: 26100
n, m, x = map(int, input().split())
C = []
A = []
for i in range(n):
    temp = list(map(int, input().split()))
    c = temp[0]
    a = temp[1:]
    A.append(a)
    C.append(c)

ans = 10**18
for i in range(2**n):
    s = [0]*m
    temp = 0
    for j in range(n):
        if (i >> j) & 1:
            temp += C[j]
            for k in range(m):
                s[k] += A[j][k]
    flag = True
    for l in range(m):
        if s[l] < x:
            flag = False
    if flag:
        ans = min(ans, temp)
if ans == 10**18:
    print(-1)
else:
    print(ans)


Measured memory_bytes: 73824
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 *
 * @author k15115kk
 */
public class Main {

    
    /**
     * @param args the command line arguments
     * @throws java.io.IOException
     */
    public static void main(String[] args) throws IOException {
        // TODO code application logic here
        InputStreamReader is = new InputStreamReader(System.in);       //?????????
        BufferedReader br = new BufferedReader(is);
        String str = br.readLine();
        int x = Integer.parseInt(str);
        if(1 <= x && 100 >= x){
            System.out.println(x * x * x);
        }else{
            System.out.println("??°????????????????????????????¶???????????????????");
        }
        
    }
    
}

Measured memory_bytes: 24092
const main = (input: string) => {
  const lines = input.trim().split("\n")
  const [T, A] = lines[1].split(" ").map(str => parseInt(str));
  const H = lines[2].split(" ").map(str => parseInt(str))
  let points:number[] = [];
  const index = 0.006

  H.forEach(h => {
    points.push(Math.abs(A - (T - h * index)))
  })
  console.log(points.indexOf(Math.min(...points)) + 1);
}

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


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


int main(){
  int n,i;
  cin >> n;
  map<int,int> mp;
  int ma=-101;
  int mi=101;
  for(i=0;i<n;++i){
    int a;
    cin >> a;
    ma=max(ma,a);
    mi=min(mi,a);
    mp[a]++;
  }
  int ans=1000000000;
  for(i=mi;i<=ma;++i){
    int cal=0;
    for(auto p : mp){
      cal+=(p.first-i)*(p.first-i)*p.second;
    }
    ans=min(ans,cal);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
;;
int main() { /* ここに書く */
  
  int A,X;
  cin >> A >> X;
  
  if(A*500 >= X){
    cout << "Yes" <<endl;
  }
  else{
    cout << "No" <<endl;
  }
}

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

#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FILL0(x) memset(x,0,sizeof(x))

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
 
 
 const ll MOD = ll(1e9)+7;
 const int MAX = 510000;
 ll fac[MAX], finv[MAX], inv[MAX];
 
 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;
     }
 }
 
 ll com(int n, int r)
 {
     if(n<r)
         return 0;
     if(n<0 || r<0)
         return 0;
     
     return fac[n]*(finv[r]*finv[n-r]%MOD)%MOD;
 }
 

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

    comInit();

    int N;
    cin >> N;

    int comb[10][10];   
    FILL0(comb);
    rep(i, 10)
    {
        comb[0][i]=0;
    }

    rep(i, N)
    {
        string istr = to_string(i+1);
        comb[istr[0]- '0'][istr[istr.size()-1]-'0']++;
    }
    int ans=0;
    rep(i, 10)
    {
        rep(j, 10)
        {
            ans += comb[i][j]*comb[j][i];
        }
    }

    cout << ans << endl;
    


 

 

    return 0;
}
 

//cout << setprecision(13);
//next_permutation();
//__gcd();
//reverse();
//set ,tuple ,pair;
//bitset
//vector.find



Measured memory_bytes: 12160
#include <iostream>
#include <cmath>
#include <vector>

using namespace std;

bool is_prime(int num) {
	if (num == 2) {
		return true;
	}
	if (num%2 == 0) {
		return false;
	}
	for (int i = 3; i <= sqrt(num); i+=2) {
		if (num%i == 0) {
			return false;
		}
	}
	return true;
}

int main(void) {
	int n,num;
	cin >> n;
	int res = 0;
	for (int i = 0; i < n; ++i) {
		cin >> num;
		if (is_prime(num)) {
			++res;
		}
	}
	cout << res << endl;
	return 0;
}



Measured memory_bytes: 3100
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int rdn()
{
  int ret=0;bool fx=1;char ch=getchar();
  while(ch>'9'||ch<'0'){if(ch=='-')fx=0;ch=getchar();}
  while(ch>='0'&&ch<='9')ret=ret*10+ch-'0',ch=getchar();
  return fx?ret:-ret;
}
const int N=2e5+5;
int n,hd[N],xnt,to[N<<1],nxt[N<<1],mx,rt;
void add(int x,int y){to[++xnt]=y;nxt[xnt]=hd[x];hd[x]=xnt;}
void dfs(int cr,int fa,int lj)
{
  if(lj>mx)mx=lj,rt=cr;
  for(int i=hd[cr],v;i;i=nxt[i])
    if((v=to[i])!=fa)dfs(v,cr,lj+1);
}
int main()
{
  n=rdn();
  for(int i=1,u,v;i<n;i++)
    u=rdn(),v=rdn(),add(u,v),add(v,u);
  mx=-1; dfs(1,0,1);
  mx=-1; dfs(rt,0,1);
  puts(mx%3==2?"Second":"First");
  return 0;
}


Measured memory_bytes: 13440
n=int(input())
d={}
for i in range(n):
  j=input()
  if j not in d:
    d[j]=1
  else:
    d[j]+=1
  
n=d[max(d, key=d.get)]

l=[k for k, v in d.items() if v==n]
print(" ".join(sorted(l)))



Measured memory_bytes: 109656
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int x, a, b;
    cin >> x >> a >> b;
    if (abs(x - a) < abs(x - b))
        cout << 'A';
    else
        cout << 'B';
}


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

int main(void)
{
	int n, i, j, c=0;
	
	scanf("%d", &n);
	
	int a[n];
	
	for(i=0; i<n; i++)
	{
		scanf("%d", &a[i]);
	}
	
	for(i=0; i<n; i++)
	{
		
			for(j=2; j<=sqrt(a[i]); j++)
			{
				if(a[i] % j == 0)
				{
					a[i]=0; //割り切れたら0にする
					break;
				}
			}
			
			if(a[i] != 0)
			{
//				printf("%d ", a[i]);
				c++;
			}
	
	}
	
	printf("%d\n", c);
	
	return 0;
	
}


Measured memory_bytes: 2072
use proconio::{fastout, input};

#[fastout]
fn main() {
  input! {
    d: usize,
    c: [usize; 26],
    s: [[i64; 26]; d],
    t: [usize; d],
  }
  
  let mut lc = Vec::with_capacity(26);

  for _ in 0..26 {
    lc.push(0);
  }
  
  let mut sc: i64 = 0;
  
  for i in 0..d {
    sc = sc + s[i][t[i]-1];
    lc[t[i]-1] = i+1;
    for j in 0..26 {
      sc = sc - c[j] as i64 * (i + 1 - lc[j]) as i64;
    }
    println!("{}",sc);
  }
}


Measured memory_bytes: 2296
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N=1e5+5;

int n, totW;
int w[105], v[105];
int cache[105][N];

int dp(int idx, int wt)
{
	if(wt>totW)
		return -1e15;
	if(idx==n+1)
		return 0;
	int &ans=cache[idx][wt];
	if(ans!=-1)
		return ans;
	ans=max(dp(idx+1, wt), v[idx] + dp(idx+1, wt+w[idx]));
	return ans;
}

int32_t main()
{
	IOS;
	memset(cache, -1, sizeof(cache));
	cin>>n>>totW;
	for(int i=1;i<=n;i++)
		cin>>w[i]>>v[i];
	int ans=dp(1, 0);
	cout<<ans;	
	return 0;
}

Measured memory_bytes: 82432