akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
#include <cstring>
using namespace std;

using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

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

    int N;
    ll K;
    cin >> N >> K;
    vector<ll> A(N);
    for(int i = 0; i < N; ++i)  cin >> A[i];
    ll X = 0;
    for(int d = 40; d >= 0; --d){
        if((1LL << d) > K)  continue;
        int zero = 0, one = 0;
        for(int i = 0; i < N; ++i){
            if(A[i] >> d & 1)   ++one;
            else    ++zero;
        }
        if(zero > one){
            X += 1LL << d;
            K -= 1LL << d;
        }
    }
    ll ans = 0;
    for(int i = 0; i < N; ++i)  ans += X ^ A[i];
    cout << ans << endl;
}

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

const int limit = 100010;
using edge = struct {int to; long long cost;};

vector<edge> tree[limit];
long long depth[limit];

void dfs(int v, int p, long long d){
  depth[v] = d;
  for (auto &e: tree[v]){
    if (e.to == p) continue;
    dfs(e.to, v, d + e.cost);
  }
}

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

  for (int i=0; i<n-1; ++i){
    int a, b, c;
    cin >> a >> b >> c;
    a--;b--;
    tree[a].push_back({b,c});
    tree[b].push_back({a,c});
  }

  int q, k;
  cin >> q >> k;
  k--;


  dfs(k, -1, 0);
  for (int i=0; i < q; ++i){
    int x, y;
    cin >> x >> y;
    x--;y--;
    cout << depth[x] + depth[y] << endl;
  }

  return 0;
}


Measured memory_bytes: 14336
#include <iostream>

using namespace std;

void solve()
{
	char F11;
	char Field[13][13];
	while(cin >> F11)
	{
		for(int i = 0; i < 13; ++i)
		{
			for(int j = 0; j < 13; ++j)
			{
				Field[i][j] = '2';
			}
		}
		Field[1][1] = F11;
		for(int i = 2; i < 9; ++i)
		{
			cin >> Field[1][i];
		}
		for(int i = 2; i < 9; ++i)
		{
			for(int j = 1; j < 9; ++j)
			{
				cin >> Field[i][j];
			}
		}
		for(int i = 1; i < 9; ++i)
		{
			for(int j = 1; j < 9; ++j)
			{
				if(Field[i][j] == '1')
				{
					if(Field[i][j + 1] == '1' && Field[i + 1][j] == '1' && Field[i + 1][j + 1] == '1')
					{
						cout << "A" << endl;
					}
					else if(Field[i + 1][j] == '1' && Field[i + 2][j] == '1' && Field[i + 3][j] == '1')
					{
						cout << "B" << endl;
					}
					else if(Field[i][j + 1] == '1' && Field[i][j + 2] == '1' && Field[i][j + 3] == '1')
					{
						cout << "C" << endl;
					}
					else if(Field[i + 1][j - 1] == '1' && Field[i + 1][j] == '1' && Field[i + 2][j - 1] == '1')
					{
						cout << "D" << endl;
					}
					else if(Field[i][j + 1] == '1' && Field[i + 1][j + 1] == '1' && Field[i + 1][j + 2] == '1')
					{
						cout << "E" << endl;
					}
					else if(Field[i + 1][j] == '1' && Field[i + 1][j + 1] == '1' && Field[i + 2][j + 1] == '1')
					{
						cout << "F" << endl;
					}
					else if(Field[i][j + 1] == '1' && Field[i + 1][j - 1] == '1' && Field[i + 1][j] == '1')
					{
						cout << "G" << endl;
					}
				}
			}
		}
	}
}

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

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

using namespace std;

using ll = long long;

constexpr char newl = '\n';

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

    int n;
    cin >> n;

    vector<int> dp(n + 1, 0);
    for (int i = 1; i <= n; i++) {
        dp[i] = dp[i % __builtin_popcount(i)] + 1;
    }

    string s;
    cin >> s;

    int cnt = 0;
    for (int i = 0; i < n; i++) {
        cnt += (s[i] == '1');
    }

    vector<int> ans(n, 0);

    {
        int all_mod1 = 0, d = 1 % (cnt + 1);
        for (int i = n - 1; i >= 0; i--) {
            if (s[i] == '1') (all_mod1 += d) %= cnt + 1;
            d = d * 2 % (cnt + 1);
        }

        d = 1 % (cnt + 1);
        for (int i = n - 1; i >= 0; i--) {
            if (s[i] == '0') ans[i] = dp[(all_mod1 + d) % (cnt + 1)] + 1;
            d = d * 2 % (cnt + 1);
        }
    }

    if (cnt > 1) {
        int all_mod1 = 0, d = 1 % (cnt - 1);
        for (int i = n - 1; i >= 0; i--) {
            if (s[i] == '1') (all_mod1 += d) %= cnt - 1;
            d = d * 2 % (cnt - 1);
        }

        d = 1 % (cnt - 1);
        for (int i = n - 1; i >= 0; i--) {
            if (s[i] == '1') ans[i] = dp[(all_mod1 + cnt - 1 - d) % (cnt - 1)] + 1;
            d = d * 2 % (cnt - 1);
        }
    }

    for (int i = 0; i < n; i++) {
        cout << ans[i] << newl;
    }

    return 0;
}

Measured memory_bytes: 5112
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define prtd(var, i) cout << fixed << setprecision(i) << var << endl;
#define ll long long
using namespace std;
#define INF 100000

int main(){
    int ans = 0;
    int MAX = 0;
    rep(i, 5){
        int t;
        cin >> t;
        int am = 10 - t % 10;
        if(am == 10) am = 0;
        ans += t + am;
        MAX = max(MAX, am);
    }
    cout << ans - MAX << endl;
    
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class QuestionE
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数の入力
            long n = long.Parse(Console.ReadLine());

            var min = int.MaxValue;

            for (long i = 1; i * i <= n; i++) {
                if(n % i != 0) {
                    continue;
                }

                var a = i.ToString().Length;
                var b = (n / i).ToString().Length;

                var c = Math.Max(a, b);
                min = Math.Min(min, c);
            }

            Console.WriteLine(min);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <string>
#include <cstdio>

using namespace std;

int main(){
    int n,a,b;
    scanf("%d",&n);scanf("%d",&a);scanf("%d",&b);
    char s[100000];
    scanf("%s",s);

    int count = 0;
    int bcount = 0;
    for(int i=0;i<n;i++){
        if(a+b <= count){printf("No\n");continue;}
        if(s[i] == 'c'){
            printf("No\n");
            continue;
        }else if(s[i] == 'a' && a+b > count){
            count++;
            printf("Yes\n");
            continue;
        }else if(s[i] == 'b' && bcount < b && a+b > count){
            bcount++;
            count++;
            printf("Yes\n");
            continue;
        }else{
            printf("No\n");
        }
    }
}

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

int main(void) {
    int n, ai, min = 1000000, max = -1000000;
    long int sum = 0;
    scanf("%d", &n);
    for(int i = 0; i < n; i++) {
        scanf("%d", &ai);
        if(ai < min) min = ai;
        if(ai > max) max = ai;
        sum += ai;
    }

    printf("%d %d %ld\n", min, max, sum);
    return 0;
}



Measured memory_bytes: 2056
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int N;
  cin >> N;
  int d[N];
  for(int i=0;i<N;i++){
    cin >> d[i];
  }
  sort(d, d+N);
  if(d[N/2-1]==d[N/2]){
    cout << 0;
  }else{
    cout << -d[N/2-1]+d[N/2];
  }
}
    


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>

using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
const ll MOD = 1000000007;
const int MAX = 100000;

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

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

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
//最大公約数
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }


int main(){
    int N; cin >> N;
    vector<int> C(N);
    vector<int> S(N);
    vector<int> F(N);
    for(int i=1;i<N;i++){
        cin >> C[i] >> S[i] >> F[i];
    }
    for(int i=1;i<N;i++){
        ll t=S[i]+C[i];
        for(int j=i+1;j<N;j++){
            if(t<=S[j]){
                t = S[j];
            }else{
                int tmp = t%F[j];
                if(tmp!=0){
                    t = t+F[j]-tmp;
                }
            }
            t += C[j];
        }
        cout << t << endl;
    }
    cout << 0 << endl;
    return 0;
}


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

#define MAX 100000

int N, M, x = 0, ans = 0;
struct bridge{
    int a, b;
    bridge(){}
    bridge(int a, int b): a(a), b(b){}
    bool operator < (const bridge &B) const{
        return b < B.b;
    }
};
bridge E[MAX];

int main(){
    cin >> N >> M;
    for(int i = 0; i < M; i++){
        int a, b;
        cin >> a >> b;
        E[i] = bridge(a, b);
    }
    sort(E, E + M);
    for(int i = 0; i < M; i++){
        if(E[i].a <= x) continue;
        ans++;
        x = E[i].b - 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include <string.h>
int main(void)
{
 char b[100];
 scanf("%s",&b);
 if(!strcmp(b,"A"))
   printf("T");
 else if(!strcmp(b,"C"))
   printf("G");
 else if(!strcmp(b,"G"))
   printf("C");
 else
   printf("A");
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define For(i,a,b) for(int (i)=(a); (i)<(b); (i)++)

int cnt1;

void printvector3(vector<int> v) {
    REP(i,v.size()-1) {
        cout << v[i] << " ";
    }
    cout << v[v.size()-1] << endl;
}

void selectionsort(vector<int> &v) {
    int N = v.size();
    REP(i,N) {
        int minj = i;
        For(j,i,N) {
            if (v[j] < v[minj]) {
                minj = j;
            }
        }
        if (v[i] != v[minj]) {
            cnt1++;
            int temp = v[i];
            v[i] = v[minj];
            v[minj] = temp;
        }
    }
}

int main() {
    int N;
    cin >> N;
    vector<int> v;
    REP(i,N) {
        int j;
        cin >> j;
        v.push_back(j);
    }
    selectionsort(v);
    printvector3(v);
    cout << cnt1 << endl;
    return 0;
}

Measured memory_bytes: 1220
n=int(input())
s=input()
ss=[i for i in s]
w=0
for i in range(1,n):
    #print(i)
    a=set(ss[:i])
    b=set(ss[i:])

    v=0
    for aa in a:
        #print(a)
        #print(b)
        if aa in b:
            v+=1
            #a.remove(aa)
            #b.remove(aa)
            #aは更新されるの？ーy
            #ただ前のaaが消された時次にforで取り出されるのは何？
            #また同じ文字でもaaでない時は消されない
        #print(v)
    if v>w:
        w=v
print(w)


Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main()
{
    int unit;
    cin >> unit;
    int n=unit%10;
    if(n==2 || n==4 || n==5 || n==7 || n==9){
        cout << "hon";
    }
    if(n==0 || n==1 || n==6 || n==8){
        cout << "pon";
    }
    if(n==3)
        cout << "bon";
    return 0;
}


Measured memory_bytes: 3104
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
#define INF 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
using namespace std;
using P = pair<int, int>;
using ll = long long;
int main(){
    ll n;
    cin>>n;
    int ans=INF;
    for(ll i=1;i<=sqrt(n);i++){
        if(n%i==0){
            ll a=i,b=n/i;
            ans=min(ans,(int)max(to_string(a).size(),to_string(b).size()));
        }
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 256
# https://atcoder.jp/contests/dp/tasks/dp_l

'''
dp[i,j] ... dequeに[i,j]が残っているときに行動するプレイヤーのスコアの最大
dp[i,j] = max(a[i-1]-dp[i-1,j], a[j+1]-dp[i,j+1]) #これじゃgreedyと同じじゃん

dp[i,j] ... dequeに[i,j)が残っているときにその状態からスタートするプレイヤーが達成できるスコアの最大 (区間を伸ばしていく感じ)

初期値 dp[i,i]==0

dp[i,j]=max(a[i]-dp[i+1,j], a[j-1]-dp[i,j-1])
'''
import sys
sys.setrecursionlimit(1 << 25)
readline = sys.stdin.buffer.readline
read = sys.stdin.readline  # 文字列読み込む時はこっち

import numpy as np
from functools import partial
array = partial(np.array, dtype=np.int64)
zeros = partial(np.zeros, dtype=np.int64)
full = partial(np.full, dtype=np.int64)


def a_int(): return int(readline())


def ints(): return np.fromstring(readline(), sep=' ', dtype=np.int64)


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import

N = a_int()
A = ints()


from numba import njit


@njit('(i8,i8[:])', cache=True)
def solve(N, A):
    dp = np.zeros((N + 1, N + 1), dtype=np.int64)
    for i in range(N - 1, -1, -1):
        for j in range(i + 1, N + 1):
            dp[i, j] = max(A[i] - dp[i + 1, j], A[j - 1] - dp[i, j - 1])
    print(dp[0, N])
    # print(*dp, sep='\n')


solve(N, A)


Measured memory_bytes: 181276
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] ans = new int[n];
        for (int i = 0; i < n; i++) {
            int a = sc.nextInt();
            ans[a-1] = i+1;
        }
        for (int i = 0; i < n; i++) {
            System.out.print(ans[i]+" ");
        }
    }
}

Measured memory_bytes: 62820
#include<iostream>
using namespace std;
long long gcd(long long a,long long b){
  return b?gcd(b,a%b):a;
}
long long lcm(long long m,long long n){
  return m/gcd(m,n)*n;
}

int main(){
  int a,p;
  long long count[3];
  while(true){
    cin>>a>>p;
    if(!a&&!p)break;
    for(int i=0;i<3;i++){
      if(i)cin>>a>>p;
      int k=1;
      count[i] = 0;
      do{
	k*=a;
	k%=p;
	count[i]++;
      }while(k!=1);
    }
    cout<<lcm(lcm(count[0],count[1]),count[2])<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
N,K = map(int,input().split())
arr = [int(i) for i in input().split()]
maxnum = max(arr)
def gcd(x,y):
    if x%y == 0:
        return y
    else:
        return gcd(y,x%y)

ok = False
num = gcd(max(arr[0:2]),min(arr[0:2]))
for i in arr[2:]:
    if num < i:
        num = gcd(i,num)
    else:
        num = gcd(num,i)

if K <= maxnum and (K-maxnum)%num == 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

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

#ifdef LOCAL
#include <debug.hpp>
#else
#define debug(...) void()
#endif

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> cnt(26, (int)1e9);
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    vector<int> ncnt(26, 0);
    for (auto&& c : s) {
      ncnt[c - 'a']++;
    }
    for (int i = 0; i < 26; i++) {
      cnt[i] = min(cnt[i], ncnt[i]);
    }
  }
  string ans = "";
  for (int i = 0; i < 26; i++) {
    while (cnt[i]--) {
      ans += char('a' + i);
    }
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3592
from math import factorial

MOD = 10 ** 9 + 7

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

f = {}
def fact(x):
    if x in f:
        return f[x]
    ans = factorial(x)
    f[x] = ans
    return ans

F = {}
def fact_power(a, b):
    if (a, b) in F:
        return F[(a, b)]
    if b == 0:
        ans = 1
    elif b % 2 == 0:
        d = fact_power(a, b // 2)
        ans = (d * d) % MOD
    else:
        ans = (fact(a) * fact_power(a, b - 1)) % MOD
    F[(a, b)] = ans
    return ans

P = {}
def perm(a, b):
    if b == 0 or a < b:
        return 0
    if (a, b) in P:
        return P[(a, b)]
    ans = fact_power(a - 1, 1) * fact_power(a - b, MOD - 2) * fact_power(b - 1, MOD - 2) % MOD
    P[(a, b)] = ans
    return ans

if N == K:
    print(1)
    for i in range(K - 1):
        print(0)
else:
    for i in range(1, K + 1):
        B = perm(K, i)
        R = perm(N - K, i - 1) + perm(N - K, i) * 2 + perm(N - K, i + 1)
        print(B * R % MOD)


Measured memory_bytes: 94172
#include<ctime>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath> 
#include<cstring> 
#include<cassert>
#include<string>
#include<sstream>
#include<fstream>
#include<deque>
#include<queue>
#include<vector>
#include<map>
#include<list>
#include<stack>
#include<set>
#include<bitset>
#include<iomanip>
#include<utility>
#include<functional>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cwchar>
#include<cwctype>
#include<exception>
#include<locale>
#include<numeric>
#include<new>
#include<stdexcept>
#include<limits>
using namespace std;

#define ll long long
#define INF 1e9
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
#define pii pair<int,int>

const int maxn=55;
int n,odd,even,p;
ll ans,sum;
int a[maxn];
ll C[maxn][maxn];

ll quick_pow(int power){
	ll res=1;
	ll base=2;
	while(power){
		if(power&1)res*=base;
		base*=base;
		power>>=1;
	}
	return res;
}

int main(){
	cin>>n>>p;
	rep(i,n+1)C[i][0]=1;
	REP(i,n)REP(j,n)
	C[i][j]=C[i-1][j]+C[i-1][j-1];
	rep(i,n){
		cin>>a[i];
		sum+=a[i];
		if(a[i]%2==0)even++;
		else odd++;
	}
	if(p==0){
		ll sum=0;
		for(int i=0;i<=odd;i+=2)sum+=C[odd][i];
		ans=quick_pow(even)*sum;
	}
	else {
		ll sum=0;
		for(int i=1;i<=odd;i+=2)sum+=C[odd][i];
		ans=quick_pow(even)*sum;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
long long a,b,c,N,i;
a=1;
b=2;
  cin>>N;
  for(i=1;i<N;i++){
      c=a+b;
      b=a ;
    a=c;
      
  }
 if(N==1) cout<<a<<endl;
 else cout<<c<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <math.h>
#include <string>
#include <string.h>
#include <stack>
#include <queue>
#include <vector>
#include <utility>
#include <set>
#include <map>
#include <stdlib.h>
#include <iomanip>

using namespace std;

#define ll long long
#define vi vector<int>
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pi 3.14159265359


int main() {
	string A, B;
	cin >> A >> B;
	if (A.size() > B.size()) {
		cout << "GREATER";
	}
	else if (A.size() < B.size()) {
		cout << "LESS";
	}
	else {

		REP(i, A.size()) {
			if (A[i] > B[i]) {
				cout << "GREATER";
				break;
			}
			else if (A[i] < B[i]) {
				cout << "LESS";
				break;
			}

			if (i == A.size()-1) cout << "EQUAL";
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <climits>
#include <iomanip>
#include <deque>

using namespace std;

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

  cin >> a >> b >> c;

  int count = 0;
  for (int i = a; i <= b; i++) {
    if (c % i == 0) {
      count++;
    }
  }

  cout << count << endl;

  return 0;
}



Measured memory_bytes: 3104
#include <stdio.h>
#define MAXN 50
int main(void)
{
	int N;
	int p[MAXN];
	int i,j;
	int min;
	int cnt=0;
	int tmp;
	
	scanf("%d",&N);

	for(i=0;i<N;i++){
		scanf("%d",&p[i]);
	}

	for(i=0;i<N-1;i++){
		min=i;
		for(j=i+1;j<N;j++){
			if(p[min]>p[j]){
				min=j;			
			}
		}
		if(p[min] != p[i]){
			tmp=p[i];
			p[i]=p[min];
			p[min]=tmp;	
			cnt++;
			if(cnt>1){
				puts("NO");
				return 0;
			}
		}
	}
	puts("YES");

	return 0;
}





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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
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; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }
template <class T1, class T2, class Pred = std::less<T2> >
struct sort_pair_second {
    bool operator()(const std::pair<T1,T2>&left, const std::pair<T1,T2>&right) {
        Pred p;
        return p(left.second, right.second);
    }
};

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

    int R; cin >> R;
    printf("%.12lf\n", 2 * PI * R);
    return 0;
}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    int r,g,b;
    cin >> r >> g >> b;
    if((10 * g + b) % 4 == 0) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            SolveA();
            //SolveB();
            //SolveC();
            //SolveD();
        }
        private const long MOD = 1000000007;
       
        static void SolveA()
        {
            int x = ReadAndParseInt();
            int a = ReadAndParseInt();
            int b = ReadAndParseInt();
            x -= a;
            x %= b;
            Console.WriteLine(x);
        }
        
        
        #region よく使う便利関数
        private static bool isPrime(long x)
        {
            if( x == 2) { return true; }
            if( x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while( i * i <= x)
            {
                if( x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }

        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        #endregion
    }
}

Measured memory_bytes: 11092
H, W = map(int, input().split())
list=["."+input()+"." for i in range(H)]
list=["."*(W+2)]+list+["."*(W+2)]
a=0
for h in range(H):
    for w in range(W):
        if list[h][w] == "#":
            if list[h+1][w] == "." and list[h-1][w] == "." and list[h][w-1] == "." and list[h][w+1] == ".":
                a=1
print("Yes" if a==0 else "No")

Measured memory_bytes: 3064
#include <stdio.h>
int main(void){
    int n;
    int a, aa,  b, cou, min=1000000;
    scanf("%d", &n);
    
    for(a=1; a<n; a++){
        cou = 0;
        b = n-a;
        aa = a;
        while(aa > 0){
            cou += aa%10;
            aa /= 10;
        }
        while(b > 0){
            cou += b%10;
            b /= 10;
        }
        
        if(min > cou){
            min = cou;
        }
    }
    printf("%d\n", min);
    
    return 0;
}

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

void solve() {
	int N, K;
  long long int prod;
  vector<int> A;
  vector<long long int> grades;
  cin>>N>>K;
  for(int i=0; i<N; i++) {
	int x;
  	cin>>x;
	A.push_back(x);
  }
  for(int i=0; i<N-K; i++) {
	if(A[i] < A[i+K]) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
  }
}

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

Measured memory_bytes: 4296
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pf push_front
#define mod 1000000007
#define endl '\n'
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);


int main()
{
    ll n,i,j;
    cin>>n;
    ll arr[n];
    for(i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    if(is_sorted(arr,arr+n))
    {
        cout<<"YES"<<endl;
    }
    else
    {
        ll mni;
        for(i=0;i<n-1;i++)
        {
            if(arr[i]>arr[i+1])
            {
                ll mn=INT_MAX;
                for(j=i;j<n;j++)
                {
                    if(arr[j]<mn)
                    {
                        mn=arr[j];
                        mni=j;
                    }
                }
                break;
            }
        }
        swap(arr[i],arr[mni]);
        if(is_sorted(arr,arr+n))
        {
            cout<<"YES"<<endl;
        }
        else
        {
            cout<<"NO"<<endl;
        }

    }
}


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

int main() {
  int A, B, result;
  string op;
  cin >> A >> op >> B;
  
  if (op == "+" ) {
    result = A + B;
  } else {
    result = A - B;
  }


  cout << result  << endl;


}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <string>
#include <iostream>
#include <vector>
#include <sstream>
#include <memory>
#include <iomanip>

int main(int argc, char* argv[])
{
    while (true) {
        std::string line;
        std::stringstream buffer;
        getline(std::cin, line);
        buffer << line;
        size_t length = 0;
        buffer >> length;
        if (length == 0) break;
        int *total = new int[length + 1];
        size_t width = length + 1;
        memset(total, 0, sizeof(int) * width);
        for (size_t i = 0; i < length; ++i) {
            getline(std::cin, line);
            std::istringstream s(line);
            std::string element;
            int sum = 0;
            for (size_t n = 0; n < length; ++n) {
               getline(s, element, ' ');
               std::stringstream tmp;
                int val = 0;
                tmp << element;
                tmp >> val;
                sum += val;
                total[n] += val;
                std::cout << std::setw(5) << val;
            }
            std::cout << std::setw(5) << sum << std::endl;
            total[length] += sum;
        }
        for (size_t i = 0; i < width; ++i) {
            std::cout << std::setw(5) << total[i];
        }
        std::cout << std::endl;
        delete[] total;
    }
    return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>


#define INF             1e9
#define INFL            1e19
#define XX              first
#define YY              second
#define PB              push_back
#define MP              make_pair

#define NEWLINE         cout << endl;
#define HOISE           cout << "hoise" << endl
#define PAUSE           system("pause")
#define DEBUG(x)        cout << #x << " = " << x << endl
#define READ            freopen("alu.txt", "r", stdin)
#define WRITE           freopen("vorta.txt", "w", stdout)
#define FASTIO          ios_base::sync_with_stdio(false);cin.tie(NULL)

#define MASK(x)         for(int i = 0; i < 8; i++){ if(x&(1<<i)){ cout << i << " "; } } cout << endl;

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

const int MAX = 200000 + 2;
const int MAXLOG = log2(MAX) + 2;
const int MAXN = 1e6 + 2;
const int MOD = 1000000007;
const double PY = acos(-1.0);

int main()
{
//    READ;
//    WRITE;
    FASTIO;

    ll n;
    cin >> n;
    if(n%2 == 1){
        cout << 0;
        return 0;
    }

    ll five = 0;
    ll b = 5;
    while(b <= n){
        ll temp = (n/b);
        temp /= 2LL;
        five += temp;
        b *= 5LL;
    }

    cout << five;

    return 0;
}




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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a <= x && x < b)
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL << 30)
#define LLINF (1LL << 60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

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

int main() {
  while (true) {
    int h, b[20][10];
    cin >> h;
    if (!h)
      break;
    REP(i, h) REP(j, 5) cin >> b[i][j];

    int ret = 0;
    //?????????????????????h???
    REP(i, h) {
      REP(j, h) {
        int c = 1;
        FOR(k, 1, 5) {
          if (b[j][k] == b[j][k - 1] && b[j][k] != 0)
            c++;
          else {
            if (c >= 3) {
              ret += b[j][k - 1] * c;
              for (int l = k - 1; l >= k - c; --l)
                b[j][l] = -1;
            }
            c = 1;
          }
        }
        if (c >= 3) {
          ret += b[j][4] * c;
          for (int l = 4; l > 4 - c; --l)
            b[j][l] = -1;
        }
      }
      /*cout << "kesu:" << endl;
      REP(i, h) {
        REP(j, 5) {
          cout << b[i][j] << " ";
        }
        cout << endl;
      }*/
      REP(j, 5) {
        int c = 0;
        for (int k = h - 1; k >= 0; --k) {
          if (b[k][j] == -1) {
            c++;
          } else if (c) {
            int ii = 0;
            while (ii != c) {
              b[k + c - ii][j] = b[k][j];
              b[k][j] = 0;
              ++ii;
            }
          }
        }
        if (c) {
          REP(k, c) b[k][j] = 0;
        }
      }
      /*cout << "otosu:" << endl;
      REP(i, h) {
        REP(j, 5) {
          cout << b[i][j] << " ";
        }
        cout << endl;
      }*/
    }

    cout << ret << endl;
  }

  return 0;
}

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

#define REP(i,num) for(ll i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=ll>
T in(){T x; cin >> x; return (x);}
template<typename T=ll,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

vvll MazeBFS(int start,int H,int W,vvll& M,ll initD=1LL<<60){
	vvll D(H,vll(W,initD));
	D[start/W][start%W]=0;
	queue<int> Q;
	Q.push(start);
	while(!Q.empty()){
		int V=Q.front();
		Q.pop();
		int u=V%W,v=V/W;
		if(u>0 && D[v][u-1]>=initD && M[v][u-1]==0){
			D[v][u-1]=D[v][u]+1;
			Q.push(u-1+v*W);
		}
		if(u<W-1 && D[v][u+1]>=initD && M[v][u+1]==0){
			D[v][u+1]=D[v][u]+1;
			Q.push(u+1+v*W);
		}
		if(v>0 && D[v-1][u]>=initD && M[v-1][u]==0){
			D[v-1][u]=D[v][u]+1;
			Q.push(u+(v-1)*W);
		}
		if(v<H-1 && D[v+1][u]>=initD && M[v+1][u]==0){
			D[v+1][u]=D[v][u]+1;
			Q.push(u+(v+1)*W);
		}
	}
	return D;
}

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

	int H=in(),W=in();
	vvll M(H,vll(W,0));

	int black=0,white=0;
	REP(i,H){
		string S=in<string>();
		REP(j,W){
			if(S[j]=='#'){
				M[i][j]=1;
				black++;
			}
			else white++;
		}
	}
	auto D = MazeBFS(0,H,W,M);
	out(D[H-1][W-1]>=1<<30 ? -1 : white-D[H-1][W-1]-1);
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
using namespace std;
const int N=3e3+10;
int n;double dp[N][N],p[N],ans;//到了第i个有j个是正面朝上的 
int main(){
	scanf("%d",&n);
	for(register int i=1;i<=n;i++)scanf("%lf",&p[i]);
	dp[0][0]=1.0;
	for(register int i=1;i<=n;i++)
		for(register int j=0;j<=i;j++){
			if(i!=j)dp[i][j]+=(1.0-p[i])*dp[i-1][j];
			if(j)dp[i][j]+=p[i]*dp[i-1][j-1];
		}
	for(register int i=0;i<=n;i++)
		if(i<n-i)ans+=dp[n][n-i];else break;
	printf("%.10lf\n",ans);
	return 0;
}

Measured memory_bytes: 69120
from collections import defaultdict
from collections import deque
from string import ascii_uppercase
import sys, bisect, math, heapq

stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
read_str = lambda : stdin.readline().rstrip()

N, K = read_int()

def solve():
    return rec(N)

def rec(n):
    if n < K:
        return 1
    return 1 + rec(n // K)

if __name__ == "__main__":
    print(solve())

Measured memory_bytes: 4088
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val m = sc.nextInt()
    val x = (0 until m).map { sc.next().toInt() }
    println(problem117c(n, m, x))
}

fun problem117c(n: Int, m: Int, x: List<Int>): Int {
    val x = x.sorted()
    val diffs = IntArray(m - 1)
    for (i in 1 until m) {
        diffs[i - 1] = Math.abs(x[i - 1] - x[i])
    }
    return diffs.sorted().dropLast(n - 1).sum()
}

Measured memory_bytes: 53412
n=int(input())
s=str(n)
n=len(s)
s=list(s)

for i in range(n):
    if i==n-1:
        if s[-1-i]=='-1' or s[-1-i]=='0':
            s[-1-i]='0'
        continue
    if s[-1-i]=='-1':
        s[-1-i]='0'
    if s[-1-i]=='9':
        continue
    else:
        t=int(s[-1-i-1])-1
        s[-1-i-1]=str(t)
        s[-1-i]='9'

ans=0
for ss in s:
    ans+=int(ss)
print(ans)


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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(20);
  
  string s, t;
  cin >> s >> t;

  int ans = 0;
  rep(i, s.size()) {
    if (s[i] == t[i]) ans++; 
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,a,n) for(int i=a;i<n;i++)
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eps 1e-15

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef map<int,int> mii;
typedef pair<int,int> pii;
typedef tuple<int,int,int> ti3;

int N;
vi D;

void Main()
{
    cin >> N;
    rep(i, N)
    {
        int x;
        cin >> x;
        D.push_back(x);
    }
    sort(D.begin(), D.end());
    cout << D[N/2] - D[N/2 - 1] << endl;
}

int main()
{
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	// cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 892
import java.util.Scanner;

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

        int a = sc.nextInt();
        int b = sc.nextInt();
        if (a > 8 || b > 8)
            System.out.println(":(");
        else
            System.out.println("Yay!");
    }
}

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

int main(void)
{
	
	char k[300000];
	int i;
	int len = 0;
	char a = '?';
	char b = 'P';
	char c = 'D';
	
	scanf("%s",k);
	
	len = strlen(k);
		
	for(i= (len - 1); i >= 0; i--){
		//printf("%d",i);
		//scanf("%c", &k[i]);
		if(k[i] == a){
			k[i] = c;
/*			if(i == (len-1)){
				k[i] = c;
			}
			else if(k[i+1] == c){
				k[i] = b;
			}
			else{
				k[i] = c;
			}*/
		}
		//printf("%d",i);
		
	}
	
	//OUT:
	printf("%s", k);
	
	
	return 0;
}

Measured memory_bytes: 1928
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {        
        var N = decimal.Parse(Console.ReadLine());
        List<decimal> list = new List<decimal>();
        for (var i = 0; i < 5; i++) {
            list.Add(decimal.Parse(Console.ReadLine()));
        }
        
        if (N <= list.Min()) {
            Console.WriteLine(5);
        } else {
            Console.WriteLine(4 + Math.Ceiling(N / list.Min()));
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define int long long
using namespace std;

void dfs(int u, int num, auto& used, const auto& g) {
    used[u] = num;
    for (int v : g[u]) {
        if (used[v]) continue;
        dfs(v, num, used, g);
    }
}
signed main() {
    int N, K, L;
    cin >> N >> K >> L;

    vector<vector<int>> G(N), H(N);
    for (int i = 0; i < K; i++) {
        int p, q;
        cin >> p >> q;
        --q, --p;
        G[p].push_back(q);
        G[q].push_back(p);
    }
    for (int i = 0; i < L; i++) {
        int r, s;
        cin >> r >> s;
        --r, --s;
        H[s].push_back(r);
        H[r].push_back(s);
    }

    int num;
    vector<int> g(N), h(N);
    num = 0;
    for (int i = 0; i < N; i++) {
        if (g[i]) continue;
        dfs(i, ++num, g, G);
    }
    num = 0;
    for (int i = 0; i < N; i++) {
        if (h[i]) continue;
        dfs(i, ++num, h, H);
    }

    map<pair<int, int>, int> m;
    for (int i = 0; i < N; i++) {
        m[{g[i], h[i]}]++;
    }

    for (int i = 0; i < N; i++) {
        cout << m[{g[i], h[i]}] << " ";
    }
    cout << endl;

    return 0;
}


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

int a[100005];

int main() {
    int n;
    cin >> n;
    ll h[n];
    rep(i, n) cin >> h[i];

    for (int i = 1; i < n; i++) {
        a[i] += a[i - 1];
        if (h[i - 1] >= h[i])
            a[i]++;
        else
            a[i] = 0;
    }

    cout << *max_element(a, a + n) << endl;
    return 0;
}


Measured memory_bytes: 4808
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "bitset"
#include "queue"
#include "functional"
#include "map"
#include "unordered_map"

#define lp(n) for (int i = 0; i < n; i++)
#define LP(n,i) for (int i = 0; i < n; i++)
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nya_n "(=^･ω･^=)"
typedef long long ll;
using namespace std;

int h, w, ans;

int main() {
	cin >> h >> w;
	if (h % 3 == 0 || w % 3 == 0)
		ans = 0;
	else {
		ans = min(h, w);
		if (h % 2 == 0)
			ans = min({ ans, abs(h*(w / 3) - h / 2 * (w - w / 3)),abs(h*(w / 3 + 1) - h / 2 * (w - w / 3 - 1)) });
		else
			ans = min({ ans,max({abs(h*(w / 3) - h / 2 * (w - w / 3)),abs(h*(w / 3) - (h / 2 + 1)*(w - w / 3)),w - w / 3}),	max({ abs(h*(w / 3 + 1) - h / 2 * (w - w / 3 - 1)),abs(h*(w / 3 + 1) - (h / 2 + 1)*(w - w / 3 - 1)),w - w / 3 - 1 }) });
		swap(h, w);
		if (h % 2 == 0)
			ans = min({ ans, abs(h*(w / 3) - h / 2 * (w - w / 3)),abs(h*(w / 3 + 1) - h / 2 * (w - w / 3 - 1)) });
		else
			ans = min({ ans,max({ abs(h*(w / 3) - h / 2 * (w - w / 3)),abs(h*(w / 3) - (h / 2 + 1)*(w - w / 3)),w - w / 3 }),	max({ abs(h*(w / 3 + 1) - h / 2 * (w - w / 3 - 1)),abs(h*(w / 3 + 1) - (h / 2 + 1)*(w - w / 3 - 1)),w - w / 3 - 1 }) });

	}
	cout << ans << endl;
	return 0;
}

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

int main() {
    int n,l,sum=0,mini=200;
    bool flag=false,sign=false;
    cin>>n>>l;
    vector<int> aji(n);
    rep(i,n) {
        aji.at(i)=l+i;
        sum+=aji.at(i);
        if (aji.at(i)==0) flag=true;
    }
    if (flag) cout<<sum<<endl;
    else {
        rep(i,n) {
            mini=abs(min(mini,aji.at(i)));
            if (mini==-1*aji.at(i)&&aji.at(i)<0) sign=true;
        }
        if (sign) sum+=mini;
        else sum-=mini;
        cout<<sum<<endl;
    }
}   

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

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

	int a,b;
	cin>>a>>b;
	(a<=8 && b<=8) ? cout<<"Yay!":cout<<":(";
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){

  int i,j,n,min,g;
  int A[100];
  
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&A[i]);
  
  for(i=1;i<n+1;i++){
    min = A[i];
    j = i-1;
     for(g=0;g<n;g++){
      printf("%d",A[g]);
      if(g < n-1)printf(" ");
      else printf("\n");
    }
    
    while(j >= 0 && A[j] > min){
      A[j+1] = A[j];
      j--;
      A[j+1] = min;
    }
   
  }
  return 0;
}

Measured memory_bytes: 604
/*
*/

#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>

#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk

#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds
#define ends asdgahhfdsfshdshfd

#define eps 1e-12
#define M_PI 3.141592653589793
#define bs 1000000007

#define ldouble long double

using namespace std;

long long INF = 1e9;
const int N = 1200031;

int n,ar[N],ans;

int main(){
	//freopen("tree.in","r",stdin);
	//freopen("tree.out","w",stdout);
	//freopen("input.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
	//cin.tie(0);

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

	int start=1;
	while (start<=n)
	{
		++ans;
		int have_up=0;
		int have_down=0;
		int new_start=-1;

		for (int i=start+1;i<=n;i++)
		{
			if (ar[i]>ar[i-1])
				have_up=1;
			if (ar[i]<ar[i-1])
				have_down=1;
			if (have_up&&have_down)
			{
				new_start=i;
				break;
			}
		}
		if (new_start==-1)
			new_start=n+1;
		start=new_start;
	}

	cout<<ans<<endl;

	cin.get(); cin.get();
	return 0;
}


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

int main(){
    ll a,b,c,count=0;
    cin >> a >> b >> c;
    if(a == b && b == c){
        if(a%2 != 0){
            cout << '0' << endl;
            return 0;
        }else{
            cout << "-1" << endl;
            return 0;
        }
    }
    if(a%2 != 0 || b%2 != 0 || c%2 != 0){
        cout << '0' << endl;
        return 0;
    }else{
        vector<ll> v(3);
        do{
            v[0] = b/2 + c/2;
            v[1] = a/2 + c/2;
            v[2] = a/2 + b/2;
            a = v[0];
            b = v[1];
            c = v[2];
            count++;  
        }while(a%2 == 0 && b%2 == 0 && c%2 == 0);
        cout << count << endl;
    }
}

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

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

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

const int mod = 998244353;
const ll inf = 3e18 + 5;

int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }  

int main(){
    ll n;
    cin >> n;
    ll a, b;
    cin >> a >> b;
    ll sol, tmp;
    tmp = n / (a + b);
    sol = tmp * a;
    ll n2 = n - tmp * (a + b);
    sol += min(n2, a);
    cout << sol;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;

//https://beta.atcoder.jp/contests/agc028/tasks/agc028_a

public class Program_AGC028_A // ←Class名変更！！
{
    public static void Main(string[] args)
    {
        var st = Console.ReadLine();
        var s = Console.ReadLine();
        var t = Console.ReadLine();

        var l = Lcm(s.Length, t.Length);
        var x = new Dictionary<long, char>();

        for (int i = 0; i < s.Length; i++)
        {
            var pos = i * (l / s.Length) + 1;
            x[pos] = s[i];
        }


        for (int i = 0; i < t.Length; i++)
        {
            var pos = i * (l / t.Length) + 1;
            if (x.ContainsKey(pos))
            {
                if (x[pos] != t[i])
                {
                    Console.WriteLine(-1);
                    return;

                }
            }
        }

        Console.WriteLine(l);
    } // Main



    //最小公倍数 least common multiple
    public static long Lcm(int a, int b)
    {
        //return a * b / Gcd(a, b) ;
        return a  / Gcd(a, b) * b;
    }

    // ユークリッドの互除法 
    //public static int Gcd(int a, int b)
    //{
    //    if (a < b)  return Gcd(b, a); // 引数を入替えて自分を呼び出す

    //    while (b != 0)
    //    {
    //        var temp = a % b;
    //        a = b;
    //        b = temp;
    //    }

    //    return a;
    //}





    static long Gcd(long a, long b)
    {
        var small = Math.Min(a, b);
        var big = Math.Max(a, b);

        if (small > 0)
        {
            return Gcd(small, big % small);
        }
        else
        {
            return big;
        }


        //if (a < b)
        //{
        //    return Gcd(b, a);
        //}
        //else
        //{
        //    if (b > 0)
        //    {
        //        return Gcd(b, a % b);
        //    }
        //    else
        //    {
        //        return a;
        //    }
        //}

        //return (a < b) ? Gcd(b, a)
        //     : (b > 0) ? Gcd(b, a % b)
        //               : a;
    }

    //static long Lcm(long a, long b)
    //{
    //    return a / Gcd(a, b) * b;
    //}


    static long gcd(long a, long b)
    {
        long c = Math.Max(a, b) % Math.Min(a, b);
        b = Math.Min(a, b);
        while (c != 0)
        {
            a = b % c;
            b = c;
            c = a;
        }
        return b;
    }

}     // Class




Measured memory_bytes: 19936
n,m = map(int,input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]

f = 0
for i in range(n - m + 1):
    for j in range(n - m + 1):
        t = [k[j:j + m] for k in a[i:i + m]]
        if t == b: f = 1

print ("Yes" if f else "No")


Measured memory_bytes: 3060
import numpy as np

s = input().split()

# 縦の長さ
h = int(s[0])

# 横の長さ
w = int(s[1])


answer = []

for num in range(h):
    x = input().split()
    answer.append(x[0])
    answer.append(x[0])

for num in range(h * 2):
    print(answer[num])






Measured memory_bytes: 27112