akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define N 400005
#define LL long long
#define L(__) (__ << 1)
#define R(__) (L(__)|1)
#define INF (1LL<<60)
using namespace std;
LL A[4*N],T[4*N],ans=INF;
int n,k,l[N],r[N],w[N],lw,a[N],b[N];
void B(int t,int l,int r)
{
	int mid=(l+r)>>1; T[t]=-INF;
	if(l==r){ A[t]=-w[l]; return ;}
	B(L(t),l,mid);
	B(R(t),mid+1,r);
	A[t]=min(A[L(t)],A[R(t)]);
}
void TA(int t,LL x){ T[t]=A[t]=x;}
void push(int t)
{
	if(T[t]==-INF) return ;
	TA(L(t),T[t]),TA(R(t),T[t]);
	T[t]=-INF;
}
void M(int t,int l,int r,int l1,int r1,LL x)
{
	int mid=(l+r)>>1;
	if(l>r1||r<l1||l>r) return ;
	if(l>=l1&&r<=r1) return TA(t,x);
	push(t);
	M(L(t),l,mid,l1,r1,x);
	M(R(t),mid+1,r,l1,r1,x);
	A[t]=min(A[L(t)],A[R(t)]);
}
LL Q(int t,int l,int r,int l1,int r1)
{
	int mid=(l+r)>>1; LL z=INF;
	if(l>r1||r<l1||l>r) return INF;
	if(l>=l1&&r<=r1) return A[t];
	push(t);
	z=min(z,Q(L(t),l,mid,l1,r1));
	z=min(z,Q(R(t),mid+1,r,l1,r1));
	A[t]=min(A[L(t)],A[R(t)]);
	return z;
}
int main()
{
	int i,p; LL z,e;
	scanf("%d %d",&n,&k),p=0;
	for(i=1;i<=n;i++){
		scanf("%d %d",&a[i],&b[i]);
		if(2*a[i]>k&&b[i]==1){ printf("-1"); exit(0);}
		if(b[i]==2) l[i]=k-1,r[i]=0;
		else r[i]=p,l[i]=(p-2*a[i]%k+k)%k;
		p=(p-2*a[i]%k+k)%k;
	  }
	for(i=1;i<=n;i++) w[++lw]=l[i],w[++lw]=r[i];
	sort(w+1,w+lw+1);
	lw=unique(w+1,w+lw+1)-w-1;
	for(i=1;i<=n;i++){
		l[i]=lower_bound(w+1,w+lw+1,l[i])-w;
		r[i]=lower_bound(w+1,w+lw+1,r[i])-w;
	  }
	B(1,1,lw);
	for(i=1;i<=n;i++){
		if(l[i]<r[i]){
			z=Q(1,1,lw,l[i]+1,r[i]-1);
			M(1,1,lw,l[i]+1,r[i]-1,INF);
			e=Q(1,1,lw,r[i],r[i]);
			if(z<e) M(1,1,lw,r[i],r[i],z);
		  }
		else{
			z=Q(1,1,lw,l[i]+1,lw);
			M(1,1,lw,l[i]+1,lw,INF);
			z=min(z+k,Q(1,1,lw,1,r[i]-1));
			M(1,1,lw,1,r[i]-1,INF);
			e=Q(1,1,lw,r[i],r[i]);
			if(z<e) M(1,1,lw,r[i],r[i],z);
		  }
	  }
	for(i=1;i<=lw;i++)
		ans=min(ans,Q(1,1,lw,i,i)+w[i]);
	for(i=1;i<=n;i++) ans+=a[i]*2;
	cout<<ans;
 	return 0;
}


Measured memory_bytes: 13312
fh = int(input())
oh = int(input())
ft = int(input())
to = int(input())
count = 0

for i in range(fh+1):
    for n in range(oh+1):
        for s in range(ft+1):
             if 500*i+100*n+50*s == to:
                 count += 1
print(count)
    

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    i64 n, k;
    std::cin >> k >> n;
    if (k % 2 == 0) {
        std::cout << k / 2 << " ";
        for (int i = 1; i < n; i++) std::cout << k << " ";
        std::cout << std::endl;
        return 0;
    }
    std::deque<i64> q(n, (k + 1) / 2);
    for (int i = 0; i < n / 2; i++) {
        if (q.back() == 1) q.pop_back();
        else {
            q.back()--;
            while (q.size() < n) q.push_back(k);
        }
    }
    for (auto el : q) std::cout << el << " ";
    std::cout << std::endl;

    return 0;
}

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

const long long int MOD = 1e9 + 7;
char board[1001][1001];
int h,w;
long long int dp[1001][1001];

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

	cin >> h >> w;

	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			cin >> board[i][j];
		}
	}

	dp[0][0] = 1;

	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			if(board[i][j]=='#')
			{
				continue;
			}
			if(i-1>=0)
			{
				if(board[i-1][j]=='.')
				{
					dp[i][j] = ((dp[i][j]%MOD) + (dp[i-1][j]%MOD));
					dp[i][j]%=MOD;
				}
			}
			if(j-1>=0)
			{
				if(board[i][j-1]=='.')
				{
					dp[i][j] = ((dp[i][j]%MOD) + (dp[i][j-1]%MOD));
					dp[i][j]%=MOD;
				}
			}
		}
	}

	cout << dp[h-1][w-1] << '\n';
	
	return 0;
}


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

int main(){
    int a, b, c, ans = 0;
    cin >> a >> b >> c;
    for (int i = a; i <= b; i++){
        if (c % i == 0) {
            ans += 1;
        }
    }
    cout << ans << endl;
    return 0;
}


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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;
const ld PI = 3.141592653589793238;

// <------------- Declare Variables Here ------------> //

ll dx4[] = {0, 0, 1, -1};
ll dy4[] = {1, -1, 0, 0};

ll T = 1;
ll n, k;
string s;

// <------------- Implement Functions Here ----------> //


// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> n;
	vll a(n);
	for(ll i=0;i<n;i++) cin>>a[i];
	sort(all(a));
	cout<<a[n/2] - a[n/2-1];
}

int main() {
	fastio; randomINT;
	//cin>>T;
	while (T--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 4024
#float型を許すな
#numpyはpythonで
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,pi,factorial
from operator import itemgetter
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)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
lisp=tuple(LI())
lisq=tuple(LI())
x=[i for i in range(1,n+1)]
u=permutations(x)
count=0
for i in u:
    if i==lisp:
        P=count
    if i==lisq:
        Q=count
    count+=1
print(abs(P-Q))
    
    



Measured memory_bytes: 3444
solver::String->Int
solver str = let n = div (length str) 2 in
              2*((length.fst.last.(filter (\(x,y)->x==y))) [let (x,y)=(splitAt i str) in (x,(take i y))|i<-[1..(n-1)]])

main::IO()
main=do
  d<-getLine
  print (solver d)


Measured memory_bytes: 892
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<cstdio>
#include<vector>

using namespace std;

#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b)) < EPS)
#define curr(P, i) P[(i) % P.size()]
#define next(P, i) P[(i+1) % P.size()]
#define prev(P, i) P[(i+P.size()-1) % P.size()]


typedef pair<int,int> P;

class Point{
public:
  double x,y;
  
  Point(double x = 0, double y = 0): x(x),y(y){};
  
  Point operator + (Point p) {return Point(x+p.x,y+p.y);}
  Point operator - (Point p) {return Point(x-p.x,y-p.y);}
  Point operator * (double a) {return Point(a*x,a*y);}

  double own_dot(){return x*x+y*y;};
  double abs(){return sqrt(own_dot());}

  bool operator < (const Point &p) const {
    return x != p.x ? x < p.x : y < p.y;
  }
  bool operator == (const Point &p) const{
    return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
  }
};

// 内積 
double dot(Point a, Point b){
  return a.x*b.x+a.y*b.y;
}

// 外積
double cross(Point a, Point b){
  return a.x*b.y-a.y*b.x; 
}


//多角形の面積
double area2(vector<Point> P) {
  double A = 0;
  for (int i = 0; i < P.size(); ++i) 
    A += cross(curr(P, i), next(P, i));
  return abs(A/2);
}

using namespace std;

int main(){
  int rev = 0;
  int n;
  while(cin >> n && n){
    vector<Point> V;
    rev++;
    while(n--){
      Point p;
      cin >> p.x >> p.y;
      V.push_back(p);
    }
    printf("%d %.1f\n",rev,area2(V));
  }
  
  return 0;
}

Measured memory_bytes: 1248
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    string s;
    cin >> n;
    cin >> s;
    int ans=0;
    for(int i=0;i<n-2;++i) {
        if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C') ++ans;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int64_t INF = 1LL << 60;

int main() {
  int N;
  cin>>N;
  vector<int>a(N);
  int64_t sum=0;
  for(int i=0;i<N;i++){
    cin>>a[i];
    sum+=a[i]-1;
  }
  cout<<sum<<endl;
  

  return 0;}

Measured memory_bytes: 256
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right #func(リスト,値)
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import *

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x):
        self.setdefault(x,0)
        self[x] += 1

N = intput()
S = input()
re = 0
for i in range(N):
    re = re+1 if S[i]=='E' else re
lw = 0
ans = INF
for i in range(N):
    re = re-1 if S[i]=='E' else re
    ans = min(ans,re+lw)
    lw = lw+1 if S[i]=='W' else lw
print(ans)

Measured memory_bytes: 69036
n,m = map(int,input().split())
graph = [[0]*(n) for i in range(n)]

for i in range(m):
    a,b = map(int,input().split())
    graph[a-1][b-1] = graph[b-1][a-1] = 1


visited = [True] + [False]*(n-1)
ans = 0


def dfs(x):
    global ans
    global visited
    
    if all(visited):
        ans += 1
        return
    
        
    for j in [j for j,v2 in enumerate(graph[x]) if v2 == 1 and not visited[j]]:
        visited[j] = True
        dfs(j)
        visited[j] = False

dfs(0)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N ,T;
  cin >> N >> T;
  int ans = 100000;
  for (int i = 0; i < N; i++) {
    int c , t;
    cin >> c >> t;
    if (t <= T && c < ans) ans = c;
  }
  if (ans <= 1000)cout << ans << endl;
  else cout << "TLE" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){
  int k, x, i, min, max;
  cin >> k >> x;
  if(x >= 0){
    min = x - k + 1;
    max = x + k - 1;
  }
  else{
    min = x + k - 1;
    max = x - k + 1;
  }
  for(i = min; i <= max; i++){
    cout << i <<' ';
  }
  return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
N, M, *L = map(int, open(0).read().split())
dic = defaultdict(list)
rdic = defaultdict(list)
nin = [0]*N
Els = []
for a,b,c in zip(*[iter(L)]*3):
  dic[a-1] += [b-1]
  rdic[b-1] += [a-1]
  nin[b-1] += 1
  Els += [(a-1,b-1,-c)]

To = [False]*N
From = [False]*N
q = [0]
To[0] = True
while q:
  p = q.pop()
  for e in dic[p]:
    if To[e]==False:
      To[e] = True
      q += [e]
q = [N-1]
From[N-1] = True
while q:
  p = q.pop()
  for e in rdic[p]:
    if From[e]==False:
      From[e] = True
      q += [e]

ok = [False]*N
for i  in range(N):
  ok[i] = To[i]&From[i]

cnt = 0
dist = [float('inf')]*N
dist[0] = 0
cnt = 0
flag = False
while True:
  update = True
  for a,b,c in Els:
    if not(ok[a] and ok[b]):
      continue
    if dist[a]!=float('inf') and dist[b]>dist[a]+c:
      dist[b] = dist[a]+c
      update = False
  if update:
    break
  cnt += 1
  if cnt>N:
    flag = True
    break

if flag:
  print('inf')
else:
  print(-dist[N-1])

Measured memory_bytes: 44780
#include<stdio.h>
#include<iostream>
#include<math.h>
#include<algorithm>
#include<string.h>
#define ll long long
using namespace std;
int N,M;
struct node{
	int l,r;
};
node p[100005];
bool mark[100005];
int bj[100005];
bool cmp(node a,node b){
	if(a.l==b.l)return a.r<b.r;
	return a.l<b.l;
}
int main(){
	scanf("%d%d",&N,&M);
	for(int i=1;i<=M;++i){
		scanf("%d%d",&p[i].l,&p[i].r);
		if(!bj[p[i].l])bj[p[i].l]=i;
		else{
			if(p[i].r<p[bj[p[i].l]].r)bj[p[i].l]=i;
		}
	}
	int last=0;
	int anss=0;
	for(int i=1;i<=N;++i){
		if(mark[i]){
			anss++;
			for(int k=last;k<i;++k){
				mark[p[bj[k]].r]=0;
			}
			last=i;
		}
		mark[p[bj[i]].r]=1;
	}
	printf("%d",anss);
	return 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(ll i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(ll i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    ll a,b,c,K;
    cin>>a>>b>>c>>K;
    if(K%2){
        cout<<b-a<<endl;
    }else{
        cout<<a-b<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var k = int.Parse(Console.ReadLine());
            var sum = 0;
            for (int a = 1; a <= k; a++)
                for (int b = 1; b <= k; b++)
                {
                    var t = GCD(a, b);
                    for (int c = 1; c <= k; c++)
                    {
                        var s = GCD(c, t);
                        sum += s;
                    }
                }
            Console.WriteLine(sum);
            Console.ReadLine();
        }

        private static int GCD(int a, int b)
        {
            if (a == b) return a;
            if (a < b)
            {
                var temp = a;
                a = b;
                b = temp;
            }
            while (b != 0)
            {
                var r = a % b;
                a = b;
                b = r;
            }
            return a;
        }
    }
}


Measured memory_bytes: 27244
using System;

namespace agc021_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            bool flag = true;
            int ret = int.Parse(s[0].ToString());
            for (int j = 1; j < s.Length; j++)
            {
                if (s[j] != '9') flag = false;
                ret += int.Parse(s[j].ToString());
            }
            Console.WriteLine(int.Parse(s[0].ToString()) + (flag ? 0 : -1) + (s.Length - 1) * 9);
        }
    }
}

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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
#define INF 1000000000000
#define MOD 1000000007
using ll = long long;

ll f(ll a, ll b){
  string sa = to_string(a);
  string sb = to_string(b);
  ll la = sa.size(), lb = sb.size();
  return max(la,lb);
}

int main(){
  ll x;
  cin >> x;
  ll n = 1;
  if(x==2){
    cout<<2<<endl;
    return 0;
  }
  for(ll i = 1; i < x; i++){
    if(x<=(i+1)*i/2){
      n = i;
      break;
    }
  }
  //1 to n の集合で作ることができる。
  cout<<n<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define BIGINF (int) 4e18 + 7
#define MOD7 1000000007
#define MOD9 1e9 + 9
#define INF  (int)2e9 + 7
#define SCD(t) scanf("%d",&t)
#define SCLD(t) scanf("%ld",&t)
#define SCLLD(t) scanf("%lld",&t)
#define SCC(t) scanf("%c",&t)
#define SCS(t) scanf("%s",t)
#define SCF(t) scanf("%f",&t)
#define SCLF(t) scanf("%lf",&t)
#define MEM(a, b) memset(a, (b), sizeof(a))
typedef long long ll;
typedef long double ld;
typedef string str;
typedef double d;
typedef unsigned u;
typedef unsigned long long ull;

const int N = 3005;

long long dp[N][N];
int a[3005];


long long rec(int low, int high) {
	if (dp[low][high] != 0) return dp[low][high];
	if (low == high) {
		return dp[low][high] = a[low];
	}	
	return dp[low][high]= max(-rec(low, high - 1) + a[high],
										-rec(low + 1, high) + a[low] );
}
int main () {
    //freopen("inputf.txt", "r", stdin);
    //freopen("outputf.txt", "w", stdout);
    memset(dp, 0, sizeof(dp));
    int n;
    SCD(n);
    for (int i = 0; i < n; i++) {
    	SCD(a[i]);
    }
    long long ans = rec(0, n - 1);
    printf("%lld", dp[0][n - 1]);
    return 0;
}



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

l = [1] * (n + 1)
res = 1

for i in range (2, n + 1):
    x = i
    while x < n + 1:
        l[x] += 1
        x += i

#print(l)
res = 0
for k in range(1, n + 1):
    res += k * l[k]
    
print(res)

Measured memory_bytes: 145412
using namespace std;
#include<bits/stdc++.h>
#define Ranger159 ios_base::sync_with_stdio(false);
#define PrintLater cin.tie(0);cout.tie(0);
#define ll long long
#define phb push_back
#define break break
#define pob pop_back()
#define continue continue
#define size size
#define insrt insert
#define fir first
#define true true
#define clear clear
#define vL vector<ll> 
#define resize resize
#define sec second
#define else else
#define reverse reverse
#define lbr1 cout<<"\n";
#define lbr2 cout<<"\n\n";
#define cin(v,n) for(ll i=0;i<n;i++) cin>>v[i];
#define cout(v,n) for(ll i=0;i<n;i++) cout<<v[i]<<" "; lbr1
const ll mod=1e9+7;

int main(int argc, char const *argv[])
{
	Ranger159
	// PrintLater
	ll test=1,n,i,j,qry,x,y,val,indx;
	// cin>>test;
	while(test--)
	{
		cin>>n;
		vector<ll> v={599, 799, 999, 1199, 1399, 1599,1799, 1999};
		ll ans=v.end()-lower_bound(v.begin(), v.end(),n);
		cout<<ans;
		lbr1
	}
	return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;

int main(){
  int n;
  cin>>n;
  vector<ll>a(n);
  rep(i,n)cin>>a[i];
  ll sum=0;
  rep(i,n)sum+=a[i];
  ll s=0;
  ll ans=LLINF;
  rep(i,n){
    s+=a[i];
    ans=min(ans,llabs(sum-s-s));
  }
  cout<<ans<<endl;
  return(0);
}


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

int main()
{
    int n;
    string word;
    cin>>n;
    cin>>word;
    int b=0,e=2;
    int cnt=0;
    for(;;){
        if(e>=n) break;
        if(word[b]=='A' && word[b+1]=='B' && word[b+2]=='C'){
            cnt++;
        }
        b++,e++;
    }
    cout<<cnt;
}

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

const long MOD = 1'000'000'007;

int main() {
	string s; cin >> s;
	long ans = 0;
	for (long i = 0; i < s.size(); i++) {
		ans += s[i] - '0';
	}
	if (ans % 9) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
	return 0;
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MAXN 1000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
const ll mod = 1e9+7;


int main() {
    int k, x;
    cin >> k >> x;

    int start = max(-1*MAXN, x-(k-1));
    int end = min(MAXN, x+(k-1));

    for(int i = start; i<= end; i++) {
        cout << i << " ";
    }

    cout << endl;
}




Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ld long double
#define INF 1000000000000000000
typedef pair<ll, ll> pll;
typedef pair<int, int> pint;

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

    ll N;
    cin >> N;
    vector<ll> en(N + 5, 1);
    for (int i = 2; i <= N; i++) {
        for (int j = i; j <= N; j += i) {
            en[j]++;
        }
    }

    ll ans = 0;
    for (int i = 1; i <= N; i++) {
        ans += i * en[i];
    }

    cout << ans << endl;
}

Measured memory_bytes: 81304
s = input()

if s[-1] == "3":
    print("bon")
elif s[-1] == "0" or s[-1] == "1" or s[-1] == "6" or s[-1] == "8":
    print("pon")
elif s[-1] == "2" or s[-1] == "4" or s[-1] == "5" or s[-1] == "7" or s[-1] == "9":
    print("hon")

Measured memory_bytes: 9124
import java.util.*;
public class Main {
  public static void main (String[] args) {
    Scanner sc = new Scanner (System.in);
    long N = sc.nextInt();
    ArrayList<String> list = new ArrayList<String>();
    for (int i=0; i<N; i++) {
      char[] c = sc.next().toCharArray();
      Arrays.sort(c);
      String s = new String(c);
      list.add(s);
    }
    Collections.sort(list);
    long ans = 0;
    long count = 1;
    
    for (int i=0; i<N-1; i++) {
      if (list.get(i).equals(list.get(i+1))) {
        count++;
        if (i == N-2) {
          ans += count*(count-1)/2;
        }
      }
      else {
        ans += count*(count-1)/2;
        count = 1;
      }
      
    }
    
    System.out.println(ans);
    
  }
}

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

using namespace std; //ごめんなさい
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF INT_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define rep(i,N) for(int i=0;i<N;i++)
#define int ll

struct edge{
  int to,cap,rev;
};

struct Flow{
  vector<vector<edge>>G;
  vector<bool>used;
  Flow(vector<vector<edge>>g){
    int N=g.size();
    used.resize(N,false);
    G.resize(N);
    for(int i=0;i<N;i++){
      for(auto it:g[i])add_edge(i,it.to,it.cap);
    }
  };
  void add_edge(int from,int to,int cap){
    G[from].push_back({to,cap,(int)G[to].size()});
    G[to].push_back({from,0,(int)G[from].size()-1});
  }
  int max_flow(int s,int g){
    int flow=0;
    while(true){
      fill(used.begin(),used.end(),false);
      int f=dfs(s,g,INF);
      if(f==0)return flow;
      flow+=f;
    }
  }
  int dfs(int s,int g,int val){
    if(s==g)return val;
    used[s]=true;
    for(auto&e:G[s]){
      if(!used[e.to]&&e.cap>0){
        int d=dfs(e.to,g,min(val,e.cap));
        if(d>0){
          e.cap-=d;
          G[e.to][e.rev].cap+=d;
          return d;
        }
      }
    }
    return 0;
  }
};

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

  int H,W;
  cin>>H>>W;
  vector<string>a(H);
  for(int i=0;i<H;i++)cin>>a[i];
  vector<vector<edge>>G(H+W+2);
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      int x=i,y=j+H;
      if(a[i][j]!='.')G[x].push_back({y,1}),G[y].push_back({x,1});
      if(a[i][j]=='S')G[H+W].push_back({x,INF}),G[H+W].push_back({y,INF});
      if(a[i][j]=='T')G[x].push_back({H+W+1,INF}),G[y].push_back({H+W+1,INF});
    }
  }

  Flow f(G);
  ll ans=f.max_flow(H+W,H+W+1);
  if(ans>=INF)cout<<-1<<endl;
  else cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 2688
use std::io::*;
use std::str::FromStr;
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
fn main(){
    let s: String = read();
    let s1 = &s[0..4];
    let num1: i32=s1.parse().unwrap();
    if(num1<2019){
        println!("Heisei");
        return;
    }
    let s2 = &s[5..7];
    let num2: i64=s2.parse().unwrap();
    if(num2<=4){
        println!("Heisei");
        return;
    }
    println!("TBD");
}

Measured memory_bytes: 2024
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int X,s=0,i,j;
    bool t=0;

    cin>>X;
    for( i=1; i<10; i++)
    {
        for(j=1; j<10; j++)
        {
            s=i*j;
            if(X==s)
            {
                t=1;
            }
        }


    }

    if(t==true)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }



    return 0;
}

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

using ll = long long;
using ld = double;
using pii = pair<int, int>;
using cd = complex<ld>;

const int MOD1 = 1'000'000'007;
const int MOD2 = 1'000'000'009;
const int P1 = 243;
const int P2 = 771;

struct hashInt {
	int a, b;
	hashInt()
		: a(0)
		, b(0) {}
	hashInt(int a, int b) {
		this->a = (a + MOD1) % MOD1;
		this->b = (b + MOD2) % MOD2;
	}
	hashInt(ll a, ll b) {
		this->a = (a + MOD1) % MOD1;
		this->b = (b + MOD2) % MOD2;
	}
};

hashInt operator+(const hashInt &a, const hashInt &b) {
	return hashInt(a.a + b.a, a.b + b.b);
}

hashInt operator*(const hashInt &a, const hashInt &b) {
	return hashInt(1LL * a.a * b.a, 1LL * a.b * b.b);
}

bool operator<(const hashInt &a, const hashInt &b) {
	return make_pair(a.a, a.b) < make_pair(b.a, b.b);
}

hashInt P(P1, P2);
vector<hashInt> hashes[26];

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

	int n;
	cin >> n;
	vector<pair<int, hashInt>> a;
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		hashInt cur;
		vector<int> have(26);
		for (char c : s) {
			have[c - 'a']++;
		}
		for (int k = 0; k < 26; k++) {
			if (have[k] > 0) {
				hashes[k].push_back(cur);
			}
		}
		for (int j = s.size() - 1; j >= 0; j--) {
			if (j == 0) {
				a.emplace_back(s[0] - 'a', cur);
			}
			have[s[j] - 'a']--;
			cur = cur * P + hashInt(s[j] - 'a' + 1, s[j] - 'a' + 1);
			for (int k = 0; k < 26; k++) {
				if (have[k] > 0) {
					hashes[k].push_back(cur);
				}
			}
		}
	}
	for (auto &x : hashes) {
		sort(x.begin(), x.end());
	}
	ll res = 0;
	for (auto[i, h] : a) {
		auto st = lower_bound(hashes[i].begin(), hashes[i].end(), h);
		auto ed = upper_bound(hashes[i].begin(), hashes[i].end(), h);
		res += ed - st - 1;
	}
	cout << res;
	return 0;
}

Measured memory_bytes: 204468
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = 1; i <= n; i++)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
using P = pair <int, int>;
 
ll MOD = 1000000007;
ll INF =1<<29;

int main() {
    int n,l;
    cin >> n >> l;
    vector<int> a(n+1);
    int tot =0;
    rrep(i,n){
        a[i]= l+i-1;
        tot +=a[i];
    }
    int MIN = 210;
    int ans;
    rrep(i,n){
        if(abs(a[i])<MIN){
            MIN =abs(a[i]);
            ans = i;
        }
    }
    cout << tot-a[ans]<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int n;
	cin >> n;
	vector<vector<pair<int, int>>> vp(n, vector<pair<int, int>>());
	rep(i, n){
		int lim;
		cin >> lim;
		rep(j, lim){
			int a, b;
			cin >> a >> b;
			a--;
			vp.at(i).push_back(make_pair(a, b));
		}
	}
	int ans = 0;
	rep(i, 1 << n){
		int add = 0;
		bool con = true;
		rep(j, n){
			if((i & (1 << j)) == 0) continue;
			add++;
			for(auto p : vp.at(j)){
				int now = i & (1 << p.first);
				if(now != 0) now = 1;
				if(now != p.second){
					con = false;
					break;
				}
			}
			if(con == false) break;
		}
		if(con == true){
			ans = max(ans, add);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
a=int(input())
b=int(input())
c=int(input())
x=int(input())
count=0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500*i+100*j+50*k==x:
                count+=1
print(count)

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a, b;
    cin >> a >> b;
    //printf("%d %d", a, b);
    
    if(a%2 == 0){
        printf("Even");
        return 0;
    }else if(b%2 == 0){
        printf("Even");
        return 0;
    }else{
        printf("Odd");
        return 0;
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353,INF=1e18;



int main() {
    string S,T;
    cin>>S>>T;
    int cou=0;
    rep(i,sz(S)){
        if(S.at(i)!=T.at(i)){
            cou++;
        }
    }
    cout<<cou<<endl;
}

Measured memory_bytes: 3920
#-*- coding: utf-8 -*-
"""
https://atcoder.jp/contests/abc117/tasks/abc117_a
"""

def sol(n, S):
    maxi = max(S)
    ttl = sum(S)
    others = ttl - maxi
    print('Yes' if maxi < others else 'No')

test = False
if test:
    n = 4
    S =list( map(int, "3 8 5 1".split()))
    sol(n, S)

    n = 4
    S =list( map(int, "3 8 4 1".split()))
    sol(n, S)

    n = 10
    S =list( map(int, "1 8 10 5 8 12 34 100 11 3".split()))
    sol(n, S)


else:
    n = int(input())
    S =list( map(int, input().split()))
    #print(n, edges)
    sol(n, S)




Measured memory_bytes: 3064
M, D = map(int, input().split())

ans = 0
for m in range(1, M + 1):
    for d in range(1, D + 1):
        if len(str(d)) == 1:
            continue
        d10, d1 = int(str(d)[0]), int(str(d)[1])
        if (d10 == 1) or (d1 == 1):
            continue
        if d10 * d1 == m:
            ans += 1

print(ans)


Measured memory_bytes: 3060
#include <stdio.h>

int main(void) {
	int H= 1,W = 1;
	int i=0,j=0;
	

	while(H != 0 && W != 0){
			scanf("%d",&H);
			scanf("%d",&W);
			if(H == 0 && W == 0){
				break;
			}

		for(i=0;i<H;i++){
			for(j=0;j<W;j++){
			
				if(i == 0 || i == H-1){
					printf("#");		
				}
				else{
					if(j == 0 || j == W-1){
						printf("#");
					}
					else{
						printf(".");
					}
				}
			}
			printf("\n");
		}
		printf("\n");
	}
	

	return 0;
}

Measured memory_bytes: 572
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define ba 47
#define MAXN 100005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 +c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
int N,K;
void Solve() {
    read(N);read(K);
    if(K == 1) puts("0");
    else {
	out((N - (K - 1)) - 1);enter;
    }
}
int main(){
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
}


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

#define rep(i, n) for(int i = 0; i < (n); i++)
using LL = long long;
using ULL = unsigned long long;

vector<int> ed[600];
double dp[601] = {};
double dpM[601] = {};
double dpP[601] = {};
int n;

double query(int p) {
	if (p == n) return 0.0;
	if (dp[p] != 0.0) return dp[p];

	dp[p] = 1.0;
	for (auto next : ed[p]) {
		double nextq = query(next);
		dp[p] += nextq / (double)ed[p].size();
		dpM[p] = max(dpM[p], 1.0 + nextq);
	}
	return dp[p];
}

void solve() {
	cin >> n;
	int m; cin >> m;
	rep(i, m) {
		int s, t; cin >> s >> t;
		ed[s].push_back(t);
	}
	for (int i = 1; i < n; i++) query(i);

	dpP[1] = 1.0;
	for (int i = 1; i < n; i++) {
		for (auto next : ed[i]) {
			dpP[next] += dpP[i] / (double)ed[i].size();
		}
	}

	double ans = 0;
	for (int i = 1; i < n; i++) {
		if (ed[i].size() == 1) continue;
		ans = max(ans, dpP[i] * (dpM[i] - dp[i]) / (ed[i].size() - 1));
	}
	cout << setprecision(10) << dp[1] - ans << endl;
}

int main() {

	solve();

	return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define FOR(i,l,r) for(int i=l,END=r;i<=END;i++)
#define DOR(i,r,l) for(int i=r,END=l;i>=END;i--)
#define loop(i,n) for(int i=0,END=n;i<END;i++)
#define sf scanf
#define pf printf
#define push_back pb
#define mms(a,x) memset(a,x,sizeof a)
#define pii pair<int,int>
#define ll long long
#define db long double
using namespace std;
const int N=1e5+5,P=1e9+7;
int n,cnt[30],two[N];
char str[N];
int main(){
	two[0]=1;
	FOR(i,1,N-5)two[i]=two[i-1]*2%P;
	sf("%d",&n);
	sf("%s",str);
	int ans=1;
	int len=strlen(str);
	loop(i,len)cnt[str[i]-'a']++;
	FOR(i,0,26)if(cnt[i])ans=1ll*ans*(cnt[i]+1)%P;
	pf("%d\n",ans-1);
	return 0;
}

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

#define all(c) (c).begin(),(c).end()
#define FOR(i, x, n) for(int i = x; i < (int)n; i++)
#define REP(i, n) FOR(i, 0, n)
#define debug(x) #x << "=" << (x) << "(L" << __LINE__ << ")"
#define show(x) cout << #x << "=" << x << endl
#define show2(x,y) cout << #x << "=" << x << "," << #y << "=" << y <<  endl
#define show3(x,y,z) cout << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z <<  endl
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

#define ALL(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;

const ld eps = 1e-9, pi = acos(-1.0);
const ld EPS = 1e-8;
const int INF = INT_MAX/2;
const ll LINF = LONG_MAX/2;
const int MOD = 1000000007;

template<class T> inline void amin(T &a, const T &b) { if (b<a) a=b; }
template<class T> inline void amax(T &a, const T &b) { if (a<b) a=b; }

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

int main(){
    
    ll n,k;
    string s;
    cin >> n >> k;
    cin >> s;
    
    s[k-1] += 32;
    
    cout << s << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using P = pair<int,int>;
int main()
{
    int n;cin >> n;
    ll a[n+1];
    rep(i,n)cin >> a[i];
    sort(a,a+n);
    ll ans = a[n-1] - a[0];
    cout << ans << endl;
    return 0;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define repa(i,a,n) for(int i=a;i<=n;i++)
#define repb(i,a,n) for(int i=a;i>=n;i--)
#define trav(a,x) for(auto a=x.begin();a!=x.end();a++)
#define all(x) x.begin(),x.end()
#define fst first
#define snd second
#define pb push_back
#define mp make_pair
typedef long double ld;
typedef pair <int,int> pii;
typedef vector <int> vi;
typedef long long ll;

void pre(){

}

void solve(){
  string s,t; cin>>s>>t;
  int flag=0;
  rep(i,s.size()){
    if(s[i]!=t[i]) flag=1;
  }

  if(flag==1 || t.size()!=s.size()+1) cout<<"No"<<"\n";
  else cout<<"Yes"<<"\n";
}

int main(){
  #ifndef ONLINE_JUDGE
    // freopen("in.txt","r",stdin);
  #endif
  ios_base::sync_with_stdio(0); cin.tie(0);
  pre();
  int t; t=1;
  rep(i,t) solve();
  return 0;
}


Measured memory_bytes: 3652
N = int(input())
A = list(map(int,input().split()))

D = {}

for a in A :
    if a not in D :
        D[a] = 1
    else :
        D[a] += 1

ans = 0

for a in D :
    if D[a] < a :
        ans += D[a]
    else :
        ans += (D[a] - a)

print(ans)


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

int main() {
  string s;
  int a, size, i, count;
  cin >> s;
  size = s.size();
  a = size / 2;
  count = 0;
  for(i=0; i < a; i++){
    if (s.at(i) != s.at(size -1 -i)){
      count += 1;
    }
  }
  cout << count <<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int l = s.length();
		char[] Odds = new char[l];

		for(int i=0; i<l; i++) {
			Odds[i] = s.charAt(i);
			if(i%2==0) {
				System.out.print(Odds[i]);
			}
		}

	}

}


Measured memory_bytes: 29428
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
    int a, b;
    cin >> a >> b;
    int c = a * b;
    if (c % 2 == 1) {
        cout << "Odd" << endl;
    }
    else {
        cout << "Even" << endl;
    }
    return 0;
}


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

int main(void){
 int X,A,B;
 char str[100];
  fgets(str,sizeof(str),stdin);
  X=atoi(str);
  fgets(str,sizeof(str),stdin);
  A=atoi(str);
  fgets(str,sizeof(str),stdin);
  B=atoi(str);
  
  printf("%d\n",(X-A)%B);
  
  return 0;
  
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<math.h>
#include<algorithm>
#include<stdio.h>
using namespace std;
int main(){
  int N , f;
  long long ans=0;
  cin>>N;
  vector<int> d(N);
  for(int i=0;i<N;i++) cin>>d[i];
  for(int j=0;j<N-1;j++){
    for(int k=j+1;k<N;k++){
      f=d[j]*d[k];
      ans+=f;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>

using namespace std;

int jj[1001][1001],oo[1001][1001],ii[1001][1001];
char map[1001][1001];

int main(void){
	int a,b,c,m,n,k;
	cin >> m >> n;
	cin >> k;
	for(a=0;a<m;a++){
		scanf("%s",map[a]);
	}
	memset(jj,0,sizeof(jj));
	memset(jj,0,sizeof(oo));
	memset(jj,0,sizeof(ii));
	for(a=0;a<m;a++){
		for(b=0;b<n;b++){
			jj[b+1][a+1]=jj[b+1][a]+jj[b][a+1]-jj[b][a];
			oo[b+1][a+1]=oo[b+1][a]+oo[b][a+1]-oo[b][a];
			ii[b+1][a+1]=ii[b+1][a]+ii[b][a+1]-ii[b][a];
			if(map[a][b]=='J')jj[b+1][a+1]++;
			if(map[a][b]=='O')oo[b+1][a+1]++;
			if(map[a][b]=='I')ii[b+1][a+1]++;
		}
	}
	for(c=0;c<k;c++){
		int ax,ay,bx,by;
		int ja=0,oa=0,ia=0;
		scanf("%d %d %d %d",&ay,&ax,&by,&bx);
		ja=jj[bx][by]-jj[ax-1][by]-jj[bx][ay-1]+jj[ax-1][ay-1];
		oa=oo[bx][by]-oo[ax-1][by]-oo[bx][ay-1]+oo[ax-1][ay-1];
		ia=ii[bx][by]-ii[ax-1][by]-ii[bx][ay-1]+ii[ax-1][ay-1];
		printf("%d %d %d\n",ja,oa,ia);
	}
	return 0;
}

Measured memory_bytes: 13000
#include<iostream>
#include<map>
#include<algorithm>
#include <iomanip>
#include <cmath>
#include <sstream>
#include <unordered_map>
#include <unordered_set>
#include <deque>
#include <vector>
#include <bitset>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <cstdio>
#include <list>


constexpr int INF = 1050000000;
constexpr int MOD = 1000000007;
constexpr long long LONGINF = 1005000000000000000;
using namespace std;

using ll = long long;

class UnionFind {
private:
	std::vector<int> parent;
	std::vector<int> height;
	std::vector<int> m_size;

public:
	UnionFind(int size_) : parent(size_), height(size_, 0), m_size(size_, 1) {
		for (int i = 0; i < size_; ++i) parent[i] = i;
	}
	void init(int size_) {
		parent.resize(size_);
		height.resize(size_, 0);
		m_size.resize(size_, 1);
		for (int i = 0; i < size_; ++i) parent[i] = i;
	}
	int find(int x) {
		if (parent[x] == x) return x;
		return parent[x] = find(parent[x]);
	}
	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y) return;
		int t = size(x) + size(y);
		m_size[x] = m_size[y] = t;
		if (height[x] < height[y]) parent[x] = y;
		else parent[y] = x;
		if (height[x] == height[y]) ++height[x];
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
	int size(int x) {
		if (parent[x] == x) return m_size[x];
		return size(parent[x] = find(parent[x]));
	}
};


int main() {

	int n, m; cin >> n;

	string user[256];

	for (int i = 0; i < n; i++) {
		cin >> user[i];
	}

	cin >> m;

	string t[256];

	for (int i = 0; i < m; i++) {
		cin >> t[i];
	}

	bool swich = true;//true:施錠 false:開錠  状態

	for (int i = 0; i < m; i++) {
		bool no_match = true;
		for (int j = 0; j < n; j++) {
			if (user[j] == t[i]) {
				if (swich) {
					cout << "Opened by " << t[i] << endl;
					swich = !swich;
				}
				else {
					cout << "Closed by " << t[i] << endl;
					swich = !swich;
				}
				no_match = false;
			}
		}
		if (no_match) {
			cout << "Unknown " << t[i] << endl;
		}
	}
}


Measured memory_bytes: 3232
#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;
char a[3][3];

int main()
{
    for(int i=0;i<3;i++)
    {
        for(int j=0;j<3;j++)
            scanf("%c",&a[i][j]);
            getchar();
    }
    printf("%c%c%c",a[0][0],a[1][1],a[2][2]);
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
//var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
namespace AtCoderSolve
{
    class Solve
    {
        const int mod = 1000000007;
        static void Main(string[] args)
        {

            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);

            var h = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int d = h[1] - h[0];
            long sum = 0;
            for(var i = 1; i <= d; i++)
            {
                sum += i;
            }
            Console.WriteLine(sum - h[1]);


            //Console.Out.Flush();
            
        }
    }



    public class Calculation
    {

    }

    public class Graph
    {

    }
}



Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define MAXN 100010
#define pii pair<int,int>
#define ff first
#define ss second
#define ll long long
#define in_range(x, y, n) (x >= 0 and x<n and y >=0 and y<n)
using namespace std;
const int mod = 1e9 + 7;

int main (){
    int n, a, b;

    cin >> n >> a >> b;

    cout << min(n*a, b) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const long long INF = 1LL<<60;

// 入力
int N;
long long W, weight[110], value[110]; // 品物の個数は 100 個なので少し余裕持たせてサイズ 110 に

// DPテーブル
long long dp[110][100100] = {0};

int main() {
    cin >> N >> W;
    for (int i = 0; i < N; ++i) cin >> weight[i] >> value[i];

    // DPループ
    for (int i = 0; i < N; ++i) {
        for (int sum_w = 0; sum_w <= W; ++sum_w) {

            // i 番目の品物を選ぶ場合
            if (sum_w - weight[i] >= 0) {
                chmax(dp[i+1][sum_w], dp[i][sum_w - weight[i]] + value[i]);
            }

            // i 番目の品物を選ばない場合
            chmax(dp[i+1][sum_w], dp[i][sum_w]);
        }
    }

    // 最適値の出力
    cout << dp[N][W] << endl;
}

Measured memory_bytes: 79360
w = gets.chomp.to_i
n = gets.chomp.to_i
a = Array.new(w){|index| "#{index+1}".to_i}

n.times do
  (x, y) = gets.chomp.split(",")
  x = x.to_i
  y = y.to_i
  a[x-1], a[y-1] = a[y-1], a[x-1]
end

a.each do |v|
  print v, "\n"
end

Measured memory_bytes: 6100
using System;
using static System.Console;
using System.Linq;

namespace Main
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] tmp = ReadLine().Split(' ').Select(int.Parse).ToArray();
            WriteLine(tmp[0] <= tmp[1] ? tmp[0] : tmp[0] - 1);
        }
    }
}

Measured memory_bytes: 11348
#include <stdio.h>

int main(void) {
	int n, i = 3, x;
	
	scanf(" %d", &n);
	
	while(i <= n){
		x = i;
		if(x % 3 == 0){
			printf(" %d", i);
		}else{
			while(x > 2){
				if(x % 10 == 3){
					printf(" %d", i);
					break;
				}else{
					x = x / 10;
				}
			}
		}
		i++;
	}
	
	printf("\n");
	
	return 0;
}



Measured memory_bytes: 2104
#include  <iostream>
#include  <stdio.h>
using namespace std;


int main(){

    int A;
    int B;
    int C;

    cin >> A;
    cin >> B;
    cin >> C;
    string ans;

    ans = "No";

    if(A == B){
        if(A == C){
            ans = "Yes";
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int N;
    cin >> N;
    vector<int>L(N);
    for(int i = 0; i < N; i++) {
        cin >> L[i];
    }
    int ans = 0;
    for(int i = 0; i < N; i++) {
        for(int j = i+1; j < N; j++) {
            for(int k = j+1; k < N; k++) {
                int X = max({L[i],L[j],L[k]});
                int Y = L[i]+L[j]+L[k];
                if(X < Y-X) {
                    set<int>st;
                    st.insert(L[i]);
                    st.insert(L[j]);
                    st.insert(L[k]);
                    if(st.size() == 3) {
                        ans++;
                    }
                    st.clear();
                }
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3628
#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector<vector<int>> mat;
//typedef unsigned int uint;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int N, X, Y;
	int x, y;
	int ans = 0;
	cin >> N >> X >> Y;
	rep(i, 0, N)
	{
		cin >> x >> y;
		if (X <= x && Y <= y)
		{
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 2005
#define INF 1000000005
#define INFLL 2000000000000000003
#define PI 3.1415926535897
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define IN(a) cin>>(a)
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
const int MAX = 1000005;
const int MOD = 1000000007;
int main(){
    int a,b;
    cin>>a>>b;
    OUT(a*b);
    return 0;
}


Measured memory_bytes: 3540
read = input
from math import sqrt
N = int(read())
sqrt_n = int(sqrt(N))
k = 1

ans = 0
m = 0

while k <= sqrt_n + 1000:
    if N % (k) == 0:
        m = N // (k)
#         print(m, k)
        if not m-1 > k:break
        ans += m - 1
    k += 1
print(ans)

Measured memory_bytes: 3060