akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e7+1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
typedef list <ll> lst;

ll n,m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

/*--------------------template--------------------*/

int main()
{
NEXT:
	while (1) {
		getline(cin, s);
		if (s.size() == 1 && s[0] == '.') {
			return 0;
		} else {
			stack<char> v;
			REP(i, s.size())
			{
				if (s[i] == '(') {
					v.push(s[i]);
				}

				if (s[i] == ')') {
					if (v.empty() || v.top() != '(') {
						cout << "no" << endl;
						while (!v.empty()) {
							v.pop();
						}
						goto NEXT;
					} else {
						v.pop();
					}
				}

				if (s[i] == '[') {
					v.push(s[i]);
				}

				if (s[i] == ']') {
					if (v.empty() || v.top() != '[') {
						cout << "no" << endl;
						while (!v.empty()) {
							v.pop();
						}
						goto NEXT;
					} else {
						v.pop();
					}
				}
			}

			if (v.empty()) {
				cout << "yes" << endl;
			} else {
				cout << "no" << endl;
			}

			while (!v.empty()) {
				v.pop();
			}
		}
	}
}

Measured memory_bytes: 3200
n = int(input())
v = list(map(int,input().split()))
l = list(range(n))
odd = [v[i] for i in l if i%2 == 0]
even = [v[i] for i in l if i%2 == 1]

import collections
oddm = collections.Counter(odd).most_common()
evenm = collections.Counter(even).most_common()

if oddm[0][0] != evenm[0][0]:
    a = (n/2)-oddm[0][1]+(n/2)-evenm[0][1]
else:
    if len(oddm) == 1 and len(evenm) == 1:
        a = n/2
    elif len(oddm) == 1:
        a = (n/2)-evenm[1][1]
    elif len(evenm) == 1:
        a = (n/2)-oddm[1][1]
    else:
        a = n-max(evenm[1][1]+oddm[0][1],evenm[0][1]+oddm[1][1])

print(int(a))


Measured memory_bytes: 24924
#include <iostream>

 

using namespace std;

 

int main() 
{
    int i, x;
    for(i=1; i<=10000; i++)
   {
       cin >> x;
            if(x == 0)
     break;
        cout << "Case" << " " <<  i << ":" << " " << x << endl;
        
    }
}



Measured memory_bytes: 3096
import java.io.*;
import java.util.*;

public class Main {
	private static final boolean local = false;
	private static BufferedReader br;
	private static StringTokenizer st;
	private static PrintWriter output;
	//char c = line.nextToken().charAt(0);

	private static void openFile() throws IOException {
		if (local) {
			String inp = "C:/Users/ztrong/Desktop/AndroidStudioProjects/Java/src/main/java/input.txt";
			String out = "C:/Users/ztrong/Desktop/AndroidStudioProjects/Java/src/main/java/output.txt";
			br = new BufferedReader(new InputStreamReader(new FileInputStream(inp)));
			output = new PrintWriter(new FileOutputStream(out));
		} else {
			br = new BufferedReader(new InputStreamReader(System.in));
			output = new PrintWriter(System.out);
		}
	}

	private static String _next() {
		while (st == null || !st.hasMoreElements()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return st.nextToken();
	}

	private static int nextInt() {
		return Integer.parseInt(_next());
	}

	private static long nextLong() {
		return Long.parseLong(_next());
	}

	private static double nextDouble() {
		return Double.parseDouble(_next());
	}

	private static String nextLine() {
		String str = "";
		try {
			str = br.readLine();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return str;
	}

	private static final int maxN = (int) 1e2 + 5;
	private static final int maxM = (int) 1e4 + 5;
	private static final int inf = (int) 1e9 + 7;

	private static int N, H, W;
	private static int[] a = new int[maxM];
	private static int[][] res = new int[maxN][maxN];

	private static void init() {

	}

	private static void enter() throws IOException {
		H = nextInt(); W = nextInt();
		N = nextInt();
		for (int i = 1; i <= N; ++i) {
			a[i] = nextInt();
		}
	}

	private static void solve() throws IOException {
		int tmp = 1;
		for (int i = 1; i <= H; ++i) {
			if (i % 2 == 1) {
				for (int j = 1; j <= W; ++j) {
					if (a[tmp] == 0) ++tmp;
					res[i][j] = tmp;
					--a[tmp];
				}
			}
			else {
				for (int j = W; j >= 1; --j) {
					if (a[tmp] == 0) ++tmp;
					res[i][j] = tmp;
					--a[tmp];
				}
			}
		}
		for (int i = 1; i <= H; ++i) {
			for (int j = 1; j <= W; ++j) {
				output.print(res[i][j] + " ");
			}
			output.println();
		}
	}

	public static void main(String[] args) throws IOException {
		openFile();
		init();
		enter();
		solve();
		output.close();
	}
}

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

using namespace std;

#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
#define vi vector<int>

#define ll long long int

int ctoi(char c) {return c-'0';}
int ord(char c) {return c-'a';}
int len(string s) {return s.length();}
int itoc(int i) {return i+'a';}

int main() {
int N;
cin>>N;
int c = 0;
for(int i=1;i<=N;i++) {
    if(fmod((floor(log10(i))+1),2)!=0) c++;
}
cout<<c<<endl;
return 0;
}


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

int main() {
    string s;
    cin >> s;
    if (s.at((int)s.size() - 1) == 's') {
        cout << s << "es" << endl;
    }
    else {
        cout << s << "s" << endl;
    }
}

Measured memory_bytes: 3624
#include <iostream>
 
using namespace std;
 
int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    int num=0;
    for(int i=0;i<=n-3;i++){
        if(s[i]=='A' &&s[i+1]=='B' &&s[i+2]=='C'){
            num++;
        }
    }
    cout<<num<<endl;
    
 
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define maxn 100005
#define ll long long
using namespace std;
ll read(){
	ll x=0,c;while(!isdigit(c=getchar()));
	while(x=x*10+c-'0',isdigit(c=getchar()));
	return x;	
}
int n,a[maxn];
int main(){
	n=read();int ans=0;
	for(int i=1;i<=n;i++)a[i]=read();
	for(int i=1;i<=n;i++){
		int j=i;
		while(j<n&&a[j+1]==a[i])j++;
		ans+=(j-i+1)>>1;
		i=j;
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int Ma = sc.nextInt();
		int Mb = sc.nextInt();
		int[] a = new int[N];
		int[] b = new int[N];
		int[] c = new int[N];
		for (int i = 0; i < N; ++i) {
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
			c[i] = sc.nextInt();
		}
		HashMap<Integer, Integer> map = new HashMap<>();
		int ans = Integer.MAX_VALUE / 3;
		for (int s = 1; s < 1 << (N / 2); ++s) {
			int ma = 0, mb = 0, cost = 0;
			for (int i = 0; i < N / 2; ++i) {
				if ((s & (1 << i)) > 0) {
					ma += a[i];
					mb += b[i];
					cost += c[i];
				}
			}
			int key = Ma * mb - Mb * ma;
			if (key == 0)
				ans = Math.min(ans, cost);
			if (map.containsKey(key)) {
				map.put(key, Math.min(map.get(key), cost));
			} else {
				map.put(key, cost);
			}
		}
		for (int s = 1; s < 1 << (N - N / 2); ++s) {
			int ma = 0, mb = 0, cost = 0;
			for (int i = 0; i < N - N / 2; ++i) {
				if ((s & (1 << i)) > 0) {
					ma += a[N / 2 + i];
					mb += b[N / 2 + i];
					cost += c[N / 2 + i];
				}
			}
			int key = -(Ma * mb - Mb * ma);
			if (key == 0)
				ans = Math.min(ans, cost);
			if (map.containsKey(key)) {
				ans = Math.min(ans, cost + map.get(key));
			}
		}
		System.out.println(ans >= Integer.MAX_VALUE / 4 ? -1 : ans);
	}
}

Measured memory_bytes: 48708
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=((ll)n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=((ll)a);i<((ll)n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    if(s=="ABC")puta("ARC");
    else puta("ABC");
    return 0;
}

Measured memory_bytes: 3640
// cpy frm Chris' sol
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
#define all(x) (x).begin(), (x).end()
 
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;
 
long long INF=numeric_limits<long long>::max();
 
ll a[200002];
multiset <ll>s;
 
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
    ll n,ans(0); cin >> n;
    for(ll i = 0; i < n; i++)
    {
        cin >> a[i];
        s.insert(a[i]);
    }
    sort(a,a+n);
    for(ll i = n; i >= 0; i--)
    {
        if(s.find(a[i])==s.end())continue;
        s.erase(s.find(a[i]));
        for(ll j = 31; j > 0; j--)
        {
            ll pow = (1LL << j);
            auto curr = s.find(pow - a[i]);
            if(curr!=s.end())
            {
                s.erase(curr);
                ans++;
                break;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 11264
def solve(n, a):
    D = {i: 0 for i in range(1, n+1)}
    for x in a:
        D[x] += 1
    for i in range(1, n+1):
        print(D[i])

n = int(input())
a = list(map(int, input().split()))
solve(n, a)

Measured memory_bytes: 38880
#include<iostream>
#include<vector>

using namespace std;

int main(){
        int n,m;
        cin>>n>>m;
        vector<int> k(m);

        vector<vector<int>> s(m);
        for(int i = 0;i < m; i++){
                cin>>k[i];
                for(int j = 0;j<k[i];j++){
                        int a;
                        cin>>a;
                        a--;
                        s[i].push_back(a);
                }
        }

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

        int ans = 0;
        for(int i = 0;i<1<<n;i++){
                bool flag = 1;
                for(int j = 0;j<m;j++){
                        int c = 0;
                        for(int t = 0;t<k[j];t++){
                                c ^= i>>s[j][t]&1;

                        }
                        if(c!=p[j]){
                                flag = 0;break;
                        }
                }
                if(flag)ans++;
        }

        cout<<ans;
}

Measured memory_bytes: 256
# define _CRT_SECURE_NO_WARNINGS 1
# define _USE_MATH_DEFINES
# include <iostream>
# include <numeric>
# include <string>
# include <bitset>
# include <vector>
# include <algorithm>
# include <cstdlib>
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <deque>
# include <iomanip>
# include <queue>
# include <sstream>
# include <unordered_set>
# include <unordered_map>
# include <climits>
# include <complex>
# include <cmath>
# include <list>
# include <functional>
# include <string>
# include <ctime>
# include <set>
# include <forward_list>
# include <map>
# include <stack>
using namespace std;
# define MP make_pair
# define INF ((int)(1<<25))
# define REP(i,n) for(int i=0;i<(int)n;i++)
# define FOR(i,n) REP(i,n)
# define FORI(i,k,n) for(int i=k;i<(int)n;i++)
# define TORAD 2.0*M_PI/360.0
# define INT(x) int x;cin>>x;
# define STRING(x) string x;cin>>x;
# define STR(x) STRING(x);
# define DOUBLE(x) double x;cin>>x;
# define DBL(x) DOUBLE(x); 
# define ALL(x) begin(x),end(x)
# define RALL(x) (x).rbegin(),(x).rend()
# define DEBUG(x) cout<<#x<<":"<<x<<endl
# define INIT(a) memset(a,-1,sizeof a)
# define CLR(a) memset(a,0,sizeof a)
# define EPS 1e-12
#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#endif
typedef long long lint;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<int> vi;
typedef vector<lint> vl;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
const int dx[4] = { 0,1,0,-1 }, dy[4] = { -1,0,1,0 };
//const int M = 1000000007;
template<class T> void debug(T a) { for ( auto i : a )cout << i << endl; }

int w[300][300] = {};
int pre[300];
int r(int p)
{
	if ( pre[p] == 2 )return 0;
	pre[p]++;
	FOR(i, 300)
	{
		if ( w[p][i] )
		{
			r(i);
		}
	}
}
int main()
{
	int N;
	cin >> N;
	FOR(i, N)
	{
		int u, d;
		string c;
		cin >> u >> c >> d;
		d += 100;
		if ( c[0] == 'l' )
		{
			w[d][u] = 1;
		}
		else
		{
			w[u][d] = 1;
		}
	}
	int ans = 0;
	FORI(i, 101, 200)
	{
		fill(begin(pre), end(pre), 0);
		r(i);
		if(pre[i]>=2)
		{
			ans = 1;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
#include <string>
#include <vector>
/* 変数i を n回繰り返すマクロ */
#define rep(i,n) for (int i = 0;i < (n);i++)
/* 配列の初期化 fill(array, 0); すべて0に初期化 */
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){std::fill( (T*)array, (T*)(array+N), val );}
using namespace std;

struct Ken{
    int x;
    int y;
    int c;
};


int main()
{
    int a,b,m;
    vector<int> rei;
    vector<int> renji;
    cin >> a >> b >> m;

    int rei_min = INT_MAX;
    rep(i,a){
        int in;
        cin >> in;
        if(rei_min > in) rei_min = in;
        rei.push_back(in);
    }

    int renji_min = INT_MAX;
    rep(i,b){
        int in;
        cin >> in;
        if(renji_min > in) renji_min = in;
        renji.push_back(in);
    }

    struct Ken biki[100000];
    rep(i,m){
        cin >> biki[i].x >> biki[i].y >> biki[i].c;
    }

    int use_min = INT_MAX;
    for(int i = 0;i < m;i++){
       int ans = rei[biki[i].x - 1] + renji[biki[i].y - 1] - biki[i].c;
       if(ans < use_min){
           use_min = ans;
       }
    }
    int no_min = renji_min + rei_min;
    if( no_min > use_min) cout << use_min << endl;
    else cout << no_min << endl;


    return 0;
}

Measured memory_bytes: 2296
import bisect
N,Q=map(int,input().split())
A=list(map(int,input().split()))
odd=[A[1]]
even=[A[0]]
Sum=[A[0],A[0]+A[1]]
for i in range(2,N):
    Sum.append(Sum[-1]+A[i])
    if i%2==0:
        even.append(even[-1]+A[i])
    elif i%2==1:
        odd.append(odd[-1]+A[i])
change=[]
data=[(0,N//2-1)]
R=N//2-1
L=0
for R in range(N//2,N-1):
    L=2*(R+1)-N
    change.append((A[L-1]+A[R])//2)
    data.append((L,R))
if N%2==1:
    Taka=even
    Aoki=odd
elif N%2==0:
    Taka=odd
    Aoki=even
for q in range(Q):
    x=int(input())
    idx=bisect.bisect_left(change,x)
    Range=data[idx]
    if Range[0]==0:
        print(Sum[-1]-Sum[Range[1]])
    else:
        print(Taka[(Range[0]-1)//2]+Sum[-1]-Sum[Range[1]])

Measured memory_bytes: 29456
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double PI=acos(-1);
 
int main(){
    ll h;
    cin >> h;

    ll ans = 0;
    ll d = 1;

    while(h > 0){
        h /= 2;
        ans += d;
        d *= 2;
    }
    
    cout << ans << endl;
   
    return 0;
    
}

Measured memory_bytes: 256
#include <stdio.h>

void trace(int A[], int N)
{
    int i;
    for (i = 0; i < N; i++)
    {
        if (i > 0)
            printf(" ");
        printf("%d", A[i]);
    }
    printf("\n");
}

int SelectionSort(int A[], int N)
{
    int sw = 0;
    for (int i = 0; i < N; i++)
    {
        int mini = i;
        for (int j = i; j < N; j++)
        {
            if (A[j] < A[mini])
            {
                mini = j;
            }
        }
        if (i != mini)
            sw++;
        int v = A[i];
        A[i] = A[mini];
        A[mini] = v;
    }
    return sw;
}
int main()
{
    int N, i, sw;
    int A[100];

    scanf("%d", &N);

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

    sw = SelectionSort(A, N);
    trace(A, N);
    printf("%d\n", sw);

    return 0;
}


Measured memory_bytes: 2148
def lcm(a, b):
    small = min(a, b)
    large = max(a, b)
    gcd = small
    while large % small != 0:
        tmp = small
        small = large % small
        large = tmp
        gcd = small

    return(a * b // gcd)


N, M = map(int, input().split())
S = input()
T = input()

lcm_nm = lcm(N, M)
s_base = lcm_nm // M
t_base = lcm_nm // N
i = 0
while s_base * i < N and t_base * i < M:
    if S[i * s_base] != T[i * t_base]:
        print(-1)
        exit()
    i += 1

print(lcm_nm)

Measured memory_bytes: 3316
H,W = map(int,input().split())
S = [list(input()) for _ in range(H)]

for h in range(H):
    for w in range(W):
        no = 0
        if S[h][w] == '.':
            if h != 0 and w != 0:
                if S[h-1][w-1] == '#':
                    no+=1
            if h != 0:
                if S[h-1][w] == '#':
                    no+=1
            if h != 0 and w != W-1:
                if S[h-1][w+1] == '#':
                    no+=1
            if h != H-1 and w != 0:
                if S[h+1][w-1] == '#':
                    no+=1
            if h != H-1:
                if S[h+1][w] == '#':
                    no+=1
            if w != 0:
                if S[h][w-1] == '#':
                    no+=1
            if w != W-1:
                if S[h][w+1] == '#':
                    no+=1
            if h != H-1 and w != W-1:
                if S[h+1][w+1] == '#':
                    no+=1
            S[h][w] = str(no)

for i in range(H):
    print("".join(S[i]))

Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		Dice dice = new Dice(sc.nextInt(),sc.nextInt(),sc.nextInt(),sc.nextInt(),sc.nextInt(),sc.nextInt());
		int count,up,front;
		count =sc.nextInt();
		for(int x= 0; x<count; x++) {
			up = sc.nextInt();
			front = sc.nextInt();
			String shijirow = "EEENEEENEEESEEESEEENEEEN";
			for(int i =0; i<shijirow.length(); i++) {
			    	if(dice.up==up&&dice.front==front) {
					System.out.println(dice.left);
					break;
				}
				dice.roll(shijirow.charAt(i));
			}
		}
	}
}

class Dice {
	int up =1;
	int front = 2;
	int left = 3;
	int right = 4;
	int back = 5;
	int down = 6;

	Dice(){};

	Dice(int up,int front,int left,int right, int back, int down){
		this.up = up;
		this.front = front;
		this.left =left;
		this.right = right;
		this.back = back;
		this.down = down;

	}


	void roll(char Shiji) {
		int  tmp;
		switch(Shiji) {
		case 'N':{
			tmp = up;
			this.up = this.front;
			this.front = this.down;
			this.down = this.back;
			this.back = tmp;
			break;
		}
		case 'E':{
			tmp = this.up;
			this.up = this.right;
			this.right = this.down;
			this.down = this.left;
			this.left = tmp;
			break;
		}
		case 'W':{
			tmp = this.up;
			this.up = this.left;
			this.left = this.down;
			this.down = this.right;
			this.right = tmp;
			break;
		}
		case 'S':{
			tmp = this.up;
			this.up = this.back;
			this.back = this.down;
			this.down = this.front;
			this.front = tmp;
			break;
		}
		}

	}

}



Measured memory_bytes: 26168
// Copyright (C) 2017 __debug.

// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; version 3

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program; If not, see <http://www.gnu.org/licenses/>.


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/priority_queue.hpp>

#define x first
#define y second
#define MP std::make_pair
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#ifdef __linux__
#define getchar getchar_unlocked
#define putchar putchar_unlocked
#endif

using std::pair;
using std::vector;
using std::string;

typedef long long LL;
typedef pair<int, int> Pii;

const int oo = 0x3f3f3f3f;

template<typename T> inline bool chkmax(T &a, T b) { return a < b ? a = b, true : false; }
template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, true : false; }
string procStatus()
{
    std::ifstream t("/proc/self/status");
    return string(std::istreambuf_iterator<char>(t), std::istreambuf_iterator<char>());
}
template<typename T> T read(T &x)
{
    int f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar())
        f = (ch == '-' ? -1 : 1);
    for (x = 0; isdigit(ch); ch = getchar())
        x = 10 * x + ch - '0';
    return x *= f;
}
template<typename T> void write(T x)
{
    if (x == 0) {
        putchar('0');
        return;
    }
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    static char s[20];
    int top = 0;
    for (; x; x /= 10)
        s[++top] = x % 10 + '0';
    while (top)
        putchar(s[top--]);
}
// EOT

const int MAXN = 205;
const int MOD = 998244353;

int N;
Pii A[MAXN];

inline Pii operator- (const Pii &a, const Pii &b)
{
    return MP(a.x - b.x, a.y - b.y);
}

inline int cross(const Pii &a, const Pii &b)
{
    return a.x * b.y - a.y * b.x;
}

void input()
{
    read(N);
    for (int i = 1; i <= N; ++i) {
        read(A[i].x); read(A[i].y);
    }
}

void solve()
{
    static LL pow2[MAXN];

    pow2[0] = 1;
    for (int i = 1; i <= N; ++i) {
        pow2[i] = pow2[i - 1] * 2 % MOD;
    }

    LL ans = (pow2[N] - 1 - N) % MOD;
    for (int i = 1; i <= N; ++i) {
        for (int j = i + 1; j <= N; ++j) {
            int cnt = 0;
            for (int k = j + 1; k <= N; ++k) {
                cnt += !cross(A[k] - A[j], A[i] - A[j]);
            }
            (ans -= pow2[cnt]) %= MOD;
        }
    }
    (ans += MOD) %= MOD;

    printf("%lld\n", ans);
}

int main()
{
#ifdef __DEBUG
    freopen("E.in", "r", stdin);
    freopen("E.out", "w", stdout);
#endif

    input();
    solve();

    return 0;
}

// 软件设计有两种方式：一种是设计得极为简洁，没有看得到的缺陷；
// 另一种是设计得极为复杂，有缺陷也看不出来。第一种方式的难度要大得多。
//     -- The Emperor's Old Clothes, CACM February 1981


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



int main() {
    int x,y,z;
    cin >> x >>y >>z;
    int ans = (x-z)/(y+z);
    cout << ans << endl;
}


Measured memory_bytes: 256
arr = input().split()
stack = []

for c in arr: 
  if c is "+":
    a = stack.pop()
    b = stack.pop()
    stack.append(a + b)
  elif c is "-":
    a = stack.pop()
    b = stack.pop()
    stack.append(b - a)
  elif c is "*":
    a = stack.pop()
    b = stack.pop()
    stack.append(a * b)
  else:
    stack.append(int(c)) 

print(stack.pop())


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

int main(){
    int a;
    string s;
    cin >> a;
    cin >> s;
    if(a>=3200){
        cout << s << endl;
    }else{
        cout << "red" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a=scan.nextInt();
		int ans=0;
		int b=scan.nextInt();
		int c=scan.nextInt();
		for(int i=0;i!=a;i++) {
			int d=scan.nextInt();
			int e=scan.nextInt();
			if(d>=b&&e>=c)ans++;
		}
		System.out.println(ans);
    }
}

Measured memory_bytes: 25556
#include <iostream>
#include <cstring>
#include <vector>
#include <map>
typedef long long ll;
using namespace std;

map<ll,char> tes;
bool ok = true;
ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b,a % b);
}

int main() {
  ll n,m;
  cin >> n >> m;
  string s, t;
  cin >> s >> t;
  
  ll tmp = n * m / gcd(n,m);

  for(ll i = 0; i < n; i++) {
    tes[i * (tmp / n)] = s[i];
  }
  for(ll i = 0; i < m; i++) {
    if(tes.find(i * (tmp / m)) == tes.end()) continue;
    if(tes[i * (tmp / m)] != t[i]) ok = false;
  }

  if(ok) cout << tmp << endl;
  else cout << -1 << endl;
}


Measured memory_bytes: 6144
//package solution;

import java.io.*;
import java.util.*;
import java.math.*;
import java.awt.Point;

public final class Main {
    BufferedReader br;
    StringTokenizer stk;

    public static void main(String[] args) throws Exception {
        new Main().run();
    }
    
    {
        stk = null;
        br = new BufferedReader(new InputStreamReader(System.in));
    }
    
    void run() throws Exception {
        char[] c = nt().toCharArray();
        if(c[0] == c[1] && c[1] == c[2]) {
            pl("No");
        } else {
            pl("Yes");
        }
    }
    
    //Reader & Writer
    String nextToken() throws Exception {
        if (stk == null || !stk.hasMoreTokens()) {
            stk = new StringTokenizer(br.readLine(), " ");
        }
        return stk.nextToken();
    }

    String nt() throws Exception {
        return nextToken();
    }

    String ns() throws Exception {
        return br.readLine();
    }

    int ni() throws Exception {
        return Integer.parseInt(nextToken());
    }

    long nl() throws Exception {
        return Long.parseLong(nextToken());
    }

    double nd() throws Exception {
        return Double.parseDouble(nextToken());
    }

    void p(Object o) {
        System.out.print(o);
    }

    void pl(Object o) {
        System.out.println(o);
    }
    
    void selector() {
        Random rd = new Random();
        String[] s = new String[] {"Strings", "Sorting", "Search"
                , "Graph theory", "Greedy", "Dynamic programming"
                , "Constructive algos", "Bit manipulation", "Recursion"};
        pl(s[rd.nextInt(s.length)] + " " + (rd.nextInt(5)+1));
    }
}

Measured memory_bytes: 21204
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
using namespace std;

#define INF (1ll<<60)


long long M = 1000000007;


int main(int argc, char const *argv[]) {
    int n;cin>>n;
    vector<long long> a(n);
    for(int i=0;i<n;++i)cin>>a[i];
    long long l=2,r=2;
    for(int i=n-1;i>-1;--i){
        long long ll = l/a[i] + (l%a[i]!=0),rr = r/a[i];
        if(ll>rr){
            cout<<-1<<endl;
            return 0;
        }
        l = ll*a[i];
        r = rr*a[i] + a[i] - 1;
    }
    cout<<l<<" "<<r<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include <cmath>
#include<vector>
#include <algorithm>
#include <map>

using namespace std;
#define pb push_back
#define mp make_pair


int main()
{
    int n;
    cin>>n;
        for( int i = 0;i<=100;i++ ){
            if( 4*i  > n ) break;
            int raz = n-4*i;
            if( raz%7==0 ) {
                cout<<"Yes"<<endl;
                return 0;
            }
        }
        cout<<"No"<<endl;

}

























Measured memory_bytes: 256
/*
ID: seekho
PROG: friday
LANG: C++14                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

//find_by_order gives kth-largest element
//order_of_key gives the number of items in the set that are strictly smaller!!

// OT.find_by_order(k-1)
// 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define db4(x, y, z, w) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << "," << #w << "=" << w << endl
#define ll long long
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define X first
#define Y second
#define sz(x) (int)((x).size())
#define pii pair<int,int>
#define MOD (ll)(1e9 + 7)
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
typedef vector<int> vi;
#define inf (ll)(1e18)
#define double long double
#define int long long

//////////////////////
const int N = 3005;
int n;
vector<int> arr(N);
int memo[N][N][2];
vector<int> fa;
vector<int> fb;

int go(int st, int end, int ch, int ta, int tb) {
	if(end < st) {
		return 0;
	}

	int &ans = memo[st][end][ch];
	if(ans != -inf)
		return ans;
	ans = 0;

	if(!ch) {
		// ans = -inf;
		// ans = max(go(st + 1, end, !ch, ta + arr[st], tb), go(st, end - 1, !ch, ta + arr[end], tb));
		ans = go(st, end - 1, !ch, ta, tb) + arr[end];
		// db(sz(fa));
		// fa.pb(arr[end]);
		if(ans < go(st + 1, end, !ch, ta, tb) + arr[st]) {
			ans = go(st + 1, end, !ch, ta, tb) + arr[st];
			// fa.pop_back();
			// db(sz(fa));
			// fa.pb(arr[st]);
		}
		// else {
		// 	ans = go(st, end - 1, !ch, ta + arr[end], tb);
		// 	fa.pb(arr[end]);
		// }

	}
	else {
		// ans = inf;
		// ans = min(go(st + 1, end, !ch, ta, tb + arr[st]), go(st, end - 1, !ch, ta, tb + arr[end]));
		ans = go(st, end - 1, !ch, ta, tb) - arr[end];
		// fb.pb(arr[end]);
		if(ans > go(st + 1, end, !ch, ta, tb) - arr[st]) {
			ans = go(st + 1, end, !ch, ta, tb) - arr[st];
			// fb.pop_back();
			// fb.pb(arr[st]);
		}
		// else {
		// }

	}
	// db4(st,end,ch,ans);
	// // db2(ta,tb);
	return ans;
}

int32_t main() {

    ios::sync_with_stdio(false);
    cin.tie(0); 
    cout.tie(0);
    // cout.precision(12);cout << fixed;

    cin >> n;
    rep(i,n)
    	cin >> arr[i];

    rep(i,n) {
    	rep(j,n) 
    		memo[i][j][0] = memo[i][j][1] = -inf;
    }

    cout << go(0,n-1,0,0,0) << '\n';
}

Measured memory_bytes: 141440
#include <bits/stdc++.h>
//#include <atcoder/all>
#define rep(i, n) for (int i = 0; i < (n); ++i)
//using namespace atcoder;
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))   //最大値を求める
#define MIN(x) *min_element(ALL(x))   //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define inf 2147483647    //int値の最大値
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back                            //vectorヘの挿入
#define MP make_pair                            //pairのコンストラクタ
#define F first                                 //pairの一つ目の要素
#define S second                                //pairの二つ目の要素
#define CST(x) cout << fixed << setprecision(x) //小数点以下の桁数指定
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;        
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
int gcd(int a, int b)
{
    if (b == 0)
        return a;
    else
        return gcd(b, a % b);
}
int lcm(int a, int b)
{
    return a * b / gcd(a, b);
}
int sumDight(int x){
    int sum = 0;
    while (x >0) {
        sum += (x %10);
        x /= 10;
    }
    return sum;
}

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

    int n,a,b;
    vector<ll> l;
    int sum = 0;
    cin >> n >> a >> b;
    for (int i = 1; i <= n;i++){
        l.push_back(sumDight(i));
    }
    for (int j = 0; j < n; j++){
        //cout << l[j] << endl;
        if (l[j] >= a && l[j] <= b) {sum += j+1;
            //cout << j << endl;
        }
    }
    cout << sum << endl;
}


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

typedef long long ll;

struct dsu {
	dsu* parent = this;
	int rank = 0;

	dsu* head(){
		if(parent != parent->parent){
			parent = parent->head();
		}

		return parent;
	}
	void merge(dsu* sec){
		dsu* fir = head();
		sec = sec->head();

		if(fir == sec){
			return;
		}

		if(fir->rank < sec->rank){
			fir->parent = sec;
		} else if(fir->rank > sec->rank){
			sec->parent = fir;
		} else {
			sec->parent = fir;
			fir->rank++;
		}
	}
};

const int maxn = 1e5 + 1e2;
int p[maxn];
dsu node[maxn];

int main(){
	std::ios::sync_with_stdio(false);

	int n, edges;

	std::cin >> n >> edges;

	for(int i = 0; i < n; i++){
		std::cin >> p[i];
		p[i]--;
	}
	for(int i = 0; i < edges; i++){
		int a, b;
		std::cin >> a >> b;
		a--, b--;

		node[a].merge(&node[b]);
	}

	int res = 0;
	for(int i = 0; i < n; i++){
		if(node[i].head() == node[p[i]].head()){
			res++;
		}
	}

	std::cout << res << '\n';
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
using ll = long long;
const int INF = 1e9;
double temp_start = 100.0;
double temp_end = 0.001; 
int climb_loop = 300000;
double temp;

int main(){
  int seed = 12345;
  mt19937 eng(seed);
  uniform_real_distribution<> uniform_01;

  // input
  int D;
  cin >> D;
  int c[26];
  rep(i,26) cin >> c[i];
  int s[D+1][26];
  rep(i,D) rep(j,26) cin >> s[i+1][j];
  
  // define parameter
  int last[D+1][26];
  int t[D+1];
  rep(i,D+1) rep(j,26) last[i][j] = 0;
  
  // calculate initial content climbing
  int content = 0;
  for(int day = 1; day <= D; day++) {
    int content_after = -INF;
    int best_kind = 0;
    rep(kind,26) {
      int res = content + s[day][kind];
      rep(j,26) {
        if(j == kind) last[day][j] = day;
        else last[day][j] = last[day-1][j];
        res -= c[j] * (day - last[day][j]);
      }
      if(res > content_after) {
        best_kind = kind;
        content_after = res;
      }
    }
    t[day] = best_kind;
    content = content_after;
    rep(j,26) {
      if(j == t[day]) last[day][j] = day;
      else last[day][j] = last[day-1][j];
    }
  }

  for(int day = 1; day <= D; day++) cout << t[day]+1 << endl;
   
  // simulated annealing
  rep(x,climb_loop) {
    int d = eng() % D + 1;
    int q = eng() % 26;
    int diff = s[d][q] - s[d][t[d]];
    int cur = d;
    while(cur <= D && last[cur][t[d]] == d) {
      diff -= c[t[d]] * (d - last[cur-1][t[d]]);
      last[cur][t[d]] = last[cur-1][t[d]];
      cur++;
    }
    cur = d;
    while(cur <= D && last[cur][q] < d) {
      diff += c[q] * (d - last[cur][d]);
      last[cur][q] = d;
      cur++;
    }
    if(uniform_01(eng) < exp((double)diff/temp)) {
      t[d] = q;
      content += diff;
    } else {
      int day = d;
      while(day <= D && last[day][t[d]] < d) {
        last[day][t[d]] = d;
        day++;
      }
      day = d;
      while(day <= D && last[day][q] == d) {
        last[day][q] = last[day-1][q];
        day++;
      }
    }
  }
  // output
  return 0;
}


Measured memory_bytes: 3816
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n;
    cin >> n;

    vector<int> v(n);
    for(int i; i < n; i++){
        cin >> v.at(i);
    }

    int cnt = 0;
    bool even = true;
    while(true){

        for(int i = 0; i < n; i++){
            if(v.at(i) % 2 != 0){
                even = false;
            }
          	v.at(i) = v.at(i) / 2;
        }

        if(even == true){
            cnt++;
        }else{
            break;
        } 
    }
    
    cout << cnt << endl;
}
 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)

using namespace std;

namespace mp = boost::multiprecision;

using ll = long long;
using Bint = mp::cpp_int;
ll mod = pow(10, 9) + 7;

int main() {
    // source
    ll x, y;
    cin >> x >> y;
    ll ans = 0;

    ll number = x;
    while (number <= y) {
        ans++;
        number *= 2;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
namespace mp = boost::multiprecision;
// mp::cpp_int
// mp::cpp_dec_float_100



int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
  
  string s;
  ll x;
  cin >> x;
  
  ll ans = 0;
  ll cnt = 100;
  while(cnt < x) {
    cnt = cnt*1.01;
    ans++;
  }  
  cout << ans << "\n";
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define ll long long int
#include<list>
#include<algorithm>
#define ld long double
#define pb push_back
#define FF first
#define SS second
#define rep(a,b,c) for(a=b;a<c;a++)
#define repr(a,b,c) for(a=b-1;a>=c;a--)
#define PLL pair<ll, ll>
#define inf 100000001
#define mod 1000000007
#define LB lower_bound
#define UB upper_bound
#define MP make_pair
#define PQ priority_queue
#define rep1 for(i=1;i<=n;i++)
#define VLL vector<ll>
#define EF else if
const double pi  =3.141592653589793238463;
#define all(x) (x).begin(), (x).end()
#define SORT(A) sort(A.begin(), A.end());
#define REVERSE(A) reverse(A.begin(), A.end());
#define UMP unordered_map
#define MAX LLONG_MAX
#define MIN LLONG_MIN
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
/*
    //string with spaces
    std::string str;
    std::getline(std::cin >> std::ws, str);
*/
ll myXOR(unsigned long long int x, unsigned long long int y)
{
    return (x|y)&(~x|~y);   
}
ll powerLL(ll x, ll n) 
{ 
    ll result = 1; 
    while (n) { 
        if (n & 1) 
            result = result * x % mod; 
        n = n / 2; 
        x = x * x % mod; 
    }
    return result; 
}
int main()
{
    fastio
    ll a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r, t,u,w,x,y,z;
    string str, ss, str1;
    long double one, two;
    cin>>one>>two;
    // cout<<one<<" "<<two<<endl;
    long double res = one*two;
    // cout<<(double)res<<endl;
    ll ans = trunc(res);
    cout<<ans;
}

Measured memory_bytes: 3784
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0; i<(int)(n); i++)
int main(){
int K, ans=-1, n=7; cin >> K; 
n=n%K;
REP(i, K){ 
  if(n==0){ ans=i+1; break; }
  n=(10*n+7)%K;
}
cout << ans << "\n";
}

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

int main(){
    int n,ans=-1;
    cin >> n;
    vector<ll> a(n),b(n),r(n);
    ll shortage = 0,cnt=0;
    for(int i = 0;i < n;i ++){
        cin >> a[i];
    }
    for(int i = 0;i < n;i ++){
        cin >> b[i];
        if(b[i]-a[i]>0){cnt ++;shortage += b[i]-a[i];}
        r[i] = max(0ll,a[i]-b[i]);
    }
    sort(r.begin(),r.end());
    reverse(r.begin(),r.end());
    if(shortage==0) ans=0;
    for(int i = 0;i < n && r[i] && shortage>0;i ++){
        shortage -= r[i];
        if(shortage<=0) ans = i+1+cnt;
    }
    cout << ans << endl;
    return 0;
}

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

long read_long() {
	long ret=0,t=1;char c=getchar();
	while(c<'0' ||c>'9') {
		if(c=='-') t=-1;
		c=getchar();
	}	while(c>='0' && c<='9') {
		ret=ret*10+c-'0';
		c=getchar();
	}		return ret*t;
}


int main() {
	long n;
	cin>>n;
	char c[70];
	register long i;
	for(i=1;i<=n;++i) {
		c[i]=getchar();
		while(c[i]<'A'|| c[i]>'Z')
			c[i]=getchar();
	}
	
	long ans=0;
	for(i=3;i<=n;++i) {
		if(c[i-2]=='A' && c[i-1]=='B' && c[i]=='C')
			++ans;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	long long a,b,c,n;
	scanf("%lld %lld %lld %lld",&a,&b,&c,&n);
	if(n>a){
		n-=a;
		if(n>b){
			n-=b;
			if(n>0)printf("%lld",a-n);
		}
		else{
			printf("%lld",a);
		}
	}
	else{
		printf("%lld",n);
	}
	return 0;
}

Measured memory_bytes: 1692
#include <iostream>
#include <bits/stdc++.h>
#include <string.h>
#include <cstdlib>
#include <vector>
using namespace std;

int main(){
	int a,b;
	cin>>a>>b;
	if( a<10 && b<10){
		cout<<(a*b);
	}
	else{
		cout<<"-1";
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<time.h>
#include<climits>
#include<string>
//#define IONAME "cttf"
//#define E_DEBUG
//#define TIMECOMP

int n;
std::string s,t;
std::string dp[2][3123];
void marota(){
    std::cin>>s>>t;  
    s=" "+s;
    t=" "+t;
    int n=s.length(),m=t.length();
    int io=0;
    for (int i=1;i<n;i++){
        io=1-io;
        for (int j=1;j<m;j++){
            if (s[i]==t[j]){
                dp[io][j]=dp[1-io][j-1]+s[i];
            }
            else {
                if (dp[io][j-1].length()>dp[1-io][j].length()){
                    dp[io][j]=dp[io][j-1];
                }
                else dp[io][j]=dp[1-io][j];
            }
        }
    }
    std::cout<<dp[io][m-1];
}

int main(){
    #ifdef TIMECOMP
    clock_t tStart = clock();
    #endif
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(0);
    std::cout.tie(0);
    #if defined(IONAME)
    freopen(IONAME".INP","r",stdin);
    freopen(IONAME".OUT","w",stdout);
    #endif
    marota();
    #ifdef TIMECOMP
    printf("Time taken: %.2fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
    #endif
    return 0;
}

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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

template<typename T1,typename T2>ostream& operator<<(ostream& os,const pair<T1,T2>& a) {os << "(" << a.first << ", " << a.second << ")";return os;}

const char newl = '\n';

vector<int> zAlgorithm(string s) {
    int n = s.size();
    vector<int> ret(n,0);
    ret[0] = n;
    int i = 1,j = 0;
    while (i < n) {
        while (i+j < n && s[j] == s[i+j]) ++j;
        ret[i] = j;
        if (j == 0) {
            ++i;
            continue;
        }
        int k = 1;
        while (i+k < n && k+ret[k] < j) {
            ret[i+k] = ret[k];
            ++k;
        }
        i += k;
        j -= k;
    }
    return ret;
}

int main() {
    string s,t;
    cin >> s >> t;
    int n = s.size(),m = t.size();
    for (int i = 0;i < (m+n-1)/n+1;++i) t += s;
    vector<int> a = zAlgorithm(t);
    vector<bool> b(n,false),used(n,false);
    for (int i = 0;i < n;++i) if (a[m+i] >= m) b[i] = true;
    int ans = 0;
    for (int i = 0;i < n;++i) if (b[i] && !used[i]) {
        if (b[((i-m)%n+n)%n]) continue;
        int cnt = 0,j = i;
        while (b[j]) {
            cnt++;
            used[j] = true;
            (j += m) %= n;
            ans = max(ans,cnt);
        }
    }
    for (int i = 0;i < n;++i) if (b[i] && !used[i]) ans = -1;
    cout << ans << endl;
}

Measured memory_bytes: 12616
#include <stdio.h>
 
int main() {
  int height, width;

  while(1){
    scanf("%d %d",&height,&width);
    if(height == 0 && width == 0) break;

    for(int i=1; i<=height; i++) {
      for(int j=1; j<=width; j++) { 
        if (i%2==0) {
          if (j%2==0) printf("#");
          else printf(".");
        }
        else {
          if (j%2==1) printf("#");
          else printf(".");
        }
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}


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

int main() {
    int n, m, c;
    cin >> n >> m >> c;

    int b[m];
    rep(i, m) cin >> b[i];

    int cnt = 0;
    rep(i, n) {
        int total = c;
        rep(j, m) {
            int a;
            cin >> a;
            total += a * b[j];
        }
        if (total > 0) cnt++;
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
import sys

def solve():
    input = sys.stdin.readline
    S = input().strip("\n")
    turn = 0
    current = S[0]
    for i in range(1, len(S)):
        if S[i] != current:
            turn += 1
            current = S[i]
    print(turn)

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
// #define fore(i, b, e) for (int i = (int)(b); i <= (int)(e); ++i)
// #define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long i64;
typedef unsigned long long u64;
typedef long double ld;
typedef long long ll;

const int maxn = 100500;

int n, k;
vi e[maxn];
int res;
int h[maxn];
int p[maxn];

void scan() {
    scanf("%d%d", &n, &k);
    forn(i, n) scanf("%d", &p[i]), --p[i];
}

int dfs1(int v) {
    int d = 0;
    for (int to: e[v]) {
        int t = dfs1(to);
        d = max(d, t + 1);
    }
    if (v != 0 && p[v] != 0 && d >= k-1) {
        ++res;
        return -1;
    } else {
        return d;
    }
}

void solve() {
    if (p[0] != 0) {
        p[0] = 0;
        ++res;
    }

    forn(i, n) if (i) {
        e[p[i]].pb(i);
    }

    dfs1(0);

    cout << res << endl;
}

int main() {
#ifdef LOCAL
    freopen("d.in", "r", stdin);
#endif

    scan();
    solve();

#ifdef LOCAL
    cerr << "Time elapsed: " << clock() / 1000 << " ms" << endl;
#endif
    return 0;
}


Measured memory_bytes: 10752
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m; i<n; i++)
#define co(n) cout << n << endl
using namespace std;
int main(){
  string s;
  int c=0;
  cin >> s;
  if(s.size()%2==0){
    rep(i,0,s.size()/2){
      if(s.at(i)!=s.at(s.size()-1-i)) c++;
    }
  }
  else{
    rep(i,0,s.size()/2){
      if(s.at(i)!=s.at(s.size()-1-i)) c++;
    }
  }
  co(c);
  
  return 0;
}

Measured memory_bytes: 256