akhauriyash/Code-Regression huggingface dataset:
def main():
  a,b=map(int,input().split())
  
  import math
  def xorsum(n):
    if n%4==0:
      return n
    elif n%4==1:
      return 1
    elif n%4==2:
      return n+1
    else:
      return 0

  print(xorsum(b)^xorsum(a-1))
if __name__=='__main__':
  main()

Measured memory_bytes: 2940
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int n;
    cin>>n;
    int temp;
    vector<int> rt;
    for(int m = 0;m<n-1;m++){
       cin>>temp;
       rt.push_back(temp);
       cout<<temp<<" ";
    }
    cin>>temp;
    rt.push_back(temp);
    cout<<temp<<endl;
    int key;
    for(int i = 1;i<n;i++){
        key = rt[i];
        int j = i-1;
        while(j>=0&&rt[j]>key){
            rt[j+1] = rt[j];
            j--;
        }
        rt[j+1] = key;
        for (int m = 0;m<n-1;m++){
            cout<<rt[m]<<" ";
        }
        cout<<rt[n-1]<<endl;
    }
}



Measured memory_bytes: 3140
#include <bits/stdc++.h>
#include <iostream>
#include <cmath>
using ll = long long; 
using namespace std;
using vi =vector<int>;
using vvi = vector<vi>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  vvi bingo(3,vi(3));
  bool che[3][3];
  rep(i,3){
    rep(j,3){
      cin >> bingo[i][j];
      che[i][j] =false;
    }
  }
  int n; cin >>n;
  
  rep(k,n){
        int b; cin >>b;
    rep(i,3){
      rep(j,3){
        if(bingo[i][j] == b) che[i][j] = true;
      }
    }
  }
  rep(i,3){
    if((che[i][1]&&che[i][2]&&che[i][0]) || (che[0][i]&&che[1][i]&&che[2][i])){
      cout <<"Yes" <<endl; return 0;
    }
  }
  if((che[0][0]&&che[1][1]&&che[2][2]) || (che[0][2]&&che[1][1]&&che[2][0])){
    cout << "Yes" <<endl; return 0;
  }
  cout << "No" <<endl; return 0;
}


Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    s = input().rstrip()
    if s.count('o') >= 8-(15-len(s)):
        print('YES')
    else:
        print('NO')

if __name__ == '__main__':
    main()

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

#ifdef MYDEBUG
#define dbp(x) cout<<#x<<": "<<x<<endl
#define dbp2(x,y) cout<<#x<<","<<#y<<": "<<x<<","<<y<<endl
#define dbp3(x,y,z) cout<<#x<<","<<#y<<","<<#z<<": "<<x<<","<<y<<","<<z<<endl
#else
#define dbp(x)
#define dbp2(x,y)
#define dbp3(x,y,z)
#endif
#define ll long long
#define ull unsigned long long
#define eps 1e-14
#define all(x) x.begin(), x.end()
#define rep(i, from, to) for(int i=from; i<to; ++i)

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
  out << "[";
  size_t last = v.size() - 1;
  for (size_t i = 0; i < v.size(); ++i) {
    out << v[i];
    if (i != last)
      out << ",";
  }
  out << "]";
  return out;
}

void solve() {
  int x, y;
  cin >> x >> y;
  int t[13] = { 0, 10, 2, 10, 4, 10, 4, 10, 10, 4, 10, 4, 10 };
  if (t[x] == t[y]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

int main() {
  solve();
  return 0;
}


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

using namespace std;

int N, M, H[mxn];
vector<int> V[mxn];

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

    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);

    cin >> N >> M;
    for (int i = 1; i <= N; i++)
        cin >> H[i];
    
    int a, b;
    while (M--){
        cin >> a >> b;
        V[a].push_back(b);
        V[b].push_back(a);
    }

    bool good;
    a = 0;
    for (int i = 1; i <= N; i++){
        good = true;
        for (auto v: V[i]){
            if (H[i] > H[v]) continue;
            good = false;
        }
        a += good;
    }
    cout << a << "\n";
    
    return 0;
}

Measured memory_bytes: 9184
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
//var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
namespace AtCoderSolve
{
    class Solve
    {
        const int mod = 1000000007;
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            string s = Console.ReadLine();
            string ans = "AC";
            if (s[0] != 'A')
            {
                ans = "WA";
            }
            int cnt = 0;
            for(int i = 1; i < s.Length; i++)
            {
                if (i == 1)
                {
                    if (!char.IsLower(s[i])) { ans = "WA"; }
                }
                else if (i >= 2 && i < s.Length - 1)
                {
                    if (s[i]=='C')
                    {
                        cnt++;
                    }
                    else
                    {
                        if (!char.IsLower(s[i]))
                        {
                            ans = "WA";
                        }
                    }
                }
                else { if (!char.IsLower(s[i])) { ans = "WA"; } }
            }
            if (cnt != 1) { ans = "WA"; }

            Console.WriteLine(ans);


            Console.Out.Flush();
        }
    }
    


    public class Calculation
    {

    }

    public class Graph
    {

    }
}
    

Measured memory_bytes: 11092
//FIRST THINK THEN CODE.

#include <bits/stdc++.h>
 
 
using namespace std;
 
typedef long long ll;
 
//#define MOD 998244353
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define FOR(i,n)  for(ll i=0;i<n;i++)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()
#define endl "\n"
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define popcount(x) __builtin_popcountll(x)

const int M=1000000007;
const int MM=998244353;


 
ll newmod(ll a,ll b)
 {
  return ((a%b)+b)%b;
}
 
 
ll powM(ll a,ll b,ll m )
{ 
  if(m<=1)return 0;
  a%=m;
  ll ans=1LL;
  while(b)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }
 
return ans;
}


 
ll poww(ll a,ll b)
{ 
  
  ll ans=1;
  while(b)
  {
    if(b&1)ans=ans*a;
    a=a*a;
    b>>=1;
  }
 
return ans;

}

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

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

const ll N=1e5+5;

ll sp[N];

void fill(){
  for(int i=1;i<N;i++)sp[i]=i;

    for(int i=2;i<N;i++){
      for(int j=i;j<N;j+=i){
        if(sp[j]==j)sp[j]=i;
      }
    }
}

//vl f(N);


int main()
{ 

IOS;

ll n;cin>>n;

ld ans;

if(n&1){

ans=((n+1)/2)/(1.0*n);

}

else {
  ans=0.5;
}

cout<<fix(ans,6);



return 0;
 
}


Measured memory_bytes: 3760
from collections import Counter

N, A = map(int, input().split())
input_list = [int(i) - A for i in input().split()]

ans = Counter([0, input_list[0]])

for i in input_list[1:]:
    temp = Counter()
    for key, value in ans.items():
        temp[i + key] += value
    ans += temp

print(ans[0] - 1)


Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define INF 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define req(i, j, n) for(int i = j; i <= (int)(n); i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main() {
ll h,n;
  cin>>h>>n;
  
  pair<ll, ll> a[n+1];
  for(int i=1;i<=n;i++){
    cin>>a[i].first;
    cin>>a[i].second;}
  
  sort(a+1, a+n+1, greater<pair<ll, ll>>());
    
  ll dp[h+1];
  for(int i=1;i<=h;i++){
      dp[i]=9999999999;}
  dp[0]=0;
  
    
  for(int i=1;i<=h;i++){
    for(int j=1;j<=n;j++){
      ll p=a[j].first;
      ll q=a[j].second;
      if(i-p<0 && i!=h){
        continue;}
      ll t=i-p;
      if(i!=h){
      if(dp[i]>dp[t]+q){
        dp[i]=dp[t]+q;}
      }
      if(i==h){
        if(i-p<0){
          dp[h]=min(dp[h], q);
        continue;}
        for(int k=1;k<=h-1;k++){
          if(k+p>=h){
            dp[h]=min(dp[h], dp[k]+q);}
                      }
      }
      
    }
  }
        
        
  
  cout<<dp[h]<<endl;
  return 0;
    
    
  
  

}


Measured memory_bytes: 384
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
 
		int n = Integer.parseInt(sc.next());
		int r = Integer.parseInt(sc.next());
		
		if(n >= 10) {
			System.out.println(r);
		}else {
			r = r + (100 * (10 - n));
			System.out.println(r);		}
		
		
		
	
	}
 
 
 
}

Measured memory_bytes: 21716
N,L=map(int,input().split())

sum_ans=0
eat_ans=10000
flag=10000
for i in range(N):
	sum_ans+=L+i
	eat_ans=min(abs(eat_ans),abs(L+i))
	if eat_ans==abs(L+i):
		if L+i<0:
			flag=-1
		if L+i==0:
			flag=0
		if L+i>0:
			flag=1

print(sum_ans-eat_ans*flag)

Measured memory_bytes: 38384
import sys

use_clipboard=True
bbn=1000000007
	
#+++++

		
def main():
	h, n = map(int, input().split())
	ii=[]
	for i in range(n):
		a,b=map(int, input().split())
		ii.append([a/b, a, b])
	#ii.sort()
	
	_,ma,mb = ii[0]
	tn = (h + ma-1)//ma
	tc = tn * mb
	
	vv=[bbn]*(h+1)
	vv[0]=0
	for i in range(h+1):
		for c,a,b in ii:
			nn = min(i + a, h)
			vv[nn]= min(vv[i] + b, vv[nn])
	
	print(vv[-1])
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
class input_clipboard:
	def __init__(self,s):
		self.input_l=s.splitlines()
		self.ii=0
		
	def input(self):
		ret = self.input_l[self.ii]
		self.ii+=1
		return ret

if __name__ == "__main__":
	if sys.platform =='ios':
		if use_clipboard:
			import clipboard
			input_text=clipboard.get()
			ic=input_clipboard(input_text)
			input = lambda : ic.input()
		else:
			sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 41452
n,m=map(int,input().split())

switches=[]
for i in range(m):
    switches.append(list(map(int,input().split())))
    
p=list(map(int,input().split()))

ans=0
for i in range(2**n):
    flag=False
    s=[0]*n
    
    for j in range(n):
        if ((i>>j) & 1):
            s[j]=1      
    
    for k in range(m):
        total=0
        judge=switches[k][1:]
        for l in judge:
            total += s[l-1]
            
        if total%2 == p[k]:
            flag=True
        
        if total%2 != p[k]:
            flag=False
            break
        
    if flag:
        ans+=1

print(ans)        

Measured memory_bytes: 3064
import java.util.*;
import java.io.*;

public class Main{
    public static void main(String args[]){
        Scanner in = new Scanner(System.in);
        
        int row = in.nextInt(), column = in.nextInt();
        int[][] M = new int[row + 1][column + 1];

        for(int i = 0; i < row; i++){
            for(int j = 0; j < column; j++){
                M[i][j] = Integer.parseInt(in.next());
                M[i][column] += M[i][j];
                M[row][j] += M[i][j];
                M[row][column] += M[i][j];
            }
        }

        for(int i = 0; i <= row; i++){
            for(int j = 0; j <= column; j++){
                System.out.printf("%d%s", M[i][j], (j == column) ? "\n" : " ");
            }
        }

    }
}


Measured memory_bytes: 50768
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  ll n,a,b;
  cin >> n >> a >> b;
  vi x(n);
  ll ans = 0;
  rep(i, n){
    cin >> x[i];
    if(i){
      ll kyori = abs(x[i] - x[i - 1]);
      ans += min(kyori * a, b);
    }
  }
  cout << ans << endl;
}

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

typedef long long ll;
const ll INF = 1e9, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define fi first
#define se second
#define m_p make_pair

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll n;
  cin >> n;
  vector<ll> h(n),dp(n,INF);
  rep(i,n) cin >> h[i];
  dp[0] = 0;
  REP(i,1,n){
    chmin(dp[i], dp[i-1]+abs(h[i]-h[i-1]));
    if(i>1) chmin(dp[i], dp[i-2]+abs(h[i]-h[i-2]));
  }
  cout << dp[n-1] << "\n";
  return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second
ll h,w,a,b;
ll prime = 1000000000 + 7;;

typedef ll MOD_POW_TYPE;
MOD_POW_TYPE mod_pow(MOD_POW_TYPE x, MOD_POW_TYPE n, MOD_POW_TYPE mod) {
	MOD_POW_TYPE res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % mod; // 最下位ビットが立っているときにx^(2^i)を掛ける
		x = x * x % mod; // xを順次二乗していく
		n >>= 1;
	}
	return res;
}



int main(){
	cin >> h >> w >> a >> b;

	ll bunshi = 1;
	ll bunbo = 1;

	REP(i,h - 1) {
		bunshi *= (h + w - 2 - i);
		bunbo *= (i + 1);
		bunshi %= prime;
		bunbo %= prime;
	}

	ll all = bunshi * mod_pow(bunbo,prime - 2,prime);
	all %= prime;

	ll p = 1;
	bunshi = 1;
	bunbo = 1;

	REP(i,a - 1) {
		bunshi *= (a - 1 + w - 1 - i);
		bunbo *= (i + 1);
		bunshi %= prime;
		bunbo %= prime;
	}

	ll q = bunshi * mod_pow(bunbo,prime - 2,prime);
	q %= prime;

	REP(i,b) {
		all -= ((p * q) % prime);
		all = (all + prime) % prime;
		p *= (h - a - 1 + i + 1);
		p %= prime;
		p *= mod_pow(i + 1,prime - 2,prime);
		p %= prime;

		q *= (a - 1 + w - 1 - i - a + 1);
		q %= prime;
		q *= mod_pow(a - 1 + w - 1 - i,prime - 2,prime);
		q %= prime;
	}
	cout << all % prime << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstring>
#include <cstring>
#include <vector>
#include <queue>
#include <iostream>
#include <string>
#include <cmath>
#include <stack>
#include <sstream>
#include <set>
#include <cstring>
#include <unordered_set>
#include <map>
#include <algorithm>
using namespace std;

int main()
{
	int n;
	cin >> n;
	string a, b, c;
	cin >> a >> b >> c;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		set<char>st;
		st.insert(a[i]);
		st.insert(b[i]);
		st.insert(c[i]);
		if (st.size() == 3)ans += 2;
		else if (st.size() == 2)ans += 1;
		
	}
	cout << ans;
	
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define all(a) (a).begin(), (a).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;

int main()
{
    cin >> N;
    
    for (ll i = 1; i <= N; i++)
    {
        if((i%3 != 0) && (i%5 != 0)) A += i;
    }

    cout << A;
    
    return 0;
}

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

using namespace std;

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


int main()
{
  int x, t;
  cin >> x >> t;
  if (t >= x) {
    cout << 0 << endl;
    return 0;
  }
  cout << x - t << endl;
  return 0;
}


Measured memory_bytes: 256
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8').trim()

const n = Number(stdin.split('\n')[0])
const a = stdin
  .split('\n')[1]
  .split(' ')
  .map(Number)

const ans = () => {
  const revs = a.map(v => 1 / v)
  const res = 1 / revs.reduce((p, c) => p + c)

  console.log(res)
}

ans()


Measured memory_bytes: 7372
#include<bits/stdc++.h>
#define ui unsigned int
#define ll long long
#define db double
#define ld long double
#define ull unsigned long long
#define ft first
#define sd second
#define pb(a) push_back(a)
#define mp(a,b) std::make_pair(a,b)
#define ITR(a,b) for(auto a:b)
#define REP(a,b,c) for(register int a=(b),a##end=(c);a<=a##end;++a)
#define DEP(a,b,c) for(register int a=(b),a##end=(c);a>=a##end;--a)
const int MAXN=2000000+10;
int n,A[MAXN],p[MAXN];
template<typename T> inline void read(T &x)
{
	T data=0,w=1;
	char ch=0;
	while(ch!='-'&&(ch<'0'||ch>'9'))ch=getchar();
	if(ch=='-')w=-1,ch=getchar();
	while(ch>='0'&&ch<='9')data=((T)data<<3)+((T)data<<1)+(ch^'0'),ch=getchar();
	x=data*w;
}
template<typename T> inline void write(T x,char ch='\0')
{
	if(x<0)putchar('-'),x=-x;
	if(x>9)write(x/10);
	putchar(x%10+'0');
	if(ch!='\0')putchar(ch);
}
template<typename T> inline bool chkmin(T &x,T y){return y<x?(x=y,true):false;}
template<typename T> inline bool chkmax(T &x,T y){return y>x?(x=y,true):false;}
template<typename T> inline T min(T x,T y){return x<y?x:y;}
template<typename T> inline T max(T x,T y){return x>y?x:y;}
inline bool check(int las)
{
	REP(i,1,n+n-1)p[i]=(A[i]>=las);
	if(p[n]==p[n-1])return p[n];
	if(p[n]==p[n+1])return p[n];
	REP(i,1,n-1)
	{
		if(p[n-i]==p[n-i+1])return p[n-i+1];
		if(p[n+i]==p[n+i-1])return p[n+i-1];
	}
	return p[n]^((n-1)&1);
}
int main()
{
	read(n);
	REP(i,1,n+n-1)read(A[i]);
	if(n==1)
	{
		printf("%d\n",A[n]);
		return 0;
	}
	int l=1,r=n+n-1,ans=r;
	while(l<=r)
	{
		int mid=(l+r)>>1;
		if(check(mid))ans=mid,l=mid+1;
		else r=mid-1;
	}
	write(ans,'\n');
	return 0;
}


Measured memory_bytes: 5120
import itertools
N,M,Q=map(int,input().split())
l=list(itertools.combinations_with_replacement(range(1,M+1),N))
ll=[]
List=[]
for x in range(Q):
    a,b,c,d=map(int,input().split())
    List.append([a,b,c,d])
for i in l:
    ans=0
    for j in List:
        a=j[0]
        b=j[1]
        c=j[2]
        d=j[3]
        if i[b-1]-i[a-1]==c:
            ans+=d
    ll.append(ans)
print(max(ll))




Measured memory_bytes: 25084
#include<iostream>
#include<string>
#include<iomanip>
using namespace std;
#define int long long
#define rep(i,n) for(int i = 0; i < n; i++)
#define INF (long long)(1e18)
#define MOD (int)(1e9+7)
#define MAX_N 103
#define MAX_V 10
#define MAX_M 101
#define min(a,b) (a>b?b:a)
#define max(a,b) (a>b?a:b)
#define yn(f) (f?"Yes":"No")
#define YN(f) (f?"YES":"NO")
#define pro "はいプロ　世界一○○が上手　○○界のtourist　○○時代の終焉を告げる者　実質○○　○○するために生まれてきた男"

signed main(){
	cout<<fixed<<setprecision(7);
	int a, b, c  = 0, d=  0;
	bool f = false;
	string s, t;
	int n, m;
	
	// cin>>n>>m;
	
	cin>>n;
	
	s = to_string(n);
	
	rep(i,s.size()){
		d += s[i] - '0';
	}
	
	if(n%d == 0) f = true;
	cout<<yn(f)<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <stack>
#include <queue>
#include <functional>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main(){
	int n;
	cin >> n;
	string s[2];

	cin >> s[0] >> s[1];

	ll ans = 1;
	int st = 0;
	if(s[0][0] != s[1][0]){
		ans = 6;
		st = 2;
	}
	else{
		ans = 3;
		st = 1;
	}

	for(int i = st;i < n;i++){
		if(s[0][i-1] != s[1][i-1]){
			if(s[0][i] != s[1][i]){
				ans *= 3;
				i++;
			}
		}
		else{
			if(s[0][i] != s[1][i]){
				ans *= 2;
				i++;
			}
			else{
				ans *= 2;
			}
		}
		ans %= MOD;
	}

	cout << ans << endl;
}


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

class Program
{
    static void Main(string[] args)
    {
        label:
        var list = ReadLine().Split().Select(Parse).ToList();
        list.Sort();
        WriteLine(list[2] * 10 + list[1] + list[0]);
        //goto label;
    }
}


Measured memory_bytes: 11220
#include<iostream>
#include<string>
#include<cstdlib>
#include<typeinfo>
#include<vector>
#include<iomanip>
#include<cmath>
#include<map>
using namespace std;
#define ll long long
int main(){
    ll N,K;
    cin >> N >> K;
    ll ans =0;
    ans+=pow((N/K),3);
    if((K%2==0)&&(N>=K/2)){
      ans+=pow((N-(K/2))/K+1,3);
    }
    cout << ans;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<string>
#include<math.h>
#include<stdlib.h>
#include<time.h>
#include<map>
#include<queue>
#include<set>
#define ji -
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
#define fe(x) for(int i=be[x];i;i=e[i].ne)
using namespace std;
const int p=1e9+7;
int n,m;
long long ans;
int main(){
	scanf("%d%d",&n,&m);
	if (abs(n-m)>1){
		printf("0\n");
		return 0;
	}
	ans=(n==m)?2:1;
	fo(i,1,n) ans=ans*i%p;
	fo(i,1,m) ans=ans*i%p;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 128
N, D = gets.split(' ').map(&:to_i)
XY = readlines.map(&:chomp)

count = 0

XY.each do |xy|
  x,y = xy.split(' ').map(&:to_i)
  if Math.sqrt(x **2 + y **2) <= D
    count +=1
  end
end

puts count

Measured memory_bytes: 45668
H, W = map(int, input().split())
N = int(input())
A = [int(i) for i in input().split()]

L = [[0 for _ in range(W)] for _ in range(H)]

cnt = 1
cnt2 = 0
for h in range(H):
    if h % 2 == 0:
        for w in range(W):
            L[h][w] = cnt
            cnt2 += 1
            if cnt2 == A[cnt-1]:
                cnt += 1
                cnt2 = 0
            
    else:
        for w in range(W)[::-1]:
            L[h][w] = cnt
            cnt2 += 1
            if cnt2 == A[cnt-1]:
                cnt += 1
                cnt2 = 0
for h in range(H):
    print(*L[h])

Measured memory_bytes: 42224
#include <iostream>
#include <algorithm>
#include <iomanip>

using namespace std;


int main()
{
	int n, k;
	cin >> n >> k;
	double answer = 0;
	int sisuu = 2;
	int min_kako = n+1;
	if (n >= k) {
		answer += double(n - k + 1) / n;
		min_kako = k;
	}
	while (1) {
		int min = (k-1) / sisuu + 1;
		if (min > n) {
			sisuu *= 2;
			continue;
		}
		answer += (double(min_kako - min) / n) * (double(1) / sisuu);
		if (min <= 1) break;
		sisuu *= 2;
		min_kako = min;
	}
	cout << setprecision(11) << answer << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
int n;
int factorial(int n){
   return n>0?n*factorial(n-1):1; 
}

int calc(int a,int b,int c,int d,int e){
    if(a==0){
      return (b && c && d && n>=e);
    }
    return calc(a-1,b+1,c,d,e*10+3)+
    calc(a-1,b,c+1,d,e*10+5)+
    calc(a-1,b,c,d+1,e*10+7);
}
int main() {
  int dec=1000,d=3,ans=0;
  cin >> n;
  while(dec<n){
    int c=factorial(d),e=0;
    rep(i,d)
      e+=c/factorial(i)/factorial(d-i);
    e*=3;
    ans+=pow(3,d)-e;
    dec*=10;
    d++;
  }
  ans+=calc(d,0,0,0,0);
  cout<<ans;
  return 0;
}

Measured memory_bytes: 256
# ABC 057: B – Checkpoints
n, m = map(int, input().split())
studentPoints = [list(map(int, input().split())) for _ in range(n)]
checkPoints = [list(map(int, input().split())) for _ in range(m)]

for i in range(n):
    distances = [abs(studentPoints[i][0] - checkPoints[k][0]) + abs(studentPoints[i][1] - checkPoints[k][1]) for k in range(m)]
    print(distances.index(min(distances)) + 1)

Measured memory_bytes: 3064
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    int N, M; cin >> N >> M;
    cout << N*(N-1)/2 + M*(M-1)/2 << endl;
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



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

int main()
{
int n;
  scanf("%d",&n);
  if(n%1000==0)
  {
    printf("0\n");
  }
  else
  {
    int p=n%1000;
    printf("%d\n",1000-p);
  }
}

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

#define times(n, i) uptil(0, n, i)
#define upto(f, t, i) for(auto _##i = (t), i = decltype(_##i)(f) poi  i <= _##i poi  i++)
#define uptil(f, t, i) for(auto _##i = (t), i = decltype(_##i)(f) poi  i < _##i poi  i++)
#define downto(f, t, i) for(auto i = (f), _##i = decltype(i)(t) poi  i >= _##i poi  i--)
#define downtil(f, t, i) for(auto i = (f), _##i = decltype(i)(t) poi  i > _##i poi  i--)

#define unless(c) if(!(c))
#define until(c) while(!(c))
#define loop while(true)

#define poi ;
#define poipoi << "\n"

/*#define do {*/
/*#define end }*/

#define val const auto
#define var auto

#define zenbu(c) c.begin(), c.end()

#define fuwafuwa(n, c) dokidoki((n) + (c) - 1, c)
#define dokidoki(n, c) ((n) / (c) * (c))

template<class T> bool read(T& t){
    return cin >> t poi
}
template<class T, class...U> bool read(T& t, U&... u){
    unless(cin >> t) return false poi
    return read(u...) poi
}

template<class T> T lov_yet(T t){
    if(t) return t poi
    else return 0 poi
}

template<class T> T gcd(T a, T b){
    if(b) return gcd(b, a % b) poi
    else return a poi
}

pair<double, double> solve_linear(double a1, double b1, double c1, double a2, double b2, double c2){
    return make_pair(lov_yet((b1 * c2 - b2 * c1) / (b1 * a2 - b2 * a1)), lov_yet((a1 * c2 - a2 * c1) / (a1 * b2 - b1 * a2))) poi
}

const long double PI = 3.141592653589793238462643383279502884L poi

double distance(const pair<double, double>& p){
    return lov_yet(sqrt(p.first * p.first + p.second * p.second)) poi
}
double distance(const pair<double, double>& a, const pair<double, double>& b){
    return distance(make_pair(a.first - b.first, a.second - b.second)) poi
}

double inner_product(const pair<double, double>& a, const pair<double, double>& b){
    return lov_yet(a.first * b.first + a.second * b.second) poi
}

double outer_product_z(const pair<double, double>& a, const pair<double, double>& b){
    return lov_yet(a.first * b.second - b.first * a.second) poi
}

template<class T> T toppo(stack<T>& stick){
    T choco = stick.top() poi
    stick.pop() poi
    return choco poi
}

bool include_word(const string& s, const string& find){
    if(s.size() < find.size()) return false poi
    if(s == find) return true poi
    if(s.substr(0, find.size() + 1) == find + " " || s.substr(s.size() - find.size() - 1) == " " + find) return true poi
    times(s.size() - find.size() - 2, i)
        if(s.substr(i, find.size() + 2) == " " + find + " ") return true poi
    return false poi
}

int main(){
    int n poi
    cin >> n poi
    long long pyon = 1 poi

    upto(1, n, i){
        pyon *= i poi
    }
    cout << pyon poipoi poi

    return 0 poi
}

Measured memory_bytes: 1160
n = gets.chomp.to_i
adjList = []
n.times { adjList.push(gets.chomp.split(' ').map(&:to_i)) }

adjMatrix = Array.new(n){ Array.new(n){ 0 } }

adjList.each do |e|
    next if e[1] == 0
    e[2, e[1]].each do |adj|
        adjMatrix[e[0] - 1][adj - 1] = 1
    end
end

adjMatrix.each { |e| puts(e.join(' ')) }



Measured memory_bytes: 6992
import java.util.Arrays;
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
		
		Scanner keyboard = new Scanner(System.in); 
	
		String S = keyboard.next();

		switch(S) {
		case "a":
			System.out.println("vowel");
			break;
		case "e":
			System.out.println("vowel");
			break;
		case "i":
			System.out.println("vowel");
			break;
		case "o":
			System.out.println("vowel");
			break;
		case "u":
			System.out.println("vowel");
			break;
		default:
			System.out.println("consonant");
		}
		keyboard.close();	
	}
}

Measured memory_bytes: 21844
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
    int x,i,max,sum,j;
    scanf("%d",&x);
    for(i=1;;i++)
    {
        if(i*i>x)
            {max=(i-1)*(i-1);
            break;
            }
    }
    for(i=1;i<=10;i++)
    {
        sum=1;
        for(j=1;j<=10;j++)
        {
        sum*=i;
        if(sum>x)
        {
            sum/=i;
            break;
        }
        }
        if(sum>max&&j>=3)
            max=sum;
    }
    printf("%d",max);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m,d,cnt=0;
	cin >> n >> m >> d;
	for(int i=n;i<=m;i++){
		if(i%d==0) cnt++;
	}
	cout << cnt << endl;
	return 0;
} 

Measured memory_bytes: 3620
#include<stdio.h>

	int main()
	{
		int a, b,ans;
		scanf("%d %d", &a, &b);
		if (a > b)
		{
			ans = a + (a - 1);
		}
		else if(b >a)
		{
			ans = b + (b - 1);
		}
		else if (a == b)
		{
			ans = a + b;
		}
		printf("%d", ans);

		return 0;
	}

Measured memory_bytes: 128
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T1, class T2>bool chmax(T1& a, const T2& b) { return a < b ? a = b, 1 : 0; }
template<class T1, class T2>bool chmin(T1& a, const T2& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int N;
    cin >> N;
    vector<int> T(N), A(N);
    rep(i, N) cin >> T[i];
    rep(i, N) cin >> A[i];

    vector<bool> determined(N);
    determined[0] = true;
    rep(i, 1, N) {
        if (T[i] > T[i - 1]) {
            determined[i] = true;
        }
    }

    ll ans = determined[N - 1] ? T[N - 1] == A[N - 1] : T[N - 1] >= A[N - 1];
    for (int i = N - 2; i >= 0; --i) {
        if (determined[i]) {
            ans = ans * (A[i] > A[i + 1] ? T[i] == A[i] : T[i] <= A[i]);
        }
        else {
            ans = ans * (A[i] > A[i + 1] ? T[i] >= A[i] : min(T[i], A[i])) % MOD;
        }
    }

    write(ans);
}

Measured memory_bytes: 1024
/*
 * 3つの整数a,b,cを読み込み、a<b<cの条件を満たすなら
 * "Yes"を出力。満たさなければ"No"を出力するプログラム。
 *
 * Input
 * a b c
 *
 * Constraints
 * 0<=a,b,c<=100
 */

#include <stdio.h>

int main()
{
	int a,b,c;
	scanf("%d %d %d", &a, &b, &c);

	if (a < b && b < c)
		printf("Yes\n");
	else 
		printf("No\n");

	return 0;
}


Measured memory_bytes: 2108
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;

class Myon
{
    public Myon() { }
    public static int Main()
    {
        cin = new Scanner();
        new Myon().calc();
        return 0;
    }

    static Scanner cin;

    // メンバ変数---
    long a;
    long b;
    long x;
    // -------------

    void calc()
    {
        a = cin.nextLong();
        b = cin.nextLong();
        x = cin.nextLong();

        long ae = a / x + 1;
        long be = b / x + 1;
        long ret = be - ae;
        if(a % x == 0)
        {
            ret++;
        }

        Write<long>(ret);


    }

    void Write<T>(T v)
    {
        Console.WriteLine(v);
    }

    int Pow(int x, int y)
    {
        return (int)Math.Pow(double.Parse(x.ToString()), double.Parse(y.ToString()));
    }

    double Pow(double x, double y)
    {
        return Math.Pow(x, y);
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }
}


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

long long gcd(long long a,long long b){
    //if(b == 0) return a;
    //return gcd(b,a%b);
    return b ? gcd(b,a%b) : a;
}

int main() {
    //input
    int a, b, k;
    cin >> a;
    cin >> b;
    cin >> k;
    //
    long long g = gcd(a,b);
    int count = 0;
    int res = 1;
    for(int i=g;i>0;i--){
        if(g%i == 0){
            count++;
            if(count == k){
                res = i;
                break;
            }
        }
    }
    cout << res;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define MOD 1000000007

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

int main() {
	string s;
	cin >> s;
	int n = s.length();
	vector<int> acc(n);
	for(int i=n-1; i>=0; i--) {
		if(i==n-1) {
			if (s[i] == 'W') acc[i] = 1;
			else acc[i] = 0;
			continue;
		}
		if (s[i] == 'W') acc[i] = acc[i+1]+1;
		else acc[i] = acc[i+1];
	}
	ll ans = 0;
	rep(i,n) {
		if(s[i] == 'W') continue;
		ans += acc[i];
	}
	cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1412
#include<stdio.h>
#include<iostream>
#include<vector>
#include <fstream>
#include<math.h>
#include <numeric>
#include<algorithm>
#include <stdlib.h>
# include <map>

using namespace std;

int main(){
    int n,m,x,y ,max_x , min_y;
    bool flag = false;
    cin >> n >> m >> x >> y;
    vector<int> vec_x(n ,0);
    vector<int> vec_y(m ,0);
    for(int i = 0;i < vec_x.size();i++ ){
        cin >> vec_x.at(i) ;
    }
    for(int i = 0;i < vec_y.size();i++ ){
        cin >> vec_y.at(i) ;
    }
    max_x = *max_element(vec_x.begin() , vec_x.end());
    min_y = *min_element(vec_y.begin() , vec_y.end());

    for(int i = x+1 ;i < y+1 ;i++){
        if ((max_x < i)&&(i <= min_y)){
            flag = true;
        }
    }
    if(flag  == true){
        cout << "No War" << endl;
    }
    else{
        cout << "War" << endl;
    }
}

Measured memory_bytes: 256
# A - Frog 1 (メモ化再帰)
import sys
sys.setrecursionlimit(10**6)

# change minimum 
def chmin(a, b):
    # a より b の方が小さいとき
    if (a > b):
        return b
    return a

# 無限大の値
INF = 10**10

N = int(input())
h = list(map(int,input().split()))

# メモ用の DP テーブル
dp = [0]*(100010)

# メモ用の DP テーブル全体を初期化
for i in range(100010):
    dp[i] = INF 

# 再帰関数
def rec(v):
    # DP の値が既に更新されていたらそのままリターン (メモ化の利点)
    if dp[v] < INF:
        return dp[v]
    
    # 初期条件
    if v == 0:
        return 0
    
    # i-1, i-2 を再帰
    res = INF
    
    # 1つ前の足場から遷移するとき
    res = chmin(res, rec(v-1) + abs(h[v] - h[v-1]))
    # 2つ前の足場から遷移するとき
    if v > 1:
        res = chmin(res, rec(v-2) + abs(h[v] - h[v-2]))
        
    # 結果をメモして返す
    dp[v] = res
    return res

# N-1 回遷移したときの最小値を出力
print(rec(N-1))

Measured memory_bytes: 100796
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pcc pair<char,char>
#define vi vector <int>
#define vl vector <ll>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d",x)
#define plld(x) printf("%lld",x)
#define pds(x) printf("%d ",x)
#define pllds(x) printf("%lld ",x)
#define pdn(x) printf("%d\n",x)
#define plldn(x) printf("%lld\n",x)
#define INF 2e9
#define INFLL 2e18
using namespace std;
ll powmod(ll base,ll exponent,ll mod){ // with mod < 1e9
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
const int upperlimit = 1e5+100;
const int mod = 1e9+7;
int arr[upperlimit];
ll fact[upperlimit];
ll invfact[upperlimit];
ll ncr(int n,int r){
	if((r>n)||(r<0)) return 0;
	ll ans=fact[n];
	ans*=invfact[r];ans%=mod;
	ans*=invfact[n-r];ans%=mod;
	return ans;
}
int main() {
	fact[0]=1;invfact[0]=1;
	for(int i = 1; i < upperlimit; i++){
		fact[i]=i;fact[i]*=fact[i-1];fact[i]%=mod;
		invfact[i]=powmod(fact[i],mod-2,mod);
	}
	int n,k;
	sd(n);sd(k);
	for(int i = 1; i <= n; i++) sd(arr[i]);
	sort(arr+1,arr+n+1);
	ll ans=0;
	for(int i = 1; i <= n; i++){
		ll calc=ncr(i-1,k-1)-ncr(n-i,k-1);
		if(calc<0) calc+=mod;
		calc*=arr[i];calc%=mod;
		if(calc<0) calc+=mod;
		ans+=calc;ans%=mod;
	}
	plld(ans);
	return 0;
}

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

#define llong long long
#define inf 999999999
#define mp make_pair
#define pb push_back
#define fn fill_n
typedef pair<int, int> P;
typedef pair<P, int> PP;
typedef pair<PP, int> PPP;
typedef struct data{
	int now;
	int cost;
}data;
int nh[4] = {1, 0, -1, 0};
int nw[4] = {0, 1, 0, -1};





int main(){
	int sum = 0, in;
	for(int i = 0; i < 4; i++){
		cin >> in;
		sum += in;
	}
	cout << sum/60 << endl;
	cout << sum%60 << endl;
	return 0;
}


Measured memory_bytes: 3064
package main

import (
	"fmt"
	"strings"
)

func main() {
	var N int
	fmt.Scan(&N)
	A := make([]int, N)
	for i := range A {
		fmt.Scan(&A[i])
	}
	_ = insSort(A)
}

func insSort(A []int) []int {
	for i := 1; i < len(A); i++ {
		fmt.Println(strings.Trim(fmt.Sprint(A), "[]"))
		v := A[i]
		j := i - 1
		for ; j >= 0 && A[j] > v; j-- {
			A[j+1] = A[j]
		}
		A[j+1] = v
	}
	fmt.Println(strings.Trim(fmt.Sprint(A), "[]"))
	return A
}



Measured memory_bytes: 1272
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	ll A, B, C, K;
	cin >> A >> B >> C >> K;

	auto ans = 0ll;
	ans = min(K, A);
	K = max(0ll, K - A - B);
	ans -= K;
	cout << ans << endl;

	return 0;
}

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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

ll gcd(ll m, ll n)
{
	if (m < n) {
		swap(m, n);
	}

	if (n == 0) {
		return m;
	}

	ll x = m % n;
	
	m = n;
	n = x;

	gcd(m, n);
}//gcd

ll lcm(ll m, ll n)
{
	// 引数に０がある場合は０を返す
	if ((0 == m) || (0 == n))
		return 0;

	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm

int main() {
	ll n;
	ll prev = 1;

	cin >> n;

	REP(i, n) {
		ll t;
		cin >> t;
		prev = lcm(prev, t);
	}

	cout << prev << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;



int main(){
    ll N, M; cin >> N >> M;
    ll K; cin >> K;
    for(int i = 0; i <= N; i++){
        for(int j = 0; j <= M; j++){
            ll tag =  i*M + j*N - 2*(i*j);
            if(tag == K){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    
    
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define P pair<ll, ll>
using ll = long long;
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define pp pair<ll, pair<ll, ll>> 




////////////////////////////////////////////////////////


int main() {
    ll n, m; cin >> n >> m;
    priority_queue<ll> pq;
    rep(i, 0, n){
        ll a; cin >> a;
        pq.push(a);
    }
    rep(i, 0, m){
        ll f = pq.top(); pq.pop();
        f /= 2;
        pq.push(f);
    }
    ll ans = 0;
    while(!pq.empty()){
        ans += pq.top(); pq.pop();
    }
    co(ans);

    return 0;
}


Measured memory_bytes: 1400
#include <iostream>
#include <cmath>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <cstring>

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define pii pair < int, int >
#define pll pair < long long, long long>
#define ull unsigned long long
#define vi vector < int >
#define vll vector < long long >
#define sz(a) (int)a.size()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x))
#define fname "searching"

const int inf = (int)1e9;
const ll INF = (ll)1e18;
const double eps = 1e-9;
const double pi = acos(-1.0);
const int mod = (int)1e9 + 7;

int solve(){
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    int ans = inf;
    for(int i = 0; i <= x; ++i){
        int cntab = 2 * (x - i);
        int cntb = max(y - (x - i), 0);
        int sum = a * i + min(b * cntb, c * cntb * 2) + c * cntab;
        ans = min(ans, sum);
    }
    return ans;
}

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

    cout << solve() << "\n";
    
    return 0;
}

Measured memory_bytes: 256
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };

int N;
ll ans[10001] ={};

signed main(){
    cin >> N;
    for(ll i=1; i<=100; i++){
        for(ll j=1; j<=100; j++){
            for(ll k=1; k<=100; k++){
                if(i*i+j*j+k*k+i*j+j*k+k*i <= N) ans[i*i+j*j+k*k+i*j+j*k+k*i]++;
            }
        }
    }
    for(int i=1; i<=N; i++) cout << ans[i] << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(){
	int N,count=0,sum=0;
	cin>>N;
	for(int i=1;i<=N;i++){
		if(i%2==0)continue;
		for(int j=1;j<=i;j++){
			if(i%j==0)count++;
		}
		if(count==8)sum++;
		count=0;
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) throws Exception {
        // Here your code !
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        long sum = 0;
        while(true) {
            sum = 0;
            String line = br.readLine();
            if(line.length()==1)
                if(Integer.parseInt(line)==0)break;
            for(int i=0;i<line.length();i++){
                sum += Integer.parseInt(String.valueOf(line.charAt(i)));
            }
            System.out.println(sum);
        }
    }
}

Measured memory_bytes: 17164
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

int N;
vector<i64> A;
int main(){
  cin >> N;
  A.resize(N);
  rep(i,0,N - 1){
    cin >> A[i];
  }

  if(A[0] != 0){
    cout << -1 << endl;
    return 0;
  }
  i64 ans = 0;
  i64 grow = 0;
  for(int i = N - 1;i >= 1;i--){
    if(A[i] - grow > 0){
      ans += A[i];
      grow = A[i];
    }
    else if(A[i] - grow < 0){
      cout << -1 << endl;
      return 0;
    }
    grow = max(0LL, grow - 1);
  }
  cout << ans << endl;
}


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

int main(){
	int W,H,x,y,r;
	cin>>W>>H>>x>>y>>r;
		if(x>=r&&y>=r&&x+r<=W&&y+r<=H){
			cout<<"Yes"<<endl;
		}else{
			cout<<"No"<<endl;
		}
	return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(x) (x).begin(),(x).end()
#define dup(x,y) (((x)+(y)-1)/(y))
#define sz(x) (int)(x).size()
#define MOD 1000000007
using namespace std;
typedef long long ll;

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

Measured memory_bytes: 256
require 'prime'
include Math
define_method :max, 		-> (a,b) { a > b ? a : b }
define_method :min, 		-> (a,b) { a < b ?  a : b }
define_method :swap, 		-> (a,b) { a, b = b, a }
define_method :gi, 			-> () { gets.split.map(&:to_i) }
define_method :gs, 			-> () { gets.chomp }
define_method :getc,		-> () { gets.chomp.split('') }
define_method :fi, 			-> () {first}
define_method :darray,	-> (size1, size2, init = nil) { Array.new(size1){Array.new(size2){init}} }
define_method :array,		-> (size,init = nil) { Array.new(size){init} }
define_method :putall, 	-> (obj) { obj.each { |o| puts o } }
define_method :repl, 		-> (st,en, &block) { st.upto en do |i| block.call(i) end }
	define_method :rep, 		-> (num, &block) { num.times do |i| block.call(i) end }

		prime = array(1001,1)
		n = gi[0]
		repl 2, n do |m|
			m.prime_division.each {|x| 
				prime[x[0]] += x[1]
			}
		end
		ans = 1
		repl 2, 1000 do |i|
			ans *= prime[i]
			ans %= (10 ** 9) + 7
		end

		puts ans


Measured memory_bytes: 2300