akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

int MOD = 1000000007;

int main() {
    string S;
    cin >> S;
    int s_len = S.length();
    vector<vector<int>> dp(s_len, vector<int>(13));
    for (int i = 0; i < 10; i++) {
        if (S[0] == '?' or S[0] == '0' + i) {
            dp.at(0).at(i) = 1;
        }
    }
    for (int i = 0; i < s_len - 1; i++) {
        for (int j = 0; j < 13; j++) {
            for (int k = 0; k < 10; k++) {
                if (S[i + 1] == '?' or S[i + 1] == '0' + k) {
                    int j2 = (j * 10 + k) % 13;
                    dp.at(i + 1).at(j2) += dp.at(i).at(j);
                    dp.at(i + 1).at(j2) %= MOD;
                }
            }
        }
    }
    cout << dp.at(s_len - 1).at(5) << endl;
    return 0;
}


Measured memory_bytes: 8960
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define FIFO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define MOD 1000000007
#define mods 1000000009
#define modhash1 1000000009
#define modhash2 1000000007
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;
int TestMillerRabin[12] = {2,3,5,7,11,13,17,19,23,29,31,37};
ll mulmod(ll a, ll b, ll p){
	ll x = 0, y = a%p;
	while(b>0){
		if(b%2==1) x = (x+y)%p;
		y = (1LL*y*2)%p;
		b = b/2;
	}
	return x%p;
}
ll fastexp(ll x, ll y, ll p){
	ll ans = 1;
	while(y > 0){
		if(y&1) ans = (1LL*ans*x)%p;
		y = y>>1;
		x = (1LL*x*x)%p;
	}
	return ans%p;
}
ll fastexpp(ll x, ll y, ll p){
	ll ans = 1;
	while(y > 0){
		if(y&1) ans = mulmod(ans,x,p);
		y = y>>1;
		x = mulmod(x,x,p);
	}
	return ans%p;
}
ll invmod(ll x, ll p){
	return fastexp(x,p-2,p)%p;
}
bool check_composite(ll n, ll a, ll d, int s){
	ll x = fastexp(a,d,n);
	if(x == 1 || x == n-1) return false;
	for(int r=1; r<s; r++){
		x = (1LL*x*x)%n;
		if(x == n-1) return false;
	}
	return true;
}
bool isPrime(ll p){
	if(p<=1) return false;
	int r = 0;
	ll d = p-1;
	while(!(d&1)){
		d >>= 1;
		r++;
	}
	for(int i=0; i<12; i++){
		int value = TestMillerRabin[i];
		if(p == value) return true;
		if(check_composite(p,value,d,r)) return false;
	}
	return true;
}

int main(){
	map <string,int> ans;
	int n;
	cin >> n;
	for(int i=0; i<n; i++){
		string s;
		cin >> s;
		ans[s]++;
	}
	cout << "AC x " << ans["AC"] << '\n';
	cout << "WA x " << ans["WA"] << '\n';
	cout << "TLE x " << ans["TLE"] << '\n';
	cout << "RE x " << ans["RE"];
	return 0;
}


Measured memory_bytes: 3624
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
/*--Input//////////////////////////////////////////////////*/
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
#define SS(T, ...)      T __VA_ARGS__; IN(__VA_ARGS__);
#define SV(type,c,n) vector<type> c(n);for(auto& i:c)cin >> i;
/*--Output/////////////////////////////////////////////////*/
inline int p(void){cout << endl; return 0;}
template<class Head> int p(Head&& head){cout << head;p();return 0;} template<class Head,class... Tail> int p(Head&& head,Tail&&... tail){cout<<head<<" ";p(forward<Tail>(tail)...);return 0;}
struct ProconInit {
    static constexpr bool AUTOFLUSH = false;
    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define vl vector<ll>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL<<(n))
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.first+a.second > b.first+b.second; }
int a[100001];

signed main() {
  SS(int,n);
  ll sum=0;
  rep(i,n){
      SS(int,A);
      a[A]++;
        sum+=A;
  }
  SS(int,q);
  rep(i,q){
      SS(int,b,c);
      sum+=(c-b)*a[b];
      p(sum);
      a[c]+=a[b];
      a[b]=0;
  }
  
}

Measured memory_bytes: 4024
t = [int(input()) for _ in range(5)]
d = [c%10 for c in t]
for i in range(5):
    if d[i] == 0:
        d[i] = 10
#print(t,d)
min_d = min(d)
totalt = 0
f = True
for x,y in zip(t,d):
    if (y == min_d) and f:
        totalt += x
        f = False
    else:
        if y == 10:
            totalt += x
        else:
            totalt += ((x//10) + 1) * 10
print(totalt)

Measured memory_bytes: 3064
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

    class Process {
        final String name;
        int time;
        public Process(String name, int time) {
            this.name = name;
            this.time = time;
        }

        public int run(int time) {
            int pre = this.time;
            this.time = Math.max(0, this.time - time);
            return pre - this.time;
        }

        public boolean isFinished() {
            return this.time == 0;
        }
    }

    class Result {
        final String name;
        final int finishedTime;
        public Result(String name, int time) {
            this.name = name;
            finishedTime = time;
        }
    }

    void solve() {
        // Input
        int n = sc.nextInt();
        int q = sc.nextInt();
        Queue<Process> que = new ArrayDeque<>();
        for(int i= 0; i<n;i++) {
            que.add(new Process(sc.next(), sc.nextInt()));
        }

        // Solve
        List<Result> results = new ArrayList<>();
        int time = 0;
        while (!que.isEmpty()) {
            Process top = que.poll();
            time += top.run(q);
            if(top.isFinished()) {
                results.add(new Result(top.name, time));
            } else {
                que.add(top);
            }
        }

        // Output
        for(Result result : results) {
            System.out.println(String.format("%s %d", result.name, result.finishedTime));
        }
    }

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



Measured memory_bytes: 120800
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define veci vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vec>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))


using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
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;}
template<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
template<class T> inline void print(T v){for(auto e:v)cout<<e<<" ";cout<<endl;}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x:vec) is >> x;
    return is;
}
const ll mod=1e9+7;

double dp[3005][3005];

int main()
{
    ll n;
    cin >> n;
    string s;
    cin >> s;
    ll left=0;
    ll right=0;
    ll cnt=0;
    rep(i,n){
        if(s[i]=='('){
            cnt++;
        }
        else{
            cnt--;
        }
        if(cnt==-1){
            left++;
            cnt++;
        }
    }
    right=cnt;
    rep(i,left){
        cout << '(';
    }
    cout << s;
    rep(i,right){
        cout << ')';
    }
    cout << endl;
    return 0;
} 

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

public class Main{

    static int comb(int m,int n)
    {
        int res=1;

        if(n>m-n)
            n=m-n;

        for(int i=0;i<n;i++)
        {
            res*=(m-i);
            res/=(i+1);
        }
        return res;
    }
    public static void main(String[] args) {
        
        Scanner in = new Scanner(System.in);

        int m= in.nextInt();
        int n = in.nextInt();

        int total_ways=0;

        if(m>=2)
            total_ways+=comb(m,2);

        if(n>=2)
            total_ways+=comb(n,2);

        System.out.println(total_ways);
    }
}


Measured memory_bytes: 21844
#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(){
  int r;
  cin >> r;
  if(r<1200)cout<< "ABC" <<endl;
  else if(r<2800) cout<< "ARC" <<endl;
  else cout<< "AGC" <<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>

#define PB push_back
#define ALL(a)  (a).begin(),(a).end()
#define all(v) begin(v), end(v)
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)

using namespace std;

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

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int INF = (int)1e9;
const ll inf = (ll)1e18;
const ll MOD{ (ll)1e9 + 7 };

int main() {
	int N; cin >> N;
	string S; cin >> S;
	map<pair<string, string>, int> mp;
	for (int i = 0; i < 1 << N; ++i) {
		string s1, s2;
		for (int j = 0; j < N; ++j) {
			((i >> j & 1) ? s1 : s2) += S[j];
		}
		++mp[make_pair( s1, s2 )];
	}
	ll ans = 0;
	for (int i = 0; i < 1 << N; ++i) {
		string s1, s2;
		for (int j = 0; j < N; ++j) {
			((i >> j & 1) ? s2 : s1) += S[N + j];
		}
		reverse(begin(s1), end(s1));
		reverse(begin(s2), end(s2));
		ans += mp[make_pair( s1, s2 )];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 87040
# -*- coding: utf-8 -*-
n = int(input())
an = list(map(int, input().split()))

#プラス始まり
if an[0] > 0:
    sum = an[0]
    ans = 0
else:
    sum = 1
    ans = abs(an[0])+1

for i in range(1,n):
    if sum * (sum + an[i]) < 0:
        sum += an[i]
    else:
        if sum > 0:
            ans += abs(sum + an[i] + 1)
            sum = -1
        else:
            ans += abs(sum + an[i] - 1)
            sum = 1
ans1 = ans

#-始まり
if an[0] < 0:
    sum = an[0]
    ans = 0
else:
    sum = -1
    ans = abs(an[0])+1

for i in range(1, n):
    if sum * (sum + an[i]) < 0:
        sum += an[i]
    else:
        if sum > 0:
            ans += abs(sum + an[i] + 1)
            sum = -1
        else:
            ans += abs(sum + an[i] - 1)
            sum = 1

# print(ans1, ans)
print(min([ans1, ans]))


Measured memory_bytes: 14468
S=input()
l=len(S)
A=[0]*l
c=0
for i in range(l-1):
    if S[i]=='R':
        c+=1
    if S[i+1]=='L'or (i==l-1 and S[-1]=='R'):
        if i==l-1 and S[-1]=='R':
            c+=1
        A[i]+=(c+1)//2
        A[i+1]+=c//2
        c=0
c=0
for i in range(l-1,0,-1):
    if S[i]=='L':
        c+=1
    if S[i-1]=='R' or (i==0 and S[0]=='L'):
        if i==0 and S[0]=='L':
            c+=1
        A[i]+=(c+1)//2
        A[i-1]+=c//2
        c=0
print(' '.join(map(str,A)))

Measured memory_bytes: 10484
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e3+5,M=2e4+5,inf=0x3f3f3f3f,mod=1e9+7;
#define mst(a,b) memset(a,b,sizeof a)
#define lx x<<1
#define rx x<<1|1
#define reg register
#define PII pair<int,int>
#define fi first
#define se second
#define pb push_back
#define il inline
char s[5]={'a','e','i','o','u'};
int main(){
	char c;cin>>c;
	int f=0;
	for(int i=0;i<5;i++) if(c==s[i]) f=1;
	puts(f?"vowel":"consonant");
	return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <list>
#include <cmath>
#include <limits>

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;

int main() {
    int n;
    cin >> n;
    string ans;
    while(n != 0) {
        int s = n % 2;
        if(s < 0) s += 2;
        n = (n-s) / -2;
        ans += to_string(s);
    }
    if(ans == "") ans += '0';
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
// #include <map>
// #include <algorithm>

using namespace std;
typedef unsigned long long ull;


ull evaluate(const string& S, const vector<int>& positions) {
    int start = 0;
    ull sum = 0;
    for (int end : positions) {
        // cout << "substr=" << S.substr(start, end - start + 1) << endl;
        sum += stoull(S.substr(start, end - start + 1));
        start = end + 1;
    }
    return sum;
}

int main(int argc, char const *argv[]) {
    string S;
    cin >> S;
    const int N = S.length();

    ull sum = 0;
    for (int i = 0; i < (1 << (N-1)); i++) {
        vector<int> positions;
        for (int j = 0; j < N-1; j++) {
            if ((i >> j) & 1) {
                positions.push_back(j);
            }
        }
        positions.push_back(N-1);
        sum += evaluate(S, positions);
    }

    cout << sum << endl;

    return 0;
}


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

#define rep(i, N) for (i = 0; i < N; i++)

int main()
{
  string S;
  cin >> S;

  int count = 0;
  int ans = 0;

  int i;
  rep(i, S.size())
  {
    if (S[i] == 'A' || S[i] == 'T' || S[i] == 'G' || S[i] == 'C')
    {
      count++;
    }
    else
    {
      ans = max(count, ans);
      count = 0;
    }
  }
  ans = max(count, ans);
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INF = INT_MAX/10;

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

int main() {
	int X, Y;
	while(cin >> X >> Y, X) {
		vvi field(Y+1, vi(X));
		REP(i, Y) {
			REP(j, X) {
				cin >> field[i][j];
			}
		}

		vvi dp(Y+1, vi(X, 0));
		REP(j, X) {
			dp[0][j] = 1;
		}

		REP(i, Y) {
			REP(j, X) {
				if(i == Y-1) {
					switch(field[i][j]) {
					case 0:
					case 2:
						dp[i+1][j] += dp[i][j];
						break;
					case 1:
						break;
					}
				} else {
					switch(field[i][j]) {
					case 0:
						REP(d, 3) {
							int ny = i+1;
							int nx = j+dx[d];
							if(0 <= nx && nx < X) {
								switch(field[ny][nx]) {
								case 0:
									dp[ny][nx] += dp[i][j];
									break;
								case 1:
									break;
								case 2:
									if(d == 1) {
										dp[ny][nx] += dp[i][j];
									}
									break;
								}
							}
						}
						break;
					case 1:
						break;
					case 2:
						int ny = min(i+2, Y);
						if(field[ny][j] != 1) {
							dp[ny][j] += dp[i][j];
						}
						break;
					}
				}
			}
		}

		int ans = 0;
		REP(i, X) {
			ans += dp[Y][i];
		}

		cout << ans << endl;
	}

	return 0;
}

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

int main() {
  int N, M;
  cin >> N >> M;

  vector<int> ans(N);
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    ans.at(a - 1)++;
    ans.at(b - 1)++;
  }
  for (int i = 0; i < N; i++) {
    cout << ans.at(i) << endl;
  }
}

Measured memory_bytes: 384
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

int main() {
	int x,a,b;
	cin>>x>>a>>b;
	x-=a;
	while(x>=b){
		x-=b;
	}
	cout<<x<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            return 0;

        vector<int> a(n);
        for(int i=0; i<n; ++i)
            cin >> a[i];

        int ret = 0;
        for(int i=0; i<n; ++i){
            for(int j=i+1; j<n; ++j){
                if(a[i] > a[j])
                    ++ ret;
            }
        }
        cout << ret << endl;
    }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()),((v).end())
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
double const EPS = 1e-12, PI = acos(-1);
const int N = 4e5 + 9, M = 5e3 + 9, OO = 1e9 + 7, MOD = 1e9 + 7;
const ll inf = 1e18;

ll x[N], v[N], pre[N], suf[N], bestPre[N], bestSuf[N];

int main() {
  fastIO;
#ifdef LOCAL
  freopen("input.in", "rt", stdin);
#endif
  int n;
  ll C;
  cin >> n >> C;
  for (int i = 1; i <= n; ++i) {
    cin >> x[i] >> v[i];
  }
  for (int i = 1; i <= n; ++i) {
    pre[i] = pre[i - 1] + v[i] - (x[i] - x[i - 1]);
    bestPre[i] = max(pre[i], bestPre[i - 1]);
  }
  x[n + 1] = C;
  for (int i = n; i > 0; --i) {
    suf[i] = suf[i + 1] + v[i] - (x[i + 1] - x[i]);
    bestSuf[i] = max(suf[i], bestSuf[i + 1]);
  }
  ll ans = 0;
  for (int i = 0; i <= n + 1; ++i) {
    ans = max({ans, pre[i], suf[i]});
    ans = max({ans, (pre[i] + bestSuf[i + 1] - x[i])});
    if(i)
      ans = max({ans, (suf[i] + bestPre[i - 1] - (C - x[i]))});
  }
  cout << ans;
  return 0;
}


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

int main() {
    ll N;
    cin >> N;
    map<string, ll> cnt;
    for (ll i = 0; i < N; i++) {
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        cnt[s] += 1;
    }

    ll res = 0;
    for (auto p : cnt) {
        res += (p.second * (p.second - 1)) / 2;
    }
    cout << res << endl;
}

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

using namespace std;

int main(){
    int N;
    cin >> N;
    int alice = 0;
    int bob = 0;
    int a[100];
    for (int i = 0; i < N;i++){
        cin >> a[i];
    }
    sort(a,a+N,greater<>());
    for (int i = 0; i < N; i += 2)
    {
        alice += a[i];
    }
    for (int i = 1; i < N; i += 2)
    {
        bob += a[i];
    }
    cout << alice - bob << endl;
}

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

int main(){
  int N,Q,count=0;
  string s,str;
  cin>>N>>Q;
  cin>>s;
  int a[s.length()];
  a[0]=0;

  for(int i=0;i<s.length();i++){
    if(s[i]=='A' && s[i+1]=='C') a[i+1]=a[i]+1;
    else a[i+1]=a[i];
  }
  int l[Q],r[Q];

  for(int i=0;i<Q;i++){
    cin>>l[i]>>r[i];
  }

  for(int i=0;i<Q;i++){
    cout<<a[r[i]-1]-a[l[i]-1]<<endl;
  }


  return 0;
}


Measured memory_bytes: 2176
N = int(input())
L = list(map(int, input().split()))

cnt = 0
for i in range(N - 2):
    for j in range(i + 1, N - 1):
        for k in range(j + 1, N):
            a = L[i]
            b = L[j]
            c = L[k]
            if a == b or b == c or c == a:
                continue
            if a + b > c and b + c > a and c + a > b:
                # print(i + 1, j + 1, k + 1)
                cnt += 1

print(cnt)


Measured memory_bytes: 9184
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll;
 
struct UnionFind {vector<int> par, cnt;
    UnionFind(int NV) { par.clear(); cnt.resize(NV, 1); rep(i, 0, NV) par.push_back(i); }
    void reset() { rep(i, 0, cnt.size()) cnt[i] = 1; rep(i, 0, par.size()) par[i] = i; }
    int operator[](int x) { return par[x] == x ? x : par[x] = operator[](par[x]); }
    void operator()(int x, int y) {x = operator[](x); y = operator[](y);
        if (x != y) par[x] = y, cnt[y] += cnt[x];}};
 
int N;
void _main() {
    cin >> N;
    vector<pair<int, int>> va, vb;
    rep(i, 0, N) {
        int x, y; cin >> x >> y;
        va.push_back({ x, i });
        vb.push_back({ y, i });
    }
 
    vector<tuple<int, int, int>> edges;
    sort(va.begin(), va.end());
    sort(vb.begin(), vb.end());
    rep(i, 0, N - 1) {
        edges.push_back(make_tuple( va[i + 1].first - va[i].first, va[i].second, va[i + 1].second ));
        edges.push_back(make_tuple( vb[i + 1].first - vb[i].first, vb[i].second, vb[i + 1].second));
    }
    sort(edges.begin(), edges.end());
 
    UnionFind uf(N);
    ll ans = 0;
    for (auto p : edges) {
        int x, y, c;
        tie(c, x, y) = p;
 
        if (uf[x] != uf[y]) {
            uf(x, y);
            ans += c;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 7144
n = int(input())
s = list(input())

list_b = []
cnt_b = 0
list_w = []
cnt_w = 0
for i in range(n):
    if s[i] == "#":
        cnt_b += 1
    else:
        cnt_w += 1
    list_b.append(cnt_b)
    list_w.append(cnt_w)
ans = 2*10**5
for i in range(n):
    if ans > list_b[i] + list_w[n-1] - list_w[i]:
        ans = list_b[i] + list_w[n-1] - list_w[i]
print(min(ans,list_b[n-1],list_w[n-1]))

Measured memory_bytes: 14176
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	ll N,K,l;
	cin >> N >> K;
	vector<ll> h;
	for (ll i = 0;i < N;i++){
		cin >> l;
		h.pb(l);
	}
	sort(ALL(h));
	ll min_h = LINF;
	for (ll i = 0;i <= N - K;i++){
		min_h = min(min_h,h[i+K-1] - h[i]);
	}
	cout << min_h << endl;
	return 0;
}

Measured memory_bytes: 1400
#include <cstddef>
#include <complex>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <array>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <limits>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <memory>
#include <random>
#include <fstream>
#include <locale>

using ll = long long;
using ull = unsigned long long;

//vector
template <class T>
using vec = std::vector<T>;

template <class T>
using vvec = vec<vec<T>>;

constexpr std::size_t operator""_sz(ull n) { return std::size_t(n); }

int main()
{
    using namespace std;

    int n, m, x;
    cin >> n >> m >> x;
    vec<int> v(n + 1);

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

    auto left = accumulate(v.cbegin(), v.cbegin() + x, 0);
    cout << min(left, m - left) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
  int N;
  scanf("%d", &N);

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

  long int yen = 1000;
  long int kabu;
  for(int i=0;i<N-1;i++){
    if(A[i] < A[i+1]){
      kabu = yen / A[i];
      yen += kabu * (A[i+1] - A[i]);
    }
  }
  
  printf("%ld\n", yen);

  return 0;
}


Measured memory_bytes: 1588
from collections import Counter

n = int(input())
v = input().split()
vls = []

for x in v:
    vls.append(int(x))

v1 = vls[0::2]
v2 = vls[1::2]

c1 = Counter(v1)
c2 = Counter(v2)

ya1 = c1.most_common()[0]
ya2 = c2.most_common()[0]

if ya1[0] == ya2[0]:
    if len(c1.most_common())== 1 and len(c2.most_common()) == 1:
        print(len(v2))
        exit()
    elif ya1[1] == ya2[1]:
        if c1.most_common()[1][1] > c2.most_common()[1][1]:
            ya1 = c1.most_common()[1]
        else:
            ya2 = c2.most_common()[1]
    elif ya1[1] > ya2[1]:
        ya2 = c2.most_common()[1]
    else:
        ya1 = c1.most_common()[1]

print(int(((n/2)-ya1[1]) + ((n/2)-ya2[1])))


Measured memory_bytes: 24652
#include <bits/stdc++.h>
#define ll long long
#define mx 1000000+7
bool a[mx+10];
ll pr[mx], p;

using namespace std;
ll sieve(ll n);
int main()
{
    ll i, j,k, l, m, n;
   while(scanf("%lld", &n)==1)
   {
       if(n == 1)
        m = 0;
       else

       m = sieve(n);
    printf("%lld\n", m);
   }

}
ll sieve(ll n)
{
   ll p = 0;
    ll i, j, k;
    k = sqrt(n);
    pr[p++] = 2;
    for(i = 4; i <= n; i+=2)
        a[i]=1;
    for(i = 3; i <= n; i+=2)
    {
        if(a[i] ==0)
            pr[p++]=i;
        if(i <= k)
            if(a[i] == 0)
        {
            for(j = i*i; j <= n; j+=2*i)
                a[j]=1;
        }
    }
    return p;
}

Measured memory_bytes: 4452
n= int(input())
ans=[0]*(n+1)
v=10**2
for x in range(1,v+1):
    for y in range(1,v+1):
        for z in range(1,v+1):
            cnt=pow(x,2)+pow(y,2)+pow(z,2)+x*y+y*z+z*x
            if cnt<=n:
                ans[cnt]+=1

for i in range(1,n+1):
    print(ans[i])

Measured memory_bytes: 69472
n = int(input())
p = list(map(int, input().split()))
q = sorted(p)
d = []
for i in range(n):
    if p[i] != q[i]:
        d.append((p[i], q[i]))
# print(d)
if len(d) == 0:
    print('YES')
elif len(d) == 2 and d[0][0] == d[1][1] and d[0][1] == d[1][0]:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <unordered_map>

template <class T>
std::vector<T> vec(int len, T elem) { return std::vector<T>(len, elem); }

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

std::vector<int> to[30][4];
std::unordered_map<int, int> dp[30];

int dfs(int v, int b) {
    if (dp[v].count(b)) return dp[v][b];

    auto& ret = dp[v][b];
    if (b == 0) return ret = (v == 0);

    ret = 0;
    for (int d = 0; d < 4; ++d) {
        for (auto u : to[v][d]) {
            if (!((b >> u) & 1)) continue;
            ret += dfs(u, b ^ (1 << u));
            if (u != 0) break;
        }
    }
    return ret;
};

bool solve() {
    int w, h;
    std::cin >> w >> h;
    if (w == 0) return false;

    auto grid = vec(h, vec(w, 0));
    int n = 0;
    for (auto& v : grid) {
        for (auto& x : v) {
            std::cin >> x;

            if (x == 1) {
                x = ++n;
            } else if (x == 2) {
                x = 0;
            } else {
                x = -1;
            }
        }
    }

    for (int sx = 0; sx < h; ++sx) {
        for (int sy = 0; sy < w; ++sy) {
            if (grid[sx][sy] == -1) continue;

            int v = grid[sx][sy];
            for (int d = 0; d < 4; ++d) {
                to[v][d].clear();

                int x = sx, y = sy;

                while (true) {
                    x += dx[d], y += dy[d];
                    if (x < 0 || h <= x || y < 0 || w <= y) break;

                    if (grid[x][y] != -1) {
                        to[v][d].push_back(grid[x][y]);
                    }
                }
            }
        }
    }

    for (int v = 0; v <= n; ++v) dp[v].clear();

    std::cout << dfs(0, (1 << (n + 1)) - 1) << "\n";

    return true;
}

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

    while (solve()) {}

    return 0;
}



Measured memory_bytes: 115628
#include<bits/stdc++.h>
#define V vector
#define VI vector<int>
#define VVI vector<vector<int>>
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define MOD 1000000007
#define INF 1e9
#define F first
#define S second
#define All(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;

int main(void){
    int H,W,A,B;
    cin>>H>>W>>A>>B;
    VI ans(W,-1);
    REP(i,W){
        if(i<A)ans[i]=0;
        else ans[i]=1;
    }


    REP(i,B){
        REP(j,W){
            cout<<ans[j];
        }
        cout<<endl;
    }
    REP(i,H-B){
        REP(j,W){
            cout<<(ans[j]^1);
        }
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 1280
N,M = map(int,raw_input().split())
A = []
T = []
for i in range(0,N):
        a,b = raw_input().split()
        A.append(a)
        A.append(b)
        T.append(A)
        A = []
B = []
S = []
for i in range(0,M):
        c,d = raw_input().split()
        B.append(c)
        B.append(d)
        S.append(B)
        B = []
ans = []
for i in range(0,N):
        for j in range(0,M):
                t = abs(int(T[i][0])-int(S[j][0])) + abs(int(T[i][1])-int(S[j][1]))
                ans.append(t)
                #print t
        print ans.index(min(ans))+1
        ans = []
        

Measured memory_bytes: 2696
import java.util.Scanner;
public class Main {
     public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
       
        long n=sc.nextLong();
        printString(n);
       
      
          
        
        }
        
        
        
        private static void printString(long columnNumber) 
    { 
        // To store result (Excel column name) 
        StringBuilder columnName = new StringBuilder(); 
  
        while (columnNumber > 0) { 
            // Find remainder 
            long rem = columnNumber % 26; 
  
            // If remainder is 0, then a 
            // 'Z' must be there in output 
            if (rem == 0) { 
                columnName.append("z"); 
                columnNumber = (columnNumber / 26) - 1; 
            } 
            else // If remainder is non-zero 
            { 
                columnName.append((char)((rem - 1) + 'a')); 
                columnNumber = columnNumber / 26; 
            } 
        } 
  
        // Reverse the string and print result 
        System.out.println(columnName.reverse()); 
    } 
}

Measured memory_bytes: 35500
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
s = [a, b, c, d, e]
u = []
v = []
ans = 0

for i in range(len(s)):
    if s[i] % 10 == 0:
        ans += s[i]
    else:
        u.append(s[i])
        v.append(s[i] % 10)

if len(v) != 0:
    k = min(v)
    for j in range(len(u)):
        ans += u[j] + 10 - v[j]
        
    ans = ans - 10 + k
print(ans)



Measured memory_bytes: 3064
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main(void) {

	string a, b, c;

	cin >> a >> b >> c;

	transform(a.begin(), a.end(), a.begin(), ::toupper);
	transform(b.begin(), b.end(), b. begin(), ::toupper);
	transform(c.begin(), c.end(), c. begin(), ::toupper);

	cout << a[0] << b[0] << c[0] << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i,n) for(ll i=0;i<n;i++)
using Graph = vector<vector<int>>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

int main(){
    string s;cin>>s;
    int n=s.size();
    string ss,tt;
    rep(i,n){
        if(i%2==0){
            ss+='0';
            tt+='1';
        }
        else {
            ss+='1';
            tt+='0';
        }
    }
    int cnss=0,cntt=0;
    rep(i,n){
        if(ss[i]!=s[i]) cnss++; 
        if(tt[i]!=s[i]) cntt++; 
    }

    int ans=min(cntt,cnss);

    cout<<ans<<"\n";
}


Measured memory_bytes: 768
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
using namespace std;

int main()
{
    int n,t,flag=1;
    cin>>n;
    while(n--)
    {
        cin>>t;
        if(t%2==0&&t%3!=0&&t%5!=0) flag=0;
    }
    if(flag) cout<<"APPROVED\n";
    else cout<<"DENIED\n";
    return 0;
}


Measured memory_bytes: 256
require 'set'
H, W = gets.split.map(&:to_i)
C = 10.times.map{
	gets.split.map(&:to_i)
}
A = $<.read.split.map(&:to_i)

Q, R = [*0..9].product([*0..9]).map{|i,j|
	C[i][j]<<8 | i<<4 | j
}.sort, []
while 0
	cij = (
		if Q.empty?
			R.shift
		elsif R.empty?
			Q.shift
		elsif R[0] < Q[0]
			R.shift
		else # Q[0] < R[0]
			Q.shift
		end
	)
	break unless cij

	c, i, j = cij>>8, cij>>4&0xF, cij&0xF
	next if i == j
	next if C[i][j] < c

	C[i][j] = c
	(0..9).each{|k|
		R.push (c+C[j][k])<<8 | i<<4 | k if c+C[j][k] < C[i][k]
	}
end

p A.reject{|a| a == -1 }.map{|a| C[a][1] }.inject(:+)


Measured memory_bytes: 5044
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
using namespace std;

struct Edge{
    int to, cap, rev;
    Edge(int t, int c, int r):to(t), cap(c), rev(r) {}
};

void AddEdge(int fr, int to, int cap, vector<vector<Edge> >& gr)
{
    gr[fr].push_back( Edge(to, cap, gr[to].size()) );
    gr[to].push_back( Edge(fr, 0, gr[fr].size()-1) );
}

int dfs(int v, int G, int f, vector<vector<Edge> >& gr, vector<int>& used )
{
    if(v==G) return f;
    used[v]=1;
    auto it = gr[v].begin();
    for(; it!=gr[v].end(); ++it) {
        if(!used[it->to] && it->cap>0) {
            int d = dfs( it->to, G, MIN(f, it->cap), gr, used);
            if(d>0) {
                it->cap -= d;
                gr[it->to][it->rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

int max_flow( int S, int G, vector<vector<Edge> >& g)
{
    int flow=0;
    while(1) {
        vector<int> used(g.size(), 0);
        int f = dfs(S, G, INF, g, used);
        if(f==0) break;
        flow += f;
    }
    return flow;
}

char str[100][105];

int main(int argc, char* argv[])
{
    int h,w;
    scanf("%d%d", &h, &w);

    int i,j;
    int s0,s1,t0,t1;
    for(i=0; i<h; i++) {
        scanf("%s", str[i]);
        for(j=0; j<w; j++) {
            if(str[i][j]=='S') {
                s0=i; s1=j;
            }
            if(str[i][j]=='T') {
                t0=i; t1=j;
            }
        }
    }
    if(s0==t0 || s1==t1) {
        printf("-1\n"); return 0;
    }

    vector<vector<Edge> > gr(h+w);

    for(i=0; i<h; i++) {
        for(j=0; j<w; j++) {
            if(str[i][j]=='o') {
                int j2=j+h;
                if(j==s1) j2=s0;
                if(j==t1) j2=t0;
                AddEdge(i, j2, 1, gr);
                AddEdge(j2, i, 1, gr);
            }
        }
    }
 
    int f = max_flow( s0, t0, gr);
    printf("%d\n", f);
 
    return 0;
}



Measured memory_bytes: 896
s = list(input())

for i in range(len(s)): # start from 0
  if ((i+1)%2 == 0) and s[i] == "R": #Even
    print("No")
    exit()
  elif ((i+1)%2 == 1) and s[i] == "L": #Odd
    print("No")
    exit()

    
print("Yes")
   

Measured memory_bytes: 38256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc *bufio.Scanner = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}()

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	n := nextInt()
	s := nextString()
	rns := []rune(s)
	if n%2 == 0 && string(rns[:n/2]) == string(rns[n/2:]) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 640
#include <iostream>
#include <cmath>
#include <iomanip>
#include <cstdio>

using namespace std;

typedef unsigned long long int ulli;
typedef long long int lli;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

    int N, M;
    cin >> N >> M;
    int maxL;
    int minR;
    int tempL, tempR;
    cin >> maxL >> minR;
    for (int i = 1; i < M; ++i)
    {
        cin >> tempL >> tempR;
        maxL = MAX(maxL, tempL);
        minR = MIN(minR, tempR);
    }

    cout << MAX(minR - maxL + 1, 0) << "\n";

    return 0;
}



Measured memory_bytes: 256
from collections import deque
import heapq
N,K=map(int,input().split())
V=list(map(int,input().split()))
ans=0
  
for i in range(0,min(N,K)+1):
  for a in range(i+1):
    b=i-a
    
    l=0
    d=deque(V)
    minus=[]
    
    for j in range(a):
      p=d.popleft()
      l+=p
      if p<0:
        minus.append(p)
    for j in range(b):
      p=d.pop()
      l+=p
      if p<0:
        minus.append(p)
    heapq.heapify(minus)
    for j in range(min(len(minus),K-i)):
      k=heapq.heappop(minus)
      l-=k
    #print(a,b,l)
    ans=max(ans,l)
    
print(ans)

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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q>
ostream& operator << (ostream& os, pair<P, Q> p)
{
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  lli n;
  while (cin >> n) {
    auto f = [&] (lli a, lli b) {
      return max<lli>(to_string(a).size(), to_string(b).size());
    };
    lli mn = f(1, n);
    for (lli i = 1; i * i <= n; ++i) {
      if (n % i == 0) {
        lli j = n / i;
        mn = min(mn, f(i, j));
      }
    }
    cout << mn << endl;
  }
  return 0;
}


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

int main() {
  int n, k;
  cin >> n >> k;
  ll ans = k;
  for (int i = 1; i<n; i++) ans *= k-1;
  cout << ans << endl;
}

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

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		
		int counter = scanner.nextInt();
		int[] odd = new int[100001];
		int[] even = new int[100001];
		
		boolean bool = true;
		for(int i = 0;i<counter;i++) {
			if(bool) odd[scanner.nextInt()]++;
			else even[scanner.nextInt()]++;
			bool = !bool;
		}
		
		int a=0,b=0,c=0,d=0;
		
		for(int i = 0;i<100001;i++) {
			if(odd[i] > a) {
				a = odd[i];
				b = i;
			}
			if(even[i] > c) {
				c = even[i];
				d = i;
			}
		}
		
		bool = b == d;
		
		Arrays.sort(odd);
		Arrays.sort(even);
		
		if(!bool) {
			System.out.println(counter - odd[100000] - even[100000]);
		}else {
          System.out.println(Math.min(counter - odd[100000] - even[99999],counter - odd[99999] - even[100000]));
		}
	}
}

Measured memory_bytes: 61856
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
//ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
int main() {
	int n, m, a, b, c = 0;
	cin >> n >> m;
	vector<vector<int>> g(n);
	vector<int> t(n);
	vector<pair<int, int>> bridge(m);
	rep(i, 0, m)cin >> a >> b, g[a - 1].push_back(b - 1), g[b - 1].push_back(a - 1)
		, bridge[i] = make_pair(a - 1, b - 1);
	deque<int> path;
	rep(i, 0, m) {
		bool ok = true;
		rep(i2, 0, n)t[i2] = 0;
		t[bridge[i].first] = 1;
		for (auto v : g[bridge[i].first]) {
			if (v == bridge[i].second)continue;
			path.push_back(v);
		}
		while (path.size()) {
			int pos = path.front();
			if (pos == bridge[i].second) {
				ok = false;
				while(path.size())path.pop_back();
				break;
			}
			path.pop_front();
			for (auto v : g[pos]) {
				if (t[v])continue;
				t[v] = 1;
				path.push_back(v);
			}
		}
		if (ok) {
			c++;
		}
	}
	printf("%d\n", c);
	return 0;
}


Measured memory_bytes: 256
/* << IN THE NAME OF GOD >> */
#include <bits/stdc++.h>
using namespace std;



#define err(x) cerr << #x  << " = "<<  x << '\n'
#define out(x) cout << x << '\n'
#define forp(i, r, l) for(int i = int(r); i < int(l); i++)
#define forn(i, r, l) for(int i = int(r); i > int(l); i--)
#define FAST ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll ,ll> pll;
const int maxn = 1e6 + 120;
 


int n ,a[maxn] ,res ,x ,mid;

int main(){FAST;
    cin >> n;
    forp(i ,0 ,n)
        cin >> a[i];

    sort(a ,a + n);

    if(a[n -1] & 1)mid++;

     mid += (a[n - 1] >> 1);

    int ans = INT_MAX;
        forp(i ,0 ,n)    
            if(abs(a[i] - mid) < ans)
                    ans = abs(a[i] - mid) ,res = a[i];
    cout << a[n - 1] << " ";
    


    cout << res;
   return 0;
}
 












Measured memory_bytes: 640
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main() {
	ll N;
	cin >> N;
	ll b, c;
	ll x = -1, y = -1, z = -1;
	for (b = 1; b <= 3500; ++b) {
		for (c = 1; c <= 3500; ++c) {
			if (4 * b * c - b * N - N * c>0 && N*b*c % (4 * b*c - b * N - N * c) == 0) {
				x = N * b*c / (4 * b*c - b * N - N * c);
				y = b;
				z = c;
			}
		}
	}
	cout << x << " " << y << " " << z << endl;
}








Measured memory_bytes: 384
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n;
   string a,b,c="";
   cin>>n>>a>>b;
   for(int i=0;i<n;i++)
   {
       c=c+a[i]+b[i];
   }
   cout<<c<<"\n";
}

Measured memory_bytes: 3604
def main():
    s = input()
    t = input()
    s_list = []
    t_list = []
    for i in range(len(s)):
        s_list.append(s[i])
    for i in range(len(t)):
        t_list.append(t[i])
    s_list.sort()
    t_list.sort(reverse = True)
    #print(s_list,t_list)
    #if 'a'<'b':
        #print ('Yes')
    s_l = len(s_list)
    t_l = len(t_list)
    if s_l >= t_l:
        ans = 'No'
    else:
        ans = 'Yes'

    for i in range(min(s_l,t_l)):
        if s_list[i] == t_list[i]:
            continue
        elif s_list[i] > t_list[i]:
            return ('No')
        else:
            return('Yes')

    return ans

print(main())


Measured memory_bytes: 9144
#include <iostream>

using namespace std;

int main() {
	int x1, x2, y1, y2;
	int x3, x4, y3, y4;

	cin >>  x1 >> y1 >> x2 >> y2;

	// 法線
	int normalVectorA = -(y2 - y1);
	int normalVectorB = x2 - x1;

	x3 = x2 + normalVectorA;
	y3 = y2 + normalVectorB;

	x4 = x1 + normalVectorA;
	y4 = y1 + normalVectorB;

	cout << x3 << " " << y3 << " " << x4 << " " << y4;

	return 0;
}

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

int main(){
	int a,b;
	cin>>a>>b;
	if(a>=13)cout<<b<<endl;
	else if(a>=6&&a<=23)cout<<b/2<<endl;
	else if(a<=5)cout<<0<<endl;
	return 0;
} 

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
const long long mod=1e9+7;
long long n,a[111111],k;
long long ex[111111],cn[111111],ck[111111],hi,lo;
long long binpow(long long a,long long n)
{
	long long res=1,p=a;
	for (long long i=n;i;i>>=1)
	{
		if (i&1) res=res*p%mod;
		p=p*p%mod;
	}
	return res;
}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n+1;i++) 
	scanf("%d",&a[i]);
	for (int i=1;i<=n+1;i++)
	{
		if (ex[a[i]])
		{
			k=ex[a[i]]+n-i;
			break;
		}
		ex[a[i]]=i;
	}
	cn[0]=ck[0]=1;
	for (long long i=1;i<=n+1;i++)
	{
		cn[i]=(cn[i-1]*(n-i+2)%mod)*binpow(i,mod-2)%mod;
	}
	for (long long i=1;i<=k;i++)
	{
		ck[i]=(ck[i-1]*(k-i+1)%mod)*binpow(i,mod-2)%mod;
	}
	for (int i=1;i<=n+1;i++)
	{
		long long res=cn[i]-ck[i-1];
		if (res<0) res+=mod;
		cout<<res<<endl;
	}
	return 0;
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define MEM 1000
#define sanic ios_base::sync_with_stdio(0)
using namespace std;
long long t,r;
string s;
deque<char> q;
int main()
{
    sanic;
    cin >> s;
    for(int i=0; i<s.size(); i++)
        q.push_back(s[i]);
    cin >> t;
    while(t--){
        int q3;
        cin >> q3;
        if(q3==1)
            r = (r+1)%2;
        else{
            int q1;
            char q2;
            cin >> q1 >> q2;
            if(q1==1){
                if(r)q.push_back(q2);
                else q.push_front(q2);
            }
            else{
                if(r)q.push_front(q2);
                else q.push_back(q2);
            }
        }
    }
    if(r)
        while(!q.empty()){
            cout << q.back();
            q.pop_back();
        }
    else
        while(!q.empty()){
            cout << q.front();
            q.pop_front();
        }
}


Measured memory_bytes: 976
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        long A=sc.nextLong();
        long B=sc.nextLong();
        long N=sc.nextLong();
        if( N >= B -1){
            p( (A * (B-1) )/ B );
        }
        else{
            p( (A * (N) )/ B );
        }
    }
    public static void p(Object o){
        System.out.println(o);
    }
}


Measured memory_bytes: 35852
#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 n, m;
  cin >> n >> m;
  vector<int> a(m), b(m);
  rep(i,m) cin >> a[i] >> b[i];
  bool check[200100];
  for(int i=1; i<=200000; i++) check[i] = false;
  for(int i=0; i<m; i++){
    if(b[i]==n) check[a[i]] = true;
  }
  for(int i=0; i<m; i++){
    if(a[i]==1){
      if(check[b[i]]){
        cout << "POSSIBLE" << endl;
        return 0;
      }
    }
  }
  cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 2048