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


//TEMPLATE
#define pb                push_back
#define mp                make_pair
#define ll                long long
#define ld                long double
#define pii               pair <ll, ll>
#define piii              pair <ll, pii>
#define F                 first
#define S                 second

#define newline           printf("\n")
#define minusone          printf("-1\n")
#define zeroo             printf("0\n")
#define scl1(a)           scanf("%lld", &a)
#define scl2(a, b)        scanf("%lld %lld", &a, &b)
#define scl3(a, b, c)     scanf("%lld %lld %lld", &a, &b, &c)
#define prl1(a)           printf("%lld\n", a)
#define prl2(a, b)        printf("%lld %lld\n", a, b)
#define ssl1(s)           scanf(" %[^\n]", s)
#define scd1(a)           scanf("%lf", &a)
#define scd2(a, b)        scanf("%lf %lf", &a, &b)
#define prd(a)            printf("%lf\n", a)
#define prld(a)           printf("%Lf\n", a)
#define prcase(cs)        printf("Case %lld: ", cs)
#define cin1(a)           cin >> a
#define cin2(a, b)        cin >> a >> b
#define cin3(a, b, c)     cin >> a >> b >> c
#define cin4(a, b, c, d)  cin >> a >> b >> c >> d
#define cot1(a)           cout << a << "\n"
#define cot2(a, b)        cout << a << " " << b << "\n"
#define cot3(a, b, c)     cout << a << " " << b << " " << c << "\n"
#define cot4(a, b, c, d)  cout << a << " " << b << " " << c << " " << d << "\n"
#define cotline           cout << "\n"
#define cotminus          cout << "-1\n"
#define cot0              cout << "0\n"
#define cotyes            cout << "YES\n"
#define cotno             cout << "NO\n"
#define cotcase(cs)       cout << "Case " << cs << ": "

#define reversed(s)       reverse(s.begin(), s.end())
#define asort(s)          sort(s.begin(), s.end())
#define dsort(s)          sort(s.rbegin(), s.rend())
#define all(s)            s.begin(), s.end()
#define uniq(s)           s.resize(distance(s.begin(),unique(s.begin(), s.end())))
#define found(s, x)       (s.find(x) != s.end())

#define for0(i, n)        for (i = 0; i < n; i++)
#define for1(i, n)        for (i = 1; i <= n; i++)
#define fora(i, a, b)     for (i = a; i <= b; i++)
#define forb(i, b, a)     for (i = b; i >= a; i--)
#define fori(it, s)       for(auto it = s.begin(); it != s.end(); it++)

#define FR                ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ms(a, x)          memset(a, x, sizeof a)
#define bitcount(n)       __builtin_popcountll(n)

//#define pi              3.1415926536
#define pi                acos(-1)

const ll INF = LLONG_MAX;
const ll SZ = 4e5+5;
const ll mod = 1e9+7;


ll n;
//ll a[SZ];
//ll b[SZ];



int main() {
    ll cs = 0, tc = 1, x, y, z, i, j, k, p, q, ans = 0, sum = 0, c = 0, t = 0;
//    ll a, b, d;
    string s, s1, s2;

    ll r, g, b;

    cin4(r, g, b, k);

    while(g <= r && k > 0) {
        g *= 2;
        k--;
    }

    while(b <= g && k > 0) {
        b *= 2;
        k--;
    }

    if(b > g && g > r) cout << "Yes\n";
    else cout << "No\n";

    return 0;
}



Measured memory_bytes: 3620
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

#define ll long long

void swap (int *x, int *y) {
  int temp;

  temp = *x;
  *x = *y;
  *y = temp;

  return;
}


int gcd(int a, int b){
  int c;

  while (b > 0){
    c = a % b;
    a = b;
    b = c;
  }

  return a;
}

int upll(const void*a, const void*b){
  return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;
}

int downll(const void*a, const void*b){
  return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;
}

void sortup(ll*a,int n){
  qsort(a,n,sizeof(ll),upll);
}

void sortdown(ll*a,int n){
  qsort(a,n,sizeof(ll),downll);
}

long int modpow(long int a,long int n,long int mod){
  long int ans=1;
  while(n>0){
    if(n & 1){
      ans=ans*a%mod;
    }
    a=a*a%mod;
    n/=2;
  }
  return ans;
}

long int modinv(long int a,long int mod){
  return modpow(a,mod-2,mod);
}

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

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

void chmax(int *a,int b){
  if(*a < b){
    *a = b;
  }

  return;
}

void chmin(int *a,int b){
  if(*a > b){
    *a =b;
  }

  return;
}

/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/

int main(void){
  int a,b;
  scanf("%d%d",&a,&b);

  if(a==1){
    a+=100;
  }
  if(b==1){
    b+=100;
  }

  if(a>b){
    printf("Alice\n");
  }
  else if(a<b){
    printf("Bob\n");
  }
  else{
    printf("Draw\n");
  }

  return 0;
}

Measured memory_bytes: 1624
N=int(input())
A=[int(c) for c in input().split()]
D=[0 for i in range(60)];
for a in A:
  for i in range(60):
    D[i]+=a%2
    a//=2
t=1
ans=0
for i in range(60):
  ans+=D[i]*(N-D[i])*t
  t*=2
print(ans%1000000007)

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

int main() {

	int a, b, c, d;

	cin >> a >> b >> c >> d;

	if (a + b > c + d) { printf("Left"); };

	if (a + b == c + d) { printf("Balanced"); };

	if (a + b < c + d) { printf("Right"); };

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i = (a);i<=(b);i++)
#define ROF(i,a,b) for(int i = (a);i>=(b);i--)
#define MST(a,x) memset(a,x,sizeof(a))
#define DEBUG cout<<"shllhs"<<endl;
#define ll long long
#define PB push_back
#define PH push
#define MP make_pair
#define FT first
#define SD second
#define N 100005
#define M 2505
#define INF 100000000000000007
#define MOD 1000000007
#define MOD2 1000000009
#define eps 1e-10
#define pi acos(-1.0)
using namespace std;
ll a[N];
ll nrm[N],pr[N];
int ok[M];
vector<ll>prime;
map<ll,int>mp;
map<ll,ll>rev;
void pre()
{
    MST(ok,0);
    FOR(i,2,M-1)
    {
        if(!ok[i])
        {
            prime.PB(i);
            for(int j = 2*i;j<M;j+=i)ok[j] = 1;
        }
    }
}
int main()
{
    //cin.tie(0);
    //ios::sync_with_stdio(false);
    int n;
    pre();
    while(scanf("%d",&n)!=EOF)
    {
        int ans = 0;
        mp.clear();
        int f = 0;
        FOR(i,1,n)
        {
            scanf("%lld",&a[i]);
            ll t = a[i];
            ll nrm = 1,pr = 1;
            for(auto u:prime)
            {
                if(u>t)break;
                int num = 0;
                while(t%u == 0)
                {
                    num++;
                    t/=u;
                }
                num%=3;
                if(num)
                {
                    FOR(j,1,num)nrm*=u;
                    FOR(j,num,2)pr*=u;
                }
            }
            if((ll)sqrt(t+0.5)*(ll)sqrt(t+0.5)==t) pr*=(int)sqrt(t+0.5);
            else if(t*t<=(ll)1e10/pr)pr*=t*t;
            else pr = -1;
            nrm*=t;
            mp[nrm]++;
            rev[nrm] = pr;
        }
        ans+=(mp[1]>=1);
        for(map<ll,int>::iterator it = mp.begin();it!=mp.end();it++)
        {
            if(it->first == 1)continue;
            if(mp.find(rev[it->first]) == mp.end())ans+=it->second;
            else if(rev[it->first]>it->first)ans+=max(it->second,mp[rev[it->first]]);
        }
        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 13568
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<cstring>

using namespace std;

typedef long long i64;

#ifdef LDEBUG
#define debug(x) cout << #x << ":" << x << endl
#else
#define debug(...)
#endif

#define REP(i,n) for(int i=0; i<n; ++i)
int n,k;
i64 v[100];

i64 m;
i64 w[100];

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

        cin >> n >> k;
        REP(i,n)
                cin >> v[i];

        REP(l,min(k+1,n+1)) {
                REP(r,min(k+1,n+1)-l) {
                        int p = k - l - r;

                        copy(v, v+l, w);
                        copy(v+n-r, v+n, w+l);

                        sort(w,w+l+r);
                        i64 a = 0;
                        REP(i, l+r) {
                                if(w[i] < 0 && p>0){
                                        p--;
                                        continue;
                                }
                                a += w[i];
                        }
                        m = max(m, a);
                }
        }

        cout << m << endl;


        return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector< tuple<string,int,int> > vt(N);
  for(int i=1;i<=N;i++){
    string s;
    int p;
    cin >> s >> p;
    vt.at(i-1)=make_tuple(s,p,i);
  }
  sort(vt.begin(),vt.end(),[](tuple<string,int,int> a, tuple<string,int,int> b){
    if(get<0>(a) != get<0>(b)){
      return get<0>(a) < get<0>(b);
    }else{
      return get<1>(a) > get<1>(b);
    }
  });
  for(auto p:vt){
    cout << get<2>(p) << endl;
  }
  return 0;
}


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

int main(){
	using ll = long long;
	ll n, m;
	cin >> n >> m;
	map<ll, int> mp;
	while(m--){
		ll a, b;
		cin >> a >> b;
		mp[a]++;
		mp[b]++;
	}
	for(auto itr = mp.begin(); itr != mp.end(); itr++){
		if(itr->second & 1){
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
}

Measured memory_bytes: 5632
import java.util.Scanner;

class Main {
    public static void main(String args[]) {
        Scanner scanner = new Scanner(System.in);
        int S = scanner.nextInt();
        int h, m, s, temp;

        h = S / 3600;
        temp = S % 3600;
        m = temp / 60;
        s = temp % 60;

        System.out.println(h+":"+m+":"+s);
    }
}

Measured memory_bytes: 26396
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int a,b;
  cin >> a >> b;
  if(b%a==0)cout << a+b << endl;
  else cout << b-a << endl;
}


Measured memory_bytes: 256
N,K = map(int,input().split())
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
if N == 2:
    if K == 0:
        print(1)
        print('1 2')
    else:
        print(-1)
else:
    uni = combinations_count(N-1,2)
    if uni < K:
        print(-1)
    else:
        ans = []
        for i in range(2,N+1):
            ans.append([1,i])
        kai = uni-K
        for i in range(2,N+1):
            for j in range(2,N+1):
                if kai > 0:
                    if i < j:
                        ans.append([i,j])
                        kai -= 1
                else:
                    break
        print(len(ans))
        for r in ans:
            print(' '.join(map(str,r)))

Measured memory_bytes: 3844
import collections
N,K = map(int, input().split())
myMap = collections.defaultdict(int)
for i in range(K):
    input()
    withSnack =  list(map(int, input().split(" ")))
    for j in withSnack:
        myMap[j] += 1
for d in myMap.keys():
    N -= 1
print(N)

Measured memory_bytes: 9488
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations
import sys
import bisect
import string
import math
import time
import random
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase
ts=time.time()
#sys.setrecursionlimit(10**5)
input=lambda: sys.stdin.readline().rstrip()

def ran_input():
    import random
    n=random.randint(4,16)
    a=sorted([random.randint(0,5) for _ in range(n)])[::-1]
    return n,a

show_flg=False
show_flg=True

n,m=LI()
g,c=GI(n,m)

v=[-1 for i in range(n)]

def bfs(x):
    q=[x]
    v[x]=0
    while q:
        c=q.pop()
        for n in g[c]:
            if v[n]==-1:
                q.append(n)
                v[n]=1-v[c]

bfs(0)

flg=True
for i in range(n):
    MM=max([v[nb] for nb in g[i]])
    mm=min([v[nb] for nb in g[i]])
    if MM==mm and MM!=v[i]:
        continue
    else:
        flg=False
        break

#show(v,flg)
if flg:
    ans=sum(v)*(n-sum(v))-m
else:
    ans=n*(n-1)//2-m
print(ans)


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

int main(){
  
	int n,k;
	cin>>n>>k;
	
	int arr[n];
	for(int i=0; i<n; i++)
		cin>>arr[i];
	
	sort(arr,arr+n);
	int sum=0;
	
	for(int i=0; i<k; i++)
		sum+=arr[i];
	cout<<sum;
}

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

#define CIN_ONLY if(1)
struct cww{cww(){
    CIN_ONLY{
        ios::sync_with_stdio(false);cin.tie(0);
    }
}}star;
#define fin "\n"
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define DEBUG if(0)
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline void chmin(T &l,T r){l=min(l,r);}
template <typename T>inline void chmax(T &l,T r){l=max(l,r);}
template <typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}

int main(){
    int N,K;
    string s;
    cin>>N>>K>>s;
    vector<int> bin(N);
    REP(i,N)bin[i]=s[i]-'A';

    int bg=1,ed=N;
    int rev=0;
    int fi=bin[0];
    for(int e=0;ed>bg;e=1-e,ed--)
        if(bin[ed-1]!=e)break;
    while(K){
        if(ed-bg<1&&fi==1)break;
        if(fi==0)fi=1;
        else{
            int val=bin[bg]^rev;
            if(val==1){
                fi=0;
            }else{
                fi=1;
            }
            rev=1-rev;
            bg++;
        }
        K--;
    }
    if(N%2){
        fi=fi^(K%2);
    }
    FOR(i,bg,ed)s[i-bg+1]=(bin[i]^rev)+'A';
    for(int i=N-1,e=0;i>ed-bg;i--,e=1-e)s[i]=e+'A';
    s[0]=fi+'A';
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 1560
#include <iostream>
#include <cstdio>

using namespace std;

int main()
{
    int sum = 0;
    int k;
    cin >> k;
    for (int i = 1; i <= k; i++) 
    {
        sum = (sum * 10 + 7) % k;
        if (!sum) { printf("%d", i); return 0; }
    }
    cout << "-1";
    return 0;
}

Measured memory_bytes: 3256
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [n, k] <- getIntList
    print $ k * (k - 1) ^ (n - 1)

Measured memory_bytes: 508
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		String s=in.next();
		int d=in.nextInt();
		int n=s.length();
		int mod=1000000007;
		int[][] dp=new int[n][d];
		dp[0][0]=1;
		for (int i=1;i<n;++i)
			for (int j=0;j<d;++j) if (dp[i-1][j]>0)
				for (int k=0;k<10;++k) {
					dp[i][(j+k)%d]+=dp[i-1][j];
					if (dp[i][(j+k)%d]>=mod)
						dp[i][(j+k)%d]-=mod;
				}
		int pre=d,res=0;
		for (int i=0;i<n;++i) {
			int num=s.charAt(i)-'0';
			for (int j=0;j<num;++j) {
				res+=dp[n-i-1][d-pre];
				if (res>=mod) res-=mod;
				++pre;
				if (pre>d) pre-=d;
			}
		}
		if (pre%d==0) ++res;
		--res;
		if (res<0) res+=mod;
		if (res>=mod) res-=mod;
		System.out.println(res);
	}
}

Measured memory_bytes: 27860
N,M=map(int,input().split())


S=[0 for i in range(N)]
A=[]

for x in range(M):
    s=list(map(int,input().split()))
    X=[]
    for y in range(1,s[0]+1):
        X.append(s[y])
    A.append(X)
P=list(map(int,input().split()))
#print(A)
ANS=0
for i in range(2**N):
    n=i
    for j in range(N):
        if n//(2**(N-1-j))==1:
            S[j]=1
        else:
            S[j]=0
        n%=(2**(N-1-j))
    #print(S,i)
    cnt=0
    for a in range(M):
        Y=0
        for b in range(len(A[a])):
            Y+=S[A[a][b]-1]
        if Y%2==P[a]:
            cnt+=1
        
    #print(cnt)
    if cnt==M:
        ANS+=1
print(ANS)
        

Measured memory_bytes: 43888
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int mod = 1e9+7;
const int MAX = 510000;
const int V = 100005;
ll dy[8] = {1,0,-1,0,1,-1,1,-1};
ll dx[8] = {0,1,0,-1,1,-1,-1,1};
const double pi = acos(-1);
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
#define INT_MAX 1e9+7

ll dp[105][10][300];

int main(){
    ll h,w,k; cin >> h >> w >> k;
    dp[0][0][0] = 1;
    rep(i,h){
        rep(bit,1<<(w-1)){
            bool flag = true;
            rep(j,w-2){
                if((bit&(1<<j))&&(bit&(1<<(j+1)))){
                    flag = false;
                    break;
                }
            }
            if(!flag) continue;
            rep(j,w-1){
                rep(bit2,1<<(w-1)){
                    if(!(bit&(1<<j))) continue;
                    dp[i+1][j+1][bit] += dp[i][j][bit2];
                    dp[i+1][j][bit] += dp[i][j+1][bit2];
                    dp[i+1][j+1][bit] %= mod;
                    dp[i+1][j][bit] %= mod;
                }
            }
            rep(j,w){
                if(j==0 && bit&(1<<j)) continue;
                if(j==w-1 && bit&(1<<(j-1))) continue;
                if((bit&(1<<j)) || (bit&(1<<(j-1)))) continue;
                rep(bit2,1<<(w-1)){
                    dp[i+1][j][bit] += dp[i][j][bit2];
                    dp[i+1][j][bit] %= mod;
                }
            }
        }
    }
    ll ans = 0;
    rep(bit,1<<(w-1)){
        ans = (ans + dp[h][k-1][bit]) % mod;
    }
    cout << ans << endl;
}


Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
const int MAXBITSIZE=2e5+1;
struct BIT
{
	long long it[MAXBITSIZE];
	void con(long long &x,long long &y)
	{
		x+=y;
	}
	void update(long long x,long long u)
	{
		while(x<MAXBITSIZE)
		{
			con(it[x],u);
			x+=x&(-x);
		}
	}
	long long query(long long x)
	{
		long long ans=0;
		while(x)
		{
			con(ans,it[x]);
			x-=x&(-x);
		}
		return ans;
	}
}T;
int main()
{
     ios_base::sync_with_stdio(0);
     cin.tie(0);
     long long n,k,i,a;
     cin>>n>>k;
	 deque<long long>d;
	 long long inv=0;
	 for(i=0;i<k;i++)
	 {
		 cin>>a;
		 a++;
		 T.update(a,1);
		 inv+=d.size()-T.query(a-1);
		 d.push_back(a);
	 }
	 long long ans=0,x,ans2=0;
	 if(inv==0)ans++;
	 long long l=0;
	 for(;i<n;i++)
	 {
		 cin>>a;
		 a++;
		 x=T.query(d.front()-1);
		 inv-=x;
		 l=0;
		 if(x!=0)l=1;
		 T.update(d.front(),-1);
		 d.pop_front();
		 x=d.size()-T.query(a-1);
		 inv+=x;
		 if(x!=0)l=1;
		 T.update(a,1);
		 d.push_back(a);
		 if(inv==0)ans++;
		 else if(l==0)ans2++;
	 }
	 cout<<n-k+1-max(0ll,ans-1)-ans2<<'\n';
}


Measured memory_bytes: 3584
N,K = map(int,input().split())
odd_count = 0
even_count = 0
ans = 0

for i in range(1,N+1):
  if i%K == 0:
    odd_count += 1
  elif i%K == K//2:
    even_count += 1

if K%2 != 0:
  ans = odd_count**3
else:
  ans = odd_count**3 + even_count**3

print(ans)

Measured memory_bytes: 3060
#include<algorithm>/*{{{*/
#include<cctype>
#include<cassert>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<ctime>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<vector>
using namespace std;
typedef long long lld;
typedef long double lf;
typedef unsigned long long uld;
typedef pair<int,int> pii;
#define fi first
#define se second
#define pb push_back
#define mk make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define ROF(i,a,b) for(int i=(a);i>=(b);--i)
namespace RA{
    int r(int p){return 1ll*rand()*rand()%p;}
    int r(int L,int R){return r(R-L+1)+L;}
}/*}}}*/
/******************heading******************/

int n;

int main(){
    cin>>n;
    FOR(i,1,9)if(n%i==0&&n/i>0&&n/i<=9)return cout<<"Yes",0;
    cout<<"No";
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,b,a) for(int i=b;i>=a;i--)
#define efo(i,u,v) for(int i=BB[u],v=B[BB[u]][1];i;v=B[i=B[i][0]][1])
#define mset(a,x) memset(a,x,sizeof(a))
using namespace std;
typedef long long ll;
typedef double db;
char ch;
int read(){int n=0,p=1;for(ch=getchar();ch<'0' || '9'<ch;ch=getchar())if(ch=='-') p=-1;for(;'0'<=ch && ch<='9';ch=getchar()) n=n*10+ch-'0';return n*p;}
const int N=5e5+5;
int n,L;
db q[N][2];
int main()
{
	//freopen("arc072f.in","r",stdin);
	//freopen("arc072f.out","w",stdout);
	n=read(),L=read();
	db S=0,V=0;int l=1,r=0;
	fo(i,1,n)
	{
		int t=read(),v=read();
		for(S+=(db)t*v,V+=v;V>L;)
			if(V-L>=q[l][0]) S-=q[l][0]*q[l][1],V-=q[l][0],++l;
			else S-=(V-L)*q[l][1],q[l][0]-=V-L,V=L;
		printf("%.7lf\n",S/L);
		for(q[++r][0]=v,q[r][1]=t;l<r && q[r-1][1]>q[r][1] && q[r][0]<L;r--)
		{
			int dt=min(q[r-1][0],L-q[r][0]);
			q[r-1][1]=(q[r-1][1]*dt+q[r][1]*q[r][0])/(dt+q[r][0]);
			q[r-1][0]=dt+q[r][0];
		}
	}
	return 0;
}


Measured memory_bytes: 16768
import static java.lang.Math.abs;
import static java.lang.Math.atan2;
import static java.lang.Math.sqrt;
import static java.util.Arrays.deepToString;

import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	void tr(Object... os) {
		System.err.println(deepToString(os));
	}

	Scanner sc = new Scanner(System.in);
	public void run() {
		P[] ps = new P[100];
		int n = 0;
		for (;sc.hasNextLine();) {
			String line = sc.nextLine();
			String[] ss = line.split(",");
			double x = Double.parseDouble(ss[0].trim());
			double y = Double.parseDouble(ss[1].trim());
			ps[n++] = new P(x, y);
		}
		ps = Arrays.copyOfRange(ps, 0, n);
		
		double area = area(ps);
		area = Math.abs(area);
		System.out.printf("%.8f\n", area);
	}
	
	static class P implements Comparable<P> {
		double x, y;
		public P(double x, double y) {
			this.x = x;
			this.y = y;
		}
		public int compareTo(P o) {
			return x != o.x ? Double.compare(x, o.x) : Double.compare(y, o.y);
		}
		public String toString() {
			return "(" + x + "," + y + ")";
		}
		public double abs() {return sqrt(x * x + y * y); }
		public double abs2() {return (x * x + y * y); }
		public double arg() { return atan2(y, x); } // (-pi 〜 pi)
		public double dist(P o) {return this.sub(o).abs(); }
		public P mul(double k) {return new P(x * k, y * k);}
		public P div(double k) {return new P(x / k, y / k);}
		public P add(P o) {return new P(x + o.x, y + o.y);}
		public P sub(P o) {return new P(x - o.x, y - o.y);}
		public P mul(P o) {return new P(x * o.x - y * o.y,  x * o.y + y * o.x); }
		public P div(P o) {return new P(x * o.x + y * o.y, -x * o.y + y * o.x).div(o.abs2()); }
		public double dot(P o) {return x * o.x + y * o.y;} // a b sin(t)
		public double det(P o) {return x * o.y - y * o.x;} // a b cos(t)
		public P normal() { return this.div(this.abs()); }
		public P rot90() { return new P(-y, x); }
		public static P polar(double d, double rad) {return new P(d * Math.cos(rad), d * Math.sin(rad));}
	}
	double area(P[] v) {
		double ret = 0.0;
		int n = v.length;
		for (int i = 0; i < n; i++) {
			ret += v[i].det(v[(i + 1) % n]);
		}
		return abs(ret / 2.0);
	}
}

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

int main() {
    long long H, W, N;
    cin >> H >> W >> N;
    int sum = 0;
    int c = 0;
    while(sum < N) {
        if(H>=W) {
            sum+=H;
            W--;
        } else {
            sum += W;
            H--;
        }
        c++;
    }
    cout << c;
    return 0;
}



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

using namespace std;

string s, t;

int main(int argc, char* argv[]) {
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end(), greater<char>());

  for (int i = 0; i < min(s.size(), t.size()); i++) {
    if (s[i] < t[i]) {
      cout << "Yes" << endl;
      return 0;
    } else if (s[i] > t[i]) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << (s.size() < t.size() ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 3592
import java.util.*;
import java.io.*;
class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());

        int sx = Integer.parseInt(st.nextToken());
        int sy = Integer.parseInt(st.nextToken());
        int tx = Integer.parseInt(st.nextToken());
        int ty = Integer.parseInt(st.nextToken());

        StringBuilder ans=new StringBuilder();
        //first
        for(int i=0;i<Math.abs(ty-sy);i++){
            if(ty>=sy)
                ans.append("U");
            else
                ans.append("D");
        }
        for(int i=0;i<Math.abs(tx-sx);i++){
            if(tx>=sx)
                ans.append("R");
            else
                ans.append("L");
        }
        for(int i=0;i<Math.abs(ty-sy);i++){
            if(sy>=ty)
                ans.append("U");
            else
                ans.append("D");
        }
        for(int i=0;i<Math.abs(tx-sx);i++){
            if(sx>=tx)
                ans.append("R");
            else
                ans.append("L");
        }

        //second
        if(tx>=sx)
            ans.append("L");
        else
            ans.append("R");
        for(int i=0;i<Math.abs(ty-sy);i++){
            if(ty>=sy)
                ans.append("U");
            else
                ans.append("D");
        }
        if(ty>=sy)
            ans.append("U");
        else
            ans.append("D");

        for(int i=0;i<Math.abs(tx-sx);i++){
            if(tx>=sx)
                ans.append("R");
            else
                ans.append("L");
        }
        if(tx>=sx)
            ans.append("R");
        else
            ans.append("L");
        
        if(ty>=sy)
            ans.append("D");
        else
            ans.append("U");

        if(tx>=sx)
            ans.append("R");
        else
            ans.append("L");
        for(int i=0;i<Math.abs(ty-sy);i++){
            if(sy>=ty)
                ans.append("U");
            else
                ans.append("D");
        }
        if(sy>=ty)
            ans.append("U");
        else
            ans.append("D");

        for(int i=0;i<Math.abs(tx-sx);i++){
            if(sx>=tx)
                ans.append("R");
            else
                ans.append("L");
        }
        if(sx>=tx)
            ans.append("R");
        else
            ans.append("L");
        
        if(sy>=ty)
            ans.append("D");
        else
            ans.append("U");

        if(sx==tx && sy==ty)
            System.out.println("URDLDLUR");
        else
            System.out.println(ans.toString());

    }

}


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

int main(void){
  vector<int> a(3);

  for(int i = 0; i < a.size(); i ++)
    cin >> a.at(i);

  int x, y, z;

  x = abs(a.at(0) - a.at(1));
  y = abs(a.at(0) - a.at(2));
  z = abs(a.at(1) - a.at(2));

  cout << (x+y+z - max({x, y, z})) << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
int main()
{
	int  i,n,a=0,t=0,r=0,w=0;
	char s[5];
	scanf("%d", &n);
	for (i = 0; i < n; i++)
	{
		scanf("%s", s);
		if (s[0] == 'A')
		{
			a++;
		}
		else if (s[0] == 'W')
		{
			w++;
		}
		else if (s[0] == 'R')
		{
			r++;
		}
		else
		{
			t++;
		}
	}
	printf("AC x %d\n", a);
	printf("WA x %d\n", w);
	printf("TLE x %d\n", t);
	printf("RE x %d", r);
	return 0;
}


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

const int nax = 1e5 + 5;
vector<int> edges[nax];
int in_degree[nax];
int dist[nax];
bool visited[nax];

void dfs(int a) {
    assert(!visited[a]);
    visited[a] = true;
    for(int b : edges[a]) {
        dist[b] = max(dist[b], dist[a] + 1);
        --in_degree[b];
        if(in_degree[b] == 0) {
            dfs(b);
        }
    }
}

int main() {
    int n, m;
    scanf("%d%d", &n, &m);
    while(m--) {
        int a, b;
        scanf("%d%d", &a, &b);
        edges[a].push_back(b);
        ++in_degree[b];
    }
    for(int i = 1; i <= n; ++i) {
        if(!visited[i] && in_degree[i] == 0) {
            dfs(i);
        }
    }
    int answer = 0;
    for(int i = 1; i <= n; ++i) {
        answer = max(answer, dist[i]);
    }
    printf("%d\n", answer);
}


Measured memory_bytes: 9728
a,b,i,t;long long k=1;L(x,y){return y?L(y,x%y):x;}main(n){for(;scanf("%d%d",&a,&b)*a;k*=n/L(n,k),n=++i>2?i=!printf("%lld\n",k),k=1:1)for(t=a;t-1;t=t*a%b)++n;}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <array>
#include <queue>
#include <map>

typedef long long int llint;


int main(void){
  int n;
  std::string s;
  std::cin >> n >> s;

  for(int i=0; i<s.size(); i++){
    std::cout << char(((s[i] - 'A') + n)%26 + 'A') ;
  }
  std::cout << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int descending_compare(const void *a, const void *b){
    if (*(int*)a > *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}

int ascending_compare(const void *a, const void *b){
    if (*(int*)a < *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}


int lower_bound(int *a, int n, int key){
    int left, mid, right;
    left = 0, right = n;
    mid = (left + right)/2;
    while ((left+1 != mid || mid+1 != right) && mid != left){
        if (key > a[mid]){
            left = mid;
        }else{
            right = mid+1;
        }
        mid = (left + right)/2;
    }
    if (a[left] >= key)return left;
    if (a[mid] >= key)return mid;
    if (a[right] >= key)return right;
    return n;
}

unsigned long  gcd(unsigned long x, unsigned long y)
{
        if (y == 0) {
                return x;
        } else {
                return gcd(y, x % y);
        }
}



long long calc(int x){
    long long rtn = 1;
    int i;
    for (i = x; i > 1; i--){
        rtn = (rtn*i);
    }
    return rtn;
}

int character[500] = {0};

int main(void){
    char s[50];
    int len;
    int i;
    scanf("%s", s);
    len = strlen(s);
    for (i = 0; i< len; i++){
        if (character[(int)s[i]] != 0){
            printf("no\n");
            return 0;
        }
        character[(int)s[i]] = 1;
    }

    printf("yes\n");







    return 0;
}


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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N, K; cin >> N >> K;
    //x-mK >= 0 m <= x/K
    ll m = N/K;
    ll ans1 = N-m*K;
    cout << min(ans1, abs(ans1-K)) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define SZ 666666
int n,h[SZ];
const int MOD=1e9+7;
ll qp(ll a,ll b)
{
	ll x=1; a%=MOD;
	while(b)
	{
		if(b&1) x=x*a%MOD;
		a=a*a%MOD; b>>=1;
	}
	return x;
}
struct arr
{
ll g[2][2],e; bool m;
void mu(ll x)
{
	(g[0][0]*=x)%=MOD;
	(g[0][1]*=x)%=MOD;
	(g[1][0]*=x)%=MOD;
	(g[1][1]*=x)%=MOD;
}
void clr() {memset(&g,0,sizeof g);e=m=0;}
ll all() {return (g[0][0]+g[0][1]+g[1][0]+g[1][1]+e)%MOD;}
};
arr tf(arr a)
{
	if(a.m) return a;
	arr s=a;
	for(int i=0;i<2;++i)
		for(int j=0;j<2;++j)
			(s.g[j][i]+=a.g[i][j])%=MOD;
	return s;
}
arr operator * (arr a,arr b)
{
	if(a.m) return b;
	if(b.m) return a;
	arr t; t.clr();
	t.e=a.e*b.e%MOD;
	for(int i=0;i<2;++i)
		for(int j=0;j<2;++j)
			(t.e+=a.g[i][j]*b.e)%=MOD,
			(t.e+=a.e*b.g[i][j])%=MOD;
	for(int i=0;i<2;++i)
		for(int j=0;j<2;++j) if(a.g[i][j])
			for(int k=0;k<2;++k)
				for(int l=0;l<2;++l)
				{
					if(j==k) (t.e+=a.g[i][j]*b.g[k][l])%=MOD;
					else (t.g[i][l]+=a.g[i][j]*b.g[k][l])%=MOD;
				}
	return t;
}
arr go(int x,int y,int b)
{
//	cerr<<"REAL"<<x<<"~"<<y<<"\n";
	if(x>y)
	{
		arr xx;
		xx.clr(); xx.m=1;
		return xx;
	}
	if(x==y)
	{
		arr xx; xx.clr();
		xx.g[0][0]=xx.g[1][1]=qp(2,h[x]-b-1);
//		cout<<x<<":"<<y<<" "<<xx.g[0][0]<<"!!\n";
		return xx;
	}
//	cout<<x<<"~"<<y<<"  "<<b<<"\n";
	int mi=1e9;
	for(int i=x;i<=y;++i)
		mi=min(mi,h[i]);
	arr ans; ans.clr(); ans.m=1; int cl=x;
	for(int i=x;i<=y;++i)
	{
		if(h[i]==mi)
		{
			arr s=go(cl,i-1,mi); s=tf(s);
			ans=ans*s; cl=i+1;
			s.clr(); s.g[0][0]=s.g[1][1]=1;
			ans=ans*s;
		}
	}
	ans=ans*tf(go(cl,y,mi));
//	cout<<x<<"~"<<y<<"  "<<b<<" "<<ans.all()<<" extra"<<mi-b-1<<"\n";
//	cout<<ans.g[0][0]<<","<<ans.g[0][1]<<","<<ans.g[1][0]<<","<<ans.g[1][1]<<" "<<ans.e<<"||\n";
	if(mi-b-1)
	{
		ans=tf(ans);
		ans.mu(qp(2,mi-b-2));
	}
	return ans;
}
int main()
{
	cin>>n;
	for(int i=1;i<=n;++i)
		cin>>h[i];
	arr t=go(1,n,0);
	ll ans=t.all();
	ans=(ans%MOD+MOD)%MOD;
	cout<<ans<<"\n";
}


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

int main(){
    ll a,b; cin >> a >> b;
    if((a+b)%2) cout << "IMPOSSIBLE" << endl;
    else cout << (a+b)/2 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string a;
    cin>>a;
    string b=a;
    reverse(a.begin(),a.end());
    for(int i=0;i<a.size();i++)
    {
        if(a[i]=='b')a[i]='d';
        else if(a[i]=='d')a[i]='b';
        else if(a[i]=='p')a[i]='q';
        else if(a[i]=='q')a[i]='p';
    }
    if(a==b)puts("Yes");
    else puts("No");
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
using namespace std;

 
void solve(){
	ll x,y;
    cin>>x>>y;
    ll ans=numeric_limits<ll>::max();
    rep(i,2){
        ll xx=x;ll yy=y;
        rep(j,2){
            if(i)xx=-x;
            if(j)yy=-y;
            if(yy-xx>=0)ans=min(ans,yy-xx+i+j);
        }
    }
    cout<<ans<<"\n";
}
 
signed main(){
	std::ios::sync_with_stdio(false);
    std::cin.tie(0);
	solve();
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<functional>
#include<algorithm>
#define rep(i,a,b) for(int i=a;i<b;i++)
using namespace std;
vector<int> num;
int main(){
	int x;
	rep(i,0,10){
		cin>>x;
		num.push_back(x);
	}
	sort(num.begin(),num.end(),greater<int>());
	rep(i,0,3)
		cout<<num[i]<<endl;
	return 0;
}

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


bool ss[100013];
vector<int> tt;
void pp(int k){
    rep(i,k) ss[i]=true;
    ss[0]=ss[1]=false;
    for(int i=2;i*i<=k;i++)if(ss[i]==1)for(int j=i;j*i<=k;j++)ss[i*j]=false;
    rep(i,k){
        if(ss[i]==true)tt.push_back(i);
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin>>n;
    pp(100013);
    int x=lower_bound(tt.begin(),tt.end(),n)-tt.begin();
    cout<<tt.at(x)<<endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) (v).begin(),(v).end()
#define out(a) cout << (a) << endl
using namespace std;
using ll = long long;
int main(){
    int h, w;
    cin >> h >> w;
    char pic[h][w];
    rep(i, h) rep(j, w) cin >> pic[i][j];

    rep(i, h){
        rep(j, w){
            cout << pic[i][j];
        }
        cout << endl;
        rep(j, w){
            cout << pic[i][j];
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(int i=0;i<n;i++)
#define vec vector
typedef int64_t intl;
#define fi first
#define se second
#define pushb push_back
#define popb pop_back
#define SortA(c) sort(c.begin(), c.end())
#define SortD(c) sort(c.rbegin(), c.rend())
const intl mod = 1000000007;

intl modpow(intl a, intl n, intl p){
  intl res = 1;
  while (n > 0){
    if (n&1){res = (res * a) % p;}
	a = (a * a) % p;
    n >>= 1;
  }
  return res;
}

intl modinv(intl a, intl p){
  if (a == 0){
    cout << "/0 at modinv"<<endl;
    exit(0);
  }
  if ( __gcd(a,p) !=1 ){
    cout << "inv_a does not exist."<<endl;
    exit(0);
  }
  if (a < 0){
    cout << "/- at modinv" <<endl;
    exit(0);
  }
  if (a==1){return 1;}
  if (a > p){return modinv(a%p, p);}

  return p - ( modinv(p%a,p) * (p/a) ) % p;
}

intl modcomb(intl n, intl k, intl p){
  if (k > n || k < 0 || n < 0){
    cout << "error at modcomb"<<endl;
    exit(0);
  }
  if (2*k > n){ k = n-k;}
  if (k ==0){return 1;}
  intl c=1;
  for (intl i = 0; i < k; i++){
    c =( c * ( (n-i) % p ) % p ) * modinv(i+1,p) % p;
  }
  return c;
}

int main(){
  intl n,a,b;
  cin >> n >> a >> b;
  if (n==2){
    cout << 0;
    return 0;
  }
  
  intl ans;
  ans = modpow(2, n, mod);
  ans -= modcomb(n, a, mod);
  ans -= modcomb(n, b, mod);
  ans -= 1;
  while (ans < 0){
    ans += mod;
  }
  cout << ans;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

// get longest common subsequence, O(s.length() * t.length())
struct LCS {
    vvi dp;
    string s, t;
    LCS(string s, string t) : s(s), t(t) {
        dp.assign(s.size() + 1, vi(t.size() + 1, 0));
        for (int i = 1; i <= s.size(); ++i) {
            for (int j = 1; j <= t.size(); ++j) {
                if (s[i - 1] == t[j - 1]) {
                    dp[i][j] = dp[i - 1][j - 1] + 1;
                }
                chmax(dp[i][j], dp[i][j - 1]);
                chmax(dp[i][j], dp[i - 1][j]);
            }
        }
    }
    int length() { return dp[s.size()][t.size()]; }
    string restore() {
        string ret = "";
        vector<char> temp;
        temp.reserve(length());
        int sidx = s.size();
        int tidx = t.size();
        while (sidx > 0 && tidx > 0) {
            if (s[sidx - 1] == t[tidx - 1]) {
                temp.push_back(s[sidx - 1]);
                --sidx;
                --tidx;
            } else if (dp[sidx][tidx] == dp[sidx - 1][tidx])
                --sidx;
            else
                --tidx;
        }
        for (auto it = temp.rbegin(); it != temp.rend(); it = next(it)) {
            ret += *it;
        }
        return ret;
    }
};

int main() {
    string s, t;
    cin >> s >> t;
    LCS lcs(s, t);
    cout << lcs.restore() << "\n";
    return 0;
}

Measured memory_bytes: 35584
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
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; }
template<class Value>using vec = vector< Value >;
using ll = long long;
using P = pair< long long, long long >;
#define fi first
#define se second
#define el endl
#pragma endregion


void Main();
void solve(long long N, std::vector<std::string> S);

int main(){
    std::cin.tie(nullptr);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

void Main(){
    long long N;
    scanf("%lld",&N);
    std::vector<std::string> S(N);
    for(int i = 0 ; i < N ; i++){
        std::cin >> S[i];
    }
    solve(N, std::move(S));
}

void solve(long long N, std::vector<std::string> S){
    ll a=0, w=0, t=0, r=0;
    REP(i, N){
        switch(S[i][0]){
            case 'A':
                a++;break;
            case 'W':
                w++;break;
            case 'T':
                t++;break;
            case 'R':
                r++;break;
        }
    }
    cout << "AC x " << a << el;
    cout << "WA x " << w << el;
    cout << "TLE x " << t << el;
    cout << "RE x " << r << el;
}



Measured memory_bytes: 6408
#include<iostream>
#include <stdio.h>
using namespace std;
int main(){
  long long int a,b,x;
  cin>>a>>b>>x;
 
  long long int A;
  if(a!=0){
   A=(a-1)/x;
  }
  else{
     A=-1;
  }
 
  long long int B=b/x;
 
  long long int ans=B-A;
  cout<<ans<<endl;
 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using P = pair<int, int>;

int main(){
	int n;
    cin >> n;
    VI a(n+2,0);
    rep(i,n) cin >> a[i+1];

    VI to(n+2,0), from(n+2,0);
    rep(i,n+1){
        to[i+1] = to[i] + abs(a[i+1] - a[i]); 
        int j = n-i;
        from[j] = from[j+1] + abs(a[j+1] - a[j]);
    }

    rep(i,n){
        int j = i+1;
        cout << (to[j-1] + abs(a[j+1] - a[j-1]) + from[j+1]) << endl;
    }


	return 0;
}

Measured memory_bytes: 2432
a, b, c, d = [int(x) for x in raw_input().split()]
if a > c:
	(a, b), (c, d) = (c, d), (a, b)
if b <= d:
	if b - c < 0:
		print 0
	else:
		print b - c
else:
	print d - c

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

struct time_check {
    int find_time, end_time;
};

int G[101][101] = {0};
time_check t[101];
int elapsed = 0, n;
stack<int> S;

void dfs(int start) {
    S.push(start);
    while (! S.empty()) {
        elapsed++;
        int u = S.top();
        for (int i = 1; i <= n + 1; i++) {
            if (G[u][i] == 1 && t[i].find_time == 0) {
                t[i].find_time = elapsed;
                G[u][i] = 0;
                S.push(i);
                break;
            }
            if (i == n + 1) {
                t[u].end_time = elapsed;
                S.pop();
            }
        }
    }
}

int main() {
    for (int i = 1; i <= 100; i++) t[i].find_time = 0;

    int u, v, k;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> u >> k;
        for (int j = 0; j < k; j++) {
            cin >> v;
            G[u][v] = 1;
        }
    }

    for (int i = 1; i <= n; i++) {
        if (t[i].end_time == 0) {
            t[i].find_time = ++elapsed;
            dfs(i);
        }
    }

    for (int i = 1; i <= n; i++) {
        cout << i << " " << t[i].find_time << " " << t[i].end_time << endl;
    }

    return 0;
}

/*
#include<iostream>
#include<stack>
using namespace std;
static const int N = 100;
static const int WHITE = 0;
static const int GRAY = 1;
static const int BRACK = 2;

int n, M[N][N];
int color[N], d[N], f[N], tt;
int nt[N];

// uに隣接するvを番号順に取得
int next(int u) {
    for (int v = nt[u]; v < n; v++) {
        nt[u] = v + 1;
        if (M[u][v]) return v;
    }
    return -1;
}

// スタックを用いた深さ優先探索
void dfs_visit(int r) {
    for (int i = 0; i < n; i++) nt[i] = 0;

    stack<int> S;
    S.push(r);
    color[r] = GRAY;
    d[r] = ++tt;

    while (! S.empty()) {
        int u = S.top();
        int v = next(u);
        if (v != -1) {
            if (color[v] == WHITE) {
                color[v] = GRAY;
                d[v] = ++tt;
                S.push(v);
            }
        } else {
            S.pop();
            color[u] = BRACK;
            f[u] = ++tt;
        }
    }
}

void dfs() {
    // 初期化
    for (int i = 0; i < n; i++) {
        color[i] = WHITE;
        nt[i] = 0;
    }
    tt = 0;

    // 未訪問のuを始点として深さ優先探索
    for (int u = 0; u < n; u++) {
        if (color[u] == WHITE) dfs_visit(u);
    }
    for (int i = 0; i < n; i++) {
        cout << i+1 << " " << d[i] << " " << f[i] << endl;
    }
}

int main() {
    int u, k, v;

    cin >> n;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) M[i][j] = 0;
    }

    for (int i = 0; i < n; i++) {
        cin >> u >> k;
        u--;
        for (int j = 0; j < k; j++) {
            cin >> v;
            v--;
            M[u][v] = 1;
        }
    }

    dfs();

    return 0;
}
*/


Measured memory_bytes: 3120
import copy

def swap(array, i,j,tar1,tar2):
  tmp = tar1 
  array[i] = tar2
  array[j] = tmp
#  print(array)
  return array

def orderd(array):
  orderd_array = sorted(array)
#  print(array,orderd_array)
  for i in range(len(array)):
    if not orderd_array[i]==array[i]:
      return False
  return True

N = int(input())
P = list(map(int,input().split()))
# print(P)
ans = "NO"
flg = False
for i in range(N):
  for j in range(i,N):
    Pi = copy.copy(P)
    Pi = swap(Pi,i,j,Pi[i],Pi[j])
    if orderd(Pi):
      ans = "YES"
      flg=True
      break
  if flg:
    break
#print(P)
print(ans)

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define REP(NAME, NUM) for (int NAME = 0; NAME < (NUM); ++NAME)
#define BREP(NAME, NUM) for (int NAME = (NUM)-1; NAME >= 0; --NAME)
#define ALL(NAME) (NAME).begin(), (NAME).end()

int main()
{
  ll n;
  cin >> n;
  string s;
  cin >> s;
  
  ll cnt =0;
  REP(i,n){
        if(s[i] == '.') cnt++;
  }
  
  ll ans = cnt;
    
  REP(i,n){
        if(s[i] == '.') cnt--;
        else cnt++;
        ans = min(ans,cnt);
  }
  
  cout<< ans <<endl;
}


Measured memory_bytes: 640