akhauriyash/Code-Regression huggingface dataset:
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#pragma GCC optimize ("O2")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define popcnt(x) __builtin_popcount(x)
#define popcntll(x) __builtin_popcountll(x)
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class CMarks {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        int N, K;
        in>>N>>K;
        vc<int> A(N);
        REP(i, N) in>>A[i];
        REP(i, N-K){
            if(A[i]<A[i+K]) out<<"Yes\n";
            else out<<"No\n";
        }
    }
};


int main() {
	CMarks solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

int main() {
  int q;
  cin >> q;
  ll ans;
  while (q--) {
    ll a, b, ab;
    cin >> a >> b;
    ab = a * b;
    ll sq = sqrt(ab);
    if (sq * (sq + 1) < ab) {
      ans = sq * 2 - 1;
    } else if (sq * sq == ab) {
      if (a == b) {
        ans = (sq - 1) * 2;
      } else {
        ans = (sq - 1) * 2 - 1;
      }
    } else {
      ans = (sq - 1) * 2;
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 3644
from collections import Counter

def check(f):
  if f >= 1.1:
    return "A"
  elif f >= 0.6:
    return "B"
  elif f >= 0.2:
    return "C"
  else:
    return "D"

dicl = Counter()
dicr = Counter()
while True:
  try:
    l, r = map(float, input().split())
    lx, rx = check(l), check(r)
    dicl[lx] += 1
    dicr[rx] += 1
  except EOFError:
    break
for alpha in ("A", "B", "C", "D"):
  print(dicl[alpha], dicr[alpha])
    


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

int main ()
{
int n;
ll ans=0;

cin >> n;

int a[n+5],b[n+5];

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

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

}

cout << ans << endl;

return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String line;
		int[] count = new int[26];
		for (int i = 0; i < 26; i++) {
			count[i] = 0;
		}
		while (sc.hasNext()) {
			line = sc.next().toLowerCase();
			for (int i = 0; i < line.length(); i++) {
				int ch = line.charAt(i) - 'a';
				if (ch >= 0 && ch < 26) {
					count[ch]++;
				}
			}
		}
		for (int i = 0; i < 26; i++) {
			char alp = (char) ('a' + i);
			System.out.println(alp + " : " + count[i]);
		}
		sc.close();
	}
}


Measured memory_bytes: 25984
#include <bits/stdc++.h>
#define ALL(x) (x).begin(),(x).end()
#define PB push_back
#define MP make_pair
#define Mod 998244353
#define MOD 1000000007
using namespace std;
using lint = long long;
using vi = vector<lint>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<lint, lint>;

// cout << fixed << setprecision(12)

lint modpow(lint a, lint n, lint m = MOD){
  lint ans = 1;
  while(n>0){
    if(n%2==1) ans *= a; 
    ans %= m;
    a *= a; 
    a %= m;
    n /= 2;
  }
  return ans;
}

lint inv(lint a, lint m = MOD){
  return modpow(a, m-2, m);
}

///////////////////////////////////

int main(){
  lint N; cin >> N;
  vi L(N);
  for(lint i=0; i<N; i++) cin >> L[i];
  
  sort(ALL(L));
  
  lint ans = 0;
  
  for(lint i=0; i<=N-3; i++){
    for(lint j=i+1; j<=N-2; j++){
      for(lint k=j+1; k<=N-1; k++){
        if(L[i]==L[j]) continue;
        if(L[j]==L[k]) continue;
        if(L[i]+L[j]>L[k]) ans++;
      }
    }
  }
  
  cout << ans << endl;
}
  

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


int main()
{
    int K, T, a[100];
    std::cin >> K >> T;
    for (int i = 0; i < T; ++ i) std::cin >> a[i];
    std::sort(a, a + T);

    printf("%d\n", a[T - 1] - 1 <= K - a[T - 1] ? 0 : a[T - 1] - 1 - (K - a[T - 1]));
}

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

int main(){
	int a1,a2,b1,b2,c1,c2;
	int counter=0;
	cin >> a1 >> b1 >>c1;

	if(a1%2==1||b1%2==1||c1%2==1){
		cout << counter << endl;
		return 0;
	}

	if(a1+b1==b1+c1&&b1+c1==a1+c1){
		cout << -1  << endl;
		return 0;
	}	

	while(1){
		a2=(b1+c1)/2;
		b2=(a1+c1)/2;
		c2=(a1+b1)/2;
		counter++;
		if(a2%2==1||b2%2==1||c2%2==1){
			cout << counter<<endl;
			return 0;
		}
		a1=a2;
		b1=b2;
		c1=c2;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define ff first
#define ss second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define boost ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define check(x) cout << #x << " : " << (x) << endl
#define all(v) v.begin(),v.end() 
//#define endl '\n'  
typedef long long ll; 
typedef unsigned long long ull; 
typedef long double ld;
typedef pair< ll , ll > mypair;
typedef priority_queue <ll> max_heap;
typedef priority_queue <ll, vector<ll>, greater<ll> > min_heap;
const ll mod=1e9+7;
const ll inf=1e15+5;
const ll N=1e5+10;

int main()
{
	boost;
	ll n,a,b;
	cin>>n>>a>>b;
	cout<<min(n*a,b);
	return 0;
} 


Measured memory_bytes: 256
/*
I am the fire that burns your skin
Soy el fuego que arde tu piel

I am the water that kills your thirst
Soy el agua que mata tu sed

The castle, the tower, I am
El castillo, la torre, yo soy

The sword that keeps the flow
La espada que guarda el caudal

You the air that I breathe
Tú el aire que respiro yo

And the moonlight on the sea
Y la luz de la luna en el mar

The throat that I want to wet
La garganta que ansio mojar

I fear drowning in love
Que temo ahogar de amor

And which desires will you give me?
¿Y cuáles deseos me vas a dar?

You say, 'my treasure just look at it'
Dices tú, 'mi tesoro basta con mirarlo'

And yours will be
Y tuyo será

And yours will be
Y tuyo será
*/
#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using dijkstra = priority_queue<T, vector<T>, greater<T>>;

typedef long long ll;
typedef unsigned long long ull;
#define fbo find_by_order  // k th index
#define ook order_of_key   // strictly smaller than k
#define PI acos(-1.0)
#define inf 0x3f3f3f3f
#define lead_zero(x) __builtin_clzll(x)
#define trail_zero(x) __builtin_ctzll(x)
#define total_1s(x) __builtin_popcountll(x)
#define first_1(x) __builtin_ffsll(x)
#define log2_(x) __builtin_clz(1) - __builtin_clz(x)
#define isLeap(x) ((x % 400 == 0) || (x % 100 ? x % 4 == 0 : false))
#define QUERY           \
    int test;           \
    scanf("%d", &test); \
    for (int _T = 1; _T <= test; _T++)
#define FAST ios_base::sync_with_stdio(0), cin.tie(0)
#define all(v) v.begin(), v.end()
#define reunique(v) v.resize(std::unique(all(v)) - v.begin())
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define ff first
#define ss second
#define MERGE(v1, v2, v) merge(all(v1), all(v2), back_inserter(v))
#define MP make_pair
#define EB emplace_back
#define read freopen("input.txt", "r", stdin)
#define write freopen("output.txt", "w", stdout)
#define in_range(v, r, l) upper_bound(all(v), r) - lower_bound(all(v), l)
#define LCM(a, b) (a / __gcd(a, b)) * b;

ll rdn(int y, int m, int d) {
    /* Rata Die day one is 0001-01-01 */
    if (m < 3)
        y--, m += 12;
    return 365 * y + y / 4 - y / 100 + y / 400 + (153 * m - 457) / 5 + d - 306;
}
/* Direction arrays */
/*int dx[] = {1,-1,0,0}, dy[] = {0,0,1,-1};                             */  // 4Direction
/*int dx[] = {1,-1,0,0,1,1,-1,-1}, dy[] = {0,0,1,-1,1,-1,1,-1};         */  // 8Direction
/* int dx[] = {1,-1,1,-1,2,2,-2,-2} , dy[] = {2,2,-2,-2,1,-1,1,-1};     */  // KnightDirection
/* int dx[] = {2,-2,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1};                */  // HexagonalDirection
/* int day[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; */
mt19937 R(chrono::system_clock().now().time_since_epoch().count());

int main() {
    ll H;
    cin>>H;
    ll ans = 0;
    ll mul = 1;
    while (H>0)
    {
        ans+=mul;
        mul = mul*2LL;
        H/=2LL;
    }
    cout<<ans<<"\n";
}


Measured memory_bytes: 256
import math

inputstrs = input().split()
n = int(inputstrs[0])
k = int(inputstrs[1])
p = map(lambda x: (0.5 ** math.ceil(math.log2(k) - math.log2(x + 1))) if x + 1 < k else 1, range(n))
print(sum(p) / n)


Measured memory_bytes: 3060
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		List<Integer> list = new ArrayList<Integer>();
		for(int i = 1; i < N; i++) {
			list.add(Integer.parseInt(sc.next()));
		}
		sc.close();
		
		list.stream().collect(Collectors.groupingBy(x -> x, Collectors.counting()));
		
		Map<Object, Long> map = list.stream().collect(Collectors.groupingBy(x -> x, Collectors.counting()));

		for(int i = 1; i < N + 1; i++) {
			if(map.get(i) == null) {
				System.out.println(0);
			}else {
				 System.out.println(map.get(i));
			}
		}
	}
}

Measured memory_bytes: 76184
#include <iostream>
#include <vector>
#include <algorithm>
#include<string>

using namespace std;

int findIt(vector <int> a, int t, int n){
    for(int i = 0; i < n; i ++ ){
        if(a[i] == t){
            return 1;
        }
    }
    return -1;
}

int main(){
    int s;
    cin >> s;
    vector<int> a(1000000);
    a[0] = s;
    int cnt = 0;
    int t = 0;
    while(findIt(a, t, cnt-1) == -1){
        if(a[cnt] % 2 == 0){
            t = a[cnt]/2;
        }else{
            t = a[cnt]*3 + 1;
        }
        cnt++;
        a[cnt] = t;
    }

    cout << cnt + 1<< endl;
}

Measured memory_bytes: 8124
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
typedef long long ll;
typedef long double ld;
int main(){
    ll a,v,b,w,t;
    cin>>a>>v>>b>>w>>t;
    bool is=false;
    if(a>b&&a-b<=(v-w)*t){
        is=true;
    }
    if(a<b&&b-a<=(v-w)*t){
        is=true;
    }
    if(is){
        cout<<"YES";
    }else{
        cout<<"NO";
    }
    return 0;
}


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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    string s;
    cin >> s;
    if(s[0] == '7' || s[1] == '7' || s[2] == '7'){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3596
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <random>

using ll = long long int;
using P = std::pair<ll, int>;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int l[30];
ll c[30],s[400][30],ans[100100];
std::vector<int> v[100100];

int main(void){
	int d,i,j,n=26,k,m=100000;
	ll ansm = -INFLL;
	for(k=0; k<m; ++k){
		for(j=0; j<n; ++j){
			v[k].push_back(j);
		}
		std::random_device seed_gen;
		std::mt19937 engine(seed_gen());
		std::shuffle(v[k].begin(), v[k].end(), engine);
	}
	std::cin >> d;
	for(i=0; i<26; ++i){
		std::cin >> c[i];
	}
	for(i=0; i<d; ++i){
		for(j=0; j<n; ++j){
			std::cin >> s[i][j];
		}
	}
	for(k=0; k<m; ++k){
		for(j=0; j<n; ++j){
			l[j] = -1;
		}
		for(i=0; i<d; ++i){
			ans[k] += s[i][v[k][i%26]];
			l[v[k][i%26]] = i;
			for(j=0; j<n; ++j){
				ans[k] -= c[j]*(i-l[j]);
			}
		}
		ansm = std::max(ansm,ans[k]);
		// std::cout << ans[k] << std::endl;
	}
	for(k=0; k<m; ++k){
		if(ans[k] == ansm){
			for(i=0; i<d; ++i){
				std::cout << v[k][i%26]+1 << std::endl;
			}
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 20904
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void solve() throws IOException {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		sc.close();

		int cnt = 0;
		int id = 0;
		for (int i = 0; i < n; i++) {
			if (id == 1) {
				System.out.println(cnt);
				return;
			}
			cnt++;
			id = a[id] - 1;
		}
		System.out.println(-1);
		return;
	}

	public static void main(String[] args) {
		try {
			solve();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

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

class Cube{
	public:
		int f[6];
		Cube(){}
		void roll_z(){ roll(1, 2, 4, 3);}
		void roll_y(){ roll(0, 2, 5, 3);}
		void roll_x(){ roll(0, 1, 5, 4);}
		void roll(int i, int j, int k, int l){
			int t = f[i]; f[i] = f[j]; f[j] = f[k]; f[k] = f[l]; f[l] = t;
		}
		void move(char ch){
			if(ch == 'E') for(int i=0;i<3;i++) roll_y();
			if(ch == 'W') roll_y();
			if(ch == 'N') roll_x();
			if(ch == 'S') for(int i=0;i<3;i++) roll_x();
		}
};

int main(){
	Cube c;
	string com;

	for(int i=0;i<6;i++) cin >> c.f[i];
	cin >> com;

	for(int i=0;i<com.size();i++) c.move(com[i]);

	cout << c.f[0] << endl;

	return 0;
}

Measured memory_bytes: 3180
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
  #  print(g1[n],g2[r],g2[n-r])
    return g1[n] * g2[r] * g2[n-r] % mod

x,y = map(int,input().split())
n = (2*y-x)/3
m = (2*x-y)/3

if n < 0 or m < 0:
    print(0)
elif int(n) != n or int(m) != m:
    print(0)
else:
    n = int(n)
    m = int(m)
    mod = 10**9+7 #出力の制限
    N = n+m
    g1 = [1, 1] # 元テーブル
    g2 = [1, 1] #逆元テーブル
    inverse = [0, 1] #逆元テーブル計算用テーブル
    
    for i in range( 2, N + 1 ):
        g1.append( ( g1[-1] * i ) % mod )
        inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
        g2.append( (g2[-1] * inverse[-1]) % mod )
    ans = cmb(n+m,n,mod)
    print(ans)

Measured memory_bytes: 118764
n = int(input())
a = list(map(int,input().split()))
a.sort()
dp = [0]*(a[-1]+1)
for i in a:
    for j in range(i, a[-1]+1, i):
        dp[j] += 1
ans = 0
for i in a:
    if dp[i]==1:
        ans += 1
print(ans)

Measured memory_bytes: 32212
from itertools import permutations

N = int(input())
P = tuple([int(x) for x in input().split()])
Q = tuple([int(x) for x in input().split()])

# Get all permutations of [1, 2, 3]
p = list(permutations([x for x in range(1, N+1)]))

a = p.index(P)
b = p.index(Q)

if a > b:
    print(a-b)
else:
    print(b-a)


Measured memory_bytes: 8052
import os, sys, re, math

N, M = [int(s) for s in input().split(' ')]

min_idx = 1
max_idx = 1e+5

for _ in range(M):
    l,r = [int(s) for s in input().split(' ')]
    min_idx = max(min_idx, l)
    max_idx = min(max_idx, r)
if max_idx >= min_idx:
    print(min(N, int(max_idx - min_idx + 1)))
else:
    print(0)


Measured memory_bytes: 45160
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <vector>
#include <cmath>
#define LL long long
using namespace std;
struct Factor
{
    int f2;
    int f5;
    Factor(int _zero) : f2(-_zero), f5(-_zero) {}
    Factor(){}
};
Factor fa[200005];
bool cmp(Factor x, Factor y){
    return x.f2 > y.f2;
}
#define L2 44
#define L5 19
LL cnt[L2][L5];
LL sum[L2][L5];

#define TR(X) (X+9)

int main()
{
    int n;
    cin >> n;
    for(int i = 0; i < L2; ++i){
        for(int j = 0; j < L5; ++j){
            cnt[i][j] = 0;
        }
    }
    for (int i = 0; i < n; ++i)
    {
        char num[20];
        scanf("%s", num);
        LL val = 0;
        int zero = 0;
        bool decimalPart = false;
        for(int j=0; num[j]; ++j){
            if(num[j] == '.')
                decimalPart = true;
            else {
                val = val * 10 + (num[j] - '0');
                if(decimalPart) zero++;
            }
        }
        fa[i] = Factor(zero);
        while(val % 2 == 0){
            val /= 2;
            fa[i].f2++;
        }
        while(val % 5 == 0){
            val /= 5;
            fa[i].f5++;
        }
        // cout<<"[Trace] str:"<<num<<"f2="<<fa[i].f2<<";f5="<<fa[i].f5<<endl;;

        cnt[TR(fa[i].f2)][TR(fa[i].f5)] ++;
    }
    for(int i = L2 - 1; i >= 0; --i){
        for(int j = L5 - 1; j >= 0; --j){
            if(i == L2 - 1 && j == L5 - 1){
                sum[i][j] = cnt[i][j];
            }
            else if (i == L2 - 1){
                sum[i][j] = sum[i][j+1] + cnt[i][j];
            }
            else if (j == L5 - 1){
                sum[i][j] = sum[i+1][j] + cnt[i][j];
            }
            else {
                sum[i][j] = sum[i+1][j] + sum[i][j+1] - sum[i+1][j+1] + cnt[i][j];
            }
            // cout<<"s["<<i<<"]["<<j<<"]="<<sum[i][j]<<" ";
        }
        // cout<<endl;
    }
    LL ans = 0;
    for (int i = 0; i < n; ++i)
    {
        int x2 = TR(-fa[i].f2);
        if(x2<0) x2 = 0;
        int x5 = TR(-fa[i].f5);
        if(x5<0) x5 = 0;
        // cout<<"[Trace] x2="<< x2<<" x5="<<x5<<" s="<<sum[x2][x5]<<endl;
        ans = ans + sum[x2][x5];
        if(fa[i].f2 >= 0 && fa[i].f5 >= 0) ans -= 1;
    }

    printf("%lld\n", ans/2);
    

}

Measured memory_bytes: 4780
#include<bits/stdc++.h>
using namespace std;
template<typename T>
inline void read(T &x)
{
	x=0;
	int f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9')
	{
		if(ch=='-') f=-1;
		ch=getchar();
}
	while(ch>='0'&&ch<='9') x=x*10+(ch^48),ch=getchar();
	x*=f;
	return;
}	
template<typename T>
void write(T x)
{
	if(x<0) putchar('-'),x=-x;
	if(x>=10) write(x/10);
	putchar(x%10+'0');
	return;
}
int a[5][5];
bool book[5][5];
int n;
int b[15];
int main()
{
    for(int i=1;i<=3;i++)
    for(int j=1;j<=3;j++) cin>>a[i][j];
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>b[i];
        for(int j=1;j<=3;j++)
        for(int k=1;k<=3;k++)
        if(b[i]==a[j][k]) book[j][k]=1;
    }
    if(book[1][1]&&book[1][2]&&book[1][3]) cout<<"Yes"<<endl;
    else if(book[2][1]&&book[2][2]&&book[2][3]) cout<<"Yes"<<endl;
    else if(book[3][1]&&book[3][2]&&book[3][3]) cout<<"Yes"<<endl;
    else if(book[1][1]&&book[2][1]&&book[3][1]) cout<<"Yes"<<endl;
    else if(book[1][2]&&book[2][2]&&book[3][2]) cout<<"Yes"<<endl;
    else if(book[1][3]&&book[2][3]&&book[3][3]) cout<<"Yes"<<endl;
    else if(book[1][1]&&book[2][2]&&book[3][3]) cout<<"Yes"<<endl;
    else if(book[3][1]&&book[2][2]&&book[1][3]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C;
  cin >> A >> B >> C;
  
  if (A != B && B != C && C != A || A == B && B == C && C == A) {
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {

    static int gcd(int a, int b){
	if(a < b){
	    int temp = a;
	    a = b;
	    b = temp;
	}
	
	while(b != 0){
	    int temp = b;
	    b = a % b;
	    a = temp;
	}
	return a;	    
    }

    static int lcm(int a, int b){
	a /= gcd(a, b);
	return a * b;
    }
    
    public static void main(String[] args){
	Scanner stdin = new Scanner(System.in);
	while(stdin.hasNextInt()){
	    int a = stdin.nextInt();
	    int b = stdin.nextInt();
	    System.out.println(gcd(a, b) + " " + lcm(a, b));
	}
    }
}

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

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define REP(i,n) for(int _n=n, i=0;i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)
#define FORD(i,a,b) for(int i=(a),_b=(b);i>=_b;--i)
using ull = uint64_t;
using ll = int64_t;
using PII = pair<int, int>;
using VI = vector<int>;

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B> string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A> string to_string(A v) {
bool first = true; string res = "{";
for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); }
res += "}"; return res; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H); debug_out(T...); }
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

const int N = 3005;
int n, t;
int A[N], B[N];
int dp[N][N][2];

int rec(int idx, int left, int last) {
    if (idx == n) {
        return 0;
    }
    if (left <= 0) {
        return 0;
    }
    if (dp[idx][left][last] != -1) return dp[idx][left][last];
    if (last == 1) {
        if (A[idx] <= left) {
            dp[idx][left][last] = max(rec(idx + 1, left - A[idx], 1) + B[idx], rec(idx + 1, left, 1));
        } else {
            dp[idx][left][last] = rec(idx + 1, left, 1);
        }
    } else {
        if (A[idx] <= left) {
            dp[idx][left][last] = max({rec(idx + 1, left - A[idx], 0) + B[idx], rec(idx + 1, left, 0), rec(idx + 1, left - 1, 1) + B[idx]});
        } else {
            dp[idx][left][last] = max(rec(idx + 1, left - 1, 1) + B[idx], rec(idx + 1, left, 0));
        }
    }
    return dp[idx][left][last];
}



int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    cin >> n >> t;
    REP(i, n) {
        cin >> A[i];
        cin >> B[i];
    }
    memset(dp, -1, sizeof dp);
    cout << rec(0, t, 0) << "\n";
}

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

int main()
{
  int N,Q;
  string S;
  cin >> N >> Q >> S;
  vector<int> pos(N+1);

  int count =0;
  for(int i=1;i<N+1;i++){
    if(S[i-1]=='A' && S[i]=='C'){
      count++;
    }
    pos[i+1]=count;
  }

  // cout << "p----" << endl;
  // rep(i,N+1) cout << pos[i] << " ";
  // cout << endl << "p----" << endl;

  //0 1 2 3 4 5 6 7 8
  // A C A C T A C G
  //0 0 1 1 2 2 2 3 3
  //     3       7
  //   2 3
  rep(i,Q){
    int l,r;
    cin >> l >> r;
    int ans=pos[r]-pos[l-1];
    // cout <<"l:"<<l<<" r:"<<r<<" S[l-2]:"<<S[l-2]<< " S[l-1]:"<< S[l-1]<< endl;
    if(S[l-2]=='A' && S[l-1]=='C'){
      ans--;
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
int arr[100100];
int dp[100100];
signed main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int q;
	cin >> q;
	for (int i = 0; i < q; i++){
		cin >> arr[i];
	}
	dp[1]= abs(arr[0] - arr[1]);
	for (int i = 2; i < q; i++){
		dp[i] = min(dp[i-1] + abs(arr[i-1] - arr[i]) , dp[i-2] + abs(arr[i-2] - arr[i]));
	}
	cout << dp[q-1];
	return 0;
}


Measured memory_bytes: 1024
/*******************************
Author:galaxy yr
LANG:C++
Created Time:2019/08/10 21:17:49
*******************************/
#include<bits/stdc++.h>
using namespace std;
const int maxn=3005;
int p,a[maxn];
int iC[maxn][maxn];
int inv[maxn],ans;
int xs[maxn][maxn];
int g[maxn];
int main(){
    scanf("%d",&p);
    for(int i=0;i<p;i++) scanf("%d",&a[i]);
    iC[0][0]=1;
    for(int i=1;i<=3000;i++){
        iC[i][0]=iC[i][i]=1;
        for(int j=1;j<i;j++) iC[i][j]=iC[i-1][j-1]+iC[i-1][j],iC[i][j]%=p;
    }
    for(int i=1;i<=3000;i++){
        for(int j=0;j<=i;j++) if((j&1)^(i&1)) iC[i][j]=p-iC[i][j];
    }
    inv[1]=1;
    for(int i=2;i<p;i++) inv[i]=(p-p/i)*inv[p%i]%p;
    inv[0]=1;
    for(int i=1;i<p;i++) inv[i]=inv[i]*inv[i-1]%p;
    for(int i=1;i<p;i++) xs[1][i]=1;
    for(int i=2;i<p;i++){
        for(int j=i;j<p;j++) xs[i][j]=(xs[i-1][j-1]+xs[i][j-1])*i%p;
    }
    for(int i=p-1;i>=1;i--){
        ans=0;
        for(int j=0;j<=i;j++) ans=(ans+iC[i][j]*a[j])%p;
        for(int j=i+1;j<p;j++){
            ans=(ans-xs[i][j]*g[j]%p+p)%p;
        }
        g[i]=ans*inv[i]%p;
    }
    g[0]=a[0];
    for(int i=0;i<p;i++) printf("%d ",g[i]);
    return 0;
}


Measured memory_bytes: 70784
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath> //abs();
using namespace std;

int main(void)
{
    long long int a,b,c,d,i,j,k,n,x[10];
    string s;
    char C[5];

    cin >> a >> b;


    cout << (a-1)*(b-1);

    return 0;
}

Measured memory_bytes: 256
N = input()
 
a = int(N[-1])
 
if a == 2 or a ==4 or a == 5 or a == 7 or a == 9:
  print('hon')
elif a == 0 or a == 1 or a == 6 or a == 8:
  print('pon')
else:
  print('bon')

Measured memory_bytes: 9120
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
	int k;
	cin >> k;
	int num[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout << num[--k] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;

bool comp(const string& x, const string& y) {
    if(x.size() > y.size()) return true;
    if(x.size() < y.size()) return false;
    for(int i = 0; i < x.size(); ++i) {
        if(x[i] > y[i]) return true;
        else if(y[i] > x[i]) return false;
    }
    return false;
}

char chr(int i) {return i + '0';}

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    vector<int> val {0,2,5,5,4,5,6,3,7,6};

    int n, m;
    cin >> n >> m;

    vector<string> dp(n + 1);
    vector<int> d(m);
    for(auto& x : d) cin >> x;

    dp[0] = "";
    vector<bool> ok(n + 1);
    ok[0] = true;

    for(int i = 1; i <= n; ++i) {
        for(auto x : d) {
            if(i - val[x] >= 0 && ok[i - val[x]]) {
                ok[i] = true;
                if(comp(dp[i - val[x]] + chr(x), dp[i])) {
                    dp[i] = dp[i - val[x]] + chr(x);
                }
            }
        }
    }

    cout << dp[n] << '\n';
}

Measured memory_bytes: 41472
# -*- coding: utf-8 -*-
from itertools import product
from collections import defaultdict
def inpl(): return list(map(int, input().split()))

MOD = 10**9 + 7

N = int(input())
DP = defaultdict(int)
for a, b, c in product(range(4), repeat=3):
    DP[(a, b, c)] = 1

DP[(0, 2, 1)] = 0
DP[(0, 1, 2)] = 0
DP[(2, 0, 1)] = 0

for i in range(N-3):
    DP2 = defaultdict(int)
    for a, b, c in product(range(4), repeat=3):
        DP2[(b, c, 0)] = (DP2[(b, c, 0)] + DP[(a, b, c)])%MOD

        if (b, c) != (0, 2) and (a, c) != (0, 2) and (a, b) != (0, 2) and (b, c) != (2, 0):
            DP2[(b, c, 1)] = (DP2[(b, c, 1)] + DP[(a, b, c)])%MOD
        if (b, c) != (0, 1):
            DP2[(b, c, 2)] = (DP2[(b, c, 2)] + DP[(a, b, c)])%MOD

        DP2[(b, c, 3)] = (DP2[(b, c, 3)] + DP[(a, b, c)])%MOD
    DP = DP2
print(sum(DP.values())%MOD)

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

lint gcd(lint x, lint y) {
  if(x == 0) { return y; }
  else { return gcd(y%x,x); }
}

lint lcm(lint x, lint y) { return x/gcd(x,y)*y; }


int main() {
  lint n; cin >> n;
  vector<lint> t(n); for(lint i=0;i<n;i++) { cin >> t[i]; }

  lint ans=t[0];
  for(lint i=1;i<n;i++) {
    ans = (lint)lcm(ans,t[i]);
  }

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

Measured memory_bytes: 256
n,q = map(int,input().split())
s = input()
ruiseki = [0 for _ in range(n)]

for index,value in enumerate(s):
    if index != 0:
        if s[index-1]+s[index] == 'AC':
            ruiseki[index] = ruiseki[index-1] + 1
        else:
            ruiseki[index] = ruiseki[index-1]

for _ in range(q):
    question = list(map(int,input().split()))
    print(ruiseki[question[1]-1] -ruiseki[question[0]-1] )

Measured memory_bytes: 6096
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    vector<ll> cnt(n);
    rep(i, n) {
        cin >> a[i];
        a[i]--;
        cnt[a[i]]++;
    }
    ll ans = 0;
    rep(i, n) {
        ans += cnt[i] * (cnt[i] - 1) / 2;
    }
    rep(k, n) {
        cout << ans - cnt[a[k]] * (cnt[a[k]] - 1) / 2 +
                    (cnt[a[k]] - 2) * (cnt[a[k]] - 1) / 2
             << endl;
    }
}

Measured memory_bytes: 4992
a=int(input())
x=[]
flag=0
for i in range(a):
    s=input()
    if i==0:
        x.append(s)
        continue
    #print(s,x[i-1])
    if s in x or x[i-1][len(x[i-1])-1]!=s[0] :
        x.append("1")
        flag=1
    else:
        x.append(s)
if flag == 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<climits>
#include<map>
#include<queue>
#include<iomanip>

using namespace std;

int main(){

	int N;

	cin >> N;

	int a[N];

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

	sort(a,a+N);

	int start = a[0];
	int end = a[N-1];

	int ans = INT_MAX;

	int count;

	for(int i = start;i <= end;i++){
		count = 0;
		for(int j = 0;j < N;j++){
	       count += (a[j]-i)*(a[j]-i);
		}
	    ans = min(ans,count);
	}

	cout << ans << endl;

	return 0;

}


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

bool dp[MAX];

bool playgame(int currentplayer,int n,int k,int steps[])
{
   
   for(int i=0;i<steps[0];i++)
   {
       dp[i]=false;
   }
   
   for(int i=steps[0];i<=k;i++)
    
    {
        for(int j=0;j<n;j++)
        {
           
            
            if(i-steps[j]>=0 && dp[i-steps[j]]==false)
            {
                dp[i]=true;
                break;
            }
        }
    
    }
   

  
   return dp[k]; 
}


void findit(int n,int k,int steps[])
{
    //1 denotes Taro
    //2 denotes Jiro
    
    //map<pair<int,int>,int> v;
    
    for(int i=0;i<=MAX;i++)
    {
        
         dp[i]=false;   
        
    }
    
    int answer=playgame(0,n,k,steps);
    
    if(answer)
    {
        cout<<"First";
    }
    
    else cout<<"Second";
    
  
}


int main()
{

    int n;
    cin>>n;
    
    int k;
    cin>>k;
    
    int steps[n];
    
    for(int i=0;i<n;i++)
    {
        cin>>steps[i];
    }
    
    findit(n,k,steps);

	return 0;
}


Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

class Main {
	
	static class BinarySearch {
		public void binarysearch (InputReader ir) {
			
			int count = 0;
			int n = ir.nextInt();
			int[] array = new int[n];
			
			for (int i = 0; i < n; i++) {
				array[i] = ir.nextInt();
			}
			
			Arrays.sort(array);
			
			int q = ir.nextInt();
			int[] array2 = new int[q];
			
			for (int i = 0; i < q; i++) {
				array2[i] = ir.nextInt();
			}
			 
			for (int i = 0; i < q; i++) {
				int left = 0;
				int right = n;
		            		        
				while (left < right) {
					int mid = (left + right)/2;   
					if (array2[i] == array[mid]) {
						count++;
						break;
						}    
					else if (array2[i] < array[mid]) right = mid;    
					else left = mid + 1;
		            
				}    
			}
			System.out.println(count);
		}
	}
	
	static class InputReader {
		BufferedReader br;
		StringTokenizer st;
		
		public String nextString() {
			
			 while (!st.hasMoreTokens()) {
	                try {
	                    st = new StringTokenizer(br.readLine(), " ");
	                } catch (IOException e) {
	                    throw new InputMismatchException();
	                }
	            }
			return st.nextToken();
		}
		
		public int nextInt() {
			return Integer.parseInt(nextString());
		}
					
		public InputReader (InputStream inputStream) {
			br = new BufferedReader (new InputStreamReader (inputStream));
			st = new StringTokenizer ("");
		}
		
	}
	
	public static void main (String[] args) {
		InputStream inputStream = System.in;
		InputReader in = new InputReader (inputStream);
		BinarySearch obj = new BinarySearch ();
		obj.binarysearch (in);
	}
}



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

vector<vector<int> > v;
void lex_permute(int a[],int n,int level)
{
	if(level == n)
	{
        vector<int> temp;
		for(int i=0;i<n;i++)
        {
            temp.push_back(a[i]);
        }
        v.push_back(temp);
			// cout<<a[i]<<" ";
		// cout<<endl;
	}

	for(int i=level;i<n;i++)
	{
		// right rotate 1 unit
		int t = a[i];
		for(int j=i;j>level;j--)
		{
			a[j] = a[j-1];
		}
		a[level] = t;

		lex_permute(a,n,level+1);

		// left rotate by 1 unit to balance the change for the next branch
		t = a[level];
		for(int j=level;j<i;j++)
		{
			a[j] = a[j+1];
		}
		a[i] = t;

	}
}
int main()
{
    int n;
    cin >> n ;
    int a[n];
    for(int i=0;i<n;i++)
        a[i] = i+1;
    int p[n],q[n];
    for(int i=0;i<n;i++)
        cin >> p[i];
    for(int i=0;i<n;i++)
        cin >> q[i];
    lex_permute(a,n,0);
    int c1=0,c2=0;
    for(int i=0;i<v.size();i++)
    {
        int flag=0;
        int ind = i;
        for(int j=0;j<v[i].size();j++)
        {
            if( v[i][j] != p[j] )
            {
                flag=1;
                
                break;
            }
        }
        if(flag==0)
        {
            c1 = ind;
            break;
        }
    }

    for(int i=0;i<v.size();i++)
    {
        int flag=0;
        int ind = i;
        for(int j=0;j<v[i].size();j++)
        {
            if( v[i][j] != q[j] )
            {
                flag=1;
                
                break;
            }
        }
        if(flag==0)
        {
            c2 = ind;
            break;
        }
    }
    cout << abs(c1-c2) << endl;
}

Measured memory_bytes: 3256
import java.util.*;
public class Main{
  public static void main(String[] args){
  Scanner sc = new Scanner(System.in);
  int a = Integer.parseInt(sc.next());
  int b = Integer.parseInt(sc.next());
  if ((a+b)%2==0){
    System.out.println((a+b)/2);
  }
  else {
    int ans = (a+b)/2;
    System.out.println(ans+1);
  }
  }
}


Measured memory_bytes: 21844
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    long n = Long.parseLong(str[0]);
    long k = Long.parseLong(str[1]);
    System.out.println(n%k<=k-n%k?n%k:k-n%k);
  }
}



Measured memory_bytes: 32200
/*Lucky_Glass*/
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
const string goal="AKIHABARA";
int main()
{
	string str;
	cin>>str;
	int len=str.length();
	bool right=true;
	int i=0,j=0;
	for(;i<len && j<9;)
	{
		if(str[i]==goal[j]) {i++,j++;continue;}
		if(goal[j]=='A') {j++;continue;}
		right=false;
		break;
	}
	while(j<9 && goal[j]=='A') j++;
	if(i<len || j<9) right=false;
	printf("%s\n",right? "YES":"NO");
	return 0;
}


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

const int MOD = 1000000007;
const int INF = 1e9;

int main(){
  int n;
  const int max_n = 100;
  int d1[101], d2[101];
  cin >> n;
  for(int i = 0; i < n; i++) cin >> d1[i] >> d2[i];

  int cnt = 0;
  string ans = "No";
  for(int i = 0; i < n; i++){
    if(d1[i] == d2[i]) {
      cnt ++;
    }else{
      cnt = 0;
    }
    if(cnt == 3) ans = "Yes";
  }
  cout << ans << endl;
  

  return 0;
}

Measured memory_bytes: 3616
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<complex>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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

using Graph=vector<vector<ll>>;

#define ketasitei setprecision(15) //15桁表示

const ll MOD = 1000000007;


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

	vector<vector<int>> a(3, vector<int>(3));
	rep(i, 3)
	{
		rep(j, 3)
		{
			cin >> a[i][j];
		}
	}
	int n;
	cin >> n;
	vector<int> b(n);
	rep(i, n)
	{
		cin >> b[i];
		rep(j, 3)
		{
			rep(k, 3)
			{
				if (a[j][k] == b[i])
					a[j][k] = 0;
			}
		}
	}

	rep(i, 3)
	{
		rep(j, 3)
		{
			if (a[i][j] == 0)
			{
				if (j == 2)
				{
					cout << "Yes" << endl;
					ret;
				}
			}
			else
				break;
		}
	}
	rep(i, 3)
	{
		rep(j, 3)
		{
			if (a[j][i] == 0)
			{
				if (j == 2)
				{
					cout << "Yes" << endl;
					ret;
				}
			}
			else
				break;
		}
	}

	if (a[0][0] == 0 && a[1][1] == 0 && a[2][2] == 0)
	{
		cout << "Yes" << endl;
		ret;
	}
	if (a[0][2] == 0 && a[1][1] == 0 && a[2][0] == 0)
	{
		cout << "Yes" << endl;
		ret;
	}

	cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int H, W;
	scanf("%d%d", &H, &W);
	char S[H][W];
	for (int i = 0; i < H; i++) {
		scanf("%s", S[i]);
	}

	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (S[i][j] == '#') {
				putchar('#');
			} else {
				int n = 0;
				for (int dy = -1; dy <= 1; dy++) {
					int y = i + dy;
					for (int dx = -1; dx <= 1; dx++) {
						int x = j + dx;
						if (y < 0 || y >= H || x < 0 || x >= W) {
							continue;
						}
						if (S[y][x] == '#') {
							n++;
						}
					}
				}
				putchar('0' + n);
			}
		}
		putchar('\n');
	}
	return 0;
}


Measured memory_bytes: 128
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"

using namespace std;

const long long int MOD = 1000000007;
const long double PI = 3.1415926535897932384626433;

long long int N, M, K, H, W, L, R;

struct Box {
	long long int a;
	long long int b;
	bool operator <(const Box& bo)const {
		return (a - b) < bo.a - bo.b;
	}
	bool operator >(const Box& bo)const {
		return (a - b) > bo.a - bo.b;
	}
};

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

	cin >> N;
	long long int ans = 0;
	vector<Box>v(N);
	for (int i = 0; i < N; i++) {
		cin >> M >> K;
		Box bo;
		bo.a = M;
		bo.b = K;
		v[i] = bo;
		ans += M;
	}
	sort(v.begin(), v.end());
	if (v[0].a - v[0].b == 0) {
		cout << 0 << endl;
		return 0;
	}
	K = LLONG_MAX;
	for (auto i : v) {
		if (i.a - i.b > 0) {
			K = min(i.b, K);
		}
	}
	cout << ans - K << endl;
	return 0;
}

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

int main(void) {
    double r;
    double pi = 3.14159265359;
    cin >> r;
    
    printf("%.6lf %.6lf", r * r * pi, 2 * r * pi);
    cout << endl;
    return 0;
}




Measured memory_bytes: 3280
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <tuple>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int n;
int p[50];

signed main() {
	int i, j, k;
	
	cin >> n;
	rep(i, n) cin >> p[i];
	
	rep(i, n) {
		for (j = i; j < n; j++) {
			swap(p[i], p[j]);
			rep(k, n - 1) {
				if (p[k] > p[k + 1]) break;
			}
			if (k == n - 1) { cout << "YES" << endl; return 0; }
			swap(p[i], p[j]);
		}
	}
	
	cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int k = saori.saori_hayami();
		int n = saori.saori_hayami();
		int[] a = new int[n];
		int[] sa = new int[n];
		int num = 0;
		for(int i = 0; i < n;i++){
			a[i] = saori.saori_hayami();
		}
		for(int i = 0;i < n-1;i++){
			sa[i] = a[i+1] - a[i];
		}
		sa[n-1] = a[0] + (k - a[n-1]);
		Arrays.sort(sa);
		for(int i = 0;i < n-1;i++){
			num += sa[i];
		}
		System.out.println(num);
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 26536
#include <bits/stdc++.h>
#define int long long
#define moder (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % moder;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), moder - 2, moder) % moder * mod_pow(kai(y), moder - 2, moder) % moder;
}
/*--------Library Zone!--------*/


signed main() {
	int a, b; cin >> a >> b;
	cout << max({ a + b,a + a - 1, b + b - 1 }) << endl;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> vec(n);
  rep(i,n){
    cin >> vec.at(i);
  }
  double rev = 0;
  rep(i,n){
    rev += (1.0 / vec.at(i));
  }
  double ans = 1/rev;
  cout << ans;

  return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC return 0;
using namespace std;
int a, b;
int main() {
    DAU
    cin >> a >> b;
    if (a <= b)
        cout << "unsafe";
    else cout << "safe";
    PLEC
}


Measured memory_bytes: 3664