akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int strig,x;
    string s;
    cin>>s;
    for(int i=0;i<s.length();i++)
    {
        if(s[i]=='A')
        {
            strig=i+1;
            break;
        }
    }
    for(int i=0;i<s.length();i++)
    {
        if(s[i]=='Z')
        {
            x=i+1;
        }
    }
    cout<<x-strig+1<<endl;
    return 0;
}
	
	
	
	
	
	


Measured memory_bytes: 640
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List

main :: IO ()
main = do
  [n,m] <- getl $ map read . words
  unless (n == 0 && m == 0) $ do
    solve <$> replicateM n (getl read) <*> replicateM m (getl read) >>= putStrLn . unwords . map show
    main

solve :: [Int] -> [Int] -> [Int]
solve xs ys
  | odd (sx + sy) = [-1]
  | otherwise = searchCards ((sy - sx) `div` 2) sxs sys
  where
    sxs = sort xs
    sys = sort ys
    sx = sum xs
    sy = sum ys

searchCards :: Int -> [Int] -> [Int] -> [Int]
searchCards _ [] _ = [(-1)]
searchCards _ _ [] = [(-1)]
searchCards d (x:xs) (y:ys)
  | x + d == y = [x, y]
  | x + d < y = searchCards d xs (y:ys)
  | otherwise = searchCards d (x:xs) ys

getl :: (String -> a) -> IO a
getl f = f <$> getLine

Measured memory_bytes: 4052
from collections import deque
h,w=map(int,input().split())
c=[list(input()) for _ in range(h)]
dhdw = [[-1,0],[1,0],[0,-1],[0,1]]
min_dis=[[-1]*w for _ in range(h)]
que=deque()
def bfs(x,y):
  que.append([x,y])
  min_dis[x][y]=0
  while que:
    sh,sw=que.popleft()
    for dh,dw in dhdw:
      nh,nw = sh+dh,sw+dw
      if not(0<=nh<=h-1) or not(0<=nw<=w-1) or min_dis[nh][nw]!=-1 or c[nh][nw]=='#':
        continue
      min_dis[nh][nw]=min_dis[sh][sw]+1
      que.append([nh,nw])
      if [nh,nw]==[h-1,w-1]:
        return min_dis[sh][sw]+1
a=bfs(0,0) or 0
if a==0:
  print(-1)
  exit()
ans=0
for i in c:
  ans+=i.count(".")
print(ans-1-a)

Measured memory_bytes: 74192
a, b, c = gets.chomp.split.map(&:to_i)
## sort は要素を新しい配列にできる
## sort! はレシーバ自身逆にして返す
array = [a, b, c].sort.reverse  ## 配列要素を逆順にする

puts (array[0] * 10 + array[1] + array[2])


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n,m,u,v;
  cin >> n >> m;
  vector<int> nbSon(n+1);
  vector<vector<int>> pere(n+1);
  for(int i = 0; i < m; ++i){
    cin >> u >> v;
    pere[v].push_back(u);
    ++nbSon[u];
  }
  deque<pair<int,int>> q;
  for(int i = 1; i <= n; ++i){
    if(nbSon[i] == 0){
      q.emplace_back(i,0);
    }
  }
  int ans = 0;
  while(!q.empty()){
    int node,val;
    tie(node,val) = q.front();
    q.pop_front();
    ans = max(ans,val);
    for(int i : pere[node]){
      --nbSon[i];
      if(nbSon[i] == 0) q.emplace_back(i,val+1);
    }
  }
  cout << ans;
  return 0;
}

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

using namespace std;

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

    double arr[n];

    for(int i=0; i<n; i++) cin >> arr[i];

    sort(arr+0,arr+n);

    for(int i=1; i<n; i++){
       arr[i] = (arr[i] + arr[i-1])/2;
    }

    cout << arr[n-1];

    return 0;
}


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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ll long long

using namespace std;

int main(){
  string n;
  cin>>n;
  
  string t=n;
  reverse(t.begin(), t.end());
  if(t==n){
    cout<<"Yes";
  }else{
    cout<<"No";
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;
 
int main(){
  int n,k; string s;
  cin >> n >> s >> k; k--;
  rep(i,n){
    if(s[i]==s[k]){cout<<s[i];}else{cout<<'*';}
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 256
n    = gets.to_i
dest = []

n.times do
  dest << gets.split.map(&:to_i)
end

dest = dest.sort_by{|d| d[0]}.unshift([0, 0, 0])

n.times do |i|
  move = (dest[i + 1][1] - dest[i][1]).abs + (dest[i + 1][2] - dest[i][2]).abs
  time = dest[i + 1][0] - dest[i][0]
  unless move <= time && (move - time) % 2 == 0
    puts :No
    exit
  end
end

puts :Yes


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

int main( ) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t,n;
	double a;
    t = 1;
    while(t--) {
     cin >> n;
     a = n / 2;
     if(n % 2)
      a++;
	 cout << fixed << setprecision(16) << a / n;
    }
    return 0;
}



Measured memory_bytes: 256
n,m=map(int,input().split())
INF=10**18
dis=[[INF for _ in range(n)]for _ in range(n)]
for i in range(m):
  a,b,c=map(int,input().split())
  dis[a][b]=c
for i in range(n):
  dis[i][i]=0
for k in range(n):
  for i in range(n):
    for j in range(n):
      dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j])
for i in range(n):
  for j in range(n):
    if dis[i][j]>=10**10:dis[i][j]='INF'
  if dis[i][i]<0:
    print('NEGATIVE CYCLE')
    exit()
for i in dis:
  print(*i)


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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define ALL(name) name.begin(),name.end()
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

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

    string S, T;
    cin >> S >> T;

    int ans = 0;
    REP(i, 3) {
        if(S[i] == T[i]) { ans++; }
    }
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>

using namespace std;

int main(){
    int N;

    cin >> N;

    int n1 = N/100*100 + N/100*10 + N/100;

    int n2 = (N/100+1)*100 + (N/100+1)*10 + N/100+1;

    if(N <= n1){
        cout << n1 << endl;
    }else{
        cout << n2 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
from collections import deque
def main():
  s = deque(list(input()))
  q = int(input())
  sr = s.reverse
  sa = s.append
  sal = s.appendleft

  cnt = 0
  for _ in range(q):
    t = input()
    if t[0] == "1":
      cnt += 1
    else:
      _,f,c = t.split(" ")
      if f == "1":
        if cnt%2==1:
          sa(c)
        else:
          sal(c)
      else:
        if cnt%2==1:
          sal(c)
        else:
          sa(c)
  if cnt%2 == 1:
    sr()
  print("".join(list(s)))

if __name__=="__main__":
  main()

Measured memory_bytes: 71272
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
from copy import deepcopy
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
inf = 10**17
mod = 10**9 + 7

h,w=MI()
data=[list(input().rstrip()) for i in range(h)]
#print(data)
deletes=[]
for i in range(h):
    count=0
    for j in range(w):
        if data[i][j]==".":
            count+=1
    if count==w:
        deletes.append(i)
for j in list(reversed(deletes)):
    del data[j]
#print(data)
h-=len(deletes)
data2=[[0 for i in range(h)] for j in range(w) ]
for i in range(w):
    for j in range(h):
        data2[i][j]=data[j][i]
#print(data2)
deletes2=[]
for i in range(w):
    count=0
    for j in range(h):
        if data2[i][j]==".":
            count+=1
    if count==h:
        deletes2.append(i)
for j in list(reversed(deletes2)):
    del data2[j]
w-=len(deletes2)
#print(data2)
data3=[[0 for i in range(w)] for j in range(h)]
#print(h,w)
#print(data3)
for i in range(h):
    for j in range(w):
        data3[i][j]=data2[j][i]
#print(data3)
for i in range(h):
    for j in range(w):
        print(data3[i][j],end="")
    print("")

Measured memory_bytes: 5236
import java.util.*

fun main(args:Array<String>){
    val (n,m) = readLine()!!.split(" ").map{it.toInt()}
    var sum = 0
    var pen = 0
    var a = HashSet<Int>()
    var b = IntArray(n)
    repeat(m){
        val (p,s) = readLine()!!.split(" ")
        if(s == "AC"){
            if(a.contains(p.toInt()) == false){
                sum++
                a.add(p.toInt())
            }
        }
        else{
            if(a.contains(p.toInt()) == false){
                b[p.toInt() - 1]++
            }
        }
    }
    for(i in 0 until n){
        if(a.contains(i + 1)){
            pen += b[i]
        }
    }
    println("${sum} ${pen}")
}


Measured memory_bytes: 58148
n = int(input())
h = [int(i) for i in input().split()]

count = 0
while True:
    flg_s = False
    for i in range(n):
        if flg_s and h[i] == 0:
            break
        if h[i] > 0:
            flg_s = True
            h[i] -= 1

    if not flg_s:
        break
    count += 1

print(count)

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<math.h>

using namespace std;

#define INF 1000000007
#define LINF 1000000000000000007

typedef long long i64;
typedef pair<i64,i64> P;


int n, a[101010];

int main(){
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	int d = a[0];
	for(int i = 1; i < n; i++){
		if(d-1 > a[i]){
			cout << "No" << endl;
			return 0;
		}
		d = max(d, a[i]);
	}
	cout << "Yes" << endl;
	
	return 0;
}

Measured memory_bytes: 640
n = gets.to_i
lis = gets.split.map(&:to_i)
lis = lis.sort.reverse
ans = 0
i = 1
k = -1
added = [[lis[0]]]
ind = 0
while i<n do
  k += 1
  new_added = []
  #p added
  for j in 0...2**k do
    new_added.push(lis[ind+j+1])
    ans += added[k][j.div(2)]
    #p ans
    i += 1
    if i>=n then
      break
    end
  end
  ind += 2**k
  added.push(new_added)
end
puts ans


Measured memory_bytes: 32656
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 266666;const ll inf=1e16;
int n,m;vector<Pii>a[N];ll dis[N];
struct zkw{
	ll a[N<<2],m;
	inline void ini(int n){
		for(m=1;m<=n+1;m<<=1);
		rep(i,0,m*2)a[i]=inf;
	}
	inline void modify(int l, int r, ll x){
		l=m+l-1;r=m+r+1;
		while((l>>1)!=(r>>1)){
			if(!(l&1))umin(a[l+1],x);
			if(r&1)umin(a[r-1],x);
			l>>=1;r>>=1;
		}
	}
	inline ll qry(int k){
		ll res=inf;for(int i=m+k;i;i>>=1)umin(res,a[i]);return res;
	}
}seg;
int main() {
	read(n);read(m);
	rep(i,1,m){
		int l,r,c;read(l);read(r);read(c);
		a[l].pb(Pii(r,c));
	}
	seg.ini(n);rep(i,2,n)dis[i]=inf;
	rep(i,1,n){
		umin(dis[i],seg.qry(i));
		rep(j,0,SZ(a[i])-1)seg.modify(i,a[i][j].fi,dis[i]+a[i][j].se);
	}
	printf("%lld\n",dis[n]<inf?dis[n]:-1);
	return 0;
}


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

int main(){
    long N, K;
    cin >> N >> K;

    long p_rest, n_rest;
    p_rest = N % K;
    n_rest = p_rest - K;

    if (p_rest <= -n_rest){
        cout << p_rest << endl;
    }else{
        cout << -n_rest << endl;
    }
}

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

int main() {
  double a, b, x;
  cin >> a >> b >> x;

  double ans;
  if (x >= a * a * b / 2) {
    ans = atan(2 * b / a - 2 * x / (a * a * a)) / M_PI * 180;
  } else {
    ans = 90 - atan(2 * x / (a * b * b)) / M_PI * 180;
  }

  printf("%.10f\n", ans);
}


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

#define int long long int
#define ll long long
#define quickie ios_base::sync_with_stdio(false); cin.tie(NULL);
#define rep(i, a, b) for(int i=a; i<b; i++)
#define rep1(i, a, b) for(int i=a; i<=b; i++)
#define repp(i, a, b) for(int i=b-1; i>=a; i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define db double
#define mi map<int, int>
#define vi vector<int>
#define qi queue<int>
#define MI(x) power(x, mod-2)
#define test int t; cin >> t;
#define pii pair<int, int>
#define mod 1000000007
#define pi 3.141592653589
#define fact(n) rep(i, 1, n+1)ft.pb((ft[i-1]*i)%mod) ;

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template<typename T>
// using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
// template<typename T>
// using ordered_multiset = tree<T,null_type,less_equal<T>,rb_tree_tag,tree_order_statistics_node_update>;
//(*****FOR USING ORDERED SET CHANGE INT*******)

int power(int x, int y) ;
int gcd(int a, int b) ;


signed main() {
    quickie
    int n ;
    cin >> n ;
    int a[n] ;
    rep(i, 0, n) cin >> a[i] ;
    sort(a, a+n) ;
    int cnt = 0 ;
    rep(i, 0, n) {
        rep(j, i+1, n) {
            if(a[i] != a[j]) {
                rep(k, j+1, n) {
                    if(a[k] != a[j] && a[k] != a[i]) {
                        if(a[i]+a[j] > a[k]) cnt++ ;
                    }
                }
            }
        }
    }
    cout << cnt << "\n" ;
}

int power(int x, int y) {
    int res = 1; x %= mod;
    while (y > 0) {
        if (y & 1)
            res = (res*x) % mod;
        y = y>>1;
        x = (x*x) % mod;
    }
    return res%mod;
}

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



Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
typedef pair<int,char>P;
int num[20],fizz[20],nn[20],nm[20],nA[20];
void make(){
	num[0]=5;
	fizz[0]=20;
	nn[0]=5;
	nm[0]=0;
	nA[0]=5;
	for(int i=1;i<20;i++){
		int x=pow(10,i+1);
		int y=pow(10,i);
		fizz[i]=(x/3+x/5)*4;
		nn[i]=(x-(x/3+x/5-x/15));
		nm[i]=(x-(x/3+x/5-x/15))*i+nm[i-1];
		for(int j=i-1;j>=0;j--)nn[i]-=nn[j];
		num[i]=nn[i]*(i+1)+num[i-1];
		nA[i]=nn[i];
	}
	r(i,19)nA[i+1]+=nA[i];
}
int ch(int mid){
	int cnt=0,keta=0,x=mid;
	while(x)x/=10,keta++;
	keta-=2;
	if(keta==-1||mid==10){
		int t=mid/3*4+mid/5*4+mid-(mid/3+mid/5);
		return t;
	}
	int t=(mid/3+mid/5)*4;
	int p=(mid-(mid/3+mid/5-mid/15))-nA[keta];
	int s=num[keta]+p*(keta+2)+t;
	return s;
}
int omt(int mid){
	mid--;
	if(mid<=10)return 0;
	int cnt=0,keta=0,x=mid,cc=0;
	while(x)x/=10,keta++;
	keta-=2;
	int t=(mid/3+mid/5)*4;
	int p=((mid)-((mid)/3+(mid)/5-(mid)/15))*(keta+1)-(nA[keta])*(keta+1)+(num[keta]-nA[keta]);
	mid/=10;
	return p;
}
string T_st(int a){
	string res;
	while(a)res+=(a%10+'0'),a/=10;
	reverse(res.begin(),res.end());
	return res;
}
char ge(int mid,int n){
	string F="FizzBuzz";
	int g=((mid-1)/3+(mid-1)/5)*3;
	g+=(mid-1)/15;
	int l=ch(mid-1);
	int sa=abs(n-mid-g-omt(mid));sa++;
	string s=T_st(mid);
	if(mid%3==0&&mid%5==0)return F[sa-1];
	else if(mid%3==0)return F[sa-1];
	else if(mid%5==0)return F[sa-1+4];
	else return s[sa-1];
}
char get(int n){
	int l=1,r=1e18+9;
	while(l<r){
		int mid=(l+r)/2;
		if(ch(mid)>=n)r=mid;
		else l=mid+1;
	}
	return ge(l,n);
}
main(){
	make();
	int n;
	cin>>n;
	r(i,20)cout<<get(i+n);
	cout<<endl;
}


Measured memory_bytes: 3304
def select(x, y, ops, i, z):
    # true -> x を増やす
    if not(x == 1 and y == 1 and i < len(ops) - 1):
        if x < y:
            return True
        else:
            return False

    # x = y = 1, i < len(ops) - 1
    # 先読みして xz なら x を増やす
    # 先読みして xy なら y を増やす
    # 先読みして xy なら どっちでもいい
    op = ops[i]
    nop = ops[i+1]

    oo = (op, nop)
    if op == nop:
        return True

    if oo in [("AB", "AC"), ("BC", "AB"), ("AC", "AB")]:
        return True

    return False

def main():
    nabc = [int(_x) for _x in input().split()]
    n = nabc[0]
    a = nabc[1]
    b = nabc[2]
    c = nabc[3]

    ops = []
    for i in range(n):
        ops.append(input())

    result = []
    for i in range(n):
        op = ops[i]
        if op == "AB":
            if select(a, b, ops, i, c):
                result.append("A")
                a+=1
                b-=1
            else:
                result.append("B")
                a-=1
                b+=1
        if op == "AC":
            if select(a, c, ops, i, b):
                result.append("A")
                a+=1
                c-=1
            else:
                result.append("C")
                a-=1
                c+=1
        if op == "BC":
            if select(b, c, ops, i, a):
                result.append("B")
                b+=1
                c-=1
            else:
                result.append("C")
                b-=1
                c+=1                
        if a <0 or b<0 or c<0:
            print("No")
            return

    print("Yes")
    for r in result:
        print(r)

main()



Measured memory_bytes: 16924
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<P,ll> PPI;
typedef pair<ll,P> PIP;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vp;
#define PQ(T) priority_queue<T,vector<T>,greater<T>>
#define PQ2(T) priority_queue<T>
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define REP(i,a,b) for(ll (i)=a;(i)<(ll)(b);++(i))
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) ((x)=min((x),(y)))
#define chmax(x,y) ((x)=max((x),(y)))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
#define DEBUG(x) cerr<<"line ("<<__LINE__<<")  "<<#x<<": "<<x<<endl;
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	ll a, b, c, d;
	cin>>a>>b>>c>>d;
	ll x = abs(c-a), y = abs(d-b);
	ll g = __gcd(x, y);
	cout<<(x/g+y/g-1)*g<<endl;
	return 0;
}


Measured memory_bytes: 256
using System;

class CountABC
{
    static void Main(string[] args)
    {
        var number = int.Parse(Console.ReadLine());
        var words = Console.ReadLine();
        int count = 0;
        int start = 0;

        for(var i = 0;i < number; i++)
        {

            var  check = words.IndexOf("ABC",start);
            start = check + 3;

            if(check == -1)
            {
                break;
            }
            else
            {
                count++;
            }
        }
        Console.WriteLine(count);
    }
   
}

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


void solve(long long N, std::vector<long long> A){
    ll ans = 1;
    if(count(A.begin(), A.end(), 0LL) == 0){
        for(int i = 0;i < N;i++){
            if(log10(1.0L * ans) + log10(1.0L * A[i]) > 18){
                //cout<<log10(ans) + log10(A[i])<<endl;;
                cout<<-1<<endl;
                return;
            }
            ans *= A[i];
        }
        if(ll(1e18) < ans){
            cout<<-1<<endl;
        }else{
            cout<<ans<<endl;
        }
    }else{
        cout<<0<<endl;
    }
}

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


Measured memory_bytes: 4080
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int MAX = 200010;
class shuturyoku_unko {
public:
	char C[MAX * 6 + 10];
	int K[MAX + 10];
	constexpr shuturyoku_unko() : C(), K() {
		auto di = C + 1;
		C[0] = '0';
		K[0] = 0;
		K[1] = 1;
		rep1(i, MAX) {
			int X = i;
			int keta = 0;
			char c[10] = {};
			while (X) {
				*(c + keta) = '0' + X % 10;
				X /= 10;
				keta++;
			}
			for (int j = keta - 1; j >= 0; j--)* di++ = (*(c + j));
			K[i + 1] = K[i] + keta;
		}
	}
} f;
const int dm = 1 << 21;
char dn[dm], * di = dn;
inline void putint(int X) {
	for (int i = f.K[X]; i < f.K[X + 1]; i++)* di++ = f.C[i];
	*di++ = '\n';
}

int A[200001];
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	int N, K, C;
	scanf("%d %d %d ", &N, &K, &C);
	char S[200010];
	fread(S, 1, N, stdin);

	int kari = K;
	for (int i = N - 1; i >= 0; i--) {
		if (S[i] == 'o') {
			A[i] = kari--;
			i -= C;
		}
	}
	kari = 1;
	rep(i, N) {
		if (S[i] == 'o') {
			if (A[i] == kari++) putint(i + 1);
			i += C;
		}
	}
	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}

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


int main()
{
    ll n,k;
    cin>>n>>k;
    vector<int>a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int low =1;
    int high = 1e9+10;
    while(low!=high){
            int z=k;
        int mid = (low+high)/2;
        for(auto x:a){

            int p = (x+mid-1)/mid - 1;
            z-=p;
        }
        if(z>=0){high=mid;}
        else low=mid+1;
    }
    cout<<low;
    return 0;
}


Measured memory_bytes: 4020
#include <stdio.h>

int main(void){
    
   	int a, b, c;
	double s, d, h;
	double sita;
	double pi = 3.14159265359;

	scanf("%d%d%d", &a, &b, &c);
	sita = c * pi / 180;
	
	
	s = a * b*sin(sita) / 2;

	h = 2 * s / a;

	d = pow(a*a + b * b - 2 * a*b*cos(sita), 0.5);

	printf("%lf\n", s);
	printf("%lf\n", a +b+d);
	printf("%lf\n", h);

    
    return 0;
}


Measured memory_bytes: 2104
//bfs instead of dfs cz sp;

#include<bits/stdc++.h>

using namespace std;

int h,w,k,stx,sty,dist[805][805],x[4]={0,0,1,-1},y[4]={1,-1,0,0},mini=1e9;
char g[805][805];
queue< pair< int, int> > qq;
pair< int, int> now,next;

void ff(int a, int b) {
	dist[stx][sty]=0;
	qq.push(make_pair(stx,sty));
	while(!qq.empty()) {
		now=qq.front();
		qq.pop();
		if(now.first==1 || now.first==h || now.second==1 || now.second==w || dist[now.first][now.second]>=k)
			continue;
		for(int i=0;i<4;i++) {
			int nextx=now.first+x[i],nexty=now.second+y[i];
			if(dist[nextx][nexty]==-1 && g[nextx][nexty]=='.') {
				dist[nextx][nexty]=dist[now.first][now.second]+1;
				qq.push(make_pair(nextx,nexty));
			}
		}
	}
}

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    memset(dist,-1,sizeof(dist));
    cin>>h>>w>>k;
    for(int i=1;i<=h;i++) {
    	for(int j=1;j<=w;j++) {
    		cin>>g[i][j];
    		if(g[i][j]=='S') {
    			stx=i;
    			sty=j;
    			if(stx==1 || stx==h || sty==1 || sty==w) {
    				cout<<0<<endl;
    				return 0;
				}
			}
		}
	}
	ff(stx,sty);
	for(int i=1;i<=h;i++) {
    	for(int j=1;j<=w;j++) {
    		if(dist[i][j]!=-1) {
    			if(i==1 || i==h || j==1 || j==w) {
    				mini=0;
				}
    			mini=min(mini,(max(0,i-1-1))/k+1);
    			mini=min(mini,(max(0,h-i-1))/k+1);
				mini=min(mini,(max(0,j-1-1))/k+1);
				mini=min(mini,(max(0,w-j-1))/k+1);	
			}
		}
	}
	cout<<mini+1<<endl;
}

Measured memory_bytes: 3456
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#define ll long long
using namespace std;
int main(){
    string s;
    int q;
    cin>>s>>q;
    int sumq=0;
    for(int i=0;i<q;i++){
        int qu1;
        cin>>qu1;
        if(qu1==1){
            sumq++;
        }else{
            int qu2;
            string c;
            cin>>qu2>>c;
            int rsumq=sumq%2;
            bool con1=rsumq==0;
            bool con2=qu2==1;
            if(con1&con2||!con1&!con2){
                s.insert(0,c);
            }else{
                s+=c;
            }
        }
    }
    if(1==sumq%2){
        reverse(s.begin(),s.end());
    }
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 900
#include <bits/stdc++.h>
#define rep(i,n) for(ll i = 0; i < (ll)(n); ++i)

using namespace std;
using ll = long long;

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	int ng = 0, ok = 1e9;
	while (ok - ng > 1) {
		int mid = (ok + ng) / 2;
		int cut = 0;
		rep (i, n) cut += (a[i] - 1) / mid;
		if (cut > k) ng = mid;
		else ok = mid;
	}
	cout << ok << endl;
	return 0;
}


Measured memory_bytes: 3984
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String[] splitS = S.split("");
        boolean result = splitS[2].equals(splitS[3]) && splitS[4].equals(splitS[5]);
        System.out.println(result ? "Yes" : "No");
    }
}


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

int main() {
	int x,N, M,val;
	cin >> x >> N >> M;
	bool a = false;

	for (int i = 1; i <= 1000; i++) {
		val = x * i;
			if (val >= N && val <= M) {
				a = true;
				break;
			}
	}

	if (a == true)
		cout << "OK" << endl;
	else
		cout << "NG" << endl;
}

Measured memory_bytes: 3624
#include <stdlib.h>
#include <iostream>
#include <math.h>
 
using namespace std;
 
int main(){
  int n;
  long h,w;
  cin >> n >> h >> w;
  long m[n][2];
  for(int i=0;i<n;i++){
    cin >> m[i][0] >> m[i][1];
  }
  int ans=0;
  for(int i=0;i<n;i++){
    if(m[i][0]>=h &&m[i][1]>=w){
      ans++;
    }
  }
  cout << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const int mod = 1e9 + 7;
//const int mod = 998244353;
const ll infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;
void YesNo(bool j){cout << (j ? "Yes" : "No") << endl; return;}
void yesno(bool j){cout << (j ? "yes" : "no") << endl; return;}
template<class Head> void pt(Head&& head){cout << head << endl; return;}


int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int a=s.size();
    if(n>=a) pt(s);
    else {
        s=s.substr(0,n);
        s+="...";
        pt(s);
    }

    return 0;
}

Measured memory_bytes: 3624
#include<stdio.h>
#include<stdlib.h>
#ifdef DEBUG
#include<conio.h>
#endif // DEBUG

int cmp(const void* a, const void* b) {
    return *(int *)a - *(int*)b;
}

int main () {
#ifdef DEBUG
    freopen("input.txt", "r", stdin);
#endif // DEBUG
    
    int a[3];
    scanf("%d %d %d", &a[0], &a[1], &a[2]);
    qsort(a, 3, sizeof(a[0]), cmp);
    printf("%d %d %d\n", a[0], a[1], a[2]);
    

#ifdef DEBUG
    getch();
#endif // DEBUG
    return 0;
}




Measured memory_bytes: 2068
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int a[21];
    for(int i=0;i<n;i++)cin >> a[i];
    int ans = 1;
    int mx = a[0];
    for(int i=1;i<n;i++){
if(mx <= a[i]){
//    cout << i << endl;
    ans++;
mx = a[i];
}
    }
    cout << ans << endl;
    return 0;
}

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

int main(void){
	int m, f, r;
	while(1){
		cin >>m >>f >>r;
		if(m==-1 && f==-1 && r==-1){
			break;
		}
		if(m==-1 || f==-1){
			cout <<"F" <<endl;
		}else if(m+f>=80){
			cout <<"A" <<endl;
		}else if(m+f>=65){
			cout <<"B" <<endl;
		}else if(m+f>=50){
			cout <<"C" <<endl;
		}else if(m+f>=30){
			if(r>=50){
				cout <<"C" <<endl;
			}else{
				cout <<"D" <<endl;
			}
		}else{
			cout <<"F" <<endl;
		}
	}
    return 0;
}

Measured memory_bytes: 1152
#include <stdio.h>  /*入出力*/
#include <stdlib.h> /*標準ライブラリ*/
#include <string.h> /*文字列*/
#include <math.h>   /*計算*/

/*ABC 142*/

int main(void)
{
  int N;
  int *A;
  int *B;

  scanf("%d", &N);
  A = (int *)malloc(sizeof(int) * N);
  if (A == NULL) {
    exit(0);
  }
  B = (int *)malloc(sizeof(int) * N);
  if (B == NULL) {
    exit(0);
  }


  for (size_t i = 0; i < N; i++) {
    scanf("%d", &A[i]);
  }
  for (size_t i = 0; i < N; i++) {
    B[i] = 0;
  }
  for (size_t i = 0; i < N; i++) {
    B[A[i]-1] = i;
  }

  for (size_t i = 0; i < N; i++) {
    printf("%d ", B[i]+1);
  }
  printf("\n");
  free(A);
  free(B);
  return 0;
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
    ll a,b,c,d;
    cin>>d;
    a=d/1000; d%=1000;
    b=d/100; d%=100;
    c=d/10; d%=10;
    ll sb[2]={b,-b},sc[2]={c,-c},sd[2]={d,-d};
    string op="+-";
    rep(i,2){
        rep(j,2){
            rep(k,2){
                if(a+sb[i]+sc[j]+sd[k]==7){
                    cout<<a<<op[i]<<b<<op[j]<<c<<op[k]<<d<<"=7"<<endl;
                    return 0;
                }
            }
        }
    }
}

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> c(n);
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        ++c[a - 1];
        ++c[b - 1];
    }
    for (int i : c) {
        if (i & 1) {
            cout << "NO\n";
            return 0;
        }
    }
    cout << "YES\n";
    return 0;
}


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

int main()
{
	int n,a,b;
	bool F=0;
	cin>>n>>a>>b;
	for(a;a<=b;a++)
	{
		if(a%n==0){
			F=1;break;
		}
	}
	if(F) cout<<"OK\n";
	else cout<<"NG\n";
}

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


#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

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

void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

signed main() {
  int64_t s,w;
  cin >> s >> w;
  
  if(s>w) cout << "safe" << endl;
  else cout << "unsafe" << endl;
  
  return 0;
}

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

bool cmp(string a,string b)
{
    return a<b;
}

int main()
{
    string a[10000];
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;++i)
    {
        cin>>a[i];
    }
    sort(a+1,a+n+1,cmp);
    for(int i=1;i<=n;++i)
    {
        cout<<a[i];
    }
    return 0;
}

Measured memory_bytes: 384
/*まずうちさあ屋上あんだけど、焼いてかない？*/
	#include <bits/stdc++.h>
	using namespace std;
	#define IOS ios::sync_with_stdio(false), cin.tie(0)
	#define REP(i, n) for (int i = 0; i < n; i++)
	#define FOR(i, a, b) for (int i = a; i < b; i++)
	#define ALL(x) (x).begin(), (x).end()
	#define dump(x) cout << (x) << endl
	#define LMAX 9223372036854775807LL
	#define LMIN -9223372036854775807LL

	using ll = long long;
	template<typename T>
	using vec = vector<T>;
	using P = pair<ll, ll>;

	template <typename A, size_t N, typename T>
	void Fill(A (&array)[N], const T &val){
		fill((T *)array, (T *)(array + N), val);
	}
	
	const ll INF = 1e18;
	const ll mod = 1e9 + 7;

	//int dx[4] = {1,0,-1,0};
	//int dy[4] = {0,1,0,-1};
	//ll pas[51][52];

	int main(){
		IOS;
		ll n, k;
		cin >> n >> k;
		vec<P> a(n);
		vec<ll> x(n),y(n);
		REP(i,n){
			cin >> x[i] >> y[i];
			a[i] = P(x[i],y[i]);
		}
		sort(ALL(x));sort(ALL(y));
		ll ans = (x[n - 1] - x[0]) * (y[n - 1] - y[0]);
		for(int i = 0;i < n - 1;i++)for(int j = i + 1;j < n;j++)for(int t = 0;t < n - 1;t++)for(int s = t + 1;s < n;s++){
			ll cnt = 0;
			ll lx = x[i],rx = x[j];
			ll dy = y[t],uy = y[s];
			REP(l,n){
				int xx = a[l].first,yy = a[l].second;
				if(xx >= lx && xx <= rx && yy >= dy && yy <= uy)cnt++;
			}
			if(cnt >= k)ans = min(ans,(rx - lx) * (uy - dy));
		}
		dump(ans);
	}

Measured memory_bytes: 256
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; i++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// Nの桁数
ll dig(ll N) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= 10;
	}
	return dig;
}
// x,yの最大公約数
ll gcd(ll x, ll y) {
	ll r;
	while (x%y) {
		r = x % y;
		x = y;
		y = r;
	}
	return y;
}

int main() {
	ll N; cin >> N;
	vector<char> S(N); rep(i, N)cin >> S[i];

	map<char, int> p;
	rep(i, N) p[S[i]] = 1;

	int cnt = 0;
	auto b = p.begin(), e = p.end();
	for (auto it = b; it != e; it++) {
		cnt += it->second;
	}

	if (cnt == 3) cout << "Three" << endl;
	else cout << "Four" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int long long
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int a,b;
	cin>>a>>b;
	if(a>=13)
	{
		 cout<<b<<endl;
	}
	else if(a>=6&&a<=12)
	{
		 cout<<b/2<<endl;
	}
	else
		cout<<0<<endl;

}

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

int main(){
    while(true){
        int h,w;
        cin >> h >> w;
        
        if(h==0 || w==0){
            break;
        }
        
        for(int i=0; i<h; i++){
            for(int j=0; j<w; j++){
                if(i%2==0 && j%2==0){
                    cout<<"#";
                }
                else if(i%2==0 && j%2==1){
                    cout<<".";
                }
                else if(i%2==1 && j%2==1){
                    cout<<"#";
                }
                else{
                    cout<<".";
                }
            }
            cout<<endl;
        }
        cout<<endl;
        
    }
    return 0;
}




Measured memory_bytes: 3088
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main() {
  int N,K;
  string S;
  cin>>N>>S>>K;
  for (char &c:S){
    if (c != S[K-1])
      c = '*';
  }
  cout<<S;
  return 0;
}

Measured memory_bytes: 256
n=int(input())
l=[]
for i in range(n):
    k=input()
    l.append(k)
print("AC x {}".format(l.count("AC")))
print("WA x {}".format(l.count("WA")))
print("TLE x {}".format(l.count("TLE")))
print("RE x {}".format(l.count("RE")))



Measured memory_bytes: 16292
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);i++)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;i--)
#define lb lower_bound
#define ub upper_bound
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 +99);
vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> void chmin(T& t, const U& u){if(t>u)t=u;}
template<typename T,typename U> void chmax(T& t, const U& u){if(t<u)t=u;}
template<typename T>T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T>T mpow(T a, T n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}



signed main(){
  cin.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  ll n,ans=0;cin>>n;
  string s;cin>>s;
  map<pair<string,string>,ll> ma;
  rep(i,0,mpow(2ll,n)){
      string a="",b="";
      int x=i,cnt=0;
      rep(j,0,n){
          if(x&1){
              a+=s[n+cnt];
          }else{
              b+=s[n+cnt];
          }
          cnt++;
          x/=2;
      }
      reverse(all(b));
      ma[mp(a,b)]++;
  }

  rep(i,0,mpow(2ll,n)){
      string a="",b="";
      int x=i,cnt=0;
      rep(j,0,n){
          if(x&1){
              a+=s[cnt];
          }else{
              b+=s[cnt];
          }
          cnt++;
          x/=2;
      }
      reverse(all(b));
      ans+=ma[mp(b,a)];
  }
  cout<<ans<<endl;
}
//( ・ __ ・ ) KEEP BEING ORGANIZED
//CHECK overflow,vector_size,what to output?

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



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

	int n;
	cin >> n;
	vector<vector<int>> a(n, vector<int>(n, 0));
	REP(i, n) {
		int u, k;
		cin >> u >> k;
		u--;
		REP(j, k) {
			int v;
			cin >> v;
			a[u][--v] = 1;
		}
	}
	REP(i, n) {
		REP(j, n) {
			cout << a[i][j];
			if (j < n - 1) cout << " ";
			else cout << "\n";
		}
	}
	
	return 0;
}



Measured memory_bytes: 3276
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    int n,m,t;cin>>n>>m>>t;
    vi v(n); rep(i,n)cin>>v[i];
    int ans=0;
    int current=0;
    ans+=v[0]-m;
    rep(i,n-1){
        if(v[i+1]-v[i]<m*2)continue;
        ans+=v[i+1]-v[i]-m*2;
    }
    if(t-v[n-1]>m)ans+=t-v[n-1]-m;
    cout<<ans<<endl;
}

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

using namespace std;
typedef long long ll;

ll p[110], q[110], r[110], b[110];
int par[110];

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

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

ll rec(int s) {
  if (s == 0) return 1;
  ll LCM = lcm(p[s] * rec(r[s]), q[s] * rec(b[s]));
  return LCM / p[s] + LCM / q[s];
}

int main(void) {
  int n;
  while (cin >> n, n) {
    fill(par, par + 110, -1);
    for (int i = 1; i <= n; i++) {
      cin >> p[i] >> q[i] >> r[i] >> b[i];
      if (r[i]) par[r[i]] = i;
      if (b[i]) par[b[i]] = i;
    }

    for (int i = 1; i <= n; i++) {
      if (par[i] > 0) continue;
      cout << rec(i) << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pf push_front
#define mod 1000000007
#define endl '\n'
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

int main()
{
    ll n,i;
    cin>>n;
    ll arr[n];
    for(i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    ll j,ans=0;
    for(i=0;i<n;i++)
    {
        for(j=i+1;j<n;j++)
        {
            ans+=(arr[i]*arr[j]);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define NMAX 100
#define AMAX 99

void push(int);
int pop(void);

int top=0;
int bufp[500];

int main(){
  int num,n1,n2;
  char buf[NMAX];
  
  while(scanf("%s",buf)!=EOF){
    if ( buf[0] == '+' ){
      n1=pop();
      n2=pop();
      push(n1+n2);
    } else if ( buf[0] == '-' ){
      n1=pop();
      n2=pop();
      push(n2-n1);
    } else if ( buf[0] == '*' ){
      n1=pop();
      n2=pop();
      push(n1*n2);
    } else {
      num = atoi(buf);
      push(num);
    }
  }
  printf("%d\n",pop());
  return 0;
}

void push(int n){
  top+=1;
  bufp[top]=n;
}

int pop(void){
  top-=1;
  return bufp[top+1];
}





Measured memory_bytes: 2044
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import time
import datetime

def calc(stay1, stay2):
    d  = datetime.datetime.strptime(stay1[0], "%H:%M")
    dd = datetime.datetime.strptime(stay2[2], "%H:%M")
    diff = (d - dd).seconds
    return diff/60

def __main__():
    n, m = map(int, raw_input().split(" "))
    stay = [map(str, raw_input().split(" ")) for _ in xrange(n)]
    ans = []
    for i in xrange(len(stay)):
        for j in xrange(len(stay)):
            if stay[i][1] == stay[j][3] and calc(stay[i], stay[j]) >= m:
                ans.append(str(stay[i][1]) + " " + str(calc(stay[i], stay[j])))
    print len(ans)
    for i in xrange(len(ans)):
        print ans[i]
                
__main__()

Measured memory_bytes: 7160
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cmath>
#include <functional>
#include <queue>
//#include <stack>
#include <climits>
#include <map>
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define put(a) cout<<a<<endl;
using namespace std;
typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> P;

ll n,m;

int main() {
    cin >> n >> m;
    vector<ll> x(n);
    vector<ll> sx(n+1);
    vector<ll> y(m);
    vector<ll> sy(m+1);
    sx[0] = 0;
    REP(i,n){
        cin >> x[i];
        sx[i+1] = sx[i]+x[i];
    }
    sy[0] = 0;
    REP(i,m){
        cin >> y[i];
        sy[i+1] = sy[i]+y[i];
    }
    const ll p = 1000000007;
    ll dx=0,dy=0;
    REP(i,n){
        dx = (dx+sx[n]-sx[i+1]-(n-i-1)*x[i])%p;
    }
    REP(i,m){
        dy = (dy+sy[m]-sy[i+1]-(m-i-1)*y[i])%p;
    }
    ll res = (dx*dy)%p;
    put(res);
    return 0;
}


Measured memory_bytes: 3328
import java.util.Scanner;

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

		int n = scanner.nextInt();
		int m = scanner.nextInt();
		int l = scanner.nextInt();
		
		int[][] A; 
		A = new int[n][m];
		int[][] B;
		B =new int[m][l];
		long[][]C;
		C = new long[n][l];
		
		
		
		for(int i=0;i<n;i++){
			for(int f=0;f<m;f++){
				int a = scanner.nextInt();
				A[i][f]=a;	
			}
		}
		
		for(int i=0;i<m;i++){
			for(int f=0;f<l;f++){
				int b = scanner.nextInt();
				B[i][f]= b;	
			}
		}
		
		for(int i=0;i<n;i++){
			for(int j=0;j<l;j++){
				for(int k=0;k<m;k++){
					C[i][j]=C[i][j]+(A[i][k]*B[k][j]);
					
				}
				
				System.out.print(C[i][j]);
				if(!(j == l-1)){
					System.out.print(" ");
				}
			}
			System.out.println("");
		}

		scanner.close();
	}
}



Measured memory_bytes: 55916
N = int(input())
A = list(map(int,input().split()))
O = []
E = []
for a in A:
    if a % 2 == 0:
        E.append(a)
    else:
        O.append(a)

if len(O) % 2 == 1:
    print("NO")
else:
    print("YES")

Measured memory_bytes: 14108
import java.util.*;

class Main{
    public static void main(String argv[]) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] A = new int[N];
        for(int i=0;i<N;i++){
            A[i] = sc.nextInt();
        }
        Arrays.sort(A);
        int[][] BC = new int[M][2];
        for(int i=0;i<M;i++){
            BC[i][0] = sc.nextInt();
            BC[i][1] = sc.nextInt();
        }
        Arrays.sort(BC, (a,b)->a[1]-b[1]);

        int m = M-1;
        int n = N-1;
        int count = 0;
        long total = 0;
        while(count < N){
            int b = BC[m][0];
            int c = BC[m][1];
            while(b>0 && n>=0 && count < N){
                count++;
                if(c<=A[n]){
                    total += A[n];
                    n--;
                }
                else{
                    total += c;
                    b--;
                }
            }
            m--;
            if(m<0){
                while(count < N){
                    count++;
                    total += A[n];
                    n--;
                }
                break;
            }
        }
        System.out.println(total);
    }
}

Measured memory_bytes: 95780
#include <cstdio>

#define N 2001
#define P 4000001
#define M 1000000007LL

long long p[2][P], f[N][N];
int n, k, t;

long long sel(int n, int m)
{
    return n >= m ? p[0][n] * p[1][m] % M * p[1][n - m] % M : 0;
}

int main()
{
    scanf("%d%d", &n, &k);
    t = n * k;

    if (k == 1)
    {
        puts("1");
        return 0;
    }

    p[0][0] = 1;
    for (int i = 1; i <= t; i++)
        p[0][i] = p[0][i - 1] * i % M;

    p[1][t] = 1;
    for (long long x = p[0][t], e = M - 2; e; e >>= 1, x = x * x % M)
        if (e & 1)
            p[1][t] = p[1][t] * x % M;

    for (int i = t; i; i--)
        p[1][i - 1] = p[1][i] * i % M;

    f[0][0] = 1;
    for (int i = 0; i <= n; i++)
    {
        for (int j = i; j <= n; j++)
        {
            f[i][j + 1] = (f[i][j + 1] + f[i][j]) % M;
            f[i + 1][j] = (f[i + 1][j] + f[i][j] * sel(t - i * (k - 1) - j - 1, k - 2) % M) % M;
        }
    }

    printf("%lld\n", f[n][n] * p[0][n] % M);
    return 0;
}


Measured memory_bytes: 93952
inp = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n')[0].split(' ')
A = inp.shift()
B = inp.shift()
console.log((A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0) ? 'Possible' : 'Impossible')

Measured memory_bytes: 21064