akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String a = sc.next();
        String b = sc.next();
        String ans="";
        sc.close();
        for(int i = 0;i < n;i++)
        {
            ans += a.charAt(i); 
            ans += b.charAt(i);
        }
        System.out.println(ans);
    }
}



Measured memory_bytes: 22996
#include<bits/stdc++.h>
#include<string>
#define ll long long
#define lld long double
#define llu unsigned long long int
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define gll(a,n) for(ll i=0;i<n;i++) cin>>a[i];
#define mod 1000000007
#define mod1 998244353
#define pi 3.1415926535897
using namespace std;
ll n,k;
vector<ll> v[100002];
ll npr(ll n, ll r)
{
    if(r>n)
        return 0;
    ll i,val=1;
    for(i=n;i>n-r;i--)
    {
        val=(val*i)%mod;
    }
    return val%mod;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("B-small-attempt0.in", "r", stdin);freopen("output.txt", "w", stdout);
    //std::cout << std::setprecision(9);
    //std::cout << std::fixed;
    ll i;
    cin>>n>>k;
    for(i=1;i<n;i++)
    {
        ll x,y;
        cin>>x>>y;
        v[x].pb(y);
        v[y].pb(x);
    }
    ll child[n+1];
    child[1]=v[1].size();
    for(i=2;i<=n;i++)
    {
        child[i]=v[i].size()-1;
    }
    ll ans=(k*npr(k-1,child[1]))%mod;
    for(i=2;i<=n;i++)
    {
        if(child[i]==0)
            continue;
        ans=(ans*npr(k-2,child[i]))%mod;
    }
    cout<<ans;
}


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


using namespace std;
const long long INF = 1LL <<60;

int main(void){
  long long a,tmp;
  long long i,j,k;
  
  cin>>a;
  
  tmp=a+a*a+a*a*a;
  
  cout<<tmp<<endl;
  
  return 0;
  
}    

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

int main()
{
    int N, Y;
    int p = -1, q = -1, r = -1;
    cin >> N >> Y;

    for(int i=0;i<=N; i++){
        for(int j=0;j<=N-i; j++){
            for(int k=0;k<=N-i-j; k++){
                if( (10000*i + 5000*j + 1000*k == Y) && ( i+j+k == N ) ){
                    p = i;
                    q = j;
                    r = k;
                }
            }
        }
    }

    cout << p << " " << q << " " << r << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
N, M = map(int, input().split())
c = defaultdict(int)
for _ in range(M):
    a, b = map(int, input().split())
    c[a] += 1
    c[b] += 1

flag = True
for k, v in c.items():
    if v % 2 != 0:
        flag = False
if flag:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 14660
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		while(true){
			int n=cin.nextInt();
			if(n==0)break;
			int[][] m = new int[n][2];
			for(int i=0;i<n;i++){
				m[i][0]=cin.nextInt();
				m[i][1]=cin.nextInt();
			}
			n = n + cin.nextInt();
			int[][] mato=new int[n][3];
			for(int i=0;i<m.length;i++){
				mato[i][0]=m[i][0];
				mato[i][1]=m[i][1];
				mato[i][2]=1;
			}
			for(int i=m.length;i<n;i++){
				mato[i][0]=cin.nextInt();
				mato[i][1]=cin.nextInt();
				mato[i][2]=1;
			}
			Arrays.sort(mato,new Comparator<int[]>(){
				public int compare(int[] a,int[] b){
					if(a[0]==b[0]){
						return a[1]-b[1];
					}
					return a[0]-b[0];
				}
			});
			for(int i=0;i<n;i++){
//				System.out.println(mato[i][0]+" "+mato[i][1]);
			}
			int ans=1;
			for(int i=0;i<n;i++){
				for(int j=i-1;j>=0;j--){
					if(mato[i][0]>mato[j][0]&&mato[i][1]>mato[j][1]){
						mato[i][2]=Math.max(mato[i][2],mato[j][2]+1);
						ans=Math.max(ans,mato[i][2]);
					}
				}
			}
			System.out.println(ans);
		}

	}

}

Measured memory_bytes: 25492
import sys

sys.setrecursionlimit(10000)

def ironuri(x, y, t, img,h,w):
    if img[y][x]!=1:
        return 0

    img[y][x]=t
    
    if y<h-1:
        ironuri(x,y+1,t,img,h,w)
    if y>0:
        ironuri(x,y-1,t,img,h,w)
    if x<w-1:
        ironuri(x+1,y,t,img,h,w)
    if x>0:
        ironuri(x-1,y,t,img,h,w)

    if x>0 and y>0:
        ironuri(x-1,y-1,t,img,h,w)
    if x>0 and y<h-1:
        ironuri(x-1,y+1,t,img,h,w)
    if x<w-1 and y>0:
        ironuri(x+1,y-1,t,img,h,w)
    if x<w-1 and y<h-1:
        ironuri(x+1,y+1,t,img,h,w)

    
    return 1
    
while True:
    cheese=[]
    il=2
    w,h=map(int, input().split())
    if w==0 and h==0:
        break
    
    for i in range(h):
        ci=list(map(int, input().split()))
        cheese.append(ci)
    
    for i in range(h):
        for j in range(w):
            if(ironuri(j,i,il,cheese,h,w)):
                il+=1

    print(il-2)


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

using namespace std;

int main(){
  int K, A, B;
  cin >> K >> A >> B;
  
  bool ok = false;
  for(int i = A; i <= B; i++){
    if(i % K == 0){
      ok = true;
      break;
    }
  }
  
  if(ok) puts("OK");
  else puts("NG");
  
  return 0;
}

Measured memory_bytes: 3596
import sys
n = int(sys.stdin.readline())
x = [float(i) for i in sys.stdin.readline().split()]
y = [float(i) for i in sys.stdin.readline().split()]
d = [abs(x_i - y_i) for (x_i, y_i) in zip(x, y)]

# p = 1 ~ 3
for p in range(1, 4):
    print(sum([a ** p for a in d]) ** (1/p))

# p = INFINITE
print(max(d))

Measured memory_bytes: 6800
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <math.h>
using namespace std;
int main()
{
	string s;
	cin >> s;
	int a, b;
	for (int i = 0; i < s.size(); i++)if (s[i] == 'A') {
		a = i;
		break;
	}
	for (int i = s.size(); i >= 0; i--)if (s[i] == 'Z') {
		b = i;
		break;
	}
	cout << b - a + 1 << endl;
	return 0;
}

Measured memory_bytes: 640
/**
 *    author:  FromDihPout
 *    created: 2020-08-17
**/

#include <bits/stdc++.h>
using namespace std;


int smallPow(int base, int num) {
    int x = base;
    while (x <= num) {
        x *= base;
    }
    return x /= base;
}

int withdrawls(int n) {
    if (n < 6) return n;
    
    int cnt6 = withdrawls(n - smallPow(6, n));
    int cnt9 = withdrawls(n - smallPow(9, n));
    return 1 + min(cnt6, cnt9);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    
    cout << withdrawls(n) << '\n';
    return 0;
}

Measured memory_bytes: 3672
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <tuple>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
#include <random>
#include <cstdlib>
#define INT_MAX 2147483647
#define INT_MIN -2147483646
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;

static const int N = 105;

struct vertex {
	int id;
	int p;
	int d;
	bool operator<(const vertex & another) const {
		return (d != another.d ? d>another.d : id>another.id);
	}
};

struct edge {
	int end;
	int w;
};

int main() {
	int n;
	cin >> n;
	vector<vector<edge>> E(N);
	Loop(i, n) {
		int u, k;
		cin >> u >> k;
		Loop(i, k) {
			int v, c;
			cin >> v >> c;
			E[u].push_back({ v,c });
		}
	}
	//
	priority_queue<vertex> pq;
	vi color(N, 0), dist(N, 0);
	pq.push({ 0,-1,0 });
	while (pq.size() > 0) {
		vertex v = pq.top();
		pq.pop();
		if (color[v.id] == 1) continue;
		dist[v.id] = v.d;
		color[v.id] = 1;
		Loop(j, E[v.id].size()) {
			pq.push({ E[v.id][j].end, v.id, dist[v.id] + E[v.id][j].w });
		}
	}
	Loop(i, n) {
		cout << i << " " << dist[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 3128
let () = Scanf.scanf "%d %d\n" @@ fun n m ->
  let abs = Array.init m @@ fun _ ->
    Scanf.scanf "%d %d\n" @@ fun a b -> a - 1, b - 1 in
  let succ = Array.make n [] in
  Array.iter (fun (a, b) ->
    succ.(a) <- b :: succ.(a);
    succ.(b) <- a :: succ.(b)) abs;
  let colour = Array.make n None in
  let rec dfs c v =
    match colour.(v) with
    | None -> colour.(v) <- Some c; List.iter (dfs (not c)) succ.(v)
    | Some c' -> if c <> c' then raise Not_found in
  try
    dfs true 0;
    Printf.printf "%d\n" @@
      List.length (List.filter (( = ) (Some true)) (Array.to_list colour)) *
      List.length (List.filter (( = ) (Some false)) (Array.to_list colour)) - m
  with Not_found -> Printf.printf "%d\n" (n * (n - 1) / 2 - m)


Measured memory_bytes: 19072
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1e9+7
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 long long int gcd(long long int m,long long int n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
long long int lcm(long long int number1,long long int number2){
	return number1 * number2 / gcd(number1,number2);	
}
int main(){
  ll N;
  cin>>N;
  
  vector<ll>A(N);
  vector<ll>B(N);
  vector<ll>C(N);
  vector<ll>mid(N);
  vector<ll>down(N);
  rep(i,N){
    cin>>A[i];
  }
  rep(i,N){
    cin>>B[i];
  }
  rep(i,N){
    cin>>C[i];
  }
  
sort(all(A));
  sort(all(B));
  sort(all(C));
  
  ll ans=0;
  
  rep(i,N){
 ll m=C.end()-upper_bound(C.begin(),C.end(),B[i]);//CのうちBより大きいものの数
 ll n=lower_bound(A.begin(),A.end(),B[i])-A.begin();//Bより小さいAの数
    
    ans+=m*n;
    

}
  
  cout<<ans<<endl;
  
}

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

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(b<=c||d<a)cout << 0 << endl;
    else cout << min({abs(a-d),abs(b-c),abs(a-b),abs(c-d)}) << endl;
}

Measured memory_bytes: 256
from heapq import heappop, heappush
X,Y,Z,K = map(int, input().split())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
memo = []
Q = []
Q.append((-(A[0]+B[0]+C[0]),0,0,0))
memo.append((0,0,0))
count = 1

while count <= K:
  p,i,j,k = heappop(Q)
  print(-p)
  count += 1
  if (i+1,j,k) not in memo and i+1<X:
    heappush(Q,(-(A[i+1]+B[j]+C[k]),i+1,j,k))
    memo.append((i+1,j,k))
  if (i,j+1,k) not in memo and j+1<Y:
    heappush(Q,(-(A[i]+B[j+1]+C[k]),i,j+1,k))
    memo.append((i,j+1,k))
  if (i,j,k+1) not in memo and k+1<Z:
    heappush(Q,(-(A[i]+B[j]+C[k+1]),i,j,k+1))
    memo.append((i,j,k+1))
    

Measured memory_bytes: 4468
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mod_) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod_;
		}
		x = x * x % mod_;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}
/*--------Library Zone!--------*/

int n, ka[114514];
void init() {
	ka[0] = 1;
	REP(i, 114514)ka[i] = ka[i - 1] * i % mod;
}
int comb1(int x, int y) {
	if (y > x)return 0;
	return ka[x] * mod_pow(ka[x - y], mod - 2, mod) % mod * mod_pow(ka[y], mod - 2, mod) % mod;
}
signed main() {
	cin >> n;
	init();
	vector<P>v;
	rep(i, n + 1) {
		int a; cin >> a; v.push_back({ a,i });
	}
	sort(all(v));
	int l, r;
	rep(i, n) {
		if (v[i].first == v[i + 1].first) {
			l = v[i].second; r = v[i + 1].second;
			break;
		}
	}
	int k = l + (n - r);
	REP(i, n + 2) {
		cout << (comb1(n + 1, i) - comb1(k, i - 1) + mod) % mod << endl;
	}
}


Measured memory_bytes: 3824
#include <bits/stdc++.h>
using namespace std;
const int MOD=998244353;
int main(){
  int N,S,ans=0,dp[3001][3001];
  cin>>N>>S;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i);
  }
  dp[0][0]=1;
  for(int i=1;i<=N;i++){
    for(int j=0;j<=S;j++){
      dp[i][j]=dp[i-1][j];
      if(j-A.at(i-1)>=0)dp[i][j]+=dp[i-1][j-A.at(i-1)];
      dp[i][j]%=MOD;
    }
    dp[i][0]++;
    ans+=dp[i][S];
    ans%=MOD;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 38812
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

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

typedef long long ll;
#define rep(i, start, end) for(int i = start; i < end; ++i)
#define sz(x) (int)(x).size()
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(d, v) memset(d, v, sizeof(d))
#define pii pair<int, int>
const double PI = 3.14159265358979323846;
const double eps = (1e-8);


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
#ifndef ONLINE_JUDGE
 //   freopen("input.txt", "r", stdin);
//    freopen("facebook.txt", "w", stdout);
#endif
    int n;
    cin >> n;
    int g;
    cin >> g;
    rep(i, 1, n)
    {
        int x;
        cin >> x;
        g = __gcd(g, x);
    }
    cout << g;
    return  0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a;
  cin >> a;
  string b="Christmas",c=" Eve";
  if (a==25){
    cout << b << endl;
  }
  if (a==24){
    cout << b << c << endl;
  }
  if (a==23){
    cout << b << c << c << endl;
  }
  if (a==22){
    cout << b << c << c << c << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mem(a, b) memset(a, (b), sizeof(a))
#define fore(i,a) for(int i=0;i<a;i++)
#define fore1(i,j,a) for(int i=j;i<a;i++)
#define print(ar) for(int i=0;i<ar.size();i++)cout<<ar[i]<<" ";
#define END cout<<'\n'
const double pi=acos(-1.0);
 
typedef pair<int, int> PII;
 
typedef vector<long long> VI;
 
typedef vector<string> VS;
 
typedef vector<PII> VII;
 
typedef vector<VI> VVI;
 
typedef map<int,int> MPII;
 
typedef set<int> SETI;
 
typedef multiset<int> MSETI;
 
typedef long int li;
 
typedef unsigned long int uli;
 
typedef long long int ll;
 
typedef unsigned long long int  ull;
ll fastexp (ll a, ll b, ll n) {
  ll res = 1;
  while (b) {
      if (b & 1) res = res*a%n;
      a = a*a%n;
      b >>= 1;
  }
  return res;
}
void fast(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
//VI vect[2020202];
int main()
 {  fast();
	int t, n, k;

	    cin >> n;
	    VI arr(n,0);
	    	   map<ll,ll> mp;
	    fore(i,n){cin>>arr[i];mp[i+1-arr[i]]++;}
	    //vector<vector<ll>> vect(n,)
	   //cout<<n<<endl;
     ll cnt=0;
	   fore(i,n){
	       cnt+=mp[arr[i]+i+1];
	   }
	   
	    cout<<cnt<<endl;}
	  
	

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

int main(){
    int w,h,n;
    cin>>w>>h>>n;
    int x,y,a;
    int p=0,q=w,r=0,s=h;
    for(int i=0;i<n;i++){
        cin>>x>>y>>a;
        if(a==1) p=max(p,x);
        if(a==2) q=min(q,x);
        if(a==3) r=max(r,y);
        if(a==4) s=min(s,y);
        
    }
    cout<<max(0,q-p)*max(0,s-r) <<endl;
}


Measured memory_bytes: 256
n, a, b = map(int, input().split())

ans = 0

for i in range(1, n + 1):
    digit = i
    digit_sum = 0
    while digit > 0:
        digit_sum += digit % 10
        digit = digit // 10

    if digit_sum >= a and digit_sum <= b:
        ans += i

print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include <algorithm>
#include <string>
#include<math.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
int main() {
    string s;
    cin >> s;
    s[3] = '8';
    cout << s << endl;
    return 0;
}

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


int main(){
  long N,X,M;
  std::cin >> N >> X >> M;
  long table[100000]={};
  std::vector<long> P;
  long now=X;
  while(table[now]==0){
    P.push_back(now);
    table[now]=1;
    now=(now*now)%M;
  }
  long end=P.size();
  long tip=now;
  long start;

  for(long i=0; i<P.size(); i++){
    if(P[i]==tip){
      start=i;
      break;
    }
  }
  long loop=0;
  for(long i=start; i<end;i++){
    loop+=P[i];
  }
  
  long loop_num = (N-(start))/(end-start);

  long result=0;
  for(long i=0; i<start; i++){
    result+=P[i];
  }
  result+=loop_num*loop;
  for(long i=start; i<start+(N-start)%(end-start);i++){
    result+=P[i];
  }
  std::cout << result << std::endl;
  return 0;
}

Measured memory_bytes: 4124
#include <iostream>
#include <map>
#include <queue>

#define MAX_N 100000

int N;
std::map<long, int> mp;
std::priority_queue<long> que;

long solve() {
    int  cnt = 2;
    long h = 0, w = 0;
    while (!que.empty() && (h == 0 || w == 0)) {
        while (!que.empty() && mp[que.top()] < 2) que.pop();
        if (que.empty()) break;
        long tmp = que.top();
        que.pop();
        if (mp[tmp] > 3) {
            if (h == 0) {
                h = tmp;
                w = tmp;
            }
            w = tmp;
        } else {
            if (h == 0) h = tmp;
            else w = tmp;
        }
    }
    return h*w;
}

int main() {
    std::cin >> N;
    for (int i=0; i<N; ++i) {
        long tmp;
        std::cin >> tmp;
        if ( mp.find(tmp) == mp.end() ) {
            // not found
            mp[tmp] = 1;
            que.push(tmp);
        } else {
            ++mp[tmp];
        }
    }

    std::cout << solve() << std::endl;

    return 0;
}

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

/*
dreamとdreamerのように、前から読むと6番目まで違いが分からない(prefix)。
後ろから読めば早い段階で違いが分かるので、各stringをreverseして比較する。
*/

int main() {
  string s;
  cin >> s;
  vector<string> options = {"dream", "dreamer", "erase", "eraser"};
  
  reverse(s.begin(), s.end());
  for (int i = 0; i < 4; i++) reverse(options.at(i).begin(), options.at(i).end());
  
  bool divisible = true;
  for (int i = 0; i < (int)s.size();) {
    bool p_divisible = false;
    for (string c : options) {
      // sのi番目からc.size要素までがoptionsのどれかと一致したら、
      // フラッグを立てc.size文字分進める
      if (s.substr(i, c.size()) == c) {
        p_divisible = true;
        i += c.size();
      }
    }
    if (!p_divisible) {
      divisible = false;
      break;
    }
  }
 
  cout << (divisible ? "YES" : "NO") << endl;
}

Measured memory_bytes: 3740
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		String a = stdIn.next();
		
		if (a.charAt(0) == a.charAt(1) && a.charAt(1) == a.charAt(2)) { 
			System.out.println("Yes");
		} else if (a.charAt(1) == a.charAt(2) && a.charAt(2) == a.charAt(3)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    ll N;
    cin >> N;
    queue<ll> qu[1010];
    REP(i, N){
    	REP(j, N-1){
    		ll tmp;
    		cin >> tmp;
    		tmp--;
    		qu[i].push(tmp);
    	}
    }

    ll nokori = N*(N-1);
    ll prev_nokori;
    ll res = 0;
    while(nokori > 0){
    	//dump(nokori)
    	prev_nokori = nokori;
    	vector<bool> check(N, false);
    	REP(i, N){
    		if(check[i]) continue;
    		if(qu[i].empty()) continue;
    		ll aite = qu[i].front();
    		ll aiteaite = qu[aite].front();
    		if(!check[aite] && aiteaite == i){
    			check[i] = true;
    			check[aite] = true;
    			qu[i].pop();
    			qu[aite].pop();
    			nokori -= 2;
    		}
    	}
    	res++;
    	if(prev_nokori == nokori){
    		cout << -1 << endl;
    		return 0;
    	}
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 9856
#include <bits/stdc++.h>
using namespace std;
using LL = long long; using PII = pair<LL, LL>; using VI = vector<LL>; using VVI = vector<VI>;
using VB = vector<bool>; using VS = vector<string>; using VP = vector<PII>;
#define VV(T)        vector<vector<T>>
#define PB           push_back
#define MP           make_pair
#define SZ(a)        LL((a).size())
#define EACH(x, c)   for (auto x : (c))
#define ALL(c)       (c).begin(), (c).end()
#define REVERSE(c)   reverse(ALL(c))
#define SORT(c)      stable_sort(ALL(c))
#define RSORT(c)     stable_sort((c).rbegin(), (c).rend())
#define FOR(i, a, b) for (LL i = (a); i < (b); ++i)
#define REP(i, n)    FOR(i, 0, n)
#define $(x)         {cout << #x << " = " << (x) << endl;}


void solve(long long N, std::vector<long long> d){
    SORT(d);
    LL left = d[SZ(d) / 2 - 1], right = d[SZ(d) / 2];
    cout << right - left << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> d(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&d[i]);
    }
    solve(N, std::move(d));
    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define MAX_N 10000
#define INF 1e9

using namespace std;

typedef int long long ll;
typedef int long l;
typedef pair<int, int> Pii;
const ll MOD = 1000000007;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b, n;
    cin >> a >> b >> n;
    if (b == 1) {
        cout << 0 << endl;
        return 0;
    }
    if (n >= b) {
        cout << (ll)((double)a / b * (b - 1)) << endl;
    } else {
        cout << (ll)((double)a / b * n) << endl;
    }
    return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  int h,w;
  cin>>h>>w;
  vector<string> as(h);
  for(int i=0;i<h;i++) cin>>as[i];

  vector<string> rs(as),bs(as);
  for(int i=0;i<h;i++){
    rs[i][0]='#';
    bs[i][w-1]='#';
    for(int j=1;j+1<w;j++){
      ((i&1)?rs[i][j]:bs[i][j])='#';
    }
  }

  for(string s:rs) cout<<s<<endl;
  cout<<endl;
  for(string s:bs) cout<<s<<endl;
  return 0;
}


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

int main(){
    int x, a, b;
    cin >> x >> a >> b;
    char L, M;
    if (a > b){
        L = 'A';
        M = 'B';
    }
    else{
        L = 'B';
        M = 'A';
    }
    if (2*x > a + b){
        cout << L << endl;
    }
    else{
        cout << M << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

#define MAX 100000

typedef struct {
  char name[10];
  int time;
}Roll;

void enqueue(Roll);
Roll dequeue(void);

 Roll data[MAX];
int head=0,tail=0;

int main(){
  int n,q,i,sumtime;
  Roll input,output;
 
  scanf("%d%d",&n,&q);
  for(i=1;i<=n;i++){
    scanf("%s%d",input.name,&input.time);
    enqueue(input);
  }
  while(head!=tail){
    if((data[head].time-q)<=0){
      output=dequeue();
      sumtime+=output.time;
      printf("%s %d\n",output.name,sumtime);
    } else {
      output=dequeue();
      sumtime+=q;
      output.time-=q;
      enqueue(output);
    }
  }

  return 0;
}
      

void enqueue(Roll p){
  data[tail]=p;
  tail=(tail+1)%MAX;
}

Roll dequeue(void){
  Roll p;
  p=data[head];
  head=(head+1)%MAX;
  return p;
}
    


Measured memory_bytes: 3288
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <complex>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <cassert>
#include <fstream>
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define SSTR( x ) static_cast< std::ostringstream & >( \
        ( std::ostringstream() << std::dec << x ) ).str()
#define ALL(s) (s).begin(), (s).end()
using namespace std;
typedef long long unsigned int llu;
typedef long long ll;


int main (){
  int N;
  while (cin >> N){
    vector<int> a;
    REP(i,N){
      int ia;
      cin >> ia;
      a.push_back(ia);
    }

    int cnt = 0;
    REP(i,N){
      int minj = i;
      FOR(j,i,N){
	if(a[j] < a[minj]) minj = j;
      }
      if(i!=minj){
	swap(a[i],a[minj]);
	cnt++;
      }
    }

    REP(i,N-1){
      cout << a[i] << " ";
    }
    cout << a[N-1] << endl;
    cout << cnt << endl;
  }
  return 0;
}



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

int main()
{
	queue<string> name; queue<int> time;
	string ret1; int n, q, ret2, sumt = 0;
	cin >> n >> q;
	for(int i = 0; i < n; i++) {
		cin >> ret1 >> ret2;
		name.push(ret1); time.push(ret2); 
	}

	while(!time.empty()){
		ret1 = name.front(); name.pop();
		ret2 = time.front(); time.pop();
		if(q >= ret2){
			sumt += ret2;
			cout << ret1 << " " << sumt << endl;
		}
		else{
			ret2 -= q;
			sumt += q;
			name.push(ret1); time.push(ret2);
		}
	}

}

Measured memory_bytes: 4176
// Problem : C - : (Colon)
// Contest : AtCoder - AtCoder Beginner Contest 168
// URL : https://atcoder.jp/contests/abc168/tasks/abc168_c
// Memory Limit : 1024.000000 MB 
// Time Limit : 2000.000000 milisec 
// Powered by CP Editor (https://github.com/coder3101/cp-editor2)
double PI = 3.141592653589;
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define REP(i,n) for (ll i = 0; i < n; i++)
#define REPR(i,n) for(ll i = n-1; i >= 0; i--)
#define FOR(i,a,b) for (ll i = a; i < b; i++)
#define FORR(i,a,b) for(ll i = a-1; i>= b; i--)
#define ff first
#define ss second
#define MAXN (ll)1000002
#define MODN (ll)1000000007
#define mp make_pair
#define pb push_back
#define LN(x) (ll)x.length()
#define SZ(x) (ll)x.size()
#define bg(x) (x.begin())
#define rbg(x) (x.rbegin())
#define ENDL cout<<endl
ll n,t=1,tmp;
int main() {
    ll a,b,h,m;
	cin>>a>>b>>h>>m;
	double ah,am,dx,dy;
	ah= (60*h+m)/(2.);
	am=m*6;
	dx=a*cos((ah*PI)/180) - b*cos((am*PI)/180);
	dy=a*sin((ah*PI)/180) - b*sin((am*PI)/180);
	 cout << fixed << setprecision(12) << sqrt((dx*dx+dy*dy)) << endl; 
}


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

int main(){
    int a, b;
    char op;
    
    while(1){
        cin >> a >> op >> b;
        
        if(op == '+') cout << a+b << endl;
        else if(op == '-') cout << a-b << endl;
        else if(op == '*') cout << a*b << endl;
        else if(op == '/') cout << a/b << endl;
        else break;
    }
    
    return 0;
}


Measured memory_bytes: 3112
/************************************************************LET US BREAK BAD!****************************************************************/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define ld long double
#define pb push_back
#define pll pair<ll, ll> 
#define vi vector<int>
#define vl vector<ll> 
#define vvl vector< vector<ll> > 
#define vvi vector< vector<int> >
#define vlp vector< pair<ll, ll> >
#define vllp vector<pair<ll, ll>, ll > 
#define mll map<ll, ll> 
#define rep(i,a)  for(ll i=0; i< a; i++)
#define rep1(i,a)   for(ll i = 1; i< a; i++)
#define foi(i, a, b)    for(ll i = a; i<b ; i++)
#define fod(i, a, b)    for(ll i = a; i>=b ; i--)
#define mp make_pair
#define fst first
#define sec second
#define ff first.first
#define fs first.second
#define pi pair<int, int>
#define ppi pair<pair<int, int>, int>
#define max3(a, b, c)   max(max(a, b), c)
#define min3(a, b, c)   min(min(a, b), c)
#define MAX 1000001
#define MOD 1000000007
// #define MOD 998244353
#define endl "\n"
#define INF (ll)1e18
#define s(v) v.size()
#define e(v) v.empty()
#define bscount(x) __builtin_popcountll(x)
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

using namespace std;
using namespace __gnu_pbds;

ll gcd(ll a, ll b){if(b==0)return a;return gcd(b, a%b);}
ll lcm(ll a, ll b){return a*b/gcd(a, b);}
ll fexp(ll a, ll b){ll ans = 1;while(b){if(b&1) ans = ans*a%MOD; b/=2;a=a*a%MOD;}return ans;}
ll inverse(ll a, ll p){return fexp(a, p-2);} 
void ingraph(vvl& graph, ll m){ll x, y;rep(i, m){cin>>x>>y;x--, y--;graph[x].pb(y);graph[y].pb(x);}}
ll modify(ll n){ll res = n;res%=MOD;res+=MOD;res%=MOD;return res;}

int main(){
    //#ifndef ONLINE_JUDGE
    //    freopen("../input.txt", "r", stdin);
    //    freopen("../output.txt", "w", stdout);
    //#endif
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    ll t;
    // cin>>t;
    t = 1;
    while(t--){
        ll n;
        cin>>n;
        vl a(n);
        rep(i, n){
            cin>>a[i];
        }
        vl pre(n, 0);
        pre[0] = a[0];
        rep1(i, n){
            pre[i] = max(pre[i-1], a[i]);
        }
        ll ans = 0;
        rep(i, n){
            ans+=pre[i]-a[i];
        }
        cout<<ans<<endl;
    }
return 0;
}


Measured memory_bytes: 6364
import copy ; import sys ; sys.setrecursionlimit(11451419)
n=int(input())
HEN=[list(map(int,input().split())) for _ in range(n-1)]
G=[[] for _ in range(n)]
for i,[a,b] in enumerate(HEN):
    a=a-1;b=b-1
    G[a].append([b,i])
    G[b].append([a,i])  #Gに、道番号も記録

visited=[0 for i in range(n)]
ans=[-1 for i in range(n-1)]

def search(v,c=-1):  #search(a)ならaと-1  search(a,b)ならaとb
    nc=1
    for to,i in G[v]:
        if visited[to]==1: continue
        visited[v]=1
        if c==nc:
            nc+=1
        ans[i]=nc
        search(to,nc)
        nc+=1
search(0)
print(max(ans))
print(*ans,sep="\n")

Measured memory_bytes: 101500
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define ll2(x, y) ll x, y; cin >> x >> y;
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define endl "\n"
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << (x) << "\n"
#define debug2(x, y) cout << " --- " << (x) << " " << (y) << "\n"
#define debug3(x, y, z) cout << " --- " << (x) << " " << (y) << " " << (z) << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)

string be = " ',-.?ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string lis[32];
string af = "ABCDEFGHIJKLMNOPQRSTUVWXYZ .,-'?";
string f(int x){
  string res;
  res.resize(5);
  int i;
  per(i, 5){
    res[i] = '0' + (x % 2);
    x /= 2;
  }
  return res;
}

signed main(void){
  int i, j;
  lis[0] = "101";
  lis[1] = "000000";
  lis[2] = "000011";
  lis[3] = "10010001";
  lis[4] = "010001";
  lis[5] = "000001";
  lis[6] = "100101";
  lis[7] = "10011010";
  lis[8] = "0101";
  lis[9] = "0001";
  lis[10] = "110";
  lis[11] = "01001";
  lis[12] = "10011011";
  lis[13] = "010000";
  lis[14] = "0111";
  lis[15] = "10011000";
  lis[16] = "0110";
  lis[17] = "00100";
  lis[18] = "10011001";
  lis[19] = "10011110";
  lis[20] = "00101";
  lis[21] = "111";
  lis[22] = "10011111";
  lis[23] = "1000";
  lis[24] = "00110";
  lis[25] = "00111";
  lis[26] = "10011100";
  lis[27] = "10011101";
  lis[28] = "000010";
  lis[29] = "10010010";
  lis[30] = "10010011";
  lis[31] = "10010000";

  for(int testcase = 0;testcase >= 0;testcase++){

    string s, rmn;
    for(;getline(cin, s);){
      rmn = "";
      rep(i, s.size()){
        rep(j, be.size())if(s[i] == af[j]){
          rmn += f(j);
          break;
        }
      }
      rmn += "        ";

      for(i = 0;i < rmn.size();){
        rep(j, 32)if(rmn.substr(i, lis[j].size()) == lis[j]){
          cout << be[j];
          i += lis[j].size();
          break;
        }
        if(j == 32)break;
      }

      kara;
      s.clear();
    }


/*/

//*/ break;
  }
  return 0;
}

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

typedef long long int   ll;
typedef pair<ll, ll>    pll;
typedef pair<int, int>  pii;

#define all(x)          x.begin(), x.end()
#define kill(x)         return cout << x << endl, 0
#define X               first
#define Y               second
#define sep             ' '
#define endl            '\n'

ll pw(ll a, ll b, ll mod) {
    if (!b)    return 1;
    if (b & 1) return a * pw(a * a % mod, b / 2, mod) % mod;
    return pw(a * a % mod, b / 2, mod) % mod;
}

const ll N    = 3e5 + 10;
const ll MOD  = 1e9 + 7;
const ll INF  = 1e18;

int n, A[N], ind[N], ans[N], timer;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> A[i]; A[i]--;
        ans[A[i]] = i + 1;
        ind[i] = i;
    }
    sort(ind, ind + n, [] (int i, int j) { return A[i] < A[j]; });
    for (int i = 0; i < n; i++) {
        int u = ind[i];
        for (int j = 0; j < u; j++) {
            while (timer < n * n && ans[timer])
                timer++;
            if (timer > A[u])
                kill("No");    
            ans[timer] = u + 1;
        }
    }
    timer = n * n - 1;
    for (int i = n - 1; i >= 0; i--) {
        int u = ind[i];
        for (int j = u; j < n - 1; j++) {
            while (timer >= 0 && ans[timer])
                timer--;
            if (timer < A[u])
                kill("No");
            ans[timer] = u + 1;
        }
    }
    cout << "Yes" << endl;
    for (int i = 0; i < n * n; i++) {
        cout << ans[i] << sep;
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 4628
class COM:
    def __init__(self, n: int, mod: int):
        self.n = n
        self.mod = mod
        self.fact = [0] * (n + 1)
        self.factinv = [0] * (n + 1)
        self.inv = [0] * (n + 1)
        
        self.fact[0] = self.fact[1] = 1
        self.factinv[0] = self.factinv[1] = 1
        self.inv[1] = 1
        for i in range(2, n + 1):
            self.fact[i] = (self.fact[i - 1] * i) % mod
            self.inv[i] = (-self.inv[mod % i] * (mod // i)) % mod
            self.factinv[i] = (self.factinv[i - 1] * self.inv[i]) % mod
    
    def get_cmb(self, n: int, k: int):
        if (k < 0) or (n < k):
            return 0
        k = min(k, n - k)
        return self.fact[n] * self.factinv[k] % self.mod * self.factinv[n - k] % self.mod


def solve():
    n, k = map(int, input().split())
    MOD = 10 ** 9 + 7
    
    com = COM(n, MOD)
    ans = 0
    for i in range(min(n, k + 1)):
        ans += com.get_cmb(n, i) * com.get_cmb(n - 1, i)
        ans %= MOD
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 46064
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<(n);i++)
#define Rep(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define eb emplace_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

int f(int x){
    return x==1?300000:x==2?200000:x==3?100000:0;
}

void run(){
    int x,y;
    cin>>x>>y;
    int ans=f(x)+f(y)+(x+y==2?400000:0);
    cout<<ans<<endl;
}

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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repp(i, n, m) for(int (i) = (n); (i) < (m); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define ldou long double
#define fi first
#define se second
#define setpre(x) std::cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ std::cout << " [LOGGER] " << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , "; logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 200005;

/* ...o(^-^)o... */

int main(){
    int n,k; cin>>n>>k;
    int r,s,p; cin>>r>>s>>p;
    string t; cin>>t;
    vector<bool> f(n);
    int res = 0;
    rep(i,n){
        if(i>=k && t[i]==t[i-k] && f[i-k]) continue;
        if(t[i]=='r') res += p;
        else if(t[i]=='s') res += r;
        else res += s;
        f[i] = true;
    }
    out(res);
}

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

int main(void){
    string w;
    cin>>w;
    vector<int> n(26,0);
    for (int i=0;i<w.size();i++){
        n[(w[i]-'a')]++;
    }
    bool ans=true;
    for (int i=0;i<26;i++){
        if (n[i]%2) ans=false;
    }
    if (ans) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
     
    #define f(i,a,b) for(  ll i = a; i < b ; i++ ) 
    #define af(i,a,b) for( ll i = a; i >= b ; i--)
    #define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
    #define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
    #define ones(x) (ll) __builtin_popcount(x);
    #define fs first
    #define sc second
    #define pb push_back
    #define mp make_pair
    #define sz(a) (ll) a.size()
    #define all(a) a.begin(), a.end()
    #define sor(a) sort( a.begin(), a.end() )
    #define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
    #define inter ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
     
    #define PI acos(-1)
     
    using namespace std;
     
    typedef long long ll;
    typedef long double ld;
    typedef pair<ll,ll> ii ;
    typedef vector<ll>  vi ;
    typedef vector<ii> vii ;
     
    const ll MAX = 1e3+12;
    const ll inf = 5e18;
     
     
    int main(){
    	fastio;
    	ll tc,n,m;
    //	cin>>tc;
    	tc=1;
    	string s;
    	f(tt,1,tc+1){
    		cin>>s;
    		bool go=false;
    		f(i,0,3)
    			if(s[i]=='7') go=true;
    		cout<< (go? "Yes\n":"No\n");
    	}
     
    }

Measured memory_bytes: 3648
def solve(v)
  sum = v
  9.times{|t|
    if t % 2 == 0
      v *= 2.to_f
    else
      v /= 3.to_f
    end
    sum += v
  }
  return sum
end

while input = $stdin.gets
  p solve(input.to_f)
end

Measured memory_bytes: 6112
#include "bits/stdc++.h"
using namespace std;typedef long long lint;typedef vector<lint> liv;
//#define rep(i,n) for(int i=0;i<n;++i)
#define all(v) v.begin(),v.end()
#define linf 1152921504606846976
#define MAXN 100010
#define md 1000000007//998244353

#define _vcppunko4(tuple) _getname4 tuple
#define _getname4(_1,_2,_3,_4,name,...) name
#define _getname3(_1,_2,_3,name,...) name
#define _trep2(tuple) _rep2 tuple
#define _trep3(tuple) _rep3 tuple
#define _trep4(tuple) _rep4 tuple
#define _rep1(n) for(lint i=0;i<n;++i)
#define _rep2(i,n) for(lint i=0;i<n;++i)
#define _rep3(i,a,b) for(lint i=a;i<b;++i)
#define _rep4(i,a,b,c) for(lint i=a;i<b;i+=c)
#define _trrep2(tuple) _rrep2 tuple
#define _trrep3(tuple) _rrep3 tuple
#define _trrep4(tuple) _rrep4 tuple
#define _rrep1(n) for(lint i=n-1;i>=0;i--)
#define _rrep2(i,n) for(lint i=n-1;i>=0;i--)
#define _rrep3(i,a,b) for(lint i=b-1;i>=a;i--)
#define _rrep4(i,a,b,c) for(lint i=a+(b-a-1)/c*c;i>=a;i-=c)
template<class T>
istream& operator>>(istream& is,vector<T>& vec);
template<class T,size_t size>
istream& operator>>(istream& is,array<T,size>& vec);
template<class T,class L>
istream& operator>>(istream& is,pair<T,L>& p);
template<class T>
ostream& operator<<(ostream& os,vector<T>& vec);
template<class T,class L>
ostream& operator<<(ostream& os,pair<T,L>& p);
template<class T>
istream& operator>>(istream& is,vector<T>& vec){ for(T& x: vec) is>>x;return is; }
template<class T,class L>
istream& operator>>(istream& is,pair<T,L>& p){ is>>p.first;is>>p.second;return is; }
//template<class T>
//ostream& operator<<(ostream& os,vector<T>& vec){ os<<vec[0];rep(i,1,vec.size())os<<' '<<vec[i];return os; }
//template<class T>
//ostream& operator<<(ostream& os,deque<T>& deq){ os<<deq[0];rep(i,1,deq.size())os<<' '<<deq[i];return os; }
template<class T,class L>
ostream& operator<<(ostream& os,pair<T,L>& p){ os<<p.first<<" "<<p.second;return os; }

inline void in(){}
template <class Head,class... Tail>
inline void in(Head&& head,Tail&&... tail){ cin>>head;in(move(tail)...); }
template <class T>
inline bool out(T t){ cout<<t<<'\n';return 0; }
inline bool out(){ cout<<'\n';return 0; }
template <class Head,class... Tail>
inline bool out(Head head,Tail... tail){ cout<<head<<' ';out(move(tail)...);return 0; }

#define rep(...) _vcppunko4((__VA_ARGS__,_trep4,_trep3,_trep2,_rep1))((__VA_ARGS__))
#define rrep(...) _vcppunko4((__VA_ARGS__,_trrep4,_trrep3,_trrep2,_trrep1))((__VA_ARGS__))
#define lin(...) lint __VA_ARGS__;in(__VA_ARGS__)
#define stin(...) string __VA_ARGS__;in(__VA_ARGS__)
#define vin(type,name,size) vector<type> name(size);in(name)

int main(){
	lint x,y;cin>>x>>y;
	cout<<(abs(x-y)<=1?"Brown\n":"Alice\n");
}

//int main(int argc,char *argv[]){
//	string inp;
//	if(argc>1)inp=argv[1];
//	else return 0;
//
//	ifstream fin(inp);
//	lint in_n;fin>>in_n;
//	fin.close();
//
//	lint a,b;cin>>a>>b;
//
//	return a+b!=in_n;
//}

//sub-EOF


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

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

	int code = (int)'0';
	int c1 = (int)(s[0] - code) * 10 + (int)(s[1] - code);
	int c2 = (int)(s[2] - code) * 10 + (int)(s[3] - code);

	if (1 <= c1 && c1 <= 12) {
		if (1 <= c2 && c2 <= 12) {
			cout << "AMBIGUOUS" << endl;
		}
		else {
			cout << "MMYY" << endl;
		}
	}
	else {
		if (1 <= c2 && c2 <= 12) {
			cout << "YYMM" << endl;
		}
		else {
			cout << "NA" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int k = sc.nextInt();
    int s = sc.nextInt();

    int a = 0;
    for (int x = 0; x <= k; ++x) {
      for (int y = 0; y <= k; ++y) {
        if (s - x - y >= 0 && s - x - y <= k) {
          ++a;
        }
      }
    }
    System.out.println(a);
  }
}


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

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

    int a, b, c;
    cin >> a >> b >> c;

    int res;
    if(a+b >= c) res = b + c;
    else res = a + b + b + 1;

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int maxn = 5e5 + 5;
ll n, m, inv[maxn], fac[maxn], ans;
ll qpow(ll a, ll b) {
	ll ans = 1, base = a;
	while (b) {
		if (b & 1) ans = ans * base % MOD;
		b >>= 1, base = base * base % MOD;
	}
	return ans;
}
void init() {
	fac[0] = 1;
	for (int i = 1; i <= m; i++) fac[i] = fac[i - 1] * i % MOD;
	for (int i = 0; i <= m; i++) inv[i] = qpow(fac[i], MOD - 2);
}
ll A(ll a, ll b) {
	return fac[a] * inv[a - b] % MOD;
}
ll C(ll a, ll b) {
	return fac[a] * inv[b] % MOD * inv[a - b] % MOD;
}
int main() {
	cin >> n >> m;
	init();
	ans = qpow(A(m, n),2);
	for (ll s = 1; s <= n; s++) {
		ans -= (s & 1 ? 1 : -1) * C(n, s) * A(m, s) % MOD * qpow(A(m - s, n - s),2);
		ans%=MOD;
	}
	cout<<(ans+MOD)%MOD;
	return 0;
}


Measured memory_bytes: 11452