akhauriyash/Code-Regression huggingface dataset:
using System;

class main
{
    static void Main(String[] args)
    {
        int n = int.Parse(Console.ReadLine());
        double b = 100000;
        for (int i = 0; i < n; i++)
        {
            b = b * 1.05;
            b += 999;
            b = ((int)(b / 1000)*1000);
        }
        Console.WriteLine(b);
        Console.ReadKey();
    }
}

Measured memory_bytes: 5632
#include<bits/stdc++.h>
int a[]={1,5,10,50,100,500};
int main(){
	int c[6];int res=0;
	for(int i=0;i<6;i++)scanf("%d",&c[i]);
	for(int i=0;i<6;i++)res+=a[i]*c[i];
	printf("%d\n",res>=1000);
}

Measured memory_bytes: 1192
import java.util.*; 
import java.lang.*; 
 
public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		
		int N = scan.nextInt();
		int M = scan.nextInt();
		
		int cnt = 0;
		double Anum = 0;
		
		double[] A = new double[N+1];
		for(int i=1; i<=N; i++){
			A[i] = scan.nextInt();
			Anum = Anum + A[i];		
		}
		
		double k = Anum/(4*M);
		
		for(int i=1; i<=N; i++){
		if(A[i]>=k){
				cnt = cnt+1;
			}
		}
		
		if(cnt>=M){
			System.out.println("Yes");
		}
		else{
			System.out.println("No");
		}
	}	
}

Measured memory_bytes: 23764
import java.util.*;

// ARC 84-A
// https://beta.atcoder.jp/contests/arc084/tasks/arc084_a

public class Main {
	
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);

		int N = in.nextInt();
		int[] A = new int[N];
		int[] B = new int[N];
		int[] C = new int[N];
		
		TreeSet<Integer> aSet = new TreeSet<Integer>();
		TreeSet<Integer> bSet = new TreeSet<Integer>();
		TreeSet<Integer> cSet = new TreeSet<Integer>();
		
		for (int i = 0; i < N; i++) {
			A[i] = in.nextInt();
			aSet.add(A[i]);
		}
		for (int i = 0; i < N; i++) {
			B[i] = in.nextInt();
			bSet.add(B[i]);
		}
		for (int i = 0; i < N; i++) {
			C[i] = in.nextInt();
			cSet.add(C[i]);
		}
		
		Arrays.sort(A);
		Arrays.sort(B);
		Arrays.sort(C);
		
		long[] temp = new long[N];
		for (int i = 0; i < N; i++) {
			Integer c = cSet.higher(B[i]);
			
			if (c != null) {
				int index = binarySearch2(C, c);
				temp[i] = (N - index);
			}
		}
		
		for (int i = N - 2; i >= 0; i--) {
			temp[i] += temp[i + 1];
		}
		
		long answer = 0;
		for (int i = 0; i < N; i++) {
			Integer b = bSet.higher(A[i]);
			
			if (b != null) {
				int index = binarySearch2(B, b);
				answer += temp[index];
			}
		}
		System.out.println(answer);
	}
	
	public static int binarySearch1(int[] arr, int n) {
		int low = 0;
		int high = arr.length - 1;
		
		while (low <= high) {
			int mid = (low + high) / 2;
			
			if (arr[mid] == n && (mid == arr.length - 1 || arr[mid + 1] != arr[mid])) {
				return mid;
			} else if (arr[mid] > n) {
				high = mid - 1;
			} else {
				low = mid + 1;
			}
		}
		return -1;
	}
	
	public static int binarySearch2(int[] arr, int n) {
		int low = 0;
		int high = arr.length - 1;
		
		while (low <= high) {
			int mid = (low + high) / 2;
			
			if (arr[mid] == n && (mid == 0 || (mid > 0 && arr[mid - 1] != arr[mid]))) {
				return mid;
			} else if (arr[mid] < n) {
				low = mid + 1;
			} else {
				high = mid - 1;
			}
		}
		return -1;
	}
}

Measured memory_bytes: 111084
n,m=list(map(int,input().split()))
Line,ans=[],0
for i in range(m):
  k,*s=list(map(int,input().split()))
  Line.append(s)
P=list(map(int,input().split()))

for i in range(1<<n):
  flag = 0
  for j,L in enumerate(Line):
    count=0
    for l in L:
      if i&(1<<(l-1)):
        count+=1
    if count % 2 == P[j]:
      flag += 1
  if flag == m:
    ans += 1
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
using namespace std;
int main(){
string s;
int a,b;
cin >> a >> b >> s;
if(s[a]!=45 || s.size() != a+b+1){
cout << "No" << endl;
return 0;
}
else{
s[a]=50;
}
for(int i=0;i<a+b+1;i++){
if(48<=s[i] && s[i]<=57){
continue;
}
else{
cout << "No" << endl;
return 0;
}
}
cout << "Yes" << endl;
return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		
		for(int i=30;i>=0;i--){
		    if((N / Math.pow(K,i)) >= 1){
			System.out.print(i+1);
			break;
		    }
		}
	}
}


Measured memory_bytes: 23636
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string ans;
	REP(i, 3) {
		string s;
		cin >> s;
		ans += s[i];
	}
	cout << ans << endl;

}


Measured memory_bytes: 256
val = [0]*(10**5)
N = int(input())
a = list(map(int, input().split()))
Q = int(input())
ans = sum(a)

for i in a:
    val[i-1] += 1

for i in range(Q):
    a, b = map(int, input().split())
    ans += (val[a-1]*b-val[a-1]*a)
    print(ans)
    val[b-1] += val[a-1]
    val[a-1] = 0


Measured memory_bytes: 21916
n = gets.to_i
divs = Array.new(n+1, 0)
ans = 0
for i in 1..n
    i.step(n, i) do |j|
        divs[j] += 1
    end
    ans += 1 if divs[i] == 8 and i % 2 == 1
end
puts ans


Measured memory_bytes: 14324
using static System.Math;
using System;

public class Hello
{
    public static void Main()
    {
        while (true)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var n = int.Parse(line[0]);
            var m = int.Parse(line[1]);
            if (n == 0 && m == 0) break;
            var f = new double[n, n];
            for (int i = 0; i < n; i++)
            {
                line = Console.ReadLine().Trim().Split(' ');
                for (int j = 0; j < n; j++) f[i, j] = double.Parse(line[j]);
            }
            var ans0 = goDP(f, n, m);
            var ans = Math.Round(ans0, 2, MidpointRounding.AwayFromZero);
            Console.WriteLine("{0:0.00}", ans);
        }
    }
    static double goDP(double[,] f, int n, int m)
    {
        var dp = new double[m, n];
        for (int i = 0; i < n; i++) dp[0, i] = 1d;
        for (int i = 1; i < m; i++)
            for (int j = 0; j < n; j++)
                for (int k = 0; k < n; k++)
                {
                    var w = dp[i - 1, j] * f[j, k];
                    dp[i, k] = Max(dp[i, k], w);
                }
        var ans = 0d;
        for (int i = 0; i < n; i++)
            ans = Max(ans, dp[m - 1, i]);
        return ans;
    }
}



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

using namespace std;

int main(){
    int N,M;
    cin >> N >> M;
    long long int ans=0;
    vector<int> X(M),Y(M-1);
    for(int i=0;i<M;i++){
        cin >> X[i];
    }
    if(M<=N){
        cout << "0" << endl;
    }else{
        sort(X.begin(),X.end());

        for(int i=0;i<M-1;i++){
            int x = abs(X[i+1]-X[i]);
            ans += x;
            Y[i] = x;
        }

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

        for(int i=0;i<N-1;i++){
            ans -= Y[M-2-i];
        }

        cout << ans << endl;
    }
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"

using namespace std;

//int N,M,K,L,R,H,W;
long long int N,M,K,L,R,H,W;

//constexpr long long int MOD=1000000007;
//constexpr  int MOD=1000000007;
constexpr int MOD=998244353;
//constexpr long long int MOD=998244353;

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

	cin>>N>>K;
	for(int i=0;i<N;i++){
		cin>>M;
		L+=M>=K;
	}
	cout<<L<<endl;
	return 0;
}

Measured memory_bytes: 256
#define rep(i, a, b) for(int i = a; i < (int)(b); i++)
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;
template<class T> inline void chmax(T &a, const T &b) {if(a < b) a = b;}
template<class T> inline void chmin(T &a, const T &b) {if(a > b) a = b;}
const long long INF = 1LL<<60;
const long long MOD = (ll)1e9+7;
// const long long MOD = (ll)1e6+3;
const long long MAX = (ll)1e5+10;

int main(void) {
    ll N,D,A;
    cin>>N>>D>>A;
    vector<ll> H(N);
    vector<ll> X(N);
    rep(i,0,N) cin>>X[i]>>H[i];

    multimap<ll,ll> Xn;
    rep(i,0,N) {
        Xn.insert(make_pair(X[i],H[i]/A+((H[i]%A==0)?0:1)));
    }
    map<ll,ll> Bx;
    ll b_now = 0;
    // for (auto el:Xn) {
    for (auto itr2 = Xn.begin();itr2 != Xn.end();itr2++) {
        // cout<<el.first<<" "<<el.second<<endl;
        if (itr2!= Xn.begin()) {
            itr2--;
            auto itr = Bx.lower_bound(itr2->first);
            itr2++;
            while (1) {
                if (itr ==Bx.end()) break;
                if (itr->first>=itr2->first) break;
                b_now -= itr->second;
                itr++;
            }
        }


        if (itr2->second<=b_now) {
            // bomb not needed.
        } else {
            Bx[itr2->first+2*D] = itr2->second-b_now;
            b_now += Bx[itr2->first+2*D];
        }
    }
    ll ans = 0;
    // for (auto el: Bx) cout<<el.first<<" "<<el.second<<endl;
    for (auto el: Bx) ans += el.second;
    cout<<ans<<endl;

   return 0;
}

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

typedef long long ll;
const ll INF = 1e9, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define REPR(i,a,b) for(ll i=b;i>=a;i--)
#define repr(i,n) REPR(i,0,n)
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define fi first
#define se second
#define m_p make_pair

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

    string s,ssub1,ssub2;
    cin >> s;
    ll size,ans=2;
    size = s.size();
    rep(i,size){
        s.pop_back();
        size = s.size();
        if(size%2==0){
            ssub1 = s.substr(0,size/2);
            ssub2 = s.substr(size/2);
            if(ssub1==ssub2){
                ans = size;
                break;
            }
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

int main()
{
    int n;
    cin >> n;
    if (n%2 == 0){
    	cout << n/2;
    }
    else{
    	cout << n/2 + 1;
    }
    
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define rep(i,l,r) for(int i=(l);i<(r);++i)
#define per(i,l,r) for(int i=(r)-1;i>=(l);--i)
#define dd(x) cout << #x << " = " << x << ", "
#define de(x) cout << #x << " = " << x << endl
const int N = 2e5 + 7;
int add[N], a[N];
ll cut[N];
int n, m;
void solve() {
	rep(i, 0, n) scanf("%d", a + i);
	fill_n(add, 2 * m, 0);
	fill_n(cut, 2 * m, 0);
	ll ans = 0;
	rep(i, 0, n - 1) {
		int s = a[i], t = a[i + 1];
		ans += t - s;
		add[s + 2]++;
		add[t + 1]--;
		cut[t + 1] += t - s - 1;
		if (s > t) {
			ans += m;
			cut[t + 1] += m;
			add[1]++;
			cut[1] -= m - s - 1; //s + 2 ~ m
		}
		//dd(s); de(t);
	}
	int cur = 0; ll tmp = 0, mx = 0;
	rep(i, 1, m + 1) {
		tmp -= cut[i];
		cur += add[i]; //de(cur);
		tmp += cur; //de(tmp);
		mx = max(mx, tmp);
	}
	printf("%lld\n", ans - mx);
}

int main() {
	while (~scanf("%d%d", &n, &m)) solve();
	return 0;
}

Measured memory_bytes: 2944
import java.util.*;

public class Main {

    static class Pair {
        int x, y;

        public Pair(int x, int y) {
            this.x = x;
            this.y = y;
        }
    }

    // Count number of 1's
    public static int countSetBits(int n) {
        int count = 0;
        while (n > 0) {
            count += n & 1;
            n >>= 1;
        }
        return count;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<List<Pair>> li = new ArrayList<>();
        for (int i = 0; i < n; ++i) li.add(new ArrayList<>());
        for (int i = 0; i < n; ++i) {
            int a = sc.nextInt();
            for (int j = 0; j < a; ++j) {
                li.get(i).add(new Pair(sc.nextInt() - 1, sc.nextInt()));
            }
        }

        int res = 0;
        for (int bit = 0; bit < (1<<n); ++bit) {
            boolean flag = true;
            for (int i = 0; i < n; ++i) {
                if ((bit & (1<<i)) == 0) continue;

                for (Pair p : li.get(i)) {
                    if (p.y == 1 && (bit & (1<<p.x)) == 0) flag = false;
                    if (p.y == 0 && (bit & (1<<p.x)) != 0) flag = false;
                }
            }
            if (flag) {
                res = Math.max(res, countSetBits(bit));
            }
        }

        System.out.println(res);
    }
}

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

int main(){
    int N,count=0;
    cin >> N;
    for(int i=1;i<=N;i+=2){
        int c=0;
        rep(j,i){
            if((i%j)==0)c++;
        }
        if(c==8)count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int,int_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_set_pair tree<pair<int,int>,int_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update> 
 
typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
typedef pair<int,int> pi; 
#define PI 3.1415926535897932384
#define FOR(i,vv,n) for(int i=vv;i<n;i++)
#define FORR(i,n,vv) for(int i=n-1;i>=vv;i--)
#define ve vector 
#define maxind(v) (max_element(v.begin(),v.end())-v.begin())
#define minind(v) (min_element(v.begin(),v.end())-v.begin())
#define maxe(v) *max_element(v.begin(),v.end())
#define mine(v) *min_element(v.begin(),v.end())
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define eb emplace_back
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mp make_pair
#define M 1000000007ll
#define M1 100000000000000000ll
#define PRECISE cout.precision(18);
#define BS(v,n) binary_search(v.begin(),v.end(),n)
#define srt(v) sort(v.begin(),v.end())
#define rsrt(v) sort(v.begin(),v.end(),greater <int>())
#define F first
#define S second
#define GET(i,p) get<i>(p)

using node= pair <ll,ll>;
int main(){

    FAST
//	PRECISE




ll n,m;
cin>>n>>m;
map <node,ve <pair <node,ll> >> v;
map <node,ll> dis;

FOR(i,0,m){
	ll p,q,c;
	cin>>p>>q>>c;
	node node1={p,c},node2={p,-1},node3={q,c},node4={q,-1};
	v[node1].pb({node3,0});
	v[node3].pb({node1,0});
	v[node1].pb({node2,0});
	v[node2].pb({node1,1});
	v[node3].pb({node4,0});
	v[node4].pb({node3,1});
	dis[node1]=M;
	dis[node2]=M;
	dis[node3]=M;
	dis[node4]=M;
}

dis[{1,-1}]=0;
priority_queue <pair <ll,node>,ve <pair <ll,node>>,greater <pair <ll,node>> > q;
q.push({0,{1,-1}});
while(!q.empty()){
	ll d1;
	node current;
	tie(d1,current)=q.top();
	q.pop();
	if(d1!=dis[current])
		continue;
	for(auto i:v[current]){
		int cd;
		node to;
		tie(to,cd)=i;
		if(dis[to]>d1+cd){
			dis[to]=d1+cd;
			q.push({dis[to],to});
		}

	}
}
ll ans=M;
if(dis.find({n,-1})!=dis.end())
 ans=dis[{n,-1}];

if(ans==M)
	cout<<-1;
else
	cout<<ans;








cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
return 0;
 }

Measured memory_bytes: 115908
#include<stdio.h>

main(){
	int i,x,y;
	
	while(1){
		scanf("%d%d",&x,&y);
		if(x==0&&y==0)break;
		
		if(x<y){
			printf("%d %d\n",x,y);
		}
		else{
			i=x;
			x=y;
			y=i;
						
			printf("%d %d\n",x,y);
		}
	}
	
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
 
#define F first
#define S second 
#define mp make_pair
#define pb push_back
#define pf push_front
#define speed_up ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define debug cerr << "OK\n";
#define ub upper_bound
#define lb lower_bound
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef set <int> si;
typedef set <ll> sll;
typedef multiset <int> msi;
typedef multiset <ll> msll;
typedef map <int, int> mi;
typedef map <ll, int> mll;
 
const int N = 1e6 + 2;
const int M = 1e5 + 2;
const int mod = 998244353;
const int inf = 1e9;
const ll INF = 1e16;
 
void data() {
    #ifdef PC
        freopen("main.in", "r", stdin);
        freopen("main.out", "w", stdout);
    #endif
}
 
template <typename T>
void scerr(T nums) {
	for (auto it : nums)
		cerr << it << " | ";
	cerr << "\n";
}
 
ll a, b, k;
 
int main() {
	data();
	scanf("%lld %lld %lld", &a, &b, &k);
	if (a - k > 0) {
		a -= k;
		k = 0;
	}
	else {
		k -= a;
		a = 0;
	}
	if (b - k > 0) {
		b -= k;
		k = 0;
	}
	else {
		k -= b;
		b = 0;
	}
	printf("%lld %lld", a, b);
}
 
/*
	Timus: 288481RF
	CodeForces: __fractal
*/


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

using namespace std;

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

    if(S=="zyxwvutsrqponmlkjihgfedcba"){
        cout<<-1<<endl;
        return 0;
    }

    vector<bool> t(26,true);

    long tt=0;

    for(int i=0;i<S.size();++i){
        t[S[i]-'a']=false;
        if(S[i]=='z')tt=i;
    }


    if(S.size()==26){
        bool tes=true;

        for(int i=tt+2;i<S.size();++i){
            if(S[i-1]<S[i]){
                tt=i;
            }
        }

        
            for(int i=S.size()-1;i>=tt;--i){
                t[S.back()-'a']=true;
                S.pop_back();
            }
            for(int i=0;i<26;++i){
                if((S[tt-1]-'a')<i&&t[i]){
                    S[tt-1]='a'+i;
                    break;
                }
            }

            cout<<S<<endl;
            return 0;
            
        
    }




    for(int i=0;i<26;++i){
        if(t[i]){
            S+=('a'+i);
            break;
        }
    }

    cout<<S<<endl;

}

Measured memory_bytes: 256
#!/usr/bin/env python

import sys

class bigint:
    def __init__(self,n,mod=10**9+7):
        self.n = n % mod
        self.mod = mod
        return
    #
    def __str__(self):
        return str(self.n)
    #
    def __add__(self,other):
        assert self.mod==other.mod, "modulos of the two not match"
        return bigint(self.n+other.n,self.mod)
    #
    def __iadd__(self,other):
        assert self.mod==other.mod, "modulos of the two not match"
        self.n = (self.n + other.n) % self.mod
        return self
    #
    def __sub__(self,other):
        assert self.mod==other.mod, "modulos of the two not match"
        return bigint(self.n-other.n,self.mod)
    #
    def __isub__(self,other):
        assert self.mod==other.mod, "modulos of the two not match"
        self.n = (self.n - other.n) % self.mod
        return self
#
#::::::::::::::::::::::::::::::::::::::::::::::::::
n,m = [ int(x) for x in sys.stdin.readline().split() ]
step= [bigint(0)] * (n+1)
wall= [False] * (n+1)
for i in range(m):
    am = int( sys.stdin.readline() )
    wall[am] = True
#
step[0]= bigint(1)
if not wall[1]: step[1]= bigint(1)
#
for i in range(2,n+1):
    if wall[i]: continue
    s1= step[i-1]
    s2= step[i-2]
    if s1==s2==0: break
    step[i] = s1 + s2
#
print( step.pop() )


Measured memory_bytes: 24308
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
# from fractions import gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    N, R = MAP()

    print(R if N >= 10 else R + 100 *(10 - N))


if __name__ == '__main__':
    main()


Measured memory_bytes: 38640
#include <iostream>                                             
#include <algorithm>
#include <vector>
using namespace std;
 
int n;
vector <int> a;
 
int main(){
  cin >> n;
  for(int i = 0; i < n; i++){
    int tmp;
    cin >> tmp;
    a.push_back(tmp);
  }
  sort(a.begin(),a.end());
  cout << a[n-1] - a[0] << endl;
  return 0;
}


Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

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

    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String S = scan.next();
        char[] oceros = S.toCharArray();
        int[] summary = new int[oceros.length+1];
        for (int i = 1; i <= oceros.length; i++) {
            if (oceros[i-1] == 'B') {
                summary[i] = summary[i - 1] + 1;
                continue;
            }
            summary[i] = summary[i - 1];
        }
        long ans = 0;
        for (int i = 1; i <= oceros.length; i++) {
            if (oceros[i-1] == 'W') {
                ans += summary[i];
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 27404
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

void bfs(int i, vector<int>& ans, int x, int y)
{
	queue<int> q;
	q.push(i);
	int n = ans.size();
	vector<int> distance(n, INT_MAX);
	distance[i] = 0;
	while (!q.empty()) {
		int key = q.front();
		q.pop();

		if (key == x) {
			if (key + (y - x) <= n - 1 && distance[key + (y - x)] == INT_MAX) {
				q.push(key + (y - x));
				distance[key + (y - x)] = distance[key] + 1;
			}
		}
		if (key == y) {
			if (0<=key - (y - x) && distance[key - (y - x)] == INT_MAX) {
				q.push(key - (y - x));
				distance[key - (y - x)] = distance[key] + 1;
			}
		}
		if (key + 1 <= n - 1 && distance[key + 1] == INT_MAX) {
			q.push(key + 1);
			distance[key + 1] = distance[key] + 1;
		}
		if (0 <= key - 1 && distance[key - 1] == INT_MAX) {
			q.push(key - 1);
			distance[key - 1] = distance[key] + 1;
		}
	}
	for (int i = 0; i < n; i++) ans[distance[i]]++;
}

int main()
{
	int n, x, y;
	cin >> n >> x >> y;
	x--;
	y--;
	vector<int> ans(n);

	for (int i = 0; i < n; i++) bfs(i, ans, x, y);
	for (int i = 1; i < n; i++) cout << ans[i] / 2 << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 26

void pre(int);
void ino(int);
void pos(int);

struct Node{
 int v, a, b; 
};

struct Node G[N];

int n, i, l, r, p;

char S[4][100]={"Preorder","Inorder","Postorder"};

int main(){
    void (*funcs[])(int)={pre,ino,pos};
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d%d%d",&p,&l,&r);
        G[l].v=G[r].v=1;
        G[p].a=l;
        G[p].b=r;
    }
    for(i=0;i<n;i++)if(!G[i].v)p=i;
    for(i=0;i<3;i++){
        puts(S[i]);
        (*(funcs[i]))(p);
        puts("");
    }
    return 0;
}

void pre(int n){
    if(n==-1)return;
    printf(" %d",n);
    pre(G[n].a);
    pre(G[n].b);
    return;
}

void ino(int n){
    if(n==-1)return;
    ino(G[n].a);
    printf(" %d",n);
    ino(G[n].b);
    return;
}

void pos(int n){
    if(n==-1)return;
    pos(G[n].a);
    pos(G[n].b);
    printf(" %d",n);
    return;
}

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


int main(){
    int k;
    cin >> k;
    string s;
    cin >> s;
    int t = s.size();
    if(t <= k)cout << s << endl;
    else{
        s = s.substr(0,k);
        cout << s << "..." << endl;
    }
}

Measured memory_bytes: 3632
var
    ans,n,i:longint;
    a:array[0..100010] of longint;
begin
    readln(n);
    a[0]:=0;a[n+1]:=0;
    for i:=1 to n do
        begin 
            read(a[i]);
            ans:=ans+abs(a[i]-a[i-1]);
        end;
    ans:=ans+abs(a[n]);
    for i:=1 to n do
        writeln(ans-abs(a[i]-a[i-1])-abs(a[i]-a[i+1])+abs(a[i-1]-a[i+1]));
end.

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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0; i<N; i++) cin >> A.at(i);
  sort(A.begin(), A.end());
  string ans="YES";
  for(int i=0; i<N-1; i++){
    if(A.at(i)==A.at(i+1)) ans="NO";
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
<?php
  fscanf(STDIN,"%d %d",$a,$b);
if($a > $b){
for($i = 0; $i < $a; $i++){
echo $b;
}
}else if ($b >= $a){
  for($j = 0; $j < $b; $j++){
  echo $a;
  }
}
?>


Measured memory_bytes: 3700
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
const double PI=3.14159265358979323846;
using namespace std;
vector<int> dx={1,0,-1,0};
vector<int> dy={0,1,0,-1};
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    int m,k;
    cin>>m>>k;
    int MAX=pow(2,m);
    if(k>=MAX) {
        cout<<-1<<endl;
        return 0;
    }
    if(k==0) {
        deque<int> ans;
        rep(i,MAX) {
            ans.push_back(i);
            ans.push_front(i);
        }
        rep(i,2*MAX) cout<<ans[i]<<" \n"[i==2*MAX-1];
        return 0;
    }
    if(MAX==2) {
        cout<<-1<<endl;
        return 0;
    }
    deque<int> left={0,k},right={k,0};
    rep(i,MAX) {
        if(i==0 || i==k) continue;
        if(sz(left)<MAX) {
            left.push_front(i);
            left.push_back(i);
        }
        else {
            right.push_front(i);
            right.push_back(i);
        }
    }
    rep(i,MAX) cout<<left[i]<<" ";
    rep(i,MAX) cout<<right[i]<<" \n"[i==MAX-1];
}


Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define per1(i,n) for(int i=n;i>0;i--)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    char a;
    cin>>a;
    if(a-'Z'<=0) cout<<'A';
    else cout<<'a';
}

Measured memory_bytes: 3648
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


struct Info{
	char name[101];
	int length,value;
};

struct Data{
	Data(int arg_left,int arg_sum_value){
		left = arg_left;
		sum_value = arg_sum_value;
	}
	bool operator<(const struct Data &arg) const{
		return left > arg.left;
	}

	int left,sum_value;
};

int N;
Info info[100];
char line[201];
int case_number = 1,line_length;


void func(){

	int tmp_length;
	for(int i = 0; i < N; i++){
		scanf("%s %d",info[i].name,&info[i].value);
		for(tmp_length = 0; info[i].name[tmp_length] != '\0'; tmp_length++);
		info[i].length = tmp_length;
	}

	scanf("%s",line);
	for(tmp_length = 0; line[tmp_length] != '\0'; tmp_length++);
	line_length = tmp_length;


	int max_value[line_length+1];
	for(int i = 0; i <= line_length; i++)max_value[i] = 0;

	priority_queue<Data> Q;
	Q.push(Data(0,0));

	bool FLG;

	while(!Q.empty()){

		if(Q.top().left == line_length){
			Q.pop();
		}else if(Q.top().sum_value < max_value[Q.top().left]){
			Q.pop();
		}else{

			for(int i = 0; i < N; i++){
				if(Q.top().left+info[i].length-1 >= line_length)continue;

				FLG = true;
				for(int k = 0; k < info[i].length; k++){
					if(line[Q.top().left+k] != info[i].name[k]){
						FLG = false;
						break;
					}
				}


				if(FLG){
					if(max_value[Q.top().left+info[i].length] < Q.top().sum_value+info[i].value){
						max_value[Q.top().left+info[i].length] = Q.top().sum_value+info[i].value;
						Q.push(Data(Q.top().left+info[i].length,max_value[Q.top().left+info[i].length]));
					}
				}
			}

			Q.pop();
		}
	}

	int digit = max_value[line_length];

	int dp[digit+1];
	int next_dp[digit+1];

	for(int i = 1; i <= digit; i++){
		dp[i] = BIG_NUM;
		next_dp[i] = BIG_NUM;
	}

	dp[0] = 0;
	next_dp[0] = 0;

	for(int i = 0; i < N; i++){

		FLG = true;
		for(int k = 0; k < N; k++){
			if(k == i)continue;

			if(info[k].value == info[i].value && info[k].length < info[i].length){
				FLG = false;
				break;
			}
		}

		if(!FLG)continue;

		for(int num = 1; num*info[i].value <= digit; num++){
			for(int k = digit; k-num*info[i].value >= 0; k--){
				if(dp[k-num*info[i].value] != BIG_NUM){
					next_dp[k] = min(next_dp[k],dp[k-num*info[i].value]+num*info[i].length);
				}
			}
		}
		for(int k = 1; k <= digit; k++)dp[k] = next_dp[k];
	}

	printf("Case %d: %d\n",case_number,next_dp[digit]);

	case_number++;
}


int main(){

	while(true){
		scanf("%d",&N);
		if(N == 0)break;

		func();
	}

	return 0;
}

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

using namespace std;

int brute(string& str, int N) {
    unordered_set<string> res;
    queue<string> q;
    res.insert(str);

    q.push(str);

    while (!q.empty()) {
        string cur = q.front(); q.pop();
        string tmp(cur);

        for (int i = 0; i < N-1; i ++) {
            if (cur[i] != cur[i+1]) {
                char a = cur[i], b = cur[i+1];
                char nch = 'a'*'b'*'c'/a/b;
                tmp[i] = nch, tmp[i+1] = nch;

                if (res.find(tmp) == res.end()) {
                    res.insert(tmp);
                    q.push(tmp);
                }

                tmp[i] = a, tmp[i+1] = b;
            }
        }
    }

    return res.size();
}

const int MAX_N = 2e5;
long long dp[MAX_N+1][3][2][3];
const long long MOD = 998244353;

int main(void) {
    ios_base::sync_with_stdio(false), cin.tie(NULL);
    string str; cin >> str;
    int N = (int)str.size();
    int sums = 0;
    char fir = str[0];

    if (N <= 3) {
        cout << brute(str, N) << '\n';
        return 0;
    }


    for (int i = 0; i < N; i ++) {
        if (fir != str[i])
            fir = 0;

        (sums += str[i]-'a') %= 3;
    }

    if (fir != 0) {
        cout << 1 << '\n';
        return 0;
    }

    dp[0][0][0][0] = 1;
    dp[0][1][0][1] = 1;
    dp[0][2][0][2] = 1;

    for (int i = 0; i < N-1; i ++) {
        for (int cur = 0; cur < 3; cur ++) {
            for (int nxt = 0; nxt < 3; nxt ++) {
                for (int j = 0; j < 2; j ++) {
                    for (int k = 0; k < 3; k ++) {
                        (dp[i+1][nxt][j?1:(nxt==cur)][(k+nxt)%3]
                            += dp[i][cur][j][k]) %= MOD;
                    }
                }
            }
        }
    }

    long long res = 0;

    for (int i = 0; i < 3; i ++)
        (res += dp[N-1][i][1][sums]) %= MOD;

    res ++;

    for (int i = 0; i < N; i ++) {
        if (str[i] == str[i+1])  {
            res--;
            break;
        }
    }

    res %= MOD;

    cout << res << '\n';



}


Measured memory_bytes: 28692
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>

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

void solve()
{
	vector<unsigned long long int> A(3);
	cin >> A[0] >> A[1] >> A[2];
	if (A[0] % 2 == 0 || A[1] % 2 == 0 || A[2] % 2 == 0)
	{
		cout << 0 << endl;
	}
	else
	{
		sort(A.begin(), A.end());
		cout << A[0] * A[1] << endl;
	}
}

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

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.FilterInputStream;
import java.io.BufferedInputStream;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author khokharnikunj8
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        ScanReader in = new ScanReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, ScanReader in, PrintWriter out) {
            int n = in.scanInt();
            out.println(24 + (24 - n));
        }

    }

    static class ScanReader {
        private byte[] buf = new byte[4 * 1024];
        private int index;
        private BufferedInputStream in;
        private int total;

        public ScanReader(InputStream inputStream) {
            in = new BufferedInputStream(inputStream);
        }

        private int scan() {
            if (index >= total) {
                index = 0;
                try {
                    total = in.read(buf);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (total <= 0) return -1;
            }
            return buf[index++];
        }

        public int scanInt() {
            int integer = 0;
            int n = scan();
            while (isWhiteSpace(n)) n = scan();
            int neg = 1;
            if (n == '-') {
                neg = -1;
                n = scan();
            }
            while (!isWhiteSpace(n)) {
                if (n >= '0' && n <= '9') {
                    integer *= 10;
                    integer += n - '0';
                    n = scan();
                }
            }
            return neg * integer;
        }

        private boolean isWhiteSpace(int n) {
            if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1) return true;
            else return false;
        }

    }
}



Measured memory_bytes: 21460
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int main()
{
	LL a1, a2, a3;
	in >> a1 >> a2 >> a3;
	out << (a1 + a2 + a3 >= 22 ? "bust" : "win") << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    int a, b; cin >> a >> b;

    int high = 0;

    rep(i,b-a) high += i+1;

    cout << high - b << endl;
} 

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}

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

  vector<int> tmp(2);
  REP(i, N) {
    if(i == 0) {
      tmp[0] = 0;
      continue;
    } else {
      if(S[i] == 'E') {
        tmp[1]++;
      }
    }
  }

  ll ans = pow(10, 9) + 7;
  REP(i, N) {
    if(i != 0) {
      if(S[i - 1] == 'W') tmp[0]++;
      if(S[i] == 'E') tmp[1]--;
    }
    ll c = tmp[0] + tmp[1];
    if(ans > c) ans = c;
  }

  cout << ans << endl;
}

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

int main(){
    string S;
    cin>>S;
    for(int i=0;i<S.size()-1;i++){
        for(int j=i+1;j<S.size();j++){
            if(S[i]=='C'&&S[j]=='F'){
                goto out;
            }
        }
    }
    cout<<"No"<<endl;
    return 0;
    out:
        cout<<"Yes"<<endl;
        return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 25
#define NIL -1

typedef struct{
  int parent;
  int left;
  int right;
}node;

void preParse(int);
void inParse(int);
void postParse(int);

node t[MAX];

int main(){
  int n, index, root;
  int i;

  scanf("%d", &n);

  //初期化
  for(i=0;i<n;i++){
    t[i].parent = NIL;
  }
  
  for(i=0;i<n;i++){
    scanf("%d", &index);
    scanf("%d %d", &t[index].left, &t[index].right);
    //右の子と左の子の親を設定
    if(t[index].left != NIL) t[t[index].left].parent = index; 
    if(t[index].right != NIL) t[t[index].right].parent = index;
  }

  for(i=0;i<n;i++){
    if(t[i].parent == NIL) root = i;
  }

  printf("Preorder\n");
  preParse(root);
  printf("\n");

  printf("Inorder\n");
  inParse(root);
  printf("\n");

  printf("Postorder\n");
  postParse(root);
  printf("\n");
  
  return 0;
}

void preParse(int u){
  if(u == NIL) return;
  printf(" %d", u);
  preParse(t[u].left);
  preParse(t[u].right);
}

void inParse(int u){
  if(u == NIL) return;
  inParse(t[u].left);
  printf(" %d", u);
  inParse(t[u].right);
}

void postParse(int u){
  if(u == NIL) return;
  postParse(t[u].left);
  postParse(t[u].right);
  printf(" %d", u);
}



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

int n,a[200010],b[200010],ans;

void work()
{
	scanf("%d",&n);
	for (int i=1; i<=n; i++)  scanf("%d",&a[i]),b[a[i]]=b[a[i]-1]+1;
	for (int i=1; i<=n; i++)  ans=max(ans,b[i]);
	printf("%d",n-ans);
}

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


Measured memory_bytes: 1792
#include <bits/stdc++.h>
 
#define REP(i, n) for(decltype(n) i = 0; i < n; i++)
 
#define ALL(c)   c.begin(), c.end()
#define SORT(c)  std::sort(ALL(c))
#define RSORT(c) std::sort(ALL(c), std::greater<decltype(c)::value_type>())
 
using namespace std;
using ll = long long;
 
const int MOD  = (int)1e9 + 7;
const int INF  = (int)1e9 + 1;
const ll  LINF = (ll)1e18 + 1;
 
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    int M, D;
    std::cin >> M >> D;
 
    int ans = 0;
    for(int i = 1; i <= M; i++) {
        for(int j = 1; j <= D; j++) {
            auto d1 = (j % 10);
            auto d2 = (j / 10);
            if(d1 < 2 || d2 < 2) {
                continue;
            }
            else if(d1 * d2 == i) {
                ans++;
            }
        }
    }
 
    std::cout << ans << std::endl;
 
    return 0;
}

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

public class Main {
	public static void main(String[] args) {
		BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder output = new StringBuilder();
		String line;
		int c;
		int sum = 0;
		try {
			while((line = buf.readLine()) != null) {
				for (int i = 0; i < line.length(); i++) {
					c = Integer.parseInt("" + line.charAt(i));
					sum += c;
				}
				if (sum == 0) break;
				output.append(sum).append('\n');
				sum = 0;
			}
			System.out.print(output);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

}

Measured memory_bytes: 17176
l,r = map(int,input().split())
mod = 2019
start = l % mod
end = r % mod
x = []
if r - l >= 2018:
  s = 0
elif start < end:
  for i in range(start,end):
    for j in range(i+1,end+1):
      x.append((i*j)%mod)
  s = min(x)
else:
  s = 0
print(s)

Measured memory_bytes: 75416
N,H = map(int,input().split())
ab = [list(map(int,input().split())) for _ in [0]*N]

a = max([a for a,b in ab])
b = sorted([b for _,b in ab if b>a])[::-1]
s = sum(b)
if s >= H:
    while s>=H:
        s -= b.pop()
    ans = len(b)+1
else:
    ans = (H-s-1)//a+1+len(b)
print(ans)

Measured memory_bytes: 29208
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int a,b;
  cin >> a >> b;
  string k,l;
  rep(i,b){
    char u='0'+a;
    k+=u;
  }
  rep(i,a){
    char u='0'+b;
    l+=u;
  }
  if(a>=b) cout << l << endl;
  else cout << k << endl;
}
                     

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int A,B,C,D;
  scanf("%d%d%d%d",&A,&B,&C,&D);
  int x;
  if( A < B )
    x=A;
  else
    x=B;
  int y;
  if( C < D )
    y=C;
  else
    y=D;
    
  int ans=x+y;
  printf("%d\n",ans);

  return 0;
}

Measured memory_bytes: 128
num=raw_input()
tmp=raw_input()
tmp2=raw_input()
bef="none"
n_state=0
af_state=0
if len(tmp)==1:
    out=3
else:
    if tmp[0]==tmp[1]:
        out=6
        n_state=1
        init=2
    else:
        out=3
        init=1
    #out=3

    for i in range(init,len(tmp)):
        if tmp[i]!=bef:
            #print "aaa"
            if i<int(num)-1:
                if tmp[i]==tmp[i+1]:
                    if n_state==0:
                        out=out*2
                    else:
                        out=out*3
                        n_state=0
                else:
                    if n_state==0:
                        out=out*2
                    else:
                        out=out*1
                        n_state=0
            else:
                if n_state==0:
                    out=out*2
                else:
                    out=out*1
                    n_state=0
        else:
            n_state=1
        bef=tmp[i]
print out % 1000000007


Measured memory_bytes: 2696
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0; i < n; i++)
#define repd(i, n) for (int i = n-1; i > -1; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;

int main()
{
    string s; cin >> s;
    int n = s.size();
    char chr[4] = {'A','T','G','C'};
    int ans = 0, cnt = 0;
    rep(i, n){
        bool flag = false;
        rep(j, 4){
            if(s[i] == chr[j]) flag = true;
        }
        if (flag){
            cnt++;
            ans = max(ans, cnt);
        } else {
            cnt = 0;
        }
    }
    cout << ans << endl;  
}

Measured memory_bytes: 3624
#include<iostream>
#include<vector>
#include<algorithm>
#include<string.h>
#include<complex>
#include<set>
using namespace std;
typedef long long int llint;
#define rep(i,n) for(int i=0;i<n;i++)
int main() {
	int n;
	cin >> n;
	vector<int>a(n);
	rep(i, n)cin >> a[i];
	set<int> b;
	int x = 1;
	int ans = 0;
	while (b.count(x) == 0) {
		b.insert(x);
		ans++;
		x = a[x - 1];
		if (x == 2) {
			cout << ans << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
int n,h[100005],k=1,cnt=0,cost[100005];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&h[i]);
	}
	if(n==1){
		printf("0");
	}else{
		cost[1]=0;
		cost[2]=abs(h[2]-h[1]);
		if(n==2){
			printf("%d",cost[2]);
		}else{
			for(int i=3;i<=n;i++){
				cost[i]=min(cost[i-2]+abs(h[i]-h[i-2]),cost[i-1]+abs(h[i]-h[i-1]));
			}
			cout << cost[n];
		}
	}
}

Measured memory_bytes: 1024
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int n=scanner.nextInt();
		Map<Character,Integer>map=new TreeMap<>();
		for(int i=0;i<n;i++) {
			String s=scanner.next();
			for(char c='a';c<='z';c++) {
				int cnt=0;
				for(int j=0;j<s.length();j++) {
					if(c==s.charAt(j)) {
						cnt++;
					}
				}
				if (map.containsKey(c)) {
					int tmp=map.get(c);
					tmp=Math.min(tmp, cnt);
					map.put(c, tmp);
				} else {
					map.put(c, cnt);
				}
			}
		}
		for(char c:map.keySet()) {
			for(int i=0;i<map.get(c);i++) {
				System.out.print(c);
			}
		}
		System.out.println("");
	}
}

Measured memory_bytes: 23252
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;

int ch[30],ch2[30];
char c1[30],c2[30];
int box[30][30];



int main(){
  int a,i,j,k;
  string s,t;
  cin >> s >> t;
  for(i=0;i<30;i++){
    c1[i]=c2[i]='\0';
    ch[i]=-1;
  }
  for(i=0;i<s.size();i++){
    if(c1[t[i]-'a']=='\0'){
      c1[t[i]-'a']=s[i];
    }else{
      if(c1[t[i]-'a']==s[i])continue;
      else{
        cout << "No" << endl;
        return 0;
      }
    }

    if(c2[s[i]-'a']=='\0'){
      c2[s[i]-'a']=t[i];
    }else{
      if(t[i]==s[i]){//同じとき
        if(c2[s[i]-'a']!=t[i]){//違うのがはいってたらno
          cout << "No" << endl;
          return 0;
        }
      }else{//違うとき
        if(c2[s[i]-'a']!=t[i]){
          cout << "No" << endl;
          return 0;
        }
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}


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

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll x,n,c=0;
    cin>>n;
    int a[n+1]={};
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    for(int i=1;i<=n;i++)
    {
        if(a[a[i]]==i)c++;
    }
    cout<<c/2<<endl;
    return 0;
}

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

int main (void) {
    int K;
    cin >> K;
    queue<int64_t> a;
    
    
    for (int i = 1; i <= 9; i++) a.push(i);
    for (int i = 1; i < K; i++) {
        int64_t x = a.front();
        a.pop();
        if (x % 10) a.push(10 * x + (x % 10) - 1);
        a.push(10 * x + (x % 10));
        if (x % 10 != 9) a.push(10 * x + (x % 10) + 1);
    }
    cout << a.front() << endl;
    
    
}

Measured memory_bytes: 5148
# 解説を参考に作成
"""
D - Decayed Bridges
"""


class UnionFind():
    # 下記から拝借
    # https://note.nkmk.me/python-union-find/
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join(
            '{}: {}'.format(r, self.members(r)) for r in self.roots())


# import sys
# sys.setrecursionlimit(10 ** 6)
# import bisect
# from collections import deque
# from decorator import stop_watch
# 
# 
# @stop_watch
def solve(N, M, AB):
    AB = AB[::-1]
    AB = [[ab[0] - 1, ab[1] - 1] for ab in AB]
    un = UnionFind(N)
    ans = [N * (N - 1) // 2]
    for a, b in AB:
        if un.same(a, b):
            ans.append(ans[-1])
            continue
        ans.append(ans[-1] - (un.size(a) * un.size(b)))
        un.union(a, b)
    ans.reverse()
    for a in ans[1:]:
        print(a)


if __name__ == '__main__':
    N, M = map(int, input().split())
    AB = [[int(i) for i in input().split()] for _ in range(M)]
    solve(N, M, AB)

    # # test
    # from random import randint
    # from func import random_str
    # solve()


Measured memory_bytes: 46352
N = int(input())
S = [input() for _ in range(N)]
AC=0
WA=0
TLE=0
RE=0
for i in S:
    if i=='AC':
        AC+=1
    elif i=='WA':
        WA+=1
    elif i=='TLE':
        TLE+=1
    else:
        RE+=1
print('AC x', AC)
print('WA x', WA)
print('TLE x', TLE)
print('RE x', RE)

Measured memory_bytes: 16284