akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<map>
using namespace std;
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 long long INF = 1LL << 60;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
    int a;
    cin>>a;
    cout<<(10000-a)%1000<<endl;
}

Measured memory_bytes: 3636
aa, b, cc = input().split()
a = int(aa)
c = int(cc)
while (b != '?'):
    if (b == '+'):
        ans = a+c
    elif (b == '-'):
        ans = a-c
    elif (b == '*'):
        ans = a*c
    elif (b == '/'):
        ans = a // c
    else:
        ans = -1
    print(ans)
    aa, b, cc = input().split()
    a = int(aa)
    c = int(cc)



Measured memory_bytes: 5592
n = int(input())
a = list(map(int, input().split()))

x = sum(a) / n
y = sum(a) // n
if x == y:
   cand = [y]
else:
   cand = [y, y+1]

cost = 10**18
for ave in cand:
   c = 0
   for i in range(n):
      c += (a[i]-ave)**2
   cost = min(cost, c)

print(cost)


Measured memory_bytes: 9192
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <functional>
#include <map>
#include <queue>
#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
using namespace std;
using ll = long long;
ll MOD = 1e9+7;


int main(int argc, const char * argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a, b, c;
    cin >> a >> b >> c;
    
    if((c > a && c < b) ||(c < a && c > b)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
while 1:
    H,W = map(int,input().split())
    if H == 0 and W == 0:
        break
    for i in range(H):
        if i%2 == 0:
            print('#.'*(W//2),'#'*(W%2),sep='')
        else:
            print('.#'*(W//2),'.'*(W%2),sep='')
    print()


Measured memory_bytes: 5616
#include <bits/stdc++.h>
#define f first
#define s second
#define ll long long int
#define pb push_back
#define mp make_pair

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

int main(){
    int a, b;
    scanf("%d %d", &a, &b);
    if( a == 1 && b == 2)
        printf("3\n");
    else if ( a == 1  &&  b == 3)
        printf("2\n");
    else if ( a == 2 && b == 1)
        printf("3\n");
    else if ( a == 2 && b == 3)
        printf("1\n");
    else if( a == 3 && b == 1)
        printf("2\n");
    else if( a == 3 && b == 2)
        printf("1\n");
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
//#include<bits/stdc++.h>
using ll = long long;
using namespace std;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;
ll test[12345678];
signed main() {
	ll n = 0, m, q, k, a = 0, b = 0, c = 0, d = 0, cnt = 0, sum = 0; string s, t;
	vector<ll> v(n);
	cin >> a >> n;
	for (int h = 0; h < n; h++) {
		cin >> b; test[b]++;
	}
	cnt = a; sum = a;
	while (true) {
		if (test[cnt] == 0) { cout << cnt << endl; return 0; }
		if (test[sum] == 0) { cout << sum << endl; return 0; }
		cnt = max((ll)0, cnt - 1); sum++;
	}
	return 0;
}

Measured memory_bytes: 3628
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from heapq import heapify, heappop, heappush
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, A, B = MAP()

a = N % (A + B)
b = N // (A + B)
c = 0

if 0 <= a <= A:
    c = a
else:
    c = A

print(b * A + c)

Measured memory_bytes: 3944
# region header
import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
from string import ascii_lowercase, ascii_uppercase, digits
sys.setrecursionlimit(10**6)
INF = float('inf')
MOD = 10 ** 9 + 7
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(rs())
def rf(): return float(rs())
def rs_(): return [_ for _ in rs().split()]
def ri_(): return [int(_) for _ in rs().split()]
def rf_(): return [float(_) for _ in rs().split()]
def divisors(n, sortedresult=True):
    div = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            div.append(i)
            if i != n // i:
                div.append(n//i)
    if sortedresult:
        div.sort()
    return div
# endregion
A = deque(list(rs()))
B = deque(list(rs()))
C = deque(list(rs()))
t = 'a'
while True:
    if t == 'a':
        if len(A) == 0:
            print('A')
            exit()
        t = A.popleft()
    elif t == 'b':
        if len(B) == 0:
            print('B')
            exit()
        t = B.popleft()
    else:
        if len(C) == 0:
            print('C')
            exit()
        t = C.popleft()

Measured memory_bytes: 5496
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
ll comb(ll n,ll r){
  if(n==0) return 1;
  return comb(n-1,r-1)+comb(n-1,r);
}
int main(){
  ll n,ma=-1,num,perf;
  cin >> n;
  ll a[n];
  for(ll i=0;i<n;i++){
    cin >> a[i];
    a[i]*=2;
    ma=(ma>a[i])?ma:a[i];
  }
  sort(a,a+n);
  perf = ma/2;
  num = a[0];
  for(int i=0;i<n;i++){
    if(abs(perf-num)>abs(perf-a[i])) num = a[i];
  }
  cout << ma/2 << " "<<num/2<<endl;
}


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

int main() {

    string str;
    cin >> str;
    int n;
    cin >> n;
    int res = 0;

    for(int i = 1; i <= n; i++) {
        string ring;
        cin >> ring;
        ring = ring + ring;
        if (ring.find(str) != string::npos )    res += 1;
    }

    cout << res << endl;

     
    return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int m[105][105],a[10050];
int main()
{
	int h,w,n,now1,now=0;
	cin>>h>>w>>n;
	for (int i=1;i<=n;i++)
		cin>>a[i];
	now1=1;
	for (int i=0;i<h;i++)
	{
		if (i%2==0)
		{
			now=0;
			while (now!=w)
			{
				m[i][now]=now1;
				now++;
				a[now1]--;
				if (a[now1]==0)
					now1++;
			}
		}
		else
		{
			now=w-1;
			while(now!=-1)
			{
				m[i][now]=now1;
				now--;
				a[now1]--;
				if (a[now1]==0)
					now1++;
			}
		}
	}
	for (int i=0;i<h;i++)
	{
		for (int j=0;j<w;j++)
			cout<<m[i][j]<<" ";
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 384
n = int(input())
ans = ''
for i in range(1, 99):
   if n <= pow(26, i):
      n -= 1
      for j in range(i):
         ans += chr(ord('a')+n%26)
         n //= 26
      break
   else:
      n -= pow(26, i)

print(ans[::-1])


Measured memory_bytes: 9176
using System;
using System.Linq;

namespace id_0582cs
{
    class Program
    {
        static void Main(string[] args)
        {
            int countTriangle = 0;
            int countRightAngledTriangle = 0;
            int countObtuseTriangle = 0;
            int countSharpTriangle = 0;
            while (true)
            {
                var vs = Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
                Array.Sort(vs);
                var a = vs[0];
                var b = vs[1];
                var c = vs[2];
                if (a + b <= c) break;
                countTriangle++;
                var judge = Math.Pow(a, 2) + Math.Pow(b, 2) - Math.Pow(c, 2);
                if(judge == 0)
                {
                    countRightAngledTriangle++;
                }
                if (judge < 0)
                {
                    countObtuseTriangle++;
                }
                if(judge>0)
                {
                    countSharpTriangle++;
                }
            }
            Console.WriteLine("{0} {1} {2} {3}",
                countTriangle, 
                countRightAngledTriangle, 
                countSharpTriangle, 
                countObtuseTriangle);
        }
    }
}



Measured memory_bytes: 9944
/************************************
/ AUTHOR : YATHARTH GOSWAMI         /  
/ ALIAS : hacker_yg                 /
/ INSTITUTE : IIT Kanpur            /
************************************/
//          TEMPLATE                //

#include <bits/stdc++.h>

#define ll long long
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define F first
#define S second

using namespace std;

int main(){
    int a[3][3];
    map <pair<int,int>, bool> m;
    for (int i= 0; i < 3; i++){
        for (int j = 0;j < 3; j++){
            cin >> a[i][j];
            m[mp(i, j)] = 0;
        }
    }
    int n;
    cin >> n;
    int b[n];
    for (int i = 0; i < n; i++) cin >> b[i];
    for (int i = 0; i< n; i++){
        for (int j = 0; j < 3; j++){
            for (int k = 0; k < 3; k++){
                if (a[j][k] == b[i]) m[mp(j, k)] = 1;
            }
        }
    }
    for (int i = 0; i< 3; i++){
        if ((m[mp(i, 0)] == 1)&&(m[mp(i, 1)] == 1)&&(m[mp(i,2)] == 1)){
            puts("Yes");
            return 0;
        }
        else if ((m[mp(0, i)] == 1)&&(m[mp(1, i)] == 1)&&(m[mp(2, i)] == 1)){
            puts ("Yes");
            return 0;
        }
        else if ((m[mp(0,0)] == 1)&&(m[mp(1,1)] == 1)&&(m[mp(2,2)] == 1)){
            puts ("Yes");
            return 0;
        }
        else if ((m[mp(0,2)] == 1)&&(m[mp(1,1)] == 1)&&(m[mp(2,0)] == 1)){
            puts("Yes");
            return 0;
        }
    }
    puts("No");
    return 0;
}




Measured memory_bytes: 256
while True:
    try:
        a, b, c, d, e, f = [int(x) for x in input().split()]
        x = round((b*f - c*e)/(b*d - a*e), 3) + 0
        y = round((a*f - c*d)/(a*e - b*d), 3) + 0
        print(format(x, ".3f"), format(y, ".3f"))
    except EOFError:
        break


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

ll w, h;
char field[100][100];
bool use[100][100];
ll ans=0;

const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

void dfs(int x, int y)
{
	use[y][x] = true;
	ans++;
	rep(i, 4){
		ll tx = x+dx[i];
		ll ty = y+dy[i];
		if (!(0<=tx && tx<=w-1 && 0<=ty && ty<=h-1)) continue;
		if (use[ty][tx] || field[ty][tx]=='#') continue;
		dfs(tx, ty);
	}
	return;
}

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	while(cin>>w>>h, w!=0){
		ll sx, sy;
		ans = 0;
		memset(use, 0, sizeof(use));
		rep(i, h){
			rep(j, w){
				cin >> field[i][j];
				if (field[i][j]=='@'){
					sx = j; sy = i;
				}
			}
		}
		dfs(sx, sy);
		cout << ans << "\n";
	}
	return 0;
}


Measured memory_bytes: 3140
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>

int main() {
  std::string s;
  std::cin >> s;
  std::transform(s.cbegin(), s.cend(), s.begin(), tolower);
  std::string t;
  int cnt = 0;
  while (std::cin >> t)
  {
    if (t == "END_OF_TEXT")
      break;
    std::transform(t.cbegin(), t.cend(), t.begin(), tolower);
    if (t == s) {
      cnt++;
    }
  }
  std::cout << cnt << "\n";
}


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

using namespace std;

int n;
char s[105],*p,*q,sep[]=" ";
int t,h;

int main()
{
    cin>>n;
    cin.get();
    for(int i=1;i<=n;++i)
        {
         cin.getline(s,105);
         p=strtok(s,sep);
         q=strtok(NULL,sep);
         if(strcmp(p,q)<0) h+=3;
          else if(strcmp(p,q)>0) t+=3;
                else
                    {
                     h++;
                     t++;
                    }
        }
    cout<<t<<" "<<h<<"\n";
    return 0;
}



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

int main(){
    int n;
    cin >> n;
    pair<double,double> p[n];
    for(int i=0; i<n; i++){
        double a,b;
        cin >> a >> b;
        p[i].first = a;
        p[i].second = b;
    }
    double n1 = 1;
    for(int i=2; i<=n-1; i++) n1 *= i;
    double sum = 0;
    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            if(i != j){
                sum  += 2*n1*sqrt(pow((p[i].first-p[j].first),2)+
                        pow(p[i].second-p[j].second,2));
            }
        }
    }
    cout << setprecision(20) << sum/(n1*n) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
int n,k;
vector<int> a;
vector<int> ama;
bool ok(int d){
    int tekazu = 0;
    for(int i=0; i<n; i++){
        ama[i] = a[i]%d;
    }
    sort(ama.begin(),ama.end());
    int l=0, r=n-1, ls=0, rs=0;
    while(l<=r){
        if(ls<rs){
            ls+=ama[l];
            l++;
        }else{
            rs+=d-ama[r];
            r--;
        }
    }
    return k>=ls;
}

int main(){
    cin>>n>>k;
    a.resize(n);
    ama.resize(n);
    for(int i=0; i<n; i++) cin>>a[i];
    int sa = 0;
    for(int i=0; i<n; i++) sa+=a[i];
    int sq = (int)pow(sa,0.5);
    int maxGCD = 0;
    for(int i=1; i<=sq; i++){
        if(sa%i==0){
            int j = sa/i;
            if(ok(i))maxGCD=max(maxGCD,i);
            if(ok(j))maxGCD=max(maxGCD,j);
        }
    }
    cout<<maxGCD;
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0);
   ll int a,b,k;
   cin>>a>>b>>k;
if(k>=a)
{
k=k-a;
a=0;

 if(b<k)
{

b=0;
}
else
{
    b=b-k;
}
}

else
{
    a=a-k;
}

cout<<a<<" "<<b;
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <tuple>
#include <map>
#include <set>
typedef long long ll;
using namespace std;
#define rep(i, n) for (int i = 0; i <= int(n); i++)
#define mod 1000000007

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    int Alice = 0;
    int Bob = 0;
    for(int i = 0; i < n; i++){
        if(i % 2 == 0){
            Alice += a[i];
        }else{
            Bob += a[i];
        }
    }
    cout << Alice - Bob << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <queue>

typedef long long ll;
const ll LL_MAX (1LL<<60);
const ll MOD (1000000007);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

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

    ll a, b, c;
    cin >> a >> b >> c;
    if (b-a == c-b)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
//
// Created by tac on 2016/10/12.
//

#include <cstdlib>
#include <string>
#include <iostream>

std::string get_range(int a, int b, int c) {
    std::string ans;

    if (a < b && b < c) {
        ans = std::string {"Yes"};
    } else {
        ans = std::string {"No"};
    }
    return ans;
}

int main() {
    int a;
    int b;
    int c;

    std::cin >> a;
    std::cin >> b;
    std::cin >> c;
    std::cout << get_range(a, b, c) << std::endl;
    return EXIT_SUCCESS;
}

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

int main() {
  int A, B;
  cin >> A >> B;
  if ((1 <= A)&&(A <= 9)&&(1 <= B)&&(B <= 9)) {
    cout << A * B << endl;
  } else {
    cout << -1 << endl;
  }
}

Measured memory_bytes: 256
#!/usr/bin/env python3
#CODE FESTIVAL 2016 A

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
a = LI()
x = []
for i in range(n):
    if i+1 > a[i]:
        x.append((a[i],i+1))
    else:
        x.append((i+1,a[i]))
print(n-len(list(set(x))))


Measured memory_bytes: 65884
######################################################
# ruby 2.5.1 or later
######################################################
module ModInt
  MOD = 10 ** 9 + 7

  def to_mod(a); a % MOD; end
  def add(a, b); (a + b) % MOD; end
  def mul(a, b); (a * b) % MOD; end
  def inv(a); a.pow(MOD - 2, MOD); end
  def div(a, b); mul(a, inv(b)); end
end
include ModInt

class FactTable
  def initialize(n)
    @fact = [1] * (n + 1)
    @finv = [1] * (n + 1)
    2.upto(n) { |i| @fact[i] = mul(@fact[i - 1], i) }
    @finv[n] = inv(@fact[n])
    n.downto(3) { |i| @finv[i - 1] = mul(@finv[i], i) }
  end

  def nCk(n, m)
    mul(mul(@fact[n], @finv[m]), @finv[n - m])
  end
end

ft = FactTable.new(2000000)

k = gets.to_s.to_i
s = gets.chomp
n = s.size

ans = 0
0.upto(k) do |x|
  y = k - x
  ans = add ans, 26.pow(x, MOD) * 25.pow(y, MOD) * ft.nCk(y + n - 1, n - 1)
end
puts ans

Measured memory_bytes: 47912
def main2():
    A, B, C = map(int, input().split())

    if A % 2 == 0 or B % 2 == 0 or C % 2 == 0:
        print(0)
    else:
        print(min(A*B, B*C, C*A))

if __name__ == "__main__":
    main2()

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

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

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts> auto make_v(size_t a,Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }

template<typename T> void fill_all(T& arr, const T& v) { arr = v; }
template<typename T, typename U> void fill_all(T& arr, const U& v) { for (auto& i : arr) fill_all(i, v); }

template<typename T>auto&operator<<(ostream&s,const vector<T>&v){s<<"[";bool a=1;for(auto e:v){s<<(a?"":" ")<<e;a=0;}s<<"]";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const pair<T,U>&p){s<<"("<<p.first<<","<<p.second<<")";return s;}
template<typename T>auto&operator<<(ostream&s,const set<T>&st){s<<"{";bool a=1;for(auto e:st){s<<(a?"":" ")<<e;a=0;}s<<"}";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const map<T,U>&m){s<<"{";bool a=1;for(auto e:m){s<<(a?"":" ")<<e.first<<":"<<e.second;a=0;}s<<"}";return s;}
#define DUMP(x) cout<<#x<<" = "<<(x)<<endl

struct edge { int to, cost; };

const LL LINF = 1LL<<60;
const int IINF = 1<<30;
const LL MOD = 1e9+7;

int main()
{
   int H, W, d; cin >> H >> W >> d;

   vector<char> cs{ 'R', 'Y', 'G', 'B' };

   auto s = make_v<int>(H, W);

   for (int i = 0; i < H; ++i) {
      for (int j = 0; j < W; ++j) {
         int x = i+j, y = i-j;
         while (y < 0) y += 2*d;
         (x /= d) %= 2;
         (y /= d) %= 2;
         s[i][j] = x*2 + y;
      }
   }

   for (int i = 0; i < H; ++i) {
      for (int j = 0; j < W; ++j) {
         cout << cs[s[i][j]];
      }
      cout << endl;
   }

   return 0;
}


Measured memory_bytes: 1536
WHITE = '.'
BLACK = '#'

H, W, K = map(int, input().split())
C = [input() for _ in range(H)]

ans = 0
for rows in range(2 ** H):
    for cols in range(2 ** W):
        cnt = 0
        for h in range(H):
            for w in range(W):
                if (rows >> h) & 1 or (cols >> w) & 1:
                    continue
                cnt += C[h][w] == BLACK
        if cnt == K:
            ans += 1
print(ans)

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

int main(){
  int a,b,c;
  scanf("%d%d%d",&a,&b,&c);
  int sum1 = a + b;
  int sum2 = a + c;
  int sum3 = c + b;
  int min = sum1;
  if(min > sum2)min = sum2;
  if(min > sum3)min = sum3;
  printf("%d\n",min);
  return 0;
}

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

int main() {
	int a,b;
	cin >> a ;
	cin >> b;
	if(a==0&&b==0){
		cout << 0 << endl;
	}else if(a==0){
		cout << b << endl;
	}else if(a==0){
		cout << b << endl;
	}else{
    long long int lar = max(a, b); 
    long long int small = min(a, b); 
    for (long long int i = lar; ; i += lar) { 
        if (i % small == 0) {
            cout <<  i << endl; 
            break;
        }
    }
	}
	
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MAX 55
int vis[MAX];
int graph[MAX][MAX];
int n,m;
int cnt=0;

void dfs(int node)
{
	vis[node]=1;
	for(int i=1;i<=n;i++)
	{
		if(graph[node][i]==1&&graph[i][node]==1&&vis[i]==0)
		{
			dfs(i);
		}
	}
}
void initvis()
{
	memset(vis,0,sizeof(vis));
}
int main (void)
{
	int tmp1,tmp2;
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++)
	{
		scanf("%d%d",&tmp1,&tmp2);
		graph[tmp1][tmp2]=1;
		graph[tmp2][tmp1]=1;	
	}
	
	for(int i=1;i<=n;i++)
	for(int j=1;j<=n;j++)
	{
		if(graph[i][j]==1)
		{
			graph[i][j]=0;
			graph[j][i]=0;
			initvis();
			dfs(i);//涂色   
		
		for(int k=1;k<=n;k++)
		if(vis[k]==0)  {
		cnt++;
		break; 
		}
		graph[i][j]=1;
		graph[j][i]=1;		
		}

		
	}
	


	printf("%d\n",cnt/2);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
int x=0;
int y=0;
int fl=0;

scanf("%d %d",&x,&y);

if(y%2==1){

printf("No\n");

}else if(4*x<y){

printf("No\n");

}else if(2*x>y){

printf("No\n");

}else{

printf("Yes\n");

}
return 0;

}

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

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

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int UI;

using namespace std;

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

    string s1, s2;
    cin >> s1 >> s2;
    string ns = s1;
    reverse(ns.begin(), ns.end());

    if (s2 == ns)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}


signed main(){
	int n; cin>>n;
  vector<ll> H;
  rep(i,n){
    ll h; cin>>h;
    H.PB(h);
  }
  bool ans = true;
  ll m = H[n-1];
  REP(i,n){
    if(H[i]-1>m) ans=false;
    m=min(m,H[i]);
  }
  if(ans){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

}


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

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;

const int INF=1e9;
const int MOD=1e9+7;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

int main()
{
	for(int n;cin>>n && n;){
		cin.ignore();
		
		map<string,int> f;
		vector<pii> es;
		rep(i,n){
			string s;
			getline(cin,s,'-');
			f.insert(mp(s,f.size()));
			int u=f[s];
			getline(cin,s);
			f.insert(mp(s,f.size()));
			int v=f[s];
			es.emplace_back(u,v);
		}
		
		n=f.size();
		vvi g1(n,vi(n));
		for(auto e:es){
			int u,v; tie(u,v)=e;
			g1[u][v]=1;
		}
		
		vvi g(n,vi(n,INF));
		rep(i,n) rep(j,n){
			rep(k,n) if((g1[i][k]||g1[k][i])&&(g1[j][k]||g1[k][j]))
				g[i][j]=0;
			rep(k,n) if((g1[i][k]&&g1[k][j])||(g1[j][k]&&g1[k][i]))
				g[i][j]=INF;
		}
		rep(i,n) rep(j,n) if(g1[i][j]) g[i][j]=1;
		rep(k,n) rep(i,n) rep(j,n)
			g[i][j]=min(g[i][j],g[i][k]+g[k][j]);
		
		cout<<n<<endl;
		
		int m; cin>>m;
		cin.ignore();
		rep(i,m){
			string s;
			getline(cin,s,'-');
			int u=f.count(s)?f[s]:-1;
			getline(cin,s);
			int v=f.count(s)?f[s]:-1;
			
			if(u==-1 || v==-1)
				cout<<"NO"<<endl;
			else
				cout<<(g[u][v]%2?"YES":"NO")<<endl;
		}
	}
}

Measured memory_bytes: 1564
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
using namespace std;

int main(){
  int N,A,B,C,D;
  string S;
  cin>>N>>A>>B>>C>>D>>S;
  
  if(C<D){
    bool CAN=true;
    for(int i=A; i<D-1; ++i){
      if(S.at(i)=='#' && S.at(i+1)=='#') CAN=false;
    }
    if(CAN) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
  
  else{
    bool CAN=true;
    bool TUG=false;
    for(int i=A; i<C-1; ++i){
      if(S.at(i)=='#' && S.at(i+1)=='#') CAN=false;
    }
    for(int i=B-2; i<D-1; ++i){
      if((S.at(i)=='.' && S.at(i+1)=='.') && S.at(i+2)=='.') TUG=true;
    }
    if(CAN && TUG) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
  
}


Measured memory_bytes: 640
def main():
	S = input()
	start0 = "0"
	ans0 = 0
	ans1 = 0
	for i, c in enumerate(S):
		if i % 2 == 0:
			if c != start0:
				ans1 += 1
			else:
				ans0 += 1
		else:
			if c != start0:
				ans0 += 1
			else:
				ans1 += 1
	print(min(ans0, ans1))

if __name__ == '__main__':
    main()

Measured memory_bytes: 3188
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String line = null;
        double x = 0, y = 0;
        double pai = Math.acos(-1);
        int ang = 0;
        while ((line = in.readLine()) != null) {
            String[] strs = line.split(",");
            int x1 = Integer.parseInt(strs[0]);
            int y1 = Integer.parseInt(strs[1]);
            if (x1 == 0 && y1 == 0) {
                break;
            }
            x += x1 * Math.sin(pai * ang / 180);
            y += x1 * Math.cos(pai * ang / 180);
            ang += y1;
        }

        System.out.println((int)x);
        System.out.println((int)y);
    }
}



Measured memory_bytes: 24284
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <map>
#include <set>
#include <deque>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int mod = 1e9+7;
const int inf = 1<<30;
typedef pair<int, int> P;

struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint c[4010][4010];

void init() {
  c[0][0] = 1;
  rep(i, 4001) {
    rep(j, i+1) {
      c[i+1][j] += c[i][j];
      c[i+1][j+1] += c[i][j];
    }
  }
}

mint comb(int n, int k) {
  return c[n][k];
}

mint f2(int n, int k) {
  return comb(n+k-1, k-1);
}

mint f(int n, int k) {
  if(n < k) return 0;
  if(n == 0 && k == 0) return 1;
  if(k < 1) return 0;
  return f2(n-k, k);
}

int main() {
  init();
  int n, k; cin >> n >> k;
  for(int i = 1; i <= k; i++) {
    mint blue = f(k, i);
    mint red = 0;
    red += f(n-k, i-1);
    red += f(n-k, i);
    red += f(n-k, i);
    red += f(n-k, i+1);
    mint ans = blue * red;
    printf("%lld\n", ans.x);
  }

  return 0;
}


Measured memory_bytes: 125952
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#include <bitset>
#include <numeric>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[8]={ 0, 1, 0,-1, 1, 1,-1,-1}; // x軸方向への変位
ll dy[8]={ 1, 0,-1, 0, 1,-1, 1,-1}; // y軸方向への変位

int main(void){
    ll n, k, s;
    cin >> n >> k >> s;
    vector<ll> ans;
    if(s!=1e+9){
        for(ll i = 1; i <= n; i++){
            if(i<=k) ans.push_back(s);
            else ans.push_back(1e+9);
        }
    }
    else{
        for(ll i = 1; i <= n; i++){
            if(i<=k) ans.push_back(s);
            else ans.push_back(1);
        }
    }
    for(ll i = 0; i < n; i++)
        cout << ans[i] << " ";
    cout << endl;
    return 0;
}


Measured memory_bytes: 2292
// abc132_c
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N;
    cin >> N;
    vector<int> A(N);
    REP(i, N) cin >> A[i];
    sort(ALL(A));

    if (N % 2 != 0){
        print(0);
        return 0;
    }

    int x = A[N / 2 - 1];
    int y = A[N / 2];

    print(y - x);

    return 0;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
// Custom Header {{{
#define all(x)      x.begin(), x.end()
#define rep(i,n)    for (i64 i = 0; i < (n); ++i)
#define reps(i,s,t) for (i64 i = (s); i <= (t); ++i)
#define repr(i,s,t) for (i64 i = (s); i >= (t); --i)
#define LF          '\n'

#ifdef DBG
#define trace(...) _trace(#__VA_ARGS__, __VA_ARGS__);
#else
#define trace(...)
#endif

using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template<class T, class U>inline bool chmax(T &a, const U &b){return b>a ? (a=b,1) : 0;}
template<class T, class U>inline bool chmin(T &a, const U &b){return b<a ? (a=b,1) : 0;}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template<class T>
ostream& operator<< (ostream &os, const vector<T> &vec) {
    rep(i, vec.size()) os << vec[i] << (i+1 == vec.size() ? "" : " ");
    return os;
}

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

template <class T>
void _trace(const char *s, T&& x)
{
    clog << '{';
    while(*s != '\0' && *s != ',') clog << *(s++);
    clog << ":" << setw(3) << x << '}' << endl;
}

template <class Head, class... Tail>
void _trace(const char *s, Head&& head, Tail&&... tail)
{
    clog << '{';
    while(*s != ',') clog << *(s++);
    clog << ":" << setw(3) << head << "}, ";
    for (++s; !isgraph(*s); ++s);
    _trace(s, std::forward<Tail>(tail)...);
}
// }}}

signed main()
{
    // ios::sync_with_stdio(false); cin.tie(nullptr);
    int n; cin >> n;
    cout << "ABC" << n << endl;

    return 0;
}



Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int main() {
  string s;
  cin >> s;
  int N = s.size();
  int ret = 0;
  for (int i = 0; i < N - 1; i++) {
    if (s[i] != s[i + 1]) {
      ret++;
    }
  }
  cout << ret << endl;
  return 0;
}

Measured memory_bytes: 512
/*
author: Apoorv Singh
*/
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
 
typedef vector <long long> vi;
typedef pair <long long, long long> pii;
#define pb push_back   
#define all(c) c.begin(), c.end()
#define For(i, a, b) for (long long i = a; i < b; ++i)
#define Forr(i, a, b) for (long long i = a; i > b; --i)
#define um unordered_map
#define F first
#define S second
#define int long long
#define inf LLONG_MAX
#define endl "\n"
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout << name << " : " << arg1 << endl;	
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

template <class X>
void printarr(X arr[], int n) {
	for (int i = 0; i < n; ++i)
		cout << arr[i] << ' ';
	cout << endl;
}

template <typename X> ostream& operator << (ostream& x,const vector<X>& v){ for (X a : v) x << a << ' '; return x;} 
template <typename X, typename Y> ostream& operator << (ostream& x, const vector< pair<X, Y> >& v) {for (pair <X, Y> it : v) x << it.first << ' ' << it.second << endl; return x;} 
template <typename T, typename S> ostream& operator << (ostream& os, const map<T, S>& v) { for (pair <T, S> it : v) os << it.first << " => " << it.second << endl; return os; }
 
template <class T, class cmp = less<T>> using ordered_set = tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
 
int modulo = 1e9 + 7;

int fpow(int a, int n) {
	int ans = 1;
	while (n) {
		if (n&1) ans = (ans*a)%modulo;
		a = (a*a)%modulo; n = n >> 1;
	}
	return ans;
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n; cin >> n;
	vector <string> arr;
	For(i,0,n) {
		string s; cin >> s;
		vector <char> x;
		For(j,0,s.size()) x.pb(s[j]);
		sort(all(x));
		string y = "";
		For(j,0,s.size()) y += x[j];
		arr.pb(y);
	}
	sort(all(arr));
	int ptr = 0;
	int ans = 0;
	while (ptr < n) {
		int cnt = 0;
		string curr = arr[ptr];
		int temp = ptr;
		For(i,temp,n) {
			if (curr == arr[i]) {
				++cnt;
				++ptr;
			}
			else break;
		}
		ans += (cnt*(cnt-1))/2;
	}
	cout << ans;
	return 0;
}

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
ll MOD = 1e9+7;
ll INF = 1e18;
void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }

int main(){
  ll i, j;
  ll n;
  cin >> n;
  bool judge = n < 1000;
  ll result;

  /*
  vector<ll> a(n);
  for(i = 0; i < n; i++)
    cin >> a[i];
  //for(i = 0; i < n; i++)
    
  */
  
  
  if(judge)
    cout << "ABC" << endl;
    //cout << "YES" << endl;
    //cout << "Yay!" << endl;
  else
    cout << "ABD" << endl;
    //cout << "NO" << endl;
    //cout << ":(" << endl;
  
  
  //cout << result << endl;

  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws NumberFormatException, IOException {
		//BufferedReader in = new BufferedReader(new FileReader(new File("input.txt")));
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Byte N = Byte.valueOf(in.readLine());
		StringBuilder S = new StringBuilder(in.readLine());
		Byte K = Byte.valueOf(in.readLine());
		
		
		char to = S.charAt(K-1);
		for(int i = 0; i < S.length(); i++) {
			if(S.charAt(i) != to) {
				S.deleteCharAt(i);
				S.insert(i, '*');
			}
		}
		System.out.println(S.toString());
	}
}


Measured memory_bytes: 22992
def main():
  divisor = 10 ** 9 + 7
  h, w = map(int, input().split())
  a = [input() for _ in range(h)]
  dp = [[0] * w for _ in range(h)]
  dp[0][0] = 1
  for i in range(h):
    ai = a[i]    
    dpi = dp[i]    
    if i + 1 < h:
      ai1 = a[i + 1]
      dpi1 = dp[i + 1]
    for j in range(w):
      if i + 1 < h and ai1[j] != '#':
        dpi1[j] = (dpi1[j] + dpi[j]) % divisor
      if j + 1 < w and ai[j + 1] != '#':
        dpi[j + 1] = (dpi[j + 1] + dpi[j]) % divisor
  print(dp[h - 1][w - 1])
main()

Measured memory_bytes: 43648
n, q = map(int, input().split())
s = input()

ac_counts = [0 for _ in range(n + 1)]

for i in range(n):
    ac_counts[i + 1] = ac_counts[i] + (1 if s[i: i + 2] == 'AC' else 0)

for i in range(q):
    l, r = map(int, input().split())
    print(ac_counts[r - 1] - ac_counts[l - 1])

Measured memory_bytes: 9564
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <queue>
#include <map>
#include <set>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define INF 1<<30
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

	vector<int> v(n);
	rep(i, n) cin >> v[i];

	int ans = 0;
	rep(i, n) {
		int j = v[i];
		j--;
		int k = v[j];

		if(k == i+1) ans++;
	}

	cout << ans / 2 << endl;

	return 0;
}


Measured memory_bytes: 640
import Control.Applicative
import Data.IntSet (IntSet)
import qualified Data.IntSet as IS

main :: IO ()
main = do
  [x, n] <- f
  if n == 0 then print x
    else solve x <$> f >>= print
  where
    f = map read <$> words <$> getLine

solve :: Int -> [Int] -> Int
solve x ps = f 0
  where
    st = IS.fromList ps
    f i
      | IS.notMember (x - i) st = x - i
      | IS.notMember (x + i) st = x + i
      | otherwise = f (i + 1)


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

int main(){
  int N;
  cin >> N;
  vector<int> A = {1,2,3,4,5,6,7,8,9,10,12,14,15,16,18,20,21,24,25,27,28,30,32,35,36,40,42,45,48,49,54,56,63,64,72,81};
  bool exist = false;
  for(int i=0;i<A.size();i++){
    if(N==A[i]){
      exist = true;
    }
  }
  if(exist){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int mx=404;
ll pre[mx];
ll arr[mx];
ll dp[mx][mx];
const ll inf=1e14;
ll cal(ll L,ll R){
    if(L>R){
        return inf;
    }
    return pre[R]-pre[L-1];
}

ll solve(int L,int R){
    if(dp[L][R] != -1)return dp[L][R];
    if(L==R)return dp[L][R]=0;
    if((L+1)==R)return dp[L][R]=arr[L]+arr[R];

    ll best=1e15;
    for(int i=L;i<R;i++){
            ll cans=solve(L,i)+solve(i+1,R)+cal(L,R);
        best=min(best,cans);
    }

    return dp[L][R]=best;
}


int main(){
    memset(dp,-1,sizeof(dp));
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
            cin>>arr[i];
            pre[i]+=pre[i-1]+arr[i];
    }
    cout<<solve(1,n);
}


Measured memory_bytes: 1536
#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
using namespace std;
using namespace __gnu_pbds;
template <class c, class cmp = less<c> > using ordered_set = tree<c, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
template <typename T,typename U>pair<T,U> operator+(const pair<T,U> & l,const std::pair<T,U> & r) { return {l.first+r.first,l.second+r.second};}
typedef long long int ll;
const ll mod =1e9+7;
const int maxn = 100002;
#define endl '\n'
#define int ll
#define ld long double
#define all(x) (x).begin(),(x).end()

int32_t main()
{ 
   IOS

  int n;
  cin >> n;
  int f[n+1] = {0};
  for(int i =  1;i<=100;i++){
    for(int j =  1;j<=100;j++){
      for(int k = 1;k<=100;k++){
        int p = i*i + j*j + k*k + i*j + i*k + j*k;
        if(p<=n)
          f[p]++;
      }
    }
  }
  for(int i = 1;i<=n;i++)
    cout << f[i]<<endl;
  



  

  

  
  
  
  

  
  
  
    


  


  
}

Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <functional>
#include <array>

using namespace std;

int main(){
    int64_t N, A, B;
    cin >> N >> A >> B;

    vector<int64_t> X(N);
    for(auto& c : X){
        cin >> c;
    }

    int64_t ans = 0;
    for(int i = 1; i < N; ++i){
        int64_t d = X[i] - X[i-1];
        ans += min(d * A, B);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<stdio.h>

int h, A[2000001];

void maxHeapify(int i) {
	int temp;
	int l,r,largest;
	l = 2*i;
	r = 2*i+1;

	if(l<=h && A[l] > A[i]) largest = l;
	else largest = i;
	if(r<=h && A[r]>A[largest]){ largest = r; }
	if(largest != i){
		temp = A[i];
		A[i] = A[largest];
		A[largest] = temp;
		maxHeapify(largest);
	} 
}

int extract() {
	int maxv;
	if (h < 1) return;
	maxv = A[1];
	A[1] = A[h--];
	maxHeapify(1);
	return maxv;
}

void increaseKey(int i, int key) {
	int temp;
	if (key < A[i]) return;
	A[i] = key;
	while (i>1 && A[i/2]<A[i]) {
		temp = A[i];
		A[i] = A[i/2];
		A[i/2] = temp;
		i = i/2;
	}
}

void insert(int key) {
	h++;
	A[h] = -1000000000;
	increaseKey(h, key);
}

main() {
	int key;
	char com[20];
	while (1) {
		scanf("%s", com);
		if (com[0] == 'i') {
			scanf("%d", &key);
			insert(key);
		}
		else if (strcmp(com, "extract") == 0) {
			printf("%d\n", extract());
		}
		else break;
	}

	return 0;
}


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

using namespace std;

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

typedef long long ll;

const int N = 3e5;

int p[N];
int sz[N];

int getp(int v) {
  return (p[v] == v ? v : p[v] = getp(p[v]));
}

mt19937 rnd;

void solve() {
  int n, m; cin >> n >> m;
  for (int i = 1; i <= n; i++)
    p[i] = i, sz[i] = 1;
  for (int i = 0; i < m; i++) {
    int v, u; cin >> v >> u;
    v = getp(v), u = getp(u);
    if (v == u) continue;
    if (rnd() & 1) swap(v, u);
    p[v] = u;
    sz[u] += sz[v];
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    ans = max(ans, sz[i]);
  }
  cout << ans;
}

// CHECK LIMITS (n <= 10^5)
// CHECK CORNER CASES (n == 1)

int main() {
  ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
  cout.setf(ios::fixed), cout.precision(20);
  //cout << 1.0 * clock() / CLOCKS_PER_SEC << endl;
  solve();
}


Measured memory_bytes: 5152
#include <stdio.h>

#define Mod 998244353

int main()
{
	int i, N, S, A[3001];
	scanf("%d %d", &N, &S);
	for (i = 1; i <= N; i++) scanf("%d", &(A[i]));
	
	int j;
	long long dp[3001] = {}, ans = 0;
	for (i = 1; i <= N; i++) {
		if (A[i] < S) ans = (ans + dp[S-A[i]] * (N - i + 1)) % Mod;
		else if (A[i] == S) ans = (ans + i * (N - i + 1)) % Mod;
		for (j = S - A[i] - 1; j > 0; j--) dp[j+A[i]] = (dp[j+A[i]] + dp[j]) % Mod;
		if (A[i] < S) dp[A[i]] = (dp[A[i]] + i) % Mod;
	}
	
	printf("%lld\n", ans);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1728
#include <iostream>
#include <cmath>

using namespace std;


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

    int a, b, c;
    cin >> a; cin >> b;
    int count = 0;
    for (int i = 0; i < n-2; i++) {
        cin >> c;
        if (max(max(a,b), c) != b && min(min(a, b), c) != b) {
            count++;
        }
        a = b;
        b = c;
    }

    cout << count << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void) {
	int a = 1,b,c,d,e=0,f;
	char r[50];
	while (a) {
		scanf("%d %d %d", &b, &c, &d);
		if (b == -1 && c == -1 && d == -1) {
			a = 0;
		}
		else if (b == -1 || c == -1) {
			r[e] = 'F';
			e++;
		}
		else if (b + c >= 80) {
			r[e] = 'A';
			e++;
		}
		else if (65 <= b + c && b + c < 80) {
			r[e] = 'B';
			e++;
		}
		else if (50 <= b + c && b + c < 65) {
			r[e] = 'C';
			e++;
		}
		else if (30 <= b + c && b + c < 50 && 50<=d) {
			r[e] = 'C';
				e++;
		}
		else if (30 <= b + c && b + c < 50 && d < 50) {
			r[e] = 'D';
			e++;
		}
		else {
			r[e] = 'F';
			e++;
		}
	}
	for (f = 0; f < e; f++) {
		printf("%c\n", r[f]);
	}
	return 0;
}


Measured memory_bytes: 2716