akhauriyash/Code-Regression huggingface dataset:
//c++ テンプレ
#include<bits/stdc++.h>
using namespace std;

typedef long long llint;
typedef long double ld;

#define inf 1e18
#define mod 1000000007
priority_queue<llint,vector<llint>,greater<llint> > que;
priority_queue<llint> Que;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

llint L,R;
void solve(){
    cin >> L >> R;
    llint mn=inf;
    llint v;
    for(llint i=L;i<R;i++){
        for(llint j=i+1;j<=R;j++){
            v=i*j%2019;
            mn=min(v,mn);
            if(mn==0){
                cout << mn << endl;
                return;
            }
        }
    }
    cout << mn << endl;
}

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


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <vector>
#include <algorithm>


using namespace std;

int main(){
  int  a,b;
  cin>>a>>b;
  int h=0;
  for(int i=1;i<=b-a;i++){
      h+=i;
  }
  cout<<h-b<<endl;
  return 0;
}


Measured memory_bytes: 384
package main

import "fmt"

func main() {
	var N, M, C int
	fmt.Scanf("%d %d %d", &N, &M, &C)

	B := make([]int, M)
	for i := 0; i < M; i++ {
		fmt.Scanf("%d", &B[i])
	}

	count := 0

	for i := 0; i < N; i++ {
		sum := 0
		for j := 0; j < M; j++ {
			var a int
			fmt.Scanf("%d", &a)
			sum += a * B[j]
		}
		if sum > -C {
			count++
		}
	}
	fmt.Println(count)
}


Measured memory_bytes: 512
///mAAria...
#include<bits/stdc++.h>
 
using namespace std;
 
#define int long long
typedef pair<int,int> pii;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007
#define inf 1000000000

const long double PI = acos(-1);

int powm(int a, int b) {
    int res=1;
    while(b) {
        if(b&1)
            res=(res*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}


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

    bool flag = false;
    n = min(100LL, n);
    for(int i = 1;i*i<=n;i++){
        if (n%i==0)
        {
            int temp1 = i;
            int temp2 = n/i;

            if (temp1 < 10 && temp2 <10)
            {
                flag = true;
                break;
            }
        }
    }

    if(flag){
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;

} 

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

    for(int i = 1;i<=t;i++){
        solve();
    }
    return 0;
} 

 


Measured memory_bytes: 256
import sys

N,M = map(int,input().split())
X = sorted(list(map(int,input().split())))

if N >= M:
    print(0)
    sys.exit()
    
s= [0]*(M-1)
for i in range(M-1):
    s[i] = X[i+1] - X[i]
s.sort(reverse=True)
res = sum(s)
if M == 1:
    res = 0
else:
    for i in range(N-1):
        res -= s[i]
print(res)


Measured memory_bytes: 13968
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
    static final int[] R_OFFSETS = { -1, 0, 1, 0 };
    static final int[] C_OFFSETS = { 0, 1, 0, -1 };

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

        int H = sc.nextInt();
        int W = sc.nextInt();
        char[][] squares = new char[H][W];
        for (int r = 0; r < H; ++r) {
            String line = sc.next();
            for (int c = 0; c < W; ++c) {
                squares[r][c] = line.charAt(c);
            }
        }

        System.out.println(solve(squares) ? "Yes" : "No");

        sc.close();
    }

    static boolean solve(char[][] squares) {
        int H = squares.length;
        int W = squares[0].length;

        for (int r = 0; r < H; ++r) {
            for (int c = 0; c < W; ++c) {
                int r_ = r;
                int c_ = c;
                if (squares[r][c] == '#' && !IntStream.range(0, R_OFFSETS.length).anyMatch(i -> {
                    int adjR = r_ + R_OFFSETS[i];
                    int adjC = c_ + C_OFFSETS[i];

                    return adjR >= 0 && adjR < H && adjC >= 0 && adjC < W && squares[adjR][adjC] == '#';
                })) {
                    return false;
                }
            }
        }

        return true;
    }
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
ll factorial(int i) {       //階乗
    if (i == 0) return 1;
    return (factorial(i - 1)) * i;
}

int main() { 
    int n;
    cin >> n;
    int ma = 0;
    vector<int> h(n);
    int k;
    rep(i, n) cin >> h[i];
    rep(i, n) {
        if(ma <= h[i]) ma = h[i];
        else if(ma - 1 > h[i]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 3796
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>

using namespace std;
using ll = long long int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i, a, b)  for(int i = (a); i < (b) ; i++)
#define pb push_back
#define SORT(v,n) sort(v, v+n)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define elif else if
#define itn ll
#define int ll
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;

void rec(int n) {
	
}

signed main() {
	ios::sync_with_stdio(false);
	int i, j;
	int n;
	cin >> n;
	vector<int> v(n);
	vector<int> c(n);
	rep(i, n)
		cin >> v[i];
	rep(i, n)
		cin >> c[i];
	int X = 0;
	int Y = 0;
	rep(i, n) {
		if (v[i] > c[i]) {
			X += v[i];
			Y += c[i];
		}
	}
	cout << X - Y << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string>
#include<math.h>
#include<stdlib.h>
#include<set>
#include<bitset>
#include<map>
#include<vector>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<queue>
#include<deque>
#include<stack>
#include<cmath>
#include<ctime>
#include<complex>
#include<list>
#include<limits.h>
#include<iomanip>
using namespace std;

const int N=1e5+5;
const long long INF=100000000000000000ll;
typedef pair<int,long long> pil;
typedef pair<int,int> pii;
set<pil> s;
int n,m;
long long dp[N];
pair<pii,int> a[N];

int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
		int l,r,c;
		scanf("%d%d%d",&l,&r,&c);
		a[i]=make_pair(make_pair(r,l),c);
	}
	for(int i=2;i<=n;i++) dp[i]=INF;
	s.insert(make_pair(1,0ll));
	sort(a+1,a+1+m);
	for(int i=1;i<=m;i++){
		int l=a[i].first.second,r=a[i].first.first,c=a[i].second;
		set<pil>::iterator it=s.lower_bound(make_pair(l,-1ll));
		if(it==s.end()||(*it).first>=r) continue;
		long long v=(*it).second+c;
//		printf("%d %d %d:%d %lld\n",l,r,i,(*it).first,v);
		if(dp[r]>v){
			if(dp[r]!=INF) s.erase(s.find(make_pair(r,dp[r])));
			dp[r]=v;
			s.insert(make_pair(r,v));
			it=s.find(make_pair(r,v));
			it--;
			while((*it).second>v){
				set<pil>::iterator pre=it;
				pre--;
				s.erase(it);
				it=pre;
			}
		}
//		for(int j=1;j<=n;j++) printf("%lld ",dp[j]);puts("");
	}
//	for(int j=1;j<=n;j++) printf("%lld ",dp[j]);puts("");
//	printf("%d\n",n);
	if(dp[n]!=INF) printf("%lld\n",dp[n]);
	else puts("-1");
	return 0;
}

Measured memory_bytes: 8320
from collections import Counter

N = int(input())
S = input()
l = Counter(S)
diff = 0
for i in range(N-2):
  for j in range(1,(N-i-1)//2 + 1):
    # print(S[i:i+3*j:j])
    if set(S[i:i+3*j:j]) == {'R','G','B'}:
      diff += 1
print(l['R'] * l['G'] * l['B'] - diff)

Measured memory_bytes: 9360
#include <stdio.h>
#include <stdbool.h>
#define true 1
#define false 0
#define MAX 1000
#define VMAX 10000

int n , A[MAX] , s;
int B[MAX] , T[VMAX+1];

void sort(int C[])
{
	int flag = 1;
	int tmp;
	while(flag == 1)
	{
		flag = 0;
		for( int j = n-1; j >= 1; j--)
		{
			if(C[j] < C[j-1])
			{
				tmp = C[j];
				C[j] = C[j-1];
				C[j-1] = tmp;
				flag = 1;
			}
		}
	}
}

int min(int a , int b)
{
	if(a < b) return a;
	else return b;
}

int solve()
{
	int ans = 0;
	
	bool V[MAX];
	for( int i = 0; i < n; i++)
	{
		B[i] = A[i];
		V[i] = false;
	}
	sort(B);
	for( int i = 0; i < n; i++) T[B[i]] = i;
	for( int i = 0; i < n; i++) {
		if(V[i])continue;
		int cur = i;
		int S = 0;
		int m = VMAX;
		int an = 0;
		while(1){
			V[cur] = true;
			an++;
			int v = A[cur];
			m = min(m,v);
			S += v;
			cur = T[v];
			if(V[cur])break;
		}
		ans += min(S+(an-2)*m,m+S+(an+1)*s);
	}
	return ans;
}

int main(void)
{
	scanf("%d",&n);
	s = VMAX;
	for( int i = 0; i < n; i++)
	{
		scanf("%d",&A[i]);
		s = min(s,A[i]);
	}
	int ans = solve();
	printf("%d\n",ans);
}


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

int main() {
  int N, K;
  string S;
  cin >> N >> S >> K;
  for(int i = 0; i < N; i++){
    if(S.at(i) != S.at(K-1)){
      S.at(i) = '*';
    }
  }
  
  
  
  
  cout << S << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define eps 1e-9

struct Point{double x,y; bool high;};
bool comp(Point a,Point b) {return (a.x==b.x ? a.y<b.y : a.x<b.x);}

Point* Intersection(Point p1,Point p2,Point p3,Point p4,bool high){
    double d = (p2.x-p1.x)*(p4.y-p3.y)-(p2.y-p1.y)*(p4.x-p3.x);
    double u = ((p3.x-p1.x)*(p4.y-p3.y)-(p3.y-p1.y)*(p4.x-p3.x))/d;
    double v = ((p3.x-p1.x)*(p2.y-p1.y)-(p3.y-p1.y)*(p2.x-p1.x))/d;
    if(fabs(d)<=eps || u<0 || u>1 || v<0 || v>1) return NULL;
    return new Point{p1.x+u*(p2.x-p1.x), p1.y+u*(p2.y-p1.y), high};
}

int main(void){
    int N,n,o,l;
    cin>>N;
    while(N--){
        Point a,b;
        vector<Point> cross;
        cin>>a.x>>a.y>>b.x>>b.y>>n;
        rep(i,n){
            Point s,t;
            cin>>s.x>>s.y>>t.x>>t.y>>o>>l;
            Point *ret = Intersection(a,b,s,t,o==l);
            if(ret)cross.push_back(*ret);
        }

        sort(cross.begin(),cross.end(),comp);
        int cnt=0;
        rep(i,(int)cross.size()-1){
            cnt += (cross[i].high!=cross[i+1].high);
        }
        cout<<cnt<<endl;
    }

    return 0;
}

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

int main(){
    int n, m, A[100][100], b[100], c[100];
    
    cin >> n >> m;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            cin >> A[i][j];
        }
    }
    for(int i = 0; i < m; i++){
        cin >> b[i];
    }
    
    for(int i = 0; i < n; i++){
        c[i] = 0;
        for(int j = 0; j < m; j++){
            c[i] += A[i][j]*b[j];
        }
    }
    
    for(int i = 0; i < n; i++){
        cout << c[i] << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3128
#include<iostream>
#include<utility>
#include<vector>
#include<set>
using namespace std ;

int main(){
    int n ; cin >> n ;
    set<pair<char,int>> card ;
    for(int i=0;i<n;i++){
        pair<char,int> sub ;
        cin >> sub.first >> sub.second ;
        card.insert(sub) ;
    }
    vector<char> mark = {'S','H','C','D'} ;
    for(int i=0;i<4;i++){
        for(int j=0;j<13;j++){
            pair<char,int> sub = make_pair(mark.at(i),j+1) ;
            if(!card.count(sub)) cout << mark.at(i) << " " << j+1 << endl ;
        }
    }
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
vector<string> M;
int H, W;

int main() {
    cin >> H >> W;

    int white = 0;
    rep(i,H) {
        string S; cin >> S;
        rep(j,W) {
            if (S[j] == '.') white++;
        }
        M.push_back(S);
    }

    queue<pair<int,int>> Q;
    vector<vector<int>> D(H, vector<int>(W, -1));
    Q.emplace(0,0);
    D[0][0] = 1;
    while (!Q.empty()) {
        int x = Q.front().first;
        int y = Q.front().second;
        int dis = D[y][x];

        Q.pop();
        int dx[] = {1,0,-1, 0};
        int dy[] = {0,1, 0,-1};
        for (int i = 0; i < 4; i++) {
            int nx = x + dx[i];
            int ny = y + dy[i];
            if (nx < 0 || ny < 0 || nx >= W || ny >= H) continue;
            if (D[ny][nx] != -1) continue;
            if (M[ny][nx] == '#') continue;
            D[ny][nx] = dis + 1;
            Q.emplace(nx,ny);
        }
    }

    if (D[H-1][W-1] == -1) {
        cout << -1 << endl;
        return 0;
    }

    cout << white - D[H-1][W-1] << endl;
}


Measured memory_bytes: 3608
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cmath>

using namespace std;

int main() {
    string s;
    cin >> s;
    int max = 0, cnt = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') {
            cnt++;
        } else {
            if (cnt > 0 && cnt > max) max = cnt;
            cnt = 0;
        }
    }
    if (cnt > 0 && cnt > max) max = cnt;
    cout << max << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
#define Endl endl
const int INF=100000000;
int main(){
	ll n,a[10010],b[10010],dif=0,dif2=0,sum=0,sum2=0,ans=0,dim=0;
	bool f=true;
	cin>>n;
	REP(i,n){
		cin>>a[i];
		sum+=a[i];
	}
	REP(i,n){
		cin>>b[i];
		sum2+=b[i];
	}
	ans=sum2-sum;
	if(ans<0){
		f=false;
	}
	REP(i,n){
		if(b[i]>a[i]){
			dim+=(b[i]-a[i]+1)/2;
		}
	}
	DEB(ans)DEB(dim)END
	if(dim>ans){
		f=false;
	}
	cout<<((f)?"Yes":"No")<<endl;
	return 0;
}
//-4 0 1 2 -1

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include<vector>
#include<algorithm>
#include<utility>
#include<queue>
#include<math.h>
#include<stack>
#include<set>
#include<map>
#define INF 2e9
#define rep(i,n,m) for(int i=n;i<m;i++)

using namespace std;

vector<int>a[100000];
vector<int>b[100000];

int main()
{
	int n, m, k;
	cin >> n >> m >> k;

	int x, y;
	rep(i, 0, m) {
		cin >> x >> y;
		a[x].push_back(y);
		a[y].push_back(x);
	}

	int now, groupnumber = 0;
	vector<bool>done(n + 1, 0);
	vector<int>ans(n + 1, 0);
	vector<int>groupnum(n + 1);
	queue<int>que;
	rep(i, 1, n+1) {
		if (done[i] == true)continue;
		vector<int>group;

		done[i] = true;
		group.push_back(i);
		for (auto nx : a[i]) {
			que.push(nx);
			done[nx] = true;
			group.push_back(nx);
		}
		while (!que.empty()) {
			now = que.front();
			que.pop();
			for (auto nx : a[now]) {
				if (done[nx] == true)continue;
				que.push(nx);
				done[nx] = true;
				group.push_back(nx);
			}
		}
		for (auto s : group) {
			ans[s] = group.size();
			groupnum[s] = groupnumber;
		}
		groupnumber++;
	}

	rep(i, 0, k) {
		cin >> x >> y;
		if (groupnum[x] == groupnum[y]) {
			b[x].push_back(y);
			b[y].push_back(x);
		}
	}
	rep(i, 1, n + 1)
		cout << ans[i] - a[i].size() - b[i].size() - 1 << " ";
}

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

using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, a, b) for (int64_t i = (a); i < (b); ++i)
const int MOD = 1e9 + 7;
typedef long long ll;
const long long INF = 1LL << 60;
using Graph = vector<vector<int>>;

int main() {
  int n;
  cin >> n;
  vector<int> a(100010, 0);
  for (int i = 0; i < n; i++) {
    int k;
    cin >> k;
    a[k]++;
  }
  ll count = 0;
  for (int i = 0; i < 100010; i++) {
    if (a[i] != 0) count++;
  }
  if (count % 2)
    cout << count << endl;
  else
    cout << count - 1 << endl;
}


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

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

  ll n; cin >> n;
  int ans = 100;

  ll b;
  for (ll a = 1; a*a <= n; a++) {
    if (n%a != 0) continue;
    b = n/a;
    b = max(a, b);

    int cnt = 0;
    while (b>0) {
      b /= 10;
      cnt++;
    }
    ans = min(ans, cnt);
  }

  cout << ans << endl;


  return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

const int MAXN = 110;
int arr[MAXN];
int main()
{
    int N;
    cin >> N;
    long long sum = 0;
    for(int i = 1 ; i <= N ; i++)
    {
        cin >> arr[i];
        sum += arr[i];
    }
    int M;
    cin >> M;
    for(int i = 0 ; i < M; i++)
    {
        int P,X;
        cin >> P >>X;
        long long ans = sum;
        ans = sum -arr[P];
        ans += X;
        cout<<ans<<endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;

int main(){
	
	int n, s=0;
	cin >> n;
	int t=n;
	for(int i=0; i<10; i++){
		s+=n%10;
		n/=10;
	}
	if(t%s==0){
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

        int[] pizza = new int[5];
        int ans = 1000000000;
        for(int i = 0; i < 5; i++) {
            pizza[i] = scan.nextInt();
        }

        for(int i = 0; i < 2*(pizza[3]+pizza[4])+1; i++) {
            int a = Math.max(0, (pizza[3]-i/2));
            int b = Math.max(0, (pizza[4]-i/2));
            int c = i;
            ans = Math.min(ans,pizza[0]*a + pizza[1]*b + pizza[2]*c);
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 24020
//Catchharsh
#include<bits/stdc++.h>
#define ll long long int 
#define ld long double
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define F first
#define S second
#define sz(x) x.size()
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define see(x) cout<<#x<<" = "<<x<<endl
const ll MOD = 1e9+7;
const ll INF = 1011111111;
const ll LLINF = 1000111000111000111LL;
const ld EPS = 1e-10;
const ld PI = 3.14159265358979323;
using namespace std;
ll power (ll base,ll exponent)
{
    ll ans=1;
    //base%=MOD;
    //exponent%=(MOD-1);
    while(exponent!=0)
    {
      if(exponent&1) ans=(1LL*ans*base);
      base=(1LL*base*base);
      exponent>>=1;
    }
    return ans;
}

int32_t main()
{   
     IOS;
     
     ll n,m,i,j,k;
     cin>>n;
     if(n<=9) return cout<<n,0;
     vector<ll> v;
     priority_queue <ll, vector<ll>, greater<ll> > pq;
     for(i=1;i<=9;i++) pq.push(i);
      ll cnt=1;
    while(1)
    {
       ll x=pq.top();
       pq.pop();
       if(cnt==n) return cout<<x,0;
       ll y=x%10;
       if(y==0)
       {
         pq.push(x*10);
         pq.push(x*10+1);
       }
       else if(y==9)
       {
         pq.push(x*10+y);
         pq.push(x*10+y-1);
       }
       else
       {
         pq.push(x*10+y-1);
         pq.push(x*10+y);
         pq.push(x*10+y+1);
       }
       cnt++;
    }
     
     cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';             
}

Measured memory_bytes: 2420
S = input()
T = input()
ls = [0]*26
lt = [0]*26
al = [chr(ord('a')+i) for i in range(26)]
for i in range(S.__len__()):
    si = al.index(S[i])
    ti = al.index(T[i])
    ls[si] += 1
    lt[ti] += 1
ls.sort()
lt.sort()
if ls == lt:
    print("Yes")
else:
    print("No")


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

using namespace std;

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

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define  INF 999999999

#ifdef Debug
#define dump(x)  cerr << #x << " = " << (x) << endl
#else
#define dump(x)
#endif

bool used[101];
int mincost[101];
int edge[101][101];

int main(){
	int n,m;
	while(cin>>n){
		if(n==0)break;
		rep(i,101)rep(j,101)edge[i][j]=INF;
		cin>>m;
		rep(i,m){
			int a,b,c;
			char ch;
			cin>>a>>ch>>b>>ch>>c;
			edge[a][b]=edge[b][a]=c/100-1;
		}
		rep(i,n){
			mincost[i]=INF;
			used[i]=false;
		}
		mincost[0]=0;
		int res=0;

		while(1){
			int v=-1;
			rep(u,n){
				if(used[u]==false && ( v==-1 || mincost[u]<mincost[v] ))
					v=u;
			}
			if(v==-1)break;
			used[v]=true;
			res+=mincost[v];

			rep(u,n){
				mincost[u]=min(mincost[u],edge[v][u]);
			}
		}
		cout<<res<<endl;
	}
	return 0;
}

Measured memory_bytes: 1204
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pf push_front
#define mod 1000000007
#define endl '\n'
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);


int main()
{
     ll a,b,c;
     cin>>a>>b>>c;
     set<ll>st;
     st.insert(a);
     st.insert(b);
     st.insert(c);
     if(st.size()==2)
     {
         cout<<"Yes"<<endl;
     }
     else
     {
         cout<<"No"<<endl;
     }
}


Measured memory_bytes: 256
#include "stdio.h"
#include <iostream>
#include <vector>
#include <string>

#include <string>
#include <sstream>

//typedef
//------------------------------------------
typedef std::vector<int> VI;
typedef std::vector<VI> VVI;
typedef std::vector<std::string> VS;
typedef std::pair<int, int> PII;
typedef long long LL;
typedef unsigned long UL;

using namespace std;

unsigned int euclidean_gcd(unsigned int a, unsigned int b) {
    if (a < b) euclidean_gcd(b, a);
    unsigned r;
    // a ≥ bであるとき、gcd(a,b) = gcd(b,a%b)
    // 1. a%bを計算する。
    // 2. a%bが0ならばbを最大公約数として出力して終了する。
    // 3. aにbを代入し、bにa%bを代入したうえで、1 に戻る。
    while((r = a%b)) {
        a = b;
        b = r;
    }
    return b;
}

int main(){
    int a, b, k;
    cin >> a >> b >> k;
    int valMax = std::max(a, b);
    VI vec;
    int x = (valMax == 1) ? 2 : valMax;
    for (int i = 1; i <= x; i++) {

        if ((int)(a % i) == 0 && (int)(b % i) == 0) {
            vec.push_back(i);
        }
    }

    cout << vec[(vec.size() - k)];

}


Measured memory_bytes: 256
#include"bits/stdc++.h"
#include<cassert>
using namespace std;
//#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const int mod = 1000000007;
const int inf = 1ll << 61;
typedef pair<int, int> P;
typedef pair<int,P>PP;
int a[200006], b[200006];
int ksa[600006];
int A[600005];

void Z(int n) {
	A[0] = n;
	int i = 1, j = 0;
	while (i < n) {
		while (i + j < n&&ksa[j] == ksa[i + j])j++;
		A[i] = j;
		if (!j) { i++; continue; }
		int k = 1;
		while (i + k < n&&k + A[k] < j)A[i + k] = A[k], k++;
		i += k; j -= k;
	}
}

signed main() {
	int n; cin >> n;
	rep(i, n)cin >> a[i];
	rep(i, n)cin >> b[i];
	rep(i, n)ksa[i+n] = a[i] ^ a[(i + 1) % n];
	rep(i, n)ksa[i] = b[i] ^ b[(i + 1) % n];
	rep(i, n)ksa[i + 2*n] = ksa[i+n];
	Z(n * 3);
	for (int i = n; i < n + n; i++) {
		if (A[i] >= n) {
			cout << i - n <<' '<<(a[i-n]^b[0])<< endl;
		}
	}
}

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

int main() {
  string s1,s2;
  s1="RUD";
  s2="LUD";
  string s;
  cin >> s;
  bool flag=true;
  for(int i=0;i<s.size();i++) {
    if(i%2==0) {
      bool temp=false;
      for(int j=0;j<3;j++) {
        if(s.at(i)==s1.at(j)) {
          temp=true;
          break;
        }
      }
      flag=temp;
    }
    else {
      bool temp=false;
      for(int j=0;j<3;j++) {
        if(s.at(i)==s2.at(j)) {
          temp=true;
          break;
        }
      }
      flag=temp;
    }
    if(!flag) {
      break;
    }
  }
  if(flag) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
//Bismillahir Rahmanir Rahim//

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

typedef long long ll;
typedef tree<int, null_type, less<int>, rb_tree_tag,
        tree_order_statistics_node_update> indexed_set;
void solution();
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
#ifndef ONLINE_JUDGE
	clock_t tStart = clock();
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    solution();
#ifndef ONLINE_JUDGE
	fprintf(stderr, "Runtime: %.10fs\n", (double) (clock() - tStart) / CLOCKS_PER_SEC);
#endif
    return 0;
}
void solution() {
    int d, s, t;
    cin >> d >> t >> s;
    if (s * t >= d)
        cout << "Yes\n";
    else 
        cout << "No\n";
}

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



int main() {
    int n;
    cin >> n;
    for(int i = 1; i <= 10; i++) {
        if(n <= i * 1000){
            cout << i * 1000 - n << endl;
            break;
        } 
    }
}



Measured memory_bytes: 3592
#include<stdio.h>
int main(void)
{
  int N,i,j,x,y,MOD,A[200000]={0},check[200000]={},move[200000]={0};
  long long K;
  x=scanf("%d %lld",&N,&K);
  for(i=0;i<N;i++)x=scanf("%d",&A[i]),check[i]=-1;
  for(i=0,j=0;;i=A[i]-1,j++)if(check[i]<0)check[i]=j,move[j]=i;else{x=j,y=check[i],MOD=x-y;break;}
  if(K>=x)K=(K-y)%MOD+y;
  return printf("%d\n",move[K]+1),0;
}

Measured memory_bytes: 4076
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const int inf = 2e9;
ll mpow(ll a, ll b) { ll r = 1; a %= mod; while (b) { r = r * ((b % 2) ? a : 1) % mod, a = a * a % mod, b >>= 1; }return r; }



int main() {
	int n; cin >> n;
	vector<int> x(n), y(n);
	rep(i, 0, n) cin >> x[i] >> y[i];
	map<P,int> mp;
	rep(i, 0, n)rep(j, 0, n) {
		if (i == j) continue;
		mp[{x[j] - x[i], y[j] - y[i]}]++;
	}
	int ans = 0;
	for (auto it : mp) ans = max(ans, it.second);
	printf("%d", n - ans);
	return 0;
}


Measured memory_bytes: 384
#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 N;
    std::cin >> N;

    vector<int> A(N);
    vector<int> A_sort(N);
    REP(i, N) {
        std::cin >> A[i];
        A_sort[i] = A[i];
    }

    SORT(A_sort);

    REP(i, N) {
        if(A[i] == A_sort.back()) {
            std::cout << A_sort[N - 2] << std::endl;
        }
        else {
            std::cout << A_sort[N - 1] << std::endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> v = {1, 2, 4, 8, 16, 32, 64};
    int res;
    for (auto x:v)
    {
        if (n < x)
            break;
        res = x;
    }
    cout << res;    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define REP(i, n) for (int i = (n - 1); i >= 0; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1000000007;

int main(){
  int n,k;
  cin>>n>>k;
  vector<ll>a(n);
  rep(i,n) cin>>a[i];
  for(int i=k;i<n;i++){
    if(a[i]>a[i-k])  cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
}


Measured memory_bytes: 4840
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
const int INF=0x3f3f3f3f;
int main()
{
	char s[5];
	scanf("%s",s);
	if(s[0]==s[1]&&s[1]==s[2]){
		printf("No\n");
	}else{
		printf("Yes\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int n;
long long res = 0;
void dfs(long long a,int mask){
    if(a>n) return;
    if(mask==7) res++;
    dfs(a*10+3,mask|1);
    dfs(a*10+5,mask|2);
    dfs(a*10+7,mask|4);
}
int main(){
    cin>>n;
    dfs(0,0);
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
	long long n;
	cin>>n;
	int c[1000];
	int now;
	for(int i=0;i<1000;i++)c[i]=1;
	for(int i=2;i<=n;i++){
		now=i;
		for(int j=2;j<=i;j++){
			if(now%j==0){
				c[j-1]++;
				now/=j;
				j--;
			}
		}
	}
	long long ans=1;
	for(int i=0;i<1000;i++)ans=ans*c[i]%1000000007;
	cout<<ans%1000000007<<endl;
	return 0;
}


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

int main() {
	double v;
	
	while (cin >> v) {
		double t = v / 9.8;
		double y = 4.9 * t * t;
		
		for (int kai = 1; ; kai++) {
			if (5 * kai - 5 >= y) {
				cout << kai << endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3192
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<float.h>
#include<tuple>

using namespace std;
#define ll long long


int main(void){
    int N;
    cin>>N;
    vector<int> W(N),total(N),ans(N);
    for(int i=0;i<N;i++) {
        cin>>W.at(i);
        if(i==0) total.at(0)=W.at(0);
        else total.at(i)=total.at(i-1)+W.at(i);
    }
  
    for(int i=0;i<N;i++){
        ans.at(i)=abs(total.at(N-1)-2*total.at(i));
    }
    sort(ans.begin(),ans.end());
    cout<<ans.at(0)<<endl;
    return 0;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF 1<<30
#define LINF 1LL<<60

/* Coordinate_Compression : ??§?¨???§???*/
class CC {
public:
	ll N;
	vector<ll> xs; // ????????¨:xs[x1 or x2????????????] := ????????§?¨?

	CC(ll N) :N(N) {}
	// x1, x2?????§?¨???§??????, ??§?¨???§???????????????????????????
	int compress(vector<ll>& x1, vector<ll>& x2, ll MIN_W = -1e10, ll MAX_W = 1e10) {
		for (int i = 0; i < N;i++) {
			/* ??´???????????£??????d????¶???????????????? */
			for (int d = -1; d <= 1; d++) {
				ll tx1 = x1[i], tx2 = x2[i];
				if (MIN_W <= tx1 && tx1 <= MAX_W) xs.push_back(tx1);
				if (MIN_W <= tx2 && tx2 <= MAX_W) xs.push_back(tx2);
			}
		}

		sort(xs.begin(), xs.end());
		xs.erase(unique(xs.begin(), xs.end()), xs.end());

		for (int i = 0; i < N;i++) {
			x1[i] = find(xs.begin(), xs.end(), x1[i]) - xs.begin();
			x2[i] = find(xs.begin(), xs.end(), x2[i]) - xs.begin();
		}

		return (int)xs.size(); // xs.size????????§??§???6*N
	}
};

/* use example : http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_4_A&lang=jp */
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	ll N; cin >> N;
	vector<ll> x1(N), y1(N), x2(N), y2(N);
	for (int i = 0; i < N;i++) cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
	CC CCx(N), CCy(N);
	ll W = CCx.compress(x1, x2);
	ll H = CCy.compress(y1, y2);

	/* imos????????¨???????????§?¨??????¢????¨???????*/
	vector<vector<int>> imos(H + 2, vector<int>(W + 2, 0)); // ??¢????¨????
	vector<vector<int>> Sum(H + 2, vector<int>(W + 2, 0));
	for (int i = 0; i < N;i++) {
		imos[y1[i]][x1[i]]++;
		imos[y1[i]][x2[i]]--;
		imos[y2[i]][x1[i]]--;
		imos[y2[i]][x2[i]]++;
	}
	ll ans = 0;
	for (int y = 0; y < H;y++) {
		for (int x = 0; x < W;x++) {
			Sum[y + 1][x + 1] = Sum[y + 1][x] + Sum[y][x + 1] - Sum[y][x] + imos[y][x];
			if (Sum[y + 1][x + 1] > 0) {
				ans += (CCy.xs[y + 1] - CCy.xs[y])*(CCx.xs[x + 1] - CCx.xs[x]);
			}
		}
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 128420
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val p = readLine()!!.split(" ").map { it.toInt() }
    var count = 1
    var max = p[0]
    for (i in 1 until n) {
        if (p[i] < max) {
            count++
            max = p[i]
        }
    }
    println(count)
}


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

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

  if (x == 1 || x == n * 2 - 1) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;

    if (n == 2) {
      cout << "1 2 3" << endl;
      return 0;
    }

    set<int> remain;
    vector<int> answer(n * 2 - 1, 0);
    for (int i = 1; i < n * 2; ++i) {
      remain.insert(i);
    }

    auto put = [&](int k, int v) {
      answer[k] = v;
      remain.erase(v);
    };

    if (x == 2) {
      put(n - 2, x + 1);
      put(n - 1, x);
      put(n, x - 1);
      put(n + 1, x + 2);
    } else {
      put(n - 2, x - 1);
      put(n - 1, x);
      put(n, x + 1);
      put(n + 1, x - 2);
    }
    for (int i = 0; i < 2 * n; ++i) {
      if (!answer[i]) {
        put(i, *remain.begin());
      }
    }

    for (int i : answer) {
      printf("%d\n", i);
    }
  }

  return 0;
}

Measured memory_bytes: 11648
N = int(input())
A = [int(input()) for _ in range(N)]
max_num = max(A)
temp = A.copy()
temp.remove(max_num)
max_num2 = max(temp)

for a in A:
    if a == max_num:
        print(max_num2)
    else:
        print(max_num)

Measured memory_bytes: 16132
#include<bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define F first
#define S second
#define pss pair<string,string>
#define pcc pair<char,char>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define piii pair<int,pii>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define vs vector<string>
#define vl vector<ll>
#define vs vector<string>
#define vll vector<pll>
#define vss vector<pss>
#define vcc vector<pcc>
#define MP make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=n-1;i>=0;i--)
#define Very_fast std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
const int N = 1e5+5;
const int mod=1e9+7;
const int INF=0x3f3f3f3f;
inline ll gcd(ll a,ll b){if(b==0)return a;else return gcd(b,a%b);}
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline ll lowbit(ll x){return (x&-x);}
string s,t;
int main()
{
	int ans=1e9;
	cin>>s>>t;
	for(int i=0;i+t.size()<=s.size();i++)
	{
		int cnt=0;
		for(int j=0;j<t.size();j++)
			if(t[j]!=s[i+j])
				cnt++;
		ans=min(ans,cnt);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3588
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

//constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
constexpr long long int MOD = 998244353;
constexpr long double EPS = 1e-8;

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

long long int power(long long int x, long long int n, long long int M) {
	long long int ret = 1;
	long long int by = x;
	while (n) {
		if (n & 1) {
			ret *= by;
			ret %= M;
		}
		by *= by;
		by %= M;
		n >>= 1;
	}
	return ret;
}

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

	cin >> N;
	vector<int>X(N);
	vector<int>Y(N);
	vector<int>Z(N);
	int XE, YE, ZE;
	cin >> XE;
	vector<vector<int>>Xedge(N);
	for (int i = 0; i < XE; i++) {
		cin >> L >> R;
		L--, R--;
		Xedge[L].push_back(R);
		Xedge[R].push_back(L);
	}
	cin >> YE;
	vector<vector<int>>Yedge(N);
	for (int i = 0; i < YE; i++) {
		cin >> L >> R;
		L--, R--;
		Yedge[L].push_back(R);
		Yedge[R].push_back(L);
	}
	cin >> ZE;
	vector<vector<int>>Zedge(N);
	for (int i = 0; i < ZE; i++) {
		cin >> L >> R;
		L--, R--;
		Zedge[L].push_back(R);
		Zedge[R].push_back(L);
	}
	for (int i = N - 1; i >= 0; i--) {
		set<int>s;
		for (auto j : Xedge[i]) {
			if (j > i)s.insert(X[j]);
		}
		for (auto j : s) {
			if (X[i] == j)X[i]++;
		}
	}
	for (int i = N - 1; i >= 0; i--) {
		set<int>s;
		for (auto j : Yedge[i]) {
			if (j > i)s.insert(Y[j]);
		}
		for (auto j : s) {
			if (Y[i] == j)Y[i]++;
		}
	}
	for (int i = N - 1; i >= 0; i--) {
		set<int>s;
		for (auto j : Zedge[i]) {
			if (j > i)s.insert(Z[j]);
		}
		for (auto j : s) {
			if (Z[i] == j)Z[i]++;
		}
	}

	/////////////
	unordered_map<long long int, long long int>Xbox(2 * N + 1);
	for (int i = 0; i < N; i++) {
		Xbox[X[i]] += power(10, 18 * (i + 1), MOD);
	}
	unordered_map<long long int, long long int>Ybox(2 * N + 1);
	for (int i = 0; i < N; i++) {
		Ybox[Y[i]] += power(10, 18 * (i + 1), MOD);
	}
	unordered_map<long long int, long long int>Zbox(2 * N + 1);
	for (int i = 0; i < N; i++) {
		Zbox[Z[i]] += power(10, 18 * (i + 1), MOD);
	}
	/*
	cout << "X " << endl;
	for (auto i : Xbox) {
		cout << i.first << " " << i.second << endl;
	}
	cout << "Y " << endl;
	for (auto i : Ybox) {
		cout << i.first << " " << i.second << endl;
	}
	cout << "Z " << endl;
	for (auto i : Zbox) {
		cout << i.first << " " << i.second << endl;
	}
	*/
	long long int ans = 0;
	for(auto i:Xbox){
		for (auto j : Ybox) {
			ans += i.second%MOD*(j.second%MOD)%MOD*(Zbox[i.first^j.first] % MOD)%MOD;
		}
	}
	cout << ans % MOD << endl;
}

Measured memory_bytes: 21632
#include<iostream>
#include<cstdio>
#include<map>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<vector>
#include<stack>
#include<cstdlib>
#include<cctype>
#include<cmath>
#define ll long long
#define inf 99999999
using namespace std;
char a[4];
int main()
{

    scanf("%s",a);
    int res=0;
    for(int i=0;i<3;i++){
        if(a[i]=='1'){
            ++res;
        }
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n)-1;i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(b)-1;i>=(a);--i)
#define ALL(a) a.begin(),a.end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
    if (a < b) { a = b; return true; }
    return false;
}
template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
    if (a > b) { a = b; return true; }
    return false;
}
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const map<T1, T2> &mp) {
    os << "{";
    int a = 0;
    for (auto &tp : mp) {
        if (a) os << ", "; a = 1;
        os << tp;
    }
    return os << "}";
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    os << p.first << ":" << p.second;
    return os;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    int N, m; cin >> N >> m;
    vi sum(N+1);
    REP(i, m) {
        int c, d; cin >> c >> d;
        if (c > d) continue;
        sum[c]++;
        sum[d]--;
    }
    REP(i, N) sum[i+1] += sum[i];

    int ans = N+1;
    REP(i, N+1) if (sum[i]) ans += 2;
    cout << ans << endl;

    return 0;

}



Measured memory_bytes: 3228
n=int(input())
import math
k=math.ceil(math.log(25*n+26,26))-1 # 名前の文字数
n=n-(26**k -26)//25-1
s=""
al=['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 
    'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y',"z"]
for i in range(k):
  s=al[n%26]+s
  n=n//26
print(s)

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

using namespace std;

int main() {
	long long a[4];
	for (int i = 0; i < 4; i++)
		cin >> a[i];
	for (int i = 0; i < 3; i++)
		a[i + 1] = min(a[i + 1], a[i] * 2);
	long long n;
	cin >> n;
	cout << n / 2 * a[3] + n % 2 * a[2] << '\n';
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        line.trim_right();
        line
    }};
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        let iter = line.split_whitespace();
        iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
    }};
}

fn main() {
    let (mut n, mut k) = parse_line!(usize, usize);

    let mut d = 1;
    loop {
        let a = n / k;
        if a == 0 {
            break;
        }
        d += 1;
        n = a;
    }

    println!("{}", d);
}


Measured memory_bytes: 4476
#include <algorithm>
#include <climits>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <vector>

// author:Swastik Banerjee

using namespace std;

typedef long long ll;
#define MOD 1000000007

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



  ll k;
  cin >> k;
  string s;
  cin >> s;

  if (s.size() <= k)
    cout << s;
  else {
    for (int i = 0; i < k; i++) {
      cout << s[i];
    }
    cout << "...";
  }
}

Measured memory_bytes: 3612
package main

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

const mod = 1000000007

func main() {
	fmt.Println(abc178c(os.Stdin))
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func abc178c(r io.Reader) int {
	sc := bufio.NewScanner(r)
	sc.Split(bufio.ScanWords)

	n := nextInt(sc)

	ans := (pow(10, n) - (pow(9, n))*2 + pow(8, n)) % mod

	return (ans + mod) % mod
}

func pow(base, exp int) int {
	res := 1
	for i := 0; i < exp; i++ {
		res *= base
		res %= mod
	}
	return res
}


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

using namespace std;
#define int long long
int MOD = 1000000007;

signed main(){
    int N;
    cin >> N;
    int a[N];
    for(int i=1;i<=N;i++){
        cin >> a[i];
    }
    
    int cnt = 0;
    for(int i=1;i<=N;i++){
        if(a[a[i]]==i) cnt++;
    }
    
    cout << cnt/2 << endl;
    return 0;
}



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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

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

    ll ans = 0;
    FORR(i,1,50+1)
        FORR(j,2,50+1){
            ll temp = pow(i,j);
            if(temp > 0 && temp <= x){
                ans = max(ans,temp);
                break;
            }
        }
    cout << ans << endl;
    return 0;
}

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



int main(){
  int N, Q;
  cin >> N;
  vector<ll> A(N);
  map<ll,ll> M;
  REP(i,N) {
    cin >> A[i];
    M[A[i]]++;
  }
  ll ans = 0;
  for ( auto m : M) {
    ans += ( m.first * m.second);
  }
  cin >> Q;
  REP(i,Q) {
    ll B, C;
    cin >> B >> C;
    ll mb = M[B];
    ll mc = M[C];
    M[C] += mb;
    M[B] = 0;
    ans -= mb * B;
    ans += mb * C;
    cout << ans << endl;
  }

}


Measured memory_bytes: 10080
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N= 3e5 + 5;
const ll mod=1e9 + 7;

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

    ll n,score;
    cin>>n;
    set<string>cities;
    string str;
    map< string , vector< pair<ll,ll> > > mp;
    for(ll i=1;i<=n;++i){
        cin>>str>>score;
        cities.insert(str);
        mp[str].push_back(make_pair(score,i));
    }

    for(set<string>::iterator itr=cities.begin() ;itr!=cities.end() ; itr++){
        str = *itr;
        vector< pair<ll,ll> > arr = mp[str];
        sort(arr.rbegin() , arr.rend() );
        for(ll i=0;i<arr.size();i++)cout<<arr[i].second<<"\n";
    }
}



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

using namespace std;

int main() {
  
  int N, M; cin >> N >> M;
  vector<deque<int> > cho;
  cho.resize(N);
  for(int i=0; i<N; i++) {
    cho[i].resize(M);
    for(int j=0; j<M; j++) {
      cin >> cho[i][j];
      if(i) cho[i][j] = 1-cho[i][j];
    }
  }
  
  int all = 0;
  for(int i=0; i<N; i++) {
    deque<int> work(cho[i]);
    int cnt = 0;
    for(int j=0; j<M-1; j++) {
      work[j+1] = 1-work[j+1];
      cnt += work[j];
    }
    
    int mx = cnt;
    
    work = cho[i];
    cnt = 0;
    for(int j=M-1; j>0; j--) {
      work[j-1] = 1-work[j-1];
      cnt += work[j];
    }
    
    mx = max(mx, cnt);
    
    work = cho[i];
    cnt = 0;
    while(!work.empty()) {
      if(work[0] == 1) { work.pop_front(); cnt++; work[0] = 1-work[0]; }
      else if(work[work.size()-1] == 1) { work.pop_back(); cnt++; work[work.size()-1] = 1-work[work.size()-1]; }
      else { work.pop_front(); work[0] = 1-work[0]; }
    }
    
    mx = max(mx, cnt);
    all += mx;
  }
  
  cout << all << endl;
  
  return 0;
}

Measured memory_bytes: 1348
import os,re,sys,operator,math
from collections import Counter,deque
from operator import itemgetter
from itertools import accumulate,combinations,groupby
from sys import stdin,setrecursionlimit
from copy import deepcopy
import heapq

setrecursionlimit(10**6)
while 1:
    n,m=map(int,stdin.readline().rstrip().split())
    if (n,m)==(0,0):
        break
    a=[int(i) for i in stdin.readline().rstrip().split()]
    ans=0
    for i in range(n-1):
        for j in range(i+1,n):
            t=a[i]+a[j]
            if t<=m:
                ans=max(ans,t)
    print(ans if ans!=0 else "NONE")


Measured memory_bytes: 6728
rec = set(list("abcdefghijklmnopqrstuvwxyz"))
rec2 = set()
s = input()
for i in range(len(s)):
    rec2.add(s[i])

t = sorted(list(rec - rec2))
if len(t) == 0:
    print("None")
else:
    print(t[0])

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

int main()
{
	int a = 0, b = 0;
	cin >> a >> b;
	if (a == b) {
		cout << "a == b" << endl;
	}
	else {
		cout << ((a < b) ? "a < b" : "a > b") << endl;
	}

	return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define endl "\n"
#define int long long
using namespace std;

const int N = 300111;
int n,m,a,b,c,d;
string s;

signed main()
{
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt","r",stdin);
    cin >> n >> a >> b >> c >> d;
    a--,b--,c--,d--;
    cin >> s;
    for (int i=1;i<s.size();i++){
        if (s[i-1]=='#' && s[i]=='#'){
            if (a < i && c>i){
                cout << "No" << endl;
                return 0;
            }
            if (b < i && d>i){
                cout << "No" << endl;
                return 0;
            }
        }
    }

    if (c > d){
        for (int i=b;i<=d;i++){
            if (s[i-1] != '#' && s[i+1] !='#' && s[i] !='#'){
                cout << "Yes" <<endl;
                return 0;
            }
        }
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 592