akhauriyash/Code-Regression huggingface dataset:
import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 19
MOD = 10 ** 9 + 7

def factorize(num: int) -> dict:
    """ 素因数分解 """
    from math import sqrt
    from collections import Counter

    d = Counter()
    for i in range(2, int(sqrt(num))+1):
        while num % i == 0:
            num //= i
            d[i] += 1
        if num == 1:
            break
    if num != 1:
        d[num] += 1
    return d

N = INT()

fact = factorize(N)
used = set()
for k in fact.keys():
    cnt = 1
    while fact[k] >= cnt:
        if (k, cnt) not in used:
            used.add((k, cnt))
            fact[k] -= cnt
        cnt += 1
ans = len(used)
print(ans)


Measured memory_bytes: 9516
n=int(input())
a=list(map(int,input().split()))
aa = sorted(a,reverse=True)
ans=0
if n%2 == 0:
    for i in range(n//2):
        ans = aa[i]*2+ans
else:
    for i in range((n+1)//2):
        ans = aa[i]*2+ans
    ans = ans - aa[(n-1)//2]
ans = ans - aa[0]
print(ans)


Measured memory_bytes: 94052
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long 
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back 
#define mp make_pair
#define inf 2000000009
#define mod 1000000007
using namespace std;
vector<ll> adj[100009];
ll d[100009][2];

 void fun(ll x,bool f)
  {
    for(ll y:adj[x])
      if(d[y][f]==-1)
      {
        d[y][f]=d[x][f]+1;
        fun(y,f);
      }
  }
int main()
{ 
    fast;
    ll n,u,v;
    cin>>n>>u>>v;
    u--,v--;

    ll x,y;
    for(ll i=0;i<n-1;i++)
    {
      ll x,y;
      cin>>x>>y;
      x--;
      y--;
      adj[x].pb(y);
      adj[y].pb(x);
    }

    memset(d,-1,sizeof(d));
d[u][0]=d[v][1]=0;
    fun(u,0);
    fun(v,1);
    ll ans=0;

   for(ll i=0;i<n;i++)
    if(d[i][0]<d[i][1])
      ans=max(ans,d[i][1]);
    cout<<ans-1<<endl;
 }

Measured memory_bytes: 11264
#include<stdio.h>
int main()
{
	int r,g,b,s;
	scanf("%d%d%d",&r,&g,&b);
	s=r*100+g*10+b;
	if(s%4==0)
	printf("YES") ;
	else
	printf("NO");
	return 0;
 } 

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

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

    map<int,int> ct;
    rep(i,n){
        int a;
        cin >>a;
        for(int j=-1; j<=1; ++j) ++ct[a+j];
    }

    int ans=0;
    for(const auto &p:ct) ans=max(ans,p.se);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4736
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>

using namespace std;
long long n,m,h,sum;
int tm[100000],ylnum[100000],yl[100000];
int main()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&tm[i]);
		sum=sum+tm[i];
	}
	scanf("%lld",&m);
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d",&ylnum[i],&yl[i]);
		h=sum-(tm[ylnum[i]]-yl[i]);
		cout<<h<<endl;
	}
return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long int ll;

int main()
{
	int n;
	cin>>n;
	int *dp = new int[n];
	int *h = new int[n];
	rep(i,n){
		cin>>h[i];
	}
	dp[0] = 0;
	dp[1] = abs(h[1] - h[0]);
	for(int i = 2; i < n; i++){
		dp[i] = min(dp[i-2] + abs(h[i] - h[i-2]),dp[i-1] + abs(h[i] - h[i-1]));
	}
	cout<<dp[n-1]<<endl;
	return 0;
}



Measured memory_bytes: 1024
D, G = map(int,input().split())
prob_list = [list(map(int,input().split())) for i in range(D)]

ans = 10000000000
point = 0
for i in range(2 ** D):
    prob = 0
    point = 0
    for j in range(D):
        if (1 & (i >> j)):
            prob += prob_list[D - 1 - j][0]
            point += (D - j) * 100 * prob_list[D - 1 - j][0] + prob_list[D - 1 - j][1]
    if point >= G:
        ans = min(ans, prob)
    else:
        for k in reversed(range(D)):
            if bin(i)[2:].zfill(D)[k] == '1':
                continue
            for z in range(prob_list[k][0]):
                point += (k + 1) * 100
                prob += 1
                if point >= G:
                    ans = min(ans,prob)
        ans = min(ans, prob)
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<cstring>
#include<stdio.h>
#include<string>
using namespace std;
bool judge(string s,int length,char ch)
{
    bool flag = true;
    for (int i = 0; i < length; i++){
        if (s[i]!=ch) flag = false;
    }
    return flag;
}
int main()
{
    string a;
    cin>>a;
    string b = a;
    int ans = 10000000;
    for (int i = 0; i < a.length(); i++){
            b=a;
        char cur = a[i];
        int length = a.length();
        int f = a.length();
        int p = 0;
        while (!judge(b,length,cur)){
            length--;
            for (int j = 0; j < length; j++){
                if (b[j]==cur||b[j+1]==cur) b[j]=cur;
            }

        }
        ans = min(ans,f-length);
        //cout<<"the "<<i<<":"<<b<<" "<<f-length<<endl;
    }
    cout<<ans;
    return 0;
}


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

int main()
{
    string s;
    cin >> s;
    map<char, int> mp;
    for(char i = 'a'; i <= 'z'; i++){
        mp[i] = 0;
    }
    rep(i, 0, s.size()){
        mp[s[i]] ++;
    }
    for(char i = 'a'; i <= 'z'; i++){
        if(mp[i] == 0){
            cout << i << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}



Measured memory_bytes: 3692
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int64_t N=s.size();
  int64_t ans=0;
  int64_t w=0;
  for(int i=N-1;0<=i;i--){
  if(s.at(i)=='W')
    w++;
    else
      ans+=w;
  }cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3692
# AC: 577 msec (Python3)
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines


def string_to_number(a):
    return 1 << (ord(a) - 97)

class SegmentTree:
    def __init__(self, A):
        self.n = 2**(len(A)-1).bit_length()
        self.identity = 0
        self.seg = [self.identity] * (2 * self.n)
        
        for i, a in enumerate(A):
            self.seg[self.n-1+i] = string_to_number(a)
        for i in range(self.n-2,-1,-1):
            self.seg[i] = self.seg[2*i+1] | self.seg[2*i+2]

            
    def update(self, k, a):
        k += self.n - 1
        self.seg[k] = string_to_number(a)
        while k:
            k = (k - 1) // 2
            self.seg[k] = self.seg[k*2+1] | self.seg[k*2+2]

            
    def query(self, a, b):
        if b == a:
        	return 1
        a += self.n - 1
        b += self.n - 2
        res = self.identity
        while b - a > 1:
            if not a & 1:
                res |= self.seg[a]
            if b & 1:
                res |= self.seg[b]
                b -= 2
            a >>= 1
            b -= 1
            b >>= 1
        if a == b:
            res |= self.seg[a]
        else:
            res |= (self.seg[a] | self.seg[b])
        
        return bin(res).count("1")


def main():
    N = int(readline())
    s = readline().strip()
    seg = SegmentTree(list(s))

    Q = int(readline())
    q = map(str, read().split())
    ans = []
    for t, a, b in zip(*[iter(q)]*3):
        if t == "1":
            seg.update(int(a)-1, b)
        else:
            ans.append(seg.query(int(a)-1, int(b)))
    
    print("\n".join(map(str, ans)))


if __name__ == "__main__":
    main()


Measured memory_bytes: 47400
#include <stdio.h>

int N;
int T[101];
int M;
int P[101];
int X[101];
int total=0;
int ans[101];

int main(){
	scanf("%d",&N);
	for(int i=1;i<=N;i++){
		scanf("%d",&T[i]);
		total+=T[i];
	}
	scanf("%d",&M);
	for(int i=1;i<=M;i++){
		scanf("%d %d",&P[i],&X[i]);
		ans[i]=total-(T[P[i]]-X[i]);
	}
	for(int i=1;i<=M;i++){
		printf("%d\n",ans[i]);
	}
}

Measured memory_bytes: 128
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
from fractions import gcd
#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 input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['Yes', 'No']
MOD = 10**9+7
inf = float('inf')
IINF = 10**19
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)


# show_flg = False
show_flg = True


def main():
    N, A, B = MI()
    ans = 0

    for i in range(1, N+1):
        n = str(i)
        s = 0
        for j in range(len(n)):
            s += int(n[j])
        if s >= A and s <= B:
            ans += i

    print(ans)


if __name__ == '__main__':
    main()


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

bool c[5000+2][5000+2];

bool t(int x,int y){
	if(x<0)return false;
	if(x>5000)return false;
	if(y<0)return false;
	if(y>5000)return false;
	return c[x][y];
}

int main(){
	while(1){
		int n,ans=0;
		pair<int,int> p[3002];
		scanf("%d",&n);
		if(n==0)break;
		for(int i=0;i<5002;i++)for(int j=0;j<5002;j++)c[i][j]=false;
		for(int i=0;i<n;i++){
			scanf("%d%d",&p[i].first,&p[i].second);
			c[p[i].first][p[i].second]=true;
		}
		for(int i=0;i<n;i++){
			for(int j=i+1;j<n;j++){
				if(t(p[i].first+p[i].second-p[j].second,p[i].second+p[j].first-p[i].first)&&t(p[j].first+p[i].second-p[j].second,p[j].second+p[j].first-p[i].first))ans=max(ans,(p[i].first-p[j].first)*(p[i].first-p[j].first)+(p[i].second-p[j].second)*(p[i].second-p[j].second));
				//if(t(p[i].first-p[i].second+p[j].second,p[i].second-p[j].first+p[i].first)&&t(p[j].first-p[i].second+p[j].second,p[j].second-p[j].first+p[i].first))ans=max(ans,(p[i].first-p[j].first)*(p[i].first-p[j].first)+(p[i].second-p[j].second)*(p[i].second-p[j].second));
			}
		}
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 25628
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    double a;
    cin >> a;
    double circumference = a * 2 * 3.141592653589;
    double area = a * a * 3.141592653589;
    printf("%.6f %.6f", area, circumference);
    return 0;
}


Measured memory_bytes: 3284
class SegmentTree:#抽象セグ木
    def __init__(self, N, id, fun):#id:単位元
        self.N0 = 2**(N-1).bit_length()
        self.id = id
        self.data = [(inf, i)for i in range(2*self.N0)]
        self.fun = fun
    def update(self, k, x):
        k+=self.N0-1
        self.data[k] = x
        while k>=0:
            k = (k-1)//2
            self.data[k] = self.fun(self.data[2*k+1], self.data[2*k+2])
    def query(self, l, r):#[l, r)
        L = l+self.N0; R = r+self.N0
        s = self.id
        while L<R:
            if R&1:
                R-=1
                s = self.fun(s, self.data[R-1])
            if L&1:
                s = self.fun(s, self.data[L-1])
                L+=1
            L >>= 1; R>>=1
        return s
inf = float('inf')
N, M = map(int, input().split())
S = input()
dp = [0]*(N+1)
seg = SegmentTree(N+1, (inf, inf), min)
seg.update(0, (0, 0))
for i in range(1, N+1):
    if S[i] == '1':
        dp[i] = (inf, -1)
    else:
        c, j = seg.query(max(0, i-M), i)
        if c == inf:
            dp[i] = (inf, -1)
        dp[i] = (c+1, j)
        seg.update(i, (c+1, i))
if dp[-1][0] == inf:
    print(-1)
else:
    i = N
    ans = []
    while i>0:
        j = dp[i][1]
        ans.append(i-j)
        i = j
    print(*ans[::-1])


        




Measured memory_bytes: 84920
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<algorithm>
#include<iterator>
#include<sstream>
#include<iomanip>
#include<map>
#include<queue>
#include<deque>
#include<fstream>

#define rep(i, n) for (ll i = 0; i < n; i++) 
#define rrep(i, n) for(ll i = n-1; i>=0; i--)
#define range(i, n, m) for (ll i = n; i < m; i++) 
#define rrange(i, n, m) for (ll i = n - 1; i => m; i--) 
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vp vector<pair<ll, ll> >
#define vvp vector<vector<pair<ll, ll> > >
#define First first
#define Second second.first
#define Third second.second
//#define MOD 998244353

typedef long long int ll;
typedef unsigned long long int ull;

using namespace std;

template<class T> inline bool chmax(T & a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T & a, T b) { if (a > b) { a = b; return true; } return false; }

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

	//std::ifstream in("../../test.txt");
	//std::cin.rdbuf(in.rdbuf());


	ll W, H, X, Y;

	cin >> W >> H >> X >> Y;

	cout << setprecision(11) << W * H / 2.0 << " ";

	if (W - 2 * X == 0 && H - 2 * Y == 0) {
		cout << 1 << endl;
	}
	else {
		cout << 0 << endl;
	}

	return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#define rep(index,num) for(int index=0;index<num;index++)
#define scan(argument) scanf("%d",&argument)
#define prin(argument) printf("%d\n",argument)
#define eps 1e-15
typedef long long ll;
int main(){
	int a,b;
	scan(a); scan(b);
	if(a*b==15) printf("*\n");
	else if(a+b==15) printf("+\n");
	else printf("x\n");
	return 0;
}

Measured memory_bytes: 128
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S = input()

print(S if len(S)==2 else S[::-1])


Measured memory_bytes: 10536
#include <iostream>
#include <vector>
#include <algorithm>
#define In_Heap(n,i)  ((-1)<(i))&&((i)<(n)) //??????PQ[i]????????????
#define lt(i,j) ((i)>(j)) //????????§??????????????§?????????
#define Parent(i)  ((i-1)>>1) //?±???¶??????
#define Last_Internal(n)  Parent(n-1) //?????????????????¨?????????????°±?????????????????¶???
#define LChild(i) (((i)<<1)+1) //?????????
#define RChild(i) ((1+(i))<<1) //?????????
#define Parent_Valid(i) (0<i) //??????i???????????¶??????????????????????????????????????¶??????
#define LChildValid(n,i)   In_Heap(n,LChild(i)) //????????????i??????????????????
#define RChildValid(n,i)    In_Heap(n,RChild(i)) //????????????i??????????????????
#define Bigger(PQ,i,j)  (lt(PQ[i],PQ[j])?i:j) //???????????????
#define ProperParent(PQ,n,i) \
((RChildValid(n,i))?((LChildValid(n,i))?\
Bigger(PQ,Bigger(PQ,i,LChild(i)),RChild(i)):Bigger(PQ,i,RChild(i))):\
((LChildValid(n,i))?Bigger(PQ,i,LChild(i)):(i)))//??¨???Floyd??????????±???\????????\?????????????????´????????§???


using namespace std;
class Heap
{
public:
    vector<int> V;
    int percolate_Up(int pos); //????????????
    int percolate_Down(int pos); //????????????
    //?????????????????????????????????????????????
    void insert(int u); //?????\??????
    int del_Max(int u); //????????????
    int get_Max() {return V[0];} //???????????§/????°????
    void heapify(); //????????????
};

int Heap::percolate_Up(int pos) //????????????
{
    while(Parent_Valid(pos)) //????????????????????¶???
    {
        int parent_pos=Parent(pos); //??°?????¶??????????????????
        if(lt(V[parent_pos],V[pos])) break; //??????????????????????°±????????????
        swap(V[parent_pos],V[pos]); //???????????¢???????????§?????????????????????
        pos=parent_pos; //??´??°?????????????????????
    }
    return pos;
}

int Heap::percolate_Down(int pos) //????????????
{
    int j; //??´??¶??????
    while(pos!=(j=ProperParent(V,V.size(),pos))) //????????????????????¶????????????????????????????????????????¬?????????????
    {
        swap(V[pos],V[j]); //?????¢??????
        pos=j; //??´??°?????????????????????
    }
    return pos;
}

void Heap::insert(int u)
{
    V.push_back(u); //????????¢??????u
    percolate_Up(V.size()-1); //??????????¬?????????????
}

int Heap::del_Max(int u)
{
    int temp=V[0];
    swap(V[0],V[V.size()-1]); //??????????????????????????¢??????
    V.pop_back(); //???????????????????????????????????????????????´??????
    percolate_Down(0); //?????´????????????????????????
    return temp;

}

void Heap::heapify() //Floyd??????
{
    for(int i=Last_Internal(V.size());In_Heap(V.size(),i);i--)
    {
        percolate_Down(i); //????????????????????¨???????????????????¬?????????????
    }
}

int main()
{
   int n;
    while(cin>>n)
    {
        Heap heap;
        for(int i=0;i<n;i++)
        {
            int j;cin>>j;
            heap.V.push_back(j);
        }
        heap.heapify();
        for(int i=0;i<n;i++)
            cout<<" "<<heap.V[i];
        cout<<endl;
    }
}

Measured memory_bytes: 4908
#include <cstdio>
#include <iostream>
#include <vector>

int main() {
  using namespace std;

  int n;
  scanf("%d", &n);

  vector<int> h(n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &h[i]);
  }

  int watering_times = 0;
  for (int i = 0; i < n; i++) {
    while(h[i]) {
      watering_times++;
      h[i]--;
      int j = i+1;
      if(j == n) continue;
      while(h[j]) {
        h[j]--;
        j++;
        if(j == n) break;
      }
    }
  }

  cout << watering_times << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define INF 1e9
#define MOD 1000000007
#define All(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;

int main(void){
    int N,M;cin>>N>>M;
    vector<vector<int>> s(M);
    REP(i,M){
        int k;cin>>k;
        REP(j,k){
            int a;cin>>a;
            a--;
            s[i].push_back(a);
        }
    }

    vector<int> p(M);
    REP(i,M)cin>>p[i];

    ll res=0;
    for(int bit=0;bit<(1<<N);bit++){
        bool ok=true;
        for(int i=0;i<M;i++){
            int con=0;
            for(auto v:s[i]){
                if(bit&(1<<v))con++;
            }
            if(con%2!=p[i])ok=false;
        }
        if(ok)res++;
    }
    cout<<res<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define fi first
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fit(x) for(auto it=x.begin();it!=x.end();++it)
#define se second
#define mp make_pair
#define ALP "abcdefghijklmnopqrstuvwxyz"
#define nline cout<<"\n"
#define rep(i,x) for(i=0;i<x;++i)
#define repr(i,a,b) for(i=a;i<=b;++i)
#define mi2 500000004
#define mi3 333333336
#define MOD 1000000007
#define N 1000005
#define pll pair<ll,ll>
#define Vll vector<ll>
#define W(t) while(t--)
#define modsum(a,b,M) (a%M + b%M)%M
#define modsub(a,b,M) (a%M - b%M + M)%M
#define modmul(a,b,M) (a%M * b%M)%M
#define moddiv(a,b,M) (a%M * modinv(b,M)%M)%M
using namespace std;
ll powermod(ll x,ll n,ll M)
{
	ll result=1;
	while(n>0)
	{
	  if(n % 2 ==1)
	    result=(result * x)%M;
	  x=(x*x)%M;
	  n=n/2;
	}
	return result;
}
vector<ll> readll() {
	cin>>ws;
	vector<ll> v;
	string input;
	getline(cin, input);
	cout<<input;
	istringstream is(input);
	ll num;
	while(is>>num) v.pb(num);
	return v;
}
ll modinv(ll n,ll p) {
	return powermod(n,p-2,p);
}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll fact[1000005],invf[1000005];
void facmod(ll n,ll M) {
	ll i;
	fact[0]=fact[1]=1;
	for(i=2;i<=n;++i) {
		fact[i]=((fact[i-1])%M * (i%M))%M;
	}
	invf[n]=modinv(fact[n],M);
	for (i=n-1;i>=0;--i){
		invf[i]=invf[i+1]*(i+1);
		invf[i]%=M;
	}
}
/*****
ll T=0;
ll p[200005], d[200005];
ll tin[200005], tout[200005];
vector<ll> g[200005];

void dfs(ll v, ll par = 1, ll dep = 0) {
	p[v] = par;
	d[v] = dep;
	tin[v] = T++;
	for (auto to : g[v]) {
		if (to == par) continue;
		dfs(to, v, dep + 1);
	}
	tout[v] = T++;
}
****/
void solve() {
	string s;
	int i,c=0;
	cin>>s;
	rep(i,3) {
		if(s[i]=='A') c++;
	}
	if(c==0 || c==3) cout<<"No";
	else cout<<"Yes";
}
int main() {
  	fastio;
	ll t=1;
	//cin>>t;
	W(t) {
		solve();
	}
	
  	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int x, b, t;
    scanf("%d %d %d", &x, &b, &t);
    if(x>t)
    {
        printf("0");
    }
    else
    {
        printf("%d", (t/x)*b);
    }
    return 0;
}

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

#define _REP(i,a,b) for(int i = (a) ; i >= (int)(b) ; --i )
#define REP(i,a,b) for(int i = (a) ; i <= (int)(b) ; ++i )
#define UREP(i,u) for(int i = p[(u)] ; i + 1 ; i = edge[i].next)
//iterator: for(int u:x),x is container
#define x(p) (p).first
#define y(p) (p).second
#define pii pair<int,int>
#define mp(x,y) make_pair((x), (y))
#define ll long long
#define inf 0x3f3f3f3f
#define mem(x,v) memset((x), (v), sizeof (x))
#define ri1(x) scanf("%d", &(x))
#define ri2(x,y) scanf("%d%d", &(x), &(y))
#define ri3(x,y,z) scanf("%d%d%d", &(x), &(y), &(z))
#define ri4(a,b,c,d) scanf("%d%d%d%d", &(a), &(b), &(c), &(d))
#define pi1(a) printf("%d\n", (a))
#define pi2(a,b) printf("%d%d\n", (a), (b))

#ifdef kinesis
mt19937 rnd(228);
#else
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif

const int maxn = 2e3 + 5;
int G[maxn][maxn];
int k[maxn],n;
int x,y;

int main()
{
    ri3(n,x,y);
    for(int i=1;i<n;i++){
        for(int j=i+1;j<=n;j++){
            G[i][j] = G[j][i] = j - i;
        }
    }
    for(int i=1;i<n;i++){
        for(int j=i+1;j<=n;j++){
            G[j][i] = G[i][j] = min(G[i][j],G[i][x] + G[y][j] + 1);
            G[j][i] = G[i][j] = min(G[i][j],G[i][y] + G[x][j] + 1);
        }
    }
    for(int i=1;i<n;i++){
        for(int j=i+1;j<=n;j++){
            k[G[i][j]]++;
        }
    }
    for(int i=1;i<n;i++){
        printf("%d\n",k[i]);
    }
    return 0;
}



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

int main()
{
  char X, Y;
  cin >> X >> Y;

  if (X == Y)
  {
    cout << '=' << endl;
  }
  else if (X < Y)
  {
    cout << '<' << endl;
  }
  else
  {
    cout << '>' << endl;
  }
}


Measured memory_bytes: 3596
#include "bits/stdc++.h"
#define REP(i,n,N) for(ll i=(n); i<(N); i++)
#define RREP(i,n,N) for(ll i=(N-1); i>=n; i--)
#define CK(n,a,b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define p(s) cout<<(s)<<endl
#define p2(a,b) cout<<(a)<<" "<<(b)<<endl
typedef long long ll;
using namespace std;
const ll inf=1e18;

ll N;
int main(){
    while(cin>>N) {
        ll a[10010];
        ll ans=0;
        REP(i,0,N){
            cin>>a[i];
            while(a[i]>0){
                if(a[i]%2) break;
                a[i]/=2;
                ans++;
            }
        }
        p(ans);

        return 0;
    }
}

Measured memory_bytes: 384
argN = int(input())
argA = list(map(int,input().split()))

cntP = 0
cntZ = 0
cntM = 0
aryAbsA = []
wkMin = abs(argA[0])
#wkMinIdx = 0
for i in range(argN):
  if argA[i] == 0:
    cntZ += 1
  elif argA[i] > 0:
    cntP += 1
  else:
    cntM += 1
  aryAbsA.append(abs(argA[i]))
  if aryAbsA[i] != 0 and aryAbsA[i] < wkMin:
    wkMin = aryAbsA[i]

if cntZ == 0 and cntM % 2 == 1:
  fix = wkMin
else:
  fix = 0

print(str(sum(aryAbsA) - fix * 2))

Measured memory_bytes: 14464
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
#define maxn 105

using namespace std;
string s[maxn];
int n;
int mp[maxn][maxn];
char str[maxn];
int ans[maxn];
int main()
{
   cin>>n;
    for(int i=1;i<=n;i++)
    {cin>>s[i];
 for(int j=0;j<s[i].length();j++)
    mp[s[i][j]-'a'][i]++;

}

for(int i=0;i<26;i++)
    {int minn=100005;
        for(int j=1;j<=n;j++)

    minn=min(mp[i][j],minn);
    ans[i]=minn;
}
int cnt=0;
for(int i=0;i<26;i++)
    if(ans[i]!=0)
{
    for(int j=1;j<=ans[i];j++)
       str[cnt++]=(char)(i+'a');
}

for(int i=0;i<cnt;i++)
 cout<<str[i];
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define mk make_pair
using namespace std;
int main(){
  double n;
  while(cin>>n,n>=0){
    double m=n-(int)n,b[]={0.5,0.25,0.125,0.0625};
    int a=(int)n;
    string s,d;
    for(int i=1<<7;i>0;i/=2){
      if(a>=i)s+='1',a-=i;
      else s+='0';
    }
    for(int i=0;i<4;i++){
      if(m>=b[i])d+='1',m-=b[i];
      else d+='0';
    }
    if(m<=0.000000001||a)cout<<s<<'.'<<d<<endl;
    else cout<<"NA"<<endl;
  }
}

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

int main() {
  int N; cin >> N;
  char s[101][11];
  for ( int i = 0; i < N; i++ ) cin >> s[i];
  bool f = true;
  for ( int i = 0; i < N; i++ ) {
      for ( int j = i+1; j < N; j++ ) {
	//cout << s[i] << " " << s[j] << endl;
	if( strcmp(s[i],s[j]) == 0 ) f = false;
    }
  }

  for ( int i = 0; i < N-1; i++ ) {
    if ( s[i][strlen(s[i])-1] != s[i+1][0])  f = false;
  }
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cassert>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define rep2(i, a, b) for(ll i = a; i <= b; ++i)
#define rep3(i, a, b) for(ll i = a; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(c) begin(c), end(c)
#define ok() puts(ok?"Yes":"No");
template<class T> bool chmax(T &a, const T &b) { if(a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if(a > b) { a = b; return true; } return false; }
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using ii = pair<int, int>;
using vvi = vector<vi>;
using vii = vector<ii>;
using gt = greater<int>;
using minq = priority_queue<int, vector<int>, gt>;
using P = pair<ll,ll>;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int k; 
int main() {
  cin >> k;
  rep(i,k) {
    cout << "ACL";
  }
  cout << endl;
  return 0;
} 


Measured memory_bytes: 3636
N=int(input())
g=[[-1]*N for _ in range(N)]
ans=0
for i in range(N):
    A=int(input())
    for _ in range(A):
        x,y=map(int,input().split())
        g[i][x-1]=y
for s in range(2**N):
    flag=1
    for i in range(N):
        if (s>>i&1):
            for j in range(N):
                if g[i][j]!=-1 and (s>>j&1)!=g[i][j]:
                    flag=0
                    break
        if flag==0:break
    if flag==1:
        t=0
        x=s
        while x>0:
            t+=x%2
            x//=2
        ans=max(ans,t)
print(ans)

Measured memory_bytes: 3064
#include<stdio.h>

int main(void)
{
	char str[1001];
	char end;
	int i,j,n,sum;
	int num[1001];

	while(1){
		for(i = 0;i < 1001;i++){
			str[i] = '0';
		}
		for(i = 0;i < 1001;i++){
			num[i] = 0;
		}
		sum = 0;
		scanf("%s",str);
		if(str[0] == '0')break;
		for(i = 0;i < 1001;i++){
			if(str[i]== 0){
				n = i;
			}
		}
		for(j = 0;j < n;j++){
			num[j] = str[j] - '0';
			sum += num[j];
		}
		printf("%d\n",sum);
	}
	return 0;
}

Measured memory_bytes: 536
#include<iostream>
#include<string.h>
#include<ctype.h>
#include<string>
#include<math.h>
#define pi 3.141592653589
#include<iomanip>
using namespace std;
#include<algorithm>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 1e9
#define LINF 1e17
#define ll long long
#define MOD (int)(1e9+7)

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



int main(){
    
    int n,a[100000]={},path[100000]={},sp=0,cnt=0;;
    
    cin>>n;
    rep(i,0,n){
        cin>>a[i];
    }
    while(1){
        if(path[sp]){
            cout<<"-1"<<endl;
            break;
        }
        if(sp==1){
            cout<<cnt<<endl;
            break;
        }
        path[sp]=1;
        sp=a[sp]-1;
        cnt++;
    }
        
    return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}

// index が条件を満たすかどうか

int main() {
	int n, x, y,time;
	cin >> n;
	x = 0;
	y = 0;
	time = 0;
	for (int i = 0; i < n; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		int t = a - time;
		int sum = abs(b - x) + abs(c - y);
		if (t < sum) {
			cout << "No";
			return 0;
		}
		else {
			if ((t - sum) % 2 != 0) {
				cout << "No";
				return 0;
			}
		}
		time = a;
		x = b;
		y = c;
	}
	cout << "Yes";
}

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

using namespace std;

int main(){
  int N;
  cin>>N;
  int H[N+1],i,j=0,k,result1=0,result2;
  for(i=0;i<N;i++){
    cin>>H[i];
  }
  H[N]=H[N-1]+1;
  for(i=1;i<=N;i++){
    if(H[i]<=H[i-1]){
      j++;
    }
    else{
      result2=j;
      if(result2>result1) result1=result2;
      j=0;
    }
  }
  cout<<result1<<endl;
  return 0;
}


Measured memory_bytes: 640
n = input()
x = n[-1]

if x == "0" or x == "1" or x == "6" or x == "8":
    print("pon")
elif x == "3":
    print("bon")
elif x == "2" or x == "4" or x == "5" or x == "7" or x == "9":
    print("hon")

Measured memory_bytes: 9048
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <string>
#include <vector>
#include <numeric>
#include <stdexcept>

template <class Weight>
class WeightedQuickFind {
  std::vector<std::vector<size_t>> groups;
  std::vector<size_t> ind;
  std::vector<Weight> weight;

public:
  WeightedQuickFind(size_t n): ind(n), weight(n) {
    std::iota(ind.begin(), ind.end(), 0);
    for (size_t i=0; i<n; ++i)
      groups.emplace_back(1, i);
  }

  struct NotConnected: public std::logic_error {
    NotConnected(): std::logic_error("") {}
  };

  void unite(size_t u, size_t v, Weight w) {
    // (weight of u) - (weight of v) = w
    if (u == v) return;
    if (groups[ind[u]].size() > groups[ind[v]].size()) {
      std::swap(u, v);
      w = -w;
    }
    size_t pi=ind[u];
    // weight[u] <- weight[v]+w
    Weight x=weight[v]+w-weight[u];
    for (size_t i: groups[ind[u]]) {
      weight[i] += x;
      ind[i] = ind[v];
      groups[ind[v]].emplace_back(i);
    }
    groups[pi].clear();
  }

  Weight diff(size_t u, size_t v) const {
    if (ind[u] != ind[v])
      throw NotConnected();

    return weight[u]-weight[v];
  }

  void update(size_t u, size_t v, Weight w) {
    weight[u] += w;
    weight[v] += w;
    if (ind[u] != ind[v])
      unite(u, v, w);
  }

  void debug() const {
    fprintf(stderr, "Weight:\n");
    for (size_t i=0; i<weight.size(); ++i)
      fprintf(stderr, "%d%c", weight[i], i+1<weight.size()? ' ':'\n');

    fprintf(stderr, "Index:\n");
    for (size_t i=0; i<ind.size(); ++i)
      fprintf(stderr, "%zu%c", ind[i], i+1<ind.size()? ' ':'\n');

    fprintf(stderr, "groups:\n");
    for (size_t i=0; i<groups.size(); ++i) {
      fprintf(stderr, "{");
      for (size_t j=0; j<groups[i].size(); ++j) {
        fprintf(stderr, "%zu%s", groups[i][j], j+1<groups[i].size()? ", ":"");
      }
      fprintf(stderr, "}%s", i+1<groups.size()? ", ":"\n");
    }
    fprintf(stderr, "\n");
  }
};

int main() {
  size_t N;
  int Q;
  scanf("%zu %d", &N, &Q);

  WeightedQuickFind<int> uf(N);
  for (int i=0; i<Q; ++i) {
    char s[8];
    scanf("%s", s);
    if (s[0] == 'I') {
      size_t u, v;
      int w;
      scanf("%zu %zu %d", &u, &v, &w);
      --u, --v;
      uf.update(v, u, w);
    } else {
      size_t u, v;
      scanf("%zu %zu", &u, &v);
      --u, --v;
      try {
        printf("%d\n", uf.diff(v, u));
      } catch (WeightedQuickFind<int>::NotConnected) {
        printf("WARNING\n");
      }
    }
  }
}



Measured memory_bytes: 10172
#include<bits/stdc++.h>
using namespace std;
const double pi = acos(-1);
double a, b, h, m;

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

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

    cin >> a >> b >> h >> m;

    double x = (h + m / 60)* 30;
    double y = m * 6;
    double p = abs(x - y);
    p = min(p, 360 - p);

    double c = sqrt(a * a + b * b - 2 * a * b * cos(p * pi / 180));
    cout << fixed << setprecision(10) << c << '\n';
}


Measured memory_bytes: 4164
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<string>
#include<typeinfo>
#include<cassert>
#include<functional>
#include<algorithm>
#include<climits>
#include<map>

using namespace std;

bool palindromic(string s){

	for(int i = 0;i < s.size()/2;i++){
		if(s[i] != s[s.size() -1 -i]){
		    return false;
		}
	}

	return true;

}

int main(){

    int A,B;

    cin >> A >> B;

    int count = 0;

    for(int i = A;i<= B;i++){
    	if(palindromic(to_string(i))){
            count++;
    	}
    }

    cout << count << endl;

    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IOS                                                                    \
  ios::sync_with_stdio(0);                                                     \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<ll, ll>;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
ll bpow(ll b, ll p, ll m = 1000000007LL) {
  ll rt = 1;
  for (; p; p >>= 1, b = b * b % m)
    if (p & 1)
      rt = rt * b % m;
  return rt;
}
ll cnt[200005];
ll a[200005];
int main() {
  IOS;
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    cnt[a[i]]++;
  }
  ll ans = 0;
  for (int i = 1; i <= n; i++) {
    ans += (cnt[i] * (cnt[i] - 1)) / 2;
  }
  for (int i = 1; i <= n; i++) {
    cout << ans - cnt[a[i]] + 1 << endl;
  }
}


Measured memory_bytes: 6748
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=(0);(i)<(int)(n);++(i))
using ll = long long;
using P = pair< int, int >;
 
const int maxv = 210;
ll d[maxv][maxv];  // d[u][v]は辺e=(u,v)のコスト, （存在しない場合はINF, ただしd[i][i]=0とする）
int V;
 
void warshall_floyd() {
    for (int k=0; k<V; ++k) {
        for (int i=0; i<V; ++i) {
            for (int j=0; j<V; ++j) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
        }
    }
}
 
int main() {
    fill(d[0], d[maxv], 1e8);
    int n, m, r;
    cin >> n >> m >> r;
    vector<int> a(r);
    V = n;
    rep(i, r) {
        cin >> a[i];
        a[i]--;
    }
    rep(i, m) {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        d[a][b] = c;
        d[b][a] = c;
    }
    rep(i, n) {
        d[i][i] = 0;
    }
    warshall_floyd();
    sort(a.begin(), a.end());
    ll ans = 1e10;
    do {
        ll t = 0;
        ll pos = a[0];
        for (int i=1; i<r; ++i) {
            t += d[pos][a[i]];
            pos = a[i];
        }
        ans = min(ans, t);
    } while(next_permutation(a.begin(), a.end()));
    cout << ans << endl;
}

Measured memory_bytes: 640
import sys
import heapq

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


INF = 10**18


def dijkstra(N, s0, edge):

    d = [INF] * N  # 始点からの距離
    used = [False] * N  # 探索済みリスト
    edgelist = [(0, s0)]  # 始点はコスト0で初期化
    heapq.heapify(edgelist)  # ヒープにpush

    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        if used[minedge[1]]:
            continue
        v = minedge[1]
        d[v] = minedge[0]
        used[v] = True
        for e in edge[v]:
            if d[e[1]] <= (e[0] + d[v]) or used[e[1]]:
                continue
            heapq.heappush(edgelist, [e[0] + d[v], e[1]])
    return d


def main():
    N = in_n()

    edge = [[]for _ in range(N)]
    for i in range(N - 1):
        a, b, c = in_nn()
        a, b = a - 1, b - 1
        edge[a].append((c, b))
        edge[b].append((c, a))

    Q, K = in_nn()
    d = dijkstra(N, K - 1, edge)

    ans = []
    for i in range(Q):
        x, y = in_nn()
        x, y = x - 1, y - 1
        ans.append(d[x] + d[y])

    print('\n'.join(map(str, ans)))


if __name__ == '__main__':
    main()


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

int N, s[105];

int C[102][10050];

int main(void) {

	cin >> N;

	for (int i = 1; i <= N; i++) {
		cin >> s[i]; 
	}

	C[0][0] = 1;
	

	for (int i = 1; i <= N; i++) {
		for (int j = 0; j <= 10000; j++) {
			if (C[i - 1][j] > 0) { C[i][j]++; C[i][j + s[i]]++; }
		 }
	}

	int ans = 0;
	for (int i = 0; i <= 10000; i++) {
		if (C[N][i] > 0 && i % 10 != 0) { ans = max(ans, i); }
	}

	cout << ans << endl;


	//system("pause");
	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <vector>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main()
{
  int N, X;
  cin >> N >> X;

  int bo = 1;
  int sum = 0;
  rep(i, N)
  {
    int l;
    cin >> l;
    sum += l;
    if (sum <= X)
    {
      bo++;
    }
  }

  cout << bo << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  int r;
  cin >> r;
  cout << r*r << endl;
  return 0;
}


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

using namespace std;

int main(){
    int n;
    int tmp;
    int cnt = 0;
    cin >> n;
    for(int i= 0;i < n;i++  ){
        cin >> tmp ;
        if(tmp != i + 1){
            cnt += 1;
        }
    }
if((cnt ==0) || (cnt == 2)){
    cout << "YES" << endl;
}
else{
    cout << "NO" << endl;
}
}


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


int main() {
    string s;cin >> s;
    int len = s.size();

    vector<bool> al(26);
    for (int i = 0;i < 26;i++){
      al.at(i) == false;
    }

    for (int i = 0;i < len;i++){
      char sc;sc = s.at(i);
      int ind = sc-'a';
      al.at(ind) = true;
    }

    char ans = ' ';
    for (int i = 0;i < 26;i++){
      if (al.at(i) == false){
        ans = 'a'+i;
        break;
      }
    }
    if (ans == ' '){
      cout << "None" << endl;
    }else{
      cout << ans << endl;
    }

  }       

Measured memory_bytes: 512
sx, sy, tx, ty = map(int, input().split())
route = []


def route_go(sx, sy, tx, ty):
    road_go = []
    for _ in range(tx-sx):
        road_go.append('R')
    for _ in range(ty-sy):
        road_go.append('U')
    return road_go


def route_back(sx, sy, tx, ty):
    road_back = []
    for _ in range(tx-sx):
        road_back.append('L')
    for _ in range(ty-sy):
        road_back.append('D')
    return road_back


a = route_go(sx, sy, tx, ty)
b = route_back(sx, sy, tx, ty)
c = route_go(sx, sy-1, tx+1, ty)
d = route_back(sx-1, sy, tx, ty+1)
e = a + b + ['D'] + c + ['L'] + ['U'] + d +['R']
for i in e:
    print(i, end='')

Measured memory_bytes: 4792
from math import log2, ceil

N, K = map(int, input().split())

p = 0
for n in range(1, N + 1):
    if n > K:
        p += 1 / N
        continue
    x = ceil(log2(K) - log2(n))
    # print(x)
    p += 1 / N * pow(0.5, x)
print(p)


Measured memory_bytes: 3188
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
                int answer = 0;
		if(n/100 == 9){
			answer = 100;
			n=n-900;
		}else{
			answer = 900;
			n=n-100;
		}
		if(n/10 == 9){
			answer = answer+10;
			n=n-90;
		}else{
			answer = answer+90;
			n=n-10;
		}
		if(n == 9){
			answer = answer+1;
			
		}else{
			answer = answer+9;
		}
		System.out.println(answer);
	}
}

Measured memory_bytes: 22100
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

#define FOR(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define REP(i, n) FOR((i), 0, (n))

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

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}

int main() {
    int n;
    cin >> n;
    vector<int> p(n);
    REP(i, n)
        cin >> p[i];

    int minn = 10000000;
    int cnt = 0;
    REP(i, n){
        if(p[i] <= minn)
            cnt++;
        minn = min(minn, p[i]);
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main()
{
    long long int n,i,j,k,ar[1000]={0},a,b,br[1000]={0},cr[1000]={0},s=0,tmp,m,l,dr[1000]={0};
    while(scanf("%lld",&n)!=EOF)
    {
        for(b=1; b<=n; b++)
        {
            scanf("%lld",&ar[b]);
        }
        for(a=1;a<=n;a++){
            dr[a] = ar[a];
        }
        scanf("%lld",&m);
        for(i=1; i<=m; i++)
        {
            scanf("%lld %lld",&br[i],&cr[i]);
            for(j=1; j<=n; j++)
            {
                    if(j==br[i])
                    {
                        tmp = ar[j];
                        ar[j] = cr[i];
                        cr[i] = tmp;
                    }
            }
            for(l=1;l<=n;l++){
                s = s + ar[l];
            }
            printf("%lld\n",s);
            s = 0;
            for(l=1;l<=n;l++){
            ar[l] = dr[l];
            }
        }
         for(l=0;l<1000;l++){
            ar[l] = 0;
            br[l] = 0;
            cr[l] = 0;
            dr[l] = 0;
        }
        n = 0; m = 0; j = 0; l=0;k = 0; i = 0; a=0; b = 0;
    }
return 0;
}

Measured memory_bytes: 256
X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))


AB = [a + b for a in A for b in B]
AB.sort()
AB = AB[-K:]

ans = [ab + c for ab in AB for c in C]
ans.sort()

for x in ans[-K:][::-1]:
    print(x)


Measured memory_bytes: 137868
import java.util.Scanner;

public class Main {

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

		// standard input
		String inputText = sc.next();

		// solve
		char[] p1 = {'m', 'a', 'e', 'r', 'd'};
		char[] p2 = {'r', 'e', 'm', 'a', 'e', 'r', 'd'};
		char[] p3 = {'e', 's', 'a', 'r', 'e'};
		char[] p4 = {'r', 'e', 's', 'a', 'r', 'e'};

		char[] inputArray = inputText.toCharArray();
		int wordIndex = 0;
		char[] targetArray = null;
		for (int i = inputArray.length - 1; i >= 0; i--) {
			if (wordIndex == 0) {
				if (inputArray[i] == 'm') {
					// p1
					targetArray = p1;
				} else if (inputArray[i] == 'e') {
					// p3
					targetArray = p3;
				} else if (inputArray[i] == 'r') {
					// p2 or p4
					if (i - 2 > 0) {
						if (inputArray[i - 2] == 'm') {
							targetArray = p2;
						} else if (inputArray[i - 2] == 's') {
							targetArray = p4;
						} else {
							System.out.println("NO");
							return;
						}
					} else {
						System.out.println("NO");
						return;
					}
				} else {
					System.out.println("NO");
					return;
				}
			} else {
				if (targetArray[wordIndex] != inputArray[i]) {
					System.out.println("NO");
					return;
				}
			}

			if (wordIndex < targetArray.length - 1) {
				wordIndex++;
			} else {
				wordIndex = 0;
				targetArray = null;
			}
		}

		// standard output
		System.out.println("YES");
	}

}


Measured memory_bytes: 13848
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
double dis(pair<int,int>p,pair<int,int>q){
    double d=((p.first-q.first)*(p.first-q.first))+((p.second-q.second)*(p.second-q.second));
    return sqrt(d);
}
int main()
{
       ll r;
    cin>>r;
    cout<<r*r<<endl;
	return 0;

} 

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

using namespace std;

typedef long long ll;

#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR1(i,n) for(int (i)=1;(i)<(n);(i)++)
#define eFOR(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define eFOR1(i,n) for(int (i)=1;(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define INF 1000000000

int main() {

	int n, a[101], b[101], ans = 0;
	cin >> n;
	a[0] = 0; b[0] = 0;
	eFOR1(i, n) {
		int m;
		cin >> m;
		a[i] = a[i - 1] + m;
	}
	eFOR1(i, n) {
		int m;
		cin >> m;
		b[i] = b[i - 1] + m;
	}

	eFOR1(i, n)ans = max(ans, a[i] + b[n] - b[i - 1]);

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256