akhauriyash/Code-Regression huggingface dataset:
n = int(input())
a = list(map(int, input().split()))
b = a[::-1]

if n == 0 and a[0] == 1:
    print(1)
    exit()

if a[0] >= 1:
    print(-1)
    exit()
    
ans = [0] * (n + 1)
for i in range(n):
    ans[i + 1] = ans[i] + b[i]

ans = ans[::-1]

ans = ans[1::]
a = a[1::]

res = 1
prev_cnt = 1

for i in range(n):
    cnt = min(prev_cnt * 2, ans[i] + a[i])
    if cnt < a[i]:
        print(-1)
        exit()
    res += cnt
    prev_cnt = cnt - a[i]
print(res)


Measured memory_bytes: 83324
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

const ll MOD = 1000000007;

ll modpow(ll x, ll n){
    ll res = 1;
    ll mul = x;
    while(n){
        if(n % 2) res = res * mul % MOD;
        mul = mul * mul % MOD;
        n /= 2;
    }
    return res;
}

struct Combination
{
    int maxn;
    vector<ll> fmemo;
    vector<ll> imemo;
    vector<ll> ifmemo;
    
    Combination(int maxn) : maxn(maxn){
        fmemo.resize(maxn + 1);
        imemo.resize(maxn + 1);
        ifmemo.resize(maxn + 1);
        for(ll i = 1; i <= maxn; i++){
            imemo[i] = modpow(i, MOD - 2);
        }
    }

    ll fact(ll n){
        if(n == 0) return 1;
        if(fmemo[n]) return fmemo[n];
        return fmemo[n] = n * fact(n - 1) % MOD;
    }

    ll ifact(ll n){
        if(n == 0) return 1;
        if(ifmemo[n]) return ifmemo[n];
        return ifmemo[n] = imemo[n] * ifact(n - 1) % MOD;
    }

    ll com(ll n, ll k){
        if(k < 0) return 0;
        if(k > n) return 0;
        if(k == n || k == 0) return 1;
        return (fact(n) * ifact(k) % MOD) * ifact(n - k) % MOD;
    }
};

int main()
{
    ll n, k;
    cin >> n >> k;
    ll a[100002];
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n, greater<ll>());
    ll m = 0;
    Combination c(n + 1);
    for(int i = 0; i < n; i++){
        m = (m + (c.com(n - i, k) + MOD - c.com(n - i - 1, k)) % MOD * a[i] % MOD) % MOD;
        m = (m + MOD - (c.com(i + 1, k) + MOD - c.com(i, k)) % MOD * a[i] % MOD) % MOD;
    }
    cout << m << endl;
}

Measured memory_bytes: 5760
import numpy as np
n = int(input())
al = np.zeros(n)
bl = np.zeros(n)
for i in range (n):
    al[i],bl[i] = map(int,input().split())
id = [*range(n)]
s=al+bl
id = sorted(id, key=lambda i: -s[i])
s=np.sort(s)
ans = 0 
for i in range(n):
    if i%2==0:
        ans+=al[id[i]]
    else:
        ans-=bl[id[i]]
print(int(ans))

Measured memory_bytes: 38704
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

long long a[87];

void func( int i ) {
    a[i] = a[i-1]+a[i-2];
    
    if ( i == 87 ) { return; }
    
    func(i+1);
}

int main() {
    
    int N;
    cin >> N;
    
    a[0] = 2; a[1] = 1;
    func(2);
    
    cout << a[N] << endl;
    
    return 0;
}

Measured memory_bytes: 256
faces = gets.split
q = gets.to_i

# right_side_finder
rsf = [[1, 2, 4, 3], [0, 3, 5, 2], [0, 1, 5, 4]]
3.upto(5) {|i| rsf[i] = rsf[5 - i].reverse }

q.times do
	top, front = gets.split.map{|i| faces.index(i)}

	side_seq = rsf[top]
	index = side_seq.index(front)

	puts faces[side_seq[(index + 1) % 4]]
end

Measured memory_bytes: 8616
#include <bits/stdc++.h>
#include <string>
#include <vector>
/* 変数i を n回繰り返すマクロ */
#define rep(i,n) for (int i = 0;i < (n);i++)
typedef long long ll;
using namespace std;
int main()
{
    cout << fixed << setprecision(10);//小数点以下10桁出力
    char c;
    cin >> c;
    cout << (char)(c + 1) << endl;
    return 0;
}

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

int a[100005];
int c[2];
int main()
{
    int n;

    cin >> n;

    for(int i = 1 ; i<=n ; i++)
    {
        cin >> a[i];
    }

    sort(a+1 , a+n+1);

    int j = 0;

    for(int i = n-1 ; i>=1 ; )
    {
        if(a[i]==a[i+1])
        {
            c[j++] = a[i];
            i--;
            if(j==2)
            {
                break;
            }
        }
        i--;
    }
    cout << 1ll*c[0]*c[1];
    return 0;
}


Measured memory_bytes: 640
//** aman**/
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define dl          double
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define lb lower_bound
#define ub upper_bound
#define bs          binary_search
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
int main(){
	ll x,y,z,k;cin>>x>>y>>z>>k;
	vi v1(x),v2(y),v3(z),v,vv;
	for(ll i=0;i<x;i++)cin>>v1[i];sort(all(v1),greater<ll>());
	for(ll i=0;i<y;i++)cin>>v2[i];sort(all(v2),greater<ll>());
	for(ll i=0;i<z;i++)cin>>v3[i];sort(all(v3),greater<ll>());
	for(ll i=0;i<x;i++){
		for(ll j=0;j<y;j++){
			v.pb(v1[i]+v2[j]);
		}
	}
	sort(all(v),greater<ll>());
	if(v.size()>k)
	v.resize(k);
	for(ll i=0;i<v.size();i++){
		for(ll j=0;j<z;j++){
			vv.pb(v[i]+v3[j]);
		}
	}
	sort(all(vv),greater<ll>());
	for(ll i=0;i<k;i++)cout<<vv[i]<<endl;
}

Measured memory_bytes: 43240
#include<cstdio>
#include<cstring>
#include<cmath>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define FOR(i,a,b) for(int i = a;i < b;i++)
#define MEM(a,b) memset(a,b,sizeof(a))
#define ALL(x) (x).begin(),(x).end()
#define LMAX 9223372036854775807
#define LMIN -9223372036854775808

using namespace std;

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

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) {}
	void unionSet(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x])swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	int k = a % b;
	if (k == 1)return 1;
	if (k == 0)return b;
	int ans = gcd(b, k);
	return ans;
}
ll digisum(ll a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}
ll countpow(ll a, ll b) {
	int ans = 0;
	if (b == 0)return -1;
	while (1) {
		if (a % b == 0) {
			a /= b;
			ans++;
		}
		else break;
	}
	return ans;
}


int main() {
	IOS;
	string s, ans = "";
	cin >> s;
	REP(i, s.size()) {
		if (i % 2 == 0)ans = ans + s[i];
	}
	cout << ans << endl;
}



Measured memory_bytes: 656
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long int
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define pci pair<char,int
#define mii map<int,int>
#define mll map<long long int,long long int>
#define mci map<char,int>
#define umii unordered_map<int,int>
#define umll unordered_map<long long int,long long int>
#define umci unordered_map<char,int>
#define F first
#define S second
#define pb push_back
#define endl '\n'
#define mod 1000000007
using namespace std;
#define maxval 10003000

int main(){
   IOS;
ll t;t=1;//cin>>t;

while(t--){
ll n;cin>>n;
string s;cin>>s;map<string,ll> m;
  for(ll i=2;i<n;i++){
  string a;
    a.pb(s[i-2]);
    a.pb(s[i-1]);
    a.pb(s[i]);
    m[a]++;
  }
  string g="ABC";
  cout<<m[g];

    
} 
    

    
return 0;    
}


Measured memory_bytes: 3632
// Ivan Carvalho
// Problem R - Educational Dynamic Programming Contest - AtCoder
// Link : https://atcoder.jp/contests/dp
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

const int MAXN = 50;
const int MOD = 1e9 + 7;

struct matrix{

	ll mat[MAXN][MAXN];

	matrix(int idd = 0){
		for(int i = 0;i<MAXN;i++){
			for(int j = 0;j<MAXN;j++){
				mat[i][j] = (idd) ? (i == j) : (0);
			}
		}
	}

	matrix operator*(const matrix& other)const{
		matrix ans;
		for(int i = 0;i<MAXN;i++){
			for(int j = 0;j<MAXN;j++){
				for(int k = 0;k<MAXN;k++){
					ans.mat[i][j] += mat[i][k]*other.mat[k][j];
					if(ans.mat[i][j] > MOD) ans.mat[i][j] %= MOD;
				}
			}
		}
		return ans;
	}

};

matrix exponentiation(matrix base, ll K){

	matrix ans(1);

	for(int i = 0;(1LL << i) <= K;i++){
		if((1LL << i) & K) ans = ans*base;
		base = base*base;
	}

	return ans;

}

int main(){

	matrix base;
	int N;
	ll K;
	cin >> N >> K;
	for(int i = 0;i<N;i++){
		for(int j = 0;j<N;j++) cin >> base.mat[i][j];
	}

	matrix ans = exponentiation(base,K);
	ll paths = 0;
	for(int i = 0;i<N;i++){
		for(int j = 0;j<N;j++){
			paths = (paths + ans.mat[i][j]) % MOD;
		}
	}

	cout << paths << endl;

	return 0;

}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e9;
const int mod = 1e9+7;
#define ll long long
int dp[100100];
int cnt = 0;
signed main() {
  string str;
  rep(i,3){
    cin >> str;
    cout << str[i] << flush;
  }
  cout << "" << endl;



  return 0;
}

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

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

    ll n; cin >> n;
    string ans = "";

    while (n) {
        n--;
        ans += (char)('a' + (n%26));
        n /= 26;
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;

    return 0;
}


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

typedef long long lli;
typedef complex<lli> P;

bool check(lli x) {
  if(x < 0 || x >= (1<<10)) {
    throw 0;
  }
}

lli toDec(string bs) {
  lli res = 0;
  reverse(bs.begin(), bs.end());
  for(lli i = 0; i < bs.size(); ++i) {
    res |= ((lli)(bs[i] - '0')) << i;
    check(res);
  }
  return res;
}

lli p;
string s;
P exp();
P term();
P fact();

P exp() {
  P x = term();
  while(1) {
    if(s[p] == '+') {
      ++p;
      x += term();
      x.imag() += 1;
    } else if(s[p] == '-') {
      ++p;
      x -= term();
      x.imag() += 1;
    } else {
      break;
    }
    check(x.real());
  }
  return x;
}

P term() {
  P x = fact();
  while(1) {
    if(s[p] == '*') {
      ++p;
      P y = fact();
      x.real() *= y.real();
      x.imag() += y.imag() + 1;
    } else {
      break;
    }
    check(x.real());
  }
  return x;
}

P fact() {
  P x;
  if(s[p] == '(') {
    ++p;
    x = exp();
    if(x.imag() == 0) throw 0;
    x.imag() = 0;
    if(s[p] != ')') throw 0;
    ++p;
  } else if(isdigit(s[p])) {
    string num;
    while(isdigit(s[p])) {
      num += s[p++];
    }
    x = P(toDec(num), 0);
  } else {
    throw 0;
  }
  return x;
}

const string C = "01+-*()";

lli rec(int k) {
  if(k == s.size()) {
    lli res = -1;
    try {
      p = 0;
      lli tmp = exp().real();
      if(s[p] != '$') throw 0;
      res = tmp;
    } catch(...) {}
    return res;
  } else {
    if(s[k] == '.') {
      lli res = -1;
      for(int i = 0; i < C.size(); ++i) {
        s[k] = C[i];
        res = max(res, rec(k + 1));
      }
      s[k] = '.';
      return res;
    } else {
      return rec(k + 1);
    }
  }
}

int main() {
  while(cin >> s) {
    s += "$";
    cout << rec(0) << endl;
  }
  return 0;
}

Measured memory_bytes: 1264
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
using namespace std;

bool is_int(vector<int> a, vector<int> b, int d) {
    vector<int> temp(d);
    int total = 0;
    rep(i, d) {
        temp[i] = a[i] - b[i];
        temp[i] *= temp[i];
        total += temp[i];
    }

    bool ans = false;

    rep(i, total + 1) {
        if(i * i == total) {
            ans = true;
        }
    }

    return ans;
}

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

    vector<vector<int>> x(n, vector<int>(d));
    rep(i, n) {
        for(int j = 0; j < d; ++j) {
            cin >> x[i][j];
        }
    }

    int ans = 0;
    rep(i, n) {
        for(int j = i + 1; j < n; ++j) {
            if(is_int(x[i], x[j], d)) {
                ans++;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(int i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	ll a; cin >> a;
	print(a + a * a + a*a*a)
	
	return 0;
}

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

int main(){
  string s;
  cin>>s;
  if(s[0]==s[2]){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl
#define INF 1000000;
#include <map>
#include <math.h>
 
using ll = long long;
using namespace std;

const ll mod = 1000000007;


int main(){
    string s;
    cin >> s;
    int n = s.size();
    int first_end = (n-1)/2, second_start=(n+3)/2+1;
    bool flag=true;
    rep(i, n/2){
        if(s[i]!=s[n-1-i]) flag=false;
    }

    rep(i, first_end/2){
        if(s[i]!=s[first_end-1-i]) flag=false;
    }


    if(flag==false) out("No");
    else out("Yes");
   }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n,a[100];
	cin>>n;
	for(ll i=0;i<n;i++){
		cin>>a[i];
	}
	ll ans=INF;
	for(ll i=1;i<=100;i++){
		ll cnt=0;
		for(ll j=0;j<n;j++){
			cnt+=(a[j]-i)*(a[j]-i);
		}
		ans=min(cnt,ans);
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
sum  = 1
flag = 0
for i in A:
    if(i == 0):
        print(0)
        flag=2
        break
if(flag==0):
    for i in A:
        sum = sum * i
        if(sum > 10**18):
            flag=1
            break
if(flag==0):
    print(sum)
elif(flag==1):
    print(-1)


Measured memory_bytes: 21672
#pragma GCC optimize("O3") 
#include<bits/stdc++.h>
#define ll      				long long int
#define vi      				vector<int>
#define ii      				pair<int,int>
#define iii     				pair<ii,int>
#define iiii    				pair<ii,ii>
#define fi      				first
#define se      				second
#define unord_map				unordered_map
#define nxt_pmt					next_permutation
#define clr					clear()
#define ALL(x) 					x.begin(),x.end()


#define pb      				push_back
#define pob     				pop_back

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

#define db(x)					  cout << "!!!!!! " << #x << " => " << x << "\n"

#define fori(i, s, N)     for (int i = s; i <= N; i++)
#define ford(i, s, N)     for (int i = s; i >= N; i--)
using namespace std;

void init(int precision){
  	ios_base::sync_with_stdio(0);
  	cin.tie(0);
  	cout.tie(0);
  	cout.setf(ios::fixed);
  	cout.setf(ios::showpoint);
  	cout.precision(precision);
}

int t;
void cjam(int z){
	cout<<"Case #"<<z<<": ";
	
}
string s;
int main(){
//	init(10);
	cin>>s;
	cout<<((s == "ABC") ? "ARC" : "ABC")<<"\n";
	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

typedef pair<ll,ll> P;
const ll MOD = 1e9+7;

int main(){
  ll N; cin >> N;
  vector<P> ab;
  REP(i,N){
    ll a; cin >> a;
    ab.push_back(make_pair(a,0));
  }
  REP(i,N){
    ll b; cin >> b;
    ab.push_back(make_pair(b,1));
  }
  sort(ALL(ab));
  vector<ll> cnt(2,0);
  ll ans = 1;
  REP(i,2*N){
    ll type = ab[i].second;
    if(cnt[type^1] == 0){
      cnt[type]++;
      continue;
    } 
    (ans *= cnt[type^1] ) %= MOD;
    cnt[type^1]--;
  }
  cout << ans << endl;
}


Measured memory_bytes: 6128
n = gets.chomp.to_i
a = gets.chomp.split.map(&:to_i)

a.sort!.reverse!
alice = 0
bob = 0
a.each.with_index(1) do |b, index|
  if index.odd?
    alice += b
  else
    bob += b
  end
end
p alice - bob


Measured memory_bytes: 1788
a, b, c, x, y = map(int, input().split())
 
ans = float('inf')
for i in range(max(x, y)+1):
    p = 2*c*i + max(0, (x-i))*a + max(0, (y-i))*b  #; print(i, p)
    ans = min(p, ans)

print(ans)


Measured memory_bytes: 8964
while True:
    h, w = map(int, input().split())
    if h == 0 and w == 0:
        break
    for i in range(h):
        if i == 0:
            print('#'*w)
        elif i == h-1:
            print('#'*w)
        else:
            print('#'+'.'*(w-2)+'#')
    print()


Measured memory_bytes: 5608
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <utility>
using namespace std;
typedef long long ll;

int par[200010],sz[200010];
void init(int n){
	for(int i=0;i<n;i++){
		par[i] = i; sz[i] = 1;
	}
}

ll find(ll x){
	if(par[x]==x) return x;
	return par[x] = find(par[x]);
}

void unite(ll x, ll y){
	x = find(x); y = find(y);
	if(x==y) return;
	if(sz[x]<sz[y]) swap(x,y);
	par[y] = x; sz[x] += sz[y];
}

bool same(ll x, ll y){
	return find(x)==find(y);
}
typedef pair<ll,pair<ll,ll>> P;
priority_queue<P,vector<P>,greater<P>> que;
int main(){
	int i,n,q;
	cin >> n >> q;
	init(n);
	for(i=0;i<q;i++){
		ll a,b,c; cin >> a >> b >> c;
		que.push({c,{a,b}});
		que.push({c + 1,{(a + 1)%n,b}});
	}
	ll res = 0;
	while(que.size()){
		P p = que.top();
		que.pop();
		ll u = p.second.first,v = p.second.second;
		if(same(u,v)) continue;
		unite(u,v); res += p.first;
		p.first += 2; (p.second.first += 1) %= n; (p.second.second += 1) %= n;
		que.push(p);
	}
	cout << res << endl;
}
	

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

int main() {
	int c[3][3];
  	vector<int> mina(3,101);
  	for(int i=0;i<3;i++){
      for(int j=0;j<3;j++){
    		cin>>c[i][j];
        	mina[i]=min(mina[i],c[i][j]);
    	}
    }
  
  for(int a1=0;a1<=mina[0];a1++){//1行目
    	int b1=c[0][0]-a1,b2=c[0][1]-a1,b3=c[0][2]-a1;
  	  		int a2=c[1][0]-b1;
        if(a2>=0 && a2<=mina[1] && (c[1][1]-b2)==a2 &&  (c[1][2]-b3)==a2){//2行目
        	int a3=c[2][0]-b1;
          	if(a3>=0 && a3<=mina[2] && (c[2][1]-b2)==a3 &&  (c[2][2]-b3)==a3){
            	cout<<"Yes"<<endl;
              	return 0;
            } 
        } 
  }
  cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));

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

	int N;
	cin>>N;
	queue <int> Q;
	int A=N;
	eFOR(i,1,N){
		Q.push(i);
		A-=i;
		if(A<=0){
			A*=-1;
			//Q.erase(A);
			break;
		}
	}
	while(!Q.empty()){
		if(A!=Q.front())
		cout<<Q.front()<<endl;
		Q.pop();
	}
	return 0;
}

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


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

typedef long long ll;
const ll INF = 1e18;
const int BIG = 1e9 + 555;

int a;
string s;

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

	cin >> a;
	cin >> s;

	if(a >= 3200){
		cout << s << '\n';
	} else {
		cout << "red\n";
	}


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pii pair<int, int>;
#define ss second
#define ff first
#define all(x) ((x).begin(), (x).end())

using namespace std;
using ll = long long;

const int mod = 1e9 + 7;
const ll oo = 1 << 31;

int main(void){
    ll n, ans = 1;
    cin >> n;
    for (ll i=1; i<=n; i++){
        ans*=i;
        ans%=mod;
    }
    cout << ans << endl;
return 0;
}

Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.Queue;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        char[] cs = s.toCharArray();
        int result = 0;
        Queue<Character> q = new ArrayDeque<>(3);
        for(int i=0;i<=9;i++){
            for(int j=0;j<=9;j++){
                for(int k=0;k<=9;k++){
                    q.clear();
                    q.add((char)(48+i));
                    q.add((char)(48+j));
                    q.add((char)(48+k));
                    for(char c : cs){
                        if(c != q.peek()) continue;
                        q.poll();
                        if(q.isEmpty()){
                            result++;
                            break;
                        }
                    }
                }
            }
        }
        System.out.println(result);
    }
}

Measured memory_bytes: 23636
import java.io.*;

class Main {
	public static void main(String[] args) {
		BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) );
		try {

			String str = kb.readLine();
			String[] tmpArray = str.split( " " );
			int n=Integer.parseInt( tmpArray[0] );
			int m=Integer.parseInt( tmpArray[1] );
			int l=Integer.parseInt( tmpArray[2] );
						
			int[][] matrixA = new int[n][m];
			int[][] matrixB = new int[m][l];
			double[][] matrixC = new double[n][l];
			for( int i=0; i<n; i++ ) {
				str = kb.readLine();
				tmpArray = str.split( " " );
				for( int j=0; j<m; j++ ) {
					matrixA[i][j]=Integer.parseInt( tmpArray[j] );
				}
			}
			for( int i=0; i<m; i++ ) {
				str = kb.readLine();
				tmpArray = str.split( " " );
				for( int j=0; j<l; j++ ) {
					matrixB[i][j]=Integer.parseInt( tmpArray[j] );
				}
			}

			for( int i=0; i<n; i++ ) {
				for( int k=0; k<m; k++ ) {
					for( int j=0; j<l; j++ ) {
						matrixC[i][j]+=matrixA[i][k]*matrixB[k][j];
					}
				}
			}
			
			for( int i=0; i<n; i++ ) {
				for( int j=0; j<l; j++ ) {
					if( l-1 != j ) {
						System.out.printf( "%.0f ", matrixC[i][j] );
					} else {
						System.out.printf( "%.0f\n", matrixC[i][j] );
					}
				}
			}
			
		} catch( IOException e ) {
			System.err.println( e );
		}
	}
}

Measured memory_bytes: 46140
#include "bits/stdc++.h"
using namespace std;
#define ASC(vec) vec.begin(), vec.end()			// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(i = 0; i < n; i++)
const long long INF = 1LL << 60;
typedef long long ll;

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

	tuple<int, int, int> pairs[101000];

	for (int i = 0; i < M; i++)
	{
		int p, y;
		cin >> p >> y;

		pairs[i] = make_tuple(y , p, i);
	}

	sort(pairs, pairs + M);

	map<int, int> m;
	pair<int, int> id[101000];

	for (int i = 0; i < M; i++)
	{
		int y = get<1>(pairs[i]);
		int idx = get<2>(pairs[i]);
		int num;

		m[y]++;

		id[idx] = make_pair(y, m[y]);
	}

	for (int i = 0; i < M; i++)
	{
		cout << setfill('0');
		cout << setw(6) << id[i].first << setw(6) << id[i].second << endl;
	}
}


Measured memory_bytes: 8192
import java.math.BigInteger;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.TreeMap;
import java.util.*;
import java.util.Map.Entry;

public class Main {
	static int mod = (int) 1e9 + 7;

	static long sumIncreasing(int[] a, int[] w) {
		long maxSum = Integer.MIN_VALUE;
		TreeMap<Integer, Long> sums = new TreeMap<>();
		for (int i = 0; i < a.length; i++) {
			Entry<Integer, Long> lowerSum = sums.lowerEntry(a[i]);
			long sum = (lowerSum != null ? lowerSum.getValue() + w[i] : w[i]);
			sums.put(a[i], sum);
			for (Entry<Integer, Long> e; (e = sums.higherEntry(a[i])) != null && e.getValue() <= sum;)
				sums.remove(e.getKey());
			if (sum > maxSum)
				maxSum = sum;
		}
		return maxSum;
	}

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
		int a[]=new int[n];
		for(int i=0;i<n;i++){
			a[i]=scn.nextInt();
		}
		int wt[]=new int[n];
		for(int i=0;i<n;i++){
			wt[i]=scn.nextInt();
		}
		
		System.out.println(sumIncreasing(a, wt));

	}

}

Measured memory_bytes: 114756
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;

fn dfs(i: usize, prev: usize, edges: &Vec<Vec<usize>>, d: usize) -> (usize, usize) {
    let mut ret = (d, i);
    for &next in edges[i].iter() {
        if next != prev {
            let next_ret = dfs(next, i, edges, d+1);
            if next_ret > ret {
                ret = next_ret
            }
        }
    }
    ret
}

fn distance(n1: usize, n2: usize, prev: usize, edges: &Vec<Vec<usize>>, d: usize) -> Option<usize> {
    if n1 == n2 {
        return Some(d)
    }
    for &next in edges[n1].iter() {
        if next != prev {
            if let Some(dia) = distance(next, n2, n1, edges, d+1) {
                return Some(dia)
            }
        }
    }
    None
}

fn main() {
    input!{
      n: usize,
      abs: [(usize, usize); n-1],
    }

    let mut edges = vec![vec![]; n];
    for &(a, b) in abs.iter() {
        edges[a-1].push(b-1);
        edges[b-1].push(a-1);
    }

    // 木の直径(diameter)を求める
    let ret = dfs(0, n, &edges, 0);
    let n1 = ret.1;
    let ret = dfs(n1, n, &edges, 0);
    let n2 = ret.1;
    let diameter = distance(n1, n2, n, &edges, 1).unwrap();

    if diameter%3 == 2 {
        println!("Second");
    } else {
        println!("First");
    }
}


Measured memory_bytes: 39420
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n); for(int i = 0;i < (int)(n);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
int n;
int x[10],y[10];
double dist(int i,int j){
    double dx = pow(x[i]-x[j],2);
    double dy = pow(y[i]-y[j],2);
    return sqrt(dx+dy);
}
int main(){
    cout << fixed << setprecision(10);
    cin >> n;
    rep(i,n)cin >> x[i] >> y[i];
    double ans = 0.0;
    vector<int>v(n);
    rep(i,n)v[i] = i;
    do{
        rep(i,n-1)ans += dist(v[i],v[i+1]);
    }while(next_permutation(all(v)));
    int Factorial = 1;
    for(int i = 2;i <= n;i++)Factorial *= i;
    cout << ans/Factorial << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
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;}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n;
    cin >> n;
    cout << 2.0 * n * 3.141 << endl;
}

Measured memory_bytes: 3776
#include <bits/stdc++.h>
 
using namespace std;
#define ll long long
const ll INF=1e15;
#define int long long
#define pb push_back
#define mp make_pair
#define endl "\n"
#define fastio cin.tie(NULL); cout.tie(NULL); ios_base::sync_with_stdio(false)
const double pi = acos(-1.0);
int gcd (int a, int b) {
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}
int lcm (int a, int b) {
    return a / gcd(a, b) * b;
}

long long binpows(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)  //impar
            res = res * a;
        a = a * a;
        b >>= 1;  // /2
    }
    return res;
}
const int mod=1e9+7;
int binpow(int a, int b, int m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
//CHECAR SE PRECISA DE LONG LONG
int n;
vector<int> v;
int dp[123456];
int resolve(int pos){
	if(pos==n-1)
		return 0;
	int &x=dp[pos];
	if(x!=-1)
		return x;
	x=INF;
	if(pos+1<=n-1){
		x=min(x,resolve(pos+1)+(abs(v[pos]-v[pos+1])));
	}
	if(pos+2<=n-1){
		x=min(x,resolve(pos+2)+(abs(v[pos]-v[pos+2])));
	}
	return x;
}
void solve(){
	cin>>n;
	v.resize(n);
	memset(dp,-1,sizeof(dp));
	for(int i=0; i<n; i++){
		cin>>v[i];
	}
	cout<<resolve(0)<<endl;
}
//revise as variaveis e a ordem nas funções
signed main(){
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 8208
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int X = sc.nextInt();
		int count = 0;
		for (int i = 0; i <= A; i++) {
			for (int j = 0; j <= B; j++) {
				for (int j2 = 0; j2 <= C; j2++) {
					int tmp = 500 * i + 100 * j + 50 * j2;
					if (tmp == X)
						count++;

				}
			}
		}
		System.out.println(count);
		sc.close();
	}
}

Measured memory_bytes: 21844
A, B, C, X = [int(input().rstrip()) for _ in range(4)]
count = 0

for a in range(A+1):
    sum_a = 500 * a
    for b in range(B+1):
        sum_b = 100 * b
        for c in range(C+1):
            sum_c = 50 * c
            sum_all = sum_a + sum_b + sum_c
            if sum_all == X:
                count += 1

print(count)


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

using namespace std;

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

  long N; cin>>N;
  for (long i = floor(sqrt(N)); i > 0; i--) {
    if (N % i == 0) {
      long ans = i-1 + N/i-1;
      cout << ans << endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 256
from itertools import permutations


N, M = map(int, input().split())
S = []
for i in range(M):
    a, b = map(int, input().split())
    S.append([a, b])
    
vertex = (i+1 for i in range(N))
all_path = list(permutations(vertex))

ans = 0
for p in all_path:
    flag = True
    if p[0] == 1:
        for i in range(N-1):
            if [p[i], p[i+1]] not in S and [p[i+1], p[i]] not in S:
                flag = False
                break
        if flag:
            ans += 1
                
print(ans)

Measured memory_bytes: 13948
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

class p{
  protected:
  p(bool *sign,int size):
   mSize(size)
  {
    for(int i = 0; i < size; i++){
      mSign[i] = sign[i];
    }
  }
  bool mSign[4];
  int mSize;
};

class c : public p{
  public:
   c(bool *sign,int size):
   p(sign,size)
   {}
  void getmSign(bool *sign){
    for(int i = 0; i < mSize; i++)
      sign[i] = mSign[i];
  }
  private:
    
};

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(20);
  int n;
  string s;

  cin >> n >> s;

  char c = s[0];
  int sub = 0;
  FOR(i,1,n){
    if(c != s[i]){
      c = s[i];
    }
    else{
      sub++;
    }
  }

  cout << n - sub << endl;

  return 0;
}

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

using namespace std;

int lx,ly,lt;
int n;

int main()
{
	cin >> n;
	for(int i=0;i<n;i++)
	{
		int x,y,t;
		cin >> t >> x >> y;
		if(abs(x-lx)+abs(y-ly)>t-lt)
		{
			cout << "No" << endl;
			return 0;
		}
		if((abs(x-lx)+abs(y-ly))%2!=(t-lt)%2)
		{
			cout << "No" << endl;
			return 0;
		}
		lx=x; ly=y; lt=t;
	}
	cout << "Yes" << endl;
}

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

#define Bye return 0
#define ll long long

using namespace std;

const int M = 1e9+7;

void solve(){
    int n; cin>>n;

    vector<ll> pos(n), neg(n);
    for (int i=0; i<n; i++){
        ll x, y; cin>>x>>y;
        pos[i] = x + y;
        neg[i] = x - y;
    }
    sort(pos.begin(), pos.end());
    sort(neg.begin(), neg.end());
    cout<<(max(pos[n-1]-pos[0], neg[n-1]-neg[0]));
}
int main(){
    solve();
    Bye;
}

Measured memory_bytes: 6336
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	string s; cin >> s;
	int ans = 0;
	while (!s.empty()) {
		s.pop_back();
		s.pop_back();
		string a = s.substr(0, s.size() / 2), b = s.substr(s.size() / 2, s.size());
		if (a == b)chmax(ans, (int)s.size());
	}
	cout << ans << "\n";
		return 0;;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
#include <cctype>
using namespace std;

int main() {
    int n, m, X, Y, x, y;
    cin >> n >> m >> X >> Y;
    int minx = X, maxx = X, miny = Y, maxy = Y;
    for (int i = 0; i < n; i++) {
        cin >> x;
        minx = min(minx, x);
        maxx = max(maxx, x);
    }
    for (int i = 0; i < m; i++) {
        cin >> y;
        miny = min(miny, y);
        maxy = max(maxy, y);
    }
    if (maxx < miny || maxy < minx) {
        cout << "No War" << endl;
    }
    else cout << "War" << endl;
}

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

bool linearSearch(const vector<int>& ary, int key) {
    for (auto i = 0; i < ary.size(); i++) {
        if (ary[i] == key) {
            return true;
        }
    }
    return false;
}

int main(void) {
    int n;
    cin >> n;
    vector<int> S(n);
    for (int i = 0; i < n; i++) {
        cin >> S[i];
    }
    int q;
    cin >> q;

    int cnt = 0;
    for (int i = 0; i < q; i++) {
        int key;
        cin >> key;

        if (linearSearch(S, key)) cnt++;
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
const long long INF=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long,long>> vpll;
typedef vector<pair<int,int>> vpii;
int main() {
		oneforall
		oneforall
		oneforall
		oneforall
		oneforall
		oneforall
		oneforall
		oneforall
		oneforall
		oneforall
		oneforall
		oneforall
		oneforall
		oneforall
		ini(x);
		ini(n);
		int total = 0;
		int pena = 0;
		map<int,pair<int,int>> map1;
		FOR(i,0,n){
			ini(x1);
			ins(wof);
			if (wof == "AC" and map1[x1].first != 1) { total++;pena += map1[x1].second;map1[x1].first++; }
			else map1[x1].second++;
		}
		out(total,pena);
		return 0;
}

Measured memory_bytes: 6528
#include<iostream>
#include<string>
using namespace std;
int main(){

  string S;
  string T;
  cin>>S>>T;
  string substr;
  int subnum=(int)(S.length()-T.length()+1);
  int ans=9999;
  int min=T.length();
  for(int i=0;i<=subnum-1;i++){
    min=T.length();
    substr=S.substr(i,T.length());
    for(int j=0;j<=T.length()-1;j++){
    
      if(substr[j]==T[j])min--;
    }
    if(ans>min)ans=min;
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 3628
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout

	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
		if len(os.Args) > 2 {
			wfp, _ = os.Create(os.Args[2])
		}
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)

	n := getNextInt(scanner)

	bb := make([]Node, n+2)

	for i := 0; i < n+2; i++ {
		bb[i].prev = i - 1
		bb[i].next = i + 1
		if i == 0 || i == n+1 {
			bb[i].b = i
			continue
		}
		bb[i].b = getNextInt(scanner)
	}

	ans := make([]int, n)
	for i := n; i > 0; i-- {
		index := i
		for tail := bb[n+1].prev; tail > 0; tail = bb[tail].prev {
			if bb[tail].b == index {
				bb[bb[tail].prev].next = bb[tail].next
				bb[bb[tail].next].prev = bb[tail].prev
				ans[i-1] = index
				break
			}
			index--
		}
		if index < 1 {
			fmt.Println(-1)
			return
		}
	}

	for i := 0; i < n; i++ {
		fmt.Fprintln(writer, ans[i])
	}
	writer.Flush()
}

type Node struct {
	prev, next, b int
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define MOD 1000000007
#define pb push_back
#define mp make_pair
typedef long long int ll;
using namespace std;

ll s;
ll sum[23000000];
ll nd(ll x){
    if(x==0) return 1;
    if(x==1) return 10;
    if(x%2){
        ll tmp = nd(x/2);
        return (((tmp*tmp)%MOD)*10)%MOD;
    }
    else {
        ll tmp = nd(x/2);
        return (tmp*tmp)%MOD;
    }
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> s;
    if(s==1){
        cout << '9' << '\n';
        return 0;
    }
    ll l=1, r=1;
    ll cnt=0;
    ll cn = 1;
    for(int i=1;i<23000000;i++){
        sum[i] = sum[i-1]+cn;
        if(i==9 || i==99 || i==999 || i==9999 || i==99999 || i==999999 || i==9999999) cn++;
    }
    for(l=1;l<10000000;l++){
        while((sum[r]-sum[l-1])<s) r++;
        if((sum[r]-sum[l-1])==s) cnt = (cnt+1)%MOD;
    }
    cnt = (cnt+(s/8))%MOD;
    for(ll i=1;i<=(s/8);i++){
        if(!(s%i)){
            cnt = (cnt+((9*nd((s/i)-1))%MOD)+MOD-i)%MOD;
        }
    }
    cout << cnt << '\n';
    return 0;
}


Measured memory_bytes: 179968
import fractions

n,x = [int(i) for i in input().split()]

lis = list(map(int,input().split()))
diffs = []
for i in range(n):
    diff = abs(lis[i]-x)
    diffs.append(diff)


if len(diffs) > 1:
    com = fractions.gcd(diffs[0],diffs[1])
    for i in range(len(diffs)-2):
        com = fractions.gcd(com, diffs[i+2])
else:
    com = diffs[0]

print(com)

Measured memory_bytes: 16280
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;

int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  vector<string> key(0);
  vector<vector<bool>> flag(3, vector<bool>(10, false)), flag2(3, vector<bool>(10, false));
  int counter = 0;
  for(int i = 0; i < N-2; i++){
    if(flag.at(0).at(S.at(i)-'0')) continue;
    flag.at(0).at(S.at(i)-'0') = true;
    for(int j = i+1; j < N-1; j++){
      if(flag.at(1).at(S.at(j)-'0')) continue;
      flag.at(1).at(S.at(j)-'0') = true;
      for(int k = j+1; k < N; k++){
        if(flag.at(2).at(S.at(k)-'0')) continue;
        flag.at(2).at(S.at(k)-'0') = true;
        counter++;
      }
      flag.at(2) = flag2.at(2);
    }
    flag.at(1) = flag2.at(1);
  }
  cout << counter << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll int
int main()
{
	ll i,j,k,m,n,t;
	cin>>n;
	ll ar[n];
	ll f[1000001]={0};
	for(i=0;i<n;i++)
	{
		cin>>ar[i];
		f[ar[i]]++;
	}
	ll N=1e6+1;
	bool prime[N+1]; 
	memset(prime, true, sizeof(prime));
	for (int p=2; p*p<=N; p++) 
	{
		if (prime[p] == true) 
		{
			for (int i=p*p; i<=N; i += p) 
				prime[i] = false; 
		} 
	} 
	int ctr=0;
	bool fl=true;
	for (int p=2; p<=N; p++) 
	{
		if (prime[p])
		{
			ll x=0;
			for(i=p;i<=1000000;i+=p)
			x+=f[i];
			if(x>=2)
			{
				fl=false;
				break;
			}
		}
	}
	if(fl)
	{
		cout<<"pairwise coprime";
		return 0;
	}
	ll g=ar[0];
	for(i=1;i<n;i++)
	g=__gcd(g,ar[i]);
	if(g==1) cout<<"setwise coprime";
	else
	cout<<"not coprime";
}

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

li = [0]*n

for i in range(1,n):
    if s[i-1] == "A" and s[i] == "C":
        li[i] += 1

from itertools import accumulate

lin = [0]+list(accumulate(li))

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

Measured memory_bytes: 8716
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
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;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
const ll mod=1e9+7;
const int inf=1<<30;

ll dp[3010][3010];

int main(){
  int n; cin >> n; n--;
  string s; cin >> s;
  rep(j,n+1) dp[0][j]=1;
  rep(i,n){
    if(s[i]=='<'){
      rep(j,n-i){
        if(j==0) dp[i+1][j]=dp[i][j];
        else dp[i+1][j]=dp[i+1][j-1]+dp[i][j];
        dp[i+1][j]%=mod;
      }
    }
    else{
      for(int j=n-i-1;j>=0;j--){
        dp[i+1][j]=dp[i+1][j+1]+dp[i][j+1];
        dp[i+1][j]%=mod;
      }
    }
  }
  cout << dp[n][0] << endl;
}

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

int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  
  if(A+B > C+D){
    cout << "Left" << endl;
  }else if(A+B < C+D){
   cout << "Right" << endl;
  }else{
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256