akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int size=2000;
const int inf=1e9;
int N;
vector<pair<int,int>> g[2000];
int d[2000]={};
void dijkstra(int a){// O(NlogN+M)]
	priority_queue<pair<int,int>> pq;
	rep(i,0,N){
		d[i] = inf;
		pq.push({-d[i] , i});
	}
	d[a] = 0; pq.push({0 , a});
	int v; int temp;
	while(!pq.empty()){
		v = pq.top().second;
		pq.pop();
        int u;
		for(pair<int,int> p:g[v]){
            u = p.first;
			temp = d[v] + p.second;
			if(d[u] > temp){
				d[u] = temp;
				pq.push({-d[u] , u});
			}
		}
	}
    return;
}
int main(){
	int X,Y;cin>>N>>X>>Y;
	X--; Y--;
    int cnt[N]= {};
	rep(i,0,N-1){
		g[i].push_back({i+1,1});
		g[i+1].push_back({i,1});
	}
	g[X].push_back({Y,1});
	g[Y].push_back({X,1});
	rep(i,0,N){
		dijkstra(i);
		rep(j,0,N) cnt[d[j]]++;
	}
	rep(i,1,N) cout<<cnt[i]/2<<endl;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
typedef long long ll;
const int N=110;

int n,m;
int t[N];
int sum;

int main()
{
	cin>>n;
	for(int i=1; i<=n; i++)
	{
		cin>>t[i];
		sum+=t[i];
	}
	cin>>m;
	
	while(m--)
	{
		int i,v;
		cin>>i>>v;
		cout<<sum-t[i]+v<< endl;
	}
	
	return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef  long long int ll;
typedef long double db;
#define pb push_back
#define mp make_pair
#define ub(v,val) upper_bound(v.begin(),v.end(),val)-v.begin()
#define lb(v,val) lower_bound(v.begin(),v.end(),val)-v.begin()
#define sortv(vec) sort(vec.begin(),vec.end())
#define rev(p) reverse(p.begin(),p.end());
#define v vector
#define PI 3.1415926535
#define len length()
#define repc(i,s,e) for(ll i=s;i<e;i++)
#define np(str) next_permutation(str.begin(),str.end())
#define fi first
#define se second
#define mset(a,val) memset(a,val,sizeof(a));
#define mt make_tuple
#define repr(i,n) for(i=n-1;i>=0;i--)
#define rep(i,n) for( i=0;i<n;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int M = 1e9 + 7;
int INF = 1e6;
ll n, m;

int main() {
	// your code goes here
	IOS;

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ll  i, j, t, k, x, y, z,  N;
	cin >> x;
	x = x / 100;
	if (x % 2 != 0)
		x--;
	v<ll> q = {18, 16, 14, 12, 10, 8, 6, 4};
	rep(i, q.size()) {
		if (x == q[i]) {
			cout << i + 1;
		}
	}






	return 0;
}



Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define debug(a) cout<<#a<<":"<<a<<endl;
const int INF=0x3f3f3f3f;
const int N=1e6+7;
const int mod=1e9+7;
int maxn,minn;
int T,n,m;
double dp[3010][3010];
double arr[N];


int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		scanf("%lf",arr+i);
	}
	dp[0][0]=1;
	for(int i=1;i<=n;i++){
		for(int j=0;j<=i;j++){
			if(j==0){
				dp[i][j]=dp[i-1][j]*arr[i];
			}
			else{
				dp[i][j]=dp[i-1][j-1]*(1-arr[i])+dp[i-1][j]*arr[i];
			}
		}
	}
	double sum=0;
	for(int i=0;i<=n/2;i++){
		sum=sum+dp[n][i];
	}
	printf("%.9lf\n",sum);


	return 0;
}





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

int main(){
  int N;
  cin >> N;
  int d[101];
  for(int i=0;i<N;i++){
    cin >> d[i];
  }
  int ans = 0;
  for(int i=0;i<N-1;i++){
    for(int j=i+1;j<N;j++){
      ans += d[i]*d[j];
    }
  }

  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int main(){
  int *A, N,i, j, minj, temp, count;

  scanf("%d",&N);
  A = (int *)malloc(sizeof(int) * N);
  for(j=0; j<N; j++){
    scanf("%d",&A[j]);
  }

  count = 0;
  for(i=0; i<N; i++){
    minj = i;
    for(j=i; j<N; j++){
      if(A[j]<A[minj]){
	minj = j;
      }
    }
    if(A[i] != A[minj]){
	temp = A[i];
	A[i] = A[minj];
	A[minj] = temp;
	count++;
      }
  }
  
  for(j=0; j<N; j++){
    printf("%d",A[j]);
    if(j != N-1) printf(" ");
  }
  printf("\n%d\n",count);
  
  return 0;
}



Measured memory_bytes: 2124
/* 
 * Project: AISing programing Contest C - XYZ Triplets
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/07/11
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

int n;

int condition(int x, int y, int z) {
    return x*x+y*y+z*z+x*y+y*z+z*x;
}

void solve() {

    int cnt[n];
    memset(cnt,0,sizeof(cnt));
    int limit = (int)sqrt(n)+1;
    for (int i=1;i<=limit;i++) {
        for (int j=1;j<=limit;j++) {
            for (int k=1;k<=limit;k++) {
                int num = condition(i, j, k);
                if (num <= n)
                    cnt[num-1]++;
            }
        }
    }
    for (int i=0;i<n;i++) {
        printf("%d\n", cnt[i]);
    }
}

int main() {

    scanf("%d", &n);

    solve();
}

Measured memory_bytes: 3192
#include<bits/stdc++.h> 
#define mp(x,y) make_pair(x,y)
#define pii pair<int,int>
using namespace std;
inline int read(){
	int x=0,f=1,ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-') f=-1; ch=getchar();} 
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
const int N=1e5+5;
set<int>e[N];
set<int>::iterator it;
map<pii,int>H;
queue<pii>q;
int n,fa[N];
inline int find(int x){return fa[x]==x ? x:fa[x]=find(fa[x]);}
int main(){
    n=read();
    for(int i=1;i<=n*2-2;i++){
        int x=read(),y=read();
        e[x].insert(y);e[y].insert(x);
        H[mp(x,y)]++;H[mp(y,x)]++;
        if(H[mp(x,y)]==2)q.push(mp(x,y));
    }
    for(int i=1;i<=n;i++)fa[i]=i;
    while(!q.empty()){
    	int x=q.front().first,y=q.front().second;q.pop();
		x=find(x);y=find(y);
    	if(e[x].size()<e[y].size())swap(x,y);
    	fa[y]=x;e[x].erase(y);e[y].erase(x);
    	for(it=e[y].begin();it!=e[y].end();it++){
    		int v=*it;
    		H[mp(y,v)]=H[mp(v,y)]=0;
			e[v].erase(y);
			e[x].insert(v);e[v].insert(x);
			H[mp(x,v)]++;H[mp(v,x)]++;
			if(H[mp(x,v)]==2)q.push(mp(x,v));
		}
		e[y].clear();
	}
	int s=0;
	for(int i=1;i<=n;i++)if(i==fa[i])s++;
	if(s==1)puts("YES");else puts("NO");
    return 0;
}


Measured memory_bytes: 56192
#include<iostream>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define INF (int)1e9
#define INFL (ll)1e11
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int gcd(int x, int y) {
	if (x < y) return gcd(y, x);
	return y == 0 ? x : gcd(x%y, y);
}

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

	int N, X;
	cin >> N >> X;
	vector<int> dis(N);
	REP(i, N) {
		int x;
		cin >> x;
		dis[i] = abs(x - X);
	}
	int res = dis[0];
	REP(i, N) res = gcd(res, dis[i]);
	cout << res << "\n";


	return 0;
}
		

Measured memory_bytes: 640
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
   int x,a,b;
   cin >> x >> a >> b;
   if(abs(x-a) >abs(x-b)){
       cout << "B" << endl;
   }
   else{
       cout << "A" << endl;
   }
   return 0;
}


Measured memory_bytes: 256
/*
 * main.cpp
 *
 *  Created on: 2017/05/14
 *      Author: YamajiTakashi
 */

#include <iostream>
#include <string>
#include <stdint.h>
using namespace std;

void print_seq(int32_t *seq_, int32_t len_) {
	string str = "";
	for (int32_t i = 0; i < len_ ; i++) {
		str += to_string(seq_[i]) + ' ';
	}
	str.erase(--str.end());
	cout << str << endl;
}

int32_t
bubbleSort(int32_t *seq_, int32_t len_) {
	bool flag = true;
	int32_t exchange_number = 0;
	while(flag == true) {
		flag = false;
		for (int j = len_ - 1; j > 0; j--) {
			if (seq_[j] < seq_[j-1]) {
				int32_t tmp = seq_[j];
				seq_[j] = seq_[j-1];
				seq_[j-1] = tmp;
				exchange_number++;
				flag = true;
			}
		}
	}
	return exchange_number;
}

int main(void) {
	uint32_t N;
	cin >> N;
	int32_t *A = new int32_t[N];

	for (int32_t i = 0; i < N; i++) {
		cin >> A[i];
	}

	int32_t n = bubbleSort(A, N);
	print_seq(A, N);
	cout << n << endl;
}

Measured memory_bytes: 3244
s,t=input(),input()
rs=[""for _ in range(26)]
rt=[""for _ in range(26)]
def a(n):return [chr(ord('a')+i)for i in range(26)].index(n)
for i in range(len(s)):
  ss,tt=a(s[i]),a(t[i])
  if rs[ss]=="":rs[ss]=t[i]
  elif rs[ss]!=t[i]:print("No");exit()
  if rt[tt]=="":rt[tt]=s[i]
  elif rt[tt]!=s[i]:print("No");exit()
print("Yes")


Measured memory_bytes: 43852
#include <stdio.h>
int main(){
  int n,k,p,i,j,v,c,s,ans;
  n=0;
  k=0;
  i=0;
  j=0;
  v=0;
  c=0;
  s=0;
  ans=0;
  int a[10000];
  scanf("%d",&n);
  scanf("%d",&k);
  for(i=0;i<n;i++)
  {
    scanf("%d",&p);
    a[i]=p;
  }
    for(i=0;i<n;i++) for(j=0;j<n-1;j++){
    int b = a[j], c = a[j+1];
    if(b>c){
      a[j+1]=b; a[j]=c;
    }
  }
  for(s=0;s<k;s++)
  {
    ans+=a[s];
  }
  printf("%d",ans);

  return 0;
}


Measured memory_bytes: 1676
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
//const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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 (a>b) { a=b; return 1; } return 0; }



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

  int d, t, s;
  cin >> d >> t >> s;

  cout << (t * s >= d ? "Yes" : "No") << '\n';

  
  return 0;
}

Measured memory_bytes: 3620
PROGRAM piyo
      IMPLICIT NONE
      INTEGER,PARAMETER :: p = 8
      integer(p) :: N(2*10**5+1)
      N = 0
      read'(*(i1))',N
      
      if( mod(sum(N),9)==0 )then
        print*,'Yes'
      else
        print*,'No'
      end if
      
      
      stop
      !debugg
      
      print*,n(1:10)
      
      
      END PROGRAM

Measured memory_bytes: 4488
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main() {
  int x1,y1,x2,y2;
  cin >> x1 >> y1 >> x2 >> y2;
  int xd = x2 - x1;
  int yd = y2 - y1;
  cout << x2 - yd << " " << y2 + xd << " ";
  cout << x2 - yd - xd << " " << y2 + xd - yd << endl;
  return 0;
}


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

using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=st; i--)

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 5e5 + 10;
const ll INF = 1LL << 60;

template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}


vector<int> g[N];
bool viss[N];
int vis[N];

// Normal DFS
void dfs(int curr, int par)
{
  for(auto x: g[curr])
    if(x != par)
      dfs(x, curr);
}

// DFS with visiting status
void dfs1(int curr, int par)
{
  viss[curr] = 1;
  for(auto x: g[curr])
    if(!viss[x])
      dfs1(x, curr);
}

// DFS with strongly connected component
void dfs2(int curr, int par, int num)
{
  vis[curr] = num;
  for(auto x: g[curr])
    if(vis[x] == 0)
      dfs2(x, curr, num);
}

// XOR from 0 to n
ll fxor(ll n)
{
  if(n < 0) return 0;
  if(n % 4 == 3) return 0;
  else if(n % 4 == 0) return n;
  else if(n % 4 == 1) return n^(n-1);
  else if(n%4 == 2) return n^(n-1)^(n-2);
}

// Power in logn with mod 1000000007
llt ppow(llt x, llt y)
{
  llt res = 1;
  while(y > 0){
    if(y&1)
      res = (res * x)%M;
    y = y >> 1;
    x = (x * x)%M;
  }
  return res;
}

// Factorial with dp
llt factdp[N];
llt fact(llt x)
{
  if(x == 0) return 1;
  if(x == 1) return 1;
  if(factdp[x] != 0) return factdp[x];
  return factdp[x] = (x*fact(x-1))%M;
}
// Combination
ll modcomb(ll n, ll r)
{
  if(n < r) return 0;
  ll res = fact(n);
  (res *= ppow(fact(r), M-2)) %= M;
  (res *= ppow(fact(n-r), M-2)) %= M;
  return res;
}

//GCD and LCM
llt gcd(llt x, llt y)
{
  if(y == 0) return x;
  return gcd(y, x%y);
}
llt lcm(llt x, llt y)
{
  return (x / gcd(x, y)) * y;
}

// String return to base b
string ansConv ="";
void convert10tob(llt N, int b)
{
     if (N == 0)
        return;
     int x = N % b;
     N /= b;
     if (x < 0)
        N += 1;
     convert10tob(N, b);
     ansConv += to_string(x);
     return;
}

// Convert string to num wiht base b
llt convertstrtob(string a, int b)
{
  llt aa = 0;
  llt mul = 1;
  for(int i=a.length()-1; i>=0; i--)
  {
    int curr = a[i] - '0';
    aa += (curr * mul);
    mul *= b;
  }
  return aa;
}

// Union Find
// Find()
int parent[N], ran[N];
int find(int x)
{
    if(parent[x]==x)return x;
    else return parent[x]=find(parent[x]);
}
// Union()
void unite(int x,int y){
    x=find(x);
    y=find(y);
    if(x==y)return;

    if(ran[x]<ran[y])
        parent[x]=y;
    else{
        parent[y]=x;
        if(ran[x]==ran[y])ran[x]++;
    }
}

// Main Code
map<int, int> mp;

int main()
{
  int ans = 0;
  int n;
  cin>>n;
  int arr[n];
  rep(i, 0, n)
  {
    int a;
    cin>>a;
    mp[a]++;
    arr[i] = a;
  }
  rep(i, 0, n)
  {
    ans = max(ans, mp[arr[i]] + mp[arr[i]+1]+ mp[arr[i]-1]);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 18944
//

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

int main() {
	ll a, b, c, d;
	cin >> a >> b >> c >> d;

	ll ans = max(a*c, max(b*d, max(a*d, b*c)));

	cout << ans << endl;

	return 0;
}

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

int main() {
  int A, B, C, K;
  cin >> A >> B >> C >> K;
  int X = 0;
  while (B <= A) {
    B *= 2;
    X++;
  }
  while (C <= B) {
    C *= 2;
    X++;
  }
  if (X <= K) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3632
use std::io::*;
use std::str::*;
use std::f64::consts::*;
use std::f64;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        a: i32,
        b: i32,
    }
    let num = format!("{}{}", a, b).parse::<i32>().unwrap();
    let root = (num as f64).sqrt();
    if root.ceil() == root {
        println!("Yes");
    } else {
        println!("No");
    }
}

Measured memory_bytes: 2600
#include <cstdio>
#include <functional>
#include <algorithm>
using namespace std;

const int N = 200000;
int n;
int a[N];

int main() 
{
	scanf("%d", &n);
	for (int i = 0; i < n; ++i) scanf("%d", a + i);
	sort(a, a + n, greater<int>());
	long long s = a[0];
	for (int i = 1; i <= (n - 1) / 2; ++i) s += a[i] * 2;
	if (n & 1) s -= a[(n - 1) / 2];
	printf("%lld\n", s);
	return 0;
}


Measured memory_bytes: 2512
#include<bits/stdc++.h>
#define debug(x) cerr << #x << " = " << x << "\n";
#define debug_v(x) cerr << #x << " ="; for(auto it : x) {cerr << " [" <<  it << "]";} cerr << "\n";
using namespace std;
using ll = long long;
using ld = long double;
const double PI = acos(-1);
const int mod = 998244353;
const int inf = 1e9 + 100;
const ll inf64 = 1e18 + 100;
int n, m;
vector<vector<int>> graph;
vector<int> visited;
stack<int> top_sort;
void max_self(int& a, int b){
	a = max(a, b);
}
void topological_sort(int v){
	visited[v] = 1;
	for(auto x : graph[v]){
		if(visited[x] == 0){
			topological_sort(x);		
		}
	}
	top_sort.push(v);
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cout << fixed << setprecision(20);
	cin >> n >> m;
	graph.resize(n);
	visited.resize(n);
	for(int i = 0;i < m;++i){
		int u, v;
		cin >> u >> v;
		--u;
		--v;
		graph[u].push_back(v);
	}
	for(int i = 0;i < n;++i){
		if(visited[i] == 0){
			topological_sort(i);
		}
	}
	vector<int> dp(n);
	int answer = 0;
	while(!top_sort.empty()){
		int node = top_sort.top();
		top_sort.pop();
		for(auto x : graph[node]){
			max_self(dp[x], dp[node] + 1);
			max_self(answer, dp[x]);
		}
	}
	cout << answer << '\n';
	return 0;
}


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

int main() {
    int t;
   // cin>>t;
   t=1;
    while(t--)
    {
        ll n;
        cin>>n;
        ll a[n+1];
        for(int i=1;i<=n;i++)
        {
            cin>>a[i];
        }
        ll dp[n+1];
        dp[0]=0;
        dp[1]=0;
        dp[2]=abs(a[1]-a[2]);
        for(int i=3;i<=n;i++)
        {
            dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
        }
        cout<<dp[n];
    }
}

Measured memory_bytes: 5168
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define all(x) x.begin(), x.end()
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5 << 28, MOD = 1e9 + 7;

int N, M, K;
vector<int> A, B;
string S1, S2;

void input() {
  cin >> N;
  int x, y, z;
  cin >> S1 >> S2;
  ;
}

vector<int> v[52 + 5] = {};
void solve() {
  int ans = 1;
  int prv = 0;
  for (int i = 0; i < N;) {  //横に見る
    if (S1[i] == S2[i])      // 縦になってるやつ
    {
      if (prv == 0) {
        ans *= 3;
      } else if (prv == 1) {  //横
        ans *= 2;
      } else {
        ans *= 1;
      }
      prv = 1;
      i += 1;
    } else {  // tate
      if (prv == 0) {
        ans *= 6;
      } else if (prv == 1) {
        ans *= 2;
      } else {
        ans *= 3;
      }
      prv = 2;
      i += 2;
    }
    ans %= MOD;
  }
  cout << ans << endl;

  ;
  ;
}
signed main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>

using namespace std;

int main() {

    int N;
    cin >> N;
    vector<long> AS;

    for (int i = 0; i < N; ++i) {
        long A;
        cin >> A;
        AS.push_back(A);
    }

    sort(AS.begin(), AS.end());

    bool ok = true;
    long s = AS[0];
    for (int i = 1; i < N; ++i) {
        if (s >= AS[i]) {
            ok = false;
            break;
        }
        s = AS[i];
    }

    if (ok) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 2420
s = input()
k = int(input())
n = len(s)
if n == 1:
    if k == 1:
        print(0)
    else:
        print(k//2)
else:
    ans = []
    ss = 0
    i = 0
    while True:
        if i == n:
            break
        curr = s[i]
        temp = 1
        i += 1
        if i == n :
            break
        while s[i] == curr:
            temp += 1
            i += 1
            if i == n:
                break
        ans.append(temp)
    if len(ans) > 1:
        for i in ans:
            ss += (i//2)*k
        if s[0] == s[-1] and ans[0]%2 == ans[-1]%2 == 1:
            ss += k-1
    else:
        ss = n*k//2
    print(ss)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <stack>

using namespace std;

int main() {
	string s; cin >> s;
	int ans = 0;
	stack<char> st;

	for (int i = 0; i < s.size(); i++)
	{
		if (st.empty() || st.top() == s[i]) st.push(s[i]);
		else {
			ans += 2;
			st.pop();
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 512
N, A, B = map(int, input().split())
X = [1<<20] * 8080
for _ in range(N):
    a, b, c = map(int, input().split())
    t = A*b-B*a
    X = [min(X[i], (0 if (i-t)%8080 == 0 else X[(i-t)%8080]) + c) for i in range(8080)]
print(-1 if X[0] > 1<<18 else X[0])

Measured memory_bytes: 3188
#include<stdio.h>
int main(){
    int  s=100000;
    int n;
    scanf("%d",&n);
    for(;n--;){
        if(int(s*1.05)%1000==0){
            s=int(s*1.05);
        }else{
            s= int(s*1.05) + (1000- int(s*1.05) % 1000);
        }
    }
    printf("%d\n",s);
    return 0;
}

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

int hit(int a[], int b[]) {
    int cnt = 0;
    for(int r = 0; r < 4; r++) {
        if(a[r] == b[r]) cnt++;
    }
    return(cnt);
}

//少し未完成なblow
int blow(int a[], int b[]) {
    int cnt = 0;
    for(int r = 0; r < 4; r++) {
        for(int c = 0; c < 4; c++) {
            if(a[r] == b[c]) cnt++;
        }
    }
    return(cnt);
}

int main(void) {
    int a[4], b[4];
    
    while(cin >> a[0] >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3]) {
        int hi = hit(a, b);
        int bl = blow(a, b) - hi;
        cout << hi << " " << bl << endl;
    }
    return(0);
}

Measured memory_bytes: 1160
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, K, A):

    sa = [0]
    for a in A:
        sa.append(sa[-1]+a)
    
    s = []
    for i in range(N+1):
        for j in range(i+1, N+1):
            s.append(sa[j]-sa[i])
    s.sort()


    pool = s
    for b in range(s[-1].bit_length(), -1, -1):
        cnd = []
        v = 1 << b
        for a in pool:
            if a & v > 0:
                cnd.append(a)
        if len(cnd) >= K:
            pool = cnd

    return reduce(lambda x, y: x&y,  pool)

        




def main():
    N, K = read_int_n()
    A = read_int_n()
    print(slv(N, K, A))


if __name__ == '__main__':
    main()


Measured memory_bytes: 94456
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define inf 1000000000
#define md 1000000007
#define pb push_back
#define li 100005
#define lo long long
using namespace std;
int a,b;
int main(){
	scanf("%d %d",&a,&b);
	if(a*500>=b){
		printf("Yes\n");
	}
	else printf("No\n");
	return 0;
}





Measured memory_bytes: 256
n = int(input())

count_list = [0] * 4

for i in range(n):
    text = input()
    if text == "AC":
        count_list[0] += 1
    elif text == "WA":
        count_list[1] += 1
    elif text == "RE":
        count_list[3] += 1
    else:
        count_list[2] += 1

print("AC x " + str(count_list[0]))
print("WA x " + str(count_list[1]))
print("TLE x " + str(count_list[2]))
print("RE x " + str(count_list[3]))

Measured memory_bytes: 9136
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#define REP(i, n) for(i=0; i<n; i++)
#define REPR(i, n) for(i=n; i>=0; i--)
#define FOR(i, m, n) for(i=m; i<n; i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;

int main(void) {
    string s;
    bool ap[26]={false};
    cin >> s;
    int i, j;
    int slen=(int)s.size();
    char p, q;
    for(i=0; i<slen; i++) {
        ap[s[i]-'a']=true;
    }
    
    if(slen<26) {
        for(p=0; p<26; p++) {
            if(ap[p]==false) {
                cout << s << (char)(p+'a');
                return 0;
            }
        }
    }

    ap[s[slen-1]-'a']=false;
    s[slen-1]='\0';
    
    for(p=slen-2; p>=0; p--) {
        for(q=s[p]-'a'+1; q<26; q++) {
            if(ap[q]==false) {
                s[p]=q+'a';
                for(j=0; s[j]!='\0'; j++)
                    cout << s[j];
                return 0;
            }
        }
        ap[s[p]-'a']=false;
        s[p]='\0';
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 256
R, G, B, N = map(int, input().split())
def solve():
    ans = 0
    for i in range(N//R+1):
        b1 = N - i*R
        for j in range(b1//G+1):
            b2 = b1 - j*G
            if b2%B==0:
                ans += 1
    return ans
print(solve())

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

using namespace std;

int32_t main() {

    ios_base::sync_with_stdio(false);

    cin.tie(0);

    string n;

    cin >> n;

    if(n.find("7")!=string::npos) {

        cout << "Yes" <<'\n';

    } else {

        cout << "No" <<'\n';

    }

    return 0;

}



Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n;
  cin >> n;
  multiset<ll, greater<ll>> st;
  map<ll, ll> mp;
  rep(i, n) {
    ll a;
    cin >> a;
    st.insert(a);
    mp[a]++;
  }
  ll ans = 0;
  for(auto v : st) {
    if(mp[v] == 0) continue;
    ll k = 1;
    while(k <= v) k *= 2;
    if(k - v > v) continue;
    mp[v]--;
    if(mp[k - v] > 0) {
      mp[k - v]--;
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 37888
#include <stdio.h>
#include <math.h>
#define pai 3.141592653

typedef struct point{
    double x;
    double y;
}Point;

void koch(int d, Point a, Point b){
    Point s, t, u;
    if(d == 0) return ;

    s.x = (2 * a.x + 1 * b.x) / 3;
    s.y = (2 * a.y + 1 * b.y) / 3;

    t.x = (1 * a.x + 2 * b.x) / 3;
    t.y = (1 * a.y + 2 * b.y) / 3;

    u.x = (t.x - s.x) * cos(60*(pai/180)) - (t.y - s.y) * sin(60*(pai/180)) + s.x;
    u.y = (t.x - s.x) * sin(60*(pai/180)) + (t.y - s.y) * cos(60*(pai/180))+ s.y;

    koch(d-1, a, s);
    printf("%.8f %.8f\n", s.x, s.y);
    koch(d-1, s, u);
    printf("%.8f %.8f\n", u.x, u.y);
    koch(d-1, u, t);
    printf("%.8f %.8f\n", t.x, t.y);
    koch(d-1, t, b);
}

int main(){
    int nm;
    Point a = {0, 0}, b = {100, 0};

    scanf("%d", &nm);

    printf("%.8f %.8f\n", a.x, a.y);
    koch(nm, a, b);
    printf("%.8f %.8f\n", b.x, b.y);

    return 0;
}


Measured memory_bytes: 2084
using System;
using System.Collections.Generic;

public class CSharp{
    public static void Main(){
        Kyopuro chokudai = new Kyopuro();
	    chokudai.AtCoder();
	}
}

public class Kyopuro{
    public void AtCoder(){
        string[] s;
		s = Console.ReadLine().Split(' ');
		int t = int.Parse(s[0]);
		long[][] input = new long[t][];
		for(int i=0; i<t; i++){
		    input[i] = new long[4];
		    s = Console.ReadLine().Split(' ');
		    input[i][0] = long.Parse(s[0]);
		    input[i][1] = long.Parse(s[1]);
		    input[i][2] = long.Parse(s[2]);
		    input[i][3] = long.Parse(s[3]);
		}
		long a, b, c, d, x, y, tmp;
		bool f;
		for(int i=0; i<t; i++){
		    f = true;
		    a = input[i][0];
		    b = input[i][1];
		    c = input[i][2];
		    d = input[i][3];
		    if(a<b) f = false;
		    if(d<b) f = false;
		    if(a%b>c) f = false;
		    if(f && c>=b){
		        Console.WriteLine("Yes");
		        continue;
		    }
		    a %= b;
		    d %= b;
		    x = (b + c - a) % b;
		    y = (b - a) % b;
		    if(x>y) y += b;
		    while(d > 0){
		        tmp = b;
		        b = d;
		        d = tmp % d;
		    }
		    if(y-x>b) f = false;
		    if(f) Console.WriteLine("Yes");
		    else Console.WriteLine("No");
		}
		
    }
    
    public static void DebugWL(object x){ System.Diagnostics.Debug.WriteLine(x); }
}

Measured memory_bytes: 11220
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
#define PI 3.14159265358979323846264338327950L
using namespace std;
using P = pair<int,int>;
using ll = long long;
using namespace std;
int main(void){
    int n, x;
    cin >> n >> x;
    int l[n]; rep(i, n){cin >> l[i];}
    int c[n+1];
    c[0] = 0;
    rep(i, n){
        c[i+1] = l[i] + c[i];
    }
    int cnt = 0;
    rep(i, n+1){
        if(c[i] <= x){++cnt;}
    }
    
    cout << cnt << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
using namespace std;
typedef long long ll;

int main()
{
  int N;
  int p[110000];
  int res=0;
  cin >> N;

  rep(i,N) {
    cin >> p[i];
    p[i]--;
  }

  int i = 0;
  while(i < N) {
    if(p[i] == i) {
      if(p[i+1] == i+1) {
        i++;
      }
      res++;
    }
    i++;
  }

  cout << res << endl;
}

Measured memory_bytes: 640
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>



using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)










int main(){
    ll n;
    cin >> n;
    vector<ll> d(n);
    REP(i, n){
        cin >> d[i];
    }
    sort(d.begin(), d.end());
    ll ans = 0;
    for(ll k = 1; k <= 100000; k++){
        ll itr = lower_bound(d.begin(), d.end(), k) - d.begin();
        if(itr == n / 2) ans++;
    }
    cout << ans << endl;
}

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

#define break break
#define continue continue
#define INF INT_MAX>>1 
#define SIZE 100010
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep2(i, from, to) for(int i=(from); i<(int)(to); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define LLPair pair<ll, ll>
#define vint vector<int>
#define vll vector<ll>
typedef long long ll;

using namespace std;

struct Edge{
	int a, b;
};

vector<vint > adj;
vector<set<int> > used;
map<pair<int, int>, int> ans;

void dfs(int idx){
	int color = 1;
	rep(i, adj[idx].size()){
		int to = adj[idx][i];
		while(used[idx].count(color)){
			color++;
		}
		used[idx].insert(color);
		used[to].insert(color);
		ans[make_pair(idx, to)] = color;
		dfs(to);
	}
}


int main(void){
	int n; cin >> n;
	adj.resize(n);
	used.resize(n);
	vector<Edge> edge(n);
	rep(i, n-1){
		cin >> edge[i].a >> edge[i].b;
		edge[i].a--; edge[i].b--;
		adj[edge[i].a].push_back(edge[i].b);
	}

	dfs(0);

	int k = -1;
	vint degree(n);
	rep(i, n-1){
		k = max(k, ++degree[edge[i].a]);
		k = max(k, ++degree[edge[i].b]);
	}
	cout << k << endl;
	rep(i, n-1){
		cout << ans[make_pair(edge[i].a, edge[i].b)] << endl;
	}
	return 0;
}

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

const ll M=1e9+7;

struct matrix
{
    ll value[105][105];
}base,trans;

matrix store(int n)
{
    matrix tempMat;
    
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            ll temp=0;
            
            for(int k=0;k<n;k++)
            {
                temp=(temp%M + (base.value[i][k]%M*trans.value[k][j]%M)%M)%M;
            }
            
            tempMat.value[i][j]=temp%M;
        }
    }
    
    return tempMat;
}

matrix mult(int n)
{
    matrix tempMat;
    
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            ll temp=0;
            
            for(int k=0;k<n;k++)
            {
                temp=(temp%M + (trans.value[i][k]%M*trans.value[k][j]%M)%M)%M;
            }
            
            tempMat.value[i][j]=temp%M;
        }
    }
    
    return tempMat;
}
int main()
{
    ll n,k;
    cin>>n>>k;
    
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            cin>>base.value[i][j];
            trans.value[i][j]=base.value[i][j];
        }
    }
    k--;
    while(k)
    {
        if(k&1)
        {
            base=store(n);
        }
        
        trans=mult(n);
        k=k>>1;
    }
    
    ll ans=0;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            ans=(ans%M + base.value[i][j]%M)%M;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 512
// Created by PRATEEK RANJAN
#include <bits/stdc++.h>
using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

#define int long long 

int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    string a,b;
    cin>>a>>b;
    if(a.length()>b.length()){
        cout<<"GREATER\n";
    }
    else if(a.length()<b.length()){
        cout<<"LESS\n";
    }
    else{
        if(a>b){
            cout<<"GREATER\n";
        }
        else if(b>a){
            cout<<"LESS\n";
        }
        else{
            cout<<"EQUAL\n";
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

Measured memory_bytes: 1164
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <utility>
#include <string>
#include <cmath>
#include <set>
#include <functional>
#include <map>
#include <queue>
#include <cstring>
#include <stack>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; ++i)
#define show(x) cout << #x << " = " << x << endl;
typedef long long ll;
typedef pair<int,int> pii;
int main(){
    char c;
    cin >> c;
    if(c=='a'||c=='i'||c=='u'||c=='e'||c=='o'){
        cout << "vowel" << endl;
    }else{
        cout << "consonant" << endl;
    }
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#define _rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define SF scanf
#define PF printf
using namespace std;
int n,k,a[200005];
int main(){
	SF("%d%d",&n,&k);
	_rep(i,1,n){
		SF("%d",&a[i]);
	}
	_rep(i,k+1,n){
		if(a[i]>a[i-k])PF("Yes\n");else PF("No\n");
	}
	return 0;
}

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

const bool DEBUG = false;

int main(int argc, char const *argv[]) {
  long long N;
  cin >> N;
  vector<long long> H(N);
  for (size_t i = 0; i < N; i++) cin >> H[i];

  long long num_max_move = 0;
  long long current;
  for (size_t i = 0; i < N - 1; i++) {
    current = 0;
    while (i < N - 1 && H[i + 1] <= H[i]) {
      current++;
      i++;
    }
    num_max_move = max(current, num_max_move);
  }

  cout << num_max_move << endl;

  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
typedef long long ll;
int n,f;
ll a[1000010],b[1000010];
ll ans=0;
bool check(ll sum,ll k)
{
  f=1;
  for (int i=n;i>=1;i--)
  {
    if (a[f]*b[i]<=sum)
	{
		f++;
		continue;
	}
    if ((a[f]-sum/b[i])>k) 
		return false;
    k-=a[f]-sum/b[i];
    f++;
  }
  return true;
}
int main()
{
  	ll k;
  	scanf("%d%lld",&n,&k);
  	for (int i=1;i<=n;i++) 
 		scanf("%lld",&a[i]);
  	for (int i=1;i<=n;i++) 
  		scanf("%lld",&b[i]);
	sort(a+1,a+1+n);
	sort(b+1,b+1+n);
 	ll l=0,r=0;
  	r=b[n]*a[n];
  	ans=r;
  	while (l<=r)
  	{	
      	ll mid=(l+r)/2;
      	if (check(mid,k)) 
	  	{
	  	ans=mid;
	 	 r=mid-1;
	  	}
      	else 
	  	l=mid+1;
  	}
  	printf("%lld\n",ans);
  	return 0;
}


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

using namespace std;


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

	int base_temp, ref_temp;
	cin >> base_temp >> ref_temp;

	vector<int> hight(N);
	vector<float> temp(N);
	float min_diff;
	int min_index;
	for (int i = 0; i < N; i++) {
		cin >> hight.at(i);
		temp.at(i) = abs(base_temp - hight.at(i) * 0.006 - ref_temp);
		if (i == 0) {
			min_diff = temp.at(i);
			min_index = i;
			continue;
		}
		if (temp.at(i) < min_diff) {
			min_diff = temp.at(i);
			min_index = i;
		}
	}

	cout << min_index + 1 << endl;
}

Measured memory_bytes: 256
class Tree():
    def __init__(self, n, decrement=1):
        self.n = n
        self.edges = [[] for _ in range(n)]
        self.root = None
        self.depth = [-1]*n
        self.size = [1]*n       # 部分木のノードの数
        self.decrement = decrement

    def add_edge(self, u, v):
        u, v = u-self.decrement, v-self.decrement
        self.edges[u].append(v)
        self.edges[v].append(u)

    def add_edges(self, edges):
        for u, v in edges:
            u, v = u-self.decrement, v-self.decrement
            self.edges[u].append(v)
            self.edges[v].append(u)

    def set_root(self, root):
        root -= self.decrement
        self.root = root
        self.par = [-1]*self.n
        self.depth[root] = 0
        self.order = [root]     # 帰りがけに使う
        next_set = [root]
        while next_set:
            p = next_set.pop()
            for q in self.edges[p]:
                if self.depth[q] != -1: continue
                self.par[q] = p
                self.depth[q] = self.depth[p]+1
                self.order.append(q)
                next_set.append(q)
        for p in self.order[::-1]:
            for q in self.edges[p]:
                if self.par[p] == q: continue
                self.size[p] += self.size[q]


#########################################################################################################
import sys
input = sys.stdin.readline

N = int(input())
T = Tree(N, decrement=1)
for _ in range(N-1):
    x, y = map(int, input().split())
    T.add_edge(x, y)
T.set_root(1)

grundy = [0]*N
for p in T.order[::-1]:
    for q in T.edges[p]:
        if T.par[p]==q: continue
        grundy[p]^=grundy[q]+1

print("Alice" if grundy[0]!=0 else "Bob")

Measured memory_bytes: 39788
# ARC059C - いっしょ / Be Together (ABC043C)
n = int(input())
lst = list(map(int, input().rstrip().split()))
ans = float("inf")
MIN, MAX = min(lst), max(lst)
for i in range(MIN, MAX + 1):
    cnt = 0
    for j in lst:
        cnt += (i - j) ** 2
    ans = min(ans, cnt)
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define N 1111116

int n,a[N],f[N][18];

struct rec{int l,r,x,y;};
priority_queue<rec> q;

bool operator <(rec x,rec y){
	return a[x.x]>a[y.x];
}

int mn(int x,int y){
	return a[x]<a[y]?x:y;
}

int query(int l,int r){
	int t=0;while (1<<(t+1)<=r-l+1) t++;
	return mn(f[l][t],f[r-(1<<t)+1][t]);
}

void push(int l,int r){
	if (l>r) return;
	int x=query(l,r),y=x+1==r?r:mn(query(x+1,r-1),r);
	q.push((rec){l,r,x,y});
}

int read(){
	int x=0,f=1;char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-')  f=-f;
	for (;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	return x*f;
}

int main(){
	n=read();
	for (int i=1;i<=n;i++) a[i]=read(),f[i][0]=f[i][1]=i;
	for (int k=2;(1<<k)<=n;k++)
		for (int i=1;i<=n-(1<<k)+1;i++)
			f[i][k]=mn(f[i][k-1],f[i+(1<<(k-1))][k-1]);
	for (push(1,n);!q.empty();){
		rec t=q.top();q.pop();
		printf("%d %d ",a[t.x],a[t.y]);
		push(t.l,t.x-1);
		push(t.x+1,t.y-1);
		push(t.y+1,t.r);
	}
	printf("\n");return 0;
}

Measured memory_bytes: 18676
import math

def combination_count(n,k):
    if k < 0 or k > n:
        return 0
    if n == 0 or k == 0:
        return 1
    
    s = math.factorial(n)
    t = math.factorial(k)
    u = math.factorial(n-k)
    
    return s//(t*u) 
    
n,k = map(int,input().split())
mod = 10**9 + 7

for i in range(1,k+1):
    x = combination_count(n-k+1, i) 
    y = combination_count(k-1, i-1)
    z = (x*y) % mod
    print(z)

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

int main() {
  string S;

  cin >> S;
  
  if(S == "SSS"){
    cout << 0 << endl;
    return 0;
  }
  if(S == "RSS"){
    cout << 1 << endl;
    return 0;
  }
  if(S == "SRS"){
    cout << 1 << endl;
    return 0;
  }
  if(S == "SSR"){
    cout << 1 << endl;
    return 0;
  }
  if(S == "SRR"){
    cout << 2 << endl;
    return 0;
  }
  if(S == "RSR"){
    cout << 1 << endl;
    return 0;
  }
  if(S == "RRS"){
    cout << 2 << endl;
    return 0;
  }
  if(S == "RRR"){
    cout << 3 << endl;
    return 0;
  }

  return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
ll m,a,r,c,h,cnt[5];
int p[10] = {0,0,0,0,0,0,1,1,1,2};
int q[10] = {1,1,1,2,2,3,2,2,3,3};
int o[10] = {2,3,4,3,4,4,3,4,4,4};
int main(void){
    int n;
    cin >> n;
    string s;
    for(int i = 0;i < n;i++){
        cin >> s;
        if(s[0] == 'M') cnt[0]++;
        if(s[0] == 'A') cnt[1]++;
        if(s[0] == 'R') cnt[2]++;
        if(s[0] == 'C') cnt[3]++;
        if(s[0] == 'H') cnt[4]++;
    }
    ll ans = 0;
    for(int i = 0;i < 10;i++){
        ans += (cnt[p[i]]*cnt[q[i]]*cnt[o[i]]);
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
	int N, M;
	cin >> N >> M;
	vector<int> k(M), p(M);
	int s[10][10];
	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			s[i][j] = 0;
		}
	}
	for (int i = 0; i < M; i++) {
		cin >> k[i];
		for (int j = 0; j < k[i]; j++) {
			cin >> s[i][j];
			s[i][j]--;
		}
	}
	for (int i = 0; i < M; i++) {
		cin >> p[i];
	}

	int ans = 0;
	for (int bit = 0; bit < (1 << N); ++bit) {
		int i;
		for (i = 0; i < M; i++) {
			int on_num = 0;
			for (int j = 0; j < k[i]; j++) {
				if (bit & (1 << s[i][j])) {
					on_num++;
				}
			}
			if (on_num % 2 != p[i]) {
				break;
			}
		}
		if (i == M) {
			ans++;
		}
	}

	cout << ans << endl;



	return 0;
}

Measured memory_bytes: 256
import sys
from copy import deepcopy


def perm(head: list, rest: list, result: list):
    if len(rest) == 0:
        # restを消費仕切ったら、結果に渡してあげる
        result.append(head)
        return
    for r in rest:
        restx = deepcopy(rest)
        restx.remove(r)

        headx = deepcopy(head)
        headx.append(r)

        perm(headx, restx, result)


def main():
    N = int(input())
    p = [int(x) for x in input().split()]
    q = [int(x) for x in input().split()]
    # 結果様のリストを渡さないといけない
    res = []
    perm([], [i for i in range(1, N+1)], res)

    p_i = 0
    q_i = 0
    for i,l in enumerate(res):
        if l == p:
            p_i = i
        if l == q:
            q_i = i
    print(abs(p_i-q_i))

if __name__ == '__main__':
    main()


Measured memory_bytes: 14708
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) (((x) < 0)?-(x):(x))
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

using cat = long long;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int H, W, N, s_r, s_c;
	string M_F, M_S;
	cin >> H >> W >> N >> s_r >> s_c >> M_F >> M_S;
	s_r--, s_c--;
	const char dir[] = "LRUD";
	int dr[] = {0, 0, -1, 1};
	int dc[] = {-1, 1, 0, 0};
	pair<int, int> range_r = {0, H-1}, range_c = {0, W-1};
	for(int i = N-1; i >= 0; i--) {
		int d_F, d_S;
		for(int j = 0; j < 4; j++) {
			if(dir[j] == M_F[i]) d_F = j;
			if(dir[j] == M_S[i]) d_S = j;
		}
		range_r.ff = max(0, range_r.ff + min(0, -dr[d_S]));
		range_r.ss = min(H-1, range_r.ss + max(0, -dr[d_S]));
		range_c.ff = max(0, range_c.ff + min(0, -dc[d_S]));
		range_c.ss = min(W-1, range_c.ss + max(0, -dc[d_S]));
		range_r.ff += max(0, -dr[d_F]);
		range_r.ss -= max(0, dr[d_F]);
		range_c.ff += max(0, -dc[d_F]);
		range_c.ss -= max(0, dc[d_F]);
		if(range_r.ff > range_r.ss || range_c.ff > range_c.ss) {
			cout << "NO\n";
			return 0;
		}
	}
	if(s_r < range_r.ff || s_r > range_r.ss || s_c < range_c.ff || s_c > range_c.ss)
		cout << "NO\n";
	else cout << "YES\n";
	return 0;
}

// look at my code
// my code is amazing


Measured memory_bytes: 920
A, B, C, X, Y = map(int, input().split())
cost = 0
if A + B <= 2 * C:
    cost = A * X + B * Y
elif A + B > 2 * C:
    if X > Y:
        cost = C * 2 * Y
        if 2 * C < A:
            cost += 2 * C * (X - Y)
        else:
            cost += A * (X - Y)
    elif Y >= X:
        cost = C * 2 * X
        if 2 * C < B:
            cost += 2 * C * (Y - X)
        else:
            cost += B * (Y - X)
print(cost)

Measured memory_bytes: 3064