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

#define all(container) container.begin(), container.end()
#define sortall(container) (sort(container.begin(), container.end()))
#define yn(cond) ((cond) ? (cout << "yes" << endl) : (cout << "no" << endl))
#define Yn(cond) ((cond) ? (cout << "Yes" << endl) : (cout << "No" << endl))
#define YN(cond) ((cond) ? (cout << "YES" << endl) : (cout << "NO" << endl))

typedef long long       ll;

typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<char>    vc;
typedef vector<string>  vs;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<vi>		vvi;
typedef vector<vll>		vvll;
typedef vector<vd>		vvd;
typedef vector<vb>		vvb;
typedef vector<vc>		vvc;
typedef vector<vs>		vvs;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;

typedef struct edge_ {
	ll to;
	ll cost;
} edge;

typedef struct point_ {
	ll x, y;
	point_(ll x = 0, ll y = 0) : x(x), y(y) {}
} point;

template <typename T>
using mat2d = vector<vector<T>>;

constexpr double	PI = 3.14159265358979323846;
constexpr ll		INF = 1 << 15;
constexpr ll		MOD = (ll)1e9 + 7;
constexpr double	EPS = 1e-7;
constexpr int		dy4[4] = { 0, 1, 0, -1 };
constexpr int		dx4[4] = { 1, 0, -1, 0 };
constexpr int		dy8[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };
constexpr int		dx8[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}

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

template<typename S, typename T>
istream& operator >> (istream& is, pair<S, T>& p) {
	is >> p.first >> p.second;
	return is;
}

istream& operator >> (istream& is, point& p) {
	is >> p.x >> p.y;
	return is;
}

template<typename S, typename T>
ostream& operator << (ostream& os, const pair<S, T>& p) {
	os << "{" << p.first << " : " << p.second << "}";
	return os;
}

template<typename T>
ostream& operator << (ostream& os, const set<T>& s) {
	for (const T& x : s) os << x << " ";
	return os;
}

ostream& operator << (ostream& os, const edge e) {
	os << "{to: " << e.to << ", cost: " << e.cost << "}";
	return os;
}

ostream& operator << (ostream& os, const point& p) {
	os << "(" << p.x << " " << p.y << ")";
	return os;
}

/******************************************************************************/
/**********************         Don't make WA !!         **********************/
/******************************************************************************/

int main()
{
	int H, W;
	cin >> H >> W;
	vvc a(H, vc(W));
	cin >> a;

	for (int h = 0; h < H + 2; h++) {
		for (int w = 0; w < W + 2; w++) {
			if (h == 0 || h == H + 1) cout << "#";
			else if (w == 0 || w == W + 1) cout << "#";
			else cout << a[h - 1][w - 1];
		}
		cout << endl;
	}
	
	return 0;
}

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


#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()

#define int long long

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second

#define mod 1000000007

template <typename T>
void print(T x)
{
	std::cout << x <<" " ;
}


template <typename T>
void println(T x)
{
	std::cout << x << "\n";
}

signed main(void) {
	int n;
	cin >> n;
	vector<int>p(n), q(n);

	rep(i, n) {
		cin >> p[i];
	}
	rep(i, n) {
		cin >> q[i];
	}
	vector<int>a(n);
	rep(i, n) {
		a[i]=i+1;
	}
	map<vector<int>, int>mp;
	do {
		mp[a] = mp.size();
	} while (next_permutation(a.begin(), a.end()));

	int ans = abs(mp[p] - mp[q]);
	print(ans);
	return 0;
}

Measured memory_bytes: 6528
"""
int #整数
float #小数

#for
for name in fruits: #fruitの頭から操作
    print(name)
    
#リスト
list0 = [] #リスト生成
list0 = [1,2,3,4] #初期化
list0 = [0]*10 #[0,0,0,0,0,0,0,0,0,0]
list1= [i for i in range(10)] #>>> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
list1 = list(map(int, input().split()))　# 複数の入力をリストに入れる
number=[int(input()) for i in range(int(input()))] #複数行の入力をリストに
list1 = list1 + [6, 7, 8] #リストの追加
list2.append(34) #リストの追加　最後に（）内が足される
list.insert(3,10) #リストの追加　任意の位置（追加したい位置,追加したい値）
len(list4) #リストの要素数
max(sa) #list saの最小値
list5.count(2) #リスト(文字列も可）内の2の数
list1.sort() #並び替え小さい順
list1.sort(reverse=True)  #並び替え大きい順
set(list1) #list1内の重複している要素を削除し、小さい順に並べる
sum([2,3,   ,3]) #リストの合計

abs(a) #aの絶対値
max(a,b) min(a,b) #最大値　最小値
text1 = text1.replace("34","test") #text1内の"34"を"test"に書き換える(文字列内の文字を入れ替える)

exit(0) #強制終了
"""
N, Y = map(int, input().split())
for i in range(N+1):
    for j in range(N+1):
        k=N-i-j
        if 0<=k and 10000*i+5000*j+1000*k==Y:
            print(i,j,k)
            exit(0)
print(-1,-1,-1)



Measured memory_bytes: 9100
#include <stdio.h>
using namespace std;

int main(void)
{
	int N = 2;
	int l[2];

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

	printf("%d %d\n",l[0]*l[1],2*(l[0]+l[1]));
}


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

int main(){
  int n,m,c,ans=0,count=0;cin>>n>>m>>c;
  vector<int> b(m,0);REP(i,m) cin>>b.at(i);
  vector<vector<int>> a(n,vector<int>(m));
  REP(i,n) REP(j,m) cin>>a.at(i).at(j);
  REP(i,n){
    REP(j,m) ans+=a.at(i).at(j)*b.at(j);
    ans+=c;
    if(ans>0) count++;
    ans=0;
  }    
  cout<<count;
}

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

int main(){
  
  //入力の宣言
  int N, P = 0, W = 0, G = 0, Y = 0;
  cin >> N;
  //この先ループ
  for(int i = 0; i < N; i++){
  string S;
  cin >> S;
  //条件分岐
  if(S == "P"){
    P += 1;
  }
  if(S == "W"){
    W += 1;
  }
  if(S == "G"){
    G += 1;
  }
  if(S == "Y"){
    Y += 1;
  }
 }
  if(P >= 1 && W >= 1 && G >= 1 && Y >= 1){
    cout << "Four" << endl;
  }
  else{
    cout << "Three" << endl;
  }
  return 0;
}

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


#define ll unsigned long long
#define ALL(x) x.begin(),x.end()
#define maxn 2005
#define FASTIO ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;
const int MOD = 1e9+7;

/*
ll power(ll x, ll int y){
    int res = 1; // Initialize result

    while (y > 0) {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res * x + MOD)%MOD;

        // n must be even now
        y = y >> 1; // y = y/2
        x = (x * x)%MOD; // Change x to x^2
    }
    return res;
}
*/

int main(){

    int n;cin >> n;
    vector<int> arr(n);
    ll sum = 0;
    for(int &x:arr) cin >> x,sum += x;
    int q;cin >> q;
    int a,b;
    for(int i=0;i<q;i++){
        cin >>  a >> b;
        cout << sum - arr[a-1] + b << "\n";
    }
    return 0;
}

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

using namespace std;

int main() {
	int N;
	int num_min = (int)(1e9 + 1), num_max = 0;

	cin >> N;

	for (int i = 0; i < N; i++) {
		int tmp;
		cin >> tmp;
		num_min = min(num_min, tmp);
		num_max = max(num_max, tmp);
	}

	cout << num_max - num_min << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100
#define INFTY 1000000
#define WHITE 0
#define GRAY 1
#define BLACK 2

int prim();


int n,M[MAX][MAX];

int main(){
  int a,e,i,j;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&e);
      M[i][j] = (e==-1)?INFTY:e;
    }
  }

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

  return 0;
}

int prim(){
  int i,u,v,minv;
  int sum=0;
  int d[MAX],p[MAX],color[MAX];

  for(i=0;i<n;i++){
    d[i]=INFTY;
    p[i]=-1;
    color[i]=WHITE;
  }
  d[0]=0;

  while(1){
    minv=INFTY;
    u=-1;
    for(i=0;i<n;i++){
      if(minv>d[i]&&color[i]!=BLACK){
	u=i;
	minv=d[i];
      }
    }
    if(u==-1)break;
    color[u]=BLACK;
      for(v=0;v<n;v++){
      if(color[v]!=BLACK&&M[u][v]!=INFTY){
	if(d[v]>M[u][v]){
	  d[v]=M[u][v];
	  p[v]=u;
	  color[v]=GRAY;
	}
      }
    }
  }
  for(i=0;i<n;i++){
    if(p[i]!=-1)sum += M[i][p[i]];
  }
  return sum;
}
  



Measured memory_bytes: 2052
#include<iostream>
using namespace std;
int main(void)
{
    int N,score[201][4],player[201];
    cin>>N;
        for(int i=0;i<N;i++)player[i]=0;

    for(int j=0;j<N;j++) {
            for(int k=0;k<3;k++)cin>>score[j][k];
    }
    for(int l=0;l<3;l++){
    for(int j=0;j<N;j++){
        for(int k=0;k<N;k++){
            if(j!=k&&score[j][l]==score[k][l])break;
            if(k==N-1)player[j]+=score[j][l];
        }
    }
    }
    for(int i=0;i<N;i++){
        cout<<player[i]<<"\n";
    }
}

Measured memory_bytes: 1164
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

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

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

        if x == y:
            return

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

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

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

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

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

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

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

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

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


def do():
    n,m=INTM()
    uf=UnionFind(n)
    for i in range(m):
        a,b=INTM()
        uf.union(a-1,b-1)

    ans=0

    for i in range(n):
        ans=max(ans,uf.size(i))
    
    print(ans)
                
if __name__=='__main__':
    do()

Measured memory_bytes: 75816
let n = stdin.ReadLine() |> int64
let a : int64 [] = stdin.ReadLine().Split(' ') |> Array.map int64

let z = Array.filter (fun x -> x = 0L) a |> Array.length
let mi = Array.filter (fun x -> x < 0L) a |> Array.length

if z>0 || mi%2=0 then 
    printfn "%d" (Array.map (fun x -> abs x) a |> Array.sum)
else
    let mn = Array.map abs a |> Array.min
    let s = Array.map abs a |> Array.sum
    printfn "%d" (s - mn*2L)


Measured memory_bytes: 33244
#include<stdio.h>
#define MAX 100000
#define SENTINEL 2000000000

struct Card {
  char suit;
  int value;
};

struct Card L[MAX / 2 + 2], R[MAX / 2 + 2];

void merge(struct Card A[], int left, int mid, int right) {
  int i, j, k;
  int n1 = mid - left;
  int n2 = right - mid;
  for ( i = 0; i < n1; i++ ) L[i] = A[left + i];
  for ( i = 0; i < n2; i++ ) R[i] = A[mid + i];
  L[n1].value = R[n2].value = SENTINEL;
  i = j = 0;
  for ( k = left; k < right; k++ ) {
    if ( L[i].value <= R[j].value )
      A[k] = L[i++];
    else
      A[k] = R[j++];
  }
}

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

int partition(struct Card A[], int p, int r) {
  int i, j;
  struct Card t, x;
  x = A[r];
  i = p - 1;
  for ( j = p; j < r; j++ )
    if ( A[j].value <= x.value ) {
      i++;
      t = A[i]; A[i] = A[j]; A[j] = t;
    }
  t = A[i + 1]; A[i + 1] = A[r]; A[r] = t;
  return i + 1;
}

void quickSort(struct Card A[], int p, int r) {
  int q;
  if ( p < r ) {
    q = partition(A, p, r);
    quickSort(A, p, q - 1);
    quickSort(A, q + 1, r);
  }
}

int main() {
  int n, i, v;
  struct Card A[MAX], B[MAX];
  char S[10];
  int stable = 1;

  scanf("%d", &n);

  for ( i = 0; i < n; i++ ) {
    scanf("%s %d", S, &v);
    A[i].suit = B[i].suit = S[0];
    A[i].value = B[i].value = v;
  }

  mergeSort(A, 0, n);
  quickSort(B, 0, n - 1);

  for ( i = 0; i < n; i++ )
    if ( A[i].suit != B[i].suit ) stable = 0;

  if ( stable == 1 ) printf("Stable\n");
  else printf("Not stable\n");
  for ( i = 0; i < n; i++ )
    printf("%c %d\n", B[i].suit, B[i].value);

  return 0;
}


Measured memory_bytes: 4928
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define repi(i, x) \
	for (auto i = (x).begin(), i##_fin = (x).end(); i != i##_fin; i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int, int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long, long long> P;
typedef vector<P> VP;
template <class T>
inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return 1;
	}
	return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return 1;
	}
	return 0;
}
template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}
template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os << "{";
	rep(i, v.size()) {
		if (i) os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}
template <class T, class U>
istream& operator>>(istream& is, pair<T, U>& p) {
	is >> p.first >> p.second;
	return is;
}
template <class T>
istream& operator>>(istream& is, vector<T>& v) {
	rep(i, v.size()) { is >> v[i]; }
	return is;
}
const long long INFLL = 1LL << 60;
const int INF         = 1 << 30;
const double PI       = acos(-1);

int main() {
	int n;
	string s;
	ll ans = 0LL;
	cin >> n >> s;
	vector<string> dis1, dis2;
	string bef = "";
	for (int bit = 0; bit < (1 << n); bit++) {
		bef = "";
		for (int i = 0; i < n; i++) {
			if (bit & (1 << i)) {
				bef += s[i];
			}
		}
		bef += '0';
		for (int i = n - 1; i >= 0; i--) {
			if ((bit & (1 << i)) == 0) {
				bef += s[i];
			}
		}
		dis1.pb(bef);
		// clog << bef << endl;
		bef = "";
		//--------//

		for (int i = n - 1; i >= 0; i--) {
			if ((bit & (1 << i)) == 0) {
				bef += s[i + n];
			}
		}
		bef += '0';
		for (int i = 0; i < n; i++) {
			if (bit & (1 << i)) {
				bef += s[i + n];
			}
		}

		dis2.pb(bef);
		//	clog << bef << endl;
	}
	sort(all(dis1));
	sort(all(dis2));
	repi(i,dis1){
		ans +=
		    distance(lower_bound(all(dis2), *i), upper_bound(all(dis2), *i) );
	//	clog << ans << endl;
	}
	cout << ans << endl;
}
/*
半分全挙列
chose red; head last: blue
chose bule: head last: red

top!= head: rr- bb- -> 2n:: n
2^n * log(n^2)


cabaacba = caba \ acba
c  -> /  aba ->
aba   <-/ <- c
== c aba   /  c aba
ab  ->/ ac
ca <-/ ba
== ab ac / ab ac
*/

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

using namespace std;

const int MOD = 1000000007;
const int MAX_N = 2010;

int64_t fa[MAX_N];  // n! mod MOD
int64_t fb[MAX_N];  // n!^(MOD - 2) mod MOD ≡ 1 / n!

int64_t modpow(int64_t base, int64_t k, int64_t mod) {
  base %= mod;
  int64_t answer = 1;
  while (k > 0) {
    if (k & 1) answer = (answer * base) % mod;
    base = (base * base) % mod;
    k >>= 1;
  }
  return answer;
}

// nCk =  n! / (k! * (n - k)!)
//     ≡ n! * k!^(MOD-2) * (n-k)!^(MOD-2) mod MOD
int64_t nCk(int64_t n, int64_t k, int64_t mod) {
  if (n == 0 || k == 0) return 1;
  if (n < 0 || k < 0) return 0;
  int64_t answer = fa[n];
  answer = answer * fb[k] % mod;
  answer = answer * fb[n - k] % mod;
  return answer;
}


int main() {
  fa[0] = 1;
  fb[0] = 1;
  for (int i = 0; i + 1 < MAX_N; i++) {
    fa[i + 1] = fa[i] * (i + 1) % MOD;
    fb[i + 1] = fb[i] * modpow(i + 1, MOD - 2, MOD) % MOD;
  }

  int S;
  cin >> S;
  int N = S / 3;
  int64_t answer = 0;
  for (int i = 1; i <= N; i++) {
    int r = S - 2 * i;
    answer = answer + nCk(r - 1, i - 1, MOD);
    answer %= MOD;
  }
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#define scan(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
char _;
#define complete_unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define all(a) a.begin(),a.end()
#define println printf("\n");
#define readln(x) getline(cin,x);
#define pb push_back
#define endl "\n"
#define INT_INF 0x3f3f3f3f
#define LL_INF 0x3f3f3f3f3f3f3f3f
#define MOD 1000000007
#define MOD2 1494318097
#define SEED 131
#define mp make_pair
#define fastio cin.tie(0); cin.sync_with_stdio(0);

#define MAXN 200005

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef unordered_map<int,int> umii;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef pair<int,pii> triple;
typedef int8_t byte;

mt19937 g1(time(0));

int randint(int a, int b){return uniform_int_distribution<int>(a, b)(g1);}
ll randlong(ll a,ll b){return uniform_int_distribution<long long>(a, b)(g1);}

ll gcd(ll a, ll b){return b == 0 ? a : gcd(b, a % b);}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}

int len,arr[MAXN],food[MAXN];
ll K;

inline bool works(ll mid){
	ll sum = 0;
	for(int i=1; i<=len; i++){
		ll curr = 1LL*arr[i]*food[i];
		if(curr <= mid) continue;
		ll dec = (curr-mid+food[i]-1)/food[i];
		sum+=dec;
	}
	return sum<=K;
}

int main(){
	scanf("%d %lld",&len,&K);
	for(int i=1; i<=len; i++)
		scanf(" %d",&arr[i]);
	for(int i=1; i<=len; i++)
		scanf(" %d",&food[i]);
	sort(arr+1,arr+len+1,greater<int>());
	sort(food+1,food+len+1);
	ll low = 0, high = 1e18, ans = 1e18;
	while(low <= high){
		ll mid = (low+high)/2;
		if(works(mid)){
			ans = mid;
			high = mid-1;
		}else low = mid+1;
	}
	printf("%lld\n",ans);
}

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


long long int Exp(long long int exp_n,long long int exp_e, long long exp_mod);


int main(){
  long long int K,A=1,B=1,O=0;
  cin >>K;
  if(K%7==0){
    K = K/7;
  }
  if(K%2==0){
    cout << "-1";
    exit(0);
  }else if(K%5==0){
    cout << "-1";
    exit(0);
  }else{
    while(true){
      O++;
      if(A%K==0){
        cout << O;
        exit(0);
      }else{
        B=B*10;
        A=A+B;
        A=A%K;
        B=B%K;
      }
    }
  }
  return 0;
}


long long int Exp(long long int exp_n,long long int exp_e, long long int exp_mod){
  long long int exp_o = 1;
  long long int exp_x=exp_n;
  long long int exp_tmp;
  
  while(0<exp_e){
    exp_tmp = exp_e/2;
    if(exp_e - exp_tmp*2 == 1){
      exp_o = exp_o*exp_x;
      if(exp_o>exp_mod){
        exp_o=exp_o%exp_mod;
      }
    }
    
    exp_x = exp_x*exp_x;
    if(exp_x>exp_mod){
      exp_x=exp_x%exp_mod;
    }
    exp_e = exp_tmp;
  }
  return exp_o;
}


Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

bool A(string s){
	if(s[0] == 'A') return true;
	else return false;
}
bool C(string s){
	int cnt = 0;
	int n = s.size()-1;
	for(int i = min(2,n-1); i <= max(2,n-1) ; i++){
		if(s[i] == 'C') cnt++;
	}

	if(cnt == 1) return true;
	else return false;
}

bool komoji(string s){
	int cnt = 0;
	for(int i = 0; i < s.size(); i++){
		if(0 <=s[i] - 'a' &&  s[i] - 'a' < 26) cnt++;
	}
	if(cnt == s.size()-2) return true;
	else return false;
}

int main()
{
	string s;
	cin >> s;
	if(A(s) && C(s) && komoji(s)) cout << "AC" << endl;
	else cout << "WA" << endl;
}

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

int main() {
  int N;
  cin >> N;
  
  string S;
  bool flag = false;
  
  for (int i = 0; i < N; i++) {
    cin >> S[i];
    
    if (S[i] == 'Y') {
      flag = true;
      break;
    }
  }
  
  if (flag == true) {
    cout << "Four" << endl;
  } else {
    cout << "Three" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y);
#define chmin(x,y) x = min(x,y);
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
const int INF = 1001001001;



int main() {
    string s;
    cin >> s;
    rep(i,3) {
        if (s[i] == '1') s[i] = '9';
        else s[i] = '1';
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3580
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <cmath>
#include <tuple>
#include <bitset>
#include <utility>
#include <climits>
#include <iomanip>

#define push emplace_back
#define each(i, x) for (auto i=0; i < x; i++)
using ull = unsigned long long;
constexpr auto mod = 1000000007;
constexpr auto INF = ULLONG_MAX;

using namespace std;
template <typename T> inline void dump(const T& x) { cout << "[" << x << "]" << endl; }
template <typename T> inline void dump(const vector<T>& x) { for (const auto v : x) { cout << v << " "; } cout << endl; }
template <typename T> inline void sort_asc(vector<T>& x) { std::sort(x.begin(), x.end()); }
template <typename T> inline void sort_desc(vector<T>& x) { std::sort(x.begin(), x.end(), greater<T>()); }
template <typename T> inline T max_value(vector<T>& x) { return *max_element(x.begin(), x.end()); }
template <typename T> inline T min_value(vector<T>& x) { return *min_element(x.begin(), x.end()); }
template <typename T> inline T sum_value(vector<T>& x) { return accumulate(x.begin(), x.end(), 0ULL); }

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

  bool rud = true;
  bool lud = true;

  each(i, s.size()) {
    if (i % 2 == 1) {
      if (s.at(i) == 'L' || s.at(i) == 'U' || s.at(i) == 'D') {
      } else {
        lud = false;
      }
    } else {
      if (s.at(i) == 'R' || s.at(i) == 'U' || s.at(i) == 'D') {
      } else {
        rud = false;
      }
    }
  }

  if (rud && lud) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

int main(){
    cin.sync_with_stdio(false);
    int w, h, n;
    cin >> w >> h >> n;

    int ux = w, dx = 0, ly = 0, ry = h;
    rep(i, n) {
        int x, y, a;
        cin >> x >> y >> a;
        if (a == 1) {
            maxch(dx, x);
        } else if (a == 2) {
            minch(ux, x);
        } else if (a == 3) {
            maxch(ly, y);
        } else {
            minch(ry, y);
        }
    }

    if (ux - dx <= 0 || ry - ly <= 0) {
        cout << 0 << endl;
    } else {
        cout << (ux - dx) * (ry - ly) << endl;
    }


    return 0;
}

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

using namespace std;

int main() {
    int A, B, K; cin >> A >> B >> K;
    int count = 0, result = min(A,B)+1;
    while (count != K) {
        result--;
        if (A%result == 0 and B%result == 0) count++;
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 384
s = input()
k = int(input())
if k == 1:
  print(s[0])
else:
  if s[0] == '1':
    for i in range(min(len(s),k)):
      if s[i] != '1':
        print(s[i])
        exit()
    print(s[1])
  else:
    print(s[0])

Measured memory_bytes: 3060
def main():
    x, n = map(int, input().split())
    p = set(map(int, input().split()))
    if not x in p:
        print(x)
    else:
        a = [abs(x-i) if not i in p else 1000 for i in range(-1, 102)]
        print(a.index(min(a))-1)
 
if __name__ == "__main__":
    main()

Measured memory_bytes: 9080
#include <stdio.h>
#include <stdlib.h>
#define INFTY (1 << 21)
#define N 100
#define BLACK 1
#define WHITE 0

int main(){
  int i,j,n,v,c,v1,c1;
  int G[N][N],color[N],d[N],p[N];
 int mincost,u;

  for(i = 0;i < N;i++){
    for(j = 0;j < N;j++){
      G[i][j] = -1;
    }
  }
  scanf("%d",&n);

  for(i = 0;i < n;i++){
    scanf("%d%d",&v,&c);
    for(j = 0;j < c;j++){
      scanf("%d%d",&v1,&c1);
      G[v][v1] = c1;
    }
  }

  for(i = 0;i < n;i++){
    color[i] = WHITE;
    p[i] = -1;
    d[i] = INFTY;
  }

  d[0] = 0;
  while(1){
    mincost = INFTY;
    for(i = 0;i < n;i++){
      if(color[i] != 2 && d[i] < mincost){
mincost = d[i];
        u = i;
      }
    }
    if(mincost == INFTY) break;
    color[u] = 2;
     for(i = 0;i < n;i++){
      if(G[u][i] != -1 && color[i] != 2 && (G[u][i]+d[u]) < d[i]){
        p[i] = u;
        d[i] = G[u][i]+ d[u];
        color[i] = BLACK;
      }
    }
  }
   for(i = 0;i < n;i++){
    printf("%d %d\n",i,d[i]);
  }
  return 0;

}

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

int main()
{
   long long int i,n,ans=1,b;
    scanf("%d",&n);
   b=pow(10,9);
   b+=7;

   for(i=1;i<=n;i++)
   {
       ans=(ans*i)%b;
}
printf("%lld",ans);

return 0;
}

Measured memory_bytes: 128
/*
ID: hafiz.i1
TASK: milk2
LANG: C++
*/
#include<bits/stdc++.h>

#define ll long long
#define mod 1000000007
#define pi acos(-1.0)

using namespace std;



int main()
{
//    freopen("milk2.in", "r", stdin);
//    freopen("milk2.out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,noz=0,d=0,s=0;
    cin>>n;
    ll l1[n+1];
    for(int i=1;i<=n;i++){
        cin>>l1[i];
        if(l1[i]==0)noz++;
    }
    while(noz!=n){
        ll l=0,r=0,mv=1e18;
        for(int i=1;i<=n;i++){
            if(l1[i]!=0&&l==0)l=i;
            if(l1[i]!=0)r=i,mv=min(mv,l1[i]);
            else if(r>0)break;
        }
        s+=mv;
        for(int i=l;i<=r;i++)l1[i]-=mv;
        for(int i=1;i<=n;i++)if(l1[i]==0)d++;
        noz=d;d=0;
        //cout<<l<<" "<<r<<" "<<mv<<" "<<s<<" "<<noz<<endl;
    }
    cout<<s<<endl;
}


Measured memory_bytes: 3608
import math

# 整数nを受け取る
n = int(input())

# ベクトルxを受け取る
x = [float(i) for i in input().split()]

# ベクトルyを受け取る
y = [float(j) for j in input().split()]

# マンハッタン距離を求める
D1 = sum([abs(k - l) for (k, l) in zip(x, y)])
print(D1)

# ユークリッド距離(p = 2)を求める
D2 = math.sqrt(sum([abs(k - l)**2 for (k, l) in zip(x, y)]))
print(D2)

# ユークリッド距離(p = 3)を求める
D3 = (sum([abs(k - l)**3 for (k, l) in zip(x, y)]))**(1/3)
print(D3)

# チェビシェフ距離を求める
Dc = max([abs(k - l) for (k, l) in zip(x, y)])
print(Dc)



Measured memory_bytes: 5724
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

const int INF = 1e9+5;
int main(){
  int n;
  cin >> n;
  while(n > 0){
    if(n%10 == 7) {
      cout << "Yes" <<endl;
      return 0;
    }
    n/=10;
  }
  cout << "No" << endl;
}


Measured memory_bytes: 3624
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            List<char> lstS = new List<char>();
            List<char> lstT = new List<char>();
            string sInp = Console.ReadLine().Trim();
            lstS = sInp.ToList();
            sInp = Console.ReadLine().Trim();
            lstT = sInp.ToList();

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            string sOut = "No";
            lstS.Sort();                                                                    // 昇順
            lstT.Sort(delegate (char mca1, char mca2) { return (int)(mca2 - mca1); });      // 降順
            string sS = new string(lstS.ToArray());
            string sT = new string(lstT.ToArray());
            if (sS.CompareTo(sT) < 0) { sOut = "Yes"; }

            // 出力
            Console.WriteLine("{0}", sOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }
}


Measured memory_bytes: 13664
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define All(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
#define IN(a, b, x) (a<=x&&x<b)
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<ll>>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename t, typename u, typename Comp=less<>>
bool chmax(t& xmax, const u& x, Comp comp={}) { if(comp(xmax, x)) { xmax = x; return true; } return false;}
template<typename t, typename u, typename Comp=less<>>
bool chmin(t& xmin, const u& x, Comp comp={}) { if(comp(x, xmin)) { xmin = x; return true;} return false;}
const int INF = 1e8;
const ll infl = ll(1e18)+5;
/*
*ios::sync_with_stdio(false);
*cin.tie(0);
*/

int N,M;
Graph G;
int s,t;

ll solve(){
  vector<vector<ll>> dist(N,vector<ll>(3,-1));
  dist[s][0] = 0;
  queue<pair<int,int>> que;
  que.push({s,0});
  while(!que.empty()){
    auto cur = que.front();que.pop();
    int v = cur.first;
    int parity = cur.second;
    for(auto nv: G[v]){
      int np = (parity + 1) % 3;
      if(dist[nv][np] == -1) {
        dist[nv][np] = dist[v][parity] + 1;
        que.push({nv,np});
      }
    }
  }
  if(dist[t][0] == -1) return -1;
  else return dist[t][0] / 3;
}

int main(){
  cin >> N >> M;
    G.assign(N, vector<ll>());
    for (int i = 0; i < M; ++i) {
        int u, v; cin >> u >> v; --u, --v;
        G[u].push_back(v);
    }
    cin >> s >> t;
    --s, --t;
    cout << solve() << endl; 
}

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

int main(){
    int l,n;
    cin >> n >> l;
    string s[100];
    string tmp;
    for(int i=0;i<n;++i){
        cin >> s[i];
    }
    for(int i=0;i<n;++i){
        for(int j=i+1;j<n;++j){
            if(s[i]>s[j]) {
                tmp=s[j];
                s[j]=s[i];
                s[i]=tmp;
            }
        }
    }
    for(int i=0;i<n;i++) cout << s[i];
    cout << endl;
}

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

int gcd(int a, int b){
   if (a%b == 0){
       return(b);
   }else{
       return(gcd(b, a%b));
   }
}

int main() {
	int k;
	cin>>k;
	long long ans=0;
	for(int i=1;i<=k;i++){
		for(int j=1;j<=k;j++){
			for(int f=1;f<=k;f++){
				ans=ans+gcd(gcd(i,j),f);
			}
		}
	}
	cout<<ans<<endl;
	// your code goes here
	return 0;
}


Measured memory_bytes: 3636
n = int(input())
txy = [tuple(map(int, input().split())) for _ in range(n)]
t, x, y = 0, 0, 0
for ti, xi, yi in txy:
    dt = ti - t
    dd = abs(xi - x) + abs(yi - y)
    if dd > dt or (dd - dt) % 2 == 1:
        print('No')
        raise SystemExit
print('Yes')


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

using namespace std;

typedef long long ll;
#define N 200005

long long n, a[N], cnt = 0;

void dfs(int len, int x, ll num)
{
	if(len == 10) return;
	ll tmp;
	for(int i = -1; i <= 1; i++)
	{
		int y = x + i;
		if(0 <= y && y <= 9)
		{
			tmp = 10 * num + y;
			a[++cnt] = tmp;
			dfs(len + 1, y, tmp);
		}
	}
}

int main()
{
	cin >> n;
	for(int i = 1; i <= 9; i++)
	{
		a[++cnt] = i;
		dfs(1, i, i);
	}
	sort(a + 1, a + cnt + 1);
	cout << a[n] << endl;
	return 0;
}

Measured memory_bytes: 1792
// A Dynamic Programming based solution for 0-1 Knapsack problem
#include <iostream>
#define ll long long int
using namespace std;
 
// A utility function that returns maximum of two integers
ll max(ll a, ll b)
{
    return (a > b) ? a : b;
}
 
// Returns the maximum value that can be put in a knapsack of capacity W
ll knapSack(ll W, ll wt[], ll val[], ll n)
{
    ll i, w;
    ll K[n + 1][W + 1];
 
    // Build table K[][] in bottom up manner
    for (i = 0; i <= n; i++)
    {
        for (w = 0; w <= W; w++)
        {
            if (i == 0 || w == 0)
                K[i][w] = 0;
            else if (wt[i - 1] <= w)
                K[i][w]
                        = max(val[i - 1] + K[i - 1][w - wt[i - 1]], K[i - 1][w]);
            else
                K[i][w] = K[i - 1][w];
        }
    }
 
    return K[n][W];
}
 
int main()
{
    ll n, W;
    cin >> n;
	cin >> W;
    ll val[n], wt[n];
    for (ll i = 0; i < n; i++)
    {
        
        cin >> wt[i];
        cin >> val[i];
    }
 
    
    cout << knapSack(W, wt, val, n);
 
    return 0;
}

Measured memory_bytes: 79104
#include<stdio.h>
int main(){
  int n,d[1000010],i,j,k;
  char s[100010];
  scanf("%d %s",&n,s);
  for(i=0;s[i];i++){
    if(s[i]-s[(i+1)%n])break;
  }
  if(s[i]==0){
    for(i=0;i<n;i++)printf("%c",s[i]=='o'?'S':'W');
    printf("\n");
    return 0;
  }      //printf("%d\n",i);
  for(k=0;k<4;k++){
    d[i]=k/2;
    d[(i+1)%n]=k%2;
    for(j=1;j<=n;j++){
      if(d[(i+j)%n]==0){
	if(s[(i+j)%n]=='o')d[(i+j+1)%n]=  d[(i+j-1+n)%n];
	else               d[(i+j+1)%n]=1-d[(i+j-1+n)%n];
      }
      else{
	if(s[(i+j)%n]=='x')d[(i+j+1)%n]=  d[(i+j-1+n)%n];
	else               d[(i+j+1)%n]=1-d[(i+j-1+n)%n];
      }
    }
    if(d[(i+j-1+n)%n]==k/2&&d[(i+j)%n]==k%2){
      for(j=0;j<n;j++)printf("%c",d[j]?'W':'S');
      printf("\n");
      return 0;
    }
  }
  printf("-1\n");
  return 0;
}
  


Measured memory_bytes: 2816
N,M = map(int,input().split())
L = [0] * M
R = [0] * M
for i in range(M):
  L[i],R[i]= map(int,input().split()) 

if min(R)>max(L):
  print(min(R)-max(L)+1)
elif min(R)==max(L):
  print(1)
else:
  print(0)

Measured memory_bytes: 46976
#include <stdio.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define max(a, b) ((a) > (b) ? (a) : (b))

typedef struct
{
    int w;
    int v;
} goods;
long long dp[110][100100] = {0};

int main(void)
{
    int n, w;
    goods g[110];
    scanf("%d%d", &n, &w);
    rep(i, n)
        scanf("%d%d", &g[i].w, &g[i].v);

    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= w; j++)
            if (j - g[i - 1].w >= 0)
                dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - g[i - 1].w] + g[i - 1].v);
            else
                dp[i][j] = dp[i - 1][j];

    printf("%lld", dp[n][w]);
    return 0;
}

Measured memory_bytes: 79232
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long
#define mod 1000000007
using namespace std;
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}
int main()
{
    ios_base:: sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
    ll n;
    cin>>n;
    ll flag=0;
    while(n--)
    {
        ll a;
        cin>>a;
        if(a%2==0)
        {
            if(a%3==0 || a%5==0)
                continue;
            else
                flag=1;
        }
    }
    if(flag)
        cout<<"DENIED";
    else
        cout<<"APPROVED";
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main
{
	public static void main(String[] args){
	    Scanner cin = new Scanner(System.in);
	    double r = cin.nextDouble();
	
	    System.out.printf("%.6f %.6f\n", cal_area(r), cal_cirum(r));
  	}
  	
  	private static double cal_area (double r){
  		double pi = Math.PI;
  		return (r * r * pi);
  	}
  	
  	private static double cal_cirum (double r){
  		double pi = Math.PI;
  		return (r * 2 * pi);
  	}
}

Measured memory_bytes: 28296
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <unordered_map>
#include <iterator>
#include <stack>
#include <unordered_set>
#include <iomanip>
#include <ctime>
#include <cstring>
#include <bitset>

#include <random>
#define all(x) (x).begin(), (x).end()


using namespace std;
void dout() { cerr << endl; }
typedef long long ll;
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

#define debug(x) cout << #x " = " << (x) << endl

using ll = long long;
using pii = pair<ll, ll>;
using ld = long double;
using pll = pair<long long, long long>;

template <typename T>
void do_uniq(vector<T> vec) {
    sort(all(vec));
    vec.resize(unique(all(vec)) - vec.begin());
}

#define solvsh
//#define multi
#ifdef solvsh

const int MAXN = 5e3 + 20;

// color comp_num
int dp[MAXN][MAXN];

vector<int> g[MAXN];

int colors[MAXN];

bool dfs_2(int ver, int col) {

    if (colors[ver] != -1) {
        return true;
    }
    colors[ver] = col;

    for (auto out : g[ver]) {

        if (colors[out] != -1 && colors[out] == colors[ver]) {
            return false;
        }
        if (!dfs_2(out, 1 - col)) {
            return false;
        }
    }

    return true;
}

bool usd[MAXN];

pair<vector<int>, vector<int>> comps[MAXN];
int comp_num = 0;
int curr_comp_0 =0;
int curr_comp_1 =0;

void dfs(int ver, int col) {
    if (usd[ver])
        return;
    usd[ver] = true;

    if (col == 0) {
        comps[comp_num].first.push_back(ver);
        ++curr_comp_0;
    }
    else {
        comps[comp_num].second.push_back(ver);
        ++curr_comp_1;
    }

    for (auto out : g[ver]) {
        dfs(out, 1 - col);
    }
}

int color_answr[MAXN];


void solve() {

    ll n;cin >> n;

    if (n % 10 == 3)
        cout << "bon";
    else if (n % 10 == 0 || n % 10 == 1 || n % 10 == 6 || n % 10 == 8){
        cout << "pon";
    } else {
        cout << "hon";
    }

}

#else

void solve() {

}

#endif

void multisolve() {

    int t;
    cin >> t;

    int i = 1;
    while (t--) {
//        cout << "Case #" << (i++) << ": ";
        solve();
        cout << "\n";
    }
}


#define int int
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    cout << fixed << setprecision(20);


#ifdef multi
    multisolve();
#else
    solve();
    //    gen();
#endif

}


Measured memory_bytes: 3976
#include<bits/stdc++.h>
#include <atcoder/all>

typedef long long ll;
typedef std::pair<ll, ll> P;
typedef std::tuple<ll, ll, ll> t3;
constexpr ll INF = 1e15;
constexpr ll mod = 1e9+7;

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

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }


class Divisor {
private:
	vector<ll> F;
public:
	Divisor(ll N) {
		for (ll i = 1; i * i <= N; i++) {
			if (N % i == 0) {
				F.push_back(i);
				if (i * i != N) F.push_back(N / i);
			}
		}
		sort(begin(F), end(F));
	}
	int size() { return F.size(); }
	ll operator[](int k) { return F[k]; }
	const vector<ll>& factors() { return F; }
};

int main() {
	ll n;
	cin >> n;
	ll n2 = n * 2;
	Divisor d(n2);
	//n2 x a == i * (i+1)
	//i * (i+1) = x * y;
	//x * y = 2 * n * a;
	//i * (i+1)は互いに素なので、xとyも互いに素
	//xはiの約数、yはi+1の約数
	//k % x == 0;
	//k % y == y-1;
	//となるkを最小化する
	auto& f = d.factors();
	ll ans = INF;
	for (auto p : f) {
		ll x = p;
		ll y = 2 * n / p;
		//k ... rem(mod)
		auto rm = atcoder::crt({ 0, y - 1 }, { x, y });
		auto k = rm.first;
		if (k > 0) {
			chmin(ans, k);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3732
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

INF = float('inf')

def solve():
    S = list(input())

    if 'A' not in S or 'B' not in S:
        print('No')
    else:
        print('Yes')


if __name__ == '__main__':
    solve()


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

int main() {
  int N;
  string s;
  cin>>N>>s;
  
  int ans = 0;
  
  for(int i = 0; i < 1000; i++) {
    string t;
    int x = i;
    
    for(int j = 0; j < 3; j++) {
      t += '0' + (x % 10);
      x /= 10;
    }
    
    int posi = 0;
    for(int j = 0; j < N; j++) {
        
      if (s[j] == t[posi]) {
        posi++;
        if (posi == 3) {
          break;
        }
      }
    }
    if(posi == 3){
        ans++;
    }
  }
  
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using static System.Console;
using static System.Int32;
using System.Linq;
using System.Collections.Generic;

class Solution
{
    static int[] Z(string s, int stt)
    {
        var ary = new int[s.Length - stt];
        for (int i = 1, j = 0; i < ary.Length; ++i)
        {
            if (i + ary[i - j] < j + ary[j])
            {
                ary[i] = ary[i - j];
            }
            else
            {
                var k = Math.Max(0, j + ary[j] - i);
                while (i + k < ary.Length && s[k + stt] == s[i + k + stt]) ++k;
                ary[i] = k;
                j = i;
            }
        }
        ary[0] = ary.Length;
        return ary;
    }
    static void Main()
    {
        ReadLine();
        var s = ReadLine();
        int result = 0;
        for(int i = 0; i < s.Length; ++i)
        {
            var ary = Z(s, i);
            for(int j = 1; j < ary.Length; ++j)
            {
                if (j < ary[j]) ary[j] = j;
                if (result < ary[j]) result = ary[j];
            }
        }
        WriteLine(result);
    }
}


Measured memory_bytes: 34468
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>
#define MAXN 1005
#define INF 0x3f3f3f3f
#define p 1000000007
#define rint register int
#define LL long long
#define LD long double
using namespace std;

int h, w, f[MAXN][MAXN];
char mp[MAXN][MAXN];

int main()
{
	scanf("%d%d", &h, &w);
	for(rint i=1; i<=h; ++i) scanf("%s", mp[i]+1);
	f[1][1]=1;
	for(rint i=1; i<=h; ++i)
		for(rint j=1; j<=w; ++j)
			if(mp[i][j]=='.') f[i][j]+=(f[i-1][j]+f[i][j-1])%p;
	printf("%d\n", f[h][w]);
	return 0;
}

Measured memory_bytes: 5120
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))
#define iter(v,ite) for(auto ite=(v).begin();ite!=(v).end();ite++)
#define mimunum(v,x) distance((v).begin(),lower_bound((v).begin(),(v).end(),x))


int main(void){
	int m,d;
	scanf("%d%d",&m,&d);
	int s=0;
	for(int i=1;i<=d;i++){
		int x = (i/10)*(i%10);
		if(i/10<=1 || i%10<=1)continue;
		if(1<=x && x<=m){
			//printf("%d %d\n",i,x);
			s++;
		}
	}
	printf("%d\n",s);
	return 0;
}






Measured memory_bytes: 764
#include <stdio.h>
#include <math.h>
int main(){
	int H,W,i,j,cnt=0;
	while(1){
		cnt=0;
	scanf("%d %d",&H,&W);
		if(H ==0 && W==0){
			break;
		}
		for (i = 0; i < H; i++){
			for (j = 0; j < W; j++){
				if(i%2 ==0){
					if(cnt%2==0){
						printf("#");
					}else{
						printf(".");
					}					
				}else{
					if(cnt%2==0){
						printf(".");
					}else{
						printf("#");
					}					
				}
				cnt++;
			}
			cnt=0;
			printf("\n");
		}
			printf("\n");
	}
	return 0;
}

Measured memory_bytes: 572
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

struct M {
  using T = int;
  static T op(const T& a, const T& b) { return a + b; }
  static constexpr T e() { return 0; }
};

template<class M> struct ST {
  using T = typename M::T;
  int n;
  V<T> t;

  ST(int n) : n(n) {
    t.assign(2 * n, M::e());
  }

  void build() {
    for (int i = n - 1; i; i--) t[i] = M::op(t[2 * i], t[2 * i + 1]);
  }

  T get(int l, int r) {
    T resl = M::e(), resr = M::e();
    for (l += n, r += n; l < r; l >>= 1, r >>= 1) { 
      if (l & 1) resl = M::op(resl, t[l++]); 
      if (r & 1) resr = M::op(t[--r], resr);
    }
    return M::op(resl, resr);
  }

  void set(int i, const T& a) {
    for (t[i += n] = a; i >>= 1;) t[i] = M::op(t[2 * i], t[2 * i + 1]);
  }
};

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  int n, k; cin >> n >> k;
  V<> a(n); for (int i = 0; i < n; i++) cin >> a[i], a[i] -= k;
  V<lint> c(n + 1); for (int i = 0; i < n; i++) c[i + 1] = c[i] + a[i];
  V<lint> z = c; sort(z.begin(), z.end());
  z.erase(unique(z.begin(), z.end()), z.end());
  for (int i = 0; i < n + 1; i++) c[i] = lower_bound(z.begin(), z.end(), c[i]) - z.begin();
  ST<M> st(z.size());
  st.set(c[0], 1);
  lint res = 0;
  for (int i = 1; i < n + 1; i++) {
    res += st.get(0, c[i] + 1);
    st.set(c[i], st.get(c[i], c[i] + 1) + 1);
  }
  cout << res << '\n';
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;

const ll INF=(1LL<<50);
#if __cplusplus>=201700L
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif

template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}

const string YES = "Yes";
const string NO = "No";

void solve(long long N, std::string S){
  if(N%2==0&&S.substr(0,N/2)==S.substr(N/2,N/2)){
    cout<<YES<<endl;
  }else{
    cout<<NO<<endl;
  }
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::string S;
    std::cin >> S;
    solve(N, S);
    return 0;
}


Measured memory_bytes: 256