akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//pair sort
bool compare_by_b(pair<LL, LL> a, pair<LL, LL> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

const string YES = "YES";
const string NO = "NO";

void solve(long long A, long long B, long long C){
    map<int, int> m;
    REP(i, 11)m[i]=0;
    m[A]++;
    m[B]++;
    m[C]++;
    if(m[5]==2 && m[7]==1)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    solve(A, B, C);
    return 0;
}


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

typedef long long LL;
const int N = 55;

LL ans = 0, a[N]; int n;
void solve() {
	LL sum = 0;
	for (int i = 0; i < n; ++i) sum += a[i] / n;
	ans += sum;
	for (int i = 0; i < n; ++i) a[i] = a[i] % n + sum - a[i] / n;
}
int main() {
	std::ios::sync_with_stdio(0), std::cin.tie(0);
	std::cin >> n;
	for (int i = 0; i < n; ++i) std::cin >> a[i];
	while (*std::max_element(a, a + n) >= n) solve();
	std::cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
import java.util.Collections;
import java.util.Arrays;
import java.lang.Math;

public class Main {
	public static void main(String[] args) {
		FS reader = new FS();
		// write reader
		int H = reader.nextInt();
		int W = reader.nextInt();
		boolean[][] matrix = new boolean[H][W];
		for(int x=0; x<H; x++) {
		    String input = reader.next();
		    for(int y=0; y<W; y++) {
		        if (input.charAt(y) == '#') matrix[x][y] = false;
		        else matrix[x][y] = true;
		    }
		}
		solver(H, W, matrix);
	}
	
	public static void solver(int H, int W, boolean[][] matrix) {
		// write logic
		boolean[] horizon = new boolean[H];
		boolean[] vertical = new boolean[W];
		for(int i=0; i<H; i++) {
		    horizon[i] = true;
		}
		for(int i=0; i<W; i++) {
		    vertical[i] = true;
		}

		for(int x=0; x<H; x++) {
		    for(int y=0; y<W; y++) {
		        vertical[y] &= matrix[x][y];
		        horizon[x]  &= matrix[x][y];
		    }
		}
		
		for(int x=0; x<H; x++) {
		    if (horizon[x]) continue;
		    for(int y=0; y<W; y++) {
		        if(!vertical[y]) {
		            String out = matrix[x][y] ? "." : "#";
		            System.out.print(out);
		        }
		    }
		    System.out.println();
		}
	}
	
	// Read Class
	static class FS {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;
		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}
	
		private int readByte() { return hasNextByte() ? buffer[ptr++] : -1;}
		private boolean isPrintableChar(int c) {return 33 <= c && c <= 126;}
		private void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
	
		public boolean hasNext() { skipUnprintable(); return hasNextByte();}
		public String next() {
			if (!hasNext()) throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while(isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}
		public int nextInt() {
			return (int)nextLong();
		}
		public long nextLong() {
			if (!hasNext()) throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while(true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if(b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}
	}
}


Measured memory_bytes: 23252
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 55;
const int mod = 1000000007;


ll f(ll a, ll b, ll x){
  return floor(a *x/b)-a*floor(x/b);
}

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  ll a,b,n;
  cin>>a>>b>>n;
  if(n<b)cout<<f(a,b,n)<<endl;
  else cout<<f(a,b,b-1)<<endl;
  return 0;
}

Measured memory_bytes: 3636
#include<cstdio>
#define mx 100005
#define For(n) for(int i;i<n;i++)
#define _ read()
using namespace std;
inline int read(){
  int x=0,f=1;char ch=getchar();
  for(;ch<'0'||ch>'9';ch=getchar())if(ch=='-')f=-f;
  for(;ch>='0'&&ch<='9';ch=getchar())x=x*10+ch-'0';
  return x*f;
}
int p[mx],b[mx],c[mx];
long long a[mx];
int f(int s){
  int t=p[s];
  return t<0?s:p[s]=f(t);
}
long long g(int j){
  int x=f(b[j]),y=f(c[j]),s=0,t;
  if(x!=y){
    s=p[x],t=p[y];
    p[x]=y;
    p[y]+=s;
  }
  return 1ll*s*t;
}
int main(){
  int n=_,m=_;
  a[m-1]=1ll*n*(n-1)/2;
  For(n)p[i]=-1;
  For(m)b[i]=_,c[i]=_;
  for(int i=m-2;i>=0;i--)a[i]=a[i+1]-g(i+1);
  For(m)printf("%lld\n",a[i]);
}

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

using namespace std;
#define ll long long
const int N = 2e3 + 5, mod = 1e9 + 7;
int dp[N][N][2];

int solve(int red, int blue, int last) {
    if (red + blue == 0) return 1;
    int &ret = dp[red][blue][last];
    if (ret != -1) return ret;
    ret = 0;
    if (red)
        ret = solve(red - 1, blue, 0);
    if (blue && !last) ret = (ret + solve(red, blue - 1, 1)) % mod;
    return ret;
}

int ncr[N][N];

int starsAndBars(int n, int k) {
    return ncr[n - 1][k - 1];
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= i; j++) {
            if (!j || i == j)ncr[i][j] = 1;
            else ncr[i][j] = (ncr[i - 1][j] + ncr[i - 1][j - 1]) % mod;
        }
    }
    int n, k;
    cin >> n >> k;
    memset(dp, -1, sizeof(dp));
    for (int i = 1; i <= k; i++) cout << (solve(n - k, i, 0) * 1LL * starsAndBars(k, i) % mod) % mod << '\n';
    return 0;
}

Measured memory_bytes: 46720
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int l,r,d;
  cin>>l;
  cin>>r;
  cin>>d;
  int count=0;
  for(int i=l;i<=r;i++)
  {
    if(i%d==0)
      count++;
  }
  cout<<count;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef vector<int> vi;

template<class T> inline T re(){
	T N = 0; char c = getchar(); bool neg = 0;
	for (; c < '0' || c > '9'; c = getchar()) neg |= c == '-';
	for (; c >= '0' && c <= '9'; c = getchar())
		N = (N<<3)+(N<<1) + c - '0';
	return neg ? -N : N;
}

int main(){
	int x = re<int>();
	printf("%lld\n", 1000LL * (x / 500) + 5LL * ((x % 500) / 5LL));
	return 0;
}


Measured memory_bytes: 256
from collections import deque
Sa = deque([ord(i) - 97 for i in list(input())] + [-1, ])
Sb = deque([ord(i) - 97 for i in list(input())] + [-1, ])
Sc = deque([ord(i) - 97 for i in list(input())] + [-1, ])
S = [Sa, Sb, Sc]
now = 0
while True:
    next = S[now].popleft()
    if next == -1:
        print(chr(now + 97).upper())
        exit()
    now = next

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

typedef long long LL;

const int N=100005;
const int MOD=1000000007;

int n,x[N],ny[N];

int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&x[i]);
	ny[0]=ny[1]=1;
	for (int i=2;i<=n;i++) ny[i]=(LL)(MOD-MOD/i)*ny[MOD%i]%MOD;
	for (int i=2;i<=n;i++) (ny[i]+=ny[i-1])%=MOD;
	int ans=0;
	for (int i=1;i<n;i++) (ans+=(LL)ny[i]*(x[i+1]-x[i])%MOD)%=MOD;
	for (int i=2;i<n;i++) ans=(LL)ans*i%MOD;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1024
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);	
		String s = sc.next();
		
		if (s.equals("Sunny")) {
			System.out.println("Cloudy");
		} else if (s.equals("Cloudy")) {
			System.out.println("Rainy");
		} else {
		System.out.println("Sunny");
		}
	}

}


Measured memory_bytes: 21716
#include <iostream>
#include <vector>
#include <set>
using namespace std;
struct union_find{
    vector<int> root; 
    union_find(int n){
        root.push_back(0);
        for(int i = 1;i<=n;i++){
            root.push_back(i);
        }
    }
    int rootfind(int a){
        if (root[a] == a) return a;
        root[a] = rootfind(root[a]);
        return rootfind(root[a]);
    }
    void unite(int a,int b){
        if (rootfind(a) == rootfind(b)) return;
        root[rootfind(a)] = rootfind(b);
    }
};
int main(){
    int n,m;
    cin >> n >> m;
    union_find hoge(n);
    int x,y,z;
    for(int i = 0;i<m;i++){
        cin >> x >> y >> z;
        hoge.unite(x,y);
    }
    set<int> ans;
    for(int i = 0;i<n;i++){
        ans.insert(hoge.rootfind(i+1));
    }
    cout << ans.size() << endl;
}

Measured memory_bytes: 5368
import sys
input = sys.stdin.readline
from collections import deque
H,W = map(int,input().split())
Sh,Sw = map(int,input().split())
Sh -= 1
Sw -= 1
Gh,Gw = map(int,input().split())
Gh -= 1
Gw -= 1
S = [list(input()) for _ in range(H)]
D = [[-1 for _ in range(W)] for _ in range(H)]
D[Sh][Sw] = -1


walk = [(1,0),(-1,0),(0,1),(0,-1)]
warp = [(x,y) for x in range(-2,3) for y in range(-2,3) if abs(x) + abs(y) > 1]
def validPosition(h,w):
	return 0 <= h and h < H and 0 <= w and w < W

search = [(0, Sh, Sw)]
V = [[False for _ in range(W)] for _ in range(H)]
while D[Gh][Gw] == -1:
	walked = []
	# walk
	while len(search) > 0:
		(d, h, w) = search.pop()
		if D[h][w] >= 0 and d > D[h][w]:
			continue
		V[h][w] = True
		D[h][w] = d
		walked.append((d,h,w))
		for (x,y) in walk:
			hh,ww = h+x, w+y
			if validPosition(hh, ww) and S[hh][ww] == "." and D[hh][ww] == -1:
				search.append((d, hh, ww))
	# warp
	next_search=[]
	for (d,h,w) in walked:
		for (x,y) in warp:
			hh,ww = h+x, w+y
			if validPosition(hh, ww) and not V[hh][ww] and S[hh][ww] == "." and D[hh][ww] == -1:
				V[hh][ww] = True
				next_search.append((d+1, hh, ww))
	if len(next_search) == 0:
		break
	search = next_search

print(D[Gh][Gw])

Measured memory_bytes: 147964
function main()
  
  (N,M,C) = map(x -> parse(Int,x), split(readline()))
  
  B = map(x -> parse(Int,x), split(readline()))
  
  A = zeros(Int,N,M)
  
  for i in 1:N
    A[i,:] = map(x -> parse(Int,x), split(readline()))
  end
  
  check_num = 0
  count = 0
  
  for i in 1:N
    
    for j in 1:M
      check_num += A[i,j]*B[j]
    end
    
    if check_num + C > 0
      count += 1
      check_num = 0
    else
      check_num = 0
    end
    
  end
  
  println(count)
  
end

main()

Measured memory_bytes: 118516
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            int N = sc.nextInt();

            int[] X = new int[N];
            int[] Y = new int[N];
            for (int i = 0; i < N; i++) {
                X[i] = sc.nextInt();
                Y[i] = sc.nextInt();
            }

            double sum = 0;
            for (int i = 0; i < N; i++) {
                for (int j = i + 1; j < N; j++) {
                    sum += Math.sqrt(Math.pow(X[i] - X[j], 2) + Math.pow(Y[i] - Y[j], 2));
                }
            }

            double ave = sum * 2 / N;

            System.out.println(ave);
        }
    }

}


Measured memory_bytes: 22736
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
const long long MOD = 1e9+7;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ll> pdl;
typedef pair<ld, ld> pdd;
//typedef boost::multiprecision::cpp_int bigint;

string S;
int main() {
	cin >> S;
	ll y = stoi(S.substr(0, 4));
	ll m = stoi(S.substr(5, 2));
	ll d = stoi(S.substr(8, 2));
	if (y < 2019)goto heisei;
	if (y > 2019)goto tbd;
	if (m < 4)goto heisei;
	if (m > 4)goto tbd;
	if (d <= 30)goto heisei;
	if (d > 30)goto tbd;
heisei:
	cout << "Heisei" << endl;
	return 0;
tbd:
	cout << "TBD" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)

int dx[]={1,0,-1,0};
int dy[]={0,-1,0,1};
int dxx[]={1,1,0,-1,-1,-1,0,1};
int dyy[]={0,-1,-1,-1,0,1,1,1};
bool inside(int x,int y,int w,int h){
  return (x>=0 && y>=0 && x<w && y<h);}
typedef long long ll;
typedef pair<int,int> pii;


int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  int n,i;
  cin>>n>>i;
  cout <<n+1-i<<endl;


  

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
#define Reve(a) reverse(a.begin(), a.end())
typedef long long ll;
const ll MOD = 1e9+7;


int main(){
  int n, j;
  cin >> n;
  ll sum = 0;
  vector<ll> A(n);
  rep(i, n){
    cin >> A[i];
    sum += A[i];
  }
  ll sun = sum;
  ll ari = 0;
  ll ans = 1000000000000000000;
  //cout << ans << endl;
  ll g;
  for(j=n-1; j>=1; j--){
    sum -= A[j];
    ari += A[j];
    g = abs(sum-ari);
    ans = min(g, ans);
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#include<time.h>
#include<stdlib.h>
#define pb push_back
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define ull unsigned long long
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/__gcd((a),(b))
#define clr(x) x.clear()
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vi>
#define mp make_pair
#define hell 1000000007

using namespace std;

int main()
{
    IOS
    string str;
    getline(cin,str);
    int n=str.length();
    int ctr=0;
    for(int i=0;i<n;i++)
    {
        if(str[i]=='x')
            ctr++;
    }
    if(ctr<=7)
        cout<<"YES\n";
    else
        cout<<"NO\n";
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll r;
  cin >> r;
  cout << r * r << endl;
  return 0;
}


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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	string s; cin >> s;
	if (s=="SAT") cout << "1" << endl;
	else if (s=="FRI") cout << "2" << endl;
	else if (s=="THU") cout << "3" << endl;
	else if (s=="WED") cout << "4" << endl;
	else if (s=="TUE") cout << "5" << endl;
	else if (s=="MON") cout << "6" << endl;
	else cout << "7" << endl;
	return 0;
}


Measured memory_bytes: 256
import sys
readline = sys.stdin.readline

def resolve():
    N = int(input())
    # A = input().replace(" ", "")
    A = readline().rstrip().split()
    import collections
    counter = collections.Counter(A)
    if N % 2 == 1:
        if counter["0"] != 1:
            print("0")
            return
        for k, v in counter.items():
            if k == "0":
                continue
            if int(k) % 2 == 1:
                print("0")
                return
            if v != 2:
                print("0")
                return
    else:
        for k, v in counter.items():
            if int(k) % 2 == 0:
                print("0")
                return
            if v != 2:
                print("0")
                return
    
    print( (2**(N//2)) % (10**9+7) )




if '__main__' == __name__:
    resolve()



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

#define mod 1000000007
#define INF (ll)9999999999999999

#define add emplace
#define eb emplace_back
#define all(x) begin(x), end(x)
#define len(x) ((int)(x).size())
#define exist(a, x) (a.find(x) != end(a))
#define log(x) cout << (x) << endl
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define rrep(i,a,b) for (int i = (int)a; i >= (int)b; --i)
#define loop(i,a,b) for(int i = (int)(a); i < (int)(b); ++i)

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;


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

	vi a(n),b(n),c(n);

	rep(i,n) cin>>a[i];
	rep(i,n) cin>>b[i];
	rep(i,n) cin>>c[i];
	sort(all(a)), sort(all(c));

	ll x, i1, i2, c1, c2, cnt = 0;
	rep (i, n) {
		x = b[i];
		i1 = distance(begin(a), upper_bound(all(a), x-1));
		i2 = distance(begin(c), lower_bound(all(c), x+1));

		if (i1 >= n) i1--;
		while (a[i1]>=x && i1>0) --i1;

		if (a[i1] < x and x < c[i2]) {
			c1 = i1+1;
			c2 = n-i2;
			cnt += c1 * c2;
		}
	}

	log(cnt);

	return 0;
}




Measured memory_bytes: 1408
/**
 * Insertion Sort
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_A&lang=ja
 */
#include <bits/stdc++.h>
using namespace std;

void trace(vector <int>A) {
  // 現在の並び替え状態を出力する
  int size = A.size();
  for (int i = 0; i < size; i++) {
    cout << A.at(i);

    if (i < size - 1) {
      cout << ' ';
    }
  }

  cout << endl;
}

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

  vector <int>A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  trace(A);

  /**
   * insertionSort(A, N) // N個の要素を含む0-オリジンの配列A
   *   for i が 1 から N-1 まで
   *     v = A[i]
   *     j = i - 1
   *     while j >= 0 かつ A[j] > v
   *       A[j+1] = A[j]
   *       j--
   *     A[j+1] = v
   */
  for (int i = 1; i < N; i++) {
    int v = A.at(i);
    int j = i - 1;
    while (j >= 0 && A.at(j) > v) {
      A.at(j + 1) = A.at(j);
      // cout << "途中経過 ";
      // trace(A);
      j--;
    }
    A.at(j + 1) = v;

    // 現在の並び替え状態を出力する
    trace(A);
  }

  return 0;
}



Measured memory_bytes: 3160
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <set>
#include <map>
#include <cassert>
#include <cstdio>
#include <cstdlib>

using namespace std;

int main(int argc,char** argv) {
	set<char> s;
	for(char i = 0x61;i <= 0x7a;i++ ){
		s.insert(i);
	}
	string h;
	cin >> h;
	for(auto e:h) {
		s.erase(e);
	}
	if(s.begin() == s.end()) cout << "None";
	else cout << *(s.begin());
}


Measured memory_bytes: 512
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        if (n < 2) {
            System.out.println(1);
            return;
        }
        int[] array = new int[n + 1];
        array[0] = 1;
        array[1] = 1;
        for (int i = 2; i <= n; i++) {
            array[i] = array[i - 1] + array[i - 2];
        }
        System.out.println(array[n]);
    }
}


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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin (),(x).end()
#define sqrt(x) sqrt(abs(x))
#define re return
#define sz(x) ((int)(x).size ())
#define prev PREV
#define next NEXT

using ll = long long;
using ii = pair<int, int>;
using ld = long double;
using D = double;
using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>;
using vs = vector<string>;

template<typename T> T abs (T x) { re x < 0 ? -x : x; }
template<typename T> T sgn (T x) { re x < 0 ? -1 : (x > 0 ? 1 : 0); }
template<typename T> T sqr (T x) { re x * x; }
template<typename T> T gcd (T a, T b) { re a ? gcd (b % a, a) : b; }

int n;
int m;
int x[100];

int main () {
	scanf ("%d", &n);
	for (int i = 0; i < n; i++) scanf ("%d", &x[i]);
	sort (x, x + n);
	int ans = 0;
	for (int i = 0; i < n; i++) ans = x[i] - ans;
	printf ("%d\n", ans);
	return 0;
}

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

int main() {
  ll k;
  cin >> k;
  vector<ll> a(k);
  for(ll i=0;i<k;i++) {
    cin >> a[i];
  }
  reverse(a.begin(),a.end());
  ll mi=2;
  ll mx=2;
  for(ll i=0;i<k;i++) {
    mi=(mi+a[i]-1)/a[i]*a[i];
    mx=mx/a[i]*a[i]+a[i]-1;
    if(mi>mx) {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << mi << " " << mx << endl;
}

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

using namespace std;

int main()
{
  int N, M;
  cin >> N >> M;
  int total = 0;
  vector<int> A;
  for (int i = 0; i < N; ++i) {
    int Ai;
    cin >> Ai;
    total += Ai;
    A.push_back(Ai);
  }
  int count = 0;
  for (int i = 0; i < N; ++i) {
    if (A[i] * 4 * M >= total) ++count;
  }

  cout << (count >= M ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
//{
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define FILL(i,n) memset(i,n,sizeof i)
#define X first
#define Y second
#define SZ(_a) (int)_a.size()
#define ALL(_a) _a.begin(),_a.end()
#define pb push_back
#ifdef brian
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // brian
//}


const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=ll(1e15);

int main()
{
    IOS();
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<min(a,b) + min(c,d)<<endl;
}


Measured memory_bytes: 256
#-*-coding:utf-8-*-

def main():
    n = int(input())
    f_list = [list(map(int, input().split())) for i in range(n)]
    p_list = [list(map(int, input().split())) for i in range(n)]

    max_profit = -1000000001
    
    for i in range(1, 2 ** 10):
        binary=[0]*10
        now=i
        for j in range(10):
            binary[j]=now%2
            now=now//2
        profit = 0
        for j in range(n):
            one_cnt = 0
            for h in range(10):
                if f_list[j][h]*binary[h]==1:
                    one_cnt += 1
            profit += p_list[j][one_cnt]
        if max_profit < profit:
            max_profit = profit
 
    print(max_profit)
    
if __name__ == '__main__':
    main()

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

int main(){
	int n,k,x,y;
	cin>>n>>k>>x>>y;
	
	int a=n-k;
	if(a<=0)cout<<n*x;
	
	else if(a>0){
		cout<<k*x+a*y;
	}
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct node{
  node* l;
  node* r;
  node* p;
  int key;
};

node L;
node* nil=&L;
node* t=nil;

bool find(node* a,int t){
  if(a->key==t)return 1;
  if(a==nil)return 0;
  if(a->key<t)return find(a->r,t);
  else return find(a->l,t);
}

void insert(node* a){
  node* y=nil;
  node* x=t;
  while(x!=nil){
    y=x;
    if(a->key<x->key)x=x->l;
    else x=x->r;
  }
  a->p=y;
  if(y==nil)t=a;
  else if(a->key<(y->key))y->l=a;
  else y->r=a;
}

void pri(node* b,int a){
  if(b==nil)return;
  if(!a)cout<<" "<<b->key;
  pri(b->l,a);
  if(a)cout<<" "<<b->key;
  pri(b->r,a);
}

int main(){
  int n,a;
  string s;
  cin>>n;
  
  for(int i=0;i<n;i++){
    cin>>s;
    if(s[0]=='i'){
      cin>>a;
      node* b=(node *)malloc(sizeof(node));
      b->l=nil;
      b->r=nil;
      b->key=a;
      insert(b);
    }
    else if(s[0]=='f'){
      cin>>a;
      if(find(t,a))cout<<"yes"<<endl;
      else cout<<"no"<<endl;
    }
    else{
      pri(t,1);
      cout<<endl;
      pri(t,0);  
      cout<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 19952
h,w = map(int,input().split())
a = [list(input()) for _ in range(h)]

delete_column = [True]*w
delete_row = [True]*h
for i in range(h):
  for j in range(w):
    if a[i][j] == '#':
      delete_column[j] = False
      delete_row[i] = False
for i in range(h):
  if not delete_row[i]:
    ans = ''
    for j in range(w):
    	if not delete_column[j]:
          ans += a[i][j]
    print(ans)


Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(void){
   int N;
   int a,b,c,d;
   cin >> N;
   for(int i = 0;i<N;i++){
       cin >> a >> b>> c >> d;
       int ans = (a*c)+(b*d);
       ans = min(ans,4*(a*max(c,5)+b*max(d,2))/5);
      cout << ans << endl;
   }
}


Measured memory_bytes: 3100
#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rrep(i, n) for(int i=(n-1); i>=0; --i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool int_ceil(T a, T b) { T res = a / b; if(a % b != 0) res++; return res; }
template<typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define print(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define print(...)
#endif

int main(int argc, const char * argv[]) {
	std::cout << std::fixed << std::setprecision(15);

	map<string, int> mp;
	int n; cin >> n;
	rep(i, n) {
		string s; cin >> s;
		mp[s] = mp[s] + 1;
	}

	string v[4] = {"AC", "WA", "TLE", "RE"};
	rep(i, 4){
		cout << v[i] << " " << "x" << " " << mp[v[i]] << endl;
	}

	return 0;
}


Measured memory_bytes: 3624
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと


def read_a_int(): return int(read())


def read_ints(): return list(map(int, read().split()))


def read_col(H):
    '''H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_tuple(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_matrix(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right
# https://atcoder.jp/contests/abc045/tasks/abc045_b

# 愚直シミュレーション
from collections import deque
S = {'a': deque(list(input())),
     'b': deque(list(input())),
     'c': deque(list(input()))}

now = 'a'
while S[now]:
    now = S[now].popleft()

print(now.upper())


Measured memory_bytes: 38384
N, M = map(int, input().split())
A = list(map(int, input().split(" ")))

val = sum(A) / (4 * M)
A.sort(reverse=True)
flag = True
for i in range(0,M):
    if A[i] < val:
        flag = False
        break
    
if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <stdio.h>
signed main(){
    int i,j,temp,x[10000];
    int n,K,sum=0;
    scanf("%d %d",&n,&K);
     for(i=0;i<n;i++){
     scanf("%d",&x[i]);
    }
    for (i=0;i<n;i++){
        for(j=0;j<n-i-1;j++){
            if(x[j]>x[j+1]){
                temp=x[j];
                x[j]=x[j+1];
                x[j+1]=temp;
            }
        }
    }
    for(i=0;i<K;i++){
        sum+=x[i];/*kまで繰り返す   小さい順にしてるからx[k]まで大丈夫*/
    }
    printf("%d\n",sum);
    return(0);
}

Measured memory_bytes: 1740
dur=int(input())
c=list(map(int,input().split()))
d=[0]*26
for i in range(dur):
  t=0
  s=list(map(int,input().split()))
  m=-1<<64
  for j in range(26):
    alt=s[j]+c[j]*(i+1-d[j])+sum([-c[k]*(i+1-d[k]) for k in range(26)])
    if alt>m:
      m=alt
      t=j
  print(t+1)
  d[t]=i+1
def cost():
  for i in range(dur):
    t=0
    s=list(map(int,input().split()))
    m=-1<<64
    for j in range(26):
      alt=s[j]+c[j]*(i+1-d[j])+sum([-c[k]*(i+1-d[k]) for k in range(26)])
      if alt>m:
        m=alt
        t=j
    print(t+1)
    d[t]=i+1

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

int main(void){
	int t = 0;
	char a[128];
	char takahashi;

	//入力
	scanf("%s",a);
	
	//計算
	for(int j=0; j<4; j++){
	takahashi = a[j];
	 	if(takahashi == '+')
		{
			t++;
		} else {
			t--;
		}
	}


	printf("%d\n", t);
}

Measured memory_bytes: 128
#include <stdio.h>
#define INFTY 2097152
#define MAX 100
#define WHITE 0
#define GRAY 1
#define BLACK 2
int M[MAX][MAX],n;
int prim(void)
{
  int u,minv,i,v;
  int d[MAX],p[MAX],color[MAX];

  for(i=0;i<n;i++)
  {
    d[i]=INFTY;
    p[i]=-1;
    color[i]=WHITE;
  }

  d[0]=0;

  while(1)
  {
    minv=INFTY;
    u=-1;
    for(i=0;i<n;i++)
    {
      if(minv>d[i] && color[i]!=BLACK)
      {
        u=i;
        minv=d[i];
      }
    }
    if(u==-1)
    {
      break;
    }
    color[u]=BLACK;
    for(v=0;v<n;v++)
    {
      if(color[v]!=BLACK && M[u][v]!=INFTY)
      {
        if(d[v]>M[u][v])
        {
          d[v]=M[u][v];
          p[v]=u;
          color[v]=GRAY;
        }
      }
    }
  }
  int sum=0;
  for(i=0;i<n;i++)
  {
    if(p[i]!=-1)
    {
      sum+=M[i][p[i]];
    }
  }
  return sum;
}
int main()
{
  int i,j,e;
  scanf("%d",&n);

  for(i=0;i<n;i++)
  {
    for(j=0;j<n;j++)
    {
      scanf("%d",&e);
      if(e==-1)
      {
        M[i][j]=INFTY;
      }
      else
      {
        M[i][j]=e;
      }
    }
  }
  printf("%d\n",prim());

  return 0;
}



Measured memory_bytes: 2036
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<float.h>
#include<tuple>
#include<string.h>
#include<iomanip>
#include<stack>
#include<queue>
#include<map>
#include<deque>

using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define REP(i,n) for(ll i=1;i<=n;i++)
#define ALLOF(c) (c).begin(), (c).end()
#define Pa pair<ll,ll>
const ll mod=1000000007;
const ll INF=10e12;
const ll inf=-1;
ll ABS(ll a){return max(a,-a);}


int main(void){
    ll X;
        cin>>X;
        vector<ll> numbers(301);
        for(ll i=-150;i<=150;i++) numbers.at(i+150)=i*i*i*i*i;
        rep(i,301){
            ll bignum=numbers.at(i)+X;
            rep(j,301){
                if(bignum==numbers.at(j)){
                    cout<<j-150<<" "<<i-150<<endl;
                    return 0;
                }
            }
        }
    cout<<"No exist"<<endl;
    return 0;
}


Measured memory_bytes: 3636
import numpy as np

N = int(input())
XY = np.empty([N,2])
for i in range(N):
    XY[i] = list(map(int, input().split()))

ans = 0.0
for i,a in enumerate(XY):
    for b in XY[i+1:]:
        ans += np.sqrt(np.sum(np.square(a-b)))
ans = ans*2/N

print(ans)

Measured memory_bytes: 12504
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		int n=in.nextInt();
		int K=in.nextInt();
		int mod=1000000007;
		int[] dp=new int[K+1];
		int[] a=new int[n+1];
		for (int i=1;i<=n;++i)
			a[i]=in.nextInt();
		dp[0]=1;
		for (int i=1;i<=n;++i) {
			for (int j=1;j<=K;++j)
				dp[j]=(dp[j]+dp[j-1])%mod;
			for (int j=K;j>=0;--j)
				dp[j]=(dp[j]-((j<a[i]+1)?0:dp[j-a[i]-1]))%mod;
		}
		System.out.println((dp[K]+mod)%mod);
	}
}

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

#define fi first
#define se second
#define pb push_back

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ii,int> iii;

const int N = 2e5;
const int MOD = 998244353;
int n, k;
int l[N+2], r[N+2];
ll dp[N+2], pref[N+2];

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    clock_t ck;
    ck = clock();
    cin >> n >> k;
    for (int i = 1; i <= k; i++) {
        cin >> l[i] >> r[i];
    }
    dp[1] = 1;
    pref[1] = 1;
    for (int i = 2; i <= n; i++) {
        // cout << i << " :\n";
        for (int j = 1; j <= k; j++) {
            if (i-l[j] > 0)
                dp[i] += pref[i-l[j]];
            if (i-r[j]-1 > 0)
                dp[i] -= pref[i-r[j]-1];
            // cout << max(0,i-l[j]) << ' ' << max(0,i-r[j]-1) << '\n';
            dp[i] %= MOD;
            dp[i] += MOD;
            dp[i] %= MOD;
        }
        pref[i] = pref[i-1] + dp[i];
        pref[i] %= MOD;
    }
    cout << dp[n] << '\n';
    ck = clock()-ck;
    cerr << "It took " << 1.0*ck/CLOCKS_PER_SEC << " sec\n";
    return 0;
}

Measured memory_bytes: 6936
n = int(input())
w1 = input()
w = {w1}
flag = True
cw = w1
for _ in range(n-1):
    nw = input()
    if nw[0] != cw[-1] or nw in w:
        flag = False
    w.add(nw)
    cw = nw
if flag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
X = int(input())

while True:
    
    flag = 0
    
    for i in range(2, X): #2からX-1までのループ
        if X % i == 0: #対象はXという数
            flag = 1
            break
    if flag == 1:
        X += 1
        continue
    break
    
print(X)

Measured memory_bytes: 2940
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

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

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

int main(void){
	int a,b,c;
	cin >> a >> b >> c;
	cout << ((a+c==b*2)?"YES":"NO") << endl;
	return 0;
}


Measured memory_bytes: 256
from collections import Counter

N = int(input())
A = list(map(int, input().split()))

cnt = Counter(A)

try:
    if cnt[0] == N:
        print("Yes")
    else:
        if N % 3 != 0:
            print("No")
        else:
            if cnt.most_common(1)[0][1] == N*2//3 and cnt[0] == N//3:
                print("Yes")
            else:
                x = cnt.most_common(3)
                if x[0][1] == x[1][1] == x[2][1] == N//3:
                    if x[0][0]^x[1][0]^x[2][0] == 0:
                        print("Yes")
                    else:
                        print("No")
                else:
                    print("No")
except:
    print("No")

Measured memory_bytes: 20660
s = input()
n = len(s)

ans = 1

tmp = s[0]
i = 1

while i < n:
    if tmp != s[i]:
        tmp = s[i]
        ans += 1
        i += 1
    else:
        if i != n-1:
            ans += 1
        tmp = ''
        i += 2

print(ans)
    
    
    

Measured memory_bytes: 41052
using System;

class Program
{
  public static void Main(string[] args)
  {
    int n = int.Parse(Console.ReadLine());
    int taro = 0;
    int hanako = 0;
    for (int i = 0; i < n; i ++)
    {
      string[] s = Console.ReadLine().Split(' ');
      string s1 = s[0];
      string s2 = s[1];
      int compare = string.Compare(s1, s2);
      if (compare == 0)
      {
        taro ++;
        hanako ++;
      }
      else if (compare > 0 ) taro += 3;
      else hanako += 3;
    }
    Console.WriteLine("{0} {1}", taro, hanako);
  }
}



Measured memory_bytes: 16744
#include<bits/stdc++.h>
using namespace std;
int num[300000],b[300000];
int main(){
	int a;
	cin>>a;
	for(int i=1;i<=a;i++){
		cin>>num[i];
		b[i]=num[i];
	}
	sort(num+1,num+a+1);
	for(int i=1;i<=a;i++){
		if(b[i]<=num[a/2])printf("%d\n",num[a/2+1]);
		else printf("%d\n",num[a/2]);
	}
	return 0;
}


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

int main() {
    long long X;
    cin >> X;

    long long Ans = 0;

    while(X >= 500){
        X -= 500;
        Ans += 1000;
    }

    while(X>=5){
        X -= 5;
        Ans += 5;
    }

    cout << Ans << endl;
}


Measured memory_bytes: 256
# C - Green Bin
def main():
    import collections


    n = int(input())
    s = [''.join(sorted(input())) for _ in range(n)]
    c = collections.Counter(s)
    ans = 0
    
    for a in c:
        ans += (c[a] * (c[a] - 1)) //2
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 24020
#include<stdio.h>
int main(void){
    int m[1000],f[1000],r[1000],l,i=0,y[1000];
    while(1){

        scanf("%d %d %d",&m[i],&f[i],&r[i]);
        if(m[i]==-1&&f[i]==-1&&r[i]==-1)break;
        l++;
        i++;
    }
    i=0;
    while(1){
            if(m[i]==-1&f[i]==-1&r[i]==-1)break;
        if(m[i]==-1||f[i]==-1||m[i]+f[i]<30){
            printf("F\n");
        }else if(m[i]+f[i]>=80){
            printf("A\n");
        }else if(65<=m[i]+f[i]&&m[i]+f[i]<80){
            printf("B\n");
        }else if(50<=m[i]+f[i]&&m[i]+f[i]<65||30<=m[i]+f[i]&&m[i]+f[i]<50&&r[i]>=50){
            printf("C\n");
        }else if(30<=m[i]+f[i]&&m[i]+f[i]<50||m[i]+f[i]<30){
            printf("D\n");
        }
        i++;
    }


    return 0;
}

Measured memory_bytes: 592
#模範解答の通りにやってみる
N,K=map(int,input().split())
P=list(map(int,input().split()))
if K==1:
	print((max(P)+1)/2)
elif N==K:
	print((sum(P)+N)/2)
else:
	T=sum(P[0:(K)])
	S=sum(P[0:(K)])
	for k in range(0,N-K):
		S=S-P[k]+P[k+K]
		if T<=S:
			T=S
		else:
			continue
	print((T+K)/2)


Measured memory_bytes: 71792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

int main(){
    int N;
    cin>>N;
    pair<int,int> p[N];
    rep(i,N){
        int a;
        cin>>a;
        p[i]={a,i};
    }
    sort(p,p+N);
    rep(i,N){
        cout<<p[i].second+1<<" ";
    }
}

Measured memory_bytes: 1536
//
//  main.cpp
//  Getting Difference
//
//  Created by wenhan on 2017/7/23.
//  Copyright © 2017年 wenhan. All rights reserved.
//

#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int a[100005];
int main() {
    int n,m;
    cin>>n>>m;
    bool f=false;
    for(int i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        if(a[i]==m)
        {
            f=true;
            break;
        }
    }
    if(f)
        printf("POSSIBLE\n");
    else if(n==1)
        printf("IMPOSSIBLE\n");
    else
    {
        sort(a,a+n);
        int s=a[0]-0;
        for(int i=0;i<n-1;i++)
            if(a[i+1]-a[i]!=0)
            s=min(s, a[i+1]-a[i]);
        if(m%s==0&&a[n-1]>m)
            printf("POSSIBLE\n");
        else
            printf("IMPOSSIBLE\n");
    }
    // insert code here...
    //std::cout << "Hello, World!\n";
    return 0;
}


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

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::fixed << std::setprecision(10);
    
    int n; cin >> n;
    cout << (n + 1)/2 << endl;
    

    return 0;
}

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

long long MOD = 1000000007;

long long Calc(long long A, long long B) {
	if (B == 0) return 1;
	if (B % 2 == 0) {
		long long C = Calc(A, B / 2);
		return (C * C) % MOD;
	}
	return (A * Calc(A, B - 1)) % MOD;
}

int main() {
	int N, K;
	cin >> N >> K;
	vector<long long> V(K + 1);
	V[1] = 1;
	for (int i = 2; i <= K; i++) {
		V[i] = i;
		for (int j = 1; j * j <= i; j++) {
			if (i % j == 0) {
				V[i] = (V[i] + MOD - V[j]) % MOD;
				if (j * j != i && j != 1) V[i] = (V[i] + MOD - V[i / j]) % MOD;
			}
		}
	}
	long long ANS = 0;
	for (int i = 1; i <= K; i++) {
		long long X = K / i;
		ANS += (Calc(X, N) * V[i]) % MOD;
		ANS %= MOD;
	}
	cout << ANS << endl;
}

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

using namespace std;

int main()
{
	string s, t;
	cin >> s >> t;
	bool ans = false;

	for (int i = 0; i < s.size(); i++)
	{
		if (s == t)
		{
			ans = true;
			break;
		}
		s = s.back() + s.substr(0, s.size() - 1);
	}

	if (ans)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10000)
def f(x,y):
    if 0<=x<w and 0<=y<h and a[y][x]=='1':
        a[y][x]='0'
        for dx,dy in[[-1,0],[1,0],[0,-1],[0,1],[-1,-1],[1,-1],[-1,1],[1,1]]:f(x+dx,y+dy)
while 1:
    w,h=map(int,input().split())
    if w==0:break
    a=[input().split() for _ in[0]*h];b=0
    for i in range(w):
        for j in range(h):
            if a[j][i]=='1':
                b+=1;f(i,j)
    print(b)

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

using namespace std;

int main() {
    // g++ -Wall -Wextra -O2 -std=c++17 helloworld.cpp
    int m1, m2, d1, d2;

    cin >> m1 >> d1;
    cin >> m2 >> d2;

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

    return 0; 
}

Measured memory_bytes: 256
import math
from functools import reduce
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
    
n = int(input())
t = []
for i in range(n):
  t.append(int(input()))
print(lcm_list(t))

Measured memory_bytes: 9500