akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long 
using namespace std;
int main(){
  int a;
  cin >>a;
  cout <<a*a*a<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long int lli;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    lli n;
    cin>>n;
    lli i,a[n],ans[n];
    
    for(i=0;i<n;i++) cin>>a[i];
    
    ans[0]=a[0];
    for(i=1;i<n;i++) ans[0]=(ans[0]^a[0]^a[i]);
    
    for(i=1;i<n;i++) ans[i]=(ans[0]^a[0]^a[i]);
    
    for(i=0;i<n;i++) cout<<ans[i]<<" ";
    return 0;
}

Measured memory_bytes: 6696
package main

import(
	"fmt"
	"strings"
	"strconv"
	"os"
	"bufio"
)

var sc = bufio.NewScanner(os.Stdin)

func readLine() string {
	sc.Scan()
	return sc.Text()
}

func main() {

	items := strings.Split(readLine(), " ")

	career := make([]int, 0, 1000)
	count := 0

	for i := 0; i < len(items); i++ {
		j := 0
		n, e := strconv.Atoi(items[i])
		if e != nil {
			panic(e)
		}
		for ; j < len(career); j++ {
			if career[j] == n {
				break
			}
		}
		if j == len(career) {
			career = append(career, n)
			count++
		}
	}

	fmt.Println(count)

}


Measured memory_bytes: 640
#include <iostream>
#include<vector>
using namespace std;
#define REP(i, j) for(int i = 0; i < j; i++)
const int N = 10010;

bool isprime[N];
vector<int> prime;

//vectorありver
int makePrime1(bool type){
    REP(i, N) isprime[i] = true;
    isprime[0] = false;
    isprime[1] = false;

    for(int i = 2; i < N; i++){
        if(!isprime[i]) continue;
        prime.push_back(i);
        for(int j = i + i; j < N; j += i) isprime[j] = false;
    }
}

//なしver
int makePrime2(){
    REP(i, N) isprime[i] = true;
    isprime[0] = false;
    isprime[1] = false;

    for(int i = 2; (i * i) <= N; i++){
        if(!isprime[i]) continue;
        for(int j = i + i; j < N; j += i) isprime[j] = false;
    }
}

void dispVector(){
    REP(i, prime.size()){
        cout <<prime[i] <<endl;
    }
}

void dispDx(){
    REP(i, N){
        if(isprime[i]) cout <<i <<endl;
    }
}

int main(){
    makePrime2();

    int n;
    while(cin >>n && n){
        for(int i = n; i >= 2; i--){
            if(isprime[i] && isprime[i - 2]){
                cout <<i - 2 <<" " <<i <<endl;
                break;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1176
n = int(input())
A = list(map(int,input().split()))
def func(list1,op,acc = 0,count = 0):
    for i in range(n):
        acc += list1[i]
        if i % 2 == 1 and acc * op >= 0:
            count += op * acc + 1
            acc = -op
        elif i % 2 == 0 and acc * op <= 0:
            count += -op * acc + 1
            acc = op
    if acc == 0:
        count += 1
    return count
ans = min(func(A,1),func(A,-1))
print(ans)

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

int main(){
  int a,b;cin >> a >> b;
  if(a<b){
    for(int i=0;i<b;i++){
      cout << a ;
    }
  }else{
    for(int i=0;i<a;i++){
      cout << b;
    }
  }
} 

Measured memory_bytes: 256
#include"iostream"
using namespace std;

int power_int(int a, int b)
{
	int x = 1;
		while (b > 0)
		{
			x *= a;
			b--;
		}
	return x;
}

int main()
{
	int x;
	cin >> x;
	int ans = 1;
	int a = 2;
	while (a * 2 <= x)
	{
		for (int i = 2; i < x + 1; i++)
		{
			if (power_int(a, i) <= x && ans < power_int(a, i))ans = power_int(a, i);
		}
				a++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>
#include <functional>
//#include <boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)
#define llrep(i, n) for(ll i = 0; i < n; ++i)
#define llREP(i, m, n) for(ll i = m; i < n; ++i)
#define llrrep(i,n) for(ll i = n; i >= 0; --i)
#define llRREP(i, m, n) for(ll i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;
using pil = std::pair<int, long long>;
using pli = std::pair<long long, int>;
using plpii = std::pair<long long, std::pair<int, int>>;
using pdd = std::pair<double, double>;

const long long INF = 1000000000000000001;
const long long _MOD = 1000000007;
const long long MOD = 998244353;
const int ALPHABET = 27;
const double pi = 3.14159265358979;

using namespace std;
//namespace mp = boost::multiprecision;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int x, y;
	cin >> x >> y;
	cout << x + y / 2 << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	int a,b,x;
	char op;
	
	while(1){
		scanf("%d %c %d",&a,&op,&b);
		
		if(op=='+'){
			x=a+b;
		}else if(op=='-'){
			x=a-b;
		}else if(op=='*'){
			x=a*b;
		}else if(op=='/'){
			x=a/b;
		}else{
			break;
		}

	
		printf("%d\n",x);
	}
	
	return 0;
}


Measured memory_bytes: 2040
#include<iostream>
#define MAX_N 100001
#define INF (1 << 30)
using namespace std;
typedef long long ll;

ll x_pos[MAX_N];

int main() {
    int N, K, start_pos = -1;
    cin >> N >> K;
    for (int i = 0; i < N; i++) {
        cin >> x_pos[i];
        if (start_pos < 0 && x_pos[i] >= 0) start_pos = i;
    }
    ll min_time = INF;
    for (int i = 0; i < N - K + 1; i++) {
        int right_pos = i + K - 1;
        int l_time = abs(x_pos[i]) + abs(x_pos[right_pos] - x_pos[i]);
        int r_time = abs(x_pos[right_pos]) + abs(x_pos[right_pos] - x_pos[i]);
        if (l_time > r_time) l_time = r_time;
        if (min_time > l_time) min_time = l_time;
    }
    cout << min_time << endl;
    return 0;
}

Measured memory_bytes: 1024
/*author - swapno7064*/

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define ll long long int
#define inf 100000000000
#define MOD 1000000007
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define for0(i, n) for (int i = 0; i < n; i++)
#define tc(t) int t; cin >> t; while (t--)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define vll vector<ll>
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define S(x) (int)(x).size()
#define L(x) (int)(x).length()
#define ps(x,y)         fixed<<setprecision(y)<<x
using namespace std;
using namespace __gnu_pbds;
int main()
{
	IOS
	int cnt=0;
	int n;
	cin>>n;
	ll arr[n];
	mll freq;
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
		freq[arr[i]]++;
	}
	sort(arr,arr+n);
	bool vis[1000010];
	memset(vis,true,sizeof(vis));
	for(int i=0;i<n;i++)
	{
		if(vis[arr[i]]==true)
		{
			if(freq[arr[i]]==1)cnt++;
			for(int j=arr[i];j<=1000006;j+=arr[i])
			{
				vis[j]=false;
			}
		}
	}
	cout<<cnt<<endl;
	
}
		
	
	


Measured memory_bytes: 18660
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORR(i, a, b) for(int i = (a); i >= (b); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOREACH(x, a) for(auto x : a)

/* exchange */
#define CHMIN(a, b) (a) = min((ll)(a), (ll)(b))
#define CHMAX(a, b) (a) = max((ll)(a), (ll)(b))

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define LN() cerr << "\n"
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N = 0;
ll t;
ll ret = 0;
vl B;

void input() {
  IN(N);
  B.pb(INF);
  REP(i, N-1) {
    IN(t);
    B.pb(t);
  }
  B.pb(INF);
}

void solve() {
  REP(i, N) {
    ll x = B[i];
    ll y = B[i+1];
    ll z = min(x, y);
    // DEBUG(z);
    ret += z;
  }
  PRINT(ret);
}

int main(void){
  input();
  solve();
}


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

const char *table[] = {
    "abcde", "fghij", "klmno",
    "pqrst", "uvwxy", "z.?! ",
};

int main(void)
{
    char msg[256];

    while (~scanf("%s", msg)){
        int i;
        char decode[256] = {0};
        int len = strlen(msg);

        if (len % 2){
            puts("NA");
            continue;
        }
        for (i = 0; i < len / 2; i++){
            int a = msg[i * 2] - '0';
            int b = msg[i * 2 + 1] - '0';

            if (a < 1 || a > 6 || b < 1 || b > 5){
                puts("NA");
                i = len + 1;
                break;
            }
            decode[i] = table[a - 1][b - 1];
        }
        if (i < len){
            puts(decode);
        }
    }

    return 0;
}

Measured memory_bytes: 524
module.exports=function(e){var r={};function n(t){if(r[t])return r[t].exports;var o=r[t]={i:t,l:!1,exports:{}};return e[t].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=r,n.d=function(e,r,t){n.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,r){if(1&r&&(e=n(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(n.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var o in e)n.d(t,o,function(r){return e[r]}.bind(null,o));return t},n.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(r,"a",r),r},n.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},n.p="",n(n.s=0)}([function(e,r,n){n(1)(n(2).readFileSync("/dev/stdin","UTF-8"))},function(e,r){e.exports=function(e){var r=e.split("\n"),n=Number(r[0]),t=r[1].split(" ").map(function(e){return Number(e)});if(l(t))console.log("YES");else{for(var o=0;o<n;o++)for(var u=n-1;u>o;u--){var i=t.concat(),f=i[o];if(i[o]=i[u],i[u]=f,l(i))return void console.log("YES")}console.log("NO")}function l(e){for(var r=0;r<n-1;r++)if(e[r]>e[r+1])return!1;return!0}}},function(e,r){e.exports=require("fs")}]);

Measured memory_bytes: 11468
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		while(true){
			StringTokenizer input_n = new StringTokenizer(br.readLine());
			
			final int n = Integer.parseInt(input_n.nextToken());
			
			if(n == 0){
				break;
			}
			
			long sum = 0;
			StringTokenizer input_p = new StringTokenizer(br.readLine());
			for(int i = 0; i < n; i++){
				sum += Integer.parseInt(input_p.nextToken());
			}
			
			PriorityQueue<Integer> joint_queue = new PriorityQueue<Integer>(n-1, Collections.reverseOrder());
			StringTokenizer input_j = new StringTokenizer(br.readLine());
			for(int i = 0; i < n - 1; i++){
				joint_queue.add(Integer.parseInt(input_j.nextToken()));
			}
			
			long max = n * sum;
			int cur_size = n;
			while(!joint_queue.isEmpty()){
				int joint = joint_queue.poll();
				sum += joint;
				cur_size -= 1;
				
				long cur = cur_size * sum;
				if(max > cur){
					break;
				}else{
					max = cur;
				}
			}
			
			System.out.println(max);
		}
	}

}

Measured memory_bytes: 47212
#include "bits/stdc++.h"
#define fi first
#define se second
#define all(x) x.begin(), x.end()
using namespace std;
using ull = unsigned long long;
using ll = long long;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;

int main(){
    vector<vector<int>> G(3, vector<int>(3));
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            cin >> G[i][j];
        }
    }
    bool flag = true;
    for(int i = 0; i < 2; i++){
        for(int j = 0; j < 2; j++){
            if(G[i][j] - G[i + 1][j] != G[i][j + 1] - G[i + 1][j + 1]){
                flag = false;
                break;
            }
            if(G[j][i] - G[j + 1][i] != G[j][i + 1] - G[j + 1][i + 1]){
                flag = false;
                break;
            }
        }
    }
    if(flag) puts("Yes");
    else puts("No");
}

Measured memory_bytes: 256
//#define LOCAL
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string>
#include<math.h>
#include<map>
#include<random>
#include<stack>
using namespace std;
using lld = long long int;
using llu = unsigned long long int;
using pii = pair<int, int>;
using pli = pair<lld, int>;
using pil = pair<int, lld>;
using pll = pair<lld, lld>;
using piii = pair<pii, pii>;
using pdii = pair<int, pii>;
int n, m;
char xx[99];
int main() {
	int i, j, k, l;
	int t = 1, tv = 0;
	while (t--) {
		scanf("%s", xx);
		xx[1] ^= 'B' ^ 'R';
		printf("%s", xx);
	}
}

Measured memory_bytes: 1728
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] S = sc.next().split("");
		sc.close();
		if (S[2].equals(S[3]) && S[4].equals(S[5])) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 21844
from collections import defaultdict
odd_dic = defaultdict(int)
even_dic = defaultdict(int)
n = int(input())
ns = list(map(int, input().split()))
for i in range(0, n, 2):
    even_dic[ns[i]] += 1
for i in range(1, n, 2):
    odd_dic[ns[i]] += 1
even = sorted(even_dic.items(), key=lambda x:x[1], reverse=True)
odd = sorted(odd_dic.items(), key=lambda x:x[1], reverse=True)

if even[0][0] != odd[0][0]:
    print(n-even[0][1]-odd[0][1])
elif even[0][1]+odd[0][1]==n:
    print(n//2)
else:
    print(min(n-even[0][1]-odd[1][1], n-even[1][1]-odd[0][1]))

Measured memory_bytes: 23008
mod = 10 ** 9 + 7

def mod_prepare(N):
    fac = [1, 1]
    finv = [1, 1]
    inv = [0, 1]
    for i in range(2, N + 1):
        fac.append(fac[i - 1] * i % mod)
        inv.append(mod - inv[mod % i] * (mod // i) % mod)
        finv.append(finv[i - 1] * inv[i] % mod)
    return fac, finv

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

fac, inv = mod_prepare(M)

ans = 0
sign = 1
for k in range(N + 1):
    ans += sign * fac[M - k] * inv[k] * inv[N - k]
    sign *= -1
    ans %= mod

print(ans * fac[N] * fac[M] * inv[M - N] * inv[M - N] % mod)

Measured memory_bytes: 68324
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> A(1 << N);
  for (int i = 0; i < (1 << N); i++){
    cin >> A[i];
  }
  vector<pair<int, int>> B(1 << N);
  for (int i = 0; i < (1 << N); i++){
    B[i] = make_pair(A[i], 0);
  }
  for (int i = 0; i < N; i++){
    for (int j = 0; j < (1 << N); j++){
      if (j >> i & 1){
        int tmp1, tmp2;
        if (B[j].first > B[j - (1 << i)].first){
          tmp1 = B[j].first;
          tmp2 = max(B[j].second, B[j - (1 << i)].first);
        } else {
          tmp1 = B[j - (1 << i)].first;
          tmp2 = max(B[j - (1 << i)].second, B[j].first);
        }
        B[j] = make_pair(tmp1, tmp2);
      }
    }
  }
  vector<int> C(1 << N, 0);
  for (int i = 1; i < (1 << N); i++){
    C[i] = B[i].first + B[i].second;
  }
  for (int i = 2; i < (1 << N); i++){
    C[i] = max(C[i], C[i - 1]);
  }
  for (int i = 1; i < (1 << N); i++){
    cout << C[i] << endl;
  }
}

Measured memory_bytes: 7464
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

const int L=1e5+1;
int X;
int K;
int r[L];
int b[L];
int u[L];
int l[L];
int main() {
	scanf("%d%d",&X,&K);
	for(int i=1;i<=K;i++){
		scanf("%d",r+i);
	}
	u[0]=X;
	for(int i=1;i<=K;i++){
		int d;
		if(i%2){
			d=-r[i]+r[i-1];
		}
		else{
			d=r[i]-r[i-1];
		}
		b[i]=b[i-1]+d;
		u[i]=u[i-1]+d;
		l[i]=l[i-1]+d;
		u[i]=max(0,min(X,u[i]));
		l[i]=max(0,min(X,l[i]));
	}
	int Q;
	scanf("%d",&Q);
	for(int i=0;i<Q;i++){
		int t,a;
		scanf("%d%d",&t,&a);
		int p=upper_bound(r,r+K+1,t)-r;
		p--;
		int s=a+b[p];
		if(s<l[p]){
			s=l[p];
		}
		else if(u[p]<s){
			s=u[p];
		}
		if(p%2==0){
			s-=t-r[p];
		}
		else{
			s+=t-r[p];
		}
		s=max(0,min(X,s));
		printf("%d\n",s);
	}




	return 0;
}



Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
using lli=long long int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using vi=vector<int>;  using vs=vector<string>; using gi=greater<int>;
#define soao(c) sort((c).begin(),(c).end()) //昇順
#define sodo(c) sort((c).begin(),(c).end(),gi()) //降順
#define rev(c) reverse((c).begin(), (c).end())

int main() {
  int X,Y; cin>>X>>Y;
  if(X%Y==0) cout<<"-1"<<endl;
  else cout<<X<<endl;
}
  


Measured memory_bytes: 256
#!/usr/bin/env python3
import math
import sys
sys.setrecursionlimit(10**6)


n = int(input())
a = list(map(int, input().split()))

ans = 10**10

for i in a:
    tmp = 0
    while(i % 2 != 1):
        tmp += 1
        i = i//2
    # print(tmp)
    ans = min(ans, tmp)

print(ans)


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

int main() {
  int n;
  cin >> n;
  
  int ans = 0;
  for(int i=1; i<=n; i++) {
    for(int j=1; j<=n; j++) {
      for(int k=1; k<=n; k++) {
        ans += __gcd(__gcd(i,j), k);
      }
    }
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <deque>
#include <numeric>
#include <utility>
using namespace std;
#define LL long long
const long long MOD = 1000000007;
vector<LL> fac(300001);
vector<LL> ifac(300001);

LL mpow(LL x, LL n){
    LL ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % MOD;
        x = x*x % MOD;
        n = n >> 1;
    }
    return ans;
}

LL comb(LL a, LL b){
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    LL tmp = ifac[a-b]* ifac[b] % MOD;
    return tmp * fac[a] % MOD;
}

void solve(long long N, long long K){
    fac[0] = 1;
    ifac[0] = 1;
    for(LL i = 0; i<300000; i++){
        fac[i+1] = fac[i]*(i+1) % MOD;
        ifac[i+1] = ifac[i]*mpow(i+1, MOD-2) % MOD;
    }

    for(LL i=1; i<=K; i++){
        cout << (comb(K-1, i-1)*comb(N-K+1, i))%MOD << endl;
    }
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    solve(N, K);
    return 0;
}


Measured memory_bytes: 4992
n = int(input())
f = [list(map(int, input().split())) for _ in range(n)]
p = [list(map(int, input().split())) for _ in range(n)]

profit = (-1) * 10**10
for bit in range(1, 2**10):
    duplicate_list = [0] * n
    for i in range(10):
        if bit & (1 << i):
            for num, f_ in enumerate(f):
                duplicate_list[num] += f_[i]
    tmp_profit = sum([p[num][cnt] for num, cnt in enumerate(duplicate_list)])
    profit = max(profit, tmp_profit)

print(profit)

Measured memory_bytes: 3064
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 30;
// clang-format on

int N;
int p[MAX_N];

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N;
  REP(i, N) cin >> p[i];

  int ans = 0;
  for (int i = 0; i < N; i++) {
    int cur = i + 1;
    if (p[i] == cur) {
      if (i + 1 < N && p[i + 1] == cur + 1) {
        swap(p[i], p[i + 1]);
      }
      else if (i - 1 >= 0) {
        swap(p[i], p[i - 1]);
      }
      else {
        swap(p[i], p[i + 1]);
      }
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
using namespace std;

int land[200][200];
int sea[200][200];

int n;
int R,z[1000];

const int INF = 0x0f0f0f0f;	

int memo[200][1000];
int Solve(int boat, int index)
{
	if(index >= R)
		return 0;
	int &ref = memo[boat][index];
	if(ref >= 0)
		return ref;
	int from = z[index-1];
	int to = z[index];

	ref = land[from][to] + Solve(boat,index+1);

	for(int i=0;i<n;++i)
		ref = min(ref, land[from][boat]+sea[boat][i]+land[i][to] + Solve(i,index+1));
	return ref;
}

int main()
{
	int m,i,j,k;
	int x,y,t;
	char c;
	while(scanf("%d%d",&n,&m),n)
	{
		memset(land,INF,sizeof(land));
		memset(sea,INF,sizeof(sea));
		for(i=0;i<n;++i)
		{
			land[i][i]=0;
			sea[i][i]=0;
		}
		while(m--)
		{
			scanf("%d%d%d %c",&x,&y,&t,&c);
			--x,--y;
			if(c=='L')
				land[y][x]=land[x][y] = min(land[y][x],t);
			else
				sea[y][x]=sea[x][y] = min(sea[y][x],t);
		}
		scanf("%d",&R);
		for(i=0; i<R; ++i)
		{
			scanf("%d",z+i);
			--z[i];
		}

		for(k=0;k<n;++k)
			for(i=0;i<n;++i)
				for(j=0;j<n;++j)
				{
					land[i][j]=min(land[i][j],land[i][k]+land[k][j]);
					sea[i][j] = min(sea[i][j],sea[i][k] +sea[k][j]);
				}

		memset(memo,-1,sizeof(memo));
		printf("%d\n",Solve(z[0],1));
	}
	return 0;
}

Measured memory_bytes: 2224
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <sstream>

using namespace std;

int main(){
    long long A, B;
    cin >> A >> B;

    if((A + B) % 2 == 0) cout << (A+B) / 2 << endl;
    else cout << "IMPOSSIBLE" << endl;


    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int ll
#define ll long long int
#define ff first
#define ss second
#define u128 __int128
#define pb push_back
 
#define N 200010
#define MOD 1000000007


int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.precision(20);
	int n;
	cin >> n;
	pair<int, int> po[n + 1];
	for (int i = 0; i < n; ++i)
	{
		cin >> po[i].ff >> po[i].ss;
	}

	sort(po, po + n, [](auto a, auto b){
		return atan2(a.ss, a.ff) < atan2(b.ss, b.ff);
	});

	double ans = 0;
	for(int len = 1; len <= n; ++len)
	{
		for(int i = 0; i < n; ++i)
		{
			int ref = i;
			int xsum = 0, ysum = 0;
			for(int k = 0; k < len; ++k)
			{
				xsum += po[ref + k].ff;
				ysum += po[ref + k].ss;
				if(ref + k == n - 1)
				{
					ref -= n;
				}
			}
			ans = max(ans, (double)sqrt((double)xsum * xsum + ysum * ysum));
		}
	}
	cout << fixed << ans;
	return 0;
}

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

int N,D;

int main()
{
	int totalInspector = 0,loc = 1;
	cin>>N>>D;

	while(1)
	{
		if(loc > N){
			break;
		}else{
			loc += D;
			totalInspector++;
			loc += D + 1;
		}
	}

	cout << totalInspector << '\n';

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;

int A,B;

int main(){
    cin>>A>>B;

    int ans=A>=13?B:A<=5?0:B/2;

    cout<<ans<<endl;
}

Measured memory_bytes: 256
n = gets.to_i
ns = gets.split.map(&:to_i)

left = Array.new(n + 1,0)
right = Array.new(n + 1,0)

(0..n - 1).each do |i|
  left[i + 1] = left[i].gcd(ns[i])
end

(n - 1).downto(0) do |i|
  right[i] = right[i+1].gcd(ns[i])
end

ans = 0

(0..n - 1).each do |i|
   left_ans = left[i]
   right_ans = right[i + 1]
   ans = [ans, left_ans.gcd(right_ans)].max
end

puts ans

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

#define rep(i, n) for(int i = 0; i < (n); i++)
using ll = long long;
constexpr ll INF = 10000000000;
const ll MOD = 1000000007;

using namespace std;

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	long long g = gcd(a, b);
	return a / g * b;
}

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

	vector<int>a(m);
	vector<int>b(m);
	rep(i, m) {
		cin >> a[i] >> b[i];
	}
	
	map<int, int>mp;
	rep(i, m) {
		mp[a[i]]++;
		mp[b[i]]++;
	}
	for(int i=1;i<n+1;i++) {
		cout << mp[i] << endl;
	}

}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
#define DEBUG 0 
#define LIMIT (LONG_MAX / 10)
#define POSITIVE_LAST_D (LONG_MAX % 10)
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;

int main(){
    char c;
    cin>>c;
    if(c>=97){
        cout<<"a"<<endl;
    }else{
        cout<<"A"<<endl;
    }

    return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;
signed main(){
    int n; cin >> n;
    vector<string> a(n);
    vector<string> b(n);
    rep(i,n){
        cin >> a[i];
        b[i] = a[i];
    }
    // bubble sort
    rep(i,n-1){
        for (int j = n-1; j > i; j--){
            if(a[j-1][1] > a[j][1]) swap(a[j],a[j-1]);
        }
    }
    rep(i,n){
        if (i == n-1) cout << a[i] << endl;
        else cout << a[i] << " ";
    }
    // as bubble sort is always stable
    cout << "Stable" << endl;
    // selection sort
    rep(i,n){
        int mn = i;
        rep2(j,i,n) if(b[j][1] < b[mn][1]) mn = j;
        if (i != mn) swap(b[i], b[mn]);
    }
    rep(i,n){
        if (i == n-1) cout << b[i] << endl;
        else cout << b[i] << " ";
    }
    // check if selection sort is stable
    bool stable = true;
    rep(i,n){
        if (b[i] != a[i]){
            stable = false;
            break;
        }
    }
    if (stable) cout << "Stable" << endl;
    else cout << "Not stable" << endl;
    return 0;
}


Measured memory_bytes: 3184
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.TreeMap;
import java.util.StringTokenizer;
import java.util.Map;
import java.util.Map.Entry;
import java.io.BufferedReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC058C solver = new ABC058C();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC058C {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int n = in.Int();
            Map<Character, Integer> map = new TreeMap<>();
            String s = in.next();
            for (char c : s.toCharArray()) {
                map.put(c, map.getOrDefault(c, 0) + 1);
            }
            for (int i = 1; i < n; i++) {
                String s2 = in.next();
                Map<Character, Integer> map2 = new TreeMap<>();
                for (char c : s2.toCharArray()) {
                    map2.put(c, map2.getOrDefault(c, 0) + 1);
                }
                for (Map.Entry<Character, Integer> e : map.entrySet()) {
                    map.put(e.getKey(), Math.min(e.getValue(), map2.getOrDefault(e.getKey(), 0)));
                }
                for (Map.Entry<Character, Integer> e : map2.entrySet()) {
                    map.put(e.getKey(), Math.min(e.getValue(), map.getOrDefault(e.getKey(), 0)));
                }
            }

            StringBuilder sb = new StringBuilder();
            for (Map.Entry<Character, Integer> e : map.entrySet()) {
                for (int i = 0; i < e.getValue(); i++) {
                    sb.append(e.getKey());
                }
            }
            out.println(sb.toString());
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    return null;
                }
            }
            return st.nextToken();
        }

        public int Int() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 24276
#include <bits/stdc++.h>
#include <algorithm>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(), (x).end()
#define PB(x) push_back(x)
#define MP(x,y) make_pair(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;


int main() {
    
    int n;
    cin >> n;
    cout<<180+180*(n-3)<<endl;


 return 0;
}


Measured memory_bytes: 256
// another code in which t-rex's tail gets a line
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cstring>
#include <cassert>
using namespace std;
#define rep(i,a,n) for (int i=a;i<(n);i++)
#define per(i,a,n) for (int i=(n)-1;i>=(a);i--)
typedef long long ll;


int main() {
    ios_base::sync_with_stdio(false);
    string s;
    ll k;
    cin >> s >> k;
    int n = s.size();
    rep(i, 0, n) {
        if (s[i] != 'a' && k >= ('z' - s[i] + 1)) {
            k -= 'z' - s[i] + 1;
            s[i] = 'a';
        }
    }
    k %= 26;
    s[n - 1] = (s[n - 1] - 'a' + k) % 26 + 'a';
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 592
#include <stdio.h>
int main(){
  int n,m,c,i,j,a,s,r=0,b[20];
  scanf("%d%d%d",&n,&m,&c);
  for(i=0;i<m;i++)scanf("%d",&b[i]);
  for(i=0;i<n;i++){
    s=c;
    for(j=0;j<m;j++){
      scanf("%d",&a);
      s+=a*b[j];
    }
    if(s>0)r++;
  }
  printf("%d",r);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main(void) {
  int rate, data, x; //割合、データ
  int ans = 0; //解答
  cin >> rate >> data >> x;

  ans = x;
  for(int i = 0; i < 10; i++) {
    ans = rate * ans - data;
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long
#define uint unsigned int



#if 0
const int MOD = (int) ;

inline int lgput(int a, int b) {
    int ans = 1;
    while(b > 0) {
        if(b & 1) ans = (1LL * ans * a) % MOD;
        b >>= 1;
        a = (1LL * a * a) % MOD;
    }
    return ans;
}

inline void mod(int &x) {
    if(x >= MOD)
        x -= MOD;
}

inline void add(int &x, int y) {
    x += y;
    mod(x);
}

inline void sub(int &x, int y) {
    x += MOD - y;
    mod(x);
}

inline void mul(int &x, int y) {
    x = (1LL * x * y) % MOD;
}

inline int inv(int x) {
    return lgput(x, MOD - 2);
}
#endif

#if 0
int fact[], invfact[];

inline void prec(int n) {
    fact[0] = 1;
    for(int i = 1; i <= n; i++) {
        fact[i] = (1LL * fact[i - 1] * i) % MOD;
    }
    invfact[n] = lgput(fact[n], MOD - 2);
    for(int i = n - 1; i >= 0; i--) {
        invfact[i] = (1LL * invfact[i + 1] * (i + 1)) % MOD;
    }
}

inline int comb(int n, int k) {
    if(n < k) return 0;
    return (1LL * fact[n] * (1LL * invfact[k] * invfact[n - k] % MOD)) % MOD;
}
#endif

using namespace std;



int main() {
#ifdef HOME
    ifstream cin("A.in");
    ofstream cout("A.out");
#endif
    int n, i;
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    string str;
    cin >> str;
    n = str.size();
    str = " " + str;

    vector <int> a(n + 2);
    ll ans = 0;
    a[0] = -1;

    i = 1;
    while(i <= n) {
        if(str[i] == '<') {
            a[i] = 0;
            int j = i;
            while(j <= n && str[j] == '<') {
                a[j + 1] = a[j] + 1;
                j++;
            }
            i = j;
        }
        else {
            int cur = a[i - 1];
            int j = i;
            while(j <= n && str[j] == '>') {
                j++;
            }
            a[i] = max(cur + 1, j - i);
            while(i < j) {
                a[i + 1] = j - i - 1;
                i++;
            }
        }
    }

    for(i = 1; i <= n + 1; i++) {
        ans += a[i];
        cerr << a[i] << " ";
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 2864
def HitandBlow( listA, listB )
	num_hit  = 0
	num_blow = 0
	4.times{ |n|
		if listA[n-num_hit] == listB[n-num_hit]
			listA.delete_at( n - num_hit)
			listB.delete_at( n - num_hit)
			num_hit += 1
		end
	}
	listA.each{ |a|
		num_blow += 1 if listB.include?( a )
	}
	return [num_hit,num_blow]
end

def main
	answers = Array.new
	while line = $stdin.gets
		listA = line.chomp.split(/\s/).map{|n| n.to_i }
		line = $stdin.gets
		listB = line.chomp.split(/\s/).map{|n| n.to_i }
		answers << HitandBlow( listA, listB )
	end
	answers.each{ |a|
		printf( "%d %d\n",a[ 0 ],a[ 1 ] )
	}
end
main


Measured memory_bytes: 6108
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include <numeric>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999

using namespace std;


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





ll gcd(ll x, ll y) {
	ll m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}

int main() {
	char Alpha[26];
	Alpha[0] = 'A';
	FOR(i, 1, 26)Alpha[i] = Alpha[i - 1] + 1;
	char alpha[26];
	alpha[0] = 'a';
	FOR(i, 1, 26)alpha[i] = alpha[i - 1] + 1;

	string S;
	cin >> S;
	int l = S.length();
	if (S[0] == 'A') {
		bool ok = false;
		int cnt = 0;
		FOR(i, 2, l - 1) {
			if (S[i] == 'C') {
				if (!ok) {
					ok = true;
					cnt = i;
				}
				else {
					cout << "WA";
					return 0;
				}
			}
		}
		if (!ok) {
			cout << "WA";
			return 0;
		}
		else {
			FOR(i, 1, l) {
				if (i == cnt)continue;
				REP(j, 26) {
					if (S[i] == Alpha[j]) {
						cout << "WA";
						return 0;
					}
				}
			}
		}
		cout << "AC" << endl;
	}
	else {
		cout << "WA";
		return 0;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=998244353,MAX=1<<18,INF=1<<30;

int main(){
    
    vector<vector<int>> A(3,vector<int>(6));
    for(int i=0;i<3;i++){
        for(int j=0;j<6;j++){
            cin>>A[i][j];
        }
    }
    
    for(int i=0;i<3;i++){
        int t=A[i][3]*3600+A[i][4]*60+A[i][5]-A[i][0]*3600-A[i][1]*60-A[i][2];
        cout<<t/3600<<" "<<(t%3600)/60<<" "<<t%60<<endl;
    }
    
}



Measured memory_bytes: 3164
#include<stdio.h>
long long CO[510][50][2];
long long R=1,C=1,H[1000010],N[1000010];
int hyouka(int a,int b){
  if(C<b)return 1;
  if(C<a||b==0)return 0;
  return N[H[a]]<N[H[b]]?1:0;
}
void hin(long long a){
  int i=C++;
  for(N[H[0]=R]=a;hyouka(0,i/2);i/=2)H[i]=H[i/2];
  H[i]=R++;
}
int hout(){
  int rt=H[1],i,j=2,k=H[--C];
  for(i=1;hyouka(i,C);i=j)H[i]=H[j=i*2+1-hyouka(i*2,i*2+1)];
  H[j/2]=k;
  return rt;
}
int id[1000010],V[1000010],F[10000010],u[510][50][2]={};
int main(){
  int n,m,i,mi,f,a,b,c,nf,v,nv;
  int ta[510],to[10010],nt[10010];
  long long ans=1e18,co[10010];
  for(i=0;i<510*50;i++)CO[i/50][i%50][0]=CO[i/50][i%50][1]=1e18;
  scanf("%d %d",&n,&m);
  for(i=0;i<=n;i++)ta[i]=-1;
  for(i=0;i<m;i++){
    scanf("%d %d %d",&a,&b,&c);
    nt[i  ]=ta[to[i+m]=a];
    nt[i+m]=ta[to[i  ]=b];
    co[ta[b]=i+m]=co[ta[a]=i]=c;
  }
  /*for(i=1;i<=n;i++){printf("%d:",i);int j;
    for(j=ta[i];j+1;j=nt[j])printf("%d ",to[j]);
    printf("\n");
    }//*/
  scanf("%d %d %d %d",&v,&a,&b,&c);
  CO[1][v][0]=0;
  mi=1;
  f=0;
  while(u[mi][v][f]-1){//printf("%lld %d %lld %d\n",CO[mi][v][f],mi,v,f);
    u[mi][v][f]=1;
    nv=(a*v+b)%c;
    for(i=ta[mi];i+1;i=nt[i]){
      nf=to[i]==n?1:f;
      if(CO[to[i]][nv][nf]>CO[mi][v][f]+co[i]*v){
	id[R]=to[i];
	V[R]=nv;
	F[R]=nf;
	hin(CO[to[i]][nv][nf]=CO[mi][v][f]+co[i]*v);
      }
    }
    while(u[mi][v][f]&&C-1){
      i=hout();
      mi=id[i];
      v=V[i];
      f=F[i];
    }
  }
  for(i=0;i<50;i++){
    if(ans>CO[1][i][1])ans=CO[1][i][1];
    //printf("%lld\n",CO[1][i][1]);
  }
  printf("%lld\n",ans);
  return 0;
}

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

int main() {
    long long W, H, x, y;
    cin >> W >> H >> x >> y;
    //(x, y)が中心点だった場合、最大値になるように分割する方法が複数存在する。
    //中心点じゃなかった場合、点(x, y)から中心点を結ぶ直線でしか長方形を二等分できないため1通りになる。
    //中心点を通ればどこから線をひいても必ず二等分にできる。
    cout << W * H / 2.0 << " " << (x + x == W && y + y == H ? 1 : 0) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
#define ll long long
#define ld long double
 
int main()
{
    ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
    string s;
    cin >> s;
    int len = s.length();
    for(int i=0;i<len;i++) s[i] = 'x';
    cout << s << endl;
}

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

int main(){
  int a[3][3];
  for(auto& i : a) for(auto& j : i) cin >> j;
  int n;
  cin >> n;
  for(int i = 0; i < n; i++){
    int b;
    cin >> b;
    for(auto& i : a) for(auto& j : i) if(j == b) j = 0;
  }
  for(int i : {0, 1, 2}){
    bool flag = 1;
    for(int j : {0, 1, 2}) if(a[i][j]) flag = 0;
    if(flag) return puts("Yes") & 0;
  }
  for(int j : {0, 1, 2}){
    bool flag = 1;
    for(int i : {0, 1, 2}) if(a[i][j]) flag = 0;
    if(flag) return puts("Yes") & 0;
  }
  {
    bool flag = 1;
    for(int i : {0, 1, 2}) if(a[i][i]) flag = 0;
    if(flag) return puts("Yes") & 0;
  }
  {
    bool flag = 1;
    for(int i : {0, 1, 2}) if(a[2 - i][i]) flag = 0;
    if(flag) return puts("Yes") & 0;
  }
  puts("No");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
//#define int long long
#define F first
#define S second
const ll INF = 1LL * 1000 * 1000 * 1000 * 1000 * 1000 * 1000;
const int inf = 1000 * 1000 * 1000;

// YE MOGHE HAII HAST KE HALE HICHI NI
// MIZARI PISH BIYAD JAYE PISHBINI
// HARKI HARJORI BASHE GIR MIDIO BE CHESH NEMIYAD HATA ... VITRINISH
// SHAYEA !

const int N = 1000 * 100 + 100,
	  MOD = 1000 * 1000 * 1000 + 7;
ll A[N], seg[4 * N];
int	dpA[N], dpB[N];

ll n, a, b;

void build(int s = 0, int e = n, int id = 1){
	if(e - s == 1){
		seg[id] = A[s + 1] - A[s];
		return ;
	}
	int mid = (s + e) / 2;
	build(s, mid, id * 2);
	build(mid, e, id * 2 + 1);
	seg[id] = min(seg[id * 2], seg[id * 2 + 1]);
}
ll get(int l, int r, int s = 0, int e = n, int id = 1){
	if(r <= l)
		return INF;
	if(e <= l || r <= s)
		return INF;
	if(l <= s && e <= r)
		return seg[id];
	int mid = (s + e) / 2;
	return min(get(l, r, s, mid, id * 2),
			get(l, r, mid, e, id * 2 + 1));
}

int32_t main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	cin >> n >> a >> b;
	for(int i = 0; i < n; i++)
		cin >> A[i];
	A[n] = INF;
	build();

	dpA[n - 1] = dpB[n - 1] = 1;
	ll k, p, q;
	for(int i = n - 2; i >= 0; i--){
		if(A[i] <= INF - a)
			k = lower_bound(A, A + n, A[i] + a) - A;
		else
			k = n;

		p = get(i + 1, k - 1);
		q = dpB[k - 1];
		if(k - 1 == i)
			q = ((ll)dpA[k] + (ll)dpB[k]) % MOD;
		if(p >= b)
			dpA[i] = q;

		if(A[i] <= INF - b)
			k = lower_bound(A, A + n, A[i] + b) - A;
		else
			k = n;
		p = get(i + 1, k - 1);
		q = dpA[k - 1];
		if(k - 1 == i)
			q = ((ll)dpA[k] + (ll)dpB[k]) % MOD;
		if(p >= a)
			dpB[i] = q;
	}

	cout << ((ll)dpA[0] + (ll)dpB[0]) % MOD << '\n';
	return 0;
}

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

int main() {
  int ans=0,N,X,T;
  cin >> N >> X >> T;

  if(N%X){
    ans = (N/X+1)*T;
  }else{
    ans = (N/X)*T;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3664
from itertools import permutations as perm
import sys
import numpy as np
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
XY = list(map(int, read().split()))
X = XY[0::2]
Y = XY[1::2]

res = 0
cnt = 0
for p in perm(range(N)):
    for i in range(N - 1):
        res += ((X[p[i + 1]] - X[p[i]])**2 + (Y[p[i + 1]] - Y[p[i]])**2)**0.5
    cnt += 1    
print(res/cnt)

Measured memory_bytes: 12388
#include <stdio.h>
#define MAX 2000000
int H,A[MAX+1];
void maxHeap(int i){
    int l,r,largest;
    int v;
    l = 2*i;
    r = 2*i+1;
    
    if(l<=H && A[l]>A[i]) largest = l;
    else largest = i;
    if(r<=H && A[r]>A[largest]) largest = r;
    if(largest!=i){
        v=A[i];
        A[i]=A[largest];
        A[largest]=v;
        maxHeap(largest);
    }
}
int main(void){
    int i;
    scanf("%d",&H);
    for(i=1;i<=H;i++) scanf("%d",&A[i]);
    
    for(i=H/2;i>=1;i--) maxHeap(i);
    
    for(i=1;i<=H;i++){
        printf(" %d",A[i]);
    }
    printf("\n");
    
    return 0;
}



Measured memory_bytes: 3680
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
int dp[500][500];

int main()
{
  cout << fixed << setprecision(10);
  int H,W;
  cin >> H >> W;
  vector<vector<int>> c(10,vector<int>(10));
  vector<vector<int>> A(H,vector<int>(W));
  rep(i,10)
  {
    rep(j,10)
    {
      cin >> c[i][j];
    }
  }
  rep(i,H)
  {
    rep(j,W)
    {
      cin >> A[i][j];
    }
  }
  for(int k=0;k<10;k++)
  {
    for(int i=0;i<10;i++)
    {
      for(int j=0;j<10;j++)
      {
        c[i][j] = min(c[i][j],c[i][k]+c[k][j]);
      }
    }
  }
  int sum = 0;
  rep(i,H)
  {
    rep(j,W)
    {
      if(A[i][j]==-1||A[i][j]==1)
      {
        continue;
      }
      else
      {
        sum += c[A[i][j]][1];
      }
      
    }
  }
  cout << sum << endl;
  return 0;
}


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

typedef long long ll;
typedef unsigned short int unsi;
typedef unsigned int uni;
typedef unsigned long int unli;

using namespace std;

int main(){
	ll A, B;
	cin >> A >> B;
	
	ll R = A % B;

	while (R!=0) {
		A = B;
		B = R;
		R = A % B;
	}

	map< ll, int > ret;
	for (ll i = 2; i * i <= B; i++) {
		while (B % i == 0) {
			ret[i]++;
			B /= i;
		}
	}
	if (B != 1) ret[B] = 1;

	ll Tmp = 0;
	int Count = 1;

	for (auto p : ret) {
		while (p.second--) {
			if (p.first > Tmp) {
				Count++;
				Tmp = p.first;
			}
		} 
	}
	cout << Count << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <vector>
#include <string>
#define INF 0x3fffffff
#define eps 1e-8
using namespace std;
char mold[100005];
int len;
int dp[10][10][2],tmp[10][10][2];
int table[]={0,-1,0,1,-1,0,1,-1,0,1};

int main()
{
    int i,j,ans,k;
    while(scanf("%s",mold))
    {
        if(mold[0]=='#')
            return 0;
        for(i=1;i<=9;++i)
            for(j=1;j<=9;++j)
                dp[i][j][1]=dp[i][j][0]=INF;
        for(i=1;i<=9;++i)
        {
            if(i==5)
                continue;
            if(table[mold[0]-'0']>table[i])
                continue;
            dp[mold[0]-'0'][i][0]=0;
        }
        for(i=1;i<=9;++i)
        {
            if(i==5)
                continue;
            if(table[i]>table[mold[0]-'0'])
                continue;
            dp[i][mold[0]-'0'][1]=0;
        }
        len=strlen(mold);
        for(i=1;i<len;++i)
        {
            memcpy(tmp,dp,sizeof(dp));
            for(j=1;j<=9;++j)
                for(k=1;k<=9;++k)
                dp[j][k][1]=dp[j][k][0]=INF;
            for(j=1;j<=9;++j)
            {
                if(j==5)
                    continue;
                if(table[j]<table[mold[i]-'0']||table[j]<table[mold[i-1]-'0'])
                    continue;
                dp[mold[i]-'0'][j][0]=tmp[mold[i-1]-'0'][j][0]+1;
            }
            for(j=1;j<=9;++j)
            {
                if(table[mold[i-1]-'0']<table[mold[i]-'0'])
                    break;
                if(j==5)
                    continue;
                if(table[j]>table[mold[i-1]-'0'])
                    continue;
                dp[mold[i]-'0'][mold[i-1]-'0'][0]=min(dp[mold[i]-'0'][mold[i-1]-'0'][0],tmp[j][mold[i-1]-'0'][1]);
            }
            for(j=1;j<=9;++j)
            {
                if(j==5)
                    continue;
                if(table[j]>table[mold[i]-'0']||table[j]>table[mold[i-1]-'0'])
                    continue;
                dp[j][mold[i]-'0'][1]=tmp[j][mold[i-1]-'0'][1]+1;
            }
            for(j=1;j<=9;++j)
            {
                if(table[mold[i-1]-'0']>table[mold[i]-'0'])
                    break;
                if(j==5)
                    continue;
                if(table[j]<table[mold[i-1]-'0'])
                    continue;
                dp[mold[i-1]-'0'][mold[i]-'0'][1]=min(dp[mold[i-1]-'0'][mold[i]-'0'][1],tmp[mold[i-1]-'0'][j][0]);
            }
        }
        ans=INF;
        for(i=1;i<=9;++i)
        {
            if(table[i]<table[mold[len-1]-'0'])
                continue;
            ans=min(ans,dp[mold[len-1]-'0'][i][0]);
        }
        for(i=1;i<=9;++i)
        {
            if(table[i]>table[mold[len-1]-'0'])
                continue;
            ans=min(ans,dp[i][mold[len-1]-'0'][1]);
        }
       /* for(i=1;i<=9;++i)
            for(j=1;j<=9;++j)
                printf("%d %d %d %d\n",i,j,dp[i][j][0],dp[i][j][1]);*/
        printf("%d\n",ans);
    }
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    int num = 0;
    for (auto i = 0; i < n; i++)
    {
        int pi;
        cin >> pi;
        p[i] = pi;
    }

    for (auto i = 0; i < n; i++)
    {
        if(p[i] != (i+1)){
            num += 1;
        }
    }

 

    if(num > 2){
        cout << "NO" << endl;
    }else{
        cout << "YES" << endl;
    }

    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  int N;
  cin>>N;
  map<int,int> A,B;
  for(int i=0;i<N;i++){
    int a;
    cin>>a;
    A[i+a]++;
    B[i-a]++;
  }
  int ans=0;
  for(pair<int,int> p:A)
    ans+=p.second*B[p.first];
  cout<<ans<<endl;
}

Measured memory_bytes: 37792