akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using std::cin;
using std::cout;

unsigned gaps[] = {1,8,23,77,281,1073,4193,16577,65921,262913,1050113};
// generated from pow(4,i)+3*pow(2,i-1)+1 (prefixed with 1)

unsigned insertion_sort(unsigned a[], unsigned n, unsigned gap){
  unsigned count = 0;
  for(unsigned i = gap; i < n; i++){
    unsigned v = a[i];
    int j = i - gap;
    while(j >= 0 && a[j] > v){
      a[j+gap] = a[j];
      j -= gap;
      count++;
    }
    a[j+gap] = v;
  }
  return count;
}

void shell_sort(unsigned a[], unsigned n){
  int i;
  unsigned gap_num = 11;
  while(gaps[--gap_num] > n);

  unsigned count = 0;
  for(i = gap_num; i >= 0; i--) count += insertion_sort(a,n,gaps[i]);

  cout << (gap_num+1) << '\n';

  for(i = gap_num; i; i--) cout << gaps[i] << ' ';
  cout << gaps[0] << '\n';

  cout << count << '\n';
}

int main(){
  std::ios::sync_with_stdio(false);
  unsigned n,i;
  cin >> n;
  auto a = new unsigned[n];
  for(i = 0; i < n; i++) cin >> a[i];
  shell_sort(a,n);
  for(i = 0; i < n; i++) cout << a[i] << '\n';
  delete[](a);
}

Measured memory_bytes: 4952
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder_20190707_1
{    class Program
    {
        static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());
            string S = Console.ReadLine();

            long E = 0;

            for(int i = 0; i < N; i++)
            {
                if(S[i] == 'E')
                {
                    E++;
                }
            }

            long W = 0;

            long min = 10000000000;

            for(int i = 0; i < N; i++)
            {
                if (S[i] == 'E')
                {
                    E--;
                }

                min = Math.Min((E + W), min);
                
                if (S[i] == 'W')
                {
                    W++;
                }
            }

            Console.WriteLine(min);
        }
    }
}

Measured memory_bytes: 28600
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<complex>
#include<cmath>
#include<algorithm>
#include<map>
#include<vector>
#include<sstream>
#include<iostream>
using namespace std;
int main(void){

    int x[3],n;
    while(cin>>x[0]>>x[1]>>x[2],x[0]){
        cin>>n;
        sort(x,x+3);
        x[0] /= 2;
        x[1] /= 2;
        double a = sqrt(x[0] * x[0] + x[1] * x[1]);
        while(n--){
            double r;
            cin>>r;
            if(r<=a)cout<<"NA"<<endl;
            else cout<<"OK"<<endl;
        }
    }


    return 0;
}

Measured memory_bytes: 1240
#include<bits/stdc++.h>
#define pb push_back
#define sz(v) (v).size()
#define all(v) (v).begin(),(v).end()
#define mp make_pair
#define fi first
#define se second
#define inf 1000000000
#define mod 1000000007
using namespace std;
template <class T> void chmax(T &x,T y){x=x>y?x:y;return;}
template <class T> void chmin(T &x,T y){x=x<y?x:y;return;}
typedef long long ll;
typedef unsigned long long ull;

double L;

int main()
{
	cin>>L;
	printf("%lf\n",(L/3)*(L/3)*(L/3));
	return 0;
}

Measured memory_bytes: 3760
//babu 
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<pair<int,int> > vii;
#define rep(i,i1,n) for(int i=i1;i<n;i++)
#define repb(i,i1,n) for(int i=i1;i>=n;i--)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define f first
#define s second
#define sz(a) (ll)a.size() 
#define EPS 1e-12
#define MOD 1000000007
#define tr1(x) cerr<<#x<<" : "<<x<<endl
#define tr2(x,y) cerr<<#x<<" : "<<x<<" | "<<#y<<" : "<<y<<endl
#define FAST_IO ios_base::sync_with_stdio(false);cin.tie(NULL)
#define si(c) scanf("%d",&c)
#define Sii(c,d) scanf("%d%d",&c,&d)
#define sll(c) scanf("%lld",&c)
#define pin(c) printf("%d\n",c)
#define plln(c) printf("%lld\n",c)
#define N 200010
#define init1(array,ST,END,val) for(int i=ST;i<END;i++)array[i]=val
#define init2(array,nn,mm,val) for(int i=0;i<nn;i++)for(j=0;j<mm;j++)array[i][j]=val

ll powmod(ll a,ll b)
{
	if(b==0)return 1;
	ll x=powmod(a,b/2);
	ll y=(x*x)%MOD;
	if(b%2)
		return (a*y)%MOD;
	return y%MOD;
}

int main()
{
    int a[220],n;
    cin>>n;
    rep(i,0,2*n){
        cin>>a[i];
    }
    sort(a,a+2*n);
    int tot=0;
    for(int i=0;i<=2*n-2;i+=2){
        tot+=min(a[i],a[i+1]);
    }
    cout<<tot<<endl;
    return 0;
}



Measured memory_bytes: 256
# input
N = int(input())
L = [0] * 100001
A = list(map(int, input().split()))
for i in A: L[i] += 1
Q = int(input())
S = sum(A)
for i in range(Q):
    B, C = map(int, input().split())
    S += L[B] * (C - B)
    L[C] += L[B]
    L[B] = 0
    print(S)



Measured memory_bytes: 21888
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

int main(){
	int x; scanf("%d", &x);
	printf("%d\n", x/500*1000 + x%500/5*5);
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <limits>
#include <cmath>
#include <cassert>

using namespace std;
using ll = long long;

const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    while(cin >> n >> m, n or m)
    {
        vector<int> A(n);
        for(int i = 0; i < n; i++) cin >> A[i];
        int ans = -1;
        for(int i = 0; i < n; i++)
        {
            for(int j = i + 1; j < n; j++)
            {
                if(A[i] + A[j] > m) continue;
                ans = max(ans, A[i] + A[j]);
            }
        }
        if(ans == -1) cout << "NONE" << endl;
        else cout << ans << endl;
    }
    return 0;
}




Measured memory_bytes: 3116
#include <stdio.h>

long GCD(long a, long b){
  long dividend, divisor;
  if (a >= b) {
    dividend = a;
    divisor = b;
  } else {
    dividend = b;
    divisor = a;
  }
  long remainder;
  while (1) {
    if (divisor == 1) {
      return 1;
    }
    remainder = dividend % divisor;
    if (remainder == 0) {
      break;
    } else {
      dividend = divisor;
      divisor = remainder;
    }
  }
  return divisor;
}

int main(void) {

  long n,m;
  scanf("%ld %ld", &n, &m);
  char s[n+1],t[m+1];
  scanf("%s %s", s, t);
  long l = (n/GCD(n,m))*m;
  long set_n = n/GCD(n,m);
  long set_m = m/GCD(n,m);
  long t_marker = 0;
  for (int i = 0; i < n; i += set_n) {
    if (s[i] != t[t_marker]) {
      printf("-1\n");
      return 0;
    }
    t_marker += set_m;
  }
  printf("%ld\n", l);

  return 0;
}

Measured memory_bytes: 256
import sys
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

sys.setrecursionlimit(10 ** 7)

class LCA:
    def __init__(self, G, root=0):
        V = len(G)
        K = 1
        while 1 << K < V:
            K += 1
        self.parent = [[-1] * V for _ in range(K)]
        self.dist = [-1] * V
        self.dfs(G, root, -1, 0)
        for k in range(K - 1):
            for v in range(V):
                if self.parent[k][v] < 0:
                    self.parent[k + 1][v] = -1
                else:
                    self.parent[k + 1][v] = self.parent[k][self.parent[k][v]]
    
    def dfs(self, G, v, p, d):
        self.parent[0][v] = p
        self.dist[v] = d
        for nv in G[v]:
            if nv != p:
                self.dfs(G, nv, v, d + 1)
    
    def query(self, u, v):
        if self.dist[u] < self.dist[v]:
            u, v = v, u
        K = len(self.parent)
        for k in range(K):
            if (self.dist[u] - self.dist[v]) >> k & 1:
                u = self.parent[k][u]
        
        if u == v:
            return u
        for k in range(K - 1, -1, -1):
            if self.parent[k][u] != self.parent[k][v]:
                u = self.parent[k][u]
                v = self.parent[k][v]

        return self.parent[0][u]
    
    def get_dist(self, u, v):
        return self.dist[u] + self.dist[v] - 2 * self.dist[self.query(u, v)]
    
    def on_path(self, u, v, a):
        return self.get_dist(u, a) + self.get_dist(a, v) == self.get_dist(u, v)

n = ni()
kc = nan(n)
q = ni()
uv = nan(q)

g = [[] for _ in range(n)]
for i in range(n):
    k = kc[i][0]
    c = kc[i][1:]
    for j in range(k):
        g[i].append(c[j])

lca = LCA(g)
for i in range(q):
    u, v = uv[i]
    print(lca.query(u, v))


Measured memory_bytes: 176232
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>

#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;

int main() {
    ll r, d, b;
    cin >> r >> d >> b;
    vector<ll> ans;
    ans.push_back(b);
    for(int i = 1; i <= 10; ++i){
        int x = ans[i - 1] * r - d;
        ans.push_back(x);
    }
    for(int i = 1; i <= 10; ++i) cout << ans[i] << endl;
	return 0;
}

Measured memory_bytes: 256
import math
a, b, h, m = map(int, input().split())
degm = m*6
degh = h*30+degm/360*30
diff = abs(degh-degm)
rad = diff/180 * math.pi
c = math.sqrt(a**2+b**2-2*a*b*math.cos(rad))
print(c)

Measured memory_bytes: 62544
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(v) v.begin(),v.end()
#define mem(arr) memset(arr, 0, sizeof(arr))
#define ff first
#define ss second
#define int long long int
const int MOD = 1e9 + 7;
const int INF = 1e18;
const int N = 1e6 + 20;
vector<int> g[N];
vector<int> vis(N);
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tc = 1;
    while(tc--){
        long double a, b;
        cin >> a >> b;
        long double p = a * b;
        int val = (int)floor(p);
        cout << val << '\n';
    }
}

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

typedef long long ll;
typedef unsigned long long ull;

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

  string s;
  cin >> s;

  ll ans = 0;
  ll x = 0;
  for (ll i = 0; i < n; ++i) {
    if (s[i] == 'I') x++;
    else if (s[i] == 'D') x--;
    ans = max(ans, x);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define  inf 2e18
#define  bg begin()
#define  en end()
#define  ll long long int
#define  pb push_back
#define  mp make_pair
#define  mod 1000000007
#define  vi vector<int>
#define  eb emplace_back
#define  lb(v,a) lower_bound(v.begin(),v.end(),a)
#define  ub(v,a) upper_bound(v.begin(),v.end(),a)
#define  bs binary_search
#define  vll vector<long long int>
#define  vpll vector<pair<long long int,long long int> >
#define  vpii vector<pair<int,int> >
#define  mpii map<int ,int>
#define  mpll map<long long int,long long int >
#define  max3(a,b,c) max(a,max(b,c))
#define  min3(a,b,c) min(a,min(b,c))
#define  w(t) ll t; cin>>t; while(t--)
#define  forn(i,n) for(int i=0;i<n;i++)
#define  forn1(i,n) for(int i=1;i<=n;i++)
#define  forv(it,v) for(auto it=v.begin();it!=v.end();it++)
#define  mem(a,val) memset(a,val,sizeof(a))
#define  Sort(vec) sort(vec.begin(),vec.end())
#define  RSort(vec) sort(vec.rbegin(),vec.rend())
#define  vin(v,n) for(int i=0;i<n;i++){cin>>x; v.pb(x);}
#define  deb1(x) cerr<<#x<<": "<<x<<" "<<endl
#define  deb2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define  deb3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define  deb4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define  FIFO ios::sync_with_stdio(false); cin.tie(0);cout.tie(0)
#define  PI 3.141592653589793238462643383279502884L
mpii mpx;
int main() {
    ll a, b, h, m;
    cin >> a >> b >> h >> m;
    ll x = h * 60 + m;
    long double d1 = (long double)(PI * x) / (360);
    long double d2 = (long double)(2 * PI * x) / 60;
    cout << fixed << setprecision(25) << sqrtl((long double)a * a + (long double) b * b - 2 * a * b * (long double)cos(abs(d1 - d2))) << endl;
    return 0;
}


Measured memory_bytes: 4164
N,M = map(int,input().split())
S = []
for _ in range(M):
    S.append(list(map(int,input().split()))[1:])
P = list(map(int,input().split()))
res = 0
for i in range(2**N):
    tmp = 0
    for j in range(M):
        ON = 0
        for s in S[j]:
            if (i >> s-1)&1 == 1:
                ON += 1
        if ON % 2 == P[j]:
            tmp += 1
    if tmp == M:
        res += 1
print(res)

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int minP = 999999999;
void DFS(int w, int p, int a, int b, int c)
{
	if(w == 0)
	{
		if(minP > p)
		{
			minP = p;
		}
	}
	if(w - 200 >= 0)
	{
		if(a + 1 < 5)
		{
			DFS(w - 200, p + 380, a + 1, b, c);
		}
		else
		{
			DFS(w - 200, p, 0, b, c);
		}
	}
	if(w - 300 >= 0)
	{
		if(b + 1 < 4)
		{
			DFS(w - 300, p + 550, a, b + 1, c);
		}
		else
		{
			DFS(w - 300, p + 220, a, 0, c);
		}
	}
	if(w - 500 >= 0)
	{
		if(c + 1 < 3)
		{
			DFS(w - 500, p + 850, a, b, c + 1);
		}
		else
		{
			DFS(w - 500, p + 544, a, b, 0);
		}
	}
	return;
}

void solve()
{
	int w;
	while(cin >> w, w)
	{
		minP = 999999999;
		DFS(w, 0, 0, 0, 0);
		cout << minP << endl;
	}
}

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

Measured memory_bytes: 1156
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N,M=MI()
    x=LI()
    y=LI()
    dx=[0]*(N-1)
    dy=[0]*(M-1)
    for i in range(N-1):
        dx[i]=x[i+1]-x[i]
    for i in range(M-1):
        dy[i]=y[i+1]-y[i]
    
    NN=max(N,M)+3
    #S[a]は1~aまでの和
    S=[0]*(NN+1)
    for i in range(1,NN+1):
        S[i]+=S[i-1]+i
        
    #端からa番目の要素を何回使う?
    def calc(a,nm):
        if nm%2==1 and a==(nm+1)//2:#aが中央の場合
            return S[a]+S[a-1]
        else:
            return 2*S[a]+(nm-2*a)*a
    

    X=0
    for i in range(N-1):
        X+=calc(i+1,N-1)*dx[i]
        X%=mod
        
    Y=0
    for i in range(M-1):
        Y+=calc(i+1,M-1)*dy[i]
        Y%=mod
        
    print((X*Y)%mod)
    

main()


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


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int h, w;
	cin >>h >>w;
	vector<string> ba(h);
	rep(i, h) cin >>ba[i];
	
	const int dr[]={0,1,0,-1,0};
	const int INF= 1<<28;
	vector<VI> dd(h, VI(w, INF));
	queue< pair<int, int> > que;
	que.emplace(0, 0); dd[0][0]=0;
	while(!que.empty()){
		int cy,cx; tie(cy,cx) = que.front();
		que.pop();
		rep(i,4){
			int ny=cy+dr[i], nx=cx+dr[i+1];
			if(ny<0 || ny>=h || nx<0 || nx>=w) continue;
			if(dd[ny][nx] == INF && ba[ny][nx] !='#'){
				que.emplace(ny, nx);
				dd[ny][nx] = dd[cy][cx] + 1;
			}
		}
	}
	
	if(dd[h-1][w-1] == INF){ puts("-1"); return 0;}
	int ans = h*w - 1 - dd[h-1][w-1];
	rep(i, h) rep(j ,w) if(ba[i][j]=='#') ans--;
	cout << ans <<"\n";
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,x,cnt=0,i,j,k;
    cin>>a>>b>>c;
    cin>>x;
    for(i=0;i<=a;i++)
    {
        for(j=0;j<=b;j++)
        {
            for(k=0;k<=c;k++)
            {
                if(i*500+j*100+k*50==x)
                    cnt++;
            }
        }
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

void CountingSort(int*,int*,int*,int,int);

int main(){
  int n,i,k=-1;
  scanf("%d",&n);

  int A[n],B[n],C[VMAX+1];

  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
    if(A[i]>k)k=A[i];
  }

  CountingSort(A,B,C,n,k);

  for(i=1;i<=n;i++){
    if(i==n) printf("%d\n",B[i]);
    else printf("%d ",B[i]);
  }

  return 0;
}

void CountingSort(int *A,int *B,int *C,int n,int k){
  int i,j;

  for(i=0;i<=k;i++){
    C[i]=0;
  }

  for(j=0;j<n;j++){
    C[A[j]]++;
  }

  for(i=1;i<=k;i++){
    C[i]=C[i]+C[i-1];
  }
  
  i=0;
  
  for(j=n-1;j>=0;j--){
    B[C[A[j]]]=A[j];
    C[A[j]]=C[A[j]]-1;
  }
  
}



Measured memory_bytes: 17516
#include "bits/stdc++.h"
#include<random>
using namespace std;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 1e9 + 7, INF = 1e18;

lint N, A;
lint cnt[1000000];
int main() {
	cin >> N;
	FOR(x, 1, 101) {
		FOR(y, 1, 101) {
			FOR(z, 1, 101) {
				cnt[x * x + y * y + z * z + x * y + y * z + z * x]++;
			}
		}
	}
	REP(i, N) {
		cout << cnt[i + 1] << endl;
	}
}


Measured memory_bytes: 4036
#include<iostream>
#include<vector>
#include<algorithm>
#include<climits>

using namespace std;

int main(void){


  int n;
  while(cin >> n,n){

    int mx=0,mn=INT_MAX;

    for(int i=0;i<n;i++){
      int sum=0;
      for(int j=0;j<5;j++){
        int a;
        cin >> a;
        sum+=a;
      }
      mx=max(mx,sum);
      mn=min(mn,sum);
    }
    cout << mx << " " << mn << endl;
  }

  return 0;
}

Measured memory_bytes: 1160
program main;
var 
    a : string;
    i,n,c : integer;
begin
    c := 0;
    readln(n);
    readln(a);
    for i := 1 to n do
        if a[i] = 'A' then 
            if a[i+1] = 'B' then 
                if a[i+2] = 'C' then 
                    inc(c);
    writeln(c);
end.

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

int main() {

  long long int n;
  cin >> n;

  for ( long long int i = 0; i < n; i++ ) {

    string in0, in1;
    cin >> in0 >> in1;

    long long int k = 1;

    long long int m0 = 0;
    for ( long long int j = 0; j < in0.size(); j++ ) {

      if ( in0[j] <= '9' ) {
	k = in0[j] - '0';
      }else {
	if ( in0[j] == 'm' ) {
	  m0 += k * 1000;
	}else if ( in0[j] == 'c' ) {
	  m0 += k * 100;
	}else if ( in0[j] == 'x' ) {
	  m0 += k * 10;
	}else {
	  m0 += k * 1;
	}
	k = 1;
      }

    }

    long long int m1 = 0;
    for ( long long int j = 0; j < in1.size(); j++ ) {

      if ( in1[j] <= '9' ) {
	k = in1[j] - '0';
      }else {
	if ( in1[j] == 'm' ) {
	  m1 += k * 1000;
	}else if ( in1[j] == 'c' ) {
	  m1 += k * 100;
	}else if ( in1[j] == 'x' ) {
	  m1 += k * 10;
	}else {
	  m1 += k * 1;
	}
	k = 1;
      }

    }

    m0 += m1;

    if ( m0 >= 1000 ) {
      if ( m0 >= 2000 ) {
	cout << m0 / 1000;
      }
      cout << "m";
      m0 %= 1000;
    }
    if ( m0 >= 100 ) {
      if ( m0 >= 200 ) {
	cout << m0 / 100;
      }
      cout << "c";
      m0 %= 100;
    }
    if ( m0 >= 10 ) {
      if ( m0 >= 20 ) {
	cout << m0 / 10;
      }
      cout << "x";
      m0 %= 10;
    }
    if ( m0 >= 1 ) {
      if ( m0 >= 2 ) {
	cout << m0 / 1;
      }
      cout << "i";
      m0 %= 1;
    }
    cout << endl;

  }

  return 0;

}

Measured memory_bytes: 1204
#!/usr/bin/env python

import sys
import math
import itertools as it
from collections import deque

sys.setrecursionlimit(10000000)

def func():
    N = input()
    S = raw_input()

    S1 = S[:N]
    S2 = S[N:]

    m = {}

    for i in range((1 << N)):
        s1 = s2 = ''
        for j in range(N):
            if(i & (1 << j)):
                s1 = s1 + S1[j]
            else:
                s2 = S1[j] + s2
        if (s1, s2) in m:
            m[(s1, s2)] += 1
        else:
            m[(s1, s2)] = 1

    ans = 0

    for i in range((1 << N)):
        s1 = s2 = ''
        for j in range(N):
            if(i & (1 << j)):
                s1 = S2[j] + s1
            else:
                s2 = s2 + S2[j]
        if (s1, s2) in m:
            ans += m[(s1, s2)]

    print ans

func()

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

void bubblesort(int *a, char*b, int n){
        for(int i=0;i<n;i++){
                for(int j=n-1;j>0;j--){
                        if(a[j]<a[j-1]) {
                                swap(a[j],a[j-1]);
                                swap(b[j],b[j-1]);
                        }
                }
        }
}
void selectsort(int *a, char *b, int n){
        int mini;
        for(int i=0;i<n-1;i++){
                mini = i;
                for(int j=i+1;j<n;j++){
                        if(a[j]<a[mini]) {
                                mini = j;
                        }
                }
                if(mini!=i){
                        swap(a[mini],a[i]);
                        swap(b[mini],b[i]);
                }
        }
}

int main(){
        int n;
        string s;
        int bubblea[100];
        char bubbleb[100];
        int selecta[100];
        char selectb[100];
        cin>>n;
        for(int i=0;i<n;i++){
                cin>>s;
                bubblea[i] = s[1]-'0';
                bubbleb[i] = s[0];
                selecta[i] = s[1]-'0';
                selectb[i] = s[0];
        }
        bubblesort(bubblea, bubbleb, n);
        selectsort(selecta, selectb, n);

        for(int i=0;i<n;i++){
                cout<<bubbleb[i]<<bubblea[i];
                if(i==n-1) cout<<endl;
                else cout<<" ";
        }
        cout<<"Stable"<<endl;

        for(int i=0;i<n;i++){
                cout<<selectb[i]<<selecta[i];
                if(i==n-1) cout<<endl;
                else cout<<" ";
        }
        bool stable = true;
        for(int i=0;i<n;i++)
                if(bubbleb[i]!=selectb[i]){
                        stable = false;
                        break;
                }
        if(stable)cout<<"Stable"<<endl;
        else cout<<"Not stable"<<endl;

        return 0;
}





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

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> X(M),Y(M);
  for(int i=0;i<M;i++){
    cin >> X.at(i) >> Y.at(i);
  }
  vector<bool> A(N,false);
  vector<int> num(N,1);
  A.at(0)=true;
  for(int i=0;i<M;i++){
    num.at(X.at(i)-1)--;
    num.at(Y.at(i)-1)++;
    if(A.at(X.at(i)-1)){
      A.at(Y.at(i)-1)=true;
    }
    if(num.at(X.at(i)-1)==0){
      A.at(X.at(i)-1)=false;
    }
  }
  int count=0;
  for(int i=0;i<N;i++){
    if(A.at(i)){
      count++;
    }
  }
  cout << count << endl;
} 

Measured memory_bytes: 4500
#include <iostream>
#include <string>
#include <vector>
#define _GLIBCXX_DEBUG
using namespace std;

int main() {
    int N,M;
    cin >> N;
    vector<string> n(N);
    for(int i=0;i<N;i++) {
        cin >> n[i];
    }
    cin >> M;
    vector<string> m(M);
    for(int i=0;i<M;i++) {
        cin >> m[i];
    }

    int ans = 0;
    for(int i=0;i<N;i++) {
        int tmp = 0;
        for(int j=0;j<N;j++) {
            if(n[i] == n[j]) {
                tmp += 1;
            }
        }
        for(int k=0;k<M;k++) {
            if(n[i] == m[k]) {
                tmp -= 1;
            }
        }
        ans = max(ans,tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import math
ans = 0
n = list(map(int, input().split()))
n.sort()
if not (n[0] % 2 == n[2] % 2) or not(n[1] % 2 == n[2] % 2):
    ans += 1
    if (n[0] % 2) != (n[2] % 2):
        if (n[1] % 2) != (n[2] % 2):
            n[0] += 1
            n[1] += 1
        else:
            n[1] += 1
            n[2] += 1
    else:
        if (n[1] % 2) != (n[2] % 2):
            n[0] += 1
            n[2] += 1
for i in range(2):
    ans += int((n[2] - n[i]) / 2)
print(ans)

Measured memory_bytes: 3064
#include<iostream>


void insert(int a[],int n){
  int i,j,k,v;
  for(i=0;i<n;i++){
    v = a[i];
    j = i-1;
    while(j >= 0 && a[j] > v){
      a[j+1] = a[j];
      j--;
      a[j+1] = v;
    }
    for(k=0;k<n;k++){
      if(k == n-1){
	std::cout<<a[k];
      }else{
	std::cout<<a[k]<<" ";
      }
    }
    std::cout<<"\n";
  }
}

int main(){
  int i,n,a[10000];

  std::cin>>n;
  for(i=0;i<n;i++){
    std::cin>>a[i];
  }
  insert(a,n);
  return 0;
}


Measured memory_bytes: 3076
import java.util.Scanner;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int i;
		int a[]=new int[n];
		for(i=0;i<=n-1;i++){
			a[i]=sc.nextInt();
		}
		for(i=n-1;i>=0;i--){
			System.out.print(a[i]);
			if(i!=0){
				System.out.print(" ");
			}
		}
		System.out.println();
	}
}

Measured memory_bytes: 26184
import java.util.*;
  public class Main{
  	public static void main(String[]args){
    	Scanner s = new Scanner(System.in);
        int a = s.nextInt();
        int b = s.nextInt();
        int c = s.nextInt();
        int k = s.nextInt();
		
        if(a >= k){
          System.out.println(k);
        }else if(k <= a+b){
          System.out.println(a);
        }else {
          System.out.println(a-(k-a-b));
        }
    }
  }

Measured memory_bytes: 35756
import sys, math, itertools, collections, bisect 
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') 
inf = float('inf') ;mod = 10**9+7 
mans = inf ;ans = 0 ;count = 0 ;pro = 1

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

n = int(input())
for i in range(1, n+1):
    chk = len(make_divisors(i))
    if chk == 8 and i%2 == 1:
        ans += 1
print(ans)

Measured memory_bytes: 38640
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main {
    static MyReader in = new MyReader();

    public static void main(String[] args) {
        int x = in.i();
        int y = in.i();
        int ans = x <= y && (0 <= x || y <= 0) ? y - x : y < x && (x < 0 || 0 < y) ? 2 + x - y : 1 + Math.abs(x + y);
        out.println(ans);
    }
}

class MyReader extends BufferedReader {
    char[] cbuf = new char[1024];
    int head = 0;
    int tail = 0;

    MyReader() {
        super(new InputStreamReader(System.in));
    }

    char next() {
        if (head == tail) {
            try {
                tail = super.read(cbuf, 0, cbuf.length);
            } catch (IOException e) {
                e.printStackTrace();
            }
            head = 0;
        }
        return cbuf[head++];
    }

    void back() {
        head--;
    }

    boolean minus() {
        boolean minus;
        while (true) {
            char c = next();
            if (!isDelimiter(c)) {
                if (!(minus = c == '-')) back();
                return minus;
            }
        }
    }

    void skip() {
        while (isDelimiter(next()));
        back();
    }

    char[] s(int N) {
        char[] cbuf = new char[N];
        read(cbuf, 0, N);
        return cbuf;
    }

    public int read(char[] cbuf, int off, int len) {
        skip();
        int i;
        for (i = 0; i < cbuf.length; i++) {
            char c = next();
            if (isDelimiter(c)) {
                break;
            }
            cbuf[i] = c;
        }
        return i;
    }

    boolean isDelimiter(char c) {
        return c == ' ' || c == '\n' || c == '\r';
    }

    int i() {
        boolean minus = minus();
        int n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }

    int[] ii(final int N) {
        int[] a = new int[N];
        for (int j = 0; j < a.length; j++) a[j] = i();
        return a;
    }

    long l() {
        boolean minus = minus();
        long n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }
}


Measured memory_bytes: 32704
#include <iostream>
using namespace std;
int main(){
  int n, i, ct=1;
  cin >> n;
  int a[n];
  for(i=0; i<n; i++){
    cin >> a[i];
    if(a[i]==ct) ct++;
  }
  if(ct==1){
    cout << -1 << endl;
    return 0;
  }
  cout << n-ct+1 << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m,x;
	cin>>n>>m>>x;
	int a[12][12];
	vector<int> c(n);
	for(int i=0;i<n;i++)
	{
		cin>>c[i];
		for(int j=0;j<m;j++)
		cin>>a[i][j];
	}
	int ans=999999999;
	for(int s=0;s<(1<<n);s++)
	{
		int t=0;
		vector<int> d(m);
		for(int i=0;i<n;i++)
		{
			if(s>>i&1)
			{
				t+=c[i];
				for(int j=0;j<m;j++)
				d[j]+=a[i][j];
			}
		}
		bool o=true;
		for(int j=0;j<m;j++) if(d[j]<x) o = false;
    	if(o) ans = min(ans,t);
	}
	if(ans==999999999)
	cout<<"-1";
	else
	cout<<ans;
}

Measured memory_bytes: 3588
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

const vector<int> dx = {1, 1, 0, -1, -1, -1,  0,  1};
const vector<int> dy = {0, 1, 1,  1,  0, -1, -1, -1};

int main() {
	int h, w;
	cin >> h >> w;

	vector<string> s(h);
	for (int i = 0; i < h; i++) {
		cin >> s[i];
	}

	vector<string> check(h, string(w, '#'));
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {

			if (s[i][j] == '#') {
				continue;
			}

			check[i][j] = '0';

			for (int k = 0; k < dx.size(); k++) {
				int ni = i + dy[k];
				int nj = j + dx[k];
				if (0 <= ni && ni < h && 0 <= nj && nj < w && s[ni][nj] == '#') {
					check[i][j]++;
				}

			}
		}
	}

	for (auto sss : check) {
		cout << sss << endl;
	}
	return 0;
}


Measured memory_bytes: 256
N = int(input())
w = list([input() for i in range(N)])
cnt=0
for i in range(N-1):
	for j in range(i+1,N,1):
		if w[i]==w[j]:
			print('No')
			exit()
	if w[i][len(w[i])-1]==w[i+1][0]:
		cnt +=1
if cnt==N-1:
	print('Yes')
else:
	print('No')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
struct edge{int v,nxt;}e[maxn<<1];
int head[maxn],ecnt=0;
void add(int u,int v)
{
	e[++ecnt]=(edge){v,head[u]},head[u]=ecnt;
	e[++ecnt]=(edge){u,head[v]},head[v]=ecnt;
}
int fa[maxn],n;
bool vis[maxn];
bool ans=1;
void dfs(int u,int pre)
{
	fa[u]=pre;
	for(int i=head[u];~i;i=e[i].nxt)
	{
		int v=e[i].v;
		if(v==pre)continue;
		dfs(v,u);
	}
	if(u==1)
	{
		if(vis[u]==0)ans=0;
	}
	else 
	{
		if(!vis[u])
		{
			if(!vis[fa[u]])vis[fa[u]]=1,vis[u]=1;
			else ans=0;
		}	
	}
	
}
int main()
{
	memset(head,-1,sizeof(head));
	scanf("%d",&n);
	for(int i=1;i<n;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		add(u,v);
	}
	dfs(1,0);
	printf("%s\n",!ans?"First":"Second");
}

Measured memory_bytes: 2816
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

// CHECK THE LIMITS
typedef long long ll;

static const int NMAX = 1e5;

int gcd(int a, int b) {
  return b ? gcd(b, a%b) : a;
} 

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

    int n;
    cin >> n;
    vector<int> a(n+1);
    vector<int> b(n);
    
    for(int i = 0; i<=n; ++i)
    {
        cin >> a[i];
    }
    for(int i =0; i < n; ++i)
    {
        cin >> b[i];
    }
    ll ans = 0;
    for(int i = 0; i< n; ++i)
    {
        ans+= min(1LL*a[i]+a[i+1], 1LL*b[i]);
        if(b[i] - a[i] > 0)
        {
            b[i]-=a[i];
            a[i+1] = max(0, a[i+1]-b[i]);
        }
    }
    cout << 1LL *ans;

    return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>

using namespace std;

int main() {
	int n; cin >> n;
	long long ans = 1;
	bool bad = false;
	while (n--) {
		long long a; cin >> a;
		if (a == 0) {
			cout << "0\n";
			return 0;
		}
		if (ans > 1000000000000000000LL / a)
			bad = true;
		if (!bad)
			ans *= a;
	}
	cout << (!bad ? ans : -1) << '\n';
	return 0;
}


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

int main()
{
    char ch;

    vector<int> counter(26,0);
    while ( cin >> ch ){
        // c++ アルファベット　判定
        if(isalpha(ch)){
            int num = tolower(ch)-'a';
            counter.at(num)++;
        }
    }

    for(int i=0;i<26;i++){
        cout<<(char)('a'+i)<<" : "<<counter.at(i)<<endl;
    }
    return 0;
}  


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

using namespace std;

int main(void)
{
    int N, Q;
    cin >> N;
    vector<int> S(N);
    for (auto &i : S) cin >> i;
    cin >> Q;
    vector<int> T(Q);
    for (auto &i : T) cin >> i;
    sort(S.begin(), S.end());
    int ans = 0;
    int pre = -1;
    for (auto i : T) for (auto j : S)
    {
        if (pre == j) continue;
        if (i == j) ans++;
        pre = j;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3164
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define MAX 200005
#define INF 200005

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

int main(){
  int n, k, r, s, p, ans=0;
  string t;
  cin >> n >> k;
  cin >> r >> s >> p;
  cin >> t;
  vector<bool> suc(n);
  rep(i, n){
    if(i < k){
      if(t[i]=='r'){
        ans+=p;
      } else if(t[i]=='s'){
        ans+=r;
      } else {
        ans+=s;
      }
    } else {
      if(t[i]=='r'){
        if(t[i-k]=='r' && !suc[i-k]){
          suc[i]=true;
        } else {
          ans+=p;
        }
      } else if(t[i]=='s'){
        if(t[i-k]=='s' && !suc[i-k]){
          suc[i]=true;
        } else {
          ans+=r;
        }
      } else {
        if(t[i-k]=='p' && !suc[i-k]){
          suc[i]=true;
        } else {
          ans+=s;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
int main(){
  int a,b,c,d;
  scanf("%d%d%d",&a,&b,&c);
  if(a > b){
   d = a;
   a = b;
   b = d;
 } if(b > c){
   d = b;
   b = c;
   c = d;
 } if(a > b){
   d = a;
   a = b;
   b = d;
 }
 printf("%d %d %d\n",a,b,c);
    return 0;

}

Measured memory_bytes: 596
#include <stdio.h>
#define NUM 10

int main(void)
{
	int i,j,index,max=0,data[NUM];

	for(i=0; i<NUM; i++)
		scanf("%d",&data[i]);
	for(i=0; i<3; i++){
		for(j=0; j<NUM; j++)
			if(data[j]>max){
				max=data[j];
				index=j;
			}
		printf("%d\n",data[index]);
		data[index]=0;
		max=0;
	}

	return 0;
}

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

vector<int>adj[100003],leaf;
int par[100003],depth[100005],sparse[100005][20],root=0,lz=0;

int lca(int p,int q)
{

    int a,b,c,d,lp,i,j;

    if(depth[p]<depth[q])
    {
        c=p; p=q; q=c;
    }

    for(j=19;j>=0;j--)
    {
         if((depth[p]-(1 << j))>=depth[q])
         {
             p=sparse[p][j];  if(depth[p]==depth[q])break;
         }
    }

    if(p==q){ return p; }
    else
    {
         for(j=19;j>=0;j--)
         {
             if(sparse[p][j]!=0 && sparse[p][j]!=sparse[q][j])
             {

                 p=sparse[p][j]; q=sparse[q][j];

                 if(par[p]==par[q])break;
             }

         }

         return par[p];
    }



}

void dfs(int src)
{
    int sz=adj[src].size();

    if(sz==1 && src!=root){   leaf.push_back(src);  lz++;   }

    for(int lp=0;lp<sz;lp++)
    {
        int u=adj[src][lp];

        if(u!=root && par[u]==0)
        {
            par[u]=src; sparse[u][0]=src; depth[u]=depth[src]+1;
            dfs(u);

        }

    }

}

int main()
{

    int n,m,a,b,i,j,u,v,ans,z,x,y,fr,sc,tr,w;
    scanf("%d %d %d",&n,&u,&v);

    for(i=1;i<=n-1;i++)
    {
        scanf("%d %d",&a,&b);
        adj[a].push_back(b); if(root==0){  if(adj[a].size()==2)root=a;  }
        adj[b].push_back(a); if(root==0){  if(adj[b].size()==2)root=b;  }

    }

    if(n==2)printf("0\n");
    else
    {
       dfs(root);

       for(j=1;j<=19;j++)
       {
           for(i=1;i<=n;i++)
           {
               if(sparse[i][j-1]!=0)
               {
                   sparse[i][j]=sparse[sparse[i][j-1]][j-1];
               }
           }
       }

       m=lca(u,v);

       ans=(depth[v]-depth[m])+(depth[u]-depth[m]); ans=ans-1;

       for(i=0;i<lz;i++)
       {
           y=leaf[i]; m=lca(u,y); w=lca(v,y);

           fr=(depth[u]-depth[m])+(depth[y]-depth[m]);
           sc=(depth[v]-depth[w])+(depth[y]-depth[w]);

           if(fr<sc)
           {
               if(sc-1>ans)ans=sc-1;
           }

       }

       printf("%d\n",ans);


    }



    return 0;
}


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

typedef long long ll;
const int maxn=1e6+7;
const int inf=INT_MAX;
const ll inff=1e18;
const int mod=998244353;
#define pii pair<int,int>
#define mkp make_pair
#define F first
#define S second
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
//#define int ll

#ifdef HNO2
#define IOS
#else
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0);
#endif // HNO2

int dp[2][307][307];
vector<int> v;

inline int singlemod(int x)
{
    return x>=mod ? x-mod : x;
}

int32_t main()
{
    IOS
    string s;
    int n,K;
    cin>>s>>K;
    n=s.length();
    K=min(n,K);

    int summ=0;
    v.pb(0);
    for (int i=0;i<n;i++)
        if (s[i]=='0') v.pb(summ);
        else summ++;
    int _0=sz(v)-1;
    K=min(K,n-_0);

    dp[0][0][0]=1;

    for (int i=1;i<=_0;i++)
    {
        //clear
        memset(dp[i&1],0,sizeof(dp[i&1]));

        for (int j=0;j<=(n-_0)-v[i];j++)
            for (int k=0;k<=n-_0;k++)
        {
            for (int l=0;l<=j;l++) dp[i&1][j][k]=singlemod(dp[i&1][j][k]+dp[i&1^1][l][k]);
            for (int l=j+1;l<=min({j+(v[i]-v[i-1]),n-_0,k+j});l++)
                dp[i&1][j][k]=singlemod(dp[i&1][j][k]+dp[i&1^1][l][k-(l-j)]);
        }
    }
    //

    int ans=0;
    for (int i=0;i<=(n-_0);i++)
        for (int j=0;j<=K;j++)
            if (i+j<=K) ans=(ans+dp[_0&1][i][j])%mod;
    cout<<ans<<endl;
}




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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;


int main(){

    int x;
    cin >> x;
    if(x < 1200) cout << "ABC" << endl;
    else cout << "ARC" << endl;
    

    return 0;
}

Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n];
    int max1=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]>max1)max1=a[i];

        }

        int min1=INT_MAX;
    for(int i=1;i<=max1;i++)
    {
        int sum=0;
        for(int j=0;j<n;j++)
        {
            if(a[j]>=i){int y=pow((a[j]-i),2);sum+=y;}
            else{int z=pow((i-a[j]),2);sum+=z;}


        }

            if(sum<min1)min1=sum;
    }
    cout<<min1<<endl;
}


Measured memory_bytes: 256
def get_answer(input_list):
    so = input_list[0]
    t = input_list[1]

    s_len = len(so)

    t_i = [-1] * len(t)
    s = so + so
    s_index = 0
    for i in range(len(t)):
        index = s.find(t[i], s_index)
        if index < 0:
            break
        index = index % s_len
        t_i[i] = index
        s_index = index + 1
        s_index = s_index % s_len

    if -1 in t_i:
        return -1

    t_len = len(t_i)
    ret = 0
    ret_i = 0
    for i in range(t_len):
        t1 = t_i[i]
        ret = t1
        if i < t_len - 1:
            t2 = t_i[i + 1]
            if t1 >= t2:
                ret_i += 1

    return ret_i * s_len + ret + 1


if __name__ == "__main__":
    input_list = []
    while True:
        try:
            input1 = input()
            if not input1:
                break
            if len(input1) == 0:
                break
            input_list.append(input1)
        except EOFError:
            break
    print(get_answer(input_list))


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

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0);
  long long a,b;
  cin >> a >> b;
  if(((long long)a+b)%2 == 1) cout << "IMPOSSIBLE\n";
  else cout << (long long)(a+b)/2 << "\n";
  return 0;
}
  

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#ifdef rd
#define trace(...) cout<<"Line:"<<__LINE__<<" "; __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(...)
#define endl '\n'
#endif
#define pb push_back
#define fi first
#define se second
#define int long long
typedef long long ll;
typedef float f80;
#define double long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
const ll infl=0x3f3f3f3f3f3f3f3fLL;
const int infi=0x3f3f3f3f;
const int mod=998244353;
//const int mod=1000000007;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;
auto clk=clock();
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}
int powm(int a, int b) {
	int res=1;
	while(b) {
		if(b&1)
			res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}


void solve() {
	int s;
	cin>>s;
	int lob=sqrtl(s);
	while(lob*lob>s)
		lob--;
	while(lob*lob<s)
		lob++;
	int rem=s-lob*lob;
	if(s<=lob*(lob-1LL)) {
		rem=s-lob*(lob-1);
		cout<<"0 0 "<<lob<<" "<<-rem<<" "<<1<<" "<<lob-1<<endl;
	} else
		cout<<"0 0 "<<lob<<" "<<-rem<<" "<<1<<" "<<lob<<endl;
}

signed main() {
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	srand(chrono::high_resolution_clock::now().time_since_epoch().count());
	cout<<fixed<<setprecision(10);
	int t=1;
//	cin>>t;
	fr(i,1,t)
	{
		solve();
	}
#ifdef rd
	cout<<endl<<endl<<endl<<endl<<"Time elapsed: "<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
#endif
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MAX 100000
vector<int> p;
vector<bool> p_table(MAX+1,true);
void prime(){
  p_table.at(0)=false,p_table.at(1)=false;
  for(int i=2;i<=MAX;i++){
    if(p_table.at(i)){
      p.push_back(i);
      for(int j=2;i*j<=MAX;j++){
        p_table.at(i*j)=false;
      }
    }
  }
}

int main(){
  int Q;
  cin>>Q;
  vector<int> l(Q),r(Q);
  for(int i=0;i<Q;i++){
    cin>>l.at(i)>>r.at(i);
  }
  prime();
  vector<int> sum(MAX+1,0);
  for(int i=3;i<=MAX;i+=2){
    if(p_table.at(i)&&p_table.at((i+1)/2)){
      sum.at(i)+=1;
    }
    sum.at(i)+=sum.at(i-2);
    sum.at(i+1)=sum.at(i);
  }

  for(int i=0;i<Q;i++){
    cout<<sum.at(r.at(i))-sum.at(l.at(i)-1)<<endl;
  }

}


Measured memory_bytes: 1920
#include <cstdio>
#include <queue>
#define rep(i,n) REP(i,0,n)
#define REP(i,a,n) for(int i = a ; i < (int)n ; i++)

using namespace std;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int mp[200][200]={0};
int w,h;

void init_map(int w,int h){
    rep(i,200){
        rep(j,200){
            mp[i][j]=1;
        }
    }
    REP(i,1,2*h){
        REP(j,1,2*w){
            mp[i][j]=0;
        }
    }
}

int main(){
    while(1){
        scanf("%d %d",&w,&h);
        if(!w && !h){break;}
        init_map(w,h);
        int in;
        rep(i,2*h-1){
            if(!(i%2)){
                rep(j,w-1){
                    scanf("%d",&in);
                    rep(k,3){
                        mp[i+k][2*j+2]|=in;
                    }
                }
            }
            else{
                rep(j,w){
                    scanf("%d",&in);
                    rep(k,3){
                        mp[i+1][j*2+k]|=in;
                    }
                }
            }
        }
        queue< pair<int,pair<int,int> > > q;
        q.push(make_pair(1,make_pair(0,1)));
        mp[0][1]=2;
        int turn=0;
        bool reach=false;
        while(!q.empty()){
            pair<int,pair<int,int> > buf=q.front();
            q.pop();
            int x=buf.second.second;
            int y=buf.second.first;
            turn=buf.first;
            if(x==2*w-1 && y==2*h-1){reach=true;break;}
            rep(i,4){
                int xx=x+dx[i];
                int yy=y+dy[i];
                if(!(xx>=1 && xx<2*w && yy>=1 && yy<2*h)){continue;}
                if(!mp[yy][xx]){
                    mp[yy][xx]=2;
                    q.push(make_pair(turn+1,make_pair(yy,xx)));
                }
            }
        }
        if(reach){printf("%d\n",turn/2);}
        else{printf("%d\n",0);}
    }
    return 0;
}



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

struct Problem{
    UL N, M, K;
    static const ULL MOD = 998244353;
    static const UL X = 500000;
    ULL F[X+1];
    ULL I[X+1];
    ULL iF[X+1];

    ULL C(UL n, UL r) {
        return F[n] * iF[r] % MOD * iF[n - r] % MOD;
    }
    static ULL POW(ULL a, ULL i) {
        if (i == 0) return 1;
        if (i & 1) return POW(a * a % MOD, i >> 1) * a % MOD;
        return POW(a * a % MOD, i >> 1);
    }

    void Solve() {
        cin >> N >> M >> K;
        F[0] = 1; for (UL i = 1; i <= X; i++) F[i] = F[i - 1] * i % MOD;
        I[1] = 1; for (UL i = 2; i <= X; i++) I[i] = MOD - MOD / i * I[MOD % i] % MOD;
        iF[0] = 1; for (UL i = 1; i <= X; i++) iF[i] = iF[i - 1] * I[i] % MOD;
        ULL ans = 0;
        for (UL x = 0; x <= K; x++) {
            ULL Cs = N - x;
            ULL tmp = M * POW(M - 1, Cs - 1) % MOD;
            tmp = tmp * C(N - 1, Cs - 1) % MOD;
            ans += tmp;
        }
        ans %= MOD;
        cout << ans << endl;
    }
};
int main() {
    unique_ptr<Problem> p(new Problem());
    p->Solve();
    return 0;
}


Measured memory_bytes: 14684