akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;

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

	int n;
	cin >> n;
	vi a(n);
	rep(i, n)cin >> a[i];

	int cnt = 0;
	rep(i, n) {
		if (a[i] == i+1) {
			if (i == 0 || a[i + 1] != i + 1) {
				swap(a[i], a[i + 1]);
				cnt++;
			}
			else {
				swap(a[i], a[i - 1]);
				cnt++;
			}
		}
	}

	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 768
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string aaa = "abcdefghijklmnopqrstuvwxyz";
		string s = Console.ReadLine();
		string ans = "a";
		if(aaa.IndexOf(s)==-1){
			ans = "A";
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 18128
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
int main()
{
    string S;
    cin >> S;
    int first=S.size()-1, last = 0;
    rep(i, S.size()){
        if(S[i] == 'A') first = min(i, first);
        if(S[S.size()-1-i] == 'Z') last = max(last, (int)S.size()-1-i);
    }
    cout << last - first + 1 << endl;

    return 0;
}

Measured memory_bytes: 3700
#include <iostream>
#include <math.h>
using namespace std;
#define ll long long

int main() {
	int N, l, r, count = 0;
	cin >> N;
	
	string s;
	cin >> s;
	
	l = 0, r = N-1;
	while(l < r){
		while(l < r & s[l] == 'R')
			l++;
			
		while(l < r & s[r] == 'W')
			r--;
			
		if(l < r){
			swap(s[l], s[r]);
			l++, r--;
			count++;
		}
	}
	
	cout << count;
	
	return 0;
}

Measured memory_bytes: 3708
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

N,K=get_i
S=get_nsp
cnt=0
(N-1).times do|i|
  cnt+=1 if S[i]!=S[i+1] 
end
puts N-1-max(cnt-2*K,0)

Measured memory_bytes: 19196
import sys
from collections import deque
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n = ni()
if n == 25:
    print("Christmas")
elif n == 24:
    print("Christmas Eve")
elif n == 23:
    print("Christmas Eve Eve")
elif n == 22:
    print("Christmas Eve Eve Eve")

Measured memory_bytes: 3316
S = input().strip()
INFTY=10**8
dp = [[INFTY for _ in range(2)] for _ in range(len(S))]
for k in range(10):
    n = int(S[-1])
    if k>= n:
        dp[0][0] = min(dp[0][0],2*k-n)
    else:
        dp[0][1] = min(dp[0][1],2*k-n+10)
for i in range(1,len(S)):
    n = int(S[-(1+i)])
    for k in range(10):
        if k>n:
            dp[i][0] = min(dp[i][0],2*k-n+dp[i-1][0],k+(k-1)-n+dp[i-1][1])
        elif k==n:
            dp[i][0] = min(dp[i][0],2*k-n+dp[i-1][0])
            if n==0:
                dp[i][1] = min(dp[i][1],k+(k-1)%10-n+dp[i-1][1])
            else:
                dp[i][1] = min(dp[i][1],k+10-n+k-1+dp[i-1][1])
        elif k<n:
            dp[i][1] = min(dp[i][1],k+10-n+k+dp[i-1][0],k+10-n+k-1+dp[i-1][1])
print(min(dp[len(S)-1][0],dp[len(S)-1][1]+1))

Measured memory_bytes: 159024
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 1000000007
const int MOD = 1000000007;
//accumulate(vec.begin(), vec.end(), 0)
//std::sort(v.begin(), v.end(), std::greater<Type>());
//set_intersection(x, x+7, y, y+6, back_inserter(v));
//set_union(x, x+7, y, y+6, back_inserter(v));
//set_difference(x, x+7, y, y+6, back_inserter(v));

int gcd(int x,int y){
  if(x%y==0) return y;
  else return gcd(y,x%y);
}

bool isPrime(int n){
  if(n < 2) return false;
  else if(n == 2) return true;
  else if(n%2==0) return false;

  for(int i=3;i<=sqrt(n);i++){
    if(n%i==0) return false;
  }
  return true;
}

int main(){
  string s,t;
  cin >> s >> t;
  s += s;
  for(int i=0;i<=s.size();i++){
    if(s.substr(i,t.size())==t){
      cout<< "Yes" <<endl;
      return 0;
    }
  }
  cout<< "No" <<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;++i)
typedef long long ll;
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 main(){
   int n;
   cin >> n;
   vector<int> v(n);
   rep(i,n) cin >> v[i];
   sort(v.begin(),v.end());
   double ans=v[0];
   rep(i,n-1) ans = (ans+v[i+1])/2;
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    static void getPermutation(boolean[] D, int level, int curr, List<Integer> permutation){
        if(level == 6){
            return;
        }
        permutation.add(curr);

        for(int i = 0; i < 10; i++){
            if(D[i]){
                continue;
            }
            getPermutation(D, level + 1, curr * 10 + i, permutation);
        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();

        boolean[] D = new boolean[10];
        for(int i = 0; i < K; i++){
            int d = sc.nextInt();
            D[d] = true;
        }

        int ans = Integer.MAX_VALUE;
        List<Integer> permutation = new ArrayList<>();
        getPermutation(D, 0, 0, permutation);
        for(int v : permutation){
            if(v >= N){
                ans = Math.min(ans, v);
            }
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 25172
package main

import (
	"fmt"
	"log"
	"strconv"
)

// 09, 18, 27, 36, 45, ... 90, 99, 108
func main() {
	var num string
	if _, err := fmt.Scan(&num); err != nil {
		log.Fatal(err)
	}

	var sum int
	for _, ch := range num {
		n, err := strconv.Atoi(string(ch))
		if err != nil {
			log.Fatal(err)
		}

		sum += n
	}

	if sum%9 == 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 3276
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int max_n = 1e6;
int n,m;
struct edge{
  int st, end;
};
int main(){
  cin >> n >> m;
  edge v[m];
  for(int i=0 ; i<m ; i++){
    int x,y;
    cin >> x >> y;
    --x; --y;
    v[i].st = x;  v[i].end = y;
  }
  int rightmi = n-1; int leftma = 0;
  for(int i=0 ; i<m ; i++){
     rightmi = min(rightmi, v[i].end);
     leftma = max(leftma, v[i].st);
  }
  int ans = rightmi - leftma + 1;
  if(ans<0) ans = 0;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;


int main(){
  
  while(1){
    int n; cin >> n;
    if(n==0) break;
    vector<pair<int,int> > isl(n);
    for(int i=0; i<n; i++) cin >> isl[i].second >> isl[i].first;
    sort(isl.begin(),isl.end());
    int w=0;
    bool f=true;
    for(int i=0; i<n; i++){
      //      cout << isl[i].second << " " << isl[i].first << "\n";
      w += isl[i].second;
      if( w > isl[i].first ){
	f=false;
      }
    }
    if(f)cout << "Yes\n";
    else cout << "No\n";
  }
}

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

#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), end(x))
#define bit(n) (1LL << (n))
#define cdiv(a, b) (((a) - 1) / (b) + 1)
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr double PI = 3.1415926535897932384626433832795028;
constexpr int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

template<typename F> long long discrete_binary_search(long long ok, long long ng, F is_ok) {
    while (abs(ok - ng) > 1) {
        long long mid = (ok + ng) / 2;
        (is_ok(mid) ? ok : ng) = mid;
    }
    return ok;
}

int n, k;
vint w(110000);
signed main() {
    cin >> n >> k;
    rep(i, n) { cin >> w[i]; }
    cout << discrete_binary_search(1e9, 0, [&](int x) {
        int cur = 0, cnt = 1;
        rep(i, n) {
            if (w[i] > x) { return false; }
            if (cur + w[i] <= x) { cur += w[i]; }
            else { cur = w[i], cnt++; }
        }
        return cnt <= k;
    }) << endl;
}


Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
int h1,h2,m1,m2,k;
int main(){
	scanf("%d%d%d%d%d",&h1,&m1,&h2,&m2,&k);
	printf("%d\n",max(0,h2*60+m2-h1*60-m1-k));
	return 0;
}

Measured memory_bytes: 3832
#include<bits/stdc++.h>
#define int long long
using namespace std;
template<class T> inline bool chmax(T& a, T b){ if(a<b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b){ if(a>b){ a=b; return 1; } return 0; }


signed main()
{
    int N; cin>>N;
    vector<int> a(N);
    for(int i=0;i<N;i++){
        cin>>a[i];
    }
    
    vector<vector<int> > dp(N+1,vector<int>(N+1));
    for(int i=0;i<=N;i++){
        dp[i][i]=0;
    }
    
    for(int len=1;len<=N;len++){
        for(int i=0;i+len<=N;i++){
            int j=i+len;
            if((N-len)%2==0){
                dp[i][j]=max(dp[i+1][j]+a[i],dp[i][j-1]+a[j-1]);
            }else{
                dp[i][j]=min(dp[i+1][j]-a[i],dp[i][j-1]-a[j-1]);
            }
        }
    }
    cout<<dp[0][N]<<endl;
}


Measured memory_bytes: 70784
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n; cin >> n;
  vector<pair<int, int> > ans;
  int m = n + (1 - (n&1));
  for(int i = 1; i <= n; i++){
    for(int j = i + 1; j <= n; j++){
      if(i + j != m) ans.push_back({i, j});
    }
  }
  cout << ans.size() << endl;
  for(auto i : ans) cout << i.first << " " << i.second << endl;
  return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<queue>
#include<assert.h>
#include<tuple>
#include<string>
#include<algorithm>
#include<iostream>
#include<map>
#include<string.h>
#include<vector>
#include<math.h>
#include<stdlib.h>
#include<set>
#include<ctype.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef tuple<int,int,int> t3;

const int MX = 1 << 20;
const int MM = 1000000007;

int D[MX], X[MX], O[MX];

int main()
{
	int N;
	scanf("%d", &N);
	for(int i = 1; i <= N; i++){
		scanf("%d", X+i);
		D[X[i]] = i;
	}
	for(int i = 1; i <= N; i++) O[i] = i;
	sort(O+1, O+N+1, [](int l, int r){
		return X[l] < X[r];
	});

	int cur = 1;
	for(int i = 1; i <= N; i++){
		int c = O[i];
		for(int j = 1; j < c; j++){
			while(D[cur]){
				if( D[cur] == c ) return !printf("No\n");
				cur++;
			}
			if( cur > X[c] ) return !printf("No\n");
			D[cur++] = c;
		}
	}
	cur = N*N;
	for(int i = N; i >= 1; i--){
		int c = O[i];
		for(int j = 1; j <= N-c; j++){
			while(D[cur]){
				if( D[cur] == c ) return !printf("No\n");
				cur--;
			}
			if( cur < X[c] ) return !printf("No\n");
			D[cur--] = c;
		}
	}
	printf("Yes\n");
	for(int i = 1; i <= N*N; i++) printf("%d ", D[i]);
	printf("\n");
}


Measured memory_bytes: 5248
from collections import deque
n = int(input())
g = [[] for _ in range(n)]
ab = []

for _ in range(n - 1):
    a, b = map(int, input().split())
    a, b = a - 1, b - 1
    g[a].append(b)
    g[b].append(a)
    ab.append((a,b))

q = deque([0])
par = [0] * n
order = []

while q:
    x = q.pop()
    order.append(x)
    for y in g[x]:
        if y == par[x]:
            continue
        par[y] = x
        q.append(y)

color = [-1] * n
for x in order:
    ng = color[x]
    c = 1
    for y in g[x]:
        if y == par[x]:
            continue
        if c == ng:
            c += 1
        color[y] = c
        c += 1

ans = []
for a, b in ab:
    if par[a] == b:
        ans.append(color[a])
    else:
        ans.append(color[b])

k = max(ans)
print(k)
print("\n".join(map(str, ans)))


Measured memory_bytes: 83360
#![allow(unused_imports)]
#![allow(unused_macros)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_variables)]
#![allow(unused_mut)]
#![allow(unused_assignments)]
use proconio::input;
use proconio::marker::Usize1;
use std::collections::*;
use std::cmp::*;
use std::f64::consts::*;

const MOD: i64 = 1000000007;
const INF: usize = std::usize::MAX / 4;

fn main() {
    input! {
        N: i64,
        K: i64,
    }

    let mut ans: i64 = 0;
    for k in K..N+2 {
        let mi = k * (k - 1) / 2;
        let mx = N * k - mi;
        ans += mx - mi + 1;
        ans %= MOD;
    }

    println!("{}", ans);
}


Measured memory_bytes: 2184
program main
implicit none
integer :: n, a, b, c, d, i, j
character :: s*200000

read(*,*) n, a, b, c, d
read(*,*) s(1:n)
if(s(a:a)=='#'.or.s(b:b)=='#'.or.s(c:c)=='#'.or.s(d:d)=='#')then
   write(*,*) 'No'
   stop
end if
j = 0
do i = a+1, c-1
   if( s(i:i+1) =='##' ) then
      j = 1
   end if
end do
if( j == 1 ) then
   write(*,*) 'No'
   stop
else
   do i = b+1, d-1
      if( s(i:i+1) =='##' ) then
         j = 1
      end if
   end do
   if( j==1 ) then
      write(*,*) 'No'
      stop
   end if
end if

if( c<d ) then
   write(*,*) 'Yes'
   stop
else
   j = 0
   do i = b-1, d-1
      if( s(i:i+2)=='...' ) then
         j = 1
      end if
   end do
   if( j== 1 ) then
      write(*,*) 'Yes'
   else
      write(*,*) 'No'
   end if
end if

end program main


Measured memory_bytes: 1084
MAX_TIME = 10
n = int(input().rstrip())
#２進法を
P = [sum(int(i) << MAX_TIME-k-1 for k, i in enumerate(input().rstrip().split())) for j in range(n)]
S = [list(map(int, input().rstrip().split())) for i in range(n)]
#予め2進数をカウントしておく
    # 予めビットをカウントしておく
pattern = [sum(i >> j & 1 for j in range(MAX_TIME)) for i in range(2 ** MAX_TIME)]
result = -float('inf')


for i in range(1, 2**MAX_TIME):
    temp = 0
    for l, j in zip(P, S):
        temp += j[pattern[l & i]]
    result = max(result, temp)
print(result)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
//const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
 
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
 
/*------------------------------------------------------------------*/
 
int main(){
    int n; cin >> n;
    vector<pair<int,int>> a(n);
    rep(i, n){
        cin >> a[i].first;
        a[i].second = i + 1;
    }
    sort(a.begin(), a.end());
    rep(i, n){
        if(i == n - 1){
            cout << a[i].second << endl;
            return 0;
        }
        cout << a[i].second << " ";
    }
}


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


int main(){
    ll n, ans = 1e12;
    cin >> n;
    for(ll i = 1; i*i <= n; ++i){
        if(n%i != 0) continue;
        ans = min(ans, n/i + i - 2);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
n,k=map(int,input().split())
a=list(map(int,input().split()))
used=[-1]*n
pos=0
flag=False
loop=0

for i in range(k):
    used[pos]=i
    pos=a[pos]-1
    if used[pos]!=-1:
        flag=True
        loop=i+1
        break
    
if flag:
    loop-=used[pos]
    start=used[pos]
    mins=start+(k-start)%loop
    
    pos=0
    for i in range(mins):
        pos=a[pos]-1


print(pos+1)

Measured memory_bytes: 92240
// E - Coprime
#include <bits/stdc++.h>
using namespace std;
#define rpd(i,s,e,d) for(int i=(s);i<(int)(e);i+=(d))

int sum_array(vector<int> &C, int start, int end, int step){
	int c = 0;
	rpd(i, start, end, step) c += C[i];
	return c;
}

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	int MAX_A = 1000000 + 1;
	int N; cin>>N;
	vector<int> C(MAX_A, 0);
	int g = 0;
	rpd(i, 0, N, 1){
		int a; cin>>a;
		C[a]++;
		g = gcd(g, a);
	}
	int t = 0;
	if(sum_array(C, 2, MAX_A, 2) > 1) t = 1;
	else
		rpd(i, 3, MAX_A, 2) if(sum_array(C, i, MAX_A, i) > 1){ t = 1; break; }
	if(t == 1 && g > 1) t = 2;
	cout<< vector<string>{"pairwise","setwise","not"}[t] <<" coprime\n";
}


Measured memory_bytes: 7128
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9+7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A,B,C,D,E,F,G,H,I,J,K,L,N,M,O,P,Q,R,S,T,U,V,W,x,y,z;
long long max_value = INF, max_index = -1;
long long min_value = MAX, min_index = -1;
typedef long long ll;
typedef pair<ll, ll> Pa;

template <std::int_fast64_t Modulus> class modint {
  using u64 = std::int_fast64_t;
public:
  u64 a;
  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};
#pragma endregion

int a[8];
int b[8];
int main() {
	cin >> N;
	if(N < 1200){
		cout << "ABC";
	}else if(N < 2800){
		cout << "ARC";
	}else{
		cout << "AGC";
	}
}



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

public class Main {

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

  public void run() {
    
    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(in.readLine());
      String line = in.readLine();
      int nHalf = n >> 1;

      Integer num;
      Map<Integer,Integer> mapA = new HashMap<>();
      Map<Integer,Integer> mapB = new HashMap<>();;
      int offset=0,next=0;
      char regx = ' ';

      for(int i=0; i<n; i++) {
        if((next = line.indexOf(regx,offset)) == -1)
          next = line.length();
        num = new Integer(line.substring(offset, next));
        offset = ++next;

        // if((i&1) == 0)
        //   mapA.merge(num, 1, Integer::sum);
        // else
        //   mapB.merge(num, 1, Integer::sum);

        if((i & 1) == 0) {
          if(mapA.containsKey(num))
            mapA.replace(num, mapA.get(num) + 1);
          else
            mapA.put(num, 1);
        }
        else {
          if(mapB.containsKey(num))
            mapB.replace(num, mapB.get(num) + 1);
          else
            mapB.put(num, 1);
        }
      }

      int[] vm1 = {0,0};
      int[] vm2 = {0,0};
      int[] x   = {0,0};

      for (Map.Entry<Integer,Integer> m : mapA.entrySet()) {
        int val = m.getValue();
        if(vm1[0] <val) {
          vm2[0] = vm1[0];
          vm1[0] = val;
          x[0]  = m.getKey();
        } else if(vm2[0] < val) {
          vm2[0] = val;
        }
      }
      for (Map.Entry<Integer,Integer> m : mapB.entrySet()) {
        int val = m.getValue();
        if(vm1[1] <val) {
          vm2[1] = vm1[1];
          vm1[1] = val;
          x[1]  = m.getKey();
        } else if(vm2[1] < val) {
          vm2[1] = val;
        }
      }

      int ans = 0;
      int cca1 = nHalf - vm1[0];
      int ccb1 = nHalf - vm1[1];
      int cca2 = nHalf - vm2[0];
      int ccb2 = nHalf - vm2[1];

      if(x[0] == x[1])
        ans = cca2 > ccb2 ? cca1 + ccb2 : cca2 + ccb1;
      else
        ans = cca1 + ccb1;

      System.out.println(ans);
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }
}

Measured memory_bytes: 45580
#define _CRT_SECURE_NO_WARNINGS
#define _SCL_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <limits>
#include <numeric>
#include <valarray>

using namespace std;
typedef unsigned int uint;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> PP;
#define REP(i,a,n) for(LL i = (a); i < (LL)(n); ++i)
#define REM(i,a,n) for(LL i = ((n) - 1); i >= (a); --i)
#define FLOAT setprecision(16)
#define IGNORE
#define SPEEDUP {cin.tie(0); ios::sync_with_stdio(false);}
#define INSIDE(i,j,H,W) ((i) >= 0 && (i) < (H) && (j) >= 0 && (j) < (W))
const int INF = 0x3FFFFFFF;
const LL INFLL = 0x3FFFFFFF3FFFFFFF;
const double INFD = 1.0e+308;
const string INFSTR = "\x7f";
const double EPS = 1.0e-9;

void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
template <class T, class U>
istream& operator>>(istream& ist, pair<T, U>& right) { return ist >> right.first >> right.second; }
template <class T, class U>
ostream& operator<<(ostream& ost, const pair<T, U>& right) { return ost << right.first << ' ' << right.second; }
template <class T, class TCompatible, size_t N>
void Fill(T(&dest)[N], const TCompatible& val) { fill(begin(dest), end(dest), val); }
template <class T, class TCompatible, size_t M, size_t N>
void Fill(T(&dest)[M][N], const TCompatible& val) { for (int i = 0; i < M; ++i) Fill(dest[i], val); }
template<class T>
T Compare(T left, T right) { return left > right ? 1 : (left < right ? -1 : 0); }
istream& Ignore(istream& ist) {string s; ist >> s; return ist;}

// all_of
// partial_sum, adjacent_difference

#ifdef ONLY_MY_ENVIR
#include "IntMod.h"
#include "Union_Find.h"
#include "Graph.h"
#include "Range.h"
#include "Global.h"
#include "Flow_Solver.h"
#include "Tree.h"
#include "Suffix_Array.h"
#include "Geometry.h"
#endif

#ifdef __GNUC__
typedef __int128 LLL;
istream& operator>> (istream& ist, __int128& val) { LL tmp;  ist >> tmp; val = tmp; return ist; }
ostream& operator<< (ostream& ost, __int128 val) { LL tmp = val; ost << tmp; return ost; }
#endif

#if 1234567891
#include <array>
#include <unordered_set>
#include <unordered_map>
template<typename T>
using PriorityQ = priority_queue<T, vector<T>, greater<T> >;	// コスト小を優先
#endif

int N, Z, W;
int A[2000];
int DPX[2001], DPY[2001];
int main() {
	cin >> N >> Z >> W;
	REP(i, 0, N) {
		cin >> A[i];
	}
	int ans;
	if (N == 1) {
		ans = abs(W - A[0]);
	} else {


		DPX[N - 1] = DPY[N - 1] = abs(A[N - 2] - A[N - 1]);
		REM(i, 1, N - 1) {
			DPX[i] = abs(A[i - 1] - A[N - 1]);
			DPY[i] = abs(A[i - 1] - A[N - 1]);

			REP(k, i + 1, N) {
				DPX[i] = max(DPX[i], DPY[k]);
				DPY[i] = min(DPY[i], DPX[k]);
			}
		}

		ans = abs(W - A[N - 1]);
		REP(k, 1, N) {
			ans = max(ans, DPY[k]);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main(void)
{
  int N, i1 = -1, m1 = 0, m2 = 0;
  scanf("%d", &N);
  for(int i = 0; i < N; i++){
    int A;
    scanf("%d", &A);
    if(m1 < A){
        i1 = i;
        m1 = A;
    } else if(m2 < A)
        m2 = A;
  }
  for(int i = 0; i < N; i++)
    printf("%d\n", i == i1 ? m2 : m1);
  return 0;
}

Measured memory_bytes: 1536
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
//#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
	int n;
	cin >> n;
	vector<int>a(n);
	int i,j;
	long long int money = 1000;
	long long int kb = 0;
	int l = 0;
	bool f = true;
	for (i = 0; i < n; i++)
	{
		cin >> a.at(i);
	}
	i = 0;
	j = 1;
	while (j!=n)
	{
		if (f == true && a.at(i) >= a.at(j))
		{
			i++;
			j++;
		}
		else if (f == true && a.at(i) < a.at(j))
		{
			f = false;
			l = a.at(i);
			kb = money / a.at(i);
			money = money - (kb * a.at(i));
			i++;
			j++;
		}
		else if (f == false && a.at(i) <= a.at(j))
		{
			i++;
			j++;
		}
		else if (f == false && a.at(i) > a.at(j))
		{
			f = true;
			money = money + (kb * a.at(i));
			kb = 0;
			i++;
			j++;
		}
	}
	if (l >= a.at(i) && f == false)
	{
		money = money + (kb * l);
	}
	else if (l < a.at(i) && f == false)
	{
		money = money + (kb * a.at(i));
	}
	cout << money << endl;

}


	
	

	
	
/**/
/*#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

#define PI 3.141592653589793

int main(void) {
	return 0;
}
*/

Measured memory_bytes: 3600
A,B,C=map(int,input().split())
A2=A%2
B2=B%2
C2=C%2
max_num=max(A,B,C)
swich=A2+B2+C2

if swich==0 or swich==3:
    ans=(max_num*3-A-B-C)//2
else:
    if swich==1:
        if max_num%2==1:
            ans=(max_num*3-2-A-B-C)//2+1
        else:
            ans=(max_num*3+1-A-B-C)//2+1
    if swich==2:
        if max_num%2==0:
            ans=(max_num*3-2-A-B-C)//2+1
        else:
            ans=(max_num*3+1-A-B-C)//2+1
print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);
	static String T = sc.nextLine();
	static String P = sc.nextLine();
	static char[] t = T.toCharArray();
	static char[] p = P.toCharArray();
	public static void main(String[] args) {
		naiveSearch(t, p);

	}

	private static void naiveSearch(char[] t, char[] p) {
		boolean isSame = true;

		for (int i = 0; i < t.length - p.length + 1; i++) {
			isSame = true;
			for (int j = 0; j < p.length; j++) {

					if (t[i + j] != p[j]) {
						isSame = false;
						break;
					}

			}

				if (isSame == true) {
					System.out.println(i);
				}
		}

	}

}



Measured memory_bytes: 26308
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll n, a, b;
  in(n);
  vector<ll> c(n);
  rep(i, n){
    in(c[i]);
  }
  a = 0;
  rep(i, n - 1){
    b = c[i] / 2;
    a = a + b;
    if(c[i] % 2 == 1 && c[i + 1] > 0){
      a++;
      c[i + 1]--;
    }
  }
  a += (c[n - 1] / 2);
  out(a);
  memi;
}

Measured memory_bytes: 1024
using System;
using System.IO;
using System.Linq;

namespace ABC120C
{
    class Program
    {
        static void Main(string[] args)
        {
            if (args.Length > 0)
            {
                Console.SetIn(new StreamReader(args[0]));
            }

            new Program().Solve();
        }

        void Solve()
        {
            var S = Console.ReadLine();
            var zero = S.ToCharArray().Where(x => x == '0').ToArray().Length;
            var one = S.ToCharArray().Where(x => x == '1').ToArray().Length;
            var diff = Math.Abs(zero - one);
            Console.WriteLine(S.ToCharArray().Length - diff);
        }
    }
}


Measured memory_bytes: 13308
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define rep(i,n) for(ll i=0;i<n;i++)
#define INF 1e9+7
#define LLINF 1e18
using namespace std;
const ll MOD = 1e9 +7;




int main(){
    int n;
    cin>>n;
    vector<int> v(n),ans(n);
    int sz=n;
    rep(i,n) cin>>v[i];
    while(!v.empty()){
        int flag=-1;
        rep(i,sz){
            if(v[i]==i+1){
                flag=i;
            }
        }
        if(flag==-1)
        {
            cout<<-1<<endl;
            return 0;
        }
        ans.pb(flag+1);
        v.erase(v.begin()+flag);
        sz--;
    }
    std::reverse(ans.begin(),ans.end());
    rep(i,n){
        cout<<ans[i]<<endl;
    }
    return 0;
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;

// Problem Specific Parameter:
const ll mod=1000000007LL;
const int limit=1000000;
vector<ll> fact(limit+1),rfact(limit+1);
	
ll power(ll a,ll n){
	ll b=1LL;
	while(n){
		if(n&1) b=b*a%mod;
		a=a*a%mod;
		n>>=1;
	}
	return b;
}

void init(){
	fact[0]=1LL;
	rep(i,1,limit+1) fact[i]=1LL*i*fact[i-1]%mod;
	rfact[limit]=power(fact[limit],mod-2);
	rrep(i,limit+1,1) rfact[i-1]=i*rfact[i]%mod;
}

inline ll C(ll n,ll k){
	if(k<0 or n<k) return 0LL;
	return fact[n]*rfact[k]%mod*rfact[n-k]%mod;
}

int main(void){
	init();

	ll n,m,k;
	cin >> n >> m >> k;

	ll ans=0LL,mid=1LL;
	rep(t,n,n+m+k+1){
		ll lft=C(t-1,n-1);
		ll rgt=power(3LL,n+m+k-t);
		ans+=1LL*lft*mid%mod*rgt%mod;
		//cout << mid << endl;
		ans%=mod;
		mid=2LL*mid%mod;
		mid=(mid+2LL*mod-C(t-n,t-n-k)-C(t-n,m))%mod;
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 16000
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <cmath>
#include <string>
#include <set>
#include <map>
#define SIZE 55

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

vector <int> A[SIZE];
vector <int> B[SIZE];
int pa[SIZE],pb[SIZE];
int deg[SIZE];
bool use[SIZE];

void dfs_a(int v,int p)
{
	pa[v]=p;
	for(int i=0;i<A[v].size();i++)
	{
		int to=A[v][i];
		if(to!=p) dfs_a(to,v);
	}
}
void dfs_b(int v,int p)
{
	pb[v]=p;
	for(int i=0;i<B[v].size();i++)
	{
		int to=B[v][i];
		if(to!=p) dfs_b(to,v);
	}
}
void solve()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++) A[i].clear();
	for(int i=0;i<n;i++) B[i].clear();
	for(int i=0;i<n-1;i++)
	{
		int a,b;
		scanf("%d %d",&a,&b);a--,b--;
		A[a].push_back(b);
		A[b].push_back(a);
	}
	for(int i=0;i<n-1;i++)
	{
		int a,b;
		scanf("%d %d",&a,&b);a--,b--;
		B[a].push_back(b);
		B[b].push_back(a);
	}
	dfs_a(0,-1);
	dfs_b(0,-1);
	bool up=true;
	for(int i=0;i<n;i++) if(pa[i]!=pb[i]) up=false;
	if(up)
	{
		puts("0");
		return;
	}
	int ans=-1;
	for(int s=0;s<n;s++)
	{
		if(A[s].size()==1)
		{
			int t=A[s][0];
			for(int i=0;i<A[t].size();i++)
			{
				if(A[t][i]==s)
				{
					swap(A[t][i],A[t][A[t].size()-1]);
					break;
				}
			}
			A[t].pop_back();
			for(int i=0;i<n;i++)
			{
				// s->i に辺を張る
				A[s][0]=i;
				A[i].push_back(s);
				dfs_a(s,-1);
				dfs_b(s,-1);
				memset(use,false,sizeof(use));
				queue <int> que;
				int cnt=0;
				que.push(s);
				while(!que.empty())
				{
					int v=que.front();que.pop();
					use[v]=true;
					cnt++;
					for(int j=0;j<A[v].size();j++)
					{
						int to=A[v][j];
						if(to!=pa[v]&&pb[to]==v) que.push(to);
					}
				}
				for(int j=0;j<n;j++)
				{
					deg[j]=A[j].size()-1;
				}
				while(1)
				{
					int v=-1;
					for(int j=0;j<n;j++)
					{
						if(!use[j]&&deg[j]==0&&use[pb[j]])
						{
							v=j;
							break;
						}
					}
					if(v==-1) break;
					use[v]=true;
					deg[pa[v]]--;
				}
				bool up=true;
				for(int j=0;j<n;j++)
				{
					if(!use[j])
					{
						up=false;
					}
				}
				if(up)
				{
					int vl=n-cnt+1;
					if(ans==-1) ans=vl;
					else ans=min(ans,vl);
				}
				A[i].pop_back();
			}
			A[t].push_back(s);
			A[s][0]=t;
		}
	}
	printf("%d\n",ans);
}
int main()
{
	int T;
	scanf("%d",&T);
	while(T--) solve();
	return 0;
}


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

int main(){
  string S;
  cin >> S;
  for(int i=0; i<S.size(); i++){
    if(S[i]=='1') S[i]='9';
    else if(S[i]=='9') S[i]='1';
  }
  cout << S << endl;
  return 0;
}

Measured memory_bytes: 256
x,n=map(int,input().split())
p=list(map(int,input().split()))

ans=10000
b=0

an=10000

for i in range(0,102):
    b=0

    for _ in p:
        if i==_:
            b=1
            break
    
    if b!=1:
        if ans> abs(x-i):
            ans=abs(x-i)
            an=i

print(an)

Measured memory_bytes: 63852
#include<bits/stdc++.h>
#define inf 1000000000
using namespace std;
struct node
{
    int num;
    int val;
    int st;
} a[1009];
int n,m,ans=inf,dp[1009][5000];
int f(int x,int y)
{
    return x&1<<y;
}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=0; i<=m; i++)
        for(int j=0; j<1<<n; j++)
            dp[i][j]=j==0?0:inf;
    for(int i=1; i<=m; i++)
    {
        int tmp=0;
        scanf("%d%d",&a[i].val,&a[i].num);
        for(int j=1; j<=a[i].num; j++)
        {
            int x;
            scanf("%d",&x);
            tmp+=1<<(x-1);
        }
        a[i].st=tmp;
    }
    for(int i=1; i<=m; i++)
    {
        for(int j=0; j<1<<n; j++)
        {
            int tmp=0;
            dp[i][j]=min(dp[i][j],dp[i-1][j]);
            for(int k=0; k<12; k++)
                tmp+=(f(a[i].st,k)|f(j,k))?1<<k:0;
            dp[i][tmp]=min(dp[i][tmp],dp[i-1][j]+a[i].val);
            //printf("%d %d\n",dp[i][tmp],tmp);
        }
    }
    for(int i=1; i<=m; i++)
        ans=min(ans,dp[i][(1<<n)-1]);
    if(ans==inf)
        printf("-1");
    else
        printf("%d",ans);
    return 0;
}

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

int main(){
    int N;
    cin >> N;
    vector<int> X(N);
    for(int i = 0; i < N; i++){
        cin >> X.at(i);
    }
    vector<int> Y(N);
    for(int i = 0; i < N; i++){
        cin >> Y.at(i);
    }

    vector<int> A(N);
    for(int i = 0; i < N; i++){
        A.at(i) = X.at(i) - Y.at(i);
    }

    sort(A.begin(),A.end());

    int answer = 0;

    for(int i = 0; i < N; i++){
        if(A.at(i) > 0){
            answer += A.at(i);
        }
    }

    cout << answer << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};

void solve() {
    int n;
    cin >> n;
    ll ans = 0;
    rep(i, n) {
        ans += (ll)(i+1)*(n-i);
    }
    rep(i, n-1) {
        int u, v;
        cin >> u >> v;
        u--; v--;
        if (u>v) swap(u, v);
        ans -= (ll)(u+1)*(n-v);
    }
    cout << ans << endl;
    
}

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


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

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

    string s;
    cin>>s;

    int ans=1;

    if(n==0)
    {
        cout<<0<<endl;
    }
    else
    {
        for(int i=1;i<n;i++)
        {
            if(s[i]!=s[i-1])
            {
                ans++;
            }
            else{
                continue;
            }
        }
        cout<<ans<<endl;
    }

    return 0;
}

Measured memory_bytes: 512
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
A = []
for i in range(N):
  A.append(list(map(int, input().split())))
           
count = 0
for i in range(N):
  if sum(list(map(lambda x,y: x*y, A[i], B)))+C > 0:
    count += 1
    
print(count)

Measured memory_bytes: 9200
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
//cout << fixed << setprecision(8) << a << endl;
#define Fast_Input ios_base :: sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
#define pb push_back
#define mem(a, b)     memset(a, b, sizeof(a))
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef long long ll;
typedef tree<int,null_type,greater<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
/*sort(v.begin(), v.end(),
     [](const pair<int, int>& x, const pair<int, int>& y)
{
    if (x.first != y.first)
        return x.first < y.first;
    return x.second < y.second;
});
*/
int const fx[]= {+1,+0,-1,+1};
int const fy[]= {-1,+1,+0,+0};
const int inf = numeric_limits<int>::max();
const ll mx=1e3;
const ll mod=1e9+7;
int cost[15],arr[15][15];
int n,m,x;
int ans=inf;
int main()
{
    ll n,k,i;
    cin >> n >> k;
    map<int,int>m;
    for(i=1; i<=n; i++)
    {
        int x;
        cin >> x;
        m[i]=x;
    }
    int now=1,d=1;
    map<int,int>c;
    for(i=1;i<=n;i++)c[i]=-1;
    c[1]=0;
    int target=0,from;
    int mov=0;
    while(1)
    {
        if(now==m[now])
        {
            cout << now << endl;
            return 0;
        }
        now=m[now];
        mov++;
        if(mov==k)
        {
            cout << now << endl;
            return 0;
        }
        if(c[now]==-1)
        {
            c[now]=d;
            d++;
        }
        else
        {
            k-=c[now];
            target=k%(d-c[now]);
            from=now;
            break;
        }
    }
    //cout << target << " " << from << endl;
    now=from;
    while(target)
    {
        now=m[now];
        target--;
    }
    cout << now << endl;
    return 0;
}




Measured memory_bytes: 22380
#include<stack>
#include<cstdio>
#include<algorithm>
using namespace std;

typedef long long ll;
const int Maxn=1e5;
const ll Mod=1e9+7;

int N;
char s[Maxn*2+5];

int main() {
	#ifdef LOACL
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
	#endif
	scanf("%d",&N);
	scanf("%s",s+1);
	ll ans=1,cnt=0,tmp=0;
	for(int i=1;i<=N*2;i++)
		if((cnt&1)^(s[i]=='B'))
			cnt++;
		else ans=(ans*cnt)%Mod,cnt--,tmp++;
	for(int i=1;i<=N;i++)
		ans=ans*i%Mod;
	printf("%lld\n",tmp==N?ans:0);
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main() {
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    int mx = max(a[0], max(a[1], a[2]));
    cout << mx * 10 + a[0] + a[2] + a[1] - mx << endl;
    return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val MOD = 1e9.toLong() + 7
    val L = readLine()!!

    val dp = Array(L.length + 1) { Array(2) {ModInt(0, MOD)} }

    dp[0][0] = ModInt(1L, MOD)

    for (i in L.indices) {
        dp[i + 1][1] = dp[i][1] * 3

        if (L[i] == '1') {
            dp[i + 1][0] = dp[i][0] * 2
            dp[i + 1][1] += dp[i][0]
        } else {
            dp[i + 1][0] = dp[i][0]
        }
    }

    println((dp[L.length][0] + dp[L.length][1]).value)
}

class ModInt (value: Long, val mod: Long) {
    init {
        if (mod <= 0) {
            throw IllegalArgumentException("ModInt cannot be created for non-positive modulus: $mod")
        }
    }

    val value = (value % mod + mod) % mod

    private fun assertSameMod(other: ModInt) {
        if (mod != other.mod) {
            throw IllegalArgumentException(
                "You cannot operate summation, subtraction and multiplication for ModInts with different moduli: $mod, ${other.mod}"
            )
        }
    }

    operator fun unaryMinus() = ModInt(mod - value, mod)

    operator fun plus(other: ModInt): ModInt {
        assertSameMod(other)

        return ModInt((value + other.value) % mod, mod)
    }

    operator fun plus(other: Long) = plus(ModInt(other, mod))

    operator fun minus(other: ModInt): ModInt {
        assertSameMod(other)

        return plus(-other)
    }

    operator fun minus(other: Long) = minus(ModInt(other, mod))

    operator fun times(other: ModInt): ModInt {
        assertSameMod(other)

        return ModInt((value * other.value) % mod, mod)
    }

    operator fun times(other: Long) = times(ModInt(other, mod))

    fun pow(k: Long): ModInt {
        var res = 1L
        var a = value
        var l = k

        while (l > 0) {
            if ((l and 1L) == 1L) {
                res = (res * a) % mod
            }

            a = a * a % mod
            l /= 2L
        }

        return ModInt(res, mod)
    }

    /**
     * Returns an inverse element of the value.
     * To ensure `m * m.inv() = 1`, the modulus should be prime, since it uses Fermat's little theorem.
     */
    fun inv() = pow(mod - 2)

    operator fun div(other: ModInt): ModInt {
        assertSameMod(other)
        if (other.value == 0L) {
            throw ArithmeticException()
        }

        return times(other.inv())
    }

    operator fun div(other: Long) = div(ModInt(other, mod))
}


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

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

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

int w, h, n;
int sx,sy,gx,gy;
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};

bool can(int y, int x) {
	if(0 <= y && y < h && 0 <= x && x < w) return true;
	return false;
}

struct edge {
	int from,to;
	ll cost;

	edge(int t,int c) : to(t),cost(c) {}
	edge(int f,int t,int c) : from(f),to(t),cost(c) {}

	bool operator<(const edge &e) const {
		return cost < e.cost;
	}
};

vector<edge> G[505*505 + 5];
ll d[505 * 505 + 5];

void dijkstra(int s, int n) {
	priority_queue<P, vector<P>, greater<P> > que;
	fill(d, d+n, INF);

	d[s] = 0;
	que.push(P(0,s));

	while(que.size()) {
		P p = que.top();
		que.pop();

		int v = p.second;
		if(d[v] < p.first) continue;

		rep(i, G[v].size()) {
			edge e = G[v][i];
			if(d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to],e.to));
			}
		}
	}
}

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

	cin >> sx >> sy >> gx >> gy;

	rep(i, h * w) {
		G[i].clear();
	}

	w++;
	h++;

	rep(i, h) {
		rep(j, w) {
			rep(k, 4) {
				int y = i + dy[k];
				int x = j + dx[k];

				if(can(y, x)) {
					G[i*w + j].push_back(edge(y*w + x, 0));
				}
			}
		}
	}

	rep(i, n) {
		int y, x, t;
		cin >> x >> y >> t;

		string s;
		cin >> s;

		rep(k, t) {
			rep(j, s.size()) {
				int from = -1, to = -1;
				if(s[j] == 'R' && x + 1 < w - 1) {
					from = y * w + (x + 1);
					to = (y + 1) * w + (x + 1);
					x++;
				} else if(s[j] == 'L' && 0 <= x - 1) {
					from = y * w + x;
					to = (y + 1) * w + x;
					x--;
				} else if(s[j] == 'U' && 0 <= y - 1) {
					from = y * w + x;
					to = y * w + (x + 1);
					y--;
				} else if(s[j] == 'D' && y + 1 < h - 1) {
					from = (y + 1) * w + x;
					to = (y + 1) * w + (x + 1);
					y++;
				}

				if(from == -1 && to == -1) continue;
				rep(k, G[from].size()) {
					if(G[from][k].to == to) {
						G[from][k].cost++;
					}
				}
				rep(k, G[to].size()) {
					if(G[to][k].to == from) {
						G[to][k].cost++;
					}
				}
			}
		}
	}

	// rep(i, h) {
	// 	rep(j, w) {
	// 		cout << " --------- " << i << ", " << j << " :" << i * w + j << " |";
	// 		rep(k, G[i*w + j].size()) {
	// 			cout << "(" << G[i*w + j][k].to << ", " << G[i*w + j][k].cost << ") ";
	// 		}
	// 		cout << endl;
	// 	}
	// }

	dijkstra(sy * w + sx, h * w);

	// rep(i, h) {
	// 	rep(j, w) {
	// 		cout << d[i*w + j] << " ";
	// 	}
	// 	cout << endl;
	// }

	cout << d[gy * w + gx] << endl;

	return 0;
}

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

using namespace std;

#define PI 3.14159265358979323846264338327950L

int main(void){

    long long ans,N,D,x,y;

    cin>>N>>D;
    ans=0;
    for(int i=0;i<N;i++){
        cin>>x>>y;
        if(sqrt(x*x+y*y)<=D ){
            ans++;
        }
    }

    cout<<ans<<endl;


    return 0;
}



Measured memory_bytes: 3676