akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int INF = 100000000;
const int MOD = 1000000007;
int main(){
  std::vector<int> a(3);;
  std::cin >> a[0]>>a[1]>>a[2];
  sort(all(a));
  if(a[0]==5&&a[1]==5&&a[2]==7){
    std::cout << "YES" << std::endl;
  }else{
    std::cout << "NO" << std::endl;
  }
}


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

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

void solve() {
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }

    vector<int> dp(K + 1);
    for (int i = 0; i < K + 1; i++) {
        bool flag = true;
        for (int j = 0; j < N; j++) {
            if (i - A[j] < 0) continue;
            if (dp[i - A[j]] == 1) flag = false;
        }
        if (flag) {
            dp[i] = 1;
        } else {
            dp[i] = 0;
        }
    }

    if (dp[K]) {
        cout << "Second" << endl;
    } else {
        cout << "First" << endl;
    }

}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}

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

ll v[3100][3100], dp[3100][3100][4];
void chmax(ll &a, ll b){ if(a < b)a = b;}
void chmin(ll &a, ll b){ if(a > b)a = b;}

int main(){
    int R, C, K; cin >> R >> C >> K;
    for(int i = 0; i < K; i++){
        ll r, c, t; cin >> r >> c >> t;
        v[r][c] = t;
    }
    for(int i = 0; i <= R; i++){
        for(int j = 0; j <= C; j++){
            for(int k = 0; k <= 3; k++){
                if(i - 1 >= 0){
                    chmax(dp[i][j][0], dp[i-1][j][k]);
                    chmax(dp[i][j][1], dp[i-1][j][k] + v[i][j]);
                }
                if(j - 1 >= 0){
                    chmax(dp[i][j][k], dp[i][j-1][k]);
                    if(k - 1 >= 0) chmax(dp[i][j][k], dp[i][j-1][k-1] + v[i][j]);
                }
            }
        }
    }
    ll res = 0;
    rep(k,4) chmax(res, dp[R][C][k]);
    cout << res << endl;
}

Measured memory_bytes: 366836
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
#define F(i,a,b) for(int i=int(a);i<=int(b);i++)
#define endl "\n"
#define ios std::ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define out(x) cout<<x<<endl,exit(0);
#define pb push_back
#define all(v) v.begin(),v.end()
#define I first
#define S second

const int N=3003;
long double dp[N][N],ph[N],pt[N],cur=1,sum;

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

	F(i,1,n){
		cin>>ph[i];
		pt[i]=1-ph[i];
	}

	F(i,0,n){
		dp[i][0]=cur;
		cur*=pt[i+1];
	}

	F(i,1,n){
		F(j,1,n){
			dp[i][j]=dp[i-1][j]*pt[i]+dp[i-1][j-1]*ph[i];
		}
	}

	F(i,n/2+1,n) sum+=dp[n][i];
	cout<<setprecision(12)<<sum;
}

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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define foreach(e, v) for (auto &e : v)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
const int MOD = 1e9 + 7;
const int INF = __INT_MAX__;               // 2^31 - 1
const long long INFLL = __LONG_LONG_MAX__; // 2^61 - 1
const int MAX_N = 1e5 + 5;
const double PI = acos(-1);

struct mint {
    // Preparation: MOD is already defined.
    ll value;

    mint(ll value = 0) : value((value % MOD + MOD) % MOD) {}

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    mint pow(mint m) const {
        return pow(m.value);
    }

    mint inv() const {
        ll a = value, b = MOD, u = 1, v = 0;
        while (b) {
            ll t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        u %= MOD;
        return u;
    }

    mint &operator+=(const mint a) {
        if ((value += a.value) >= MOD) value -= MOD;
        return *this;
    }
    mint &operator-=(const mint a) {
        if ((value += MOD - a.value) >= MOD) value -= MOD;
        return *this;
    }
    mint &operator*=(const mint a) {
        (value *= a.value) %= MOD;
        return *this;
    }
    mint &operator/=(const mint a) {
        return (*this) *= a.inv();
    }

    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

int main() {
    int n;
    cin >> n;
    set<int> m;
    rep(i, n) {
        int x;
        cin >> x;
        m.insert(x);
    }

    int k = m.size();
    out(k - (k + 1) % 2);
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
typedef long double ld;

const ld PI = 3.14159265358979323846;

ld min(ld x, ld y)  
{  
    return (x < y)? x: y;  
      
}
ld calcAngle(ld h, ld m)  
{    
     
  
    if (h == 12) h = 0;  
    if (m == 60) m = 0;  
 
    ld hour_angle = 0.5 * (h * 60 + m);  
    ld minute_angle = 6 * m;  
    ld angle = abs(hour_angle - minute_angle);  
	angle = min(360 - angle, angle);  
  	
    return angle;  
}
int main()
{
	ld a,b,h,m;
	cin>>a>>b>>h>>m;
	ld d=calcAngle(h,m);
	ld c= (a*a)+(b*b) - (2*a*b*cos(d* PI /180));
	cout<< fixed <<setprecision(20)<<sqrt(c);
}

Measured memory_bytes: 4172
#include<iostream>
#include<math.h>
#include<string.h>
#include<vector>
#include<algorithm>
#include<iomanip>
using namespace std;

int main(){
	int h,w;
	cin >> h >> w;
	string s[h];
	
	for(int i=0;i<h;i++){
		cin >> s[i];
	}
	
	int cnt;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(s[i][j]=='.'){
				cnt=0;
				if(i>=1){
					if(s[i-1][j]=='#')cnt++;
				}
				if(i<h-1){
					if(s[i+1][j]=='#')cnt++;
				}
				if(j>=1){
					if(s[i][j-1]=='#')cnt++;
				}
				if(j<w-1){
					if(s[i][j+1]=='#')cnt++;
				}
				if(i>=1 && j>=1){
					if(s[i-1][j-1]=='#')cnt++;
				}
				if(i<h-1 && j<w-1){
					if(s[i+1][j+1]=='#')cnt++;
				}
				if(i<h-1 && j>=1){
					if(s[i+1][j-1]=='#')cnt++;
				}
				if(i>=1 && j<w-1){
					if(s[i-1][j+1]=='#')cnt++;
				}
				cout << cnt;
			}else{
				cout << '#';
			}
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 384
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    string S;
    cin>>S;
    int a=0,b=S.size()-1;
    int ans=0;
    while(a<b){
        if(S[a]==S[b]){
            a++;
            b--;
            continue;
        }
        if(S[a]=='x'){
            a++;
            ans++;
            continue;
        }
        if(S[b]=='x'){
            b--;
            ans++;
            continue;
        }
        if(S[a]!=S[b]){
            puts("-1");
            return 0;
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

int main() {
    int n; cin >>n;
    vector<int> a(3*n);
    for (int i = 0; i < 3*n; i++) cin >>a.at(i);
    sort(a.begin(), a.end());
    long long ret = 0;
    int at = 3*n-2;
    for (int i = 0; i < n; i++) {
        ret += a.at(at);
        at -= 2;
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 1408
import Control.Applicative
import Text.Printf

mdist :: Floating a => [a] -> [a] -> a -> a
mdist xs ys p = sum [abs (x - y) ** p | (x, y) <- zip xs ys] ** (1 / p)

cdist :: (Floating a, Ord a) => [a] -> [a] -> a
cdist xs ys = maximum [abs (x - y) | (x, y) <- zip xs ys]

main :: IO ()
main = do
    _ <- getLine
    xs <- (map (read :: String -> Double) . words) <$> getLine
    ys <- (map (read :: String -> Double) . words) <$> getLine
    ((\[p1, p2, p3] -> printf "%.6f\n%.6f\n%.6f\n" p1 p2 p3) . map (mdist xs ys)) [1.0, 2.0, 3.0]
    printf "%.6f\n" (cdist xs ys)

Measured memory_bytes: 4580
from collections import Counter

n, *a = map(int, open(0).read().split())
n += 1


def cmb(n, r, mod=10 ** 9 + 7):
    if r < 0 or r > n:
        return 0
    r = min(r, n - r)
    return g1[n] * g2[r] * g2[n - r] % mod


def make_table(n, mod=10 ** 9 + 7):
    N = n
    # 元テーブル
    g1 = [0] * (N + 1)
    g1[0] = 1
    g1[1] = 1

    # 逆元テーブル
    g2 = [0] * (N + 1)
    g2[0] = 1
    g2[1] = 1

    # 逆元テーブル計算用テーブル
    inverse = [0] * (N + 1)
    inverse[0] = 0
    inverse[1] = 1

    for i in range(2, N + 1):
        g1[i] = (g1[i - 1] * i) % mod
        inverse[i] = (-inverse[mod % i] * (mod // i)) % mod
        g2[i] = (g2[i - 1] * inverse[i]) % mod

    return tuple(g1), tuple(g2), tuple(inverse)


d = Counter(a).most_common(1)[0][0]
lr = [i for i, e in enumerate(a) if e == d]
l = lr[1] - lr[0] + 1
g1, g2, inverse = make_table(n)
MOD = 10 ** 9 + 7

answer = [(cmb(n, i) - cmb(n - l, i - 1)) % MOD for i in range(1, n + 1)]
print('\n'.join(map(str, answer)))


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

class MainClass
{
   
    public static void Main(string[] args)
    {
        Console.WriteLine( (float)LnInt() * 2 * Math.PI);

    }

   
    public static int[] LnInts()
    {
        var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
        var ins = new int[vs.Length];
        for (int i = 0; i < vs.Length; i++) ins[i] = int.Parse(vs[i]);
        return ins;
    }

    public static int LnInt()
    {
        var vs = Console.ReadLine().Trim();
        return int.Parse(vs);
    }

    public static string[] LnStrs()
    {
        var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
        return vs;
    }
    public static string LnStr()
    {
        var vs = Console.ReadLine().Trim();
        return vs;
    }
}

Measured memory_bytes: 18664
#include<bits/stdc++.h>
    #include <ext/pb_ds/assoc_container.hpp> 
    #include <ext/pb_ds/tree_policy.hpp> 
    using namespace std;
    using namespace __gnu_pbds; 
    #define lli long long int
    #define fr(i,a,b) for(lli i=a;i<b;i++)
    #define bfr(i,a,b) for(lli i=a;i>=b;i--)
    #define fio ios_base::sync_with_stdio(false); cin.tie(NULL),cout.tie(NULL);
    #define tc int t;cin>>t;while(t--)
    #define mod 1000000007LL
    #define mod2 998244353LL
    #define all(vec) vec.begin(),vec.end()  
    #define ld long double
    #define pb push_back

    #define ordered_set tree<lli, null_type,less<lli>, rb_tree_tag,tree_order_statistics_node_update> 


       int main()
    {
                           
             

            
                        
              fio   
             
              lli x;
              cin>>x;
              set<lli> s;
              map<lli,lli> m;
              fr(i,1,5001){s.insert(i*i*i*i*i);m[i*i*i*i*i]=i;}

              fr(i,-5000,5001)
              if(s.find(x+(i*i*i*i*i))!=s.end())
                {cout<<m[x+(i*i*i*i*i)]<<" "<<i;break;}
return 0;}

Measured memory_bytes: 4220
main :: IO ()
main = do
    _ <- getLine
    a <- getLine >>= return . words >>=  return . map read :: IO [Int]
    print $ solve 1000000007 a

solve :: Int -> [Int] -> Int
solve m xs = (`mod` m) . sum $ zipWith (\x y -> x * y `mod` m) xs . scanr (\x acc -> x + acc `mod` m) 0 $ tail xs


Measured memory_bytes: 136780
N=int(input())
ans = [0]*N
for x in range(1,101):
    for y in range(1,101):
        for z in range(1, 101):
            n = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if N >= n:
                ans[n-1] += 1
for i in ans:
    print(i)

Measured memory_bytes: 9028
#[allow(dead_code)]
fn main() {
    let n = i::u();
    let ab = i::iv2(n);
    let mut sum: Vec<i64> = ab.iter().map(|k| k.0 + k.1).collect();
    let mut all_sum: i64 = ab.iter().map(|ab| ab.0).sum();
    if n == 1 {
        println!("{}", all_sum);
        return;
    }
    sum.sort();
    sum.reverse();
    let mut i = 1;
    loop {
        all_sum -= sum[i];
        i += 2;
        if i >= n {
            break;
        }
    }
    println!("{}", all_sum);
}

#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::num::*;
#[allow(unused_imports)]
use std::str::*;

#[allow(dead_code)]
mod i {
    use super::*;

    pub fn read<T: FromStr>() -> T {
        stdin()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .ok()
            .unwrap()
    }

    pub fn str() -> String {
        read()
    }

    pub fn s() -> Vec<char> {
        str().chars().collect()
    }

    pub fn i() -> i64 {
        read()
    }

    pub fn u() -> usize {
        read()
    }

    pub fn u2() -> (usize, usize) {
        (read(), read())
    }

    pub fn u3() -> (usize, usize, usize) {
        (read(), read(), read())
    }

    pub fn f() -> f64 {
        read()
    }

    pub fn c() -> char {
        read::<String>().pop().unwrap()
    }

    pub fn iv(n: usize) -> Vec<i64> {
        (0..n).map(|_| i()).collect()
    }

    pub fn iv2(n: usize) -> Vec<(i64, i64)> {
        (0..n).map(|_| iv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv(n: usize) -> Vec<usize> {
        (0..n).map(|_| u()).collect()
    }

    pub fn uv2(n: usize) -> Vec<(usize, usize)> {
        (0..n).map(|_| uv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv3(n: usize) -> Vec<(usize, usize, usize)> {
        (0..n).map(|_| uv(3)).map(|a| (a[0], a[1], a[2])).collect()
    }

    pub fn fv(n: usize) -> Vec<f64> {
        (0..n).map(|_| f()).collect()
    }

    pub fn cmap(h: usize) -> Vec<Vec<char>> {
        (0..h).map(|_| s()).collect()
    }
}


Measured memory_bytes: 6396
#include <bits/stdc++.h>
using namespace std;
#define int                     long long int
#define ld                      long double
#define pb                      push_back
#define MOD                     1000000007
#define inf                     3e18
#define vi                      vector<int>
#define vld                     vector<ld>
#define pii                     pair<int,int>
#define mii                     map<int,int>
#define fi                      first
#define se                      second
#define fastIO                  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << " "<< name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

void inp_out()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
    #endif
}

int32_t main()
{
	fastIO
	inp_out();
	int N;
	cin>>N;
	int ans=0;
	for(int i=2;i*i<=N;++i)
	{
		int cnt=0;
		while(N%i==0)
		{
			N/=i;
			++cnt;
		}		

		if(cnt==0)
			continue;

	//	db(i,cnt);
		cnt*=2;
		int temp=sqrt(cnt);

		if(temp * (temp+1)<=cnt)
		{
			ans+=temp;
		}

		else ans+=temp-1;

	//	db(ans);

	}

	if(N>2)
		ans++;

	cout<<ans;
	return 0;
}

Measured memory_bytes: 3696
/******************************************************************************

Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
C#, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
Code, Compile, Run and Debug online from anywhere in world.

*******************************************************************************/
#include <cstdio>
#include <iostream>
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b;
    if(a%2==1 && b%2==1){
        printf("Yes");
    }
    else{
        printf("No");
    }
}


Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll mod=1e9+7;
int dy[]={1,-1,0,0};
int dx[]={0,0,1,-1};

int main(){
  int n;
  cin>>n;
  for(int i=n;i<1000;i++){
      int n1=i%10;
      int n2=(i/10)%10;
      int n3=i/100;
      if(n1==n2&&n2==n3){
          cout<<i<<endl;
          return 0;
      }
  }
  return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define _GLIBCXX_DEBUG
#define V vector<ll>
using namespace std;
using ll = long long;

int main() {
   int a,b,c,x;
   cin>>a>>b>>c>>x;
   int ans=0;
   rep(i,0,a+1){
      rep(j,0,b+1){
         rep(k,0,c+1){
            if(i*500+j*100+k*50==x) ans++;
         }
      }
   }
   cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
using edge = struct { int to; int cost; };
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; }
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  IOS;
  int h,w; cin >> h >> w;
  int a[h][w];
  REP(i,h) REP(j,w) cin >> a[i][j];

  vector<tuple<int,int,int,int>> ans;
  REP(i,h-1) {
    REP(j,w) {
      if(a[i][j]%2==0) continue;
      a[i][j]--; a[i+1][j]++;
      ans.push_back( make_tuple(i,j,i+1,j) );
    }
  }
  REP(j,w-1) {
    if (a[h-1][j]%2==0) continue;
    a[h-1][j]--; a[h-1][j+1]++;
    ans.push_back( make_tuple(h-1,j,h-1,j+1) );
  }

  cout << ans.size() << endl;
  for(auto x: ans) {
    int x1,y1,x2,y2;
    tie(x1,y1,x2,y2) = x;
    x1++,y1++,x2++,y2++;
    cout << x1 << " " << y1 << " " << x2 << " " << y2 << endl;
  }
  return 0;
}

Measured memory_bytes: 6308
// Created by AboAbdoMC
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long

using namespace std;
using namespace __gnu_pbds;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

const int OO = 1e9+7;
const int MOD = 1e9+7;
const int N = 1e5+7;



int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s,t;
    cin >> s >> t;
    int ans = 0;
    rep(i,3) if (s[i] == t[i]) ans++;
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
using namespace std;
int bubble(int a[], int n) {
    int flag = 1;
    int count = 0;
    while(flag) {
        flag = 0;
        for(int i = n-1; i > 0; i--) {
            if(a[i] < a[i-1]) {
                a[i] = a[i] + a[i-1];
                a[i-1] = a[i] - a[i-1];
                a[i] = a[i] - a[i-1];
                count++;
                flag = 1;
            }
        }
    }
    for(int i = 0; i < n; i++) {
        if(i != 0) printf(" ");
        printf("%d", a[i]);
    }
    printf("\n");
    return count;
}
int main() {
    int n;
    scanf("%d", &n);
    int a[n];
    for(int i = 0; i < n; i++) scanf("%d", &a[i]);
    printf("%d\n", bubble(a, n));
}


Measured memory_bytes: 2732
//#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define ll long long
#define ld long double
#define pi pair<int,int>
#define pd pair<ld,ld>
#define ft first
#define sd second
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define FOR(i,a,b) for(int i=(a); i<=(b);i++)
#define F(i,a,b) FOR(i,(a),(b)-1)
#define REV(i,a,b) for(int i=(a); i>=(b);i--)
#define VI vector<int>
#define VPI vector<pi>
#define VPD vector<pd>
#define PI 3.14159265
#define all(x) (x).begin(), (x).end()
#define sz(a) (int)((a).size())
#define int long long

template<class TH> void _dbg(const char *sdbg, TH h){cerr<<sdbg<<"="<<h<<"\n";}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
    while(*sdbg!=',')cerr<<*sdbg++;cerr<<"="<<h<<","; _dbg(sdbg+1, a...);
}
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
mt19937 r(chrono::steady_clock::now().time_since_epoch().count());
int rand_range(int a, int b)
{
    assert(a<=b);
    return a+r()%(b-a+1);
}
const long long K = 1000;
const long long KK = K*K;
const long long MIL = KK*K;
const long long INF = MIL*MIL;
const long long MOD = MIL+7;
const long long N = 1e6 + 10, M=10;

void solve(){
    int n;
    cin >> n;
    VPI v(n);
    F(i, 0, n)
        cin >> v[i].ft >> v[i].sd;
    ld res = 0;
    sort(all(v));
    int licznik = 0;
    do {
        licznik++;
        F(i,1,n) {
            ld a = v[i].ft - v[i - 1].ft;
            ld b = v[i].sd - v[i - 1].sd;
//            debug(sqrt(a * a + b * b));
            res += sqrt(a * a + b * b);
        }
    }while(next_permutation(all(v)));
    cout << res / licznik;
}

int32_t main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cerr.tie(0);
    cout<<setprecision(9)<<fixed;
    cerr<<setprecision(6)<<fixed;
    int test = 1, f;
    //cin>>test;
    F(_test, 0, test){
        //cout<<"Case #"<<_test + 1<<": ";
        solve();
//		if(_test == 1)
//            return 0;
    }
}


Measured memory_bytes: 256
while True:
	h,w = map(int,input().split())
	if h==0 and w==0:
		break
	for j in range(h):
		for i in range(w):
			if (i+j)%2==0:
				print("#",end="")
			else:
				print(".",end="")
		print()
	print()





Measured memory_bytes: 7004
//二重ループは真ん中で分ける！
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)

int main(){
    int n; cin >> n;
    ll ans=0;
    vector<ll> a(n); rep(i,n) cin >> a[i];
    vector<ll> b(n); rep(i,n) cin >> b[i];
    vector<ll> c(n); rep(i,n) cin >> c[i];
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());
    
    rep(i,n){
        auto it_a = lower_bound(a.begin(),a.end(),b[i]);
        ll index_a = it_a - a.begin();
        
        auto it_c = upper_bound(c.begin(),c.end(),b[i]);
        ll index_c = it_c - c.begin();
        // cout << index_a << index_c << endl;
        ans += (n-index_c)*(index_a);
        
    }
    
    cout << ans << endl;
}

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

void ins(int [],int);

int main(){
	int n,a[100];
	cin >> n;
	for(int i=0;i<n;i++) cin >>a[i];
	for(int k=0;k<n;k++){
		cout << a[k];
		if(k!=n-1) cout << " ";
	}
	cout << endl;
	ins(a,n);

	return 0;
}

void ins(int a[],int n){
	int w;
	for(int i=1;i<n;i++){
		for(int j=i-1;j>=0;j--){
			if(a[j+1] > a[j]) break;
			w=a[j+1];
			a[j+1]=a[j];
			a[j]=w;
		}
	for(int k=0;k<n;k++){
		cout << a[k];
		if(k!=n-1) cout << " ";
	}
	cout << endl;
	}
}

Measured memory_bytes: 1160
#include<stdio.h>
int main(){
    int ary[20];
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)scanf("%d",&ary[i]);
    int maxnum=0,gt=0;
    for(int i=0;i<n;i++){
        if(ary[i]>=maxnum){
            maxnum=ary[i];
            gt++;
        }
    }
    printf("%d\n",gt);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <map>
#include <cmath>

using namespace std;
typedef long long ll;
ll n;

ll F(ll x) {
    ll ret = 1;
    for (ll i = 2; i * i <= x; i++) {
        if (x % i == 0) {
            ret += 2;
            if (x / i == i) ret--;
        }
    }
    return ret;
}

ll G(ll x) {
    ll ret = 1, tp;
    for (ll i = 2; i * i <= x; i++) {
        if (x % i == 0) {
            ll tmp = x / i;
            tp = x;
            while (tp % i == 0) {
                tp /= i;
            }
            if (tp > i) tp %= i;
            ret += (tp == 1);
            if (tmp != i) {
                tp = x;
                while (tp % tmp == 0) {
                    tp /= tmp;
                }
                if (tp > tmp) tp %= tmp;
                ret += (tp == 1);
            }
        }
    }
    return ret;
}

int main() {
    cin >> n;
    if (n == 2) {
        cout << 1;
        return 0;
    }
    cout << F(n - 1) + G(n);
    return 0;
}

Measured memory_bytes: 256
package main

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

// input に使うやつ
var rdr = bufio.NewReaderSize(os.Stdin, 10000)

func readLine() string {
	buf := make([]byte, 0, 10000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

// string から int へ
func atoi(s string) int {
	i, _ := strconv.Atoi(s)
	return i
}

// 一つの文字を int として読み込み
func readInt() int {
	return atoi(readLine())
}

// 複数の文字を int のスライスとして読み込み
func readInts() []int {
	in := readLine()
	ins := strings.Split(in, " ")
	out := make([]int, len(ins))
	for i, v := range ins {
		out[i] = atoi(v)
	}
	return out
}

// sortしたスライスを返す
func sorted(a []int) []int {
	sort.Ints(a)
	b := a
	return b
}

// 逆順のsort
func reverse(a []int) []int {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	b := a
	return b
}

func main() {
	n := readInt()
	a := readInts()
	b := readInts()

	var c int
	for i := 0; i < n; i++ {
		if i == n-1 {
			if a[i+1] >= b[i] {
				c += b[i]
				a[i+1] = a[i+1] - b[i]
			} else {
				c += a[i+1]
				b[i] -= a[i+1]
				if a[i] >= b[i] {
					c += b[i]
					a[i] -= b[i]
				} else {
					c += a[i]
					a[i] = 0
				}
			}
		} else {
			if a[i] >= b[i] {
				c += b[i]
				a[i] = a[i] - b[i]
			} else {
				c += a[i]
				b[i] -= a[i]
				if a[i+1] >= b[i] {
					c += b[i]
					a[i+1] -= b[i]
				} else {
					c += a[i+1]
					a[i+1] = 0
				}
			}
		}
	}
	fmt.Println(c)
}


Measured memory_bytes: 8448
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 7;
const int A = 26;

int cnt[A];
	int n, k;

bool valid(int x)
{
	int sum = 0;
	for (int i=0; i<A; i++)
		sum += min(cnt[i], x);
	if (sum / k >= x)
		return true;
	return false;
}

int main()
{
	ios::sync_with_stdio(false);

	cin >> n >> k;
	for (int i=0; i<n; i++)
	{
		string s;
		cin >> s;
		cnt[s[0]-'A']++;
	}
	int l = 0, r = n/k+1;
	while (r - l > 1)
	{
		int mid = (l + r) / 2;
		if (valid(mid))
			l = mid;
		else
			r = mid;
	}
	cout << l << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
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; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N, K, C;
	string S;
	cin >> N >> K >> C >> S;
	
	int b = INF;
	int j = 1;
	VI num(N);

	REP(i, N) {
		if (S[i] == 'o' && b == INF) {
			num[i] = j;
			j++;
			b = i;
		}
		else if (S[i] == 'o') {
			if (b + C < i) {
				num[i] = j;
				j++;
				b = i;
			}
		}
	}
	
	VI out;
	b = INF;
	j--;
	if (j > K) {
		return 0;
	}
	for (int i = N - 1; i >= 0; i--) {
		if (S[i] == 'o' && b == INF) {
			if (num[i] == j)out.push_back(i + 1);
			j--;
			b = i;
		}
		else if (S[i] == 'o') {
			if (b - C > i) {
				if (num[i] == j)out.push_back(i + 1);
				j--;
				b = i;
			}
		}
	}







	SORT(out);
	fore(i, out)cout << i << endl;


	return 0;
}



Measured memory_bytes: 5000
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <cstring>
#include <map>
#include <stack>
using namespace std;

stack<pair<int,int> > mark[10001];
int n,size;
int ret[100001];
map<string,int> midx;

struct Kanji {
    bool kaeri;
    int num,kind;
};

bool isnum(char c) {
    return c >= '0' && c <= '9';
}

Kanji parse(string &s) {
    Kanji k;
    k.kaeri = false, k.num = 0, k.kind = -1;
    if(s[s.length()-1] == 'v') {
        k.kaeri = true;
        s = s.substr(0,s.length()-1);
    }

    if(s == "-" || s == "") return k;
    int idx = 0;
    while(!isnum(s[idx])) idx++;
    k.num = atoi(s.substr(idx).c_str());
    if(midx.find(s.substr(0,idx)) == midx.end())
        midx[s.substr(0,idx)] = size++;
    k.kind = midx[s.substr(0,idx)];
    return k;
}

void func(int i) {
    cout<<i+1<<endl;
    if(ret[i] != -1) func(ret[i]);
    return;
}

int main() {
    string s;
    while(cin>>n, n) {
        size = 0;
//        for(int i=0; i<10001; ++i) mark[i].clear();
        memset(ret, -1, sizeof(ret));
        midx.clear();
        for(int i=0; i<n; ++i) {
            cin>>s;
            Kanji k = parse(s);

            if(k.kind == -1) {
                if(!k.kaeri) func(i);
                else ret[i+1] = i;
            }else{
                if(k.num == 1) {
                    if(!mark[k.kind].empty() && mark[k.kind].top().first == 2) {
                        ret[i] = mark[k.kind].top().second;
                        mark[k.kind].pop();
                    }
                    if(k.kaeri) ret[i+1] = i;
                    else func(i);
                }else{
                    if(!mark[k.kind].empty() && mark[k.kind].top().first == k.num+1) {
                        ret[i] = mark[k.kind].top().second;
                        mark[k.kind].pop();
                    }
                    mark[k.kind].push(make_pair(k.num,i));
                }
            }
        }
    }
}

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

int main() {
  int N;
  int R = 0;
  cin >> N;

  for(int i = 0; i < N; i++){
    int l, r;
    cin >> l >> r;
    while(l <= r){
      R++;
      l++;
    }
  }
  cout << R << endl;
}

Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;

int main()
{
    int N;
    cin>>N;    
    vector<vector<int>> E[3];
    for (int i=0; i<3; i++)
    {
        int M;
        cin>>M;
        E[i].resize(N);
        for (int j=0; j<M; j++)
        {
            int a, b;
            cin>>a>>b;
            E[i][a-1].push_back(b-1);
            E[i][b-1].push_back(a-1);
        }
    }

    vector<int> G[3];
    set<int> S;
    for (int i=0; i<3; i++)
    {
        G[i] = vector<int>(N);
        for (int j=N-1; j>=0; j--)
        {
            S.clear();
            for (int e: E[i][j])
                if (e>j)
                    S.insert(G[i][e]);
            for (int k=0; ; k++)
                if (S.count(k)==0)
                {
                    G[i][j] = k;
                    break;
                }
        }
    }

    long long M = 998244353LL;
    vector<long long> P10(N+1);
    P10[0] = 1;
    for (int i=1; i<=N; i++)
        P10[i] = P10[i-1]*(1000000000000000000%M)%M;

    vector<long long> GS[3];
    int MG[3] = {};
    for (int i=0; i<3; i++)
    {
        GS[i] = vector<long long>(N);
        for (int j=0; j<N; j++)
        {
            GS[i][G[i][j]] += P10[j+1];
            GS[i][G[i][j]] %= M;
            MG[i] = max(MG[i], G[i][j]);
        }
    }

    long long ans = 0;
    for (int i=0; i<=MG[0]; i++)
        for (int j=0; j<=MG[1]; j++)
        {
            int k = i^j;
            if (k<=MG[2])
            {
                ans += GS[0][i]*GS[1][j]%M*GS[2][k]%M;
                ans %= M;
            }
        }
    cout<<ans<<endl;
}


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

class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int line[] = new int[2];
		int count=0;
		int area=1;
		int around=0;

		String s = br.readLine();

		String[] strArray = s.split(" ");

		try{
		for(int i=0;i<strArray.length;i++){
			if(strArray[i] !=" "){
				line[count]=Integer.parseInt(strArray[i]);
				count++;
			}
		}

		for(int i=0;i<line.length;i++){
			area = area * line[i];
			around = around + 2*line[i];
		}

		System.out.println(area + " " + around);

		}catch(ArrayIndexOutOfBoundsException e){

		}
	}
}

Measured memory_bytes: 16940
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;

const ll mod = (ll)(1e9) + 7;

ll ans = 1;
ll n;
string s1, s2;

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

    int s = -1;

    for (int i = 0; i < n; i++) {
        if (s1[i] == s2[i]) {
            if (s == -1) {
                ans = 3;
            }
            else if (s == 0) {
                ans *= 2;
            }

            s = 0;
        }
        else {
            if (s == -1) {
                ans = 6;
            }
            else if (s == 0) {
                ans *= 2;
            }
            else if (s == 1) {
                ans *= 3;
            }
            
            s = 1;
            i++;
        }

        ans %= mod;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 #include <ext/pb_ds/tree_policy.hpp>
 #include <ext/pb_ds/assoc_container.hpp>
 #include<chrono>
 using namespace std;
 using namespace std::chrono;      
 using namespace __gnu_pbds; 
 #define fastio     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 #define fi         first
 #define se         second
 #define int         long long 
 #define pb         push_back
 #define emp        emplace_back
 #define vv(x)      vector<x>
 #define mp(x,y)    map<x,y>
 #define dq(x)      deque<x>
 #define pql(x)     priority_queue<x>
 #define pqs(x)     priority_queue<x,vv(x),greater<x> >
 #define M          1000000007
 #define forf(i,a,b) for(int i=a;i<b;i++)
 #define it(x)      x::iterator
 #define ll         long long 
 #define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
 #define time__(d)  for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
 #define vii        vector<int>
 #define big        3e18
 #define sm         -2e9
 #define mkr        make_pair
 #define vpi        vector<pair<int,int> >
 #define pii        pair<int,int>
 #define rng        500005
 #define sz(x)      (int)x.size()
 #define rv(x)      reverse(x.begin(),x.end())
 #define out(x)     cout<<x.fi<<" "<<x.se<<endl;

//#define ordered_set tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update> 
  
void pr_init()
{
   
    #ifndef ONLINE_JUDGE
    freopen("gin.txt", "r", stdin);
    freopen("gout.txt", "w", stdout);
   
    #endif
}


double dp[3000][3000] ,ar[3001];

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

  forf(i,1,n+1) cin >> ar[i];
  
  dp[0][0]=1;

  for(int i=1;i<=n;i++)
  {
    for(int k=0;k<=n;k++)
    {
        
        dp[i][k] = ar[i]*dp[i-1][k-1] + (1-ar[i])*dp[i-1][k];
    }
  }

 
  
  double an = 0;

  forf(j,n/2+1,n+1) an += dp[n][j];

  printf("%0.10f\n",an);
}


int32_t main()
{
  pr_init();
  //fastio;
  
  auto start = high_resolution_clock::now(); 
 
  solve();
  auto stop = high_resolution_clock::now();
  auto duration = duration_cast<microseconds>(stop - start); 
   // cout << "Time taken by function: "
   //       << duration.count() << " microseconds" << endl; 

 }
      
      

Measured memory_bytes: 74040
#include <cstdio>
#include <algorithm>
using namespace std;
long long n,s=0;
long long sum(long long m){
	long long r=0;
	while(m!=0){
		r+=m%10;
		m/=10;
	}
	//printf("%lld\n",r);
	return r;
}
int main(){
	scanf("%lld",&n);
	for(long long i=1;i<=n;i*=10){
		//printf("%lld\n",n-(n+1)%i);
		s=max(s,sum(n-(n+1)%i));
	}
	printf("%lld\n",s);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
LL solve(LL a, LL b) {
    if (a == b || a == 0) return 0;
    if (a * 2 <= b) 
        return b + solve(b - a - a, b - a);
    LL d = b - a;
    return a / d * 2 * d + solve(a - a / d * d, b - a / d * d);
}
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    LL n, x; cin >> n >> x;
    cout << x + solve(x, n) << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define int long long
#define M 1000000007
 
int gcd(int a,int b){
	if(b==0){
		return(a);
	}
	return(gcd(b,a%b));
} 
 
signed main(){
	
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
	
	int n;
	cin >> n;
	int a[n];
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	int mp[n+1]={0};
	mp[0]=1;
	int mx=0;
	for(int i=0;i<n;i++){
		if(mp[a[i]-1]){
			mp[a[i]]=1;
			mx=max(mx,a[i]);
		}
	}
	if(mx==0){
		cout << -1 << endl;
		exit(0);
	}
	cout << n-mx;
}

Measured memory_bytes: 6780
#include<stdio.h>

int solve(int,int);

int x;
int a[2000];
int main(){
  int y,z,i;
  scanf("%d",&x);
  for(i=0;i<x;i++)scanf("%d",&a[i]);
  scanf("%d",&y);
  int b[y];
  for(i=0;i<y;i++)scanf("%d",&b[i]);
  for(i=0;i<y;i++){
    z=solve(0,b[i]);
    if(z==1)printf("yes\n");
    else printf("no\n");
  }
  return 0;
}

int solve(int z,int y){
  int res;
  if(y==0)return 1;
  if(z>=x)return 0;
  res=solve(z+1,y)||solve(z+1,y-a[z]);
  return res;
}



Measured memory_bytes: 2108
package main

import (
  "fmt"
)

func main(){
  var a,b int
  fmt.Scan(&a, &b)
  if a == 1 {
    a = 14
  }
  if b == 1 {
    b = 14
  }
  if a == b {
    fmt.Println("Draw")
  } else if a > b {
    fmt.Println("Alice")
  } else {
    fmt.Println("Bob")    
  }
  
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<pair<ll,ll>> g[55];
const int max_v=100000, max_log_v=20;
int root, parent[max_log_v][max_v], depth[max_v];
void lca_dfs(int w, int p, int d){
    parent[0][w] = p;
    depth[w] = d;
    for(int i = 0; i < g[w].size(); i++){
        if(g[w][i].first != p) lca_dfs(g[w][i].first, w, d + 1);
    }
}
//初期化
void lca_init(int w){
    lca_dfs(root, -1, 0);
    for(int k = 0; k + 1 < max_log_v; k++){
        for(int i = 0; i < w; i++){
            if(parent[k][i] < 0) parent[k + 1][i] = -1;
            else parent[k + 1][i] = parent[k][parent[k][i]];
        }
    }
}
int lca(int u, int w){
    if(depth[u] > depth[w]) swap(u,w);
    for(int k = 0; k < max_log_v; k++){
        if((depth[w] - depth[u]) >> k & 1){
            w = parent[k][w];
        }
    }
    if(u == w) return u;
    for(int k = max_log_v - 1; k >= 0; k--){
        if(parent[k][u] != parent[k][w]){
            u = parent[k][u];
            w = parent[k][w];
        }
    }
    return parent[0][u];
}
int main() {
    // your code goes here
    ll n,m,i,ii,j,ls,aa,bb,u[25],v[25],bit,ans=0,pm,en[55][55];
    vector<ll> es[55];
    cin >> n;
    root=0;
    for(i=1;i<n;i++){
        cin >> aa >> bb;
        aa--; bb--;
        g[aa].push_back({bb,i});
        g[bb].push_back({aa,i});
        en[aa][bb]=i;
        en[bb][aa]=i;
    }
    lca_init(n);
    cin >> m;
    for(ii=0;ii<m;ii++){
        cin >> u[ii] >> v[ii];
        u[ii]--; v[ii]--;
        ls=lca(u[ii],v[ii]);
        pm=u[ii];
        while(pm!=ls){
            es[ii].push_back(en[pm][parent[0][pm]]);
            pm=parent[0][pm];
        }
        pm=v[ii];
        while(pm!=ls){
            es[ii].push_back(en[pm][parent[0][pm]]);
            pm=parent[0][pm];
        }
    }
    for(bit=1;bit<(1<<m);bit++){
        ll popcnt=__builtin_popcount(bit);
        ll mul=1;
        bool used[55]={0};
        ll kom=0;
        for(i=0;i<m;i++){
            if(bit>>i&1){
                for(j=0;j<es[i].size();j++){
                    if(!used[es[i][j]]){
                        kom++;
                        used[es[i][j]]=true;
                    }
                }
            }
        }
        mul=(1ll<<(n-1-kom));
        if(popcnt%2==1) ans+=mul;
        else ans-=mul;
    }
    ans=(1ll<<(n-1))-ans;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6528
#include <iostream>
//#include <numeric>
//#include <vector>
//#include<math.h>
//#include <algorithm>
//#include <functional>
//#include <numeric>
//#include<cmath>
//#include <stdio.h> 
//#include <cstdint>
//#include <string>
//#include <cstdlib>
//#define pi 3.14159265359
using namespace std;

int main() {

	
	int m1, m2, d1, d2;
	cin >> m1 >> d1; 
	cin >> m2 >> d2;

	if (m1 != m2) {
		cout << "1";
	}
	else {
		cout << "0";
	}

	return 0;

}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

vector<int> ans;
int main(){
	while(1){
		int n,w,h,s,t;
		cin >> n;
		if(n == 0) break;
		cin >> w >> h;
		bool tree[100][100] = {false};
		for(int i = 0;i < n;i++){
			int x,y;
			cin >> x >> y;
			tree[y-1][x-1] = true;
		}
		cin >> s >> t;
		int cmax = 0;
		for(int i = 0;i <= h - t;i++){
		for(int j = 0;j <= w - s;j++){
			int count = 0;
			for(int k = 0; k < t;k++){
			for(int l = 0; l < s;l++){
				if(tree[i+k][j+l]) count++;
			}
			}
			cmax = max(cmax,count);
		}
		}
		ans.push_back(cmax);
	}
	for(int i = 0;i < ans.size();i++){
		cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 3092
N, K = map(int, input().split())

ans = 0
for b in range(1, N + 1):
    x = N // b
    c = N % b
    if K != 0:
        ans += x * max(0, b - K) + max(0, c - K + 1)
    else:
        ans += x * max(0, b - K) + c

print(ans)

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

#define int long long

signed main() {
  int n, x, y;
  std::cin >> n >> x >> y;
  x--; y--;

  std::vector<int> d(n, 0);
  
  for(int i = 0; i < n; i++) {
    for(int j = i+1; j < n; j++) {
      int dist = j-i;
      dist = std::min(dist, abs(i-x) + abs(j-y) + (int) 1);
      dist = std::min(dist, abs(j-x) + abs(i-y) + (int) 1);
      d[dist]++;
    }
  }

  for(int i = 1; i < n; i++)
    std::cout << d[i] << std::endl;

  return 0;
}



Measured memory_bytes: 256
type X=record a,b:int64;f:Boolean;end;
type SortDataType=X;
function SortCmp(const a,b:SortDataType):Boolean;forward;
procedure SortImpl(var A:Array of SortDataType;L,R:Longint);
var
	tmp:SortDataType;
	mid,il,ir:Longint;
begin
	if R-L<20 then begin
		for ir:=R-1 downto L+1 do for il:=L to ir-1 do if SortCmp(A[il+1],A[il])then begin
			tmp:=A[il];
			A[il]:=A[il+1];
			A[il+1]:=tmp;
		end;
	end else begin
		mid:=(L+R)div 2;
		if SortCmp(A[mid],A[L])then begin
			tmp:=A[mid];
			A[mid]:=A[L];
			A[L]:=tmp;
		end;
		if SortCmp(A[R-1],A[mid])then begin
			tmp:=A[R-1];
			A[R-1]:=A[mid];
			A[mid]:=tmp;
			if SortCmp(A[mid],A[L])then begin
				tmp:=A[mid];
				A[mid]:=A[L];
				A[L]:=tmp;
			end;
		end;
		il:=L;
		ir:=R-1;
		while il<=ir do begin
			while SortCmp(A[il],A[mid])do inc(il);
			while SortCmp(A[mid],A[ir])do dec(ir);
			if il<ir then begin
				tmp:=A[il];
				A[il]:=A[ir];
				A[ir]:=tmp;
				if mid=il then mid:=ir else if mid=ir then mid:=il;
				inc(il);
				dec(ir);
			end else if il=ir then begin
				inc(il);
				dec(ir);
			end;
		end;
		SortImpl(A,L,il);
		SortImpl(A,il,R);
	end;
end;
procedure Sort(var A:Array of SortDataType;size:Longint);
begin
	SortImpl(A,0,size);
end;
function SortCmp(const a,b:SortDataType):Boolean;
begin
	if a.a<>b.a then SortCmp:=a.a<b.a else if a.b<>b.b then SortCmp:=a.b<b.b else SortCmp:=False;
end;
const M=1000000007;
var
	N,i,j,sz:Longint;
	f:Boolean;
	a,b,g,tmp,u,v,ans,O:int64;
	Ar:Array[1..200000]of X;
function gcd(a,b:int64):int64;
begin
	if b=0 then gcd:=a else gcd:=gcd(b,a mod b);
end;
begin
	read(N);
	O:=M-1;
	sz:=0;
	for i:=1 to N do begin
		read(a,b);
		if(a=0)and(b=0)then inc(O)else begin
			g:=gcd(a,b);
			a:=a div g;
			b:=b div g;
			if(a<0)or((a=0)and(b>0))then begin
				a:=-a;
				b:=-b;
			end;
			f:=False;
			if b<0 then begin
				tmp:=a;
				a:=-b;
				b:=tmp;
				f:=True;
			end;
			inc(sz);
			Ar[sz].a:=a;
			Ar[sz].b:=b;
			Ar[sz].f:=f;
		end;
	end;
	Sort(Ar,sz);
	i:=1;
	ans:=1;
	while i<=sz do begin
		j:=i;
		u:=1;
		v:=1;
		while(i<=sz)and(Ar[i].a=Ar[j].a)and(Ar[i].b=Ar[j].b)do begin
			if Ar[i].f then u:=u*2 mod M else v:=v*2 mod M;
			inc(i);
		end;
		ans:=ans*(u+v-1)mod M;
	end;
	writeln((ans+O)mod M);
end.


Measured memory_bytes: 4888
#include <iostream>
using namespace std;
typedef long long ll;

int main() {
    int N; cin >> N;
    long long ans = 0;
    for (int i = 1; i <= N; i++) {
        ll n = N / i;
        ans += i * n * (n+1) / 2; 
    }
    cout << ans << endl;  
}

Measured memory_bytes: 3608
#include <cstdio>
#include <algorithm>

const int INF = 1 << 30;

int gram;
int memo[30][30][30];

int solve(int A, int B, int C)
{
  if (memo[A][B][C] != -1)
    return memo[A][B][C];
  else if (A*200 + B*300 + C*500 > gram)
    return INF;
  else if (A*200 + B*300 + C*500 == gram)
    return A/5*1520 + (A%5)*380 + B/4*1870 + (B%4)*550 + C/3*2244 + (C%3)*850;

  int ret = std::min(solve(A+1, B, C), std::min(solve(A, B+1, C), solve(A, B, C+1)));
  return memo[A][B][C] = ret;
}

int main()
{
  while (~scanf("%d", &gram)) {
    if (gram == 0)
      break;

    for (int i = 0; i < 30; ++i) {
      for (int j = 0; j < 30; ++j) {
	for (int k = 0; k < 30; ++k)
	  memo[i][j][k] = -1;
      }
    }
    printf("%d\n", solve(0, 0, 0));
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=(n);i<(int)N;i++)
#define p(s) cout<<(s)<<endl
using namespace std;

int main() {
	int a[13];
	REP(i,0,13){
		if(i==2) a[i]=0;
		else if(i==4||i==6||i==9||i==11) a[i]=1;
		else a[i]=2;
	}
	int x,y;
	cin>>x>>y;
	p(a[x]==a[y]?"Yes":"No");
	return 0;
}

Measured memory_bytes: 256