akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Console;
using static System.Convert;
using static System.Math;
using static Extentions;

class IO
{
    int idx;
    string[] input;

    public IO(TextReader reader)
    {
        input = reader.ReadToEnd().Split(new[] { " ", Environment.NewLine },
            StringSplitOptions.RemoveEmptyEntries);
    }

    T Get<T>(Func<string, T> parser) => parser(input[idx++]);

    public string S => Get(s => s);
    public char C => Get(char.Parse);
    public int I => Get(int.Parse);
    public long L => Get(long.Parse);
    public double F => Get(double.Parse);
    public decimal D => Get(decimal.Parse);
    public BigInteger B => Get(BigInteger.Parse);

    T[] Gets<T>(int n, Func<string, T> parser)
        => input.Skip((idx += n) - n).Take(n).Select(parser).ToArray();

    public string[] Ss(int n) => Gets(n, s => s);
    public char[] Cs(int n) => Gets(n, char.Parse);
    public int[] Is(int n) => Gets(n, int.Parse);
    public long[] Ls(int n) => Gets(n, long.Parse);
    public double[] Fs(int n) => Gets(n, double.Parse);
    public decimal[] Ds(int n) => Gets(n, decimal.Parse);
    public BigInteger[] Bs(int n) => Gets(n, BigInteger.Parse);

    public void Write<T>(params T[] xs) => WriteLine(string.Join(" ", xs));
    public void Write(params object[] xs) => WriteLine(string.Join(" ", xs));
}

static class Extentions
{
}

static class Program
{
    public static void Main()
    {
        var sw = new StreamWriter(OpenStandardOutput())
        { NewLine = "\n", AutoFlush = true };
#if !DEBUG
        sw.AutoFlush = false;        
#endif
        SetOut(sw);
        Solve(new IO(In));
        Out.Flush();
    }

    static void Solve(IO io)
    {
        var n = io.I;
        var k = io.I;
        var t = io.Is(n);
        var a = new List<int>(t.Distinct());

        if (k > a.Max()) { io.Write("IMPOSSIBLE"); return; }
        if (a.Contains(k)) { io.Write("POSSIBLE"); return; }

        a.Sort();
        var min = int.MaxValue;

        for (var i = 0; i < a.Count - 1; i++)
            min = Min(min, Abs(a[i] - a[i + 1]));

        var tmp = min;

        while (true)
        {
            if (a.Min() != min) min = Min(min, Abs(a.Min() - min));
            if (tmp == min) break;
            if (!a.Contains(min)) a.Add(min);
            tmp = min;
        }

        if (a.All(x => x % min == 0) && k % min != 0) io.Write("IMPOSSIBLE");
        else io.Write("POSSIBLE");
    }
}

Measured memory_bytes: 29408
n = int(input().strip())
l = list(map(int, input().split()))

t = 0
for i in range(n):
    for j in range(i + 1, n):
        if l[i] == l[j]:
            continue
        for k in range(j + 1, n):
            if l[i] == l[k] or l[j] == l[k]:
                continue
            if l[i] < l[j] + l[k] and l[j] < l[i] + l[k] and l[k] < l[j] + l[i]:
                t += 1

print(t)

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

class Factorization:	
	def __init__(self):
		# privateなインスタンス変数を作成
		self.__factors = dict()
		self.__n = 0
	
	
	def get_factors(self, n):
		# [summary] 素因数分解した結果を、辞書([素因数, 指数]...)で返す
		self.__factors.clear()
		self.__n = n
		
		if n < 2:
			# 2より小さい数の場合、素因数分解できない
			return { n:1 }
		else:
			self.__factorization()
			
			return self.__factors
	
	
	def get_divisors(self, n):
		# [summary] 約数をリストに列挙
		self.__factors.clear()
		self.__n = n
		
		if n < 2:
			return [1]
		else:
			self.__factorization()
			divisors = [1]
			
			for k, v in self.__factors.items():
				import copy
				copy_ = copy.deepcopy(divisors)
								
				for i in range(1, v + 1):
					for c in copy_:
						divisors.append(c * (k ** i))
			
			return divisors

				
	def count_divisors(self, n):
		# [summary] 約数の個数を返す
		self.__factors.clear()
		self.__n = n
		
		if n < 2:
			return 1
		else:
			self.__factorization()
			count = 1
			
			for v in self.__factors.values():
				count *= v + 1
			
			return count
	

	def	__factorization(self):
		# [summary]素因数分解した結果を、インスタンス変数に格納
		
		# 2,3,5で、割れなくなるまで割り続ける
		# (末尾に2,3,5のつく数は素数でないことが明白なので
		# 後続の処理で素数のリストに入れないように、先に処理する)
		self.__divide_with(2)
		self.__divide_with(3)
		self.__divide_with(5)
			
		# 平方根以下の素数で総当たりで試し割りする
		# (実際は、素数らしき数)
		import math
		sqrt_ = math.floor(math.sqrt(self.__n))
			
		primes = [7, 11, 13, 17, 19, 23, 29, 31]
		i = 0
		is_break = False
			
		while self.__n > 1:
			for p in primes:
				if p + i <= sqrt_:
					self.__divide_with(p + i)
				else:
					# 試し割りする数が平方根を超えたら、ループを抜ける
					is_break = True
						
					# 1が素因数に追加されることを防止
					if self.__n > 1:
						self.__factors.setdefault(self.__n, 1)
				
			if is_break:
				break
			else:
				i += 30
	
	
	def __divide_with(self, d):
		count = 0
		
		while self.__n % d == 0:
			self.__n //= d
			count += 1
		
		if count > 0:
			self.__factors.setdefault(d, count)


# D - Div Game
n = int(input())

if n == 1:
	print(0)
else:
	lib = Factorization()
	factors = lib.get_factors(n)

	ans = 0

	for v in factors.values():
		count = 0
		sum = 0
		i = 1
	
		while True:
			count += 1
			sum += i
		
			if sum > v:
				count -= 1
				break
			elif sum == v:
				break
			else:
				i += 1 
	
		ans += count

	print(ans)

Measured memory_bytes: 9344
#include "stdio.h"
#include "ctype.h"

int main(void)
{
	char ch;

	while(1)
	{
		scanf("%c", &ch);
		if (ch == '\n')
		{
			printf("\n");
			break;
		}
		if (islower(ch))
		{
			ch = toupper(ch);
		}
		else if (isupper(ch))
		{
			ch = tolower(ch);
		}

		printf("%c", ch);
	}

	return 0;
}

Measured memory_bytes: 524
#include<stdio.h>
#include<string.h>
#include<string>
#include<math.h>
#include<map>
#include<vector>
#include<queue>
#include<set>
#include<algorithm>
using namespace std;
int a[3];
int main(){
    for(int i=0;i<3;i++){
        scanf("%d",&a[i]);
    }
    sort(a,a+3);
    printf("%d\n",a[0]+a[1]);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF    	((ll)1ll<<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007ll)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			(3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}
template<class T> void chmax(T &a, const T &b){if(a<b)a=b;}
template<class T> void chmin(T &a, const T &b){if(a>b)a=b;}
void YN(bool b){cout<<(b?"YES":"NO")<<endl;}
void Yn(bool b){cout<<(b?"Yes":"No")<<endl;}
void yn(bool b){cout<<(b?"yes":"no")<<endl;}

class compare {
public:
	bool operator()(pll a, pll b) {
		return (a.fs > b.fs);
	}
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vl v(3*n);
	vl l(n+1),r(n+1);
	rep(i,3*n)cin>>v[i];
	priority_queue<ll,vector<ll>,greater<ll>> lq;
	ll sum=0;
	rep(i,n){
		sum+=v[i];
		lq.push(v[i]);
	}
	l[0]=sum;
	rep(i,n){
		lq.push(v[n+i]);
		sum+=v[n+i];
		ll t;
		t=lq.top();lq.pop();
		sum-=t;
		l[i+1]=sum;
	}

	priority_queue<ll> rq;
	sum=0;
	rep(i,n){
		sum+=v[3*n-1-i];
		rq.push(v[3*n-1-i]);
	}
	r[n]=sum;
	rep(i,n){
		rq.push(v[2*n-1-i]);
		sum+=v[2*n-1-i];
		ll t;
		t=rq.top();rq.pop();
		sum-=t;
		r[n-1-i]=sum;
	}
	ll ans=-LINF;
	rep(i,n+1)chmax(ans,l[i]-r[i]);
	cout<<ans<<endl;
}


Measured memory_bytes: 6516
#include <stdio.h>

int main(void)
{
	int i,smallp,smallj,answer;
	int pasta[10];
	int juice[10];
	for(i=1;i<=3;i++){
		scanf("%d",&pasta[i-1]);
	}
	smallp=pasta[0];
	if(smallp>pasta[1]){
		smallp=pasta[1];
	}
	if(smallp>pasta[2]){
		smallp=pasta[2];
	}
	for(i=1;i<=2;i++){
		scanf("%d",&juice[i-1]);
	}
	if(juice[0]>=juice[1]){
		smallj=juice[1];
	}else{
		smallj=juice[0];
	}
	printf("%d\n",smallp+smallj-50);
	return 0;
}

Measured memory_bytes: 592
n = int(input())
f = [[int(x) for x in input().split()] for i in range(n)]
p = [[int(x) for x in input().split()] for i in range(n)]
t={i:0 for i in range(1,2**10)}
for i in range(1,2**10):
  d, b={j:0 for j in range(n)}, format(i, "010b")
  for j in range(n):
    for k in range(10):
      if (i>>k)%2&f[j][k]==1: d[j]+=1
    t[i]+=p[j][d[j]]
print(max(t.values()))

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

using namespace std;

const int DIM = 207;

vector <int> v[DIM];
int col[DIM];

int n;

int get(int start)
{
	memset(col, 0, sizeof(col));
	
	queue <int> q;
	
	col[start] = 1;
	q.push(start);
	
	int res = 1;
	
	while(!q.empty())
	{
		int nod = q.front();
		q.pop();
		
		for(auto i : v[nod])
			if(col[i] != 0 && abs(col[i] - col[nod]) != 1)
			{
				return -1;
			}
			else
				if(col[i] == 0)
				{
					col[i] = col[nod] + 1;
					res = max(res, col[i]);
					q.push(i);
				}
	}
	
	return res;
}

main()
{
	cin >> n;
	
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= n; j++)
		{
			char c;
			cin >> c;
			
			if(c == '1')
				v[i].push_back(j);
		}
	
	int ans = -1;
	
	for(int i = 1; i <= n; i++)
		ans = max(ans, get(i));
	
	cout << ans;
}

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

int main() {
  int N;
  int A, B;
  cin >> N;

  if ( N == 1 ){
    cout << "Hello World" << endl;
  }
  else if ( N == 2 ){
    cin >> A >> B;
    cout << A + B << endl;
  }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<ll, int> P;

int main()
{
	int n; cin>>n;
	string s[55];
	ll c[55];
	for(int i=0; i<n; i++){
		cin>>s[i]>>c[i];
	}
	const ll INF=1e18;
	ll ans=INF;
	for(int i=0; i<n; i++){
		string t=s[i];
		reverse(t.begin(), t.end());
		if(s[i]==t) ans=min(ans, c[i]);
	}
	vector<P> g[2020];
	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++){
			bool ok=1;
			for(int k=0; k<min(s[i].size(), s[j].size()); k++){
				if(s[i][k]!=s[j][(int)s[j].size()-1-k]){
					ok=0;break;
				}
			}
			if(!ok) continue;
			string t=s[i]+s[j], tr=t;
			reverse(tr.begin(), tr.end());
			if(t==tr){
				g[0].push_back({c[i]+c[j], 0});
			}else{
				int l=abs((int)s[i].size()-(int)s[j].size());
				if(s[i].size()<s[j].size()){
					g[0].push_back({c[i]+c[j], 40*j+20+l});
				}else{
					g[0].push_back({c[i]+c[j], 40*i+l});
				}
			}
		}
	}
	for(int i=0; i<n; i++){
		for(int l=1; l<(int)s[i].size(); l++){
			for(int j=0; j<n; j++){
				bool ok=1;
				for(int k=0; k<min(l, (int)s[j].size()); k++){
					if(s[i][(int)s[i].size()-l+k]!=s[j][(int)s[j].size()-1-k]){
						ok=0;break;
					}
				}
				if(!ok) continue;
				string t=s[i].substr((int)s[i].size()-l)+s[j], tr=t;
				reverse(tr.begin(), tr.end());
				if(t==tr){
					g[40*i+l].push_back({c[j], 0});
				}else{
					int m=abs(l-(int)s[j].size());
					if(l<s[j].size()){
						g[40*i+l].push_back({c[j], 40*j+20+m});
					}else{
						g[40*i+l].push_back({c[j], 40*i+m});
					}
				}
			}
		}
	}
	for(int i=0; i<n; i++){
		for(int l=1; l<(int)s[i].size(); l++){
			for(int j=0; j<n; j++){
				bool ok=1;
				for(int k=0; k<min(l, (int)s[j].size()); k++){
					if(s[i][l-1-k]!=s[j][k]){
						ok=0;break;
					}
				}
				if(!ok) continue;
				string t=s[j]+s[i].substr(0, l), tr=t;
				reverse(tr.begin(), tr.end());
				if(t==tr){
					g[40*i+20+l].push_back({c[j], 0});
				}else{
					int m=abs(l-(int)s[j].size());
					if(l<s[j].size()){
						g[40*i+20+l].push_back({c[j], 40*j+m});
					}else{
						g[40*i+20+l].push_back({c[j], 40*i+20+m});
					}
				}
			}
		}
	}
	ll d[2020];
	for(int i=0; i<40*n; i++) d[i]=INF;
	d[0]=0;
	priority_queue<P, vector<P>, greater<P>> que;
	que.push({0, 0});
	while(!que.empty()){
		P p=que.top(); que.pop();
		int x=p.second;
		if(p.first>d[x]) continue;
		for(auto q:g[x]){
			int y=q.second;
			if(d[y]>d[x]+q.first){
				d[y]=d[x]+q.first;
				que.push({d[y], y});
			}
		}
	}
	for(int x=0; x<40*n; x++){
		for(auto q:g[x]){
			int y=q.second;
			if(y==0){
				ans=min(ans, d[x]+q.first);
			}
		}
	}
	if(ans<INF) cout<<ans<<endl;
	else cout<<-1<<endl;
	return 0;
}


Measured memory_bytes: 3696
from collections import Counter
n = int(input())
A = list(map(int, input().split()))
c = Counter(A)
com = {}
ans = 0
for k, v in c.items():
  ans += v*(v-1)//2 

for i in range(n):
  a = A[i]
  print(ans-c[a]*(c[a]-1)//2+(c[a]-1)*(c[a]-2)//2 )
  


Measured memory_bytes: 27028
import sys

def main():
    lines = sys.stdin.readlines()

    A = []
    B = []
    C = []
    n = 0
    m = 0
    for i, line in enumerate(lines):
        # print(line)
        # rm '\n' from string of a line
        line = line.strip('\n')
        elems = line.split(" ")
        if i == 0:
            n = int(elems[0])
            m = int(elems[1])
        elif 0 < i and i < n + 1:
            A.append([int(e) for e in elems])
        elif n < i:
            B.append([int(elems[0])])
    c = []
    for i in range(0, n):
        num = 0
        for index, e in enumerate(A[i]):
            num += e * B[index][0]
        c.append(num)

    for i in range(0, n):
        print c[i]

if __name__ == "__main__":
    main()

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

public class Main {
	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int w = Integer.parseInt(br.readLine());
		int n = Integer.parseInt(br.readLine());
		int[] lots = new int[w];
		for(int i = 0;i < lots.length;i++){
			lots[i] = i + 1;
		}
		String[] bufbuf;
		int[] buf;
		for(int i = 0;i < n;i++){
			bufbuf = br.readLine().split(",");
			buf = new int[bufbuf.length];
			for(int j = 0;j < bufbuf.length;j++){
				buf[j] = Integer.parseInt(bufbuf[j])-1;
			}
			int tmp = lots[buf[0]];
			lots[buf[0]] = lots[buf[1]];
			lots[buf[1]] = tmp;
		}
		for(int i = 0;i < lots.length;i++){
			System.out.println(lots[i]);
		}
	}
}

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

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

using ll = long long;
ll P[100005];
const ll mod = 998244353;

ll pow(ll x, ll y) {
    if (y == 0LL) return 1LL;
    ll X = 1LL;
    for (ll i = 0LL; i < y; i++) {
      X *= x;
      X %= mod;
    }
    return X;
}

int main() {
  ll N;
  cin >> N;
  bool can = true;
  ll M = 0LL;
  for(ll i = 0; i < N; i++) {
    ll x;
    cin >> x;
    chmax(M, x);
    if(i == 0LL && x != 0) {
      can = false;
      break;
    }
    P[x]++;
  }
  if(P[0] != 1) can = false;
  ll ans = 1LL;
  for(ll i = 1LL; i <= M; i++) {
    ans *= pow(P[i-1], P[i]);
    ans %= mod;
  }
  if(can) cout << ans << endl;
  if(!can) cout << 0 << endl;
}
  

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
	int c[4][4];
	rep(i,3) rep(j,3) cin>>c[i][j];
	bool chk=1;
	rep(i,2){
		rep(j,2){
			if(c[i+1][j]-c[i][j]!=c[i+1][j+1]-c[i][j+1]) chk=0;
			if(c[i+1][j+1]-c[i+1][j]!=c[i][j+1]-c[i][j]) chk=0;
		}
	}
	if(chk) cout<<"Yes"<<"\n";
	else cout<<"No"<<"\n";
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<numeric>
#include<vector>
#include<tuple>
using namespace std;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
typedef long long ll;
const int MOD = 1e9 + 7;
string a, b;
int N;
int main(void)
{
	cin >>N>> a >> b;
	int ans = 2 * N;
	FOR(i, 1, N+1) {
		int cnt = 0;
		FOR(k, 0, i) {
			if (a[N  -i + k] != b[k])continue;
			cnt++;
		}
		if (cnt == i) {
			ans = 2*N-i;
		}
	}
	cout << ans << endl;
	return 0;
}


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

#define MAX 200010

using namespace std;

int A,B;
int a[MAX],b[MAX];
map<int,int> mpa,mpb;

int main(void)
{
    cin>>A;

    for(int i = 0;i < A;i++)
        cin>>a[i];
    cin>>B;
    for(int i = 0;i < B;i++)
        cin>>b[i];

    for(int i = 0;i < A;i++)
        mpa[a[i]]++;
    for(int i = 0;i < B;i++)
        mpb[b[i]]++;

    for(int i = 0;i < B;i++)
    {
        if(mpb[b[i]] > mpa[b[i]])
        {
            cout<<"NO"<<endl;

            return 0;
        }
    }

    cout<<"YES"<<endl;

    return 0;
}


Measured memory_bytes: 22656
/**
*    Username : adhoc_king
*    Name : adhoc_king
*    Institute : IIT Bombay
*/

#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <string>
// #include <deque>
// #include <queue>
// #include <array>
// #include <ctime>
// #include <list>
// #include <map>
// #include <set>
// #include <cassert>
// #include <complex>
// #include <sstream>
// #include <forward_list>
// #include <unordered_set>
// #include <unordered_map>

using namespace std;

#define int long long
#define pb push_back
#define mp make_pair
#define scani(n) scanf("%d",&n);
#define EPS 1e-9
#define FOR(i,n) for(int i=0; i<n; i++)
#define X first
#define Y second
#define arrinput for(int i=0; i<n; i++) cin>>arr[i];
#define arrsum for(int i=0; i<n; i++) sum+=arr[i];
#define for0(i,n) for(int i=0; i<n; i++)
#define for1(i,n) for(int i=1; i<=n; i++)
#define forr(i,n) for(int i=n-1; i>=0; i--)
#define all(v) v.begin(), v.end()

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;

const int MOD = 1e9+7;
const int n_ = 1e5+1000;
const long double PI = acos(-1.0);

ll gcd (ll a, ll b) {return ( a ? gcd(b%a, a) : b );}
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}
ll power(ll a, ll n, ll mod) {ll p = 1;while (n > 0) {if(n%2) {p = p * a; p %= mod;} n >>= 1; a *= a; a %= mod;} return p % mod;}

bool vowel(char ch) {
    if(ch=='a' || ch=='e' || ch=='i' || ch=='o' || ch=='u') return true;
    else return false;
}

// Union-Find Disjoint Sets Library written in OOP manner, using both path compression and union by rank heuristics
class UnionFind {                                              // OOP style
private:
    vi p, rank, setSize;                       // remember: vi is vector<int>
    int numSets;
public:
    UnionFind(int N) {
        setSize.assign(N, 1); numSets = N; rank.assign(N, 0);
        p.assign(N, 0); for (int i = 0; i < N; i++) p[i] = i; }
    int findSet(int i) { return (p[i] == i) ? i : (p[i] = findSet(p[i])); }
    bool isSameSet(int i, int j) { return findSet(i) == findSet(j); }
    void unionSet(int i, int j) { 
        if (!isSameSet(i, j)) { numSets--; 
        int x = findSet(i), y = findSet(j);
        // rank is used to keep the tree short
        if (rank[x] > rank[y]) { p[y] = x; setSize[x] += setSize[y]; }
        else                   { p[x] = y; setSize[y] += setSize[x];
                                 if (rank[x] == rank[y]) rank[y]++; } } }
    int numDisjointSets() { return numSets; }
    int sizeOfSet(int i) { return setSize[findSet(i)]; }
};

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

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    int n;
    cin>>n;
    int arr[n], brr[n];
    for0(i,n) cin>>arr[i];
    brr[0] = arr[0];
    for1(i,n-1) brr[i] = max(brr[i-1], arr[i]);
    int count = 0;
    for0(i,n) if(arr[i] == brr[i]) count++;
    cout<<count;

    return 0;
}

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

int main() {

    while(1){
        int n;
        cin>>n;
        int s[n];
        if(n==0) break;
        else{
            int sum=0;
            for(int i=0;i<n;i++){
                cin>>s[i];
                sum+=s[i];
            }
            double ave=1.0*sum/n;
            double dif=0;
            for(int i=0;i<n;i++){
                dif+=pow(s[i]-ave,2);
            }
            double result=sqrt(dif/n);
            printf("%lf\n",result);

        }
    }
}


Measured memory_bytes: 3204
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>

using namespace std;

int main() {
	int n;

	cin >> n;

	if (n % 2 == 0) {
		cout << n / 2 * n / 2;
	}
	else {
		cout << ((int)n / 2)*(int)(n / 2 + 1);
	}

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	int x = 0, y = 0;
	while (1){
		scanf("%d %d", &x, &y);
		if (x == 0 && y == 0){
			break;
		}
		if (x <= y){
			printf("%d %d\n", x, y);
		}
		else{
			printf("%d %d\n", y, x);
		}
	}
}

Measured memory_bytes: 2632
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int a, b; cin >> a >> b;
    cout << (a-1)*(b-1) << endl;
}

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

const int MAX_N = 100;
const int INF = 1 << 29;

int main()
{
  int n, m, s, g1, g2;
  while (scanf("%d %d %d %d %d", &n, &m, &s, &g1, &g2) != EOF) {
    if (n == 0 && m == 0 && s == 0 && g1 == 0 && g2 == 0)
      break;
    --s;
    --g1;
    --g2;

    int cost[MAX_N][MAX_N];
    for (int i = 0; i < MAX_N; ++i) {
      for (int j = 0; j < MAX_N; ++j) {
	if (i == j)
	  cost[i][j] = 0;
	else
	  cost[i][j] = INF;
      }
    }

    for (int i = 0; i < m; ++i) {
      int b1, b2, c;
      scanf("%d %d %d", &b1, &b2, &c);
      --b1;
      --b2;
      cost[b1][b2] = c;
    }

    for (int k = 0; k < n; ++k)
      for (int i = 0; i < n; ++i)
	for (int j = 0; j < n; ++j)
	  cost[i][j] = min(cost[i][j], cost[i][k]+cost[k][j]);

    int ans = INF;
    for (int i = 0; i < n; ++i)
      ans = min(ans, cost[s][i]+cost[i][g1]+cost[i][g2]);

    printf("%d\n", ans);
  }
  return 0;
}

Measured memory_bytes: 796
(k, n) = input().split()
n = int(n)
k = int(k)
alist = list(map(int,input().split()))
alist.sort()

maxd = 0

for i in range(n):
  if i < (n-1):
    d = alist[i+1] - alist[i]
  else:
    d = k - ( alist[i] - alist[0] )
  if maxd < d:
    maxd = d
print(k - maxd)

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

typedef long long ll;

std::mt19937 gen;

struct node {
  bool rev;
  int prior, size = 1;
  char c;
  node *l = nullptr, *r = nullptr;
  node() { prior = gen(); }
};

node *root = nullptr;

int size (node *v) { return v ? v->size : 0; }

void upd (node *v) { v->size = 1 + size(v->l) + size(v->r); }

typedef pair<node *, node *> Pair;

void push(node *v) {
  if (v->rev) {
    swap(v->l, v->r);
    if (v->l)
      v->l->rev ^= 1;
    if (v->r)
      v->r->rev ^= 1;
  }
  v->rev = 0;
}

Pair split(node *p, int k) {
  if (!p)
    return {0, 0};
  push(p);
  if (size(p->l) + 1 <= k) {
    Pair q = split(p->r, k - size(p->l) - 1);
    p->r = q.first;
    upd(p);
    return {p, q.second};
  } else {
    Pair q = split(p->l, k);
    p->l = q.second;
    upd(p);
    return {q.first, p};
  }
}

node* merge (node *l, node *r) {
    if (!l) return r;
    if (!r) return l;
    push(l);
    push(r);
    if (l->prior > r->prior) {
        l->r = merge(l->r, r);
        upd(l);
        return l;
    }
    else {
        r->l = merge(l, r->l);
        upd(r);
        return r;
    }
}

void dfs(node* v) {
  if (!v)
    return;
  push(v);
  dfs(v->l);
  putchar(v->c);
  dfs(v->r);
}

int main(int argc, char **argv) {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  std::string s;
  int m;
  std::cin >> s >> m;
  for (auto d : s) {
    node* nn = new node();
    nn->c = d;
    root = merge(root, nn);
  }
  std::string g;
  while (m--) {
    int t;
    std::cin >> t;
    if (t == 1) {
      if (root)
        root->rev ^= 1;
    } else {
      int f;
      std::cin >> f >> g;
      node* nn = nullptr;
      for (auto d : g) {
        node* p = new node();
        p->c = d;
        nn = merge(nn, p);
      }
      if (f == 1)
        root = merge(nn, root);
      else
        root = merge(root, nn);
    }
  }
  dfs(root);
  putchar('\n');
}

Measured memory_bytes: 14672
import java.util.Scanner;

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

		int cnt=0;
		for (int i = 0; i < p.length; i++) {
			p[i] = sc.nextInt();

			if ((i+1)!=p[i]) {
				cnt++;
			}
		}
		if (cnt <= 2) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}


Measured memory_bytes: 23380
P = 1000000007
def pow(a,n)
	r = 1
	while n > 0
		if n % 2 == 1
			r *= a
			r %= P
		end
		a **= 2
		a %= P
		n /= 2
	end
	r
end
N = gets.to_i
A = Hash.new{0}
ab0 = 0
N.times{|n|
	a, b = gets.split.map(&:to_i)
	if a == 0 && b == 0
		ab0 += 1
		next
	end
	gcd = a.gcd(b)
	a /= gcd
	b /= gcd
	if (a < 0) == (b < 0) || a == 0 || b == 0
		a = a.abs
	else
		a = -a.abs
	end
	b = b.abs
	A[[a, b]] += 1
}
keys = A.keys
r = 1
keys.each{|k|
	next unless A[k]
	a, b = k
	if a <= 0
		b = -b
		a = a.abs
	end
	ik = [-b, a]
	if A[ik]
		a = pow(2, A[k]) - 1
		b = pow(2, A[ik]) - 1
		r *= a + b + 1
		r %= P
		A[ik] = nil
	else
		r *= pow(2, A[k])
		r %= P
	end
}
puts (r - 1 + ab0) % P


Measured memory_bytes: 47856
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author lstd
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <bitset>
#include <random>
#include <chrono>
#include <complex>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <ctime>

using namespace std;

#define sqr(x) ((x)*(x))
#define mp make_pair
#define pb push_back
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define RE(i, n) FOR(i,1,n)
#define REP(i,n) FOR(i, 0, (int)(n)-1)
#define fst first
#define snd second

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;

string to_string(string s) {
    return '"' + s + '"';
}

string to_string(const char* s) {
    return to_string((string) s);
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}



void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

int XMOV[4] = {0, 0, 1, -1};
int YMOV[4] = {1, -1, 0, 0};

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

using namespace std;

class EStringsOfImpurity {
public:
	void solve(std::istream& in, std::ostream& out) {
		string s, t;

		in >> s >> t;

		map<char, vector<int>> sc, tc;
		for (int i = 0; i < s.size(); i++)
			sc[s[i]].pb(i);

		bool flag = true;
		for (int i = 0; i < t.size(); i++)
			if (sc.count(t[i]) == 0)
				flag = false;

		if (!flag){
			out << -1;
			return;
		}

		int carry = 0, lastidx = -1;
		for (int i=0; i < t.size(); i++){
			int cur;
			auto idx = upper_bound(sc[t[i]].begin(), sc[t[i]].end(), lastidx);
			if (idx != sc[t[i]].end()){
				cur = *idx;
			}
			else{
				carry++;
				cur = sc[t[i]][0];
			}
			lastidx = cur;

		}

		out << carry*s.size()+lastidx+1;
	}
};

int main() {
	EStringsOfImpurity solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

Measured memory_bytes: 1216
#include <cstdio>
#include <array>
#include <algorithm>

using namespace std;

const int32_t N = 100000;
array<int32_t, N> parent, depth;
array<vector<int32_t>, N> children;

void calc_depth(int32_t id, int32_t d) {
    depth[id] = d;
    for (int32_t id_c : children[id]) calc_depth(id_c, d+1);
    return;
}

int main() {
    parent.fill(-1);
    int32_t n;

    scanf("%d", &n);
    for (int32_t i = 0; i < n; i++) {
        int32_t id;
        scanf("%d", &id);

        int32_t k;
        scanf("%d", &k);
        for (int32_t j = 0; j < k; j++) {
            int32_t c;
            scanf("%d", &c);
            parent[c] = id;
            children[id].push_back(c);
        }
    }

    int32_t id = 0;
    while (parent[id] != -1) id++;
    calc_depth(id, 0);

    for (int32_t id = 0; id < n; id++) {
        printf("node %d: parent = %d, depth = %d, ", id, parent[id], depth[id]);

        if (parent[id] == -1) {
            printf("root");
        } else if (children[id].empty()) {
            printf("leaf");
        } else {
            printf("internal node");
        }

        printf(", [");
        for (int32_t id_c : children[id]) {
            if (id_c != children[id][0]) printf(", ");
            printf("%d", id_c);
        }
        printf("]\n");
    }

    return 0;
}

Measured memory_bytes: 6556
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 300010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
int A[MAX_N];

void solve() {
	cin >> N;
	string S;
	cin >> S;
	rep(i, 0, N) {
		if(S[i] == '#') A[i + 1] = 1;
		A[i + 1] += A[i];
	}
	int res = inf;
	rep(i, 0, N + 1) {
		MIN(res, A[i] + N - i - (A[N] - A[i]));
	}
	cout << res << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



Measured memory_bytes: 1428
Imports System

Module Program
    Dim a As Integer
    Dim result As Integer
    Sub Main(args As String())
        a = Console.ReadLine()
        If 400 <= a And a <= 599 Then
            result = 8
            Console.WriteLine(result)
        ElseIf 600 <= a And a <= 799 Then
            result = 7
            Console.WriteLine(result)
        ElseIf 800 <= a And a <= 999 Then
            result = 6
            Console.WriteLine(result)
        ElseIf 1000 <= a And a <= 1199 Then
            result = 5
            Console.WriteLine(result)
        ElseIf 1200 <= a And a <= 1399 Then
            result = 4
            Console.WriteLine(result)
        ElseIf 1400 <= a And a <= 1599 Then
            result = 3
            Console.WriteLine(result)
        ElseIf 1600 <= a And a <= 1799 Then
            result = 2
            Console.WriteLine(result)
        ElseIf 1800 <= a And a <= 1999 Then
            result = 1
            Console.WriteLine(result)
        End If

    End Sub
End Module

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if (a+b > c+d) {
    cout << "Left" << endl;
  }
  else if (a+b == c+d) {
    cout << "Balanced" << endl;
  }
  else {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<numeric>
#include<cmath>

int main(void){
    int N;
    std::string S;
    std::cin >> N >> S;

    int cnt=0;

    for(int i=0; i<1000; i++) {
        int a = 0;
        for (auto s : S){
            if(a == 0 && i/100 == (s-'0')){
                a = 1;
            }else if(a == 1 && i/10%10 == (s-'0')){
                a = 2;
            }else if(a == 2 && i%10 == (s-'0')){
                cnt++;
                break;
            }
        }
    }

    std::cout << cnt << std::endl;

    return 0;
}

Measured memory_bytes: 384
N = int(input())
ab = [list(map(int, input().split())) for _ in range(N)]
time = 0
ab = sorted(ab, key=lambda x:x[1])
for a, b in ab:
  time += a
  if time <= b:
    pass
  else:
    print('No')
    exit()
print('Yes')

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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

pair<int64_t, bool> dfs(const vector<vector<int64_t>>& adjs,
                        vector<int64_t>& depth, int64_t v, int64_t p) {
    int64_t n = adjs.size();

    int64_t s = 1;
    bool has = (v == n - 1);
    for (auto u : adjs[v]) {
        if (u == p) {
            continue;
        }

        depth[u] = depth[v] + 1;

        auto t = dfs(adjs, depth, u, v);
        s += t.first;
        if (t.second) {
            has = true;

            if (depth[v] <= depth[n - 1] / 2) {
                return t;
            }
        }
    }

    return make_pair(s, has);
}

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

    vector<vector<int64_t>> adjs(n);
    for (auto _ : irange(0L, n - 1)) {
        int64_t a, b;
        cin >> a >> b;
        --a;
        --b;
        adjs[a].push_back(b);
        adjs[b].push_back(a);
    }

    vector<int64_t> depth(n);
    auto t = dfs(adjs, depth, 0, -1);

    cout << (t.first < (n - t.first) ? "Fennec" : "Snuke") << endl;
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
typedef int64_t i64;

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


  if(b == "A"){
      cout << 'T' << endl;
  }else if(b == "C"){
      cout << 'G' << endl;
  }else if(b == "G"){
      cout << 'C' << endl;
  }else{
      cout << 'A' << endl;
  }
}


Measured memory_bytes: 256
import std.stdio;
import std.algorithm;
import std.string;
import std.conv;
import std.math;

bool check(string s){
    for(int i=0;i<s.length-3;i++){
	string str = s[i..i+4];
	if(str == "this" || str == "that"){
	    writeln(s);
	    return true;
	}
    }
    return false;
}

void main(){

    int n = to!int(chomp(readln()));
    for(int i=0;i<n;i++){
	string ans;
	auto s = chomp(readln());
	int[] ss;
	for(int a=1;a<=27;a++){
	    bool flg = false;
	    for(int b=0;b<=26;b++){
		flg = false;
		ans = "";
		for(int j=0;j<s.length;j++){
		    int c = to!int(s[j]-'a');
		    if(0 <= c && c <= 25){
			while((c-b+26)%a!=0){
			    c += 26;
			    if(c>1000) break;
			}
			c = (c-b+26)/a;
			c %= 26;
		    }
		    ans ~= to!char(c +to!int('a'));
		}
		flg = check(ans);
		if(flg) break;
	    }
	    if(flg){
	       	break;
	    }
	}
    }
}

Measured memory_bytes: 2480
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#include<assert.h>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
#define SZ(x) ((int)x.size())
using namespace std;
inline LL read()
{
	LL f=1,x=0;char ch=getchar();
	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 stack[20];
template<typename T>inline void write(T x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
template<typename T>inline void pr1(T x){write(x);putchar(' ');}
template<typename T>inline void pr2(T x){write(x);putchar('\n');}
template<typename T>inline void chkmin(T &x,T y){x=x<y?x:y;}
template<typename T>inline void chkmax(T &x,T y){x=x>y?x:y;}
const int MAXN=105;
const int mod=1e9+7;
int pow_mod(int a,int b)
{
	int ret=1;
	for(;b;b>>=1,a=1LL*a*a%mod)if(b&1)ret=1LL*ret*a%mod;
	return ret;
}
int f[MAXN][MAXN],g[MAXN][MAXN],h[MAXN],a[MAXN],n;
void ad(int &x,int y){x+=y;if(x>=mod)x-=mod;}
void dl(int &x,int y){x-=y;if(x<0)x+=mod;}
//f same 
//g not same
void dp(int l,int r,int down)
{
	if(l>r)return ;
	if(l==r){g[l][r]=pow_mod(2,h[l]-down);return ;}
	int mn=0;for(int i=l;i<=r;i++)if(!mn||h[i]<h[mn])mn=i;
	int s1=0,s2=0;
	for(int i=l,nxt;i<=r;i=nxt+1)
	{
		nxt=i;
		if(h[i]==h[mn])
		{
			s1=2LL*s1%mod;ad(s1,2LL*s2%mod);
			if(!s2)s2=1;continue;
		}while(h[nxt+1]>h[mn]&&nxt+1<=r)++nxt;
		dp(i,nxt,h[mn]+1);
		int u1=f[i][nxt],u2=g[i][nxt];
		if(i!=l)
		{
			if(!s1)
			{
				ad(s1,2LL*s2*u1%mod);
				ad(s1,4LL*u2*s2%mod);
			}
			else 
			{
				s1=(4LL*s1*u2%mod+1LL*s1*u1%mod)%mod;ad(s1,2LL*s2*u1%mod);
				ad(s1,4LL*u2*s2%mod);
			}
			if(!s2)s2=2LL*u2%mod;
			else s2=2LL*s2*u2%mod;
		}
		else s1=u1,s2=2LL*u2%mod;
	}
	if(h[mn]>down)s2=1LL*s2*pow_mod(2,h[mn]-down)%mod;
	f[l][r]=s1;g[l][r]=s2;
}
int main()
{
	n=read();for(int i=1;i<=n;i++)h[i]=a[i]=read();
	if(n==1)return pr2(pow_mod(2,h[1])),0;
	sort(a+1,a+1+n);int ln=unique(a+1,a+1+n)-(a+1);
	a[0]=1;
	dp(1,n,1);
	pr2((f[1][n]+2LL*g[1][n])%mod);
	return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main() {
	char str[1000] = { 0 };
	char order[10] = { 0 };
	char p[1000] = { 0 };
	int ordercnt;
	int a, b;
	int i, j, k, temp;

	scanf("%s", str);
	scanf("%d", &ordercnt);

	for (i = 0; i < ordercnt; i++) {
		scanf("%s %d %d", order, &a, &b);

		if (strcmp(order, "print") == 0) {			//出力
			for (j = a; j <= b; j++) {
				printf("%c", str[j]);
			}
			printf("\n");
		}
		else if (strcmp(order, "reverse") == 0) {	//入れ替えソート
			k = 0;
			for (j = a; j <= b - k; j++) {
				temp = str[j];
				str[j] = str[b - k];
				str[b - k] = temp;
				k++;
			}
		}
		else if (strcmp(order, "replace") == 0) {	//文字代入
			scanf("%s", p);
			j = a;
			k = 0;
			while (j <= b) {
				str[j] = p[k];
				j++;
				k++;
				if (p[k] == '\0') {
					k = 0;
				}
			}
		}
	}

	return 0;
}


Measured memory_bytes: 2108
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    map<int,int>mp;
    set<int>s;
    int cnt=0,n,a;
    cin>>n;
    while(n--){
        cin>>a;
        mp[a]^=1;
        s.insert(a);
    }
    for(auto x:s)
        if(mp[x])
        cnt++;
    cout<<cnt<<endl;

    return 0;
}


Measured memory_bytes: 12996
n = int(input())
a = list(map(int, input().split()))
from collections import Counter
c = Counter(a)
d = dict(c)
ans = 0
cnt = 0
for k, v in d.items():
  if v%2==0:
    d[k] = 2
    cnt += 1
  else:
    d[k] = 1
  ans += 1
if cnt%2==1:
  ans -= 1
print(ans)

Measured memory_bytes: 20720
import sys
alpha = 'abcdefghijklmnopqrstuvwxyz'
def this(word):
    i=0
    t=[]
    for c in word:
        x=ord(c)-ord('this'[i])
        if x>=0:
            t.append(x)
        else:
            t.append(26+x)
    
        i+=1
    if(t[0]==t[1] and t[1]==t[2] and t[2]==t[3]):
        return t[0]
    return 30
def that(word):
    i=0
    t=[]
    for c in word:
        x=ord(c)-ord('that'[i])
        if x>=0:
            t.append(x)
        else:
            t.append(26+x)
    
        i+=1
    if(t[0]==t[1] and t[1]==t[2] and t[2]==t[3]):
        return t[0]
    return 30
def the(word):
    i=0
    t=[]
    for c in word:
        x=ord(c)-ord('the'[i])
        if x>=0:
            t.append(x)
        else:
            t.append(26+x)
    
        i+=1
    if(t[0]==t[1] and t[1]==t[2]):
        return t[0]
    return 30

for string in sys.stdin:
    for word in string.split(" "):
        if(len(word)==3):
           if the(word) < 30:
               x=the(word)
               break
        if(len(word)==4):
           if this(word) <30:
               x=this(word)
               break
           if that(word) <30:
               x=that(word)
               break

    result=""
    for c in string:
        if c in alpha:
            result+=alpha[alpha.find(c)-x]
        else:
            result+=c
    print result[:-1]

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

using namespace std;

int main(){
    int n, m;
    cin >> n >> m;
    string A(n, '0');
    vector<bool> B(n);
    for (int i = 0; i < m; i++){
        int s, c;
        cin >> s >> c;
        s--;
        if ((B[s] and A[s] - '0' != c) or (n != 1 and s == 0 and c == 0)){
            puts("-1");
            return 0;
        }
        A[s] = c + '0';
        B[s] = true;
    }
    if (A[0] == '0' and n != 1)
        A[0] = '1';
    cout << A << endl;
}

Measured memory_bytes: 256
N,M=map(int,input().split())
C=[list(map(int,input().split())) for _ in range(M)]
G=[0]*(N+1)
for l,r in C:
  G[l-1]+=1
  G[r]-=1
gg=0
li=[]
for g in G:
  gg=gg+g
  li.append(gg)
print(li.count(M))

Measured memory_bytes: 32348
#include <bits/stdc++.h>
#define int long long
#define maxn 2005
using namespace std;

const int mod = 1e9 + 7;

int dp[maxn][maxn] = {};
int S;

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> S;
    dp[0][0] = 1;
    for(int i = 1; i <= S; i++) {
        dp[0][i] += dp[0][i - 1];
    }
    for(int i = 1; i <= S; i++) {
        for(int j = 3; j <= S; j++) {
            dp[i][j] = dp[i - 1][j - 3];
        }
        for(int j = 1; j <= S; j++) {
            dp[i][j] = (dp[i][j] + dp[i][j - 1]) % mod;
        }
    }
    int ans = 0;
    for(int i = 1; i <= S; i++) {
        ans = (ans + dp[i][S] - dp[i][S - 1] + mod) % mod;
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 34888
// OddString
#include <iostream>
#include <algorithm>
using namespace std;

int main() {
    string s;
    string odd_string = "";
    cin >> s;
    for (int i = 1; i <= s.size(); ++i) {
        if (i % 2 == 1) odd_string += s[i-1];
    }
    cout << odd_string << endl;
}

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

#define ll long long
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n, m) for (int (i) = (n); (i) < (m); (i)++)
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

int main() {
   int a, b, c, x;
   cin >> a >> b >> c >> x;
   int cnt = 0;
   rep (i, 0, a+1) {
      rep (j, 0, b+1) {
         rep (k, 0, c+1) {
            if (500*i + 100*j + 50*k == x) {
               cnt++;
            }
         }
      }
   } 
   cout << cnt << endl;

   return 0;
}

Measured memory_bytes: 256
import collections
import numpy as np
from scipy.sparse.csgraph import csgraph_from_dense, dijkstra

H, W = map(int, input().split())
c = [[int(i) for i in input().split()] for _ in range(10)]
cnp = np.array(c, dtype=np.int32)

G = csgraph_from_dense(cnp.T)
d = dijkstra(G, indices=1)
# print(d)

l = []
for i in range(H):
    l.extend(map(int, input().split()))


cc = collections.Counter(l)

ans = 0
for k, v in cc.items():
    if k >= 0:
        ans += d[k]*v
print(int(ans))


Measured memory_bytes: 17508
while True:
    a, op, b = input().split()
    a =int(a)
    b =int(b)
    
    if op =="?":
        break
    else:
        if op =="+":
            print(a+b)
        elif op =="-":
            print(a-b)
        elif op =="*":
            print (a*b)
        elif op =="/":
            print(a//b)


Measured memory_bytes: 5596
import java.util.Scanner;

public class Main {
	


	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		int length;
		int[] numbers;
		length = input.nextInt();
		if(1 <= length && length <= 10000) {
			
		
		numbers = new int[length];
		for(int i = 0; i < length; i ++) {
			numbers[i] = input.nextInt();
			if(numbers[i] < 2 || numbers[i] > 100000000) {
				System.out.println("Enter numbers between 2 and 100000000");
				System.exit(0);
				
			}
		}
		input.close();
		int count = 0;
		for(int i = 0; i < length; i ++) {
			if(isPrime(numbers[i])) {
				count ++;
			}
		}
		System.out.println(count);
		}
		else {
			System.out.println("Enter a list size between 1 and 10000");
			System.exit(0);
		}
	}
	
	public static boolean isPrime(int num) {
		
		if(num % 2 == 0 && num != 2) {
			return false;
		}
			
		for(int i = 3; i * i <= num; i += 2) {
			if(num % i == 0) {
				return false;
			}}
	
		return true;
			
		}

}



Measured memory_bytes: 41960
#include <vector>
//#define DEBUG
#define MAXN 10000000
#include <bits/stdc++.h>
using namespace std;


int main() {
#ifdef DEBUG
    freopen("in.in", "r", stdin);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    string s, t;
    cin >> s >> t;

    string test = t.substr(0, s.size());
    if (test == s) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    


    return 0;
}


Measured memory_bytes: 3668