akhauriyash/Code-Regression huggingface dataset:
n, k = map(int, input().split())
dlis = []
Alis = []
for i in range(k):
    dlis.append(int(input()))
    Alis.append(list(map(int, input().split())))
lis = [0]*n
for i in range(k):
    for a in Alis[i]:
        lis[a-1] += 1
print(lis.count(0))

Measured memory_bytes: 9268
#ifdef _DEBUG
#define _CRT_SECURE_NO_WARNINGS
#include "MyLib.h"
#else
#define main_A main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define MGN 8
#define LINF (LONG_MAX/2)
using namespace std;
typedef long long ll; typedef unsigned long long ull;
typedef vector<int> vi; typedef vector<vi> vvi; 
typedef vector<ll> vl; typedef vector<vl> vvl;
typedef vector<double> vd; typedef vector<string> vs;
typedef pair<int, int> pii; typedef pair<ll, ll> pll;
typedef vector<bool> vb; typedef vector<vb> vvb;
template <typename T>
using keyVal = pair<string, T>;
template<typename T>
bool val_greater(const keyVal<T>& left, const keyVal<T>& right) {
    return left.second > right.second;}
vs split(string str, char sep) {
    vs v; stringstream ss(str); string t;
    while (getline(ss, t, sep)) v.push_back(t);
    return v;}
vs re_search_g(string s, regex re) {
    vs ret; smatch mc; auto it = s.cbegin();
    while (regex_search(it, s.cend(), mc, re)) {
        ret.push_back(mc[0]);
        it += mc.position(0) + mc.length();}
    return ret;}
#endif

void init_global_A() {}


int main_A() {
    cin.tie(0);
    ios::sync_with_stdio(false);
     
    int A, B, C; cin >> A >> B >> C;

    string ans = "No";
    if (A <= C && C <= B) ans = "Yes";

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
main=mapM_ putStrLn.solve.lines=<<getContents
solve(hw:s)=zipWith(\i t->zipWith(g i)[0..]t)[0..]s where
  [h,w]=map read.words$hw
  f i j=if i<0||h<=i||j<0||w<=j||s!!i!!j=='.'then 0 else 1
  g x y c=if c=='#' then c else head$show$sum[f i j|i<-[x-1..x+1],j<-[y-1..y+1],i/=x||j/=y]

Measured memory_bytes: 1020
n=int(input())
l=[int(i) for i in input().split()]
l.sort()
ans=0


for i in range(2,n):
    for j in range(1,i):
        for k in range(j):
            if l[k]==l[j] or l[i]==l[j] or l[i]==l[k]:
                continue
            x=l[k]+l[j]

            if x > l[i]:
                ans+=1

print(ans)


Measured memory_bytes: 9188
def gcd(a, b):
  while b:
    a, b = b, a % b
  return a

def lcm(a, b):
  return a * b // gcd (a, b)

N = input()
T = [input() for i in range(N)]

for i in range(N-1):
  T[i+1]=lcm(T[i],T[i+1])

print T[N-1]

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

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

int main(){
    ll p[4][3][10]={};
    ll n,b,f,r,v;
    cin>>n;
    REP(i,n){
        cin>>b>>f>>r>>v;
        p[b-1][f-1][r-1]+=v;
    }
    REP(i,4){
        if(i!=0){
            REP(j,20)cout<<"#";
            cout<<endl;
        }
        REP(j,3){
            REP(k,10){
                cout<<" "<<p[i][j][k];
            }
            cout<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3096
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <complex>
using namespace std;

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

   int tp = 0, hp = 0;
   for(int i = 0; i < n; i++){
       string t, h;
       cin >> t >> h;
       if(t > h){
           tp += 3;
       }
       if(t < h){
           hp += 3;  
       }
       if(t == h){
           tp += 1;
           hp += 1;
       }      
   }
   cout << tp << " " << hp << endl;
}


Measured memory_bytes: 3148
// And Then the GOD Entered..   
#include<bits/stdc++.h>
 using namespace std;
 
typedef long long int ll;
#define endl "\n"
#define fi first
#define sec second 
#define pb push_back
#define test cout<<"debuged\n";
#define INF ll(1e18)
#define MOD 1000000007
#define debug(x) cout<<x<<"\n";
#define pll pair<ll,ll>
#define mp make_pair
#define Minato_Namikaze ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define all(v) v.begin(),v.end()
#define MAX 200015

int main()
{
    Minato_Namikaze
    
    
    ll n;
    cin >> n;
    ll x;
    bool ans = true;
    for(ll i = 0; i < n; ++i)
    {
        cin >> x;
        if(x % 2 == 0 and (x % 3 != 0 and x % 5 != 0))
            ans = false;
    }
    if(ans)
        cout << "APPROVED";
    else
        cout << "DENIED";
    
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
int c[30][12];
int d[30][12];
char in[30];
int pow3[12];
int dp[30][60000];
int u[30];
int main(){
	int a;
	scanf("%d",&a);
	pow3[0]=1;
	for(int i=1;i<12;i++)pow3[i]=pow3[i-1]*3;
	for(int i=0;i<a;i++){
		int p,q;
		scanf("%s%d",in,&q);
		p=in[0]-'A';
		c[p][q]=1;
		u[p]=1;
	}
	int b;scanf("%d",&b);
	for(int i=0;i<30;i++)for(int j=0;j<12;j++)
		d[i][j]=99999999;
	for(int i=0;i<b;i++){
		int p,q,r;
		scanf("%s%d%d",in,&q,&r);
		p=in[0]-'A';
		d[p][q]=min(d[p][q],r);
	}
	for(int i=0;i<30;i++)for(int j=0;j<60000;j++)
		dp[i][j]=99999999;
	dp[0][0]=0;
	for(int i=0;i<26;i++){
		for(int j=0;j<pow3[10];j++){
			for(int k=0;k<10;k++){
				int to=j-j%pow3[k+1]/pow3[k]*pow3[k]+pow3[k]*2;
				dp[i][to]=min(dp[i][to],dp[i][j]+d[i][k]);
				dp[i+1][to]=min(dp[i+1][to],dp[i][j]+d[i][k]);
			}
			int to=j;
			for(int k=0;k<10;k++){
				if(j%pow3[k+1]/pow3[k]==0&&c[i][k]){
					to+=pow3[k];
				}
			}
			dp[i+1][to]=min(dp[i+1][to],dp[i][j]);
		}
	}
	int ret=99999999;
	for(int i=0;i<pow3[10];i++){
		bool ok=true;
		for(int j=0;j<10;j++)if(i%pow3[j+1]/pow3[j]==1)ok=false;
		if(ok)ret=min(ret,dp[26][i]);
	}
	if(ret>9999999)printf("-1\n");
	else printf("%d\n",ret);
}

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

int main(){
    int D, E;
    
    while(cin >> D>> E, D|E) {
        double ans = 1e9;
        for(int i=0; i<D; i++)
            ans = min(ans, abs(E - sqrt(i*i + (D-i)*(D-i))));
        cout << ans << endl;
    }
    
    return 0;
}

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

int main() {

  int a;
  cin >> a;
  
  vector<int> t(a);
  rep(i,a) cin >> t[i];
  int ans = 0;
  
  rep(i,a-2) {
    if(t[i] < t[i+1] && t[i+1] < t[i+2]) ans += 1;
    else if(t[i] > t[i+1] && t[i+1] > t[i+2]) ans += 1;
  }
  
  cout << ans << endl;
  
  
  
}


Measured memory_bytes: 256
#include <stdio.h>
 
int  main(void){
         int h,w,i,j;
          while(1){
          scanf("%d %d",&h,&w);
           if( h==0 && w==0)
              break;
           for(i=1; i<=h; i++){
            for(j=1; j<=w; j++){
              if(i==1 || i==h || j==1 || j==w)
              printf("#");
             else
              printf(".");
             }printf("\n");
            }printf("\n");
           }
            return 0;
}

Measured memory_bytes: 572
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <stdio.h>
#include <string>
#include <bitset>
#include <math.h>
#include <vector>
#include <set>

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

using namespace std;

int main (void){
    int a,b,k;

    cin >> a >> b >> k;

    int cnt = 0;
    for(int i = 100; i >= 1; i--){
        if(a % i == 0 && b % i == 0){
            cnt++;
            if(cnt == k){
                cout << i << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){

     int a,b,ama;

     scanf ("%d %d",&a,&b);

     if(a>b){
          while(b!=0){
               ama=b;
               b=a%ama;
               a=ama;
          } 
     }

     else{
          while(a!=0){
               ama=a;
               a=b%ama;
               b=ama;
          } 
     }
 
     printf ("%d\n",ama);
  
     return 0;

}

Measured memory_bytes: 2708
// Ver19.02
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF 1 << 29
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
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); }

int main()
{
  int r, g, b;
  scanf("%d%d%d", &r, &g, &b);
  if ((r * 100 + g * 10 + b) % 4 == 0)
    puts("YES");
  else
    puts("NO");
  return 0;
}

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

int main() {
    int n, d;
    int ret = 0;
    cin >> n >> d;

    for(int i = 0; i < n; i++) {
        long long p, q;
        cin >> p >> q;

        if(sqrt(p * p + q * q) <= (long long)d) {
            ret++;
        }
    }

    cout << ret << endl;
}

Measured memory_bytes: 3620
n = int(input())

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""

def fac(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
  
list = fac(n)
count = 0
for l in list:
  c = 0
  sum = 0
  while True:
    c += 1
    sum += c
    if l[1]<sum:
      break
    count += 1

if n == 1:
  print(0)
else:
  print(count)

Measured memory_bytes: 9500
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>
 
using namespace std;
 
int main(){
    int X;
    cin >> X;

    int sum = 0;

    while(X >= 500){
        sum += 1000;
        X -= 500;
    }

    while(X >= 5){
        sum += 5;
        X -= 5;
    }

    cout << sum << endl;
    
    return 0;
}

Measured memory_bytes: 256
# Problem: https://atcoder.jp/contests/abc081/tasks/arc086_a
# Python 2nd Try

import sys
from collections import Counter
# import heapq,copy
# from collections import deque
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]


def solver(givenBall, selectKind, ball_num):
    result = 0
    summary_Ball = Counter(ball_num)
    # print("{}".format(list(summary_Ball.values())))
    sortedCount = sorted(list(summary_Ball.values()))
    # print(sortedCount)
    ballAllKind = len(sortedCount)
    changeNumberKind = ballAllKind - selectKind
    if changeNumberKind <= 0:
        result = 0
    else:
        for j in range(0, changeNumberKind, +1):
            result += sortedCount[j]
    return result


if __name__ == "__main__":
    N, K = MI()
    Ai = LI()
    print("{}".format(solver(N, K, Ai)))


Measured memory_bytes: 36504
/*  
*  Sachin Mittal
*/
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define M 998244353
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define rep(i,j,n) for(int i=j;i<n;i++)
#define F first
#define S second
#define lb lower_bound
#define mem0(dp) memset(dp,0,sizeof(dp))
#define mem1(dp) memset(dp,-1,sizeof(dp))
#define pb push_back
#define sz(s) (int)(s.size())
#define debug(x) cout << #x << " = " << x << '\n';


void solve()
{
  int n;
  cin >> n;
  vector<int> a(n);
  int mn = 1e18;
  int sm = 0;
  rep(i, 0, n){
    cin >> a[i];
    sm += a[i];
    mn = min(mn, a[i]);
  }
  sort(all(a));
  reverse(all(a));
  int ans = a[0];
  n -= 2;
  int i = 1;
  while(n){
    ans += min(2LL, n) * a[i];
    n -= min(2LL, n);
    i++;
    // cout << ans << " " << a[i] << " " << n << '\n';
  }
  cout << ans << " ";
}

int32_t main(){
ios_base::sync_with_stdio(false); 
cin.tie(0); cout.tie(0);
int tst = 1;
//cin >> tst;
while(tst--)
{
  solve();
}
}

Measured memory_bytes: 4772
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
#include<limits.h>
#include<float.h>

int main(){
	int n, m, l, r, l_max = INT_MIN, r_min = INT_MAX;
	scanf("%d%d\n", &n, &m);
	for(int i=0; i<m; i++){
		scanf("%d%d\n", &l, &r);
		if(l>l_max) l_max = l;
		if(r<r_min) r_min = r;
	}
	if(l_max <= r_min)
		printf("%d\n", r_min - l_max + 1);
	else
		printf("0\n");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()
#define INF 1<<29

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
int icicles[100005];
int start[100005];		// 相手のつららが落ちれば、自分が成長するつららの番号
int n, l;

ll dfs (int curr )
{
	ll res = (ll)max (0, l - icicles[curr] );

	if (start[curr] == curr ){
		return res;
	} // end if

	res += dfs (start[curr] );

	return res;
}

int main()
{
//	cut here before submit 
//	freopen ("testcase.icicles3", "r", stdin );
	while (scanf ("%d %d", &n, &l ) != EOF ){
		memset (icicles, 0, sizeof (icicles ) );
		memset (start, -1, sizeof (start ) );
		for (int i = 1; i <= n; i++ ){
			scanf ("%d", &icicles[i] );
			if (icicles[i] >= l ) icicles[i] = 0;
		} // end rep
		
		for (int i = 1; i <= n; i++ ){
			if (icicles[i] > icicles[i-1] && icicles[i] > icicles[i+1] ){
				start[i] = i;
			}else{
				vector<P> order (3);
				rep (j, 3 ){
					order[j].first = -icicles[i+j-1];
					order[j].second = i+j-1;
				} // end rep
				sort (ALL (order ) );
				if (order[1].second == i ){
					start[i] = order[0].second;
				} // end if
			} // end if
		} // end for

		for (int i = 1; i <= n; i++ ){
			if (start[i] == -1 ){
				if (dfs (i-1 ) > dfs (i+1 ) ){
					start[i] = i-1;
				}else{
					start[i] = i+1;
				} // end if
			} // end if
		} // end for

		ll res = 0LL;
		for (int i = 1; i <= n; i++ ){
			if (icicles[i] == 0 ) continue;
			ll curr = dfs (i );
			res = max (res, curr );
		} // end for
		printf ("%ld\n", res );

	} // end loop
		
	return 0;
}

Measured memory_bytes: 1984
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF (1LL<<57)
#define MV 200001
#define LMV 21
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define emp emplace
#define whoami(x) cerr<<#x<<" "<<x<<"\n";
#define mp make_pair
#define ins insert
#define sz size

void FLASH() {ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}
void SETF() {cout.ios_base::setf(ios_base::fixed);}
void UNSETF() {cout.ios_base::unsetf(ios_base::fixed);}

typedef long long ll;
typedef long double ld;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<PII, int> PPII;
typedef pair<PLL, ll> PPLL;
typedef map<int, int> MII;

struct h_llint {
  static uint64_t splitmix64(uint64_t x) {    // http://xorshift.di.unimi.it/splitmix64.c
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};

struct h_pair{
  size_t operator()(const PLL&x)const{
    return hash<ll>()(((ll)x.ff)^(((ll)x.ss)<<32));
  }
};

typedef map<ll, ll> MLL;
typedef map<PII, int> MPII;
typedef map<PLL, ll> MPLL;
typedef set<int> SI;
typedef set<ll> SL;
typedef unordered_map<ll, int, h_llint> UMLI;
typedef unordered_map<ll, ll, h_llint> UMLL;
typedef unordered_map<PLL, int, h_pair> UMPI;
typedef unordered_map<PLL, ll, h_pair> UMPL;

int ar[MV];
ll arr[MV];
vector<pair<string, int> > VX;

void solve(int T)
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		string s;
		int t;
		cin>>s>>t;
		VX.pb({s, t});
	}
	string x;
	cin>>x;
	bool mt = 0;
	int tx = 0;
	for(auto u : VX)
	{
		if(mt)
		tx += u.ss;
		if(u.ff == x)
		mt = 1;	
	}
	cout<<tx<<"\n";
	return;
}

int main(void)
{
	FLASH();
	int T;
	T = 1;



	while(T--)
	solve(T);


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  	int i;
    int count = 0;
    string S;
    string T;
    cin >> S;
    cin >> T;
    int think = 0;
    int result = 0;

    for (i = 0; i < 3; i = i + 1){
      		char Si = S.at(i);
  			char Ti = T.at(i);
            if (Si  == 'S'){
                think = 4;
            }
            else if (Si == 'C'){
                think = 5;
            }
            else if (Si == 'R'){
                think = 6;
            } 
            //cout << Si << endl;
            if (Ti == 'S'){
                result = 4;
            }
            else if (Ti == 'C'){
                result = 5;
            }
            else if (Ti == 'R'){
                result = 6;
            } 
     		//cout << Ti << endl;

            if (think - result == 0){
                count++;
            }
			//cout << count << endl;
    }
	cout << count << endl;
}

Measured memory_bytes: 256
/*氏名：保坂優介, 学籍番号：200441141
  概要：*/

#include<stdio.h>

int evaluation(int m, int f, int r)
{
    char Grade;

    if (m == -1 || f == -1)
    {
        Grade = 'F';
    }

    else if (m + f >= 80)
    {
        Grade = 'A';
    }

    else if (m + f >= 65)
    {
        Grade = 'B';
    }
    else if (m + f >= 50)
    {
        Grade = 'C';
    }
    else if (m + f >= 30)
    {
        if (r >= 50)
        {
            Grade = 'C';
        }
        if (r < 50)
        {
            Grade = 'D';
        }
    }
    else
    {
        Grade = 'F';
    }
    return Grade;
}

int main(void)
{
    int i, j, k, m, f, r;
    char Grade;

    scanf("%d %d %d", &m, &f, &r);

    while (m != -1 || f != -1 || r != -1)
    {
        Grade = evaluation(m, f, r);

        printf("%c\n", Grade);

        scanf("%d %d %d", &m, &f, &r);
    }
    return 0;
}


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

using namespace std;

struct pos {
    int x;  // x座標
    int y;  // y座標
};

int main() {
    // 黒マスで表される部分の座標リスト
    const struct pos fig[7][3] = {
        { {1,0}, {0,1}, {1,1} },    // A
        { {0,1}, {0,2}, {0,3} },    // B
        { {1,0}, {2,0}, {3,0} },    // C
        { {0,1}, {-1,1}, {-1,2} },  // D
        { {1,0}, {1,1}, {2,1} },    // E
        { {0,1}, {1,1}, {1,2} },    // F
        { {1,0}, {0,1}, {-1,1} },   // G
    };
    // マップの領域
    char map[12][12];

    while(1) {
        // マップのリフレッシュ
        for(int y = 0; y < 12; y++) {
            for(int x = 0; x < 12; x++) {
                if(1 >= x && x <= 8 && 1 >= y && y <= 8)    map[x][y] = '0';
                else                                        map[x][y] = '2';
            }
        }

        // データ入力
        bool flag = true;
        struct pos fst;
        for(int y = 0; y < 8; y++) {
            for(int x = 0; x < 8; x++) {
                cin >> map[1+x][1+y];
                if(flag && map[1+x][1+y] == '1') { fst.x = x; fst.y = y; flag = false; }
            }
        }
        if(cin.eof()) {break;}
        
        // 走査
        // あらかじめ最初の1の入力箇所を把握しておく事で、1の出現箇所の探索回数を改善している。
        for(int i = 0; i < 7; i++) {
            if(     map[1+fst.x+fig[i][0].x][1+fst.y+fig[i][0].y] == '1'
                &&  map[1+fst.x+fig[i][1].x][1+fst.y+fig[i][1].y] == '1'
                &&  map[1+fst.x+fig[i][2].x][1+fst.y+fig[i][2].y] == '1')
                {
                cout << (char)('A' + i) << endl;
                break;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 2992
using System;

class Program
{
    static void Main(string[] args)
    {
        var s = " " + Console.ReadLine();
        var ans = 0;

        for (int i = 1; i < s.Length; i++)
        {
            if (s[i] == 'R')
            {
                if (s[i - 1] == 'R')
                {
                    ans++;
                }
                else
                {
                    ans = 1;
                }
            }
        }

        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 25952
#include <bits/stdc++.h>
using namespace std;
using ll = long long; // ll は long long　と同じとする。(int64_t)
int main(){
    vector <int> A(3);
    for(int i = 0; i < 3; i++){
        cin >> A[i];
    }
    sort(A.begin() , A.end());
    int a = A[2] - A[0];
    int b = A[2] - A[1];
    if(a % 2 == 0 && b % 2 == 0){
        cout << a / 2 + b / 2 << endl;
    }
    else if(a % 2 == 1 && b % 2 == 1){
        cout << a / 2 + b / 2 + 1 << endl;
    }
    else{
        if(a % 2 == 1){
            cout << (a + 2) / 2 + b / 2 + 1 << endl;
        }
        else{
            cout << a / 2 + (b + 1) / 2 + 1 << endl;
        }
    }
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys
from itertools import accumulate

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 ** 18
MOD = 10 ** 9 + 7

S = input()

if S.count('7'):
    Yes()
else:
    No()


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


void solve(std::string O, std::string E){
    ll n= E.length();
    string ans;
    for(ll i=0; i< n; i++){
        ans.push_back(O.at(i));
        ans.push_back(E.at(i));
    }
    if(O.length()>n) ans.push_back(O[n]);

    cout << ans << endl;
}

int main(){
    std::string O;
    std::cin >> O;
    std::string E;
    std::cin >> E;
    solve(O, E);
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def round_up(a, b):
        return -(-a // b)

    @staticmethod
    def is_prime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


class PriorityQueue:
    def __init__(self, l=[]):
        self.q = l
        heapq.heapify(self.q)
        return

    def push(self, n):
        heapq.heappush(self.q, n)
        return

    def pop(self):
        return heapq.heappop(self.q)


MOD = int(1e09) + 7
INF = int(1e15)


def main():
    # sys.stdin = open("sample.txt")
    n = Scanner.int()
    A = Scanner.map_int()
    B = Scanner.map_int()
    cnt = 0
    for i in range(n):
        if A[i] < B[i]:
            cnt += (B[i] - A[i]) // 2
        else:
            cnt -= (A[i] - B[i])
    print('NYoe s'[cnt >= 0::2])
    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 41596
n = int(input())
t_l = list(map(int, input().split()))
m = int(input())
import copy
for _ in range(m):
    k, v = map(int, input().split())
    tmp_t = copy.deepcopy(t_l)
    tmp_t[k-1] = v
    print(sum(tmp_t))

Measured memory_bytes: 9268
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <ctime>
#define INF 999999999
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=(n);i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define MOD(x) (x%(mod))
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;
/*---------------------------------------------------*/

int main(){
  vector<int> v;
  int n,a;
  cin>>n;
  rep(i,n){
    cin>>a;
    if(i%2==0)v.pb(a);
    else v.insert(v.begin(),a);
  }
  if(n%2==1)reverse(all(v));
  rep(i,v.size())cout<<v[i]<<" ";
  cout<<endl;
}


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

long long cnt;
int l;
int A[1000000];
int N;
vector<int> G;

void insertionSort(int A[], int N, int g){
	int v;
	for(int i=g;i<N;i++){
		v=A[i];
		int j=i-g;
		while(j >=0 && A[j]>v){
			A[j+g]=A[j];
			j=j-g;
			cnt++;
		}
		A[j+g]=v;
	}
}
void shellSort(int A[],int N){
	for(int h=1;;){
		if(h>N){
			break;
		}
		G.push_back(h);
		h = 3*h+1;
	}
	for(int i = G.size()-1;i>=0;i--){
		insertionSort(A,N,G[i]);
	}
}

int main() {
	cin >> N;
	for(int i =0;i<N;i++){
		cin >>A[i];
	}
	cnt = 0;
	shellSort(A,N);
	cout <<G.size()<<endl;
	for(int i=G.size()-1;i>=0;i--){
		cout <<G[i];
		if(i>0){
			cout <<" ";
		}
	}
	cout <<endl;
	printf("%d\n", cnt);
	for(int i = 0 ; i<N ; i++){
		printf("%d\n", A[i]);
	}
	return 0;

}


Measured memory_bytes: 7184
/*  ex4_2
    B30095    */
#include <stdio.h>
#include <math.h>
#define PI 3.14159265359
 
int main(void){
    int hourHndLen, mntHndLen, hour, minute;
    scanf("%d %d %d %d", &hourHndLen, &mntHndLen, &hour, &minute);

    double hourAngle = hour * 30 + minute * 0.5;  // angle between hour hand and 12 'O clock
    double mntAngle = minute * 6;                 // angle between minute hand and 12 'O clock
    double angleDiffRad = fabs((hourAngle - mntAngle) * PI / 180);  // angle between hands in radian
    double distance = sqrt(hourHndLen * hourHndLen + mntHndLen * mntHndLen - 2 * hourHndLen * mntHndLen * cos(angleDiffRad));

    printf("%.9f", distance);
    return 0;
}

Measured memory_bytes: 2540
n, a, b, c, d = gets().split(' ').map(&:to_i)
s = gets().chomp

s = " " + s

# 岩が連続しているかチェック
a.upto([c, d].max) {|i|
	if s[i] == "#" && s[i + 1] == "#"
		puts "No"
		exit
	end
}

if c < d
	puts "Yes"
else
	result = false
	(b - 1).upto(d - 1) {|i|
		result = true if s[i] == "." && s[i + 1] == "." && s[i + 2] == "."
	}
	puts (result ? "Yes" : "No")
end


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

int main() {

    int a, b;
    cin >> a >> b;
    cout << (a + b + 1) / 2 << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
#define first fi
#define second se
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001
const int mxint = 100;

int main(void) {
	int n; cin >> n;
	vector<tuple<string,int,int>> t(n);
	rep(i,n){
		string s;
		int p;
		cin >> s >> p;
		t[i] = make_tuple(s,mxint-p,i+1);
	}
	SORT(t);
	rep(i,n) cout << get<2>(t[i]) << endl;
}




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

int main() {
  ll n, m;
  cin >> n >> m;
  cout << n + m/2 << endl;
}

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

int main(){
  int n,cat;
  cin >> n;
  for(int i = 0; i < n; i++){
    int ans = 0;
    int x,y,w,h;
    cin >> x >> y >> w >> h;
    cin >> cat;
    for(int j = 0; j < cat; j++){
      int cx,cy;
      cin >> cx >> cy;
      if(x <= cx && cx <= x + w &&
	 y <= cy && cy <= y + h)ans++;
    }
    cout << ans << endl;
  }
  return 0;
}

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

ll a, b, c, d;
vector<ll> ans;

int main() {
	cin >> a >> b >> c >> d;
	ans.emplace_back(a * c);
	ans.emplace_back(a * d);
	ans.emplace_back(b * c);
	ans.emplace_back(b * d);
	if (a * b <= 0 || c * d <= 0)
		ans.emplace_back(0);
	sort(ans.rbegin(), ans.rend());
	cout << ans[0] << endl;
}


Measured memory_bytes: 3636
n,Y = map(int, input().split())
Y//=1000

for i in range(n):
    x=Y%5
    x+=i*5

    Y_dash = (Y-x)//5
    n_dash = n-x

    y=2*n_dash-Y_dash
    z=Y_dash-n_dash
    if x>=0 and y>=0 and z>=0:
        break

if x>=0 and y>=0 and z>=0:
    print(z,y,x)
else:
    print(-1,-1,-1)

Measured memory_bytes: 3064
import sys
from collections import Counter

cin = sys.stdin

N = int(cin.readline())
A = list(map(int, cin.readline().split()))

C = Counter(A)
indi = len(C)
last = N - indi
if last % 2==1:
    ans = indi - 1
else:
    ans = indi

print(ans)


Measured memory_bytes: 18720
#include <iostream>
#include <vector>
#include <tuple>
#include <fstream>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#define REP(i, n) for(int i = 0; i < n; i++)
using ll = long long;
using namespace std;


int main() {

    cin.tie(0);
    ios::sync_with_stdio(false);
 
    ll n,k,tmp=0, ans=0;
    cin >> n >> k;

    tmp = min(n%k, k-n%k);

    ans = min(tmp, k);

    cout << ans << endl;
   
}


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

int main(){
	int h1, m1, h2, m2, k;
	scanf("%d%d%d%d%d", &h1, &m1, &h2, &m2, &k);
	h1 = h1 * 60 + m1;
	h2 = h2 * 60 + m2;
	printf("%d\n", h2 - k - h1);
}

Measured memory_bytes: 3836
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define max3(x, y, z) max(x, max(y, z))

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endl
#endif
using namespace std;
int main() {
  string a;
  cin >> a;
  if (a[0] ==a[1] and a[2] == a[3] and a[0] != a[2]) {
    cout << "Yes";
  } else if (a[0] == a[2] and a[1] == a[3] and a[0] != a[1]) {
    cout << "Yes";
  } else if (a[0] == a[3] and a[1] == a[2] and a[0] != a[1]) {
    cout << "Yes";
  } else {
    cout << "No";
  }
}
/*
//よく使うやつ
int N;
cin >> N;
vector<int> list(N);
for (int i = 0; i < N; i++) {
  cin >> list[i];
}
// for文
for (int i = 0; i < N; i++) {
}
//配列
vector<int> vec;
vec.at(i)
vector<vector<int>> vec(10, vector<int>(10));
sort(all(vec));
sort(all(vec), greater<int>());
    //配列の内容表示
dout << "====vecの内容====\n";
for (int i = 0; i < N; i++) dout << vec[i] << endl;
dout << "====ここまで====\n";
*/


Measured memory_bytes: 256
[<AutoOpen>]
module Program

open System

let read f = stdin.ReadLine() |> f
let reada f = stdin.ReadLine().Split() |> Array.map f
let reads f = stdin.ReadLine().Split() |> Array.toList |> List.map f

type Array with
    static member private _BinarySearch<'T when 'T: comparison>
        (comp, array: 'T [], first: Int32, last: Int32, value: 'T) =
        let rec loop left right =
            if left > right then
                left
            else
                let mid = left + ((right - left) >>> 1)
                if comp array.[mid] value then
                    loop (mid + 1) right
                else
                    loop left (mid - 1)
        loop first (last - 1)

    static member LowerBound<'T when 'T: comparison>
        (array: 'T [], first: Int32, last: Int32, value: 'T) =
        Array._BinarySearch((<), array, first, last, value)

    static member UpperBound<'T when 'T: comparison>
        (array: 'T [], first: Int32, last: Int32, value: 'T) =
        Array._BinarySearch((<=), array, first, last, value)

[<EntryPoint>]
let main _ =
    let N = read int
    let LS = reada int |> Array.sort

    let mutable ans = 0
    for i in [N-1 .. -1 .. 2] do
        for j in [i-1 .. -1 .. 1] do
            let high = LS.[i]
            let mid = LS.[j]
            let bound = Array.UpperBound(LS, 0, LS.Length, (high - mid))
            let lows = max 0 (j - bound)
            ans <- ans + lows

    Console.WriteLine(ans)
    0

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

typedef long long ll;
typedef pair<int, int> ii;

const int N = 1e5 + 5; 
vector<int> adj[N]; 
int n, k, a[N], ans; 

int dfs(int u) {
  int ret = 0; 
  for(int v : adj[u]) {
    int x = dfs(v); 
    if(x == k - 1 && u != 1) ++ans; 
    else ret = max(ret, 1 + x); 
  } 
  return ret;
}


int main() {
  scanf("%d %d %d", &n, &k, &a[1]);
  for(int i = 2; i <= n; ++i) {
    scanf("%d", &a[i]); 
    adj[a[i]].push_back(i); 
  }

  ans = a[1] != 1; 
  dfs(1); 

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

Measured memory_bytes: 10752
#include <bits/stdc++.h>
#define FOR(i,n) for(int i=0;i<(int)(n);i++)
#define FORR(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define ZERO(a) memset(a,0,sizeof(a))
using namespace std;
typedef signed long long ll;

void solve(){
 string s,p;
 cin>>s>>p;
 s=s+s;
 FOR(i,s.length()-p.length()){
  if(s.substr(i,p.length())==p){
   cout<<"Yes"<<endl;
   return;
  }
 }
 cout<<"No"<<endl;
}

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

Measured memory_bytes: 1192
use std::io::{stdin, Read};
use std::str::FromStr;

// https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[allow(dead_code)]
fn main() {
    let n = read::<usize>();
    let k = read::<usize>();
    let w = 2 * k + 1;

    let s = read::<String>().chars().collect::<Vec<_>>();
    let mut v = vec![];
    let mut prev = '1';
    let mut c = 0;
    for i in 0..n {
        if prev == s[i] {
            c += 1
        } else {
            v.push(c);
            prev = s[i];
            c = 1
        }
    }
    v.push(c);
    if prev == '0' {
        v.push(0) // 1
    }

    use std::cmp::{max, min};
    let mut ans = 0;
    for i in 0..min(v.len(), w) {
        ans += v[i]
    }

    let mut i = 0;
    let mut candidate = ans;
    while i + w + 1 < v.len() {
        candidate = candidate - v[i] - v[i + 1] + v[i + w] + v[i + w + 1];
        ans = max(ans, candidate);
        i += 2
    }

    println!("{}", ans)
}


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        String s = scanner.next();

        if(n % 2 != 0){
            System.out.println("No");
        } else {
            String x = s.substring(0, (n /2));
            String y = s.substring((n /2), n);
            if(x.equals(y)){
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        }


        scanner.close();

    }
}

Measured memory_bytes: 21844
#include <iostream>

using namespace std;

int H, W;

char field[100][100];

bool check_range(int y, int x){
  return (0 <= x && x < W && 0 <= y && y < H)? true : false;
}

void dfs(int y, int x, char type){
  field[y][x] = '.';

  if(check_range(y, x+1) && type == field[y][x+1]) dfs(y, x+1, type);
  if(check_range(y+1, x) && type == field[y+1][x]) dfs(y+1, x, type);
  if(check_range(y, x-1) && type == field[y][x-1]) dfs(y, x-1, type);
  if(check_range(y-1, x) && type == field[y-1][x]) dfs(y-1, x, type);
}

int main(){

  while(true){
    int count = 0;
    cin >> H >> W;

    if( H == 0 && W == 0 ) break;

    for(int y = 0; y < H; y++){
      for(int x = 0; x < W; x++){
        cin >> field[y][x];
      }
    }

    for(int y = 0; y < H; y++){
      for(int x = 0 ; x < W; x++){
        if(field[y][x] != '.'){
          count++;
          dfs(y, x, field[y][x]);
        }
      }
    }

    cout << count << endl;
  }
  return 0;
}

Measured memory_bytes: 1632
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,move(vector<T>(w))))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,move(vector<T>(w,i))))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
	ll a = in(), b = in(), c = in();
	cout << (b - a == c - b ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int a;
int main(){
    cin>>a;
    if(a<2) cout<<1<<endl;
    else if(a<4)cout<<2<<endl;
    else if(a<8)cout<<4<<endl;
    else if(a<16)cout<<8<<endl;
    else if(a<32)cout<<16<<endl;
    else if(a<64)cout<<32<<endl;
    else cout<<64<<endl;
    return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using str = string;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vs> vvs;
typedef vector<vc> vvc;
typedef vector<vb> vvb;
using P = pair<ll,ll>;
#define REP(i, n) for (ll i = 0; i < (int)(n); i++)
#define RREP(i, n) for (ll i = (int)(n)-1; i > -1 ; i--)
#define IN(T, x) T x;cin >> x;
#define AIN(T, a, n) vector<T> a(n);REP(i, n){cin >> a[i];}
#define A2IN(T1, a, T2, b, n) vector<T1> a(n);vector<T2> b(n);REP(i, n){cin >> a[i] >> b[i];}
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) SORT(a);reverse(ALL(a))
#define pb push_back
#define mp make_pair
#define PF first
#define PS second
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<typename A, size_t N, typename T>void Fill(A (&array)[N], const T &val){fill( (T*)array, (T*)(array+N), val );}
#define OUT(x) cout << x << endl;
#define OUTD(x) cout << fixed << x << endl;
#define BOUT(b) if(b){OUT("Yes");}else{OUT("No");}
const ll MOD = 100000007;
const ll INF = 10e9;
#define PI 3.14159265369;
ll dx[4] = {1,-1,0,0};
ll dy[4] = {0,0,1,-1};
ll ddx[8] = {1,1,1,-1,-1,-1,0,0};
ll ddy[8] = {0,1,-1,0,1,-1,1,-1};

ll dp[30000];

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  IN(ll,N);
  AIN(ll,P,N);
  ll swap = 0;
  REP(i,N){
    if(i+1 != P.at(i))
      swap++;
  }
  if(swap == 0 || swap == 2){
    OUT("YES");
  }
  else{
    OUT("NO");
  }
}



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

string s;
int n, d;
 
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> s;
	REP(i, 0, n) {
		if (s[i] == '(') d++;
		else d--;
		if (d < 0) {
			cout << '(';
			d++;
		}
	}
	cout << s;
	while (d--) cout << ')';
}

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

const int DIM = 20005;

int arr[DIM];

int main(void)
{
    int n;
    cin >> n;
    
    for (int i = 1; i <= n; ++i) {
        int x; cin >> x;
        arr[x] += i;
    }
    
    for (int i = 1; i <= n; ++i)
        cout << i * DIM << " ";
    cout << endl;
    
    for (int i = 1; i <= n; ++i)
        cout << (n - i + 1) * DIM + arr[i] << " ";
    cout << endl;
    
    return 0;
}


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

#define endl "\n"
#define all(x) x.begin(),x.end()
#define pb push_back
#define ff first 
#define ss second 
#define pii pair<int,int>
#define vi vector<int>
#define vc vector<char>
#define vii vector<pii>
#define vvi vector<vi>
#define fori(i,n) for(int i=1;i<=n;++i)
#define forn(i,n) for(int i=0;i<n;++i)
#define sz(x) int(x.size())
#define error(x) cout<<#x<<" "<<x<<endl
#define IOS  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)

const int N=100*1000;
const int mod=1e9+7;

int min3(int a,int b,int c){return min(a,min(b,c));}
int max3(int a,int b,int c){return max(a,max(b,c));}
int min4(int a,int b,int c,int d){return min(min(a,b),min(c,d));}
int max4(int a,int b,int c,int d){return max(max(a,b),max(c,d));}

//#define int int64_t
//int a[N+2];

int32_t  main(){
	IOS;
  int a,b,h;cin>>a>>b>>h;
  cout<<((a+b)*h)/2<<endl;

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
 
int main(){
  int W, H, x, y;
  cin >> W >> H >> x >> y;
  cout << fixed << setprecision(6) << (double)W * H / 2.0 << " ";
  cout << (((x*2==W) && (y*2==H)) ? '1' : '0') << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String s = scan.next();
        System.out.println(pridict(s));
    }
    private String pridict(String s) {
        if ("Sunny".equals(s)) {
            return "Cloudy";
        }
        if ("Cloudy".equals(s)) {
            return "Rainy";
        }
        return "Sunny";
    }
}


Measured memory_bytes: 21844
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    template<typename T>
    vector<T> read_vec(size_t n){
        vector<T> tmp(n);
        for(size_t i = 0; i < n; i++){
            cin >> tmp[i];
        }
        return tmp;
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
};

int main(){
    Stream io;

    int N, K, Q;
    io.read(N, K, Q);
    auto A = io.read_vec<int>(Q);

    vector<int> v(N, K - Q);

    for(int i = 0; i < Q; i++){
        v[A[i] - 1]++;
    }

    for(int i = 0; i < N; i++){
        string ans = "No";
        if(v[i] > 0) ans = "Yes";
        cout << ans << '\n';
    }
    return 0;
}

Measured memory_bytes: 3920
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    //入力・初期化
    int A, B, C;
    cin >> A >> B >> C;
    int cnt;

    //処理
    int abc = A+B+C;
    int all = max(max(A,B),C)*3;
    int add = all-abc;
    if(add%2!=0){
        all += 3;
        add = all-abc;
    }
    cnt = add/2;

    //出力
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

void solve() {
  string s;
  cin >> s;
  bool good = true;
  for(int i = 1; i < s.size(); i++) {
    good &= s[i] != s[i-1];
  }
  if(good) cout << "Good\n";
  else cout << "Bad\n";
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
  /*
  ll t;
  cin >> t;
  for(ll i = 1; i <= t; i++) {
    cout << "Case #" << i << ": ";
    solve();
  }
  */
}


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

#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
#define test cout<<"test"<<endl;
#define fi first
#define se second
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void ans(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
void debug(vector<vector<ll>>v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j]<<" ";cout<<endl;}};
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}
//m.emplace(x,0).fi->second++;

int main(){
  ll i,j,o;
  ll res=0,res1=INF,res2=-INF,buf=0;
  bool judge = true;
  string s;cin>>s;
  cout<<count(ALL(s),'1')<<endl;
  return 0;
}

Measured memory_bytes: 256
while True:
  n,x=map(int,input().split())
  
  if n==x==0 : break
  
  count = 0 
  for i in range(1,n-1) :
    for j in range(i+1,n):
      for k in range(j+1,n+1):
        if i+j+k==x :
          count = count +1

  print(count)   

Measured memory_bytes: 6724