akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
#include <algorithm>
#pragma warning(disable : 4996)
using namespace std;
int H, W, c, a[9][9], b[9][9], g[6][9][9], v[9][9];
int dx[4] = { 1, 0, -1, 0 }, dy[4] = { 0, 1, 0, -1 };
int rec1(int x, int y) {
	int ret = 1; v[y][x] = 1;
	for (int i = 0; i < 4; i++) {
		int tx = x + dx[i], ty = y + dy[i];
		if (0 <= tx && tx < W && 0 <= ty && ty < H && b[y][x] == b[ty][tx] && !v[ty][tx]) ret += rec1(tx, ty);
	}
	return ret;
}
void rec(int x, int y, int e) {
	int w = b[y][x]; b[y][x] = e;
	for (int i = 0; i < 4; i++) {
		int tx = x + dx[i], ty = y + dy[i];
		if (0 <= tx && tx < W && 0 <= ty && ty < H && b[ty][tx] == w) rec(tx, ty, e);
	}
}
void cpy(int d, int m) {
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			switch (m) {
			case 0: g[d][i][j] = b[i][j]; break;
			case 1: b[i][j] = g[d][i][j]; break;
			case 2: v[i][j] = 0; break;
			}
		}
	}
}
int solve(int d) {
	int ret = 0; cpy(d, 0);
	if (b[0][0] != c) rec(0, 0, c);
	cpy(0, 2), ret = rec1(0, 0), cpy(d, 1);
	if (d < 4) {
		for (int i = 1; i <= 6; i++) {
			if (b[0][0] == i) continue;
			cpy(d, 0), rec(0, 0, i);
			ret = max(ret, solve(d + 1)), cpy(d, 1);
		}
	}
	return ret;
}
int main() {
	while (scanf("%d%d%d", &H, &W, &c), H) {
		memset(g, 0, sizeof(g));
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) scanf("%d", &a[i][j]), b[i][j] = a[i][j];
		}
		printf("%d\n", solve(0));
	}
	return 0;
}

Measured memory_bytes: 2612
#フレームの描画

while True:
  x, y = map(int, input().split())
  if x == 0 and y == 0:
      break
  for i in range(x):
    if i == 0 or i==x-1:
      print('#' * y)
    else:
      print('#%s#' %('.'*(y-2)))

  print('')



Measured memory_bytes: 5616
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
//#define ARRAY(type,n) (type *)malloc(sizeof(type)*n)
template<typename T>
T* ARRAY(int n){
	(T*)malloc(sizeof(T)*n);
}
template<typename T>
T** ARRAY2(int m,int n){
	T** type = (T**)malloc(sizeof(T*)*m);
	for(int i=0;i<m;i++){
		type[i]=(T*)malloc(sizeof(T)*n);
	}
	return type;
}
 
int par[100000];
void init(int n){
	rep(i,n){
		par[i]=i;
	}
}
 
int root(int x){
	if(par[x]==x){
		return x;
	}else{
		return par[x] = root(par[x]);
	}
}
 
void unite(int x,int y){
	x=root(x);
	y=root(y);
	if(x==y)return;
	par[x]=y;
}
 
 
 
struct a{
	ll a;
	int num;
	int par;
	bool use;
};
 
bool operator< (const a& left,const a& right){
        return left.a < right.a;
}

/*
rep(i,n){
	cin>>aa[i].a;
	aa[i].num=i;
}*/
 
 
 
int main(void){
	int l;
	ll a[200002];
	cin >> l;
	rep(i,l){
		cin>>a[i];
	}
	//l+1
	ll lmodoru[200002], lmodoran[200002], rmodoru[200002], rmodoran[200002], suml[200002], sumr[200002];
	lmodoru[0] = 0;
	lmodoran[0] = 0;
	lmodoru[1] = a[0]%2;
	lmodoran[1] = 0;
	rmodoru[l-1] = a[l-1]%2;
	rmodoran[l-1] = 0; 
	rmodoru[l] = 0;
	rmodoran[l] = 0;
	suml[0] = 0;
	sumr[l] = 0;
	rep(i,l+1){
		if(i==0){
			continue;
		}
		suml[i] = suml[i-1] + a[i-1];
		if(i==0 || i ==1){
			continue;
		}
		
		lmodoru[i] = min(a[i-1]%2 + (a[i-1]==0?2:0) + lmodoru[i-1], suml[i]);
		lmodoran[i] = min((a[i-1]+1)%2 + min(lmodoru[i-1],lmodoran[i-1]), suml[i]);//sumいる？
	}

	rep(i,l+1){
		if(i==0){
			continue;
		}
		sumr[l-i] = sumr[l-i+1] + a[l-i];
		if(i==0 || i ==1){
			continue;
		}
		
		rmodoru[l-i] = min(a[l-i]%2 + (a[l-i]==0?2:0) + rmodoru[l-i+1], sumr[l-i]);
		rmodoran[l-i] = min((a[l-i]+1)%2 + min(rmodoru[l-i+1],rmodoran[l-i+1]), sumr[l-i]);//sumいる？
	}

	ll ans = 9999999999;
	rep(i,l+1){
		//cout<<lmodoru[i]<<","<<lmodoran[i]<<","<<rmodoru[i]<<","<<rmodoran[i]<<endl;
		ans = min(lmodoru[i]+rmodoru[i],min(lmodoru[i]+rmodoran[i],min(lmodoran[i]+rmodoru[i],min(lmodoran[i]+rmodoran[i],ans))));
	}
	cout<<ans<<endl;
 
	return 0;
}

Measured memory_bytes: 11136
s = [list(map(int, input().split())) for _ in range(3)]
flag = 0
cnt = 0
for i in range(1, 5):
    for j in s:
        if (j[0] == i) or (j[1] == i):
            cnt += 1
    if cnt == 3:
        flag = 1
        break
    else:
        cnt = 0
        continue

if flag == 1:
    print('NO')
else:
    print('YES')


Measured memory_bytes: 3060
#include <stdio.h>

int main()
{
  int n,q;
  int count=0,i,j,L,M,R;
  int S[100000],T[50000];

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

  scanf("%d",&q);
  for(i=0; i<q; i++){
    scanf("%d",&T[i]);
    L = 0;
    R = n;
    while(L < R){
      M = (L + R) / 2;
      if(S[M] < T[i])
        L = M + 1;
      if(S[M] == T[i]){
        count++;
        break;
      }
      if(S[M] > T[i])
        R = M;
    }
  }
  printf("%d\n",count);

  return 0;
}


Measured memory_bytes: 2368
/*double p =log(a);
    p=p-floor(p);
    int x=pow(10,p);    m s di
 int x =floor(log10(a)) + 1;  d co
 a=ceil(log2(n)) == floor(log2(n)); pow of 2*/

#include<bits/stdc++.h>
#include<iostream>
#include<math.h>
#include<string>
using namespace std;
int main()
{
    long long int a,b,c,d,e,i,j,n=0,m=0;
    cin>>a>>b;
    c=max((a+b),max((a-b),(a*b)));
    cout<<c<<endl;
}


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

using namespace std;

int main() {
  std::ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  int c1 = 0, c2 = 0, c3 = 0, ans = 0;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    for (int j = 0; j + 1 < s.size(); j++) {
      if (s[j] == 'A' && s[j + 1] == 'B') ans++;
    }
    if (s[0] == 'B' && s[s.size() - 1] == 'A') c1++;
    if (s[0] == 'B') c2++;
    if (s[s.size() - 1] == 'A') c3++;
  }
  ans += min(c2, c3);
  if (c2 == c3 && c1 == c3 && c1) ans--;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
X,K,D=map(int,input().split())
x=abs(X)
key=x//D
Key=x%D
if key>K:
  print(x-K*D)
  exit()
KEY=Key-D
if (K-key)%2==0:
  ans=abs(Key)
else:
  ans=abs(KEY)
print(ans)

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

typedef long long ll;

using namespace std;

#define swap(a, b)    do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while(0)
#define repd(i, a, b) for(typeof(b) i = a; i < (b); ++i)
#define rep(i, n)     repd(i, 0, n)
#define dump(x)       cerr << #x << " = " << (x) << endl
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define YesNo(x)      cout << ((x) ? "Yes" : "No") << endl
#define YESNO(x)      cout << ((x) ? "YES" : "NO") << endl
#define absi(x)       ( ((x) >= 0) ? (x) : (-(x)) )

class unionfind {
private:
	vector<ll> a;
public:
	unionfind(ll n) { a = vector<ll>(n); rep(i, n) a[i] = i; }
	ll root(ll i) { return (a[i] == i) ? i : ( a[i] = root(a[i]) ); }
	bool same(ll x, ll y) { return root(x) == root(y); }
	bool unite(ll x, ll y) { x = root(x); y = root(y); if(x == y) return false; a[x] = y; return true; }
};

int main(int argc, const char* argv[]) {
	ll n, m;
	cin >> n >> m;
	unionfind uf(n);

	ll ret = n;
	rep(i, m) {
		ll x, y, z;
		cin >> x >> y >> z;
		if(uf.unite(x, y)) --ret;
	}

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ull = long long unsigned;
using P = pair<int,int>;
const int INF=1001001;
const int NMAX=8;



int main()
{
	int n,q;
	cin>>n>>q;
	vector<tuple<int,int,int>> T(n);
	vector<int> X(n);
	set<pair<int,int>> D;
	vector<int> A(q,-1);

	rep(i,n){
		int s,t,x;
		cin>>s>>t>>x;
		T[i]=make_tuple(x,s-x,t-x);
	//	X[i]=;
	}
	sort(begin(T),end(T));
	rep(i,q){
		int temp;
		cin>>temp;
		D.insert(make_pair(temp,i));
	}
	rep(i,n){
		int l1,r1,x1;
		tie(x1,l1,r1)=T[i];

	//
	//	cout<<l<<'l'<<r<<'r'<<endl;
		auto it=D.lower_bound(make_pair(l1,-1));
	//	auto it_r=D.lower_bound(r);
		//cout<<idx_l<<'l'<<' '<<idx_r<<'r'<<endl;
//		int idx_l=it_l-D.begin();
//		int idx_r=it_r-D.begin();
		while (it!=D.end()){
		//	cout<<j<<endl;
		//	if (A[j]==-1 or A[j]>X[i]){
			//	cout<<X[j]<<'x'<<j<<'j'<<endl;

			if (it->first>=r1)break;
			A[it->second]=x1;

			D.erase(it++);
		
	//	}

	}

}

rep(i,q){
	cout<<A[i]<<endl;
}


}


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

int main() {
  vector<long int> a;
  long int b;
  for(int i = 0; i < 3; i++) {
    cin >> b;
    a.push_back(b);
  }
  if(a[0] % 2 == 0 || a[1] % 2 == 0 || a[2] % 2 == 0) {
    cout << 0 << endl;
    return 0;
  }
  sort(a.begin(), a.end());
  cout << a[0] * a[1] << endl;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> pi;
typedef pair<int,int> vi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(vi c, vi d){
	return c.S < d.S;
}

int main() {
	int N;
	cin >> N;
	int p[2][N];
	REP(i, 0, N) cin >> p[0][i] >> p[1][i];
	
	float ans = 0;
	int c = 0;
	REP(i, 0, N){
		REP(j, i+1, N){
			ans += sqrt(pow(p[0][i]-p[0][j], 2) + pow(p[1][i]-p[1][j], 2));
			++c;
		}
	}
	cout << setprecision(7)<< (N-1)*ans/c;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin>>N;
  int a[N];
  int alice=0,bob=0;
  
  for(int i=0;i<N;i++){
	cin>>a[i];
  }
  sort(a,a+N,greater<int>());
  
  for(int i=0;i<N;i+=2){
	alice+=a[i];
  }
  for(int i=0;i<N-1;i+=2){
   	 bob+=a[i+1];
  }
  
  cout<<alice-bob<<endl;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll calc(vector<pair<ll,ll>> &vec, int n){
    ll ret=0;
    priority_queue<ll, vector<ll>, greater<ll>> que;
    auto itr = vec.begin();
    For(i,0,n+1){
        while(itr < vec.end() && (*itr).first <= i){
            que.push((*itr).second);
            ret += (*itr).second;
            itr++;
        }
        while(i<que.size()){
            ret -= que.top();
            que.pop();
        }
    }
    return ret;
}
ll solve(){
    int n;
    cin >> n;
    vector<pair<ll, ll>> left,right;
    ll sum = 0;
    For(i,0,n){
        ll k,l,r;
        cin >> k >> l >> r;
        if(l>r){
            sum += r;
            left.push_back({k,l-r});
        }
        else{
            sum += l;
            right.push_back({n-k,r-l});
        }
    }
    sort(ALL(left));
    sort(ALL(right));
    sum += calc(left,n) + calc(right,n);
    return sum;
}
void Main(){
    int t;
    cin >> t;
    vector<ll> ans(t);
    For(i,0,t) ans[i] = solve();
    For(i,0,t){
        cout << ans[i] << endl;
    }
}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}

Measured memory_bytes: 8268
#include <stdio.h>
#include <math.h>
int main ( void ) {
    int a[7]={0},i,j;
    double input;
    scanf("%d",&j);
    for(i=0;i<j;i++){
        scanf("%lf",&input);
        if(input<165){
            a[1]++;
        }else if(input<170){
            a[2]++;
        }else if(input<175){
            a[3]++;
        }else if(input<180){
            a[4]++;
        }else if(input<185){
            a[5]++;
        }else{
            a[6]++;
        }
    }
    for(i=1;i<=6;i++){
        printf("%d:",i);
        for(j=1;j<=a[i];j++){
            printf("*");
        }
        puts("");
    }
    return 0;
}

Measured memory_bytes: 648
#include "bits/stdc++.h"

using namespace std;

void solve()
{
	int as[5], ans = 0, m = 10;
	for (int i = 0; i < 5; i++)
	{
		cin >> as[i];
		ans += (as[i] + 9) / 10 * 10;
		if (as[i] % 10) m = min(m, as[i] % 10);
	}
	if (m != 10) ans -= 10- m;
	cout << ans << endl;
}

int main()
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


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

int main(){
	while(1){
		int n;
		cin>>n;
		if(n==0) break;
		int h[21][21];
		lp(i,21){
			lp(j,21){
				h[i][j]=0;
			}
		}
		lp(i,n){
			int a,b;
			cin>>a>>b;
			h[a][b]=1;
		}
		int m,count=0;
		cin>>m;
		int nowx=10,nowy=10;
		if(h[nowx][nowy]==1){
			count++;
			h[nowx][nowy]=0;
		}
		lp(i,m){
			char a;
			int b;
			cin>>a>>b;
			if(a=='N'){
				lp(j,b){
					nowy++;
					if(h[nowx][nowy]==1){
						h[nowx][nowy]=0;
						count++;
					}
				}
			}
			if(a=='S'){
				lp(j,b){
					nowy--;
					if(h[nowx][nowy]==1){
						h[nowx][nowy]=0;
						count++;
					}
				}
			}			
			if(a=='E'){
				lp(j,b){
					nowx++;
					if(h[nowx][nowy]==1){
						h[nowx][nowy]=0;
						count++;
					}
				}
			}
			if(a=='W'){
				lp(j,b){
					nowx--;
					if(h[nowx][nowy]==1){
						h[nowx][nowy]=0;
						count++;
					}
				}
			}
		}
		if(count==n)
			cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 3008
# coding: utf-8
# Your code here!

X = list(input())
num = len(X)
stack = []

for i in X:
    if i == "S":
        stack.append(i)
    else:
        if stack == [] or stack[-1] == "T":
            stack.append(i)
        else:
            stack.pop()
print(len(stack))


Measured memory_bytes: 6436
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main() {
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    if(k<=a){
        cout<<k<<endl;
    }else if(k>a && k<=(a+b)){
        cout<<a<<endl;
    }else{
        ll temp = a-(k-(a+b));
        cout<<temp<<endl;
    }
	return 0;
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n==0)break;
			int[] c = new int[10];
			while(n--!=0)c[sc.nextInt()]++;
			for(int i=0;i<10;i++){
				if(c[i]==0)System.out.print("-");
				else for(int j=0;j<c[i];j++)System.out.print("*");
				System.out.println();
			}
		}
	}
}

Measured memory_bytes: 52452
#include<iostream>
#include<queue>
using namespace std;
int main(){
  	string s;
  	int cnt=0, n;
  	cin >> n >> s;
  	for(int i=0; i<n-2; i++){
      if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C'){
		cnt += 1;
      }
    }
    cout << cnt << endl;
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
using namespace std;
#define sz(x) ((int)(x).size())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MEMSET(v, h) memset((v), h, sizeof(v))
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; }
#define pb push_back
#define mp make_pair
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const ll INF = 1LL<<58;
 
int main() {
	ll n;
	cin >> n;
	ll ans = 0;
	vector <ll> A(n);
	vector <ll> B(n);
	rep(i, n) {
		cin >> A[i];
		cin >> B[i];
	}
	for(ll i = n - 1; i >= 0; --i) {
      	ll temp = (A[i] + ans) % B[i];
        ans += temp == 0 ? 0 : B[i] - temp;
		A[i] += ans;
      
	}
	cout << ans << endl;
}

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

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

	int n, ans=0;
	string A, B, C;
	cin>>n>>A>>B>>C;
	for(int i=0; i<n; i++){
		vector<char> S;
		S.push_back(A[i]);
		S.push_back(B[i]);
		S.push_back(C[i]);
		sort(S.begin(), S.end());
		if(S[0]==S[2]) continue;
		if(S[0]==S[1] || S[1]==S[2]) ans++;
		else ans+=2;
	}

	cout<<ans<<'\n';

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define int long long
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
 
using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;
 
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
 
template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}
 
template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}
 
signed main(){
	int N;
	cin>>N;
	vint A(N);
	rep(i,N)cin>>A[i];
 
	int neg=0;
	rep(i,N){
		if(A[i]<0)neg++;
		A[i]=abs(A[i]);
	}
 
	int al=accumulate(all(A),0ll);
	if(neg&1){
		al-=*min_element(all(A))*2;
	}
	cout<<al<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const int INF = 1001001001;
const ll LINF = 1001001001001001001;

int main(){
    ll n ; cin >> n;
    vector<bool> a(55556,1);
    a.at(0)==0;
    a.at(1)==0;
    for(int i=2;i*i<=55555;i++){
        if(!a.at(i)) continue;
        ll x = a.at(i);
        for(int j=i+i;j<=55555;j+=i){
            a.at(j)=0;
        }
    }
    for(int i=2;i<=55555;i++){
        if(a.at(i) && i%5 == 1){
            if(n==1){
                cout << i <<endl;
                return 0;
            }
            cout << i << " ";
            n--;
        }
    }
    return 0;
}


Measured memory_bytes: 256
import sys


def next_str() -> str:
    result = ""
    while True:
        tmp = sys.stdin.read(1)
        if tmp.strip() != "":
            result += tmp
        elif tmp != '\r':
            break
    return result


def next_int() -> int:
    return int(next_str())


def gcd(x: int, y: int) -> int:
    while y != 0:
        x = x % y
        x, y = y, x
    return abs(x)


def main() -> None:
    n, k = [next_int() for _ in range(2)]
    g, m = [0 for _ in range(2)]

    for i in range(n):
        a = next_int()
        if i == 0:
            g = a
            m = a
        g = gcd(g, a)
        m = max(m, a)

    if k % g == 0 and k <= m:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")


if __name__ == '__main__':
    main()

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <map>
#include <queue>
#include <cmath>
#include <iomanip>
#include <set>
#include <functional>

#define MOD (1000000007)

using namespace std;

typedef long long ll;
typedef pair<ll, ll> tup;
const int MAX = 3000000;

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


ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

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

map<ll,ll> prime;//素因数分解でそれぞれの素数がいくつ出てきたかを保存するmap

//O(√n)
//整列済み(mapはkeyで自動で整列される)
void prime_factorize(ll n){
    if(n<=1) return;
    ll l=sqrt(n);
   for(ll i=2;i<=(ll)(l);i++) { //
        if(n%i==0){
            prime_factorize(i);prime_factorize(ll(n/i));return;
        }
    }
    //mapでは存在しないkeyの場合も自動で構築される
    prime[n]++;return;
}


int main() {

    string S, T;
    cin >> S;
    cin >> T;

    int ret = 0;
    for(int i = 0; i < S.size() ; i++) {
        if(S[i] != T[i]) ret++;
    }

    cout << ret << endl;

    return 0;    
}



Measured memory_bytes: 3808
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using P = pair<int,int>;
using vl = vector<ll>; using vvl = vector<vl>;
#define mp make_pair
#define pb push_back
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,n) for (int i=(n-1);i >= 0;i--)
#define all(v) v.begin(),v.end()
#define sz(v) (int)((v).size())
#define MAX(v) *max_element(all(v))
#define MIN(v) *min_element(all(v))
#define Sort(v) sort(all(v))
#define Rev(v) reverse(all(v))
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);in(name)
#define vv(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define VV(type,name,h,w) vector<vector<type>>name(h,vector<type>(w));in(name)
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cout << H << " ";
    debug_out(T...);
}
#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
    for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
    return os;
}
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
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 INF = 1LL << 60;
const ll mod = 1000000007;
const int dx[8] = {1,0,-1,0,1,1,-1,-1}; const int dy[8] = {0,1,0,-1,1,1,-1,-1};

void cul(int n,vector<int> &div){
    for(int i = 1;i*i<=n;i++){
        if(n%i==0){
            div.pb(i);
            if(n/i!=i) div.pb(n/i);
        }
    }
}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    int n;cin >> n;
    vec(int,a,n);
    rep(i,n) cin >> a[i];
    Sort(a);
    set<int> st;
    int cnt = 0;
    vector<int> div;
    if(n==1){
        cout << 1 << endl;
        return 0;
    }
    rep(i,n){
        if(i!=n-1&&a[i]==a[i+1]){
            st.insert(a[i]);
            continue;
        }
        div.clear();
        cul(a[i],div);
        bool f = true;
        for(auto v : div){
            // cout << v << endl;
            if(st.count(v)==1) f=false;
        }
        if(f) cnt++;
        st.insert(a[i]);
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 13400
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;

void main(){

    int n;
    readf("%d\n",&n);
    for(int i=0;i<n;i++){
	string s1,s2,res;
	s1 = chomp(readln());
	s2 = chomp(readln());
//	readf("%s\n",&s1);
	//readf("%s\n",&s2);
	res = "";
	int x = to!int(s1.length-1);
	int y = to!int(s2.length-1);
	if( y > x) {
	    swap(s1,s2);
	    swap(x,y);
	}
	int add = 0;
	while(x >= 0 || add > 0){
	    int sum = 0;
	    if(y >= 0)
		sum = to!int(s1[x] - '0') + to!int(s2[y] - '0');
	    else if(x >= 0)
		sum = to!int(s1[x] - '0');
	    else 
		sum = 0;
	    if( sum + add > 9){
		    res = to!string((sum + add)%10) ~ res;
		    add = 1;
	    }else{
		res = to!string(sum + add) ~ res;
		add = 0;
	    }
	    if(x >= 0) x--;
	    if(y >= 0) y--;
	}
	if(res.length > 80) writef("overflow\n");//writeln("overflow");
	else writef("%s\n",res);//writeln(res);
    }
}

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

int main(){
	int N;
	cin >> N;
	int A[N];
	int max = 0, min = 1000000000;;
	
	for(int i=0; i<N; i++){
		cin >> A[N];
		if(A[N] <= min) min = A[N];
		if(A[N] >= max) max = A[N];
	}
	
	cout << max - min << endl;
}


Measured memory_bytes: 384
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

const ll INF = 1LL << 50;

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

  vll xs(n);
  rep(i, n) { cin >> xs[i]; }

  ll ans = LONG_LONG_MAX;
  rep(j, 101) {
    ll sum = 0;
    rep(i, n) { sum += (j - xs[i])*(j - xs[i]); }
    chmin(ans, sum);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main() {
	n, k := SingleInt(), SingleInt()

	// まず左端のボールに塗る色を決めます。これは K 通りあります。さらに左から順番に塗る色を決めていき
	// ます。この時、これまでどのように塗っていようが、”ひとつ左のボールに塗られている色”以外の K − 1 通
	// りの色が塗れるので、全体では K · (K − 1)^N−1 通りになります

	// 一番左の選び方K通り、その隣の選び方は、K-1通り。またその隣の塗り方はK-1通り
	// K * (K-1) * (K-1) ... (K-1)は(N-1)個現れる
	// (K-1)*(N-1)　ではないのは、順列であるため

	fmt.Println(k * int(math.Pow(float64(k-1), float64(n-1))))
}

func SingleInt() int {
	var n int
	fmt.Scan(&n)
	return n
}


Measured memory_bytes: 512
import sys
sys.setrecursionlimit(10**8)

N = int(input())

ss = set()
n = 6
while n <= 10**5:
    ss.add(n)
    n *= 6
n = 9
while n <= 10**5:
    ss.add(n)
    n *= 9

dp = [None] * (N+1)

def rec(n):
    if dp[n] is not None:
        return dp[n]
    tmp = n
    for s in ss:
        if s > n: continue
        if s == n:
            tmp = 1
            break
        tmp = min(tmp, 1 + rec(n-s))
    dp[n] = tmp
    return tmp

print(rec(N))

Measured memory_bytes: 9800
#include <iostream>
#include <map>
#include <string.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX_A 100000
using namespace std;

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

  int A[MAX_A+2];
  memset(A, 0, sizeof(int) * (MAX_A+2));
  rep(i, N) {
    int a;
    cin >> a;
    A[a+1]++;
  }

  int MAX_SUM = 0;
  for (int i = 1; i < MAX_A; i++) {
    int SUM = A[i - 1] + A[i] + A[i + 1];
    MAX_SUM = max(MAX_SUM, SUM);
  }
  cout << MAX_SUM << endl;
  return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<math.h>
#include<bitset>
#include <numeric>
using namespace std;
using ll=long long;
using ld=long double;
using pint=pair<int,int>;
using pll=pair<ll,ll>;
#define LONG_INF 9223372036854775807
#define INF 1000000000LL
#define EPS 1e-10
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define dump(a) rep(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define all(v) v.begin(),v.end()
#define pb push_back


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

    int A, B, C , D;
    cin >> A >> B >> C >> D;

    int i=0;
    string ret;
    while(true){
        if(i%2==0) C -= B;
        else A -= D;
        if(A<=0){
            ret="No";
            break;
        }else if(C <= 0){
            ret = "Yes";
            break;
        }
        i++;
    } 
    cout << ret << endl;

    return 0;
}

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

int main( int argc, char *argv[] )
{
int A;
int B;

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

	cin >> A;
	cin >> B;
	cout << ( A + B ) % 24 << endl;

	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int N, A[100010], C[100010], S[100010], bit[200010]; 
void add(int a, int b){
	int x = a; 
	while(x <= N*2+1){
		bit[x] += b; x += x & -x; 
	}
}
int sum(int a){
	int res = 0; 
	int x = a; 
	while(x > 0){
		res += bit[x]; x -= x & -x;
	}
	return res; 
}
bool solve(int M){
	long long int cor = 0; 
	fill(bit, bit+2*N+2, 0); // -N～Nがそれぞれbit[1]～bit[2N+1]に対応
	add(N+1, 1); 
	for(int i = 1; i <= N; i++){
		if(A[i] >= M) C[i] = 1; 
		else C[i] = -1; 
		S[i] = S[i-1] + C[i]; 
		cor += (long long) sum(S[i] + N + 1); 
		add(S[i] + N + 1, 1);
	}
	return (cor * 2 >= (long long) N * (N+1) / 2); 
}
int main(){
	cin >> N; 
	for(int i = 1; i <= N; i++){
		cin >> A[i]; 
	}
	int ng = 1e9+7; int ok = 0; 
	while(ng - ok > 1){
		int mid = (ok + ng) / 2; 
		if(solve(mid)) ok = mid; 
		else ng = mid; 
	}
	cout << ok << endl; 
}

Measured memory_bytes: 2176
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

s = input().strip()

def cond():
    p1 = ((len(s) - 1)//2)
    p2 = (len(s) + 3)//2 - 1
    t1 = s[:p1]
    t2 = s[p2:]
    return s == ''.join(reversed(s)) and t1 == ''.join(reversed(t1)) and t2 == ''.join(reversed(t2))

if cond():
    print('Yes')
else:
    print('No')


Measured memory_bytes: 38384
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
	int A, B; cin >> A >> B;
	if (A > B  && B != 1 || (A != B && A == 1))cout << "Alice" << endl;
	else if (B > A && A != 1|| (A != B && B == 1))cout << "Bob" << endl;
	else cout << "Draw" << endl;
}


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

using namespace std;

string s;

int main(){
	cin >> s;
	int n = s.size();
	if (s[0] != 'A')
		return cout << "WA\n", 0;
	for (int i = 1; i < n; ++i)
		if (s[i] == 'A')
			return cout << "WA\n", 0;
	int cnt = 0;
	for (int i = 2; i + 1 < n; ++i)
		if (s[i] == 'C')
			cnt++;
	if (cnt != 1 || s[0] == 'C' || s[1] == 'C' || s[n - 1] == 'C')
		return cout << "WA\n", 0;
	for (int i = 1; i < n; ++i)
		if (s[i] <= 90 && s[i] != 'C')
			return cout << "WA\n", 0;
	cout << "AC\n";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <set>
#include <stdio.h>
#include <cmath>
#include <ctime>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <tuple>
using namespace std;

int main(){
	int N; cin >> N;
	vector<long long> a(N);
	int count = 0;
	for (int i = 0; i < N; i++) cin >> a.at(i);
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			for (int k = 0; k < N; k++) {
				if(i < j && j < k){
				if (a.at(i) != a.at(j) && a.at(i) != a.at(k) && a.at(j) != a.at(k)) {
					if (a.at(i) + a.at(j) > a.at(k) && a.at(k) + a.at(j) > a.at(i) && a.at(i) + a.at(k) > a.at(j))
						count++;
					}
				}
			}
		}
	}

	cout << count << endl;
}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <utility>
#include <map>
#include <algorithm>
using namespace std;

bool compare_by_b(pair<string, int> a, pair<string, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second > b.second;
    }
}

int main(void){
   
    int n;
    
    cin>>n;
    vector<pair<string, int>> p(n), q(n);
    
    string ts;
    int temp;
    
    for(int i=0; i<n; i++){
        cin>>ts>>temp;
        q[i]=p[i]=make_pair(ts,temp);
    }
    
    sort(p.begin(), p.end(), compare_by_b);
    
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            if(q[j]==p[i]){
                cout<<j+1<<endl;
                break;
            }
        }
    }
    
}


Measured memory_bytes: 256
<?php
fscanf(STDIN,"%d",$n);

$sum = 0;
$cul = 0;

for ($i=0; $i < $n; $i++)
{ 
	$temp = fgets(STDIN);
	$poss[$i] = explode(" ", $temp);
}

for ($i=0; $i < $n-1; $i++)//(n-1) no kaijo
{ 
	$keisu = 1;
	$keisu *= $i+1;
}

for ($i=0; $i < 9999; $i++)
{ 
    $j = $i+1;
    do
    {
      $lens[$cul] = sqrt(pow($poss[$i][0]-$poss[$j][0],2) + pow($poss[$i][1]-$poss[$j][1],2));
      if($cul+1 == $n*($n-1)/2)
      {
        break 2;
      }
      $cul++;
      $j++;
    }
    while($j < $n);
}


for ($i=0; $i < $n*($n-1)/2; $i++)
{ 
	$sum += $keisu*$lens[$i];
}
//echo($keisu*$n);
//print_r($lens);
echo($sum/($n*($n-1)/2));

Measured memory_bytes: 3828
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a, b;
	cin >> a >> b;

	string T = to_string(a) + to_string(b);
	int k = stoi(T);

	for (int i = 1; i <= 1000; ++i) {
		if (i * i == k) {
			puts("Yes");
			return 0;
		}
	}

	puts("No");

	return 0;
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy,copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
    n,m=MAP()

    if (n+m) % 2 ==0:
        print(int((n+m)/2))
    else:
        print('IMPOSSIBLE')


if  __name__=='__main__':
    main()

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

const char wall = '#';
vector<vector<char>> fields;
vector<vector<bool>> used;
vector<vector<ll>> dist;
const int dx[4] = {0, -1, 0, 1};
const int dy[4] = {1, 0, -1, 0};

vector<ll> A;
// vectorのリサイズ
// A.resize(N);

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

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

  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  char f = ' ';
  ll ans = 1;
  rep(i, n) {
    if(i == 0) continue;
    if (a[i] > a[i-1]) {
      if (f == '-') {
        ans++;
        f = ' ';
        continue;
      }
      f = '+';
    }
    if (a[i] < a[i-1]) {
      if (f == '+') {
        ans++;
        f = ' ';
        continue;
      }
      f = '-';
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
//raja1999

//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")

#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string> 
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//setbase - cout << setbase (16)a; cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
using namespace __gnu_pbds;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
//#define int ll

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;


//std::ios::sync_with_stdio(false);

int main(){
	std::ios::sync_with_stdio(false); cin.tie(NULL);
	int s,w;
	cin>>s>>w;
	if(w>=s){
		cout<<"unsafe"<<endl;
	}
	else{
		cout<<"safe"<<endl;
	}
	return 0;
} 


Measured memory_bytes: 3652
n, t = map(int, input().split())
ct = [list(map(int, input().split())) for _ in range(n)]

ans = 10 ** 10
for i in range(n):
    cost = ct[i][0]
    time = ct[i][1]
    if time <= t:
        ans = min(ans, cost)

if ans == 10 ** 10:
    ans = 'TLE'

print(ans)


Measured memory_bytes: 3060
// 154 B

#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include<algorithm>

using namespace std;

int main(){
    long long int n, k, sum=0, tmp;
    cin >> n >> k;
    for(int i=k; i<=n+1; i++){
        sum += ((n-i+1)*i+1)%1000000007;
        if(sum > 1000000007) sum %= 1000000007;
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3632
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    N, A, B = MAP()

    if A > B or (A != B and N == 1):
        print(0)
        sys.exit()

    print(B*(N - 2) - A*(N - 2) + 1)


if __name__ == '__main__':
    main()

Measured memory_bytes: 9924
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define pb push_back

typedef long long LL; 
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);	
    int N; cin >> N;
    string S; cin >> S;
    int cntr = 0; 
    int cntb = 0;
    REP(i,S.length())
    {
        if(S[i] == 'R') cntr++;
        else cntb++;
    }
    if(cntr > cntb) cout << "Yes" << endl;
    else cout << "No" << endl;

}


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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
    int N;
    cin >> N;
    vector<int> P(N);
    vector<int> Q(N);
    for (int i = 0; i < N; ++i) cin >> P[i], --P[i]; 
    for (int i = 0; i < N; ++i) cin >> Q[i], --Q[i]; 
    map<vector<int>, int> ord;
    int iter = 0;

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

    do {
        ord[v] = iter++;
    } while (next_permutation(v.begin(), v.end()));
    cout << abs(ord[P] - ord[Q]) << endl;
    return 0;
}

Measured memory_bytes: 5248
//Do what you can't.

import java.io.*;
import java.util.*;
import java.math.BigInteger;
public class Main  {
  public static void main(String[] args) {
    InputReader in = new InputReader(System.in);
    PrintWriter w = new PrintWriter(System.out);
    long x = in.nextLong()  ;
    long ans = x / 11;
    ans += ans;
    if (x%11 > 6)
      ans += 2;
    else if (x % 11 > 0)
      ans ++;

    w.println(ans);
    w.close();
  }
  static class InputReader {

    private final InputStream stream;
    private final byte[] buf = new byte[8192];
    private int curChar, snumChars;
    private SpaceCharFilter filter;

    public InputReader(InputStream stream) {
      this.stream = stream;
    }

    public int snext() {
      if (snumChars == -1)
        throw new InputMismatchException();
      if (curChar >= snumChars) {
        curChar = 0;
        try {
          snumChars = stream.read(buf);
        } catch (IOException e) {
          throw new InputMismatchException();
        }
        if (snumChars <= 0)
          return -1;
      }
      return buf[curChar++];
    }

    public int nextInt() {
      int c = snext();
      while (isSpaceChar(c)) {
        c = snext();
      }
      int sgn = 1;
      if (c == '-') {
        sgn = -1;
        c = snext();
      }
      int res = 0;
      do {
        if (c < '0' || c > '9')
          throw new InputMismatchException();
        res *= 10;
        res += c - '0';
        c = snext();
      } while (!isSpaceChar(c));
      return res * sgn;
    }

    public long nextLong() {
      int c = snext();
      while (isSpaceChar(c)) {
        c = snext();
      }
      int sgn = 1;
      if (c == '-') {
        sgn = -1;
        c = snext();
      }
      long res = 0;
      do {
        if (c < '0' || c > '9')
          throw new InputMismatchException();
        res *= 10;
        res += c - '0';
        c = snext();
      } while (!isSpaceChar(c));
      return res * sgn;
    }

    public int[] nextIntArray(int n) {
      int a[] = new int[n];
      for (int i = 0; i < n; i++) {
        a[i] = nextInt();
      }
      return a;
    }

    public String readString() {
      int c = snext();
      while (isSpaceChar(c)) {
        c = snext();
      }
      StringBuilder res = new StringBuilder();
      do {
        res.appendCodePoint(c);
        c = snext();
      } while (!isSpaceChar(c));
      return res.toString();
    }

    public String nextLine() {
      int c = snext();
      while (isSpaceChar(c))
        c = snext();
      StringBuilder res = new StringBuilder();
      do {
        res.appendCodePoint(c);
        c = snext();
      } while (!isEndOfLine(c));
      return res.toString();
    }

    public boolean isSpaceChar(int c) {
      if (filter != null)
        return filter.isSpaceChar(c);
      return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    private boolean isEndOfLine(int c) {
      return c == '\n' || c == '\r' || c == -1;
    }

    public interface SpaceCharFilter {
      public boolean isSpaceChar(int ch);
    }
  }
}


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

namespace ConsoleApp15
{
    class Class92
    {
        static void Main()
        {
            var N = Console.ReadLine().ToCharArray();
            var S = string.Join("",N).Substring(1);
            if (!S.All(x=>x=='9'))
            {
                N[0] = (int.Parse(N[0].ToString()) - 1).ToString()[0];
                Console.WriteLine(int.Parse(N[0].ToString()) + 9 * S.Length);
            }
            else
            {
                Console.WriteLine(int.Parse(N[0].ToString())+9*S.Length );
            }

        }
    }
}



Measured memory_bytes: 13268
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
ll INF = 1e18;

ll gcd(ll a, ll b) { return a ? gcd(b % a, a) : b; }

int main() {
  //
  ll n, k;
  cin >> n >> k;
  vl a(n);
  ll m = 0;
  rep(i, n) {
    cin >> a[i];
    m = max(m, a[i]);
  }
  ll g = a[0];
  REP(i, 1, n) g = gcd(g, a[i]);
  if (k <= m && k % g == 0) {
    cout << "POSSIBLE" << endl;
  } else {
    cout << "IMPOSSIBLE" << endl;
  }
  return 0;
}


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

int N,A,B;

int func(int x){
    if(x/10 == 0) return x;
    return func(x/10) + x%10;
}

int main()
{
    cin>>N>>A>>B;
    
    int sum = 0;
    for (int i = 1; i <= N; i++)
    {
        if(A<=func(i) && func(i)<=B) sum+=i;
    }
    
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;
int n,k;
int height[100100];
int dp[100100];

int solve(int now){
	if(dp[now]!=-1)return dp[now];
	if(now==n-1)return 0;
	int tmp=999999999;
	for(int i=now+1; i<n; i++){
		if(i-now>k)break;
		else{
			tmp=min(tmp,solve(i)+abs(height[now]-height[i]));
		}
	}
	return dp[now]=tmp;
}

int main(){
	cin >> n >> k;
	for(int i=0; i<n; i++){
		cin >> height[i];
		dp[i] = -1;
	}

	cout << solve(0) << endl;

	return 0;
}


Measured memory_bytes: 5760
#include<iostream>
#include<sstream>
#include<fstream>
#include<cstdio>
#include<vector>
#include<list>
#include<stack>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdlib>
using namespace std;
int u = 0;

void solve(int i,int sum,int n,int s){
	if(sum==s && !n){
		++u;return;
	}
	if(i==10 || !n)return;
	solve(i+1,sum,n,s);
	solve(i+1,sum+i,n-1,s);
}

int main(){
	int n,s;
	while(scanf("%d %d",&n,&s)==2,n||s){
		u = 0;
		solve(0,0,n,s);
		cout<<u<<endl;
	}
	return 0;
}

Measured memory_bytes: 1208
fun main(args: Array<String>) {
    val (N ,K) = readLine()!!.split(" ").map(String::toInt)
    val Aii = (1..K).map {
        val dk = readLine()!!.toInt()
        readLine()!!.split(" ").map(String::toInt)
    }
    val s_map: MutableMap<Int,Int> = mutableMapOf()
    Aii.forEach { _list ->
        _list.forEach { i -> 
            s_map[i] = 1
        }
    }
(N - s_map.keys.size).run(::println)
}

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

using namespace std;

#define rep(i, a) for (int i = 0; i < a; i++)
#define reps(i, a, b) for (int i = a; i < b; i++)
#define MP(a, b) make_pair(a, b)

int main()
{
	int N;
	cin >> N;
	bool f = false;
	while (N--) {
		char c;
		cin >> c;
		f |= c == 'Y';
	}
	if(f) cout << "Four" << endl;
	else cout << "Three" << endl;
	return 0;
}


Measured memory_bytes: 256
function Main(input) {
  const inputs = input.split('\n')
    .filter(v => v);
  const n = parseInt(inputs[0], 10);
  const strs = inputs[1]
    .split('');
  
  console.log(strs.map(function(s) {
    var c = s.charCodeAt() + n;
    if (c > 90) {
      c -= 26;
    }
    return String.fromCharCode(c)
  }).join('') + '\n');
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 9548
#include <bits/stdc++.h>
#include <string.h>
#include <vector>
#include <math.h>
//s#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX 10000

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a; i<n; i++)
#define r0 return 0
#define INF (int)1e15
#define MOD 1000000007

#define access(i) a[i/3][i%3]

 int main(){


 long long k,ans=0;
 cin>>k;

  for(int i=1;i<1000001;i++){
     ans = ans*10+7;
     ans = ans%k;
     if(ans == 0){
        cout<<i<<endl;
        return 0;
     }
  }

  cout<<"-1"<<endl;

 return 0;
 }

Measured memory_bytes: 3604