akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define all(V) V.begin(),V.end()
using ll = long long;
const ll MOD = 1000000007;

int main() {
	int N;
	cin >> N;
	int A;
	set<int>S;
	for (int i = 0;i < N;i++) {
		cin >> A;
		S.insert(A);
	}
	if (S.size() == N)cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 9600
import java.util.*;
public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        char arr[] = sc.next().toCharArray();
        if(arr[0]!='A'){
            System.out.println("WA");
            return;
        }
        arr[0]='x';
        boolean f= false;
        for(int i=2;i<=arr.length-2;i++){
            if(arr[i]=='C'){
                f= true;
                arr[i] ='x';
                break;
            }
        }
        if(!f){
            System.out.println("WA"); return;
        }
        for(int i=0;i<arr.length;i++){
            if(Character.isUpperCase(arr[i])){
                System.out.println("WA");
                return ;
            }
        }
        System.out.println("AC");
    }
}


Measured memory_bytes: 21844
def calc_sum(n):
    sum = 0
    while n > 0:
        sum += n % 10
        n //= 10
    return sum


def main():
    N, A, B = map(int, input().split())
    ans = 0

    for i in range(1, N + 1):
        sum = calc_sum(i)
        if A <= sum and sum <= B:
            ans += i

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define mst(a, b) memset((a), (b), sizeof(a))
#define mp(a, b) make_pair(a, b)
#define pi acos(-1)
#define pii pair<int, int>
#define pb push_back
const int INF = 0x3f3f3f3f;
const double eps = 1e-10;
const int maxn = 1e5 + 107;
const int maxm = 5e5 + 10;
int s[maxn][3];
int dp[maxn][3];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    for (int i=1;i<=n;++i)
    cin>>s[i][0]>>s[i][1]>>s[i][2];
    dp[0][0]=dp[0][1]=dp[0][2]=0;
    for (int i=1;i<=n;++i)
    {
        dp[i][0]=max(dp[i-1][1],dp[i-1][2])+s[i][0];
        dp[i][1]=max(dp[i-1][0],dp[i-1][2])+s[i][1];
        dp[i][2]=max(dp[i-1][1],dp[i-1][0])+s[i][2];
    }
    cout<<max(dp[n][0],max(dp[n][1],dp[n][2]))<<endl;
    return 0;
}

Measured memory_bytes: 2560
#include <stdio.h>
#include <math.h>

int main(void) {
    int n, i, max_b, b, type, r, year;
    double ex, max_ex;

    while (EOF != scanf("%d",&n)) {
        if (n == 0) {
            break;
        }

        max_b = max_ex = 0;

        scanf("%d", &year);

        for (i = 0; i < n; i++) {
            scanf("%d %d %d", &b, &r, &type);

            if (type == 1) {
                ex = (1.0 + (double)year * (double)r / 100.0);
            } else {
                ex = pow((1.0 + (double)r / 100.0), year);
            }
            /*
             * printf("bank number is %d\n", b);
             * printf("ex is %f\n", ex);
             */

            if (max_ex < ex) {
                max_ex = ex;
                max_b = b;
            }
        }

        printf("%d\n", max_b);
    }


    return 0;
}

Measured memory_bytes: 692
#include<iostream>
#include<vector>
#include<stack>
#include<algorithm>
#include<string>
#include<set>
#include<numeric>
#include<functional>
#include<unordered_map>
#include<cmath>
using namespace std;

int main()
{
	long long A, B, C;
	cin >> A >> B >> C;
	long long counter = 0;
	bool flag = 0;
	while (A % 2 == 0 && B % 2 == 0 && C % 2 == 0) {
		long long half_A = A / 2, half_B = B / 2, half_C = C / 2;
		A = half_B + half_C;
		B = half_A + half_C;
		C = half_B + half_A;

		if (A == 2 * half_A && B == 2 * half_B && C == 2 * half_C) {
			printf("-1\n");
			return 0;
		}

		counter++;
	}
	printf("%lld\n", counter);

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
using P = pair<int,int>;
typedef long long ll;
const ll mod = 1e9+7;
#define all(x) (x).begin(),(x).end()

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(10);
    int A,B,C;
    cin >> A >> B >> C;
    if(A == B && B == C){
        cout <<"No"<< "\n";
    }else if(A != B && B != C && C != A){
        cout <<"No"<< "\n";
    }else{
        cout <<"Yes"<< "\n";
    }
}

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

int main() {

    ll n;
    cin >> n;

    ll cnt = 0;
    for ( int i = 1 ; i <= n - 1; i++ ) {
        cnt += i;
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  char N[n]={};
  int count=0;
  for(int i=0;i<n;i++){
    cin >> N[i];
    if(N[i-2]=='A' && N[i-1]=='B' && N[i]=='C')count++;
  }
  cout << count << endl;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define VI         vector<int>
#define MOD 1000000007

using ll = long long int;
using P = pair<int,int>;

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; }

const ll INF=(ll)1e19;
//const int INF=(1<<30);

int main(){
  int k;
  string s;
  cin >> k >> s;

  if(s.size()<=k){
    cout << s << endl;
  }else{
    cout << s.substr(0,k) << "..." << endl;
  }
}



Measured memory_bytes: 3624
s=input()

counter=[0]*2019
counter[0]=1
num=0
t=1
prefer=0
for i in reversed(s):
    num+=int(i)*t
    num%=2019
    t*=10
    t%=2019
    counter[num]+=1

ans=0
for i in range(2019):
    c=counter[i]
    ans+=c*(c-1)/2
print(int(ans))





Measured memory_bytes: 68512
N, Q = map(int,input().split())
P = [i for i in range(N)]

def root(x):
    path_to_root = []
    while P[x] != x:
        path_to_root.append(x)
        x = P[x]
    for node in path_to_root:
        P[node] = x
    return x

def is_same_set(x,y):
    return root(x) == root(y)

def unite(x,y):
    P[root(x)] = root(y)
    
for _ in range(Q):
    com,x,y = map(int,input().split())
    if com == 0:
        unite(x,y)
    elif com == 1:
        if is_same_set(x,y):
            print(1)
        else:
            print(0)
    



Measured memory_bytes: 5984
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <set>
#include <queue>
using namespace std;
typedef long long ll;

void solve(){
  string s; cin >> s;
  for(int i = 0; i < s.size(); i++){
    if(s[i] == '?') s[i] = 'D';
  }
  cout << s << endl;
  return;
}

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


Measured memory_bytes: 3752
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
    int n,m;
    cin >> n >> m;
    vector<string> a(n),b(m);
    rep(i,n) cin >> a[i];
    rep(i,m) cin >> b[i];
    rep(i,n-m+1) {
        rep(j,n-m+1) {
            bool same = true;
            rep(k,m) {
                if(a[i+k].substr(j,m) != b[k]) same = false;
            }
            if(same) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct _OMAZINAI_ { _OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } __omazinai_instance__;
#define INF ((1LL<<61) + (1<<29))
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
void _INPUT_IMPL_() {};
template <class T, class... Args> void _INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; _INPUT_IMPL_(args...); }
void _OUTPUT_IMPL_() {};
template <class T, class... Args> void _OUTPUT_IMPL_(T dest, Args... args) { cout<< dest << (sizeof...(Args)?" ":""); _OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; _INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define set_fix(x) ((std::cerr<<std::fixed<<std::setprecision(x)),(std::cout<<std::fixed<<std::setprecision(x)))
#define out(...) (_OUTPUT_IMPL_(__VA_ARGS__), std::cout<<std::endl)
//小さい方に寄る
#define space_op(x, y, a, b, c) ([](auto x_, auto y_, auto a_, auto b_, auto c_){if(x_<y_)return a_;if(x_>y_)return c_;return b_;}(x,y,a,b,c))
#define space_out(x, y, a, b, c) out(space_op(x, y, a, b, c))

int main() {
	in(string, a, b);
	auto c = stoll(a+b);
	bool sq = false;
	for(int i=0; i*i<=c; ++i)
		if(i*i==c)
			sq = true;
	YesNo(sq);
}



Measured memory_bytes: 256
def f(a1,b1,a2,b2,a3,b3)
    return ((b3-b2)*(a2-a1) < (b2-b1)*(a3-a2))
end

n,c = gets.split.map(&:to_i)
h = gets.split.map(&:to_i)
dp = Array.new(n,0)
a = [0]
(1...n).each do |i|
    while (a.size > 1 && (h[a[0]]-h[i])**2+dp[a[0]] > (h[a[1]]-h[i])**2+dp[a[1]])
        a.shift
    end
    dp[i] = (h[a[0]]-h[i])**2+c+dp[a[0]]
    while (a.size > 1 && !f(-2*h[a[-2]],h[a[-2]]**2+dp[a[-2]],-2*h[a[-1]],h[a[-1]]**2+dp[a[-1]],-2*h[i],h[i]**2+dp[i]))
        a.pop
    end
    a << i
end
puts dp[n-1]

Measured memory_bytes: 18060
dp[1<<26];i;a;c;b;j;
main()
{
	for(;++i<1<<26;)dp[i]=1e9;
	for(;c=getchar()-10;)
	{
		a=dp[b^=1<<c-87]+1;
		for(j=1;j<1<<26;j<<=1)a=fmin(a,dp[b^j]+1);
		dp[b]=fmin(dp[b],a);
	}
	printf("%d",a);
}

Measured memory_bytes: 262272
import math
def fs(A, B, x):
    return math.floor(A*x/B) - A * math.floor(x/B)


def main():
    A, B, N = map(int, input().split())

    print(fs(A, B, min(N, B-1)))
    return 0

if __name__ == '__main__':
    main()

Measured memory_bytes: 62068
import math

n = int(input())
list = {}
flag = True
while flag:
    flag = False
    for i in range(2,int(math.sqrt(n)+2)):
        if n%i==0:
            if i in list:
                list[i] = list[i]+1
            else:
                list[i] = 1
            n /= i
            flag = True
            break
if n>1:
    if n in list:
        list[n] = list[n]+1
    else:
        list[n] = 1
ans = 0
for i in list.keys():
    m = list[i]
    for j in range(1,m+1):
        if not j>m:
            ans += 1
            m -= j
        else:
            break
print(ans)


Measured memory_bytes: 9256
Module Module1

    Sub Main()

        Dim tmp As String() = Split(Console.ReadLine(), " ")
        Dim N As Integer = CInt(tmp(0))
        Dim M As Integer = CInt(tmp(1))

        If N = M Then
            Console.WriteLine("Yes")
        Else
            Console.WriteLine("No")
        End If

    End Sub

End Module


Measured memory_bytes: 13408
def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    plus = []
    minus = []
    for a in A:
        if a >= 0:
            plus.append(a)
        else:
            minus.append(a)
    # 答えが負になる場合をFalse
    flag = False
    if len(plus) > 0:
        if N == K:
            flag = (len(minus) % 2) == 0
        if N > K:
            flag = True
    elif len(plus) == 0:
        flag = (K % 2) == 0
    
    MOD = 10 ** 9 + 7
    ans = 1
    if flag:
        plus.sort(reverse=True)
        minus.sort()
        if K % 2 == 1:
            ans = plus.pop(0)
        B = []
        for i in range(0,len(plus),2):
            if i + 1 < len(plus):
                B.append(plus[i]*plus[i+1])
        for i in range(0,len(minus),2):
            if i + 1 < len(minus):
                B.append(minus[i]*minus[i+1])
        B.sort(reverse=True)
        for j in range(K//2):
            ans *= B[j]
            ans %= MOD
    else:
        A.sort(reverse=True)
        for i in range(K):
            ans *= A[i]
            ans %= MOD

    print(ans)
        


if __name__ == "__main__":
    main()

Measured memory_bytes: 112912
import pprint
H,W=map(int,input().split())
import copy
lastraw=["#"]*(W+2)
field=[["#"]*(W+2)]
for i in range(H):
  field.append(["#"]+list(input())+["#"])
 
field.append(lastraw)
maxmoves=0
#print(field)
saved_field=copy.deepcopy(field)
 
for i in range(H):
  for j in range(W):
    field=copy.deepcopy(saved_field)
    goal_point=(0,0)
    [sy,sx]=[j+1,i+1]
    [gy,gx]=[0,0]
 
    queue=[[sy,sx]]
    tests = ((-1,0),(0, 1),(1, 0),(0, -1))
    moves=0
 
    if field[sx][sy]=='#':
      queue=[]
    else:
      field[sx][sy]=0
 
    while True:
      if len(queue)==0:
        maxmoves=max(maxmoves,moves-1)
        break
      queue_next = []
      moves += 1
      #pprint.pprint(field)
      for y, x in queue:
        for ny, nx in tests:
          ty, tx = y + ny, x + nx
          if field[tx][ty] == '.':
            field[tx][ty] = moves
            queue_next.append((ty, tx))
      queue = queue_next
      if goal_point in queue:
        break
        #pprint.pprint(field)
        maxmoves=max(maxmoves,moves)
print(maxmoves)

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

using namespace std;
typedef long long ll;
#define REP(i,n) for (ll i = 0; i < (n); ++i)

int main(){
    string s;
    cin >> s;
    string prev;
    ll i = 0;
    ll ans = 0;
    for(ll j = 1; j <= s.size(); ++j){
        if(s.substr(i, j - i) != prev){
            ans++;
            prev = s.substr(i, j - i);
            i = j;
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
    long long n,m;
    cin>>n>>m;
    if(n>=2&&m>=2){
        cout<<(n-2)*(m-2)<<endl;
    }else if(n==1&&m==1){
        cout<<1<<endl;
    }else{
        cout<<max(n,m)-2<<endl;
    }
}


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

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	while(1){
		int n,m; cin >> n >> m;
		if(n==0&&m==0)break;
		vector<int> a(n),b(m);
		for(int i=0;i<n;i++){
			cin >> a[i];
		}
		for(int i=0;i<m;i++){
			cin >> b[i];
		}
		int now=0;
		int ans=0;
		for(int i=0;i<m;i++){
			ans++;
			now+=b[i];
			if(now>=n-1)break;
			now+=a[now];
			if(now>=n-1)break;
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 3108
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
# from collections import deque
from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np
# from numpy import cumsum  # accumulate

def solve():
    N, K = MI()
    A = LI()
    for i in range(K):
        B = [0] * N
        for idx, a in enumerate(A):
            l = max(0, idx - a)
            r = idx + a + 1
            # print(idx, a, l, r)
            B[l] += 1
            if N > r:
                B[r] -= 1
        # print(B)
        B = list(accumulate(B))
        # print(B)
        if all([j == N for j in B]):
            printlist(B)
            return
        A = B
    printlist(A)



if __name__ == '__main__':
    solve()


Measured memory_bytes: 181320
#include <set>          
#include <map>           
#include <list>
#include <ctime>
#include <deque>         
#include <bitset>        
#include <vector>
#include <list>
#include <stack>
#include <random>		 
#include <string>       
#include <numeric>      //  needed for  accumulate
#include <utility>      // needed for std:: move
#include <iterator> 
#include <iostream>   
#include <algorithm> 
#include <functional>    
#include <cmath>         
#pragma warning(disable:4996) // ignore this
#define ve vector
#define pb push_back
#define mp make_pair                     
#define srt(x) sort(x.begin(),x.end())         
#define mod static_cast<long long> (1e9+7)     
#define sumx(x) accumulate(x.begin(),x.end(),0LL)
#define pi 3.14159265358979323846
#define testing 0
using namespace std;
template<typename T>
istream& operator >> (istream& in, ve<T> &v)
{
	for (auto &x : v)
		in >> x;
	return in;
}
template<typename T>
ostream& operator<<(ostream& in, ve<T> &v)
{
	for (auto &x : v)
		in << x << " ";
	return in;
}
long long fast(long long a, long long b, long long mid)
{
	if (b == 0)
		return 1;
	a %= mid;
	long long ans = 1;
	while (b)
	{
		if (b & 1)
		{
			ans = (ans*a) % mid;
		}
		a *= a;
		a %= mid;
		b >>= 1;
	}
	return ans;
}
class solve
{
	int n;
	ve<ve<int> > adj;
	ve<int> parent;
	ve<int> sbt,visit;
	void dfs(int c)
	{
		visit[c]=true;
		for(auto &x:adj[c])
		{
			if(!visit[x])
			{
				dfs(x);
				parent[x]=c;
				sbt[c]+=sbt[x];
			}
		}
		sbt[c]++;
	}
public:
	solve()
	{
		cin >> n;
		visit.resize(n);
		adj.resize(n);
		parent.resize(n);
		sbt.resize(n);
		for(int i=0;i<n-1;i++)
		{
			int x,y;
			cin >> x >> y;
			--x,--y;
			adj[x].pb(y);
			adj[y].pb(x);
		}
		dfs(0);
		ve<int> path;
		
		int c=n-1;
		while(c!=0)
		{
			path.pb(c);
			c=parent[c];
		}
		int y=path.size();
		int x=0;
		if(sbt[path[x]]*2>=n)
		{
			cout <<"Snuke\n";
			return;
		}
		while(x<y)
		{
			--y;
			++x;
			if(x<y && sbt[path[x]]*2>=n)
			{
				cout <<"Snuke\n";
				return;
			}
			
		}
		cout <<"Fennec\n";
		return;
	}
};
 
int32_t main()
{
	int t = 1, i = 1;
//	scanf("%d", &t);
	while (t--)
	{
		new solve;
	}
	return 0;
}

Measured memory_bytes: 10620
#include <iostream>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <cstdio>
#include <map>
#include <set>
#include <utility>
#include <string>
#include <functional>
#include <queue>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;


int main() {
    ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> arr(n);
	int i;
	for(i = 0; i < n; i++) {
		cin >> arr[i];
	}
	sort(arr.begin(), arr.end());
	bool poss = false;
	if(arr[n - 1] - arr[0] <= 1) {	
		if(arr[0] == arr[n - 1]) {
			if(arr[0] == n - 1) {
				poss = true;
			}
			else {
				poss = (n >= 2 * arr[0]);
			}
		}
		else {
			int c1 = 0, c2 = 0;
			for(i = 0; i < n; i++) {
				if(arr[i] == arr[0]) {
					c1++;
				}
				else {
					c2++;
				}
			}
			//int col_left = arr[n - 1] - c1;
			poss = (c1 + 1 <= arr[n - 1]) && (arr[n - 1] <= c2 / 2 + c1);
		}
	}
	if(poss) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
	cout << endl;		
    return 0;
}



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

using namespace std;
int n,x;
int a[105];
const int INF = 1e9;
int main() {
  cin >> n >> x;
  int ans = n;
  int t = INF;
  for(int i = 0; i < n; i++) {
    cin >> a[i];
    x -= a[i];
    t = min(t,a[i]);
  }
  cout << ans + x / t << endl;
    
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int, W: int, w: "List[int]", v: "List[int]"):
    maxv=sum(v)+1
    dp=[[2**60]*maxv for _ in range(N+1)]
    dp[0][0]=0
    for i in range(N):
        for j in range(maxv):
            if j>=v[i]:
                dp[i+1][j]=min(dp[i][j],dp[i][j-v[i]]+w[i])
            else:
                dp[i+1][j]=dp[i][j]

    ans=0
    for j in range(maxv):
        if W >= dp[N][j]:
            ans=j
    print(ans)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    w = [int()] * (N)  # type: "List[int]"
    v = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        w[i] = int(next(tokens))
        v[i] = int(next(tokens))
    solve(N, W, w, v)

if __name__ == '__main__':
    main()

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

int main(){
  int N,l,r,s;
  cin >> N;
  s = 0;
  for(int i=0;i<N;i++){
    
    cin >> l >> r;
    s+=r-l+1;
  }
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long
#define V vector<vector<ll>>
using namespace std;
ll util(int i,V & arr,int mask,V &dp){
	if(i==arr.size())
		return 1;
	if(dp[i][mask]!=-1)
		return dp[i][mask];
	ll res=0;
	for(int j=0;j<arr.size();j++){
		if(arr[i][j]==1)
		if((mask & (1<<j))==0){
			res+=util(i+1,arr,(mask | 1<<j),dp);
			res%=mod;
		}
	}
	dp[i][mask]=res;
	return res;
}
int main(){
	int n;
	cin>>n;
	V arr(n,vector<ll>(n));
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++)
			cin>>arr[i][j];
	}
	int mask=0;
	ll res=0;
	V dp(n,vector<ll>(1LL<<22,-1));
	for(int j=0;j<n;j++){
		if(arr[0][j]==1){
			res+=util(1,arr,(mask | 1<<j),dp);
			res%=mod;
		}
	}
	cout<<res;
	return 0;
}

Measured memory_bytes: 721280
import itertools
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

ans = 10**18
for v in itertools.permutations([a, b, c, d, e], 5):
    m = 0
    for i in range(len(v)):
        m += v[i]
        if i == len(v)-1:
            break
        if v[i] % 10 != 0:
            m += 10 - v[i] % 10
    ans = min(ans, m)
print(ans)


Measured memory_bytes: 3064
from itertools import combinations

N = int(input())
A = list(map(int, input().split()))
Q = int(input())
M = list(map(int, input().split()))

sum_A = set()
for i in range(N):
    for cmb in combinations(A, i+1):
        sum_A.add(sum(cmb))

for m in M:
    print("yes" if m in sum_A else "no")


Measured memory_bytes: 5708
#include <bits/stdc++.h>
    #include <math.h>
 
    using namespace std;
    typedef long long ll;
    typedef unsigned long long ull;
    # define M_PI  3.14159265358979323846
 
 
    const int M=1e9+7;
    long long mod(long long x){
        return ((x%M + M)%M);
    }
    long long add(long long a, long long b){
        return mod(mod(a)+mod(b));
    }
    long long mul(long long a, long long b){
        return mod(mod(a)*mod(b));
    }
 
    ll modPow(ll a, ll b){
        if(b==0)
            return 1LL;
        if(b==1)
            return a%M;
        ll res=1;
        while(b){
            if(b%2==1)
                res=mul(res,a);
            a=mul(a,a);
            b=b/2;
        }
        return res;
    }
    void solve (){
        int n,k;
        cin>>n>>k;
        int mini=1e9;
        int total=1;
        for(int i=1;i<=n;i++){
            total=1;
            for(int j=0;j<i;j++){
                total*=2;
            }
            for(int j=0;j<(n-i);j++)
                total+=k;
            // cout<<"in "<<total<<"\n";
            mini=min(mini,total);
        }
        cout<<mini;
    }
    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cout<<fixed;
        cout<<setprecision(10);
//        freopen("timber_input.txt", "r", stdin);
//        freopen("timber_output.txt", "w", stdout);
        int t=1;
        // cin>>t;
        for(int i=1;i<=t;i++){
//            cout<<"Case #"<<i<<": ";
            solve();
        }
        return 0;
    }

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ll          long long
#define pb          push_back
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define rs(v,n)     v.resize(n)
#define hell        1000000007
#define peak        9123372036854775807
#define pii         acos(-1)
#define clr(a,x)    memset(a,x,sizeof(a))
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
template<class x,class y> x sum(x a,y b){return a+b;}
template<class x,class y> x mul(x a,y b){return a*b;}
template<class x,class y> x sub(x a,y b){return a-b;}
template<class x,class y> x divi(x a,y b){return a/b;}

template<class x,class y>
istream &operator>>(istream &in,pair<x,y> &p) 
{ 
    in>>p.F>>p.S;
    return in;
}
template<class x>
istream &operator>>(istream &in,vector<x> &v) 
{
    for(auto& i:v)
        in>>i;
    return in;
}
template<class x,class y>
ostream &operator<<(ostream &out,pair<x,y> &p) 
{ 
    out<<"("<<p.F<<","<<p.S<<") ";
    return out; 
}
template<class x>
ostream &operator<<(ostream &out,vector<x> &v) 
{ 
    out<<v.size()<<endl;
    for(auto i:v)
        out<<i<<" ";
    out<<endl;
    return out; 
}
#define N  1000005

int main()
{
    ios;
    ll tt=1;
    // cin>>tt;
    while(tt--)
    {
    	ll i,j,k,l,m,n;
    	cin>>n>>k;
    	ll ans=0;
    	for(i=k;i<=n+1;i++)
    	{
    		ll l,r;
    		l=(i*(i-1))/2;
    		r=(n*(n+1))/2;
    		ll x=n-i;
    		r-=(x*(x+1))/2;
    		ans=(ans+r-l+1)%hell;
    		// cout<<l<<" "<<r<<endl;
    	}
    	cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 3652
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static readonly long Mod = 1000000000 + 7;

        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var HW = Sarray();
            var H = HW[0];
            var W = HW[1];
            var x = new int[] { 0, 1, -1, 0 };
            var y = new int[] { 1, 0, 0, -1 };
            var canvas = new List<string>();
            canvas.Add(new string('.', (int)W + 2));
            for (var i = 0; i < H; ++i)
                canvas.Add($".{ReadLine()}.");
            canvas.Add(new string('.', (int)W + 2));
            for (var i = 1; i <= H; ++i)
            {
                for (var j = 1; j <= W; ++j)
                {
                    if (canvas[i][j] == '.')
                        continue;
                    var isBlack = false;
                    for (var k = 0; k < 4; ++k)
                        if (canvas[i + y[k]][j + x[k]] == '#')
                            isBlack = true;
                    if (!isBlack)
                    {
                        WriteLine("No");
                        return;
                    }
                }
            }
            WriteLine("Yes");
            //Out.Flush();
        }
    }
}

Measured memory_bytes: 13396
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<time.h>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; ++i)
#define FOR(i,n,m) for(long long i=n; i<m; ++i)
#define DUMP(n,a) for(long long dump=0; dump<n; ++dump) { cout<<a[dump]; if(dump!=n-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;
 
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin>>s;
	cout<<s.substr(0,s.size()-8)<<endl;
}


Measured memory_bytes: 256
n = gets.to_i
s1 = gets.chomp
s2 = gets.chomp
mod = 10**9 + 7

if s1[0] == s2[0]
  comb = 3
  pred = :v
  i = 1
else
  comb = 6
  pred = :h
  i = 2
end

while i <= n - 1
  if s1[i] == s2[i]
    comb *= pred == :v ? 2 : 1
    pred = :v
    i += 1
  else
    comb *= pred == :v ? 2 : 3
    pred = :h
    i += 2
  end

  comb %= mod
end

puts comb

Measured memory_bytes: 14368
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }


int main() {
    int N, M;
    while (cin >> N >> M) {
        long long res = 0;
        for (int i = 0; i < N+M; ++i) {
            for (int j = i+1; j < N+M; ++j) {
                int tmp = 0;
                tmp += (i < N ? 0 : 1);
                tmp += (j < N ? 0 : 1);
                if (tmp % 2 == 0) ++res;
            }
        }
        cout << res << endl;
    }
}

















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

#define REP(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define ALL(c) c.begin(), c.end()
#define SZ(c) (int) c.size()
#define DBG1(x) cout<<#x<<" = "<<x<<"\n"
#if USE_CP_REDIR
#define CP \
    freopen("input.txt","r", stdin); \
    freopen("output.txt","w", stdout);
#endif

using ll = long long;
using pii = pair<int,int>;

const ll MOD = 1'000'000'007;
const int MN = 1'000'000;

int main()
{
ios::sync_with_stdio(false);
#ifdef CP
    CP;
#endif
    int n;
    cin >> n;
    vector<pii> D(n);
    REP(i,0,n) cin >> D[i].first >> D[i].second;
    REP(i,0,n-2){
        if(D[i].first == D[i].second &&
           D[i+1].first == D[i+1].second &&
           D[i+2].first == D[i+2].second){
               cout << "Yes" << endl;
               return 0;
           }
    }

    cout << "No" << endl;
}

Measured memory_bytes: 3652
#include<iostream>
#include<queue>
#include<map>
#define MAX 10000000
#include<vector>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
struct edge{
	int cost,to;
};
typedef pair<int,int> p;
typedef pair<int,p> P;
//`Pbg@»ÝÌ@v
int main(){
	int tic,n,m,s,a,b,g,d[11][101],f;
	//d ticket place
	while(cin>>tic>>n>>m>>s>>g,tic||n||m||s||g){
		s--;g--;
		//tic `Pbg
		//n Ì
		//m ´Ì
		//s¨g
		vector<edge> v[101];
		rep(i,m){
			cin>>a>>b>>f;
			a--;b--;
			edge c;
			c.cost=f;
			c.to=b;v[a].push_back(c);
			c.to=a;v[b].push_back(c);
		}
		rep(i,tic+1)
		rep(j,n){
			if(j==s)
			d[i][j]=0;
			else
			d[i][j]=MAX;
		}
		int nowticket,nowplace,nowsum;
		priority_queue<P,vector<P>,greater<P> > que;
		P now;
		que.push(P(tic,p(s,0)));
		while(!que.empty()){
			now=que.top();
			que.pop();
			nowticket=now.first;
			nowplace=now.second.first;
			nowsum=now.second.second;
			if(d[nowticket][nowplace]<nowsum)
				continue;
			rep(i,(int)v[nowplace].size()){
				edge e=v[nowplace][i];
				if(nowticket>0){
					if(d[nowticket-1][e.to]>e.cost/2+nowsum){
						d[nowticket-1][e.to]=e.cost/2+nowsum;
						que.push(P(nowticket-1,p(e.to,d[nowticket-1][e.to])));
					}
				}
				if(d[nowticket][e.to]>e.cost+nowsum){
						d[nowticket][e.to]=e.cost+nowsum;
						que.push(P(nowticket,p(e.to,d[nowticket][e.to])));
				}
			}
		}
		int mi=100000000;
		rep(i,tic+1)
		mi=min(mi,d[i][g]);
		cout<<mi<<endl;
	}
	return 0;
}

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

int main() {
    int n; cin >> n;
    vector<lint> s(n);
    rep(i,n) cin >> s[i];
    lint ans = 0;
    rep(i,n-2) {
        for(int j=i+1; j<n-1; j++) {
            for (int k=j+1; k<n; k++) {
                if (s[i] == s[j] || s[j] == s[k] || s[i] == s[k]) continue;
                if (s[i]+s[j] > s[k] && s[j]+s[k] > s[i] && s[i]+s[k] > s[j]) ans ++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>

using namespace std;

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

Measured memory_bytes: 512
n = int(input())
a = list(map(int, input().split()))
for i in range(n):
    if a[i]%2 == 0:
        if a[i]%3 == 0:
            continue
        elif a[i]%5 == 0:
            continue
        else:
            print("DENIED")
            exit()
print("APPROVED")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define divceil(A, B) ((A + (B - 1)) / B)
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define CERR if(false) cerr

typedef long long ll;

using namespace std;

ll lcd(ll a, ll b){
    if(a < b) return lcd(b,a);
    if(a % b == 0){
        return b;
    }else{
        return lcd(a % b, b);
    }
}

ll gcd(ll a, ll b){
    return a / lcd(a,b) * b;
}

int main(){

    ll a,b;

    cin >> a >> b;

    cerr << lcd(a,b) << endl;

    cout << gcd(a,b) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int n;
long long t, a;
long long x, y, z;
int main() {
	scanf("%d", &n);
	t = 1; a = 1;
	for (int i = 0; i < n; i++) {
		scanf("%lld%lld", &x, &y);
		z = (t - 1) / x;
		if (z < (a - 1) / y)z = (a - 1) / y;
		z++;
		t = x * z;
		a = y * z;
	}
	printf("%lld\n", t + a);
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ld INF = (ld)10000000000000;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;

const ll m = 999999937;
int n; string t;
ll rol[1 << 20]; ll srol[1 << 20];
ll invrol[1 << 20], sinvrol[1 << 20];
ll x[1 << 20]; ll invx[1 << 20];

ll mod_pow(ll z, ll n) {
	ll ret = 1;
	while (n) {
		if (n % 2)ret = ret * z%mod;
		n >>= 1; z = z * z%mod;
	}
	return ret;
}
ll invm;
void init() {
	x[0] = 1;
	rep(i, ((1 << 20) - 1)) {
		x[i + 1] = x[i] * m%mod;
	}
	invm = mod_pow(m, mod - 2);
	invx[0] = 1;
	rep(i, ((1 << 20) - 1)) {
		invx[i + 1] = invx[i] * invm%mod;
	}
}
ll calc(int i, int len) {
	ll ret = srol[i + len] - srol[i]; ret = (ret + mod) % mod;
	return ret * invx[i] % mod;
}
ll invcalc(int i, int len) {
	ll ret = sinvrol[i + len] - sinvrol[i]; ret = (ret + mod) % mod;
	return ret * invx[i] % mod;
}
bool can(int k) {
	k--;
	if (2 * k > n) {
		int r = n % k; r--;
		ll le = calc(k - r, r);
		ll ri = invcalc(0, r);
		return le == ri;
	}
	ll le = calc(0, k); ll ri = invcalc(n - 2 * k, k);
	ll le2 = calc(1, k - 1); ll ri2 = invcalc(n - 2 * k, k - 1);
	//cout << k + 1 << " " << le2 << " " << ri2 << endl;
	if (le2 != ri2)return false;

	//cout << k + 1 << endl;
	for (int i = 0; i + k <= n; i += 2 * k) {
		ll c = calc(i, k);
		if (le != c)return false;
	}
	//cout << k + 1 << endl;
	for (int i = k; i + k <= n; i += 2 * k) {
		ll c = invcalc(n - (i + k),k);
		if (ri != c)return false;
	}
	//cout << k + 1 << endl;
	ll r = n % (2 * k); ll d = n / (2 * k); d *= 2 * k;
	if (r <= k) {
		ll c = calc(d, r);
		le = calc(0, r);
		if (c != le)return false;
	}
	else {
		r %= k;
		ri = invcalc(n - k - r,r);
		ll c = invcalc(0, r);
		if (c != ri)return false;
	}
	return true;
}
bool somosomo() {
	rep(i, n - 1) {
		if (t[i] != t[i + 1])return false;
	}
	return true;
}
int main() {
	init();
	cin >> n >> t;
	if (somosomo()) {
		cout << 2 << endl; return 0;
	}
	rep(i, n) {
		rol[i] = (t[i] - 'a' + 1)*x[i]%mod;
	}
	rep(i, n) {
		srol[i + 1] += srol[i] + rol[i]; srol[i + 1] %= mod;
	}
	rep(i, n) {
		invrol[i] = (t[n - 1 - i] - 'a' + 1)*x[i] % mod;
	}
	rep(i, n) {
		sinvrol[i + 1] += sinvrol[i] + invrol[i]; sinvrol[i + 1] %= mod;
	}
	int ans = n;
	Rep1(k,2, n-1) {
		if (can(k)) {
			ans = k; break;
		}
	}
	cout << ans << endl;
	//stop
	return 0;
}


Measured memory_bytes: 51804
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
using namespace std;
#define rep(i,a,n) for(llint i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define sort(s) sort(s.begin(),s.end())
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<int>>
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！


//2のn乗を求めるよ！！！
int ni(int n) {
	if (n == 0)return 1;
	int x = ni(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;
}

//フィボナッチ数列のx番目を求めるよ！
llint f(int x, vector<llint> &s) {
	if (x == 0)return 0;
	if (x == 1)return 1;
	if (s[x] != 0)return s[x];
	return  s[x] = f(x - 1, s) + f(x - 2, s);
	
}

//aとｂの最大公約数を求めるよ！
llint gcd(llint a, llint b) {
	if (a < b)swap(a, b);
	if (b == 0)return a;
	return gcd(b, a % b);
}



// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

// mod. m での a の逆元 a^{-1} を計算するよ！
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


//aCbをmod.mで割った余りを求める
ll int c(ll int a, ll int b, ll int m) {
	ll int ans = 1;
	for (ll int i = 0; i < b; i++) {
		ans *= a - i;
		ans %= m;
	}
	for (ll int i = 1; i <= b; i++) {
		ans *= modinv(i, m);
		ans %= m;
	}
	return ans;
}

//m進数のn桁を全列挙やで
void dfs(int m, int n) {
	int x = 0;
	stack<string> st;
	st.push("");
	while (!st.empty()) {
		string now = st.top();
		st.pop();
		if (now.size() == n) {
			cout << now << endl;
		}
		else {
			for (int i = m - 1; i >= 0; i--) {
				string next = now + to_string(i);
				st.push(next);
			}
		}
	}
	cout << x << endl;
}
void press(string& v) { v.erase(unique((v).begin(), (v).end()), v.end()); }

llint min(llint a, llint b) {
	if (a < b)return a;
	return b;
}
llint max(llint a, llint b) {
	if (a < b)swap(a, b);
	return a;
}
llint p(int n) {
	if(n==1)return 1;
	return n * p(n - 1);
}

int main() {
	int s;
	cin >> s;
	hei(int) a(s),b(s),c(s);
	rep(i, 0, s) {
		cin >> a[i];
		c[i] = i + 1;
	}
	int n=0, m=0;
	rep(i, 0, s)cin >> b[i];
	for (int i = 0; i < p(s); i++) {
		int x = 0;
		int z = 0;
		for (int j=0; j < s; j++) {
			if (c[j] == b[j])z++;
			if (c[j] == a[j])x++;
		}
		if (z == s)n = i + 1;
		if (x == s)m = i + 1;
		next_permutation(begin(c), end(c));
	}
	cout << abs(n - m) << endl;
	return 0;
}


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

int main() {
  int b[101] = {}, n, a, mini = 100, maxi = 0, cnt = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a;
    b[a]++;
    if (b[a] >= 3) {
      cnt++;
    }
    mini = min(mini, a);
    maxi = max(maxi, a);
  }

  if (mini != (maxi + 1) / 2) {
    cout << "Impossible" << endl;
    return 0;
  }
  if (maxi % 2 == 0 && b[mini] >= 2 || b[mini] >= 3) {
    cout << "Impossible" << endl;
    return 0;
  }
  if (n - cnt != maxi + 1) {
    cout << "Impossible" << endl;
    return 0;
  }
  for (int i = mini; i <= maxi; i++) {
    if (!(b[i] >= 2 || i == mini && maxi % 2 == 0)) {
      cout << "Impossible" << endl;
      return 0;
    }
  }
  cout << "Possible" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
using namespace std;

int main()
{
    int A;
    int B[210000];
    cin >> A;
    for(int i=0; i < A ;i++){
        cin >> B[i];
    }
    std::sort(B, A+B);
    int flag = 0;
    for(int i=0;i < A-1 ;i++){
            if (B[i] == B[i+1]){
                cout << "NO" << endl;
                flag = 1;
                break;
        }
    }
    if(flag == 0) cout << "YES" << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <set>
#include <map>
#include <unordered_map>
#include <vector>
#include <queue>
#include <string>
#include <iomanip>
#include <stdio.h>
#include <cstring>
#include <random>
#include <chrono>
#include <bitset>
#include <fstream>
#include <sstream>

using namespace std;

typedef long long ll;
typedef long double ld;

ll big = 1000000007ll;
float likeabutterfly;
string likeabee;
ll n,m,q,h,k,w;
ll T;


int main()
{
    ll c1,c2,c3,c4,c5,c6;
    ll a,b,d,e,g,c;
    ll x,y,z;
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);

   string s;
   cin >> s;

   ll state = 0;

   for(c1 = 0; c1 < s.length(); c1++){

    if(state == 0 && s[c1] == 'C')state++;
    if(state == 1 && s[c1] == 'F')state++;
   }

   if(state == 2){cout << "Yes\n";}
   else{cout << "No\n";}

	return 0;
}


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

typedef long long ll;
typedef pair<ll, ll> P;


#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define frep(i,m,n) for(ll (i)=(m); (i)<=(ll)(n); (i)++)
#define rrep(i,n) for(ll (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(ll (i)=(n); (i)>(ll)(m); (i)--)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 100100100100100100;
const ll MOD = 1000000007;

// get abs
ll my_abs(ll a);
// a^n
ll a_n(ll a, ll n);
// get gcd
ll my_gcd(ll a, ll b);
// a^(-1) % MOD 
ll inv(ll a);
// (a+b+c)%MOD
ll madd(ll a, ll b, ll c);
// (a-b)%MOD
ll msub(ll a, ll b);
// (a*b*c)%MOD
ll mtime(ll a, ll b, ll c);


int main() {
    ll n, ans; cin >> n;
    vector<ll> a(n), b(n);
    rep(i, n) {
        cin >> a[i] >> b[i];
    }
    sort(ALL(a));
    sort(ALL(b));
    // 奇数
    if((n%2)==1) {
        ans = b[(n-1)/2] - a[(n-1)/2] + 1;
    }
    else {
        ll a1 = a[n/2-1], a2 = a[n/2];
        ll b1 = b[n/2-1], b2 = b[n/2];
        ans = ((b1+b2)/2 - (a1+a2+1)/2)*2 + 1;
        if((a1+a2)%2 != 0) ans++;
        if((b1+b2)%2 != 0) ans++;
    }
    cout << ans << endl;
    return 0;
}

ll my_abs(ll a) {
    if(a >= 0) return a;
    else return -1 *a;
}

ll a_n(ll a, ll n) { 
    if(n == 0) return 1;
    
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count));
}

ll my_gcd(ll a, ll b) {
    if(b == 0) return a;
    return my_gcd(b, a%b);
}

ll inv(ll a) {
    return a_n(a, MOD-2);
}

ll madd(ll a, ll b, ll c) {
    ll ret = (a+b) % MOD;
    return (ret+c) % MOD;
}

ll msub(ll a, ll b) {
    if(a < b) return (a-b+MOD) % MOD;
    else return (a-b) % MOD;
}

ll mtime(ll a, ll b, ll c) {
    ll ret = (a*b) % MOD;
    return (ret*c) % MOD;
}


Measured memory_bytes: 6376
package main

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

func main() {
	s := readStr()
	strs := strings.Split(s, "")
	sort.Strings(strs)
	a := strs[0] + strs[3]
	b := strs[1] + strs[2]
	if a == b && a[0] != a[1] {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

func checkErr(err error) {
	if err != nil {
		log.Fatal(err)
	}
}

func toInt(s string) int {
	i, e := strconv.Atoi(s)
	checkErr(e)
	return i
}

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

func readInt() int {
	var num int
	_, e := fmt.Scan(&num)
	checkErr(e)
	return num
}

func readStr() string {
	var str string
	_, e := fmt.Scan(&str)
	checkErr(e)
	return str
}

func readLine() string {
	var scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanLines)
	return nextLine(scanner)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>  // ver2.1.6
#define int long long
#define endl "\n"
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define Pii pair<int,int>
#define Tiii tuple<int,int,int>
#define PQi priority_queue<int>
#define PQir priority_queue<int, vector<int>, greater<int>>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define sortr(v) sort(v,greater<>())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define dem(a,b) ((a+b-1)/(b))
#define Vout(a) rep(i,0,a.size()-1)cout<<a[i]<<' ';cout<<a.back()<<endl
#define INF 9000000000000000000  //  9.0 * 10^18
#define MOD 1000000007  //  10^9 + 7
using namespace std;

vector<pair<int,int>> fac(int n) {  //  素因数分解
vector<Pii>r;for(int i=2;i*i<=n;++i){if(n%i)continue;r.emplace_back(i,0);while(n%i==0){
n/=i;r.back().second++;}}if(n!=1)r.emplace_back(n,1);return r;}

signed main() {
  cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(12);
  int n;
  cin >> n;
  if(n==1000000000000000000) {cout<<"0 0 0 1000000000 1000000000 0"<<endl;return 0;}
  int x,y,kt=1000000000;
  x = n/kt + 1;
  y = kt - (n%kt);
  cout << "0 0 1 1000000000 " << x <<' '<<y <<endl;
  //cout << 311114771000000000-435958503<<endl;
  return 0;
}

Measured memory_bytes: 256
S = input()

N = len(S)

ng = False
for i in range(N):#First
  if S[i] != S[-i-1]:
    ng = True
    
for i in range(N//2):#Second
  if S[i] != S[ N // 2 - i - 1]:
    ng = True

print('No') if ng else print('Yes')


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

int main(){
	int n,ans=0,cnt=0;
	cin >> n;
	string s;
	cin >> s;
	// int temp=0;
	// queue<int>q;
	for(int i=0;i<(int)s.length();i++){
		if(s[i]=='R') cnt++;
	}
	for(int i=0;i<cnt;i++){
		if(s[i]=='W') ans++;
	}
	cout << ans << '\n';
}

Measured memory_bytes: 3720
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  long long T = 1, A = 1;
  for(int i = 0; i < n; i++){
    long long t, a;
    cin >> t >> a;
    if(T%t != 0) T = T/t+1;
    else T /= t;
    if(A%a != 0) A = A/a+1;
    else A /= a;
    T = max(T, A);
    A = max(T, A);    
    T *= t;
    A *= a;
  }
  cout << T+A << endl;
  return 0;
}

Measured memory_bytes: 256
S = sorted([c for c in input()])
T = sorted([c for c in input()], reverse=True)

for i in range(min(len(S), len(T))):
    if S[i] == T[i]:
        continue
    elif S[i] < T[i]:
        print('Yes')
        break
    else:
        print('No')
        break
else:
    if len(S) < len(T):
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 3060