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

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int d = sc.nextInt();
        int[][] x = new int[n][d];
        for (int i = 0 ; i < n ; i++) {
            for (int j = 0 ; j < d ; j++) {
                x[i][j] = sc.nextInt();
            }
        }
        int count = 0;
        for (int i = 0 ; i < n ; i++) {
            for (int j = i + 1 ; j < n ; j++) {
                int dis = 0;
                for (int k = 0 ; k < d ; k++) {
                    dis += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
                }
                for (int k = 1 ; k <= 200 ; k++) {
                    if (dis == k * k) count++;
                }
            }
        }
        System.out.println(count);
    }

}


Measured memory_bytes: 23252
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstdlib>
using namespace std;
typedef long long ll;
ll combi(ll n){
  return n*(n-1)/2;
}
int main(){
  int N;
  ll M;
  cin >> N >> M;
  ll A[N];
  for(int i=0;i<N;i++) cin >> A[i];

  ll sum[N+1];
  ll tmp = 0;
  for(int i=0;i<N;i++){
    tmp += A[i]%M;
    sum[i] = tmp%M;
  }
  sum[N] = 1000000001;
  sort(sum, sum+N);


//  for(int i=0;i<N;i++) cout << sum[i] << " ";
//  cout <<endl;

  ll ans = 0;
  int i = 0;
  while(i<N){
    int cnt = 1;
    while(sum[i]==sum[i+1]){
      cnt++;
      i++;
    }
    ans += combi(cnt);
    i++;
  }

  for(int i=0;i<N;i++){
    if(sum[i]==0){
      ans++;
    }else{
      break;
    }
  }

  cout << ans <<endl;

  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <stdio.h>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional> //operator[]
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
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;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;

const ll MOD = 1000000007;
signed main(){
    ll n,k; cin >> n >> k;
    ll ans=0;
    for(ll i=k;i<=n+1;i++){
        ll res=(n*i-i*(i-1)+1)%MOD;
        ans+=res; ans%=MOD;
    }

    cout << ans << endl;
    
}



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

l = list(map(int,input().split()))

under = 0
c =0 

for i in range(n-1):
    if l[i+1] > under:
        under = l[i+1]-1
        c += 1
    elif under == l[i+1]:
        
        c += 1
    
    else:
        break
    
if c == n -1:
    print('Yes')

else:
    print('No')
    
    

Measured memory_bytes: 15020
#include <bits/stdc++.h>
	using namespace std;
	typedef long long int lld;
	int main()
	{
	    ios_base::sync_with_stdio(false);
	    cin.tie(NULL);
	    lld n,m,q,i,x,y,j,l,k=0;string s;
	    cin>>s
	    ;l=s.length();
	    for(i=0;i<l;i++)
	    {
	    	if(s[i]=='1')
	    		k++;
	    }
	    cout<<k;
	 	}

Measured memory_bytes: 256
void solve();

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

//////////////////////////////////////////////////
//////////////////////////////////////////////////
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <limits.h>
#include <complex>
#include <assert.h>
#include <set>
using namespace std;
typedef pair<int, int> pii;
typedef long double ld;
typedef long long ll;
typedef complex<ld> Point;
vector<int> P;

void solve() {
	int N;
	cin >> N;
	P.resize(N);
	for (int n = 0; n < N; n++)cin >> P[n];
	sort(P.begin(), P.end());
	cout << P[N / 2] - P[N / 2 - 1] << endl;
	return;
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main()
{
 int a,b,c,d,e,f;
 scanf("%d%d%d%d",&a,&b,&c,&d);
 e=a+b;f=c+d;
 if(e>f) cout<<"Left";
 if(e==f) cout<<"Balanced";
 if(e<f) cout<<"Right";
 return 0;
}


Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from functools import reduce



INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007



def gcd(a, b):
    while b:
        a, b = b, a % b
    return a



n, x = LI()
L = [abs(i-x) for i in LI()]
print(reduce(lambda p, q:gcd(p, q), L))

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

using ll=long long;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DBG(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

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

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(int x,int suc=1){
	printf("%lld",x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

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

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

template<class T>
T Sq(const T& t){
	return t*t;
}

const int inf=LLONG_MAX/3;
const int Nmax=514114;
char buf[Nmax],mx[Nmax];
int kind[Nmax];
void setkind(int i){
	if(buf[i-1]<=buf[i])kind[i]=kind[i-1];
	else kind[i]=kind[i-1]+1;
	mx[kind[i]]=buf[i];
}
void addone(int n){
	int i=n-1;
	while(buf[i]=='9')i--;
	buf[i]++;
	setkind(i);
	for(i++;i<n;i++){
		buf[i]='0';
		setkind(i);
	}
}

signed main(){
	scanf("%s",buf+19);
	REP(i,19)buf[i]='0';
	int n=strlen(buf),ans=0;
	FOR(i,1,n)setkind(i);
	int head=19;
	while(head<n){
		ans++;
		addone(n);
		while(buf[head]<mx[kind[head]])head++;
		head++;
		while(head<n&&buf[head]=='0')head++;
	}
	cout<<ans<<endl;
}


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

int main(){ 
  ll N; cin >> N;
  string s; cin >> s;
  map<pair<string,string>,ll> mp;
  ll ans = 0;
  for(ll bit = 0; bit < (1<<N); bit++){
    string a = "",b = "";
    for(ll i = 0;  i < N; i++){ 
      if((bit>>i)&1){a += s[i];}
      else{ b += s[i];}
    }
    mp[{a,b}]++;
  }
  for(ll bit = 0; bit < (1<<N); bit++){ 
    string a = "",b = "";
    for(ll i = 0; i < N; i++){ 
      if((bit>>i)&1){ a += s[i+N];}
      else{b += s[i+N];}
    }
    reverse(a.begin(),a.end()); reverse(b.begin(),b.end());
    ans += mp[{a,b}];
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 87040
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<utility>
#include<stack>
#include<queue>
#include<map>
#include<set>

#define fi first
#define se second
#define long long long

using namespace std;

int main()
{
    //    freopen("input.in", "r", stdin);
    int a, b, c; cin >> a >> b >> c;
    int res = 0;
    while(a%2 == 0 && b%2 == 0 && c%2 == 0)
    {
        res++;
        int _a = (b+c)/2;
        int _b = (a+c)/2;
        int _c = (a+b)/2;
        
        if(res == 10000000)
        {
            cout << "-1\n";
            return 0;
        }
        a = _a;
        b = _b;
        c = _c;
    }
    cout << res << "\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=410;
const int mod=998244353;

int qpow(int a,int b) {
	int ret=1;
	while(b) {
		if(b&1) ret=1ll*ret*a%mod;
		a=1ll*a*a%mod,b>>=1;
	}
	return ret;
}

int n,fac[N],ifac[N],f[N][N][N],g[N];

int main() {//
	fac[0]=ifac[0]=1;
	for(int i=1;i<N;i++) {
		fac[i]=1ll*fac[i-1]*i%mod;
		ifac[i]=qpow(fac[i],mod-2);
	}
	f[0][0][0]=mod-1;
	cin>>n;
	int s1=0,s2=0;
	for(int i=1;i<=n;i++) {
		int a,b;cin>>a>>b;
		for(int j=0;j<=s1;j++)
			for(int k=0;k<=s2;k++) f[i][j][k]=f[i-1][j][k];
		g[0]=1;
		for(int j=1;j<b;j++) g[j]=1ll*g[j-1]*a%mod;
		for(int j=0;j<b;j++) g[j]=1ll*g[j]*ifac[j]%mod;
		for(int j=0;j<=s1;j++)
			for(int k=0;k<=s2;k++)
				for(int l=0;l<b;l++)
					f[i][j+l][k+a]=(f[i][j+l][k+a]+mod-1ll*f[i-1][j][k]*g[l]%mod)%mod;
		s1+=b-1,s2+=a;
	}
	int ans=0;
	for(int i=0;i<=s1;i++)
		for(int j=1;j<=s2;j++) {
			int val=1ll*f[n][i][j]*fac[i]%mod;
			val=1ll*val*qpow(j,mod-1-i)%mod;
			ans=(ans+1ll*val*s2%mod*qpow(j,mod-2))%mod;
		}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 262400
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <stack>
#include <climits>

using namespace std;

#define rep(i,n,m) for(int i=n; i<=m; i++)
#define per(i,n,m) for(int i=n; i>=m; i--)
#define printi(x) printf("%d ", x)
#define printiln(x) printf("%d\n", x)
#define printiarray(a,n) for(int i=0; i<n-1; i++){printf("%d ", a[i]);} printf("%d\n", a[n-1])
#define scani(x) scanf("%d", &x)
#define scaniarray(a,n) for(int i=0; i<n; i++){scanf("%d", &a[i]);}
#define scans(str) scanf("%s",str)
#define scanc(ch) scanf("%c", &ch)

const int NMax = 500000;
int B[NMax];
int count = 0;
void merge(int *A, int left, int mid, int right);
void mergeSort(int *A, int left, int right);

int main() {
    int n;
    scani(n);
    scaniarray(B,n);

    mergeSort(B,0,n);

    printiarray(B,n);
    printiln(count);


    return 0;
}

void merge(int *A, int left, int mid, int right) {
    int n1 = mid - left;
    int n2 = right - mid;
    int L[n1];
    int R[n2];
    rep(i,0,n1-1) {
        L[i] = A[left+i];
    }
    rep(i,0,n2-1) {
        R[i] = A[mid + i];

    }
    L[n1] = INT_MAX;
    R[n2] = INT_MAX;
    int i = 0;
    int j = 0;
    rep(k,left,right-1) {
        if(L[i] <= R[j]) {
            A[k] = L[i];
            i++;
            count++;

        }
        else {
            A[k] = R[j];
            j++;
            count++;

        }
    }
}


void mergeSort(int *A, int left, int right) {
    if(left+1 < right){
        int mid = (left + right)/2;
        mergeSort(A, left, mid);
        mergeSort(A, mid, right);
        merge(A, left, mid, right);

    }
}



Measured memory_bytes: 6472
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <map>
#include <set>
using namespace std;
#define lowbit(x) (x&(-x))
#define max(x,y) (x>y?x:y)
#define min(x,y) (x<y?x:y)
#define MAX 100000000000000000
#define MOD 1000000007
#define pi acos(-1.0)
#define ei exp(1)
#define PI 3.141592653589793238462
#define INF 0x3f3f3f3f3f
#define mem(a) (memset(a,0,sizeof(a)))
typedef long long ll;
const int N=1005;
const int mod=1e9+7;
int main()
{
    int n;
    cin>>n;
    if(n<2) cout<<1<<endl;
    else if(n<4) cout<<2<<endl;
    else if(n<8) cout<<4<<endl;
    else if(n<16) cout<<8<<endl;
    else if(n<32) cout<<16<<endl;
    else if(n<64) cout<<32<<endl;
    else cout<<64<<endl;
    return 0;
}






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

using namespace std;
typedef long long ll;

int main() {
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> c(h);
    for (int i = 0; i < h; i++)cin >> c[i];

    int ret = 0;
    for (int bit = 0; bit < 1 << (h + w); bit++) {
        vector<string> now = c;
        for (int row = 0; row < h; row++) {
            if (bit & (1 << row)) {
                for (int column = 0; column < w; column++) now[row][column] = 'R';
            }
        }
        for (int column = 0; column < w; column++) {
            if (bit & (1 << (h + column))) {
                for (int row = 0; row < h; row++) now[row][column] = 'R';
            }
        }

        int count = 0;
        for (const auto &x:now) {
            for (auto y:x) {
                if (y == '#')count++;
            }
        }
        if (count == k)ret++;
    }

    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3620
n,h = map(int,input().split())
a,b = map(int,input().split())
M = a
throw = [b]
for i in range(1,n):
    x,y = map(int,input().split())
    if M < x:
        M = x
    throw.append(y)
throw.sort(reverse=True)
i = 0
while throw[i] > M:
    h -= throw[i]
    i += 1
    if h <= 0:
        print(i)
        exit()
    elif i == n:
        break
if h%M == 0:
    i += h//M
else:
    i += h//M + 1
print(i)

Measured memory_bytes: 55768
#include <bits/stdc++.h>
#define vsort(v) sort(v.begin(), v.end())
#define ll long long
#define rep(i, s, g) for (ll i = (s); i < (g); i++)
#define MOD 1000000007
using namespace std;
int main()
{
  ll A, B, N, r; cin >> A >> B >> N; 
  r = N % B; 
  if (N < B) {
  	cout << A * r / B << endl; 
  } else {
  	cout << A * (B - 1) / B << endl;
  }
}

Measured memory_bytes: 3620
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
    #from itertools import 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

    n = int(input())
    s,t = input().rstrip().split()
    res = ''
    for a,b in zip(s, t):
        res += a + b
    print(res)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bitset>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef long long LL;

typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<string, int> PSI;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define SORTG(c) sort((c).begin(),(c).end(),greater<auto>())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define REP(i,n)  for(int i=0; i<(n); i++)

//constant
//--------------------------------------------
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const LL MOD = 1e9+7; 
int main(){
  int n, m;
  cin >> n >> m;
  vector<PII> xy(m);
  REP(i, m){
    int a, b;
    cin >> a >> b;
    xy[i]=MP(a-1, b-1);
  }
  vector<bool> cnt1(n,false);
  cnt1[0]=true;
  vector<int> cntm(n,1);
  REP(i,m){
      if(cnt1[xy[i].first]==true){
        cnt1[xy[i].second]=true;
      }
        cntm[xy[i].second]++;
        cntm[xy[i].first]--;
      if(cntm[xy[i].first]==0){
        cnt1[xy[i].first]=false;
      }
  }
  int ans = 0;
  REP(i, n){
    if(cnt1[i]==true) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1408
#!/usr/bin/env perl

use strict;
use warnings;
use bigint;

my $x = <>;
chomp $x;

my $base = int($x / 11);
my $re = int($x % 11);
print $base * 2 + ($re == 0 ? 0 : ($re > 6 ? 2 : 1));

__END__

sub c {
  my ($m, $n) = @_;
  $x - $n <= 5 * ($m + $n);
}

sub bsearch {
  my $plus = shift;
  my $l = 0;
  my $r = 1000000000000000;
  while ($l + 1 < $r) {
    my $n = int(($l + $r) / 2);
    if ($n + $plus >= 0 && &c($n + $plus, $n)) {
      $r = $n;
    } else {
      $l = $n;
    }
  }
  2 * $r + $plus;
}

my $xx = &bsearch(-1);
my $yy = &bsearch(0);
my $zz = &bsearch(1);

my @array = sort { $a <=> $b } ($xx, $yy, $zz);
print $array[0];


Measured memory_bytes: 4992
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
 
namespace At
{
    class Program
    {
        static void Main(string[] args)
        {
            var x = ReadLong();
            var ans = (x / 11) * 2;
            var a = x % 11;
            if (a == 0)
            {
                
            }
            else if (a <= 6)
            {
                ans += 1;
            }
            else
            {
                ans += 2;
            }
 
            WriteLine(ans);
        }
       
 
        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
 
        //最大公約数
        
        public static int Gcd(int a, int b)
        {
            if (a < b)
            {
                return Gcd(b, a);
            }
            while (b != 0)
            {
                var reminder = a % b;
                a = b;
                b = reminder;
            }
            return a;
        }
 
        //最小公倍数
        public static int Lcm(int a, int b)
        {
            return a * b / Gcd(a, b);
        }
 
    }
}


Measured memory_bytes: 11220
#include <iostream>
#include <string>

using namespace std;

int main() {
 int a, b;

 cin >> a >> b;

 string op;

 if(a == b) 
  op = " == ";
 else if(a > b) 
  op = " > ";
 else 
  op = " < ";

 cout << "a" << op << "b" << endl;

 return 0;
}

Measured memory_bytes: 3144
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());
#define PAU 

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 28);
const ll LINF = 1e18;
const double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	FOR(i, 1, 10) {
		FOR(j, 1, 10) {
			cout << i << "x" << j << "=" << i * j << endl;
		}
	}
	PAU;
	return 0;
}



Measured memory_bytes: 3108
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

#[fastout]
fn main() {
    input! {//
        n:Chars,
    }
    pub fn yn(ans: bool) {
        if ans {
            println!("Yes");
        } else {
            println!("No");
        }
    }

    let v = n.iter().fold(0, |sum, &x| sum + charconv(x, '0'));
    yn(v % 9 == 0);
}
pub fn charconv(c: char, base: char) -> usize {
    return (c as u8 - base as u8) as usize;
}


Measured memory_bytes: 3112
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {


	public static void main(String[] args) {

		PrintWriter out = new PrintWriter(System.out);
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		for (int i = 0; i < n; i++) {
			byte s = scan.nextByte();
			byte g = scan.nextByte();
			if(s<g || s<=5) out.println(range(s,g));
			else{
				if(g>=6) out.println(range(s,9)+" "+range(5,0)+" "+range(1,g));
				else out.println(range(s,9)+" "+range(5,g));
			}
		}
		out.flush();
	}

	static String range(int p,int q){
		int d = p<q ? 1:-1;
		String mes = "";
		for (int i = p; i != q; i+=d) {
			mes+=i+" ";

		}
		return mes+q;
	}
}

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

using namespace std;
using ll = long long;


int main()
{
	string s;
	cin >> s;
	int n = s.size();
	for(auto &i : s)i -= '0';
	int odd = 0, even = 0; //odd: oxoxo

	for(int i = 0; i < n; i++) {
		if((i % 2 == 0 && s[i] == 0) || (i % 2 == 1 && s[i] == 1))odd++;
		if((i % 2 == 0 && s[i] == 1) || (i % 2 == 1 && s[i] == 0))even++;
	}
	cout << min(odd, even) << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n;
	cin>>n;
	vector<int> t(n);
	for(int i=0;i<n;++i) {
		cin>>t[i];
	}
	
	int ans=0;
	int curr=0;
	for(int i=0;i<n;++i) {
		if(t[i]==i+1) {
			curr++;
		}else {
			ans+=curr/2+curr%2;
			curr=0;
		}
	}
	
	ans+=curr/2+curr%2;
	
	cout<<ans<<"\n";
	return 0;
}


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

const int INF = 1001001001;

int main() {
  int h, n;
  cin >> h >> n;
  vector<int> dp(h+1, INF);
  dp[0] = 0;
  rep(i,n) {
    int a, b;
    cin >> a >> b;
    rep(j,h) {
      int nj = min(j+a,h);
      dp[nj] = min(dp[nj], dp[j]+b);
    }
  }
  cout << dp[h] << endl;
  return 0;
}


Measured memory_bytes: 3584
import java.lang.reflect.Array;
import java.util.*;

/**
 * Created by Santa.
 */
public class Main {

  static int N;
  static int K;
  static long Q;
  static int A;
  static int B;
  static long C;
  static double min = 9999999;
  static long ans = 0;




  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int A = scanner.nextInt();

    int B = scanner.nextInt();

    int K = scanner.nextInt();

    int cnt = 0;

    for (int i = 100; i > 0; i--) {
      if(A % i == 0 && B % i == 0){
        cnt++;
//        System.out.println(i);
        if(cnt == K){
          System.out.println(i);
        }
      }
    }




  }

}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
long double pi = 2 * acos(0.0);
const ll mod = 1e9 + 7;

void solve() {
    ll n;
    cin >> n;
    ll a[n];
    for(ll i = 0; i < n; i++) cin >> a[i];
    ll stocks = 0, money = 1000;
    for(ll i = 0; i + 1 < n; i++) {
        if(a[i] < a[i + 1]) {
            stocks = money / a[i];
            money -= stocks * a[i];
            money += stocks * a[i + 1];
        }
    }
    cout << money << "\n";
}
           

int main() {
    ios_base :: sync_with_stdio(false); 
    cin.tie(nullptr);   
    ll t = 1;
    //cin >> t;
    while(t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3560
n = int(input())
h = list(map(int, input().split()))
check = h[-1]
count = 0

for i in range(n):
    if check + 1 < h[n-1-i]:
        print('No')
        break
    else:
        check = min(check,h[n-1-i])
        count = i

if count == n-1:
    print('Yes')

Measured memory_bytes: 14252
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

typedef long long ll;
//typedef pair<int,int> Pint;
//typedef pair<ll, ll> P;
//typedef pair<ll, pair<ll, ll>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define revrep(i, n) for(ll i = n-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
ll INFL = 1LL << 60;//10^18 = 2^60
int INF = 1 << 30;//10^9
ll MOD = 1e9 + 7;
//ll MOD  = 998244353;
vector<ll> dy = {0, 0, 1, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, -1, 0, 0, 1, -1, 1, -1, 0};

ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  x %= MOD; x += MOD; x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}
ll inverse(ll x){return pow_mod(x, MOD - 2);};

ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a % b);
}
ll lcm(ll x, ll y){return x / gcd(x, y) * y % MOD;};


int main(){
  ll N; cin >> N;
  vector<ll> p(N); rep(i, N) cin >> p[i];
  const int X = 22000;
  vector<ll> A(N), B(N);
  rep(i, N) A[i] = X * i + 1;
  rep(i, N) B[i] = X * (N - i) + 1;
  rep(i, N){
    B[p[i]-1] += i;
  }
  rep(i, N) cout << A[i] << " ";
  cout << endl;
  rep(i, N) cout << B[i] << " ";
  cout << endl;

}


Measured memory_bytes: 1152
while True:
    data = input().split()
    a,op,b = int(data[0]),data[1],int(data[2])
    if op == "+":
        print(a+b)
    elif op == "-":
        print(a-b)
    elif op == "*":
        print(a*b)
    elif op == "/":
        print(a//b)
    elif op == "?":
        break


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

const int N=120,mod=1000000007;
inline void reduce(int&x){x+=x>>31&mod;}
int dp[N][N][N],n,a[N];
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n;
	for(int i=1;i<2*n;++i)cin>>a[i];
	sort(a+1,a+2*n);
	dp[n][1][0]=1;
	for(int i=n-1;i;--i){
		int u=a[i]!=a[i+1],v=a[2*n-i]!=a[2*n-i-1];
		for(int l=0;l<2*n;++l)
			for(int r=0;l+r<2*n;++r)if(dp[i+1][l][r]){
				for(int j=1;j<=l+u;++j)reduce(dp[i][l+u-j+1][r+v+(j>1)]+=dp[i+1][l][r]-mod);
				for(int j=1;j<=r+v;++j)reduce(dp[i][l+u+1][r+v-j]+=dp[i+1][l][r]-mod);
			}
	}
	int ans=0;
	for(int l=0;l<2*n;++l)
		for(int r=0;l+r<2*n;++r)
			reduce(ans+=dp[1][l][r]-mod);
	cout<<ans<<'\n';
	return 0;
}


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

#define rep(i, n)     for (int i = 0; i < (int) (n); i++)
#define repr(i, a, b) for (int i = a; i < b; i++)
#define each(i, mp)   for (auto &i : mp)
const int MAX_W = 5000;
const int MAX_H = 5000;
const int INF   = 1001001;

int  h, w, sy, sx, gy, gx;
char maze[MAX_W][MAX_H];
bool reached[MAX_W][MAX_H];
bool isGool = false;
int  d[MAX_W][MAX_H];
int  dx[4] = { 1, 0, -1, 0 }, dy[4] = { 0, 1, 0, -1 };
int bfs()
{
  deque <P> que;
  rep(i, w + 1) rep(j, h + 1) d[i][j] = INF;
  que.push_back(P(sx, sy));
  d[sx][sy] = 0;

  while (!que.empty()) {
    P   p = que.front();
    int now_x = p.first, now_y = p.second;
    int now_cost = d[now_x][now_y];
    que.pop_front();
    // cout << "gx= " << gx << "gy= " << gy << '\n';
    // cout << "now_x" << now_x << "now_y" << now_y <<  "now_cost" << now_cost << '\n';
    if (now_x == gx && now_y == gy) { break; }

    rep(i, 4) {
      int nx = now_x + dx[i], ny = now_y + dy[i];
      // cout << "nx=" << nx << "ny=" << ny << '\n';
      if (0 < nx && nx <= w && 0 < ny && ny <= h && maze[nx][ny] != '#' && d[nx][ny] > now_cost) {
        // 普通の移動
        que.push_front(P(nx, ny));
        d[nx][ny] = now_cost;
      }
    }
    repr(i, -2, 3) {
      repr(j, -2, 3) {
        int nx = now_x + i, ny = now_y + j;
        if (0 < nx && nx <= w && 0 < ny && ny <= h && maze[nx][ny] != '#' && d[nx][ny] > now_cost + 1) {
          // ワープ
          que.push_back(P(nx, ny));
          d[nx][ny] = now_cost + 1;
        }
      }
    }
  }

  return d[gx][gy];
}

int main()
{
  cin >> h >> w;
  cin >> sy >> sx;
  cin >> gy >> gx;

  repr(i, 1, h + 1) repr(j, 1, w + 1) cin >> maze[j][i];
  // cout << "d[gx][gy]= " << d[gx][gy] << '\n';
  ll ans = bfs();
  if (ans == INF) { ans = -1; }
  cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 16444
import collections
import sys
import time
sys.setrecursionlimit(10 ** 5)
N, M= map(int, input().split())
P = 0
e = collections.defaultdict(list)
st = time.time()
for _ in range(M):
  u, v, c = map(int, input().split())
  e[u].append((v, c))
def isConnected(n):
  if n == N:
    return True
  vis = [0] * (N + 1)
  que = collections.deque([])
  que.append(n)
  while que:
    nc = que.popleft()
    vis[nc] = 1
    for o in e[nc]:
      if o[0] == N:
        return True
      if vis[o[0]] == 0:
        que.append(o[0])
  return False
inf = float("inf")
visited = [0] * (N + 1)
earn = [-inf] * (N + 1)
earn[1] = 0
def dfs(now):
  global visited
  global earn
  visited[now] = 1
  for n in e[now]:
    if visited[n[0]] == 0:
      if n[1] + earn[now] - P > earn[n[0]]:
        earn[n[0]] = n[1] + earn[now] - P
        dfs(n[0])
        visited[n[0]] = 0
    else:
      if earn[n[0]] < n[1] + earn[now] - P:
        if isConnected(n[0]) == True:
          print("inf")
          exit(0)
dfs(1)
print(earn[N])

Measured memory_bytes: 44136
s = int(input())
f = s // 100
b = s % 100
if 1 <= f <= 12 and  1 <= b <= 12:
    print("AMBIGUOUS")
elif 1 <= b <= 12 and not  1 <= f <= 12:
    print("YYMM")
elif 1 <= f <= 12 and not  1 <= b <= 12:
    print("MMYY")
else:
    print("NA")


Measured memory_bytes: 2940
#include<stdio.h>
int main(){
  int a;
  int b[4];
  scanf("%d",&a);
  for(int i=3;i>=0;i--){
    b[i]=a%10;
    a=a/10;
  }
  for(int i=0;i<3;i++){
    if(b[i]==b[i+1]){
      printf("Bad");
      return 0;
    }
  }
  printf("Good");
  return 0;
}


Measured memory_bytes: 1708
import std.algorithm, std.conv, std.range, std.stdio, std.string;
import std.container;

void main()
{
  auto n = readln.chomp.to!size_t;

  auto ei = new size_t[][](n);
  foreach (_; n.iota) {
    auto rd = readln.split.to!(size_t[]);
    auto u = rd[0] - 1;
    auto vi = rd[2..$].map!("a - 1").array;
    ei[u] = vi;
  }

  auto di = new int[](n);
  auto fi = new int[](n);

  auto t = 1;
  for (;;) {
    auto s = di.countUntil!(d => d == 0);
    if (s == -1) break;

    di[s] = t++;

    void dfs(size_t u)
    {
      foreach (v; ei[u]) {
        if (di[v] != 0) continue;
        di[v] = t++;
        dfs(v);
      }
      fi[u] = t++;
    }

    dfs(s);
  }

  foreach (i, d, f; lockstep(di, fi))
    writefln("%d %d %d", i + 1, d, f);
}

Measured memory_bytes: 2552
fun main(args: Array<String>) {
    val (a,b) = readLine()!!.split(" ").map { it.toLong() }
    val ans = g(a-1) xor g(b)
    println(ans)
}

fun g(x:Long) = when(x%4){
    0L -> x
    1L -> 1
    2L -> x+1
    3L -> 0
    else -> 0
}

Measured memory_bytes: 38000
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

func main() {
	solve(NewScanner())
}

type constraint struct {
	s int
	c int
}

func solve(s *Scanner) {
	wtr := bufio.NewWriter(os.Stdout)
	N, M := s.nextInt(), s.nextInt()

	cs := make([]constraint, M)

	for i := 0; i < M; i++ {
		cs[i].s = s.nextInt()
		cs[i].c = s.nextInt()
	}

	dupCheck := make(map[int]int, M)

	for _, c := range cs {
		val, ok := dupCheck[c.s]
		if ok {
			if val != c.c {
				fmt.Fprintln(wtr, "-1")
				wtr.Flush()
				return
			}
		}
		dupCheck[c.s] = c.c
	}

	ans := make([]int, N)
	for i := 0; i < N; i++ {
		ans[i] = -1
	}
	for i := 0; i < N; i++ {
		for _, c := range cs {
			if c.s == i+1 {
				ans[i] = c.c
			}
		}
	}

	if ans[0] == 0 {
		if N != 1 {
			fmt.Fprintln(wtr, "-1")
			wtr.Flush()
			return
		}
	}

	if ans[0] == -1 {
		if N == 1 {
			ans[0] = 0
		} else {
			ans[0] = 1
		}
	}

	for i := 0; i < N; i++ {
		if ans[i] == -1 {
			ans[i] = 0
		}
	}

	ansstr := ""
	for i := 0; i < N; i++ {
		ansstr += strconv.Itoa(ans[i])
	}

	fmt.Fprintln(wtr, ansstr)
	wtr.Flush()
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s,t;cin >> s >> t;
	if(s[0]==t[2] && s[2]==t[0] && s[1]==t[1]) cout << "YES" << endl;
	else cout << "NO" << endl;
}

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

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

typedef long long ll;
ll N, A, B, C, D;
ll solve(ll);
map<ll,ll> memo;
ll plus_div(ll n, bool is_plus, ll divnum, ll unit_cost) { // nをdivで割れるまでプラスして割る
    ll start = n;
    ll cost = 0;
    while (n%divnum){
        n += is_plus ? 1 : -1;
        cost += D;
    }
    if (n != 0) cost += unit_cost;
    ll goal = n/divnum;
    ll dist = abs(start - goal);
    double per_cost = cost / dist;
    if (per_cost > D) { // 割るだけ無駄な時
        return solve(n/divnum) + D * dist;
    }
    return solve(n/divnum) + cost;
}
ll solve(ll n) {
    if (n == 0) return 0;
    if (memo[n] > 0) return memo[n];
    ll res = INT64_MAX;
    if (res/n > D) res = n*D;
    res = min(res, plus_div(n, true, 2, A));
    res = min(res, plus_div(n, false, 2, A));
    res = min(res, plus_div(n, true, 3, B));
    res = min(res, plus_div(n, false, 3, B));
    res = min(res, plus_div(n, true, 5, C));
    res = min(res, plus_div(n, false, 5, C));
    return memo[n] = res;
}
int main(int argc, char const *argv[])
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    ll T; cin >> T;
    REP(i, T) {
        cin >> N >> A >> B >> C >> D;
        map<ll,ll> new_mp;
        memo = new_mp;
        memo[1] = D;
        
        cout << solve(N) << endl;
    }
    return 0;
}


Measured memory_bytes: 4436
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		double r = scn.nextDouble();
		double h =2*Math.PI*r;
		double s = Math.PI* r*r;
		System.out.printf("%f %f", s, h);
	}
}



Measured memory_bytes: 28288
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define Rep(i,N) for(i=0;i<N;i++);
#define mod 1000000007

long mmax(long a,long b,long c){return a<b?max(b,c):max(a,c);}

long mmin(long a,long b,long c){return a<b?min(a,c):min(b,c);}

int mid(int a,int b,int c){
if((a<b&&b<c)||(a>b&&b>c))return 0;
return 1;
}
long long modinv(long long a) {
    long long b = mod, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= mod;
    if (u < 0) u += mod;
    return u;
}

long long moddevide(long long a,long long b){return (a*modinv(b))%mod;}

long long modncr(long long n,long long r){
  long long i,plus=1;
  for(i=0;i<r;i++){
    plus=(plus*(n-i))%mod;
    plus=moddevide(plus,i+1);
  }
  return plus;
}

long long euclidean_gcd(long long a, long long b) {
  if(a < b) return euclidean_gcd(b, a);
  long long r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main(){
  int i,N,K,cnt=0;
  char ss[5];
  cin>>N;
  vector<int> a(N);
  for(i=0;i<N;i++){
  cin>>a[i];
  }
  for(i=2;i<N;i++){
    if(mid(a[i-2],a[i-1],a[i])==0)cnt++;
  }
  cout <<cnt;
  return 0;
}

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

#define ll long long
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);

void solve()
{
    string s;
    cin>>s;
    ll final=0;
    for(ll i=0;i<s.length();i++) final+=s[i]-'0';
    if(final%9==0) cout<<"Yes";
    else cout<<"No";
}

int main()
{
	FAST
	ll t=1;
	//cin>>t;
	for(ll i=0;i<t;i++) solve();
	return 0;
}

Measured memory_bytes: 3712
/*Lower_Rating*/
/*Ex*/
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<stack>
#include<vector>
#include<queue>
#include<bitset>
#include<set>
using namespace std;

#define LL long long
#define DB double
#define MOD 1000000007
#define Pr pair<int,int>
#define X first
#define Y second
#define MAXN 1000000
#define eps 1e-10
#define INF 2147483647
#define mem(x,p) memset(x,p,sizeof(x))

LL read(){
  LL x=0,F=1;char c=getchar();
  while(c<'0'||c>'9'){if(c=='-')F=-1;c=getchar();}
  while(c>='0'&&c<='9'){x=(x<<3)+(x<<1)+c-'0';c=getchar();}
  return x*F;
}
int add(int a,int b){return (a+b>=MOD)?a+b-MOD:a+b;}
int dec(int a,int b){return (a-b<0)?a-b+MOD:a-b;}
int mul(LL a,int b){return a*b%MOD;}

int n,cntA;LL ans;
char s[MAXN+5];

int main(){
    scanf("%s",s+1);
    n=strlen(s+1);
    for(int i=1;i<=n;i++){
        if(s[i]=='A')cntA++;
        else if(s[i]=='B'&&s[i+1]=='C')
        ans+=cntA,i=i+1;
        else cntA=0;
    }
    printf("%lld",ans);
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int main(){
    int n, m;
    cin >> n >> m;
    int A[n][m];
    int b[m];
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            cin >> A[i][j];
        }
    }
    for(int i = 0; i < m; i++){
            cin >> b[i];
    }
    for(int i = 0; i < n; i++){
        int sum = 0;
        for(int j = 0; j < m; j++){
            sum = sum + A[i][j] * b[j];
        }
        cout << sum << endl;
    }
return 0;
}
    

Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin >> n;
    long long int l[n];
    int ans = 0;
    for (int i = 0; i < n; ++i){cin >> l[i];}
    sort(l, l+n);
    for (int i = 0; i < n-2; ++i){
        for (int j = i+1; j < n-1; ++j){
            for (int k = j+1; k < n; ++k){
                if(l[i] != l[j] && l[j] != l[k] && l[i]+l[j] > l[k] && l[i]+l[k] > l[j] && l[j]+l[k] > l[i]){
                    ++ans;
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3572
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define ll long long int

ll t[100001],ar[100001];

ll fun(ll l,ll r){
  if(l>=r) return 0;
  ll a=0,b=0;
  if(t[l]==-1){
   if(l+1<=r){
     a=fun(l+1,r)+abs(ar[l+1]-ar[l]);
     t[l]=a;
   }
   if(l+2<=r){
     b=fun(l+2,r)+abs(ar[l]-ar[l+2]);
     t[l]=a>=b?b:a;
   }
  }
  return t[l];
}

  int main(){
    for(int i=0;i<100001;i++)
     t[i]=-1;
    ll n;
    scanf("%lld",&n);
    for(int i=0;i<n;i++)
      scanf("%lld",ar+i);
    printf("%lld\n",fun(0,n-1));
    return 0;
  }


Measured memory_bytes: 6400
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
vector<int> a[N];
int b[N][3];
int main()
{
	ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; i++)
	{
		int u, v;
		cin >> u >> v;
		a[u].push_back(v);
	}
	for (int i = 1; i <= n; i++)
	{
		for (int j = 0; j < 3; j++)
		{
			b[i][j] = -3;
		}
	}
	int s, t;
	cin >> s >> t;
	queue <pair< int, int >> q;
	b[s][0] = 0;
	q.push({ s,0 });
	while (!q.empty())
	{
		const int cx = q.front().first, cy = q.front().second, ny = (cy + 1) % 3;
		q.pop();
		for (int i = 0; i<int(a[cx].size()); i++)
		{
			const int nx = a[cx][i];
			if (b[nx][ny] == -3)
			{
				q.push({ nx,ny });
				b[nx][ny] = b[cx][cy] + 1;
			}
		}
	}
	cout << b[t][0]/3 << endl;


}


Measured memory_bytes: 6912
use std::fmt;
use std::cmp;
use std::io::stdin;
use std::io::BufRead;
use std::str;
use std::str::FromStr;
use std::char;

fn main() {
	let stdin = stdin();
	let mut scan = InputScanner::new(stdin.lock(),256);

	let h:usize = scan.next();
	let w:usize = scan.next();

	let s = (0..h).map(|_| scan.next::<String>().chars().collect::<Vec<char>>()).collect::<Vec<Vec<char>>>();

	let mut m = (0..h).map(|_| {
		(0..w).map(|_| '.').collect::<Vec<char>>()
	}).collect::<Vec<Vec<char>>>();

	for n in 0..h {
		for i in 0..s[n].len() {
			m[n][i] = s[n][i];
		}
	}

	for n in 0..h {
		for i in 0..s[n].len() {
			if m[n][i] == '.' {
				let mut c:u32 = 0;

				for y in (cmp::max(0,n as i32 - 1) as usize)..cmp::min(n+2,h) {
					for x in (cmp::max(0,i as i32 - 1) as usize)..cmp::min(i+2,s[n].len()) {
						if y == n && x == i {
							continue;
						}

						if m[y][x] == '#' {
							c += 1;
						}
					}
				}

				m[n][i] = char::from_u32(c + '0' as u32).unwrap();
			}
		}
	}

	for l in m {
		println!("{}",l.into_iter().collect::<String>());
	}
}
struct InputScanner<R: BufRead> {
	reader: R,
	buf: Vec<u8>, // Should never be empty
	pos: usize,   // Should never be out of bounds as long as the input ends with '\n'
}
impl<R: BufRead> InputScanner<R> {
	fn new(reader: R, capacity: usize) -> Self {
		InputScanner {
			reader: reader,
			buf: Vec::with_capacity(capacity),
			pos: 0,
		}
	}

	#[inline]
	fn next<T: FromStr>(&mut self) -> T
	where
		T::Err: fmt::Debug,
	{
		if self.buf.is_empty() {
			self._read_next_line();
		}
		let mut start = None;
		loop {
			match (self.buf[self.pos], start.is_some()) {
				(b' ', true) | (b'\n', true) | (b'\r', true) => break,
				(_, true) | (b' ', false) => self.pos += 1,
				(b'\n', false) | (b'\r', false) => self._read_next_line(),
				(_, false) => start = Some(self.pos),
			}
		}
		let target = &self.buf[start.unwrap()..self.pos];
		unsafe { str::from_utf8_unchecked(target) }.parse().unwrap()
	}

	#[inline]
	fn _read_next_line(&mut self) {
		self.pos = 0;
		self.buf.clear();
		if self.reader.read_until(b'\n', &mut self.buf).unwrap() == 0 {
			panic!("Reached EOF");
		}
	}
}


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

const double PI=3.14159265358979323846;

int main(){
	double a, b, x;
	cin >> a >> b >> x;
	double rest = a*a*b - x;
	double ans;
	double h = 2*rest/(a*a);
	if(h <= b){
        double sha = sqrt(a*a + h*h);
        ans = asin(h/sha);
        printf("%.6f\n", 180*ans/PI);
	}else{
	    h = 2*x/(b*a);
	    double sha = sqrt(b*b + h*h);
	    ans = asin(h/sha);
	    printf("%.6f\n", 90 - 180*ans/PI);
	}

}


Measured memory_bytes: 256
import std.stdio, std.conv, std.string;
import std.algorithm, std.array, std.container;
import std.numeric, std.math;
import core.bitop;

T RD(T = string)() { static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }

long mod = pow(10, 9) + 7;
long moda(long x, long y) { return (x + y) % mod; }
long mods(long x, long y) { return ((x + mod) - (y % mod)) % mod; }
long modm(long x, long y) { return (x * y) % mod; }

void main()
{
	auto N = RD!long;
	auto a = RDR.split.to!(long[]);

	long cnt2, cnt4;
	foreach (e; a)
	{
		if (e % 4 == 0) ++cnt4;
		else if (e % 2 == 0) ++cnt2;
	}
	long cnt1 = N - cnt2 - cnt4;
	auto ans = cnt1 + cnt4 == N ? cnt4 >= cnt1 - 1 : cnt4 >= cnt1;

	writeln(ans ? "Yes" : "No");
	stdout.flush();
}

Measured memory_bytes: 4148
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repd(i, n) for (int i = n; i >= 1; i--)
#define mod 1000000007
#define MOD 998244353
#define inf 1e20
typedef long long int ll;
typedef pair<ll, ll> p;


int main() {
	int a, b, c;
	cin >> a >> b >> c;
	cout << (a^b^c) << endl;
	return 0;
}

//Ctrl+Aを使わない

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>

using namespace std;

#define int long long

signed main(){
	vector<int> num, in;
	vector<vector<pair<int,int>>> G;
	priority_queue<pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>>> Q;
	int N, R, sum = 0;
	
	cin>>N>>R;
	
	G.resize(N);
	num.resize(N);
	in.resize(N);
	
	for(int i = 0; i < N; i++){
		int t, e;
		cin>>t>>e;
		num[i] = t;
		in[i] = e;
		Q.push(make_pair(t,i));
	}
	
	for(int i = 0; i < R; i++){
		int a, b, c;
		
		cin>>a>>b>>c;
		a--, b--;
		
		G[b].push_back(make_pair(a,c));
	}
	
	while(!Q.empty()){
		pair<int,int> p = Q.top(); Q.pop();
		
		if(num[p.second] > p.first) continue;
		
		for(pair<int,int> next : G[p.second]){
			if(num[next.first] > num[p.second] + next.second - 1){
				num[next.first] = num[p.second] + next.second - 1;
				Q.push(make_pair(num[next.first], next.first));
			}
		}
	}
	
	for(int i = 0; i < N; i++){
		sum += in[i] * num[i];
	}
	
	cout<<sum<<endl;
	
	return 0;
}


Measured memory_bytes: 11468