akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
using namespace std;
typedef long long LL;
const int maxn=400+2;
const int mod=1e9+7;
int n;
int a[maxn],b[maxn],posa[maxn],posb[maxn];
int t[maxn][maxn];
LL dp[maxn][maxn][maxn];
void DP(){
	dp[0][0][0]=1;
	for (int k=1;k<=n/3;k++)
		for (int i=1;i<=n;i++)
			for (int j=1;j<=n;j++){
				dp[k][i][j]=(dp[k][i-1][j]+dp[k][i][j-1]-dp[k][i-1][j-1]+mod)%mod;
				if (i<posa[b[j]]&&j<posb[a[i]]) dp[k][i][j]=(dp[k][i][j]+dp[k-1][i-1][j-1]*(3*k-t[i][j]))%mod;
			}
}
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		posa[a[i]]=i;
	}
	for (int i=1;i<=n;i++){
		scanf("%d",&b[i]);
		posb[b[i]]=i;
	}
	for (int i=0;i<=n;i++)
		for (int j=0;j<=n;j++)
			for (int k=1;k<=n;k++)
				if (posa[k]<=i||posb[k]<=j) t[i][j]++;
	DP();
	LL ans=dp[n/3][n][n];
	for (int i=1;i<=n;i++)
		if (i%3) ans=(ans*i)%mod;
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 171264
#include<stdio.h>
#include<string.h>
char ch[101][101];
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++)
	{
		scanf("%s",ch[i]);
	}
	for(int i=0;i<m+2;i++)
	printf("#");
	printf("\n");
	for(int i=0;i<n;i++)
	{
		printf("#%s#\n",ch[i]);
	}
	for(int i=0;i<m+2;i++)
	printf("#");
}

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

#define MAX_W ((ll)1e9)
#define MAX_N (100)
#define MAX_V (1000)
int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);

	int N, W;
	std::cin >> N >> W;
	std::vector<ll> val(N), wei(N), dp(MAX_V*MAX_N+10, (ll)1e12+1);
	for(int i=0; i<N; i++){
		std::cin >> wei[i] >> val[i];
	}

	ll ans = 0;
	dp[0] = 0;
	for(int i=0; i<N; i++){
		for(int v = 1e5; v >= val[i]; v--){
			dp[v] = std::min( dp[v], dp[v - val[i]] + wei[i] );
			if( dp[v] <= W )
				ans = std::max(ans, (ll) v );
		}
	}

	std::cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int[] a=new int[4];
    int count=0;
    boolean flag=true;
	for(int j=0;j<3;j++) {
		int h=sc.nextInt()-1,w=sc.nextInt()-1;
		a[h]++;
		a[w]++;
	}
    for(int i=0;i<4;i++) {
    	if(a[i]>=2)count++;
		if(a[i]>=3 || count>=3) {
			flag=false;
			//break;
		}
		//System.out.println(a[i]);
    }
    if(flag) {
    	System.out.println("YES");
    }else {
    	System.out.println("NO");
    }
  }
}


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

int main() {
  int N;
  int count = 0;
  vector<int> s(200);
  bool isContinued = true;
  
  cin >> N;
  for(int i = 0; i < N; i++) cin >> s[i];
  while(isContinued){
    for(int i = 0; i < N; i++){
      if(s[i] % 2 == 1){
        isContinued = false;
        break;
      }else{
        s[i] /= 2;
      }
    }
    if(isContinued) count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int sum = 0;
		int[] w = new int[n+1];
		int[] count = new int[n+1];
		for(int i=1;i<n+1;i++){
			w[i] = sc.nextInt();
			sum += w[i];
		}
		int min = sum;
		for(int i=1;i<n+1;i++){
			count[i]+=count[i-1]+w[i];
		}
		for(int i=1;i<n+1;i++){
			if(Math.abs(sum-2*count[i])<min) min = Math.abs(sum-2*count[i]); 
		}
		System.out.println(min);
	}
}
				


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

const int N = 1e5 + 10;
int n, a[N], ans;

int main() {
    cin >> n;
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
    }
    sort(a + 1, a + n + 1);
    int lst = 1;
    for (int i = 1; i <= n; i++) {
        if (a[i] != a[lst]) {
            int len = i - 1 - (lst - 1);
            if (len > a[lst]) ans += len - a[lst];
            if (len < a[lst]) ans += len;
            lst = i;
        }
    }
    if (lst <= n) {
        int len = n - (lst - 1);
        if (len > a[lst]) ans += len - a[lst];
        if (len < a[lst]) ans += len;
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 640
n = int(input())
c_str = input()
c_list = list(c_str)

cnt = 0
flag = 1
w_pos = 0
r_pos = 0
range_start = 0
range_end = n

while flag:
    for i in range(range_start, range_end):
        if c_list[i] == "W":
            w_pos = i
            range_start = i
            break
        if i == range_end-1:
            w_pos = range_end-1 
    for j in reversed(range(range_start, range_end)):
      if c_list[j] == "R":
        r_pos = j
        range_end = j
        break
      if j == range_start:
        r_pos = range_start 
    if w_pos < r_pos:
        c_list[w_pos] = "R"
        c_list[r_pos] = "W"
        cnt += 1
    else:
      flag = 0

print(cnt)

Measured memory_bytes: 10792
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

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

int main(){
    int n;
    cin >> n;
    int p[n];
    rep(i, n) cin >> p[i];
    int cnt = 0;
    for(int i = 1; i < n-1; i++){
        vector<int> a;
        for(int j = i-1; j <= i+1; j++){
            a.push_back(p[j]);
        }
        sort(a.begin(), a.end());
        if(p[i] == a[1]) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

W,H,x,y=get_f
if x*2==W and y*2==H
    puts [W*H/2.0,"1"].join(" ")
else
    puts [W*H/2.0,"0"].join(" ")
end

Measured memory_bytes: 1788
#include<stdio.h>
#include<string.h>

int main(void){
    //入力パート
    int N, Q;
    scanf("%d", &N);
    scanf("%d", &Q);
    char S[N+1];
    scanf("%s", S);

    int i,j,k;
    int L[Q][2];
    for(i = 0; i < Q; i++){
        for(j = 0; j < 2; j++){scanf("%d", &L[i][j]);}
    }
  
    int C[strlen(S)];
    C[0] = 0;
    int sum = 0;
    char target[] = "AC";
    char tmp[3];
    for(i = 0; i < strlen(S)-1; i++){
        tmp[0] = S[i]; tmp[1] = S[i+1];
        tmp[2] = '\0';
        if(strcmp(target, tmp) == 0){sum++;}
        C[i+1] = sum;
    }
    
    for(i = 0; i < Q; i++){
        printf("%d\n", C[L[i][1]-1] - C[L[i][0]-1]);
    }
    
    return 0;
    
}


Measured memory_bytes: 2048
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
typedef unsigned int uint;
typedef unsigned long long ull;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
template <class T> using VVV = V<VV<T>>;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;
void yesno(bool ok, string yes = "Yes", string no = "No") {
    if (ok) {
        cout << yes << endl;
    } else {
        cout << no << endl;
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll X;
    cin >> X;
    ll ans = (X / 500) * 1000;
    ans -= X / 500 * 500;
    ans += (X / 5) * 5;
    cout << ans << endl;
}


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

using namespace std;
int main() {
	int N,K;
	cin >> N >> K;
	vector<long long>H(N);
	for (int n = 0;n<N;++n) {
		cin >> H[n];

	}
	sort(H.begin(),H.end());
	long long ans = 0;
	for (int n = 0;n < N - K;++n) {
		ans += H[n];
	}
	cout << ans <<  endl;
	return 0;
}


Measured memory_bytes: 4696
#include <cstdio>
#include <math.h>

int main()
{
    double x1, y1, x2, y2;
    scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
    double x0 = (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1);
    printf("%.8f\n", sqrt(x0));
}


Measured memory_bytes: 2760
import java.util.*;
public class Main{
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int x = scan.nextInt();
        int[] lst = new int[n];
        long ans = 0;
        for(int i = 0; i < n; i++) {
            lst[i] = scan.nextInt();
        }
        for(int i = 0; i < n - 1; i++) {
            if(lst[i] + lst[i + 1] > x){
                ans += lst[i] + lst[i + 1] - x;
                lst[i + 1] = Math.max(0, x - lst[i]);
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 49724
using System;

class Program{
  public static void Main(){
    
    var input = Console.ReadLine().Split();
    long n = long.Parse(input[0]);
    long k = long.Parse(input[1]);
    
    long m = n % k;
    long ans = Math.Min(m,Math.Abs(m-k));
    
    Console.WriteLine(ans);
  }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define pb push_back
#define sz(x) ((int)x.size())

vector<int> h(100005), dp(100005, (1LL<<62));
int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    for(int i = 1; i <= n; i++)
        cin >> h[i];
    dp[1] = 0;
    for(int i = 2; i <= n; i++)
        for(int j = 1; j <= k; j++)
            if(i-j >= 1)
                dp[i] = min(dp[i], llabs(h[i]-h[i-j]) + dp[i-j]);
    
    cout << dp[n] << endl;
}

Measured memory_bytes: 4664
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

cnt = 0
for i in range(n):
	if a[i] >= b[i]:
		cnt += b[i]
	else:
		cnt += a[i]
		b[i] -= a[i]
		if a[i+1] - b[i] >= 0:
			cnt += b[i]
			a[i+1] -= b[i]
		else:
			cnt += a[i+1]
			a[i+1] = 0
print (cnt)

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

int main(int argc, char **argv)
{
	string s;
  cin>>s;
  map <char,int> mp;
  for(ll i=0;i<s.size();i++){
    mp[s[i]]++;
  }
  ll flag=1;
  for(auto itr=mp.begin();itr!=mp.end();++itr){
    if (itr->second%2!=0){
      flag=0;
      break;
    }
  }
  
  if (flag) cout<<"Yes"<<"\n";
  else cout<<"No"<<"\n";
	return 0;
}


Measured memory_bytes: 3632
#include<cstdio>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
using namespace std;
#define MAXN 105
#define MO 1000000007
#define PII pair<int,int>
#define LL long long
int n,m;
bool vis[MAXN][MAXN];
int main()
{
	scanf("%d",&n);
	for(int i=1,j=n-(n&1);i<=j;i++,j--)
		vis[i][j]=vis[j][i]=1;
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++)
			if(!vis[i][j]) m++;
	printf("%d\n",m);
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++)
			if(!vis[i][j])
				printf("%d %d\n",i,j);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    #define ll long long int
    #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int32_t main()
    {
        ll i,j,k,l,n,m,q,t;
        cin>>n>>l;
        string s[n];
        for(i=0;i<n;i++)
        {
            cin>>s[i];
        }
        sort(s,s+n);
        for(i=0;i<n;i++)
        {
            cout<<s[i];
        }


       return 0;
    }






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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define INTMAX 1000000000
using namespace std;
typedef long long ll;
typedef pair<int,int> p;

ll n;

int main(){
  cin >> n;
  ll ans = INTMAX;
  for(ll i=1;i<=sqrt(n);i++){
    if(n%i!=0)continue; //割り切れない時
    ll a = i;
    ll b = (ll) n/i;
    ll tmp = (ll) max(log10(a)+1, log10(b)+1);
    ans = min(ans,tmp);
  }
  cout << ans <<endl;
}


Measured memory_bytes: 640
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn f(s: &[char]) -> bool {
    let m = s.len();
    for i in 0..m {
        if s[i] != s[m - 1 - i] {
            return false;
        }
    }
    true
}

use std::iter::Iterator;

fn main() {
    input! {
        n:usize,
        s:String,
    }

    let s_str = s.as_str();

    let half = (n /2) as usize;

    let mut ans = "";
    if n % 2 == 1 {
        ans = "No";
    }else{
        if &s_str[0..half] == &s_str[half..n]{
            ans = "Yes";
        }else{
            ans = "No";
        }

    }

    println!("{}", ans);

}


Measured memory_bytes: 4352
#include<iostream>
using namespace std;
int main() {
	int N;
	cin >> N;
	bool ans = false;
	for (int i = 0; i < 26; ++i) {
		for (int j = 0; j < 15; ++j) {
			if (i * 4 + j * 7 == N)
				ans = true;
		}
	}
	if (ans)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
R, G, B, N = map(int, input().split())
ans = 0
for x in range(N // R + 1):
	for y in range(N // G + 1):
		if (N - R * x - G * y) % B == 0 and 0 <= (N - R * x - G * y) // B <= N // B:
			ans += 1
print(ans)


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

int main(){
    int size,ans=1;
    string s;
    cin >> size;
    cin >> s;
    for(int i=1; i<size; i++){
       if(s[i]!=s[i-1])ans++;
    }
    cout << ans << endl;
    return 0;   
}

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	long double a, b, c;
	cin >> a >> b >> c;
	c /= a;
	if (c >= a * b / 2){
	c = a * b - c;
	c /= a / 2;
	cout << setprecision(18) << fixed << atan(c / a) * 180 / 3.14159265358979323846;
	return 0;
	}
	c /= b / 2;
	cout << setprecision(18) << fixed << atan(b / c) * 180 / 3.14159265358979323846;
}


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

import sys
import math


debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        # for line in sys.stdin:
        #     lines.append(line)
        lines.append(input())
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    (m1, d1) = [int(e) for e in lines[0].split(" ")]
    (m2, d2) = [int(e) for e in lines[1].split(" ")]

    return (m1, d1, m2, d2)


def solve(m1, d1, m2, d2):


    result = '0'
    if d2 == 1:
        result = '1'

    return  result

def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()
	

Measured memory_bytes: 3064
a = input()

if a[0] == a[1] == a[2]:
    print("No")

elif a[0] == a[1]:
    if a[2] == a[3]:
        print("Yes")
    else:
        print("No")

elif a[0] == a[2]:
    if a[1] == a[3]:
        print("Yes")
    else:
        print("No")

elif a[0] == a[3]:
    if a[1] == a[2]:
        print("Yes")
    else:
        print("No")

else:
    print("No")


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=5005,mod=1e9+7;
int n,a,b;
ll f[N],dp[N][2];
ll qpow(ll a,ll n)
{
    ll ans=1;
    for(;n;n>>=1,a=a*a%mod)if(n&1) ans=ans*a%mod;
    return ans;
}
int main()
{
    scanf("%d%d%d",&n,&a,&b);
    if(a>b) swap(a,b);
    f[1]=1;
    for(int i=1;i<b;i++)
    {
        f[i+1]=(f[i+1]+f[i])%mod;
        for(int j=a;i+j+1<=b;j++)
                f[i+j+1]=(f[i+j+1]+f[i])%mod;
    }
    dp[0][0]=dp[0][1]=1;
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<i+a&&j<=n;j++)
            (dp[j][0]+=dp[i][1])%=mod;
        for(int j=i+1;j<i+b&&j<=n;j++)
            (dp[j][1]+=dp[i][0]*f[j-i+(i==0||j==n)])%=mod;
    }
    ll ans=qpow(2,n);
    ans=(ans-dp[n][0]-dp[n][1])%mod;
    ans=(ans+mod)%mod;
    printf("%lld\n",ans);
}


Measured memory_bytes: 3856
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7;
int n,u,a,b;
ll tmp;
vector<int> vec[4];

int main(){
	cin >> n >> u;
	REP(i,0,n){
		if(!i) cin >> tmp >> b,vec[0].push_back(b);
		else cin >> a >> b,vec[a-tmp].push_back(b);
	}
	
	ll sum[4][110]={};
	REP(i,0,4) sort(vec[i].rbegin(),vec[i].rend());
	REP(i,0,4) REP(j,0,vec[i].size()) sum[i][j+1]=sum[i][j]+vec[i][j];	
	
	ll ma=0;
	REP(i,0,vec[0].size()+1){
		REP(j,0,vec[1].size()+1){
			REP(k,0,vec[2].size()+1){
				REP(l,0,vec[3].size()+1){
					ll pos=i*tmp+j*(tmp+1)+k*(tmp+2)+l*(tmp+3);
					ll v=sum[0][i]+sum[1][j]+sum[2][k]+sum[3][l];
					if(pos<=u) ma=max(ma,v);
				}
			}
		}
	}
	
	cout << ma << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 0; i < n; ++i)
#define rep3(i, a, b) for (ll i = a; i < b; ++i)
#define rep4(i, a, b, c) for (ll i = a; i < b; i += c)
#define erep(n) for (ll i = 0; i <= n; ++i)
#define erep2(i, n) for (ll i = 0; i <= n; ++i)
#define erep3(i, a, b) for (ll i = a; i <= b; ++i)
#define erep4(i, a, b, c) for (ll i = a; i <= b; i += c)
#define rrep(i, a, b) for (ll i = a; i > b; --i)
#define rrep2(i, a, b, c) for (ll i = a; i > b; i -= c)
#define errep(i, a, b) for (ll i = a; i >= b; --i)
#define errep2(i, a, b, c) for (ll i = a; i >= b; i -= c)
#define print(a) cout << a << endl;
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
#define cin(x) cin >> x;
const ll MOD = 1000000007;
const double PI = acos(-1);
inline int newline() { putchar('\n'); return 0; }

int main() {
    ll a, b, h, m;
    cin(a);
    cin(b);
    cin(h);
    cin(m);

    double th = double(h * 60 + m) / 720 * 2 * PI;
    double tm = double(m) / 60 * 2 * PI;

    double x = a * a + b * b - 2 * a * b * cos(abs(th - tm));

    printf("%.20f\n", sqrt(x));
    return 0;
}

Measured memory_bytes: 4256
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
        int m = sc.nextInt();
        long sum = 0;
        long total = 0;
        for (int i = 0; i < m; i++) {
            long d = sc.nextLong();
            long c = sc.nextLong();
            sum = sum + d * c;
            total += c;
        }
        long ret = (long) (total - 1 + Math.ceil((double) sum / 9)) - 1;
        out.println(ret);
        out.close();
    }


    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }


    }

}

Measured memory_bytes: 54672
///AJoy Sarker ,CSE JAHANGIRNAGAR UNIVERSITY 48 Batch

#include<bits/stdc++.h>

using namespace std;
#define SORT(c) sort((c).begin(),(c).end());
#define inf INT_MAX/3
#define pb push_back
#define MP make_pair
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define pi 3.141592653589793
#define in scanf
#define out printf
#define ll long long
#define ull unsigned long long
#define w(x) int x;cin>>x;while(x--)
typedef unsigned long long UL;
template<typename T>inline T  S(T a)
{
    return a*a;
}
template<class T>inline string tostring(T a)
{
    ostringstream os("");
    os << a;
    return os.str();
}
template<typename T>inline ll tolong(T a)
{
    ll res;
    istringstream os(a);
    os>>res;
    return res;
}
template<typename T>inline T gcd(T a, T b)
{
    if (b == 0)return a;
    else return gcd(b, a % b);
}
template<typename T>inline T bigmod(T a, T b, T m)
{
    if (b == 0)return 1;
    else if (b % 2 == 0)return S(bigmod(a, b / 2, m)) % m;
    else return (a % m*bigmod(a, b - 1, m)) % m;
}
int ara[5001];

int main()
{
    ios_base::sync_with_stdio(0);
    int N;
	cin >> N;
	int dif = 0;
	for (int i = 1; i <= N; i++) {
		int p;
		cin >> p;
		if (i != p) dif++;
	}
	cout << (dif == 0 || dif == 2 ? "YES" : "NO") << endl;
    return 0;
}


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

int main(void){
   string N;
   cin>>N;
   long long sum=0;
   for(int i=0;i<N.size();i++){
      sum+=N[i]-'0';
   }
   if(sum%9==0){
      cout<<"Yes"<<endl;
   }else{
      cout<<"No"<<endl;
   }
   return 0;
}


Measured memory_bytes: 3716
C = str(input())

def main():
    list = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
            'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']

    for i in range(len(list)):
        if list[i] == C:
            print(list[i+1])
        else:
            pass

if __name__ == "__main__":
    main()

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

int main() {
  string N;
  int sum = 0;
  cin >> N;
  rep(i, N.size()) sum += N.at(i) - '0';
  if(sum % 9 == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

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

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-9;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int sh[325252], sw[325252];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  int h, w, m;
  cin>>h>>w>>m;
  map<pii, bool> mp;
  REP(i, m){
    int x, y;
    cin>>x>>y;
    --x;--y;
    ++sh[x];
    ++sw[y];
    mp[pii(x, y)]=true;
  }
  vi idh(h);
  iota(ALL(idh), 0);
  sort(ALL(idh), [](int a, int b){
    return sh[a]>sh[b];
  });
  vi th;
  REP(i, h){
    int idx=idh[i];
    if(sh[idx]!=sh[idh[0]]){
      break;
    }
    th.push_back(idx);
  }
  vi idw(w);
  iota(ALL(idw), 0);
  sort(ALL(idw), [](int a, int b){
    return sw[a]>sw[b];
  });
  vi tw;
  REP(i, w){
    int idx=idw[i];
    if(sw[idx]!=sw[idw[0]]){
      break;
    }
    tw.push_back(idx);
  }
  // DEBUG_VEC(th);
  // DEBUG_VEC(tw);
  int ans=sh[th[0]]+sw[tw[0]]-1;
  for(auto& hh : th){
    for(auto& ww : tw){
      bool tmp=mp[pii(hh, ww)];
      if(!tmp){
        ++ans;
        cout<<ans<<'\n';
        return 0;
      }
      CHMAX(ans, sh[hh]+sw[ww]-(mp[pii(hh, ww)] ? 1 : 0));
      // DEBUG(sh[hh]);
      // DEBUG(sw[ww]);
    }
  }
  cout<<ans<<'\n';
  return 0;
}


Measured memory_bytes: 30944
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>

using namespace std;
typedef long long ll;
#define pl pair<ll,ll>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define dbg(x) cout << #x"="<< (x) << endl
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back(a) 
#define in(x) cin >> x;
#define all(x) (x).begin(), (x).end()
#define INF 2147483600
#define fi first
#define se second


int main(){
  int n;cin>>n;
  int ans=0;
  ll temp;
  rep(i,n){
    cin>>temp;
    if(temp%2==0){
      ans+=__builtin_ffs(temp)-1;
    }
  }
  cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# 自分の得意な言語で
# Let's チャレンジ！！

a = input()
b = input()

s = 1001

for i in range(len(a) - len(b)+ 1):
    score = 0
    test = a[i:i+len(b)]
    for j in range(len(b)):
        if test[j] != b[j]:
            score += 1
    s = min(s, score)

print(s)

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

using namespace std;

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

vector<ll> apply(vector<ll> ar, const vector<ll> &perm)
{
	vector<bool> done(ar.size());
	for(int i=0; i<ar.size(); i++)
	{
		if(!done[i])
		{
			int pos = i, store = ar[i];
			while(perm[pos] != i)
			{
				ar[pos] = ar[perm[pos]];
				done[pos] = true;
				pos = perm[pos];
			}
			ar[pos] = store;
			done[pos] = true;
		}
	}
	return ar;
}

vector<ll> bigpow(vector<ll> &base, ll pw)
{
	vector<ll> ret(base.size());
	for(int i=0; i<ret.size(); i++)
		ret[i] = i;

	while(pw)
	{
		if(pw&1)
			ret = apply(ret,base);
		base = apply(base,base);
		pw >>= 1;
	}

	return ret;
}

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(nullptr);
	/* freopen("input.txt", "r", stdin); */

	int n;
	cin >> n;
	vector<ll> d(n-1);
	ll a0, prev, cur;
	cin >> a0;
	prev = a0;
	for(int i=0; i<d.size(); i++)
	{
		cin >> cur;
		d[i] = cur - prev; 
		prev = cur;
	}

	vector<ll> perm(n-1);
	for(int i=1; i<perm.size(); i++)
		perm[i] = i;

	int m, ord;
	ll k;
	cin >> m >> k;
	for(int i=0; i<m; i++)
	{
		cin >> ord;
		swap(perm[ord-1],perm[ord-2]);
	}

	perm = bigpow(perm,k);
	d = apply(d,perm);
	
	cout << a0 << '\n';
	for(auto x: d)
	{
		a0 += x;
		cout << a0 << '\n';
	}

	return 0;
}

Measured memory_bytes: 3456
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#define LLI long long

LLI n,x;

LLI GCD(LLI n, LLI m){
	if(m==0)
		return n;
	else
		return GCD(m,n%m);
}

int main(){

	scanf("%lld%lld",&n,&x);
	printf("%lld\n",3*n-3*GCD(n,x));
	//system("pause");
	return 0;
}

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

using namespace std;

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

  char map[H + 2][W + 2];
  for (int i = 0; i <= H + 1; i++) {
    for (int j = 0; j <= W + 1; j++) {
      if (i == 0 || i == H + 1) {
        map[i][j] = '#';
      } else if (j == 0 || j == W + 1) {
        map[i][j] = '#';
      } else {
        cin >> map[i][j];
      }
    }
  }

  for (int i = 0; i <= H + 1; i++) {
    for (int j = 0; j <= W + 1; j++) {
      cout << map[i][j];
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<complex>
#include<string>
#include<cstring>
using namespace std;
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
#define INF 100000000
#define debug(x) cout<<#x<<": "<<x<<endl

#define all(x) x.begin(),x.end()
typedef pair<int,int> P;
typedef pair<int,P> PP;
int flag;
string s;
int ans;
int main()
{
	cin>>s;
	int t=s.size();
	flag=0;
	rep(i,t)
	{
		if(flag==0)
		{
			if(s[i]=='p')ans--;
		}
		if(flag==1)
		{
			if(s[i]=='g')ans++;
		}
		flag=1-flag;
	}
	
	cout<<ans<<endl;
	return 0;
}

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

#define LL long long

#define FOR(INDEX, START, END) for (LL INDEX = (START); INDEX < (END); ++INDEX)
#define REP(INDEX, COUNT) for (LL INDEX = 0; INDEX < (COUNT); ++INDEX)

#define DIV 1000000007

map<char, LL> counts;

LL tbl[27][27];

LL CalcPattern(char symbol, LL selectNum) {
	if (tbl[symbol - 'a'][selectNum] >= 0) {
		return tbl[symbol - 'a'][selectNum];
	}

	if (selectNum == 0) {
		return 1;
	}

	if (symbol > 'z') {
		return 0;
	}

	LL c = counts[symbol];

	LL total = 0;

	// 選ぶ
	if (c > 0) {
		total += c * CalcPattern(symbol + 1, selectNum - 1);
		total %= DIV;
	}

	// 選ばない
	total += CalcPattern(symbol + 1, selectNum);
	total %= DIV;

	tbl[symbol - 'a'][selectNum] = total;

	return total;
}



int main()
{
	REP(i, 27) {
		REP(j, 27) {
			tbl[i][j] = -1;
		}
	}


	LL N;
	cin >> N;

	REP(i, N) {
		char c;
		cin >> c;
		counts[c]++;
	}

	LL S = counts.size();
	LL ans = 0;
	REP(i, S) {
		ans += CalcPattern('a', i + 1);
		ans %= DIV;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define ll long long
#define ull unsigned long long
#define ld long double
#define zeros(x) x^(x-1)&x
#define pii pair<ll,ll>
#define cd complex<double>
#define dbg(x) cerr<<x<<endl;
#define Nmax 500005
using namespace std;

ll n, mx, A, B, v[Nmax];

int main()
{
    cin >> n;
    for (int i=1;i<=n;i++){
        cin >> v[i];
        mx = max(mx, v[i]);
    }
    for (int i=1;i<=n;i++){
        if (v[i] == mx){
            B++;
        }
        else if (v[i] == mx-1) A++;
        else{
            cout << "No\n";
            return 0;
        }
    }
    if (A==0 && B == mx + 1){
        cout << "Yes\n";
        return 0;
    }
    if (B==1){
        cout << "No\n";
        return 0;
    }
    if (mx > A && mx <= A + B / 2) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) {}
    void init(int n) { par.assign(n, -1);}
    
    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};
main(){
    int N,M;
    cin >> N >> M;
    vector<P> V(M);
    rep(i,0,M){
        cin >> V[i].first >> V[i].second;
        V[i].first--, V[i].second--;
    }
    int cnt = 0;
    rep(i,0,M){
        UnionFind uf(N);
        rep(j,0,M){
            if(i == j)continue;
            uf.merge(V[j].first, V[j].second);
        }
        if(uf.size(0) != N)cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);let input_i=-1;const tn=():number=>{input_i++;return Number(input[input_i])};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{input_i++;return String(input[input_i])};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const asc=(ar:number[])=>{const t=[...ar];return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{const t=[...ar];return t.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length-1;i+=2){if(eval(a+op+arr[i])){return arr[i+1]}}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};const deduplicate=(a:any[]):any[]=>{return Array.from(new Set(a))};
const main=()=>{
  let [w,h,n]=tnn(3)
  let ar=new Array(h)
  let x=0,y=0
  for(let i=0;i<h;i++){
    ar[i]=new Array(w)
    ar[i].fill(0)
  }
  for(let i=0;i<n;i++){
    let [xi,yi,a]=tnn(3)
    if(a==1){
      for(let j=0;j<h;j++){
        for(let k=0;k<xi;k++){
          ar[j][k]=1
        }
      }
    }else if(a==2){
      for(let j=0;j<h;j++){
        for(let k=xi;k<w;k++){
          ar[j][k]=1
        }
      }
    }else if(a==3){
      for(let j=0;j<w;j++){
        for(let k=0;k<yi;k++){
          ar[k][j]=1
        }
      }
    }else if(a==4){
      for(let j=0;j<w;j++){
        for(let k=yi;k<h;k++){
          ar[k][j]=1
        }
      }
    }
  }
  let c=0
  for(let i=0;i<h;i++){
    for(let j=0;j<w;j++){
      if(ar[i][j]==0)c++
    }
  }
  to(c)
}
main()


Measured memory_bytes: 7628
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <tuple>
#include <set>
#include <queue>
#include <numeric>
using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;

	if (k > n * (n - 1) / 2 - n + 1){
		cout << "-1\n";
		return 0;
	}

	vector<pair<int, int>> edges;
	for (int i = 0; i < n - 1; ++i) {
		edges.push_back(make_pair(1, 2 + i));
	}
	int cnt = n * (n - 1) / 2 - n + 1;
	for (int i = 2; i < n && cnt > k; ++i)
		for (int j = i + 1; j <= n && cnt > k; ++j) {
			--cnt;
			edges.push_back(make_pair(i, j));
		}
	cout << edges.size() << endl;
	for (auto p : edges)
		cout << p.first << " " << p.second << endl;
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n;
	set<long long>Se;
	long long num;
	vector<long long>Vec;
	scanf("%d", &n);
	for (int i = 0; i != n; ++i) {
		cin>>num;
		if (Se.find(num) != Se.end()) {
			Vec.push_back(num);
			Se.erase(num);
		}
		else {
			Se.insert(num);
		}
	}
	sort(Vec.begin(), Vec.end());
	if (Vec.size() < 2)printf("0\n");
	else {
		cout << Vec[Vec.size() - 1] * Vec[Vec.size() - 2] << endl;
	}

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

Measured memory_bytes: 4992
gets;
nums = gets.split(" ").map(&:to_i);
prod = 1;
if nums.find {|n| n === 0} then
	puts "0";
    exit;  
end
nums.each { |n| 
  prod = prod * n ; 
  if prod > 10**18 then 
	puts "-1";
    exit;
  end
};
puts prod;

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

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

#define sz(c) int((c).size())
#define all(c) (c).begin(), (c).end()
#define pb push_back

#define INF int(1e9)
#define EPS 1e-9
#define MOD 13

int addMod(int a, int b, int mod) {
    return ((a % mod) + (b % mod)) % mod;
}

int multiplyMod(int a, int b) {
	return (1LL * (a % MOD) * (b % MOD)) % MOD;
}

int modPow(int a, int n) {
	int res = 1;
	while(n) {
		if(n & 1)
			res = multiplyMod(res, a);
		a = multiplyMod(a, a);
		n >>= 1;
	}
	return res;
}

const int LIMIT = 100000;
int n;
string s;
int memo[LIMIT][13];

int power[LIMIT];

int dp(int idx, int rem) {
	if(idx == n) {
		if(rem == 5)
			return 1;
		return 0;
	}
	if(memo[idx][rem] != -1) return memo[idx][rem];
	int ans = 0;
	if(s[idx] == '?' ) {
		for(int i = 0; i <= 9; i++) {
			int newRem = addMod(rem, multiplyMod(i, power[n - idx - 1]), 13);
			int res = dp(idx + 1, newRem);
			ans = addMod(ans, res, int(1e9 + 7));
		}
	} else {
		int i = s[idx] - '0';
		int newRem = addMod(rem, multiplyMod(i, power[n - idx - 1]), 13);
		int res = dp(idx + 1, newRem);
		ans = addMod(ans, res, int(1e9 + 7));
	}
	return memo[idx][rem] = ans;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cin >> s;
	n = s.length();
	power[0] = 1;
	for(int i = 1; i < n; i++) {
		power[i] = multiplyMod(10, power[i - 1]);
	}
	memset(memo, -1, sizeof memo);
	cout << dp(0, 0) << '\n';
	return 0;
}


Measured memory_bytes: 13776
#include <iostream>

using namespace std;

const int MAX_N = 50 + 10;

int main(int argc, char const *argv[])
{
    int n, p[MAX_N];

    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> p[i];
    }
    int cnt = 0;
    for (int i = 0; i < n; ++i) {
        if (p[i]==i+1) continue;
        cnt++;
    }
    if (cnt <= 2) {
        cout << "YES" << endl;
    }
    else cout << "NO" << endl;
    return 0;
}

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

using namespace std;

typedef long long llint;
typedef long double ld;
#define inf 1e18

priority_queue<llint,vector<llint>,greater<llint>> que;
priority_queue<llint> q;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

string s;


void solve(){
	cin >> s;
	bool f=false;
	for(char c:s){
		if(c=='7'){
			f=true;
			break;
		}
	}
	if(f)cout << "Yes";
	else cout << "No";
	cout << endl;


}

int main(int argc, char *argv[]) {
  solve();
  return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <cmath>
#include <cstdlib>

using namespace std;

int main() {
	int n;
	int a[150];
	double ave;
	double sum = 0;
	int tmp = 0;

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

	ave = sum / n;

	for (int i = 0; i < n; i++) {
		if (fabs(ave - a[i]) < fabs(ave - a[tmp]))
			tmp = i;
	}

	cout << tmp << endl;
	return 0;
}

Measured memory_bytes: 256
import math

A, B, H, M = map(int, input().split())
# K=int(input())

ans = A ** 2 + B ** 2 - 2 * A * B * math.cos(+(M / 60 * 2 * math.pi) - ((H / 12+M/60/12) * 2 * math.pi))
print(ans ** 0.5)

Measured memory_bytes: 9500
from sys import stderr, setrecursionlimit
from functools import reduce
from operator import add
setrecursionlimit(2147483647)
def f(n=1):
    if n == 1:
        return [int(i) for i in input().split()]
    res = []
    for i in range(n):
        res.append([int(j) for j in input().split()])
    return res
def debug(*x, sep=" ", end="\n"):
    for item in x:
        stderr.write(str(item))
        stderr.write(sep)
    stderr.write(end)

rgb = int("".join(input().split()))
print("NO" if rgb%4 else "YES")


Measured memory_bytes: 4196
text = input()

def checkHitachi(text):
  # odd length
  if (len(text)%2 != 0): 
    return 'No'
  # even length
  for i in range(0, len(text)-1, 2):
    if (text[i:i+2]!='hi'):
      return 'No'

  return 'Yes'
 
print(checkHitachi(text))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V) { os << "[ "; 
	for(auto v:V)os << v << " "; return os << "]";
}
template<class T> ostream& operator<<(ostream &os, set<T> S){ os << "{ "; 
	for(auto s:S) os<<s<<" ";  return os<<"}"; 
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
	return os<<"("<<P.first<<","<< P.second << ")";
}
template<class L, class R> ostream& operator<<(ostream &os, map<L,R> M) {
	os<<"{ ";for(auto m:M)os<<"("<<m.F<<":"<<m.S<<")";
	return os<<"}";
}
#define cerr cout
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
#define ll long long
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define I insert 
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define For(i,n) for(int i=0;i<(int)n;++i)
#define Rev(i,n) for(int i=(int)n-1;i>=0;--i)
#define Rep(i,n) for(int i=1;i<=(int)n;++i)
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpii;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)


int main(){
	fio; cout<<fixed<<setprecision(25);	
	ll x; cin >> x;
	ll m = x/500;
	ll ans = m*1000ll;
	x %= 500;
	ans += (x/5)*5;
	cout << ans << endl;








	return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define REVERSE(x) reverse((x).begin(), (x).end())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << '\n'
#define endl '\n'

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-10;

constexpr int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
constexpr int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

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

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

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

    lint A, B, X;
    cin >> A >> B >> X;

    double a = A;
    double b = B;
    double x = X;

    double ok, ng;

    if(X * 2LL == A * A * B){
        ok = asin(b / sqrt(a * a + b * b));
    }else if(X * 2LL < A * A * B){
        double z = (x * 2.0) / (a * b);
        ok = atan(b / z);
    }else{
        double y = (b * 2.0) - ((x * 2.0) / (a * a));
        ok = atan(y / a);
    }

    double ans = ok / M_PI * 180.0;

    cout << ans << endl;

    cout << flush;

    return 0;
}

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

#define NREP() for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define IPT(x) ll t; cin >> t; x.push_back(t);
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<string> vvs;

const static ll MOD = 1e9 + 7;

int main() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;

    bool turn = true;
    while (a > 0 && c > 0) {
        if (turn) {
            c -= b;
        } else {
            a -= d;
        }
        turn = !turn;
    }

    if (a > 0) {
        MSG("Yes")
    } else {
        MSG("No")
    }

}


Measured memory_bytes: 3620
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
ll X;
// a>bと仮定

ll MAX_A() {
  ll i = 1;
  while(pow(i,5)-pow(i-1, 5)<=X) i++;
  return i;
}

int main() {
  INCANT;
  cin >> X;
  ll _A = MAX_A();
  for (ll i=_A; i>=-_A; i--) {
    for (ll j=_A; j>=-_A; j--) {
      if (pow(i, 5)-pow(j, 5)==X) {
        cout << i << ' ' << j << "\n";
        return 0;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 4116
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long a,b,c,d,ans,r,s,t;
  cin>>a>>b>>c>>d;
  ans=(b-a+1);
  s=min(c,d);
  t=max(c,d);
  r=t%s;
  while(r>0){
    t=s;
    s=r;
    r=t%s;
  }
  t=c*d/s;
  ans=ans-(b/c-(a-1)/c+b/d-(a-1)/d-b/t+(a-1)/t);
  cout<<ans;
}

Measured memory_bytes: 256