akhauriyash/Code-Regression huggingface dataset:
# UnionFind
#############################################################
class UnionFind:

    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, v):  # vが属する集合の根を返す
        if self.parents[v] < 0:
            return v
        else:
            self.parents[v] = self.find(self.parents[v])
            return self.parents[v]

    def unite(self, u, v):  # 「uが属する集合」と「vが属する集合」を併合（根同士を結ぶ）
        u = self.find(u)
        v = self.find(v)
        if u == v:
            return
        if self.parents[u] > self.parents[v]:  # u < v に統一する
            u, v = v, u
        self.parents[u] += self.parents[v]
        self.parents[v] = u

    def size(self, v):  # vが属する集合の要素数
        return -self.parents[self.find(v)]

    def same(self, u, v):  # uとvが同じ集合に属するか否か
        return self.find(u) == self.find(v)
#############################################################
import sys
input = sys.stdin.readline

N = int(input())
XY = [list(map(int, input().split())) + [i] for i in range(N)]

X = sorted(XY, key=lambda x: x[0])
Y = sorted(XY, key=lambda x: x[1])

dist = []
for i in range(N - 1):
    # iとi+1の距離、iのindex, i+1のindex
    dist.append([X[i + 1][0] - X[i][0], X[i][2], X[i + 1][2]])
    dist.append([Y[i + 1][1] - Y[i][1], Y[i][2], Y[i + 1][2]])

ans = 0
dist.sort(key=lambda x: x[0])

uf = UnionFind(N)
# クラスカル法
for cost, i, j in dist:
    if uf.same(i, j):
        continue
    uf.unite(i, j)
    ans += cost

print(ans)


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

using namespace std;
using ll = long long;

template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_V(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_M(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}

int main() {
    int N;
    cin >> N;
    unordered_map<string, int> mp;
    for (int i = 0; i < N; ++i) {
        string s;
        cin >> s;
        mp[s]++;
    }
    cout << "AC x " + to_string(mp["AC"]) << "\n";
    cout << "WA x " + to_string(mp["WA"]) << "\n";
    cout << "TLE x " + to_string(mp["TLE"]) << "\n";
    cout << "RE x " + to_string(mp["RE"]) << "\n";

    return 0;
}

Measured memory_bytes: 3700
q,h,s,d = map(int, input().split())
n = int(input())
num = 0
if 2 <= n:
    num += min(8*q,4*h,2*s,d)*(n//2)
    n = n%2
if n == 1:
    num += min(4*q,2*h,s)
print(num)

Measured memory_bytes: 9116
#include<stdio.h>
int main(void)
{
  char moji;
   
  while(1){
      scanf("%c",&moji);
       
      if(moji >= 'A' && moji <= 'Z'){
    moji += 32;
    printf("%c",moji);
      }
       
      else if(moji >= 'a' && moji <= 'z'){
    moji -= 32;
    printf("%c",moji);
      }
       
      else if(moji != '\n'){
    printf("%c",moji);
      }
      else if(moji == '\n'){
    printf("\n");
    break;
      }
  }
  return 0;
}

Measured memory_bytes: 524
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <cassert>
#include <random>
#include <time.h>
//#include <boost/multiprecision/cpp_int.hpp>



using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const double EPS = 1e-10;
long long const MOD = 1000000007;

long long mod_pow(long long x, long long n) {
    long long res = 1;
    for (int i = 0;i < 60; i++) {
        if (n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

void fastInput() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}


int main(void) {
    string S; cin >> S;
    int N = S.length();
    vector<char> odd = {'R', 'U', 'D'};
    vector<char> even = {'L', 'U', 'D'};
    for (int i = 0; i < N; i++) {
        int flag = 1;
        if (i % 2) {
            for (int j = 0; j < 3; j++) {
                if (S[i] == even[j]) flag = 0;
            }
        } else {
            for (int j = 0; j < 3; j++) {
                if (S[i] == odd[j]) flag = 0;
            }
        }
        if (flag) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
 
int main() {
 
  long int N, Y, i, j, ans;
  cin >> N >> Y;
  
  for (i = 0; i <= N; i++){
    for (j = 0; j <= N - i; j++){
      ans = 10000 * i + 5000 * j + 1000 * (N - i -j);
      if (ans == Y){ 
        cout << i << " " << j << " " << N - i - j;
        return 0;
      }
    }
  }
  cout << "-1 -1 -1" << endl;

}

Measured memory_bytes: 256
S = gets.chomp
N = S.length

if (S == S.reverse) && (S[0..(N - 1)/2 - 1] == S[0..(N - 1)/2 - 1].reverse) && (S[(N + 1)/2..(-1)] == S[(N + 1)/2..(-1)].reverse)
	puts 'Yes'
else
	puts 'No'
end

Measured memory_bytes: 1788
#include <stdio.h>
#include<string.h>
int main()
{
long int n,i;
char a[100];
gets(a);

for(i=0;i<strlen(a);i++)
{
if(a[i]=='+')
{
    n++;
}else{
 if(a[i]=='-'){
    n--;}
}
}
printf("%ld",n);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;

int main(){
  string s;
  cin >> s;
  rep(i, s.length()){
    if(s[i] == ',') s[i] = ' ';
  }
  cout << s << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<algorithm>
using namespace std;
typedef long long LL;
const int maxn=1e5+5;
const LL mod=1e9+7;
int read() {
	char ch=getchar();int x=0,f=1;
	while(ch<'0' || ch>'9')	{if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int gcd_(int a,int b) {return b==0?a:gcd_(b,a%b);}
LL fpow(LL a,LL b) {
	LL res=1;
	while(b) {
		if(b&1) res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}
int main() {
//	cout<<"Accepted!\n";
	int n,ac=0,wa=0,tle=0,re=0;
	cin>>n;
	while(n--) {
		string s;
		cin>>s;
		if(s=="AC") ac++;
		if(s=="WA") wa++;
		if(s=="TLE") tle++;
		if(s=="RE") re++; 
	}
	cout<<"AC x "<<ac<<'\n';
	cout<<"WA x "<<wa<<'\n';
	cout<<"TLE x "<<tle<<'\n';
	cout<<"RE x "<<re<<'\n';
	return 0;
}


Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using P = pair<int, int>;

int C[10000];

int lower_search(int key) {
  int l = -1, r = 10000;
  while(r - l > 1) {
    int half = (r + l) / 2;
    if(key <= C[half]) r = half;
    else l = half;
  }
  return r;
}

int main() {
  rep(i, 10000) {
    if(i < 2) C[i] = 0;
    else C[i] = (i * (i - 1)) / 2;
  }
  int N;
  cin >> N;
  int index;
  index = lower_search(N);
  // cout << index << endl;
  if(C[index] != N) {
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
  cout << index << endl;
  vector<vector<int>> v;
  v.resize(index);
  int count = 1;
  for(int i = 0; i < index; i++) {
    for(int j = i + 1; j < index; j++) {
      v[i].push_back(count);
      v[j].push_back(count);
      count++;
    }
  }
  rep(i, index) {
    cout << v[i].size() << " ";
    rep(j, v[i].size()) {
      cout << v[i][j];
      if(j != v[i].size() - 1) cout << " ";
      else cout << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 4084
// ------------------------------------
// Date:2018/ 3/13
// Problem:Colorfu; Leaderboard . e.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl

typedef long long ll;

static const int MOD = 1000000007;

bool state[8];

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

  int N;
  cin >> N;
  memset(state, false, sizeof(state));
  vector< int > A(N);
  REP(i, N) {
    cin >> A[i];
  }
  
  int cnt = 0;
  REP(i, N) {
    if (   1 <= A[i] and A[i] <  400) state[0] = true;
    if ( 400 <= A[i] and A[i] <  800) state[1] = true;
    if ( 800 <= A[i] and A[i] < 1200) state[2] = true;
    if (1200 <= A[i] and A[i] < 1600) state[3] = true;
    if (1600 <= A[i] and A[i] < 2000) state[4] = true;
    if (2000 <= A[i] and A[i] < 2400) state[5] = true;
    if (2400 <= A[i] and A[i] < 2800) state[6] = true;
    if (2800 <= A[i] and A[i] < 3200) state[7] = true;
    if (3200 <= A[i]) cnt++;
  }

  int ansMin = 0, ansMax = 0;
  REP(i, 8) if (state[i]) ansMin++;
  if (ansMin == 0) {
    ansMin = 1;
    ansMax = cnt;
  } else ansMax = ansMin + cnt;
  cout << ansMin << " " << ansMax << endl;
  
  return 0;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int x,y,temp;
    while(1){
        cin >> x >> y;
        if(x==0 && y==0){
            return 0;
        }
        if(x>y){
            temp=x;
            x=y;
            y=temp;
        }
        cout << x << " " <<  y << endl;
    }
}


Measured memory_bytes: 3084
#include <stdio.h>

int main(void) {
	int n, k,l;
	scanf("%d %d", &n, &k);
	l = k;
	int ans = 1;

	while (1)
	{
		if (n < l)
		{
			break;
		}
		else {
			l = l * k;
			++ans;
		}
	}
	printf("%d",ans);

	return 0;
}

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

int main () {
  int H, W;
  cin >> H >> W;
  
  char s;
  for (int i = 0; i <W+2; i++) {
    cout << "#";
  }
  cout << endl;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W+2; j++) {
      if (j == 0 || j == W+1) {
        cout << "#";
      }
      else {
        cin >> s;
        cout << s;
      }
    }
  cout << endl;
  }
  for (int i = 0; i < W+2; i++) {
    cout << "#";
  }
  cout << endl;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+10;
struct node{
	int id,pos;
}e[N];
bool cmp(node a,node b){
	return a.id<b.id;
}
int n;
int ans[N];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&e[i].id);e[i].pos=i;
	}
	sort(e+1,e+1+n,cmp);
	for(int i=1;i<=n;i++)ans[i]=e[i].pos;
	for(int i=1;i<=n;i++){
		printf("%d%c",ans[i],i==n?'\n':' ');
	}
}

Measured memory_bytes: 2048
while True:
    try:
        string = input()
    except:
        break
    ans = ""
    i = 0
    while i < len(string):
        if string[i] == "@":
            ans += int(string[i+1])*string[i+2]
            i += 3
        else:
            ans += string[i]
            i += 1
    print(ans)

Measured memory_bytes: 7508
#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;
vector<vector<int>> v(200000);
vector<ll> ans(200000,0LL);
vector<bool> used(200000);


void search(int p,int parent){
	used[p] = true;
	for(int i = 0; i < v[p].size(); i++) {
		if (v[p][i] != parent && used[v[p][i]] == false){
			ans[v[p][i]] += ans[p];
			search(v[p][i],p);
		}
	}
}

int main(){
	int n,q;cin>>n>>q;
	int a,b;
	for(int i = 0; i < n - 1; i++) {
		cin>>a>>b;
		v[a - 1].pb(b - 1);
		v[b - 1].pb(a - 1);
	}
	for(int i = 0; i < q; i++) {
		ll a,b;cin>>a>>b;
		ans[a - 1LL] += b;
	}
	search(0, 0);

	for(int i = 0; i < n; i++) {
		cout << ans[i] << " ";
	}
	cout << endl;




	return 0;
}

Measured memory_bytes: 27392
A1 = list(map(int,input().split()))
A2 = list(map(int,input().split()))
A3 = list(map(int,input().split()))
N = int(input())
for _ in range(N):
  b = int(input())
  for i in range(3):
    if A1[i] == b:
      A1[i] = 0
  for j in range(3):
    if A2[j] == b:
      A2[j] = 0
  for k in range(3):
    if A3[k] == b:
      A3[k] = 0

if A1[0] == 0:
  if (A1[1]==0 and A1[2]==0) or (A2[0]==0 and A3[0]==0) or (A2[1]==0 and A3[2]==0):
    print('Yes')
    exit()
if A2[0] == 0:
  if (A2[1]==0 and A2[2]==0):
    print('Yes')
    exit()
if A3[0] == 0:
  if (A3[1]==0 and A3[2]==0) or (A2[1]==0 and A1[2]==0):
    print('Yes')
    exit()
if A1[1] == 0:
  if (A2[1]==0 and A3[1]==0):
    print('Yes')
    exit()
if A1[2] == 0:
  if (A2[2]==0 and A3[2]==0):
    print('Yes')
    exit()
print('No')

Measured memory_bytes: 3064
//
// Created by Pulak on 06-10-
//
#include <stdio.h>
#include <math.h>
typedef long long int ll;
int main(){
    ll r,D,x,x1;
    scanf("%lld %lld %lld",&r, &D,&x);
    for (int i = 0; i < 10; ++i) {
        x1 = r * x - D;
        printf("%lld \n",x1);
        x = x1;
    }
    




}

Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;
  vector<int> p(a), q(b), r(c);
  for (int i = 0; i < a; ++i) {
    cin >> p[i];
  }
  for (int i = 0; i < b; ++i) {
    cin >> q[i];
  }
  for (int i = 0; i < c; ++i) {
    cin >> r[i];
  }
  sort(p.rbegin(), p.rend());
  sort(q.rbegin(), q.rend());
  vector<int> vec;
  for (int i = 0; i < x; ++i) {
    vec.push_back(p[i]);
  }
  for (int i = 0; i < y; ++i) {
    vec.push_back(q[i]);
  }
  for (int i = 0; i < c; ++i) {
    vec.push_back(r[i]);
  }
  sort(vec.rbegin(), vec.rend());
  ll ans = 0;
  for (int i = 0; i < x + y; ++i) {
    ans += vec[i];
  }
  cout << ans << endl;
  return 0;
}

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

int main()
{

  int N;
  int slen;
  int numr, numb;
  numr = 0;
  numb = 0;
  string s;
  cin >>  N>> s;
  slen = s.size();
  for (int i = 0; i < slen; i ++){
    if(s.at(i) == 'R'){
      numr ++;
    }else if(s.at(i) == 'B'){
      numb ++;
    }
  }
  if(numr > numb){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


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

#define REP(i,n) for(int i=0;i<n;++i)

const int N = 1000;

int main() {
  int q, lmax;
  int c[N + 1][N + 1] = {0};
  string X, Y;

  cin >> q;
  REP(i, q) {
    cin >> X >> Y;

    X = ' ' + X;
    Y = ' ' + Y;
    lmax = 0;
    REP(i, X.length()) REP(j, Y.length()) {
      if (i == 0 || j == 0) continue;
      if (X[i] == Y[j]) {
        c[i][j] = c[i - 1][j - 1] + 1;
      } else {
        c[i][j] = max(c[i - 1][j], c[i][j - 1]);
      }
      lmax = max(lmax, c[i][j]);
    }

    cout << lmax << endl;
  }

  return 0;
}

Measured memory_bytes: 7120
/*COMPETITIVE PROGRAMMING C++ TEMPLATE */

#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <cmath>
#include <iostream>
#include <stack>
#include <queue>
#include <climits>
#include <iomanip>

#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << " = " << x << "\n"
#define MOD 1000000007

const long double PI = 3.141592653589793236L;

typedef long long int ll;
typedef long double ld;

using namespace std;

void solvea()
{
    string s;
    cin>>s;
    if(s[s.length()-1]=='s'){
        s.append("es");
    } else{
        s.push_back('s');
    }
    cout<<s;
}
void solveb(){
    int n;
    cin>>n;
    int d1[n];
    int d2[n];
    int currcount=0;
    int max_cc=0;
    for(int i =0;i<n;i++){
        cin>>d1[i]>>d2[i];
    }
    for(int i =0;i<n;i++){
        if(d1[i]==d2[i]){
            currcount++;
            if(currcount>max_cc)max_cc=currcount;
        }
        else currcount=0;
    }
    if(max_cc>=3){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
}
void solvec(){

}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int T = 1;
    //cin >> T;

    while (T--)
    {
        solveb();
    }

    return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,M,NE;
vector<int> O;
vector<int> E;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M;
	FOR(i,M) {
		cin>>x;
		if(x%2==1) O.push_back(x);
		else E.push_back(x);
	}
	
	if(O.size()>2) return _P("Impossible\n");
	NE=E.size();
	sort(ALL(E));
	reverse(ALL(E));
	
	if(O.size()==2) {
		_P("%d",O[0]);
		FOR(i,NE) _P(" %d",E[i]);
		_P(" %d\n",O[1]);
		
		x = NE+1+2;
		if(O[0]==1) x--;
		if(O[1]==1) x--;
		
		_P("%d\n",x);
		if(O[0]>1) _P("%d ",O[0]-1);
		_P("2 ");
		FOR(i,NE) _P("%d ",E[i]);
		if(O[1]>1) _P(" %d",O[1]-1);
		_P("\n");
	}
	else if(O.size()==1) {
		_P("%d",O[0]);
		FOR(i,NE) _P(" %d",E[i]);
		_P("\n");
		
		
		x = NE+1+1;
		if(O[0]==1) x--;
		
		_P("%d\n",x);
		if(O[0]>1) _P("%d ",O[0]-1);
		
		if(NE) {
			_P("2");
			FOR(i,NE-1) _P(" %d",E[i]);
			
			_P(" %d\n",E[NE-1]-1);
		}
		else {
			_P("1\n");
		}
		
	}
	else {
		FOR(i,NE) _P("%d%c",E[i],(i==NE-1)?'\n':' ');
		_P("%d\n",NE+1);
		_P("1");
		FOR(i,NE-1) _P(" %d",E[i]);
		_P(" %d\n",E[NE-1]-1);
	}
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace HelloWorld
{
    class Program
    {
        const int HOUSES = 4;
        const int STORIES = 3;
        const int ROOMS = 10;
        static void Main()
        {
            Command cmd = new Command();
            int[,,] OfficialHouse = cmd.Tidy_up();
            cmd.Story(OfficialHouse);
            cmd.House(OfficialHouse);
            Console.ReadLine();
        }
    }

    class Command
    {
        const int HOUSES = 4;
        const int STORIES = 3;
        const int ROOMS = 10;
        const int ARRAYER = 1;
        internal int[,,] Tidy_up()
        {
            int[,,] house = new int[HOUSES, STORIES, ROOMS];
            int info = int.Parse(Console.ReadLine());
            for (int i = 0; i < info; ++i)
            {
                int[] order = Console.ReadLine().Split().Select(int.Parse).ToArray();
                house[order[0] - ARRAYER, order[1] - ARRAYER, order[2] - ARRAYER] += order[3];
            }
            return house;
        }
        internal void House(int[,,] house)
        {
            for (int k = 1; k < HOUSES; ++k)
            {
                Console.WriteLine("####################");
                for (int i = 0; i < STORIES; i++)
                {
                    for (int j = 0; j < ROOMS; j++)
                    {
                        Console.Write(" {0}", house[k, i, j]);
                    }
                    Console.WriteLine();
                }
            }
        }
        internal void Story(int[,,] house)
        {
            for (int i = 0; i < STORIES; ++i)
            {
                for (int j = 0; j < 10; ++j)
                {
                    Console.Write(" {0}", house[0, i, j]);
                }
                Console.WriteLine();
            }
        }
       
    }
}


Measured memory_bytes: 16372
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

//#define mod 1000000007;

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const long long M = 1e6+5;
vector<bool>a(M, 0);

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


    long long n, m = INT_MIN;
    cin>>n;
    vector<long long>v(n), c(M, 0);
    map<long long,long long>mp;
    for(long long i=0;i<n;i++)
    {
        cin>>v[i];
        m = max(m, v[i]);
        mp[v[i]]++;
    }

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

    for(long long i=0;i<n;i++)
    {
        if(a[v[i]]==0)
        {
            for(long long j=2;v[i]*j<=m;j++)
            {
                a[v[i]*j] = 1;
            }
        }
    }
    long long s = 0;
    /*
    for(int i=3;i<=335;i++)
    {
        cout<<a[i]<<' '<<i<<'\n';
    }*/
    for(long long i=0;i<n;i++)
    {
        if(a[v[i]] == 0 && mp[v[i]]==1)
            s++;
    }
    cout<<s;

    return 0;
}

Measured memory_bytes: 25108
L = [chr(i) for i in range(97,97+26)]
S = list(input())
T = list(input())

LS = []
LT = []

for i in range(26):
	LS.append(S.count(L[i]))
	LT.append(T.count(L[i]))

LS = sorted(LS)
LT = sorted(LT)

if LS == LT:
	print("Yes")
else:
	print("No")

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

int main() {
  int a,b; cin >> a >>b;
  int count=0;
  for(int i=a; i<=b; i++){
    string s = to_string(i);
    if(s[0] == s[4] && s[1] == s[3]){
      //cout << s << endl;
      count++;
    }
  }
  cout << count << endl;
}


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

using ll = long long;
using ld  = long double;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
const int INF=1e9+7;
const ll LINF=9223372036854775807;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld EPS = 1e-10; //微調整用（EPSより小さいと0と判定など）

int ii() { int x; if (scanf("%d", &x)==1) return x; else return 0; }
long long il() { long long x; if (scanf("%lld", &x)==1) return x; else return 0; }
string is() { string x; cin >> x; return x; }
char ic() { char x; cin >> x; return x; }
void oi(int x) { printf("%d ", x); }
void ol(long long x) { printf("%lld ", x); }
void od_nosp(double x) { printf("%.15f", x); } // 古い問題用
void od(double x) { printf("%.15f ", x); }
// long doubleで受け取り、fをLfなどに変えて出力すると、変な数値が出る
// それをなんとかするには独自の出力を作らなければならなそう
void os(const string &s) { printf("%s ", s.c_str()); }
void oc(const char &c) { printf("%c ", c); }
#define o_map(v){cerr << #v << endl; for(const auto& xxx: v){cout << xxx.first << " " << xxx.second << "\n";}} //動作未確認
void br() { putchar('\n'); }

// #define gcd __gcd //llは受け取らない C++17~のgcdと違うので注意
// int lcm(int a, int b){return a / gcd(a, b) * b;}
#define begin_end(a) a.begin(),a.end() //sort(begin_end(vec));
#define REP(i,m,n) for(ll i=(ll)(m) ; i < (ll) (n) ; i++ )
#define rep(i,n) REP(i,0,n)
#define m_p(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define p_b push_back
#define SZ(x) ((int)(x).size) //size()がunsignedなのでエラー避けに


// coutによるpairの出力（空白区切り）
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << " " << p.second << ")";}
// coutによるvectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << " "; //"\t"に変えるとTabで見やすく区切る
  }
  return s;
}
// coutによる多次元vectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i] << endl;
  }
  return s;
}

//最大値、最小値の更新。更新したor等しければtrueを返す
template<typename T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<typename T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}

//4近傍（上下左右） rep(i, 2) にすると右・下だけに進む
vector<int> dx_4 = {1, 0, -1, 0};
vector<int> dy_4 = {0, 1, 0, -1};

// -------- template end - //


// - library ------------- //

ll N;
vector<string> anss; 

void dfs(ll len, string s, char bef){
  for (char c = 'a'; c <= bef+1; c++){
    string ss = s + string(1, c);
    if (N>len) dfs(len+1, ss, max(bef, c));
    else anss.p_b(ss);
  }
}

// --------- library end - //


int main(){

  N = il();

  if ( N == 1 ){
    cout << "a" << endl;
    return 0;
  }

  dfs(2, "a", 'a');


  sort(begin_end(anss));
  for (auto ans : anss){
    cout << ans << endl;
  }


  
}

Measured memory_bytes: 7264
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        m: usize,
        k: usize,
    }

    const MOD : usize = 1000000007;

    let mut xsum : usize = 0;
    let mut ysum : usize = 0;

    for i in 1..n{
        xsum += ((i * (n-i) % MOD)  * (m * m % MOD)) % MOD;
    }

    for i in 1..m{
        ysum += ((i * (m-i) % MOD)  * (n * n % MOD)) % MOD;
    }

    xsum %= MOD;
    ysum %= MOD;

    let c = Combination::new(n*m, MOD);
    let p = c.comb(n*m-2, k-2);

    xsum = (xsum * p) % MOD;
    ysum = (ysum * p) % MOD;

    println!("{}",(xsum + ysum)%MOD);
}

pub struct Combination{
    fac : Vec<usize>,
    finv : Vec<usize>,
    m : usize,
}

impl Combination{
    pub fn new(n : usize, m : usize) -> Self{
        let mut inv = vec![1;n+1];
        let mut fac = vec![1;n+1];
        let mut finv = vec![1;n+1];

        for i in 2..(n+1){
            fac[i] = (fac[i-1] * i) % m;
            inv[i] = m - (inv[m%i] * (m/i) % m);
            finv[i] = (finv[i-1]*inv[i])%m;
        }

        Combination{
            fac,
            finv,
            m,
        }
    }

    pub fn comb(&self, n : usize, k: usize) -> usize{
        if n < k{
            return 0;
        }

        (self.fac[n] * (self.finv[k] * self.finv[n-k] % self.m)) % self.m
    }
}


Measured memory_bytes: 6800
#include<bits/stdc++.h>
using namespace std;
typedef long long int  ll;
int main()
{
   string s;
   cin>>s;
   int i;
   for(i=0;i<s.size();i++)
   {
       if(s[i]=='?')
       {
           s[i]='D';
       }
   }
   for(i=0;i<s.size();i++)
   {
       cout<<s[i];
   }
}


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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  string s;cin>>s;
  int res=1000000;
  for(int i=0;i<s.size()-2;i++){
    int k = stoi(
      s.substr (i,3)
    );
    if(abs(753-k) < abs(753-res)){
      res = k;
    }
  }
  cout<<abs(753-res)<<endl;

  return 0;
}


Measured memory_bytes: 256
import itertools

N, M = map(int, input().split())
node_relationship = [set(map(int, input().split())) for _ in range(M)]
permutations_lis = list(itertools.permutations([x for x in range(1, N + 1)]))
ans = 0

for one_case in permutations_lis:
    if one_case[0] != 1:
        continue

    flg = True
    for i in range(len(one_case) - 1):
        if not flg:
            break
        tmp = {one_case[i], one_case[i + 1]}
        if not tmp in node_relationship:
            flg = False
    if flg:
        ans += 1

print(ans)


Measured memory_bytes: 8052
def RainySeason():
    
    str1 = str(input())

    if str1 == 'RRR':
        print(3)
        
    elif str1 == 'SSS':
        print(0)
        
    elif str1[:2] == 'RR' or str1[1:] == 'RR':
        print(2)
    
    else:
        print(1)

if __name__ == '__main__':
    RainySeason()



Measured memory_bytes: 9040
fun main(args: Array<String>) {
    // Your code here!
    val (S,T) = readLine()!!.split(" ")
    var (A,B) = readLine()!!.split(" ").map{it.toInt()}
    val U = readLine()!!

    if(U.equals(S)){
        print(A-1)
        print(" ")
        print(B)
    }else{
        print(A)
        print(" ")
        print(B-1)
    }
    
}


Measured memory_bytes: 37868
def solve(nu,mu,du):
    E = []
    vs = [False]*nu
    vs[0] = True

    while True:
        min_dist,ind = float("inf"),float("inf")
        for i in xrange(len(du)):
            p_from = du[i][0]
            p_to = du[i][1]
            dist = du[i][2]
            if ( vs[p_from] and not vs[p_to] ) or ( not vs[p_from] and vs[p_to]):
                if min_dist > dist:
                    min_dist,ind,pf,pt = dist,i,p_from,p_to
        E.append(min_dist)
        vs[pf] = vs[pt] = True
        du.pop(ind)
        if all(vs):
            break
        for i in xrange(len(du)):
            try:
                if vs[du[i][0]] and vs[du[i][1]]:
                    du.pop(i)
            except:
                pass

    print sum(E)/100 - len(E)

while True:
    n = input()
    if n == 0:
        exit()
    m = input()
    data = []
    for i in xrange(m):
        data.append( map(int,raw_input().split(",")) )
    solve(n,m,data)

Measured memory_bytes: 4776
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
using Graph = vector<vector<int> >;
using GraphC = vector<vector<char> >;
const int INF = 1000000000;
typedef pair<int, int> P;
const int MAX_N = 1000000000;
typedef int64_t ll;
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; }



int main() {
	int N;
	cin >> N;
	vector<int> vec(N+1);
	for (int i = 1; i <= N; i++)
	{
		cin >> vec.at(i);
	}
	int j = 1;
	int cnt = 0;
	for (int i = 1; i <= N ; i++)
	{
		if (vec.at(i)==j)
		{
			cnt++;
			j++;
			
		}
	}
	if (cnt == 0)cout << -1 << endl;
	else cout << N - cnt << endl;
}


Measured memory_bytes: 4056
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  int cnt = 0;
  while (a >= b) {
    b *= 2;
    cnt++;
  }
  while (b >= c) {
    c *= 2;
    cnt++;
  }
  if (cnt <= k)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

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

int main() {
	ll n, m;
	cin >> n >> m;
	vector<pair<ll, ll>> v;
	for (ll i = 0; i < m; ++i) {
		ll a, b;
		cin >> a >> b;
		--a; --b;
		v.push_back({ a,b });
	}
	sort(v.begin(), v.end());
	set<ll> s;
	ll ans = 1;
	s.insert(v[0].second);
	for (ll i = 1; i < m; ++i) {
		if (*s.begin() <= v[i].first) {
			++ans;
			s.clear();
			s.insert(v[i].second);
		}
		else {
			s.insert(v[i].second);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 2800
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

a, b = map(int, readline().split())
if a < b:
    print(str(a) * b)
else:
    print(str(b) * a)


Measured memory_bytes: 2940
#include <iostream>
using namespace std;
int n,m[100][100];
void mins(){
    int u,min;
    int d[100],p[100],color[100];
    for(int i=0;i<n;i++){
        d[i]=2001;
        p[i]=-1;
        color[i]=1;
    }
    d[0]=0;
    while(1){
        min=2001;
        u=-1;
        for(int i=0;i<n;i++){
            if(color[i]!=3&&d[i]<min){
                u=i;
                min=d[i];
            }
        }
        if(u==-1){
            break;
        }
        color[u]=3;
        for(int v=0;v<n;v++){
            if(color[v]!=3&&m[u][v]!=-1){
                if(d[v]>m[u][v]){
                    p[v]=u;
                    d[v]=m[u][v];
                    color[v]=2;
                }
            }
        }
    }
    int ans=0;
    for(int i=0;i<n;i++){
        if(p[i]!=-1){
            ans+=d[i];
        }
    }
    cout<<ans<<endl;
}
int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cin>>m[i][j];
        }
    }
    mins();
    return 0;
}




Measured memory_bytes: 3112
def main():
    n,m=map(int,input().split())
    a=list(map(int,input().split()))
    a.sort(reverse=True)
    cost=[0,2,5,5,4,5,6,3,7,6]
    dp=[-n-n]*(n+1)
    dp[0]=0
    ans=[]
    for i in range(1,n+1):
        for j in a:
            if i>=cost[j]:
                dp[i]=max(dp[i],dp[i-cost[j]]+1)
    cnt=n
    while cnt:
        for j in a:
            if cnt>=cost[j] and dp[cnt-cost[j]]==dp[cnt]-1:
                ans.append(j)
                cnt-=cost[j]
                break
    for j in ans:
        print(j, end="")
    print("")

if __name__ == '__main__':
    main()

Measured memory_bytes: 4108
from functools import reduce
from math import gcd

MOD = 10 ** 9 + 7

_ = int(input())
la = list(map(int, input().split()))


def inv(a):
    return pow(a, MOD - 2, MOD)


def lcm(a, b):
    return a * b // gcd(a, b)


def addmod(a, b):
    return (a + b) % MOD


l = reduce(lcm, la) % MOD
answer = reduce(addmod, (l * inv(a) for a in la), 0)
print(answer)


Measured memory_bytes: 10412
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
struct BIT { //1-indexed
private:
    int n,n2;
    vector<ll> bit;

public:
    BIT(ll N){
        n = N;
        bit.assign(n+1, 0);
        n2 = 1;
        while(n2 * 2 <= n) n2 *= 2;
    }

    ll sum(ll x){ //[1, x]
        ll res = 0;
        for(ll i = x; i > 0; i -= i & -i) res += bit[i];
        return res;
    }

    ll sum(ll lv, ll rv){ // [lv, rv)
        return sum(rv-1) - sum(lv-1);
    }

    void add(ll x, ll v){
        if(x == 0) return;
        for(ll i = x; i <= n; i += i & -i) bit[i] += v;
    }

    ll lower_bound(ll w) {
        if (w <= 0) return 0;
        ll x = 0;
        for (ll k = n2; k > 0; k /= 2) {
            if (x + k <= n && bit[x + k] < w) {
                w -= bit[x + k];
                x += k;
            }
        }
        return x + 1;
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    ll N = S.size();
    map<char,ll> mp;
    rep(i,0,N){
        mp[S[i]]++;
    }
    ll odd_cnt = 0;
    for(auto &e: mp){
        if(e.second % 2 == 1) odd_cnt++;
    }
    if(odd_cnt >= 2){
        print(-1);
        return 0;
    }
    map<char,ll> cnt;
    string ls = "", rs = "";
    ll ans = 0;
    ll idx = 0;
    rep(i,0,N){
        cnt[S[i]]++;
        if(cnt[S[i]] <= mp[S[i]]/2){
            ls += S[i];
            // print(i,S[i], idx);
            ans += i - idx;
            idx++;
        }else if(mp[S[i]] % 2 == 1 && 2 * cnt[S[i]] - 1 == mp[S[i]] ){
            ans += abs((i + N/2-idx) - N/2);
        }else{
            rs += S[i];
        }
    }
    // print(ans);
    reverse(rs.begin(), rs.end());
    vector<ll> pos[30];
    rep(i,0,N/2){
        pos[ls[i] - 'a'].push_back(i);
        // print(ls[i], i);
    }
    // print(ls,rs);
    vector<ll> v;
    map<char,ll> cnt2;
    rep(i,0,N/2){
        ll n = cnt2[rs[i]];
        ll p = pos[rs[i] - 'a'][n];
        v.push_back(p);
        cnt2[rs[i]]++;
    }
    // print(ans);
    // printa(v, N/2);
    BIT bit(200010);
    ll tentou = 0;
    rep(i,0,N/2){
        tentou += bit.sum(1, v[i]+1);
        bit.add(v[i]+1, 1);
    }
    tentou = (N/2) * (N/2-1) / 2 - tentou;
    // print(tentou);
    ans += tentou;
    print(ans);


    

}

Measured memory_bytes: 4876
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
#define ll long long

const int INF = 1e9;
const long long LLINF = 1e18;

using namespace std;

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

/*==================================================*/
/*variable*/
string s;
/*==================================================*/
/*function*/

/*==================================================*/

int main() {
    cin>>s;
    int sum = 0;
    REP(i,0,s.size()){
        sum += (s[i] - '0');
    }
    int t = 0, d = 1;
    REP(i,0,s.size()){
        t += (s[s.size()-i-1] - '0')*d;
        d *= 10;
    }


    if(t % sum == 0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
const long long INF = 1LL << 60;
const int MOD = 1000000007;
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; }
signed main(void){
    int n; cin>>n;
    cout<<n*n<<endl;
}


Measured memory_bytes: 256
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

from collections import Counter

n = int(readline())
s = [input() for i in range(n)]
check = list(Counter(s).items())
check.sort(key=lambda x: (-x[1], x[0]))
max_a = check[0][1]
for k, v in check:
    if v != check[0][1]:
        break
    print(k)


Measured memory_bytes: 48740
n = int(input())
t, a = list(map(int, input().split()))
h = list(map(int, input().split()))

x = 10000000
s = 0

for i in range(n):
    if abs((t * 1000 - h[i] * 6) - (a * 1000)) < x:
        s = i+1
        x = abs((t * 1000 - h[i] * 6) - (a * 1000))

print(s)


Measured memory_bytes: 9124
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;
 
int main(){

    int A,B;
    cin>>A>>B;

    cout<<max(0,A-2*B)<<endl;

    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define int ll
#define Endl endl

signed main(){
    string A;
    cin >> A;
    int N=A.size();
    int Ans=N*(N-1)/2+1;
    int Z[26]={};
    REP(i,N){
        Z[A[i]-'a']++;
    }
    REP(i,26){
        int Y=Z[i];
        Ans-=(Y*(Y-1))/2;
    }
    
    cout << Ans << endl;
    return 0;
}


Measured memory_bytes: 640
import java.time.Instant;
import java.util.*;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

public class Main {
	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);
		String S = sc.next();

		int f = Integer.parseInt(S.substring(0, 2));
		int l = Integer.parseInt(S.substring(2, 4));

		boolean fBool = 0 < f && f < 13;
		boolean lBool = 0 < l && l < 13;

		if(fBool && lBool){
			System.out.println("AMBIGUOUS");
		} else if(fBool && !lBool){
			System.out.println("MMYY");
		} else if(!fBool && lBool){
			System.out.println("YYMM");
		} else {
			System.out.println("NA");
		}

	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <cstring>

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

#define vii vector<int>
#define vll vector<ll>
#define vip vector<pair<int,int> >
#define pb push_back


int main(int argc,char* argv[])
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    //#ifndef ONLINE_JUDGE
    //   freopen("input.txt", "r", stdin);
    //   freopen("output.txt", "w",stdout);
    //#endif

    int n,r;
    cin>>n>>r;
    int ir;
    if(n>=10) ir=r;
    else ir=r+((10-n)*100);
    cout<<ir;




    return 0;
}


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

def main():
    N, M = map(int, input().split())
    ab = sorted([list(map(int, input().split())) for i in range(M)], key=lambda x:x[1])

    B = 0
    ans = 0
    for i in range(M):
        a, b = ab[i]
        if a >= B:
            B = b
            ans += 1
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 29920
#include <stdio.h>
#include <string.h>

int main() {
	char a[11], b[11], c[11];
	int d, e;
	scanf("%s %s\n", &a, &b);
	scanf("%d %d\n", &d, &e);
	scanf("%s", &c);
	
	if(strcmp(a, c) == 0) {
		printf("%d %d", d - 1, e);
	} else if (strcmp(b, c) == 0) {
		printf("%d %d", d, e - 1);
	}
	
	return 0;
}

Measured memory_bytes: 3220
package main

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

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	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 getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	s := getNextString(scanner)
	t := getNextString(scanner)

	n := len(s)
	m := len(t)
	dd := make([]int, 0)
	for i := 0; i+m <= n; i++ {
		d := 0
		for j := 0; j < m; j++ {
			if t[j] == s[i+j] {
				continue
			}
			d++
		}
		dd = append(dd, d)
	}
	sort.Ints(dd)
	fmt.Fprintln(writer, dd[0])
}


Measured memory_bytes: 1868
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 998244353;
const int INF = 2e18;

signed main() {
    int N;
    cin >> N;
    vector<pair<int, int>> AB, BA;
    {
        vector<int> A(3), B(3);
        cin >> A >> B;
        for (int i = 0; i < 3; i++) {
            AB.emplace_back(A[i], B[i] - A[i]);
            BA.emplace_back(B[i], A[i] - B[i]);
        }
    }
    vector<int> dp(N + 1, 0);
    // A -> B
    for (int j = 0; j < 3; j++) {
        for (int i = 0; i <= N; i++) {
            if (i + AB[j].first > N) continue;
            dp[i + AB[j].first] = max(dp[i + AB[j].first], dp[i] + AB[j].second);
        }
    }
    // B -> A
    N = N + dp[N];
    dp = vector<int>(N + 1, 0);
    for (int j = 0; j < 3; j++) {
        for (int i = 0; i <= N; i++) {
            if (i + BA[j].first > N) continue;
            dp[i + BA[j].first] = max(dp[i + BA[j].first], dp[i] + BA[j].second);
        }
    }

    cout << N + dp[N] << endl;
}


Measured memory_bytes: 195584
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>
#include <regex>

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

using namespace std;

template<class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int N;

int main() {
    cin >> N;
    printf("ABC%d\n", N);
}



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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

	int n;
	cin >> n;

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

	ll s[n+1];
	s[0] = 0;
	rep(i,n){
		s[i+1] = s[i] + a[i];
	}

	map<ll, vector<ll>> mp;
	rep(i,n){
		mp[s[i+1]].push_back(i+1);
	}

	ll ans = 0;

	for(auto itr = mp.begin(); itr != mp.end(); ++itr){
		ll key = itr->first;
		ll val = itr->second.size();
		if(key == 0){
			ans += val * (val+1) / 2;
		}else{
			ans += (val - 1) * val / 2;
		} 
	}

	cout << ans << endl;	
}

Measured memory_bytes: 25216
import sys
import copy
from collections import deque
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces
maxr = 10**18
_ = ni()
a = na()
res = 1

if 0 in a:
    print(0)
    exit(0)

for item in a:
    res *= item
    if res > maxr:
        print(-1)
        exit(0)

print(res)

Measured memory_bytes: 83004
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int N; cin>>N;
	ll ret=0;
	vector<int> A(N);
	for (int i=0; i<N; i++)
		cin>>A[i];
	sort(A.rbegin(),A.rend());
	ret+=A[0];
	int iter=0; N--;
	for (int i=1; i<N; i++) {
		if(i%2) iter++;
		ret+=A[iter];
	}
	cout<<ret<<"\n";
	return 0;
}

Measured memory_bytes: 3960
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long const INF=1e9+7;
		long long n,k;
		cin>>n>>k;
		long long height[n];
		for(long long i=0;i<n;i++){
			cin>>height[i];
		}
		long long ans[n];
		for(long long i=0;i<n;i++){
			ans[i]=INF;
		}	
		ans[0]=0;
		for(long long i=0;i<n-1;i++){
			for(long long j=i+1;j<=i+k&&j<n;j++){
				ans[j]=min(ans[j],abs(height[i]-height[j])+ans[i]);
			}		
		}
		cout<<ans[n-1]<<endl;
	
}

Measured memory_bytes: 1792
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
const ll MAX_N=1e5;
ll N,A[MAX_N],g[MAX_N+1][2];
ll gcd(ll a,ll b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>N;
    REP(i,N){
        cin>>A[i];
    }
    REP(i,2){
        g[0][i]=0;
        REP(j,N){
            g[j+1][i]=gcd(g[j][i],A[j]);
        }
        reverse(A,A+N);
    }
    ll ans=0;
    REP(i,N){
        ans=max(ans,gcd(g[i][0],g[N-1-i][1]));
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 2560