akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<map>
#include<vector>
#include<cstring>
#include<algorithm>
struct node {
	int x,y;
};
using namespace std;
node R[1000],B[1000];
bool vis[1000];
int mat[1000];
int N,ans;
vector<int>G[1000];
bool dfs(int u) {
	for(int i=0;i<G[u].size();i++) {
		int v=G[u][i];
		if(vis[v]) continue;
		vis[v]=1;
		if(! mat[v]||dfs(mat[v])) {
			mat[v]=u;
			mat[u]=v;
			return 1;
		}
	}
	return 0;
}
int main()
{
	scanf("%d",&N);
	for(int i=1;i<=N*2;i++)
		scanf("%d%d",&R[i].x,&R[i].y);
	for(int i=1;i<=N;i++)
		for(int j=N+1;j<=2*N;j++)
			if(R[i].x<R[j].x&&R[i].y<R[j].y) {
				G[i].push_back(j);
				G[j].push_back(i);
			}
	for(int i=1;i<=2*N;i++) {
		memset(vis,0,sizeof(vis));
		if(!mat[i]&&dfs(i))
			ans++;
	}
	printf("%d",ans);//
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"errors"
	"fmt"
	"io"
	"math"
	"os"
)

func main() {
	sc := NewScanner(os.Stdin)
	s, _ := sc.NextString()
	a := []rune(s)[0]
	var out string
	if 'a' <= a && a <= 'z' {
		out = "a"
	} else {
		out = "A"
	}
	fmt.Println(out)
}

// Scanner is a wrapper of bufio.Scanner which is customized for competitive programing.
type Scanner struct {
	bufio.Scanner
}

// NewScanner is a constructor for Scanner.
func NewScanner(r io.Reader) *Scanner {
	sc := Scanner{*bufio.NewScanner(r)}
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Split(bufio.ScanWords)
	return &sc
}

// NextString reads a string from io stream
func (sc *Scanner) NextString() (string, error) {
	if !sc.Scan() {
		return "", errors.New("failed to scan")
	}
	return sc.Text(), nil
}


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

#define pb push_back
#define pf push_front

using namespace std;

typedef long long llong;

const int MXN = (int)1e6 + 7;
const int MOD = (int)1e9 + 7;
const int MNN = (int)1e2 + 7;

inline void boost()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

int n;
int s[MNN];
bool dp[MXN];

int main()
{
  boost();
  cin >> n;
  for(int i = 1; i <= n; i++){
    cin >> s[i];
  }
  dp[0] = 1;
  for(int i = 1; i <= n; i++){
    for(int j = 1e4; j >= 0; j--){
      if(dp[j] && s[i] + j <= 1e4){
        dp[j + s[i]] = 1;
      }
    }
  }
  int mx = 0;
  for(int j = 1e4; j >= 0; j--){
    if(dp[j] && j % 10 != 0){
      mx = max(mx, j);
    }
  }
  cout << mx;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <stdio.h>
#include <string>
#include <vector>
#include <functional>
#include <algorithm>
#include <queue>
#include <string>
#include <map>
#include <cmath>
#include <iostream>
using namespace std;

struct Point {
    int x;
    int y;

    Point(int x, int y) {
        this->x = x;
        this->y = y;
    }
};

Point grid[] = {
    Point(0, 1),
    Point(1, 0)
};

int main() {
    int N;
    cin >> N;

    vector<int> t(N);
    vector<Point> p(N, Point(0, 0));

    for(int i = 0; i < N; i++) {
        cin >> t.at(i);

        int x, y;
        cin >> x >> y;
        p.at(i) = Point(x, y);
    }

    bool flag = true;
    Point currentPoint = Point(0, 0);
    int currentTime = 0;

    for(int i = 0; i < N; i++) {
        Point point = Point(p.at(i).x - currentPoint.x, p.at(i).y - currentPoint.y);
        int time = t.at(i) - currentTime;
        bool timeOver = time < abs(point.x + point.y);
        bool odd =  (time - point.x - point.y) % 2 != 0;
        if(timeOver || odd) {
            flag = false;
            break;
        }
        currentPoint = p.at(i);
        currentTime = t.at(i);
    }

    if(flag) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
    return 0;
}

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

#define ll long long int
#define tinput int t; cin>>t; while(t--)
#define rep(i,n,s) for((i)=(s); (i)<(n); (i)++)

template <typename T>
T mini(T x, T y) { return (x<y)?x:y; }
template <typename T>
T maxi(T x, T y) { return (x>y)?x:y; }
ll M = 1e9+7;

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

    ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n;
	cin>>n;
	bool flag=false;
	int a[n], b[n];
	for(int i=0;i<=n;i++) {
		cin>>a[i]>>b[i];
		if(i>=2) {
			if(a[i]==b[i] && a[i-1]==b[i-1] && a[i-2]==b[i-2]) {
				flag=true;
			}
		}
	}
	if(flag) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3648
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>
#include <map>
#include <queue>

using namespace std;
typedef long long ll;
using Graph = vector<vector<ll>>;

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

int main() {
    ll N;
    cin >> N;
    ll A[N];
    ll B[1000001];
    rep(i,1000001) B[i] = 0;
    rep(i,N){
        cin >> A[i];
        B[A[i]]++;
    }
    ll out = N;
    rep(i,N){
        for(ll j=1;j<=sqrt(A[i]);j++){
            if(A[i]%j==0){
                if(B[j]>0){
                    if(A[i]==1){
                        if((B[j]>1)){
                            out--;
                            break;
                        }
                    }else{
                        out--;
                        break;
                    }
                }else if(j==1){
                    if(B[A[i]/j]>1){
                        out--;
                        break;
                    }
                }else{
                    if(B[A[i]/j]>0){
                        out--;
                        break;
                    }
                }
            }
        }
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 13012
N, M = gets.split.map(&:to_i)
ab = []
M.times.map do
  a,b = gets.split.map(&:to_i)
  ab[a] ||= []
  ab[b] ||= []
  ab[a] << b
  ab[b] << a
end

ab[1].each do |i|
  if ab[i].include?(N)
    puts "POSSIBLE"
    exit
  end
end
puts "IMPOSSIBLE"


Measured memory_bytes: 22908
using System;

namespace ITP1_6_C
{
    class Program
    {
        static void Main(string[] args)
        {
            int noOfMembers = int.Parse(Console.ReadLine());
            int[, ,] list = new int[4, 3, 10];

            for (int i = 0; i < noOfMembers; i++)
            {
                var input = Console.ReadLine().Split(' ');
                int b = int.Parse(input[0]);
                int f = int.Parse(input[1]);
                int r = int.Parse(input[2]);
                int v = int.Parse(input[3]);
                list[b - 1, f - 1, r - 1] += v;
            }

            for (int i = 0; i < 4; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    for (int k = 0; k < 10; k++)
                    {
                        Console.Write(" {0}", list[i, j, k]);
                    }
                    Console.Write("\n");
                }
                if (i < 3) Console.WriteLine("####################");
            }

        }
    }

}

Measured memory_bytes: 5664
#include <bits/stdc++.h>
#define F first
#define S second
#define T second.first
#define C second.second
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int,pair<int,int>> piii;

const int N= 1e2+5, L = 14, OO = 0x3f3f3f3f;
const ll M=10 ;
const double ESP = 1e-8;

int n, w;
pii A[N];
ll dp[N][100005];
ll solve(int idx, int rem){
    if(idx == n)
        return 0;

    ll& ret = dp[idx][rem];
    if(~ret)
        return ret;

    return ret = max(solve(idx+1, rem), (rem-A[idx].F>=0)? solve(idx+1, rem-A[idx].F)+A[idx].S : 0);


}

int main(){
    FIO
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    cin>>n>>w;
    for(int i=0; i<n; i++)cin>>A[i].F>>A[i].S;
    memset(dp, -1, sizeof dp);
    cout<<solve(0,w);
}


Measured memory_bytes: 82304
import numpy as np

N,M,X,Y = map(int,input().split())
x_list = list(map(int,input().split())) + [X]
y_list = list(map(int,input().split())) + [Y]

if min(y_list) - max(x_list)>0:
  print("No War")
else:
  print("War")

Measured memory_bytes: 12508
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    int N;
    cin >> N;
    vector<ll> A(N + 1, 0);
    //整数iが書かれたカードをAi枚持っている
    ll ans = 0LL;
    REP(i, N) { cin >> A[i]; }
    REP(i, N) {
        ans += A[i] / 2LL;
        A[i] %= 2LL;
        if(A[i] > 0 and A[i + 1] > 0) {
            A[i]--;
            A[i + 1]--;
            ans++;
        }
    }
    // cout << ans << endl;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

int N;
vector<int> *g;
vector<int> bfn(int spoint); 
int main(){

  cin >> N;
  g = new vector<int>[N+1];
  int a, b;
  for(int i=1; i<N; i++){
    cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  vector<int> dist1 = bfn(1);
  vector<int> dist2 = bfn(N);

  int l=0; int r=0;
  for(int i=1; i<=N; i++){
    if(dist1[i]<=dist2[i]) l++;
    else r++;
  }
  if(l>r) cout << "Fennec" << endl;
  else  cout << "Snuke" << endl;
}

vector<int> bfn(int spoint){
  vector<int> dist(N+1,-1);
  queue<int> q;
  dist[spoint] = 0;
  q.push(spoint);
  while(!q.empty()){
    int u = q.front();
    q.pop();
    for(auto i: g[u]){
      if(dist[i]==-1){
	dist[i] = dist[u] + 1;
	q.push(i);
      }
    }
  }    
  return dist;
}


Measured memory_bytes: 6528
N, A, B, K = map(int, input().split())

mod = 998244353
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 )

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


ans = 0

for i in range(N+1):
    if (K - A*i) % B == 0 and K - A*i >= 0:
        j = (K - A*i) // B
        ans += cmb(N, i, mod) * cmb(N, j, mod)
        ans %= mod

print(ans)


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
  int n, m;
  cin >> n >> m;
  P p[100001];
  rep(i, 0, m) {
    cin >> p[i].first >> p[i].second;
  }
  sort(p, p + m);

  int r = p[0].second;
  int ans = 0;
  rep(i, 0, m) {
    if(p[i].first >= r){
      ans++, r = p[i].second;
    }
    else {
      r = min(r, p[i].second);
    }
  }
  cout << ans + 1 << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i < (n);++i)
#define reps(i,n) for(int i = 1;i <= (n);++i)
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  if((a * b) % 2 == 1) cout << "Odd\n";
  else cout << "Even\n";
  return 0;
}

Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    from bisect import bisect_left
    N = int(input())
    if N == 1:
        print("a")
        sys.exit()
    d = [chr(i) for i in range(97, 97+26)]
    X = [0, 26]
    y = 26
    while y < 10**15:
        y *= 26
        X.append(X[-1] + y)
    x = bisect_left(X, N) # 桁数
    a = N - X[x-1] - 1
    ans = []
    while a > 0:
        ans.append(a%26)
        a //= 26
    while len(ans) < x:
        ans.append(0)
    for a in reversed(ans):
        print(d[a], end="")
    print()

if __name__ == '__main__':
    main()

Measured memory_bytes: 62220
#include <bits/stdc++.h>
using namespace std;
int n,m;
int main () {
	scanf("%d%d",&n,&m);
	if (n>m) {swap(n,m);}
	for (int i=1;i<=m;i++) {printf("%d",n);}
	printf("\n");
	return 0;
}

Measured memory_bytes: 256
temp = input()
a,b,k = temp.split()
a = int(a)
b = int(b)
k = int(k)

box = []
for i in range(k):
    box.append(a+i)
    box.append(b-i)
out = set(box)
out = list(out)
out = [i for i in out if i>=a and i<=b]
out = sorted(out)
for i in out:
    print(i)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 1e9 + 7;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd_calc(T a, T b){ if(b){ return gcd_calc(b, a % b); }else{ return a; }}
template<class T> T gcd(T a, T b){ if(a < b) swap(a, b); return gcd_calc(a, b); }
template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
inline int at(int x, int k){ return (x >> k) & 1; }

int main(){
    int A, B;
    cin >> A >> B;
    for(int i = 0; i < 100000; i++){
        if((i * 8 / 100) == A && (i * 10 / 100) == B){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <queue>
#define int long long
using namespace std;
void file(){
    freopen("read.in","r",stdin);
    freopen("write.out","w",stdout);
}
const int N=500010;
inline int read(){
    int sym=0,res=0;char ch=0;
    while (!isdigit(ch))sym|=(ch=='-'),ch=getchar();
    while (isdigit(ch)) res=(res<<3)+(res<<1)+(ch^48),ch=getchar();
    return sym?-res:res;
}
int n,m,k,a[N],b[N],c[N];
bool check(int x){
    for (int i=1;i<=n;i++)c[i]=x/b[i];
    sort(c+1,c+n+1);
    int res=0;
    for (int i=1;i<=n;i++)res+=max(0ll,a[i]-c[i]);
    return res<=k;
}
signed main(){
    n=read();k=read();
    for (int i=1;i<=n;i++)a[i]=read();
    for (int i=1;i<=n;i++)b[i]=read();
    sort(a+1,a+n+1);
    int l=0,r=1e13;
    while (l<r){
        int mid=l+r>>1;
        if (check(mid))r=mid;
        else l=mid+1;
    }
    printf("%lld",r);
    return 0;
}

Measured memory_bytes: 9984
#include <bits/stdc++.h>
 
#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define FOR(i,n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, ll> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;

const int MX = 300005, mod = 998244353;
int n;
ll a, b, k, res = 0;
ll fac[MX], inv[MX];

void pre () {
	fac[0] = 1;
	for (ll i = 1; i < MX; i++)
		fac[i] = i * fac[i-1] % mod;

	inv[0] = inv[1] = 1;
	for (int i = 2; i < MX; i++)
		inv[i] = inv[mod%i] * (mod - mod / i) % mod;

	for (int i = 2; i < MX; i++) 
		inv[i] = inv[i] * inv[i-1] % mod;
}

ll C (int n, int k) {
	return fac[n] * inv[k] % mod * inv[n-k] % mod;
}

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

	cin >> n >> a >> b >> k;

	for (ll i = 0; i <= n; i++) {
		ll j = k - i * a;
		if (j % b)
			continue;

		j /= b;
		if (j > n || j < 0)
			continue;

		res += C(n, i) * C(n, j) % mod;
		res %= mod;
	}

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 4992
def main():
    n = int(input())
    xs, ys = [], []
    for _ in range(n):
        x, y = map(int, input().split())
        xs.append(x)
        ys.append(y)

    if xs == ys:
        print(0)
        return

    ans = 0
    capacity = 0
    weights, values = [], []
    for x, y in zip(xs, ys):
        if x <= y:
            ans += y
            capacity += y - x
        else:
            weights.append(x - y)
            values.append(y)

    unavailable = min(values)
    ans -= unavailable
    ans += sum(values)

    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 48344
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include <numeric>
using namespace std;
typedef unsigned long long int ulint;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define RE return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
const int mod=(int)1e9+7;
const llint big=(llint)(2.19e15)+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
template <class T> void soun(T& ar)
{sort(ar.begin(),ar.end());ar.erase(unique(ar.begin(),ar.end()),ar.end());}
llint gcd(llint a,llint b){if(a%b==0){return b;}else{return gcd(b,a%b);}}
llint lcm(llint a,llint b){return a/gcd(a,b) *b;}
template<class T,class U> auto LB(T& ve,U in){return lower_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto UB(T& ve,U in){return upper_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto LBI(T& ve,U in){return LB(ve,in)-ve.begin();}
template<class T,class U> auto UBI(T& ve,U in){return UB(ve,in)-ve.begin();}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
using pli=pair<llint,int>;
using daic=priority_queue<pli,vector<pli>,greater<pli>>;
int main(void){
	llint n;cin>>n;n++;
	llint ans=0;
	llint gen=1;
	for(gen=1;gen<n;gen*=10){
		ans+=9;
	}
	gen/=10;
	ans+=n/gen;
	cout<<ans-10<<endl;
	RE;
}

Measured memory_bytes: 888
H, W, D = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]
Q = int(input())
L, R = zip(*(map(int, input().split()) for _ in range(Q)))
p = {A[i][j]: (i, j) for i in range(H) for j in range(W)}
dp = [0 for _ in range(H * W + 1)]
for x in range(D + 1, H * W + 1):
    y = x - D
    dp[x] = dp[y] + abs(p[x][0] - p[y][0]) + abs(p[x][1] - p[y][1])
ans = '\n'.join(str(dp[r] - dp[l]) for l, r in zip(L, R))
print(ans)


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

using namespace std;

int main() {
    
    char x;
    scanf("%c", &x);
    
    switch(x){
        case 'A':
        printf("T");
        break;
        
        case 'T':
        printf("A");
        break;
        
        case 'G':
        printf("C");
        break;
        
        case 'C':
        printf("G");
        break;
    }

	return 0;
}


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

int main() {
  ll ans=0,n,l,absmin=10000;
  cin >> n >> l;
  vector<ll>p(n);
  rep(i,n) p.at(i)=l+i;
  ans=accumulate(p.begin(),p.end(),0);
  rep(i,n) if(abs(absmin)>abs(p.at(i))) absmin=p.at(i);
  ans-=absmin;
  cout << ans << endl;
}


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

int main(){
    int long long N,K;
    cin>>N>>K;
    int long long cnt1=0;
    int long long cnt2=0;
    for(int i=1;i<=N;i++){
        if(i%K==0) cnt1++;
        else if((2*i)%K==0) cnt2++;
    }
    cout<<cnt1*cnt1*cnt1+cnt2*cnt2*cnt2<<endl;
}

Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w;
    cin >> h >> w;
    vector<string> as(h); cin >> as;
    vector<vector<ll>> dp(h + 1, vector<ll>(w + 1));
    dp[0][0] = 1;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(as[i][j] == '#'){ continue; }
            dp[i + 1][j] += dp[i][j];
            dp[i][j + 1] += dp[i][j];
            dp[i + 1][j] %= M;
            dp[i][j + 1] %= M;
        }
    }
    cout << dp[h - 1][w - 1] << '\n';
}


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

int main(){
    int H, W, D, q;
    cin >> H >> W >> D;
    //A[i]にAij の座標を格納
    vector<pair<int, int>> A(H * W + D, pair<int, int>(0, 0));
    //cost[i], i % D から i までのコスト
    vector<long long> cost(H * W + D, 0);
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            int a;
            cin >> a;
            A[a].first = i;
            A[a].second = j;
        }
    }
    
    for(int i = 1; i <= D; i++){
        cost[i + D] = abs(A[i].first - A[i + D].first) + abs(A[i].second - A[i + D].second);
    }
    
    for(int i = D + 1; i <= H * W - D; i++){
        cost[i + D] = cost[i] + abs(A[i].first - A[i + D].first) + abs(A[i].second - A[i + D].second);
    }
    
    cin >> q;
    while(q > 0){
        int s, g;
        cin >> s >> g;
        cout << cost[g] - cost[s] << '\n';
        q--;
    }
    return 0;
}

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

#define MAXN 100010

int n;
long long ans;
string s;
map<string,int> m;

int main()
{
	cin >> n;
	for(int i=1;i<=n;++i)
	{
		cin >> s;
		sort(s.begin(),s.end());
		ans+=m[s];
		++m[s];
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 11136
# Aizu Problem 00163: Highway Tooll
#
import sys, math, os, bisect

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")

M = [[0, 300, 500, 600, 700,1350,1650],
     [6,   0, 350, 450, 600,1150,1500],
     [13,   7,   0, 250, 400,1000,1350],
     [18,  12,   5,   0, 250, 850,1300],
     [23,  17,  10,   5,   0, 600,1150],
     [43,  37,  30,  25,  20,   0, 500],
     [58,  52,  45,  40,  35,  15,   0]]

def intime(t):
    return 1730 <= t <= 1930

def getinfo(src, dst):
    if src > dst:
        src, dst = dst, src
    return M[dst][src], M[src][dst]

while True:
    n1 = int(input())
    if n1 == 0:
        break
    h1, m1 = [int(_) for _ in input().split()]
    n2 = int(input())
    h2, m2 = [int(_) for _ in input().split()]
    t1, t2 = 100 * h1 + m1, 100 * h2 + m2
    a, b = getinfo(n1 - 1, n2 - 1)
    if (intime(t1) or intime(t2)) and a <= 40:
        b = (b // 2 + 49) // 50 * 50
    print(b)

Measured memory_bytes: 7792
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define ll long long 
#define ld long double 

int main()
{
    ld a,b;
    cin>>a>>b;
    ld s=(a*b);
    // cout<<s;
    cout<<(ll)s;
    return 0;
}

Measured memory_bytes: 3732
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<map>
using namespace std;

long long calc(long long A) {
	long long cnt1 = (A + 1) / 2;
	long long ans = cnt1 % 2;
	if (A % 2 == 0) ans ^= A;
	return ans;
}

int main() {
	long long A, B;
	cin >> A >> B;
	long long ans = calc(B) ^ calc(A - 1);
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define INF 10000000000
#define mod 1000000007
typedef long long int ll;
ll u(const void *a, const void *b){
    return *(ll*)a-*(ll*)b;
}
ll d(const void *a, const void *b){
    return *(ll*)b-*(ll*)a;
}
ll min(ll a,ll b){
  if(a>b)return b;
  return a;
}
ll max(ll a,ll b){
  if(a>b)return a;
  return b;
}
ll gcd(ll a,ll b){
  if(!b)return a;
  return gcd(b,a%b);
}
int kt(ll a){
  int sum=0;
  while(a){
    a/=10;
    sum++;
  }
  return sum;
}
int ks(ll a){
  int sum=0;
  while(a){
    sum+=a%10;
    a/=10;
  }
  return sum;
}
int f(ll a){
  for(int i=2;i<=sqrt(a);i++)if(a%i<1)return 0;
  return 1;
}
int x[1001];
int main(void){
  int n,a,ans=0;
  while(1){
    scanf("%d",&n);
    if(!n)break;
    ans=0;
    FOR(n/4){
      scanf("%d",&a);
      ans+=a;
    }
    PRN(ans);
  }
  return 0;
}



Measured memory_bytes: 2036
N, W = map(int, input().split())
value = []
weight = []
for _ in range(N):
  v, w = map(int, input().split())
  value.append(v)
  weight.append(w)
dp = [[0 for i in range(W + 1)] for j in range(N + 1)]
for i in range(N):
  for j in range(W + 1):
    if weight[i] <= j:
      dp[i + 1][j] = max(dp[i][j], dp[i][j - weight[i]] + value[i])
    else:
      dp[i + 1][j] = dp[i][j]
print(dp[N][W])


Measured memory_bytes: 25936
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repf(i,a,b) for (int i = (a); i < (b); i++)
#define repi(i,a,b) for (int i = (a); i <= (b); i++)
#define repr(i,a,b) for (int i = (a); i >= (b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define debug(x)  cout << #x << " = " << (x) << endl;
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using tiii = tuple<int, int, int>;

int main() {
  int N, K; cin >> N >> K;
  vi l(N); rep(i,N) cin >> l.at(i);

  sort(rbegin(l),rend(l));
  int ans = 0;
  rep(i,K) ans += l.at(i);
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
  int a,b;
  cin >> a >> b;
  if(a > b){
    cout << "a > b" << endl;
  }else if(a < b){
    cout << "a < b" << endl;
  }else{
    cout << "a == b" << endl;
  }

    return 0;
}



Measured memory_bytes: 3060
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
typedef pair<P,P> PP;
#define fi first
#define se second
#define all(v) (v).begin(),v.end()
set<string> c;
const ll inf=(1e18);
const ll mod=1000000007;
const ll mod2=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);

class UF{
public:
	vector<int> par,num;
	int find(int v){
		return (par[v]==v)? v: (par[v]=find(par[v]));
	}
	explicit UF(int N):par(N),num(N,1){
		iota(par.begin(),par.end(),0);
	}
	void unite(int u,int v){
		u=find(u),v=find(v);
		if(u==v)return ;
		if(num[u]<num[v])swap(u,v);
		num[u] += num[v];
		par[v] = u;
	}
	bool same(int u,int v){
		return find(u) == find(v);
	}
	bool ispar(int v){
		return v=find(v);
	}
	int size(int v){
		return num[find(v)];
	}
};
// 頂点a, bをつなぐコストcostの（無向）辺
struct Edge{
int a, b, cost;
  // コストの大小で順序定義
  bool operator<(const Edge& o) const {
    return cost < o.cost;
  }
};

// 頂点数と辺集合の組として定義したグラフ
struct Graph{
  int n;  // 頂点数
  vector<Edge> es;  // 辺集合
  // クラスカル法で無向最小全域木のコストの和を計算する
  // グラフが非連結のときは最小全域森のコストの和となる
  int kruskal() {
    // コストが小さい順にソート
    sort(es.begin(), es.end());
    UF uf(n);
    int min_cost = 0;
    for(int ei=0;ei<es.size();ei++){
      Edge& e = es[ei];
      if (!uf.same(e.a, e.b)) {
        // 辺を追加しても閉路ができないなら、その辺を採用する
        min_cost += e.cost;
        uf.unite(e.a, e.b);
      }
    }
    return min_cost;
  }
};
// 標準入力からグラフを読み込む
Graph input_graph() {
  Graph g;
  int m;
  cin >> g.n >> m;
  for(int i=0;i<m;i++) {
    Edge e;
    cin >> e.a >> e.b >> e.cost;
    g.es.push_back(e);
  }
  return g;
}
int main(){
  Graph g = input_graph();
  cout << g.kruskal() << endl;
  return 0;
}


Measured memory_bytes: 4516
def dfs(i, j, s):
    if j > 3:
        return
    if j == 3 and s == x:
        ans.append(1)

    for k in range(1, i):
        if s + k > x:
            break
        dfs(k, j + 1, s + k)

while True:
    ans = []
    n, x = map(int, input().split())
    if n == x == 0:
        break

    for i in range(3, n + 1):
        dfs(i, 1, i)

    print(sum(ans))


Measured memory_bytes: 5608
import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)]


#隣接リスト 1-order
def make_adjlist_d(n, edges):
    res = [[] for _ in range(n + 1)]
    for edge in edges:
        res[edge[0]].append(edge[1])
        res[edge[1]].append(edge[0])
    return res


def make_adjlist_nond(n, edges):
    res = [[] for _ in range(n + 1)]
    for edge in edges:
        res[edge[0]].append(edge[1])
    return res


#nCr
def cmb(n, r):
    return math.factorial(n) // math.factorial(r) // math.factorial(n - r)


def main():
    N, K = NMI()
    A = NLI()
    A.sort()
    print(sum(A[:K]))


if __name__ == "__main__":
    main()

Measured memory_bytes: 9624
import sys
S = input()
T = input()

for i in range(len(S)):
    flg = True
    for j in range(i, len(S)):
        if S[j] != T[j - i]:
            flg = False
            break
    if not flg:
        continue
    for j in range(i):
        if S[j] != T[j + len(S) - i]:
            flg = False
            break
    if flg:
        print('Yes')
        sys.exit()
print('No')


Measured memory_bytes: 9044
def factorization(n):
    arr=[]
    tmp=n
    for i in range(2,int(n**0.5)+1):
        if(tmp%i==0):
            cnt=0
            while tmp%i==0:
                cnt+=1
                tmp//=i
            arr.append([i,cnt])
    if(tmp!=1):
        arr.append([tmp,1])
    return arr

n=int(input())
s=str(n)+':'
arr=factorization(n)
for x,y in arr:
    s+=(' '+str(x))*y
print(s)


Measured memory_bytes: 5640
#include <bits/stdc++.h>
using namespace std;
signed main() {
  int a, b;
  cin >> a >> b;
  int bigger = max(a,b);
  int smaller = min(a,b);
  long long ans = bigger;
  while(ans % smaller != 0) {
    ans += bigger;
  }
  cout << ans;
  cout << "\n";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
/*

*/
int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  ll D,T,S; cin>>D>>T>>S;
  ll min=0;
  min = D/S;
  if (D%S)
    min++;
  if (min>T)
    cout<<"No"<<endl;
  else
    cout <<"Yes"<<endl;
}


Measured memory_bytes: 3684
from collections import defaultdict

n, x, y = map(int, input().split())

d = defaultdict(int)

for i in range(1, n):
    for j in range(i + 1, n + 1):
        d[min(j - i, abs(x - i) + abs(y - j) + 1)] += 1

for i in range(1, n):
    print(d[i])

Measured memory_bytes: 9456
N = int(input())
s_t = []
for i in range(N):
    s, t = input().split()
    s_t.append((s, int(t)))
X = input()

flag = False
ans = 0
for s, t in s_t:
    if flag:
        flag = True
        ans += t
    if s == X:
        flag = True

print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    // Your code here!
    int a,b;
    cin >> a;
    cin >> b;
    int sum,sub,mul;
    sum = a+b;
    sub = a-b;
    mul = a*b;
    cout << max({sum,sub,mul}) << endl;
}

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

typedef long long ll;
typedef string st;
typedef vector<int> vi;
typedef vector<st> vs;
#define rep(i, n) for(int i = 0; i < n; i++)
#define fogg(i,a,b) for(int i = (a); i <= (b); i++)
#define ford(i,a,b) for(int i = (a); i >= (b); i--)
#define test int t; cin >> t; while(t--)
#define debug(x) cout << '>' << #x << ':' << x << "\n";
#define endl '\n'
#define pb push_back
#define gp " "
#define ff first
#define ss second
#define mp make_pair



int main() {
	
	int r;
	cin >> r;
	double pi = 3.14159;
	printf("%.2f",2*pi*r);

	return 0;
}


Measured memory_bytes: 3752
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String N = scanner.next();
		String result = "No";

		if (N.substring(0, 1).equals(N.substring(2, 3))) {
			result = "Yes";
		}
		System.out.println(result);
	}

}

Measured memory_bytes: 22732
#include <bits/stdc++.h>
#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() {
    string S;
    cin >> S;
    string L;
    string R;
    if(S.size() % 2 == 0){
        L = S.substr(0,S.size()/2);
        R = S.substr(S.size()/2);
    }else{
        L = S.substr(0,S.size()/2);
        R = S.substr(S.size()/2+1);
    }
    
    int ans = 0;
    for(int i = 0; i < S.size()/2; i++){
        if(L[i] != R[L.size()-1-i]){
            ans++;
        }
    }
    cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
#define PI acos(-1)
#define sz 100010
#define RUN_FAST ios::sync_with_stdio(false);
using namespace std;

int main()
{
    RUN_FAST; cin.tie(nullptr);
    int n, i, tmp;
    cin >> n;
    int arr[n];
    for (i=0; i<n; i++) cin >> arr[i];
    for (i=0; i<n; i++) {
        tmp=arr[i];
        if (tmp%2==0 && tmp%3 && tmp%5) {
            cout << "DENIED" << endl;
            return 0;
        }
    }
    cout << "APPROVED" << endl;
    return 0;
}


Measured memory_bytes: 3664
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
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>;

// mt19937 gen_rand_int(chrono::steady_clock::now().time_since_epoch().count());
// mt19937_64 gen_rand_ll(chrono::steady_clock::now().time_since_epoch().count());
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

long long power(long long a, long long b,long long m) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a %m;
        a = a * a %m;
        b >>= 1;
    }
    return res;
}


signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);  
cout.tie(0);   

#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif  

    int n,m,h,w;
    cin>>n>>m>>h>>w;
        int a[505][505];
        int z=1e9;
        z++;
        z/=max(2LL,h*w-1);
        for(int i=1;i<=n;i++)
        {
            for(int j=1;j<=m;j++)
                a[i][j]=-z;
        }
        int tot=0;
        for(int i=1;i<=n;i++)
        {
            for(int j=1;j<=m;j++)
            {
                if(((i-1)%h==0) && ((j-1)%w==0))
                {
                    a[i][j]=(h*w-1)*z-1;
                }
                tot+=a[i][j];
            }
        }
        if(tot<=0)
        {
            cout<<"No";
            return 0;
        }
        cout<<"Yes\n";
        for(int i=1;i<=n;i++)  
        {
            for(int j=1;j<=m;j++)
                cout<<a[i][j]<<" ";
            cout<<'\n';
        }
    

} 
    


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

int main(){
    char s[3][3];
    
    while(true){
        cin >> s[0][0];
        if(s[0][0]=='0') break;
        for(int i = 0 ; i < 3 ; i++){
            for(int j = 0 ; j < 3 ; j++){
                if(!i&&!j) continue;
                else cin >> s[i][j];
            }
        }
        
        int j = 0;
        bool flg = false;
        for(int i = 0 ; i < 3 ; i++){
            if(s[i][j]=='b'){
                if(s[i][j]==s[i][j+1]&&s[i][j+1]==s[i][j+2]){
                    cout << 'b' << endl;
                    flg = true;
                    break;
                }
            }
            else if(s[i][j]=='w'){
                if(s[i][j]==s[i][j+1]&&s[i][j+1]==s[i][j+2]){
                    cout << 'w' << endl;
                    flg = true;
                    break;
                }
            }
        }
        if(flg) continue;
        
        int i = 0;
        for(int j = 0 ; j < 3 ; j++){
            if(s[i][j]=='b'){
                if(s[i][j]==s[i+1][j]&&s[i+1][j]==s[i+2][j]){
                    cout << 'b' << endl;
                    flg = true;
                    break;
                }
            }
            else if(s[i][j]=='w'){
                if(s[i][j]==s[i+1][j]&&s[i+1][j]==s[i+2][j]){
                    cout << 'w' << endl;
                    flg = true;
                    break;
                }
            }
        }
        if(flg) continue;
        
        if(s[1][1]=='b'){
            if((s[0][0]==s[1][1]&&s[1][1]==s[2][2])||
               (s[0][2]==s[1][1]&&s[1][1]==s[2][0])){
                cout << 'b' << endl;
                flg = true;
            }
        }
        else if(s[1][1]=='w'){
            if((s[0][0]==s[1][1]&&s[1][1]==s[2][2])||
               (s[0][2]==s[1][1]&&s[1][1]==s[2][0])){
                cout << 'w' << endl;
                flg = true;
            }
        }
        
        if(flg) continue;
        
        cout << "NA" << endl;
    }

    return 0;
}

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

int main(){
  string w;
  cin >> w;
  
  if (w.size() % 2 != 0) {
    cout << "No" << endl;
    return 0;
  }
  
  sort(w.begin(), w.end());
  for(int i = 0; i < w.size(); i += 2){
    if (w.at(i) != w.at(i+1)){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  
}

Measured memory_bytes: 256
from collections import Counter
from operator import mul
from functools import reduce

def comb(n,r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom

N = int(input())
A = list(map(int,input().split()))
li = Counter(A)
S = 0
for i,j in enumerate(li):
    if li[j]>=2:
        S += comb(li[j],2)

for i in A:
    ans = S
    tmp = li[i]
    if tmp>2:
        ans -= comb(tmp,2)-comb(tmp-1,2)
    elif tmp==2:
        ans -= 1
    print(ans)

Measured memory_bytes: 26896
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
const int INF = 1e9;
const LL LLINF = 1e16;
const int mod = 1e9+7;

int main(){
    int r,g,b, n;
    cin >> r >> g >> b >> n;
    int ans = 0;
    rep(i,n+1)rep(j,n+1){
        if(n-i*r-j*g < 0) continue;
        if((n-i*r-j*g) % b == 0) ans++;
    }

    cout << ans << endl;
}


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

int main() {
  int n,k; cin >> n >> k; 
  vector<int> N(n,1);
  rep(i,k) {
    int d; cin >> d;
    rep(j,d) {
      int a; cin >> a;
      N[a-1] = 0;
    }
  }
  int ans=0;
  rep(i,n) ans += N[i];
  cout << ans << endl;
}

Measured memory_bytes: 3628
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

int main(){
  ll N; cin>>N;
  vector<ll> a(N,0);
  a[1]=1;
  ll sum= N>1 ? 1 : 0;
  for( ll i=2; i<N; i++ ){
    ll cnt=0;
    bool prime=true;
    for(ll j=2; j<((ll)sqrtl(i)+1);j++){
      if(i%j==0){
        ll cnt2 = 0;
        ll k = i;
        while(k%j==0){
          k/=j;
          cnt2++;
        }
        a[i]=a[i/j] * (cnt2+1) / cnt2;
        prime=false;
        break;
      }
    }
    if(prime) a[i]=2;
    sum+=a[i];
  }
  cout<<sum<<endl;
}

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

int main(){
  int n,x,count=0;
  cin >> n >> x;
  vector<int> L(n),D(n+1);
  for(int i=0;i<n;i++){
  	cin >> L[i];
  }
  D[0]=0;
  for(int i=0;i<n+1;i++){
  	if(D[i]<=x){
    	count++;
    }
    if(i==n)
      break;
    D[i+1]=D[i]+L[i];
  }
  cout << count;
}

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

int main(){
	long long a,b,c,d;
	cin >> a >> b >> c >> d;
	long long temp1=a*d;
	long long temp2=a*c;
	long long temp3=b*d;
	long long temp4=b*c;
	cout << max(temp1,max(temp2,max(temp3,temp4))) << '\n';
}

Measured memory_bytes: 3640
import java.util.Scanner;




public class Main {

    public static void main(String[] args) {

    	Main main=new Main();

    	main.run();

    }

    void run() {
    	Scanner sc=new Scanner(System.in);

    	int K=sc.nextInt();
    	int S=sc.nextInt();

    	int sum=0;

    	for(int x=0;x<=K;x++) {
    		for(int y=0;y<=K;y++) {
    			int z=S-(x+y);
    			
    			if(z>=0 && z<=K) {
    				sum++;
    			}
    		}
    	}
    	
    	
    	System.out.println(sum);
    }
}



Measured memory_bytes: 20820
#include<bits/stdc++.h>
#define lg long long int
using namespace std;
lg min(lg a,lg b)
{
    if(a<b)
        return a;
    else
        return b;

}
lg max(lg a,lg b)
{
    if(a>b)
        return a;
    else
        return b;

}
int main()
{
    int n,m;
    cin>>n>>m;
    int a[n]={0};
    int b[n]={0};
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(int i=0;i<m;i++)
    {
        int a1,a2;
        cin>>a1>>a2;
        if(a[a1-1]<=a[a2-1])
            b[a1-1]=1;
        if(a[a2-1]<=a[a1-1])
            b[a2-1]=1;
    }
    int count=0;
    for(int i=0;i<n;i++)
    {
        if(b[i]==0)
            count++;
    }
    cout<<count;
}


Measured memory_bytes: 4416
N, K = [int(_) for _ in input().split()]

A = [int(_) for _ in input().split()]

m = min(A)
# idx = A.index(m)
i = 0
ans = 0
while i < N:
    if i ==0:
        i+=K
    else:
        i += K - 1
    ans += 1
print(ans)

Measured memory_bytes: 13880
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();

        int result = 0;
        if (a > b) {
            result += a;
            a--;
        } else {
            result += b;
            b--;
        }

        if (a > b) {
            result += a;
            a--;
        } else {
            result += b;
            b--;
        }

        System.out.println(result);
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>

using namespace std;

int count_underscores(string s)
{
    int count = 0;

    for (int i = 0; i < s.size(); i++)
        if (s[i] == '2')
            count++;

    return count;
}

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

    string str;
    cin >> str;

    cout << count_underscores(str) << "\n";
}


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

#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
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 (a>b) { a=b; return 1; } return 0; }

using ll = long long;
using namespace std;
constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int MOD = 1000000007;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n;
cin>>n;
vector<int>a(n);
vector<int>b(n,0);
rep(i,n){
    cin>>a[i];
}
int cnt=0;
rep(i,n){
    if(i+1==a[i]){
        if(i<n-1){
            swap(a[i],a[i+1]);
        }
        else{
            swap(a[i],a[i-1]);
        }
        cnt++;
    }
}
cout<<cnt<<endl;
return 0;
}

Measured memory_bytes: 3960