akhauriyash/Code-Regression huggingface dataset:
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	static long solveNaive(int A[]){
		int N = A.length;
		long cnt = 0;
		for(int i = 0 ; i < N ; ++i){
			int Aii = A[i] + i;				
			for(int j = i + 1 ; j < N ; ++j){
				if(Aii == j - A[j]){
					++cnt;
				}
			}
		}
		return cnt;
	}
	static long solve(int A[]){
		// A[i] + A[j] == (j - i)
		// A[i] + i == j - A[j]
		int N = A.length;
		Map<Long , Integer> count = new HashMap();
		for(int j = 0 ; j < N ; ++j){
			long v = j - A[j];
			if(!count.containsKey(v)){
				count.put(v, 1);
			}else{
				int c  =count.get(v);
				count.put(v, c + 1);
			}
		}
		long ret = 0;
		for(int i = 0 ; i < N ; ++i){
			long Aji = i - A[i];
			int c = count.get(Aji);
			count.put(Aji, c - 1);
			long Aii = A[i] + i;
			if(count.containsKey(Aii)){
				ret += count.get(Aii); 
			}			
		}
		return ret;
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A[] = new int[N];
		for(int i = 0 ; i < A.length ; ++i){
			A[i] = sc.nextInt();
		}
		System.out.println(solve(A));
	}
}


Measured memory_bytes: 62444
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cstring>
#include<cmath>
#include <numeric>
#include<queue>
#include<climits>
#include<cstdio>
#include<map>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
//#define INF ((LLONG_MAX) / (2))
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long int ll;
typedef pair<ll,int> LL_IP;
#define INF 1e9+7
#define N_MAX 1001


/*約数列挙*/
vector<ll> prime_factorization(ll m){
    
    vector<ll> arr;
    for(ll i = 1;i * i <= m;i++){
        if(m % i == 0){
            arr.push_back(i);
            if(i != m/i){
                arr.push_back(m/i);
            }
        }
    }
    return arr;
}

int main(){

    ll n,m,ans = -1;
    cin >> n >> m;
    vector<ll> arr = prime_factorization(m);

    REP(i,arr.size()){
        if(n * arr[i] <= m){
            ans = max(arr[i],ans);
        }
    }
    cout << ans << endl;



    return 0;
}

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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    A=LI()
    ans=pow(3,N)
    cnt=1
    for i in range(N):
        if A[i]%2==0:
            cnt*=2
            
    print(ans-cnt)

main()


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

long long miria = 0;

int N, A[100001], B[100001], C[100001];

int main(){
	
	scanf("%d", &N);
	for(int i = 0;i < N;i ++) scanf("%d", &A[i]);
	for(int j = 0;j < N;j ++) scanf("%d", &B[j]);
	for(int k = 0;k < N;k ++) scanf("%d", &C[k]);
	
	sort(A, A + N);
	sort(B, B + N);
	sort(C, C + N);
	
	for(int l = 0;l < N;l ++){
		miria += (lower_bound(A, A + N, B[l]) - A) * ((C + N) - upper_bound(C, C + N, B[l]));
		
	}
	printf("%lld", miria);
	return 0;
}

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

using namespace std;

const int maxl = 3010;
string s, t;
int dp[maxl][maxl];
int sub[maxl][maxl][2];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> s >> t;
	s = " " + s;
	t = "1" + t;
	int sl = s.length();
	int tl = t.length();

	int ans = 0;
	int xc = 0, yc = 0;

	for (int i = 1; i < sl; i++) {
		for (int j = 1; j < tl; j++) {
			sub[i][j][0] = 1;
			if (dp[i-1][j] > dp[i][j]) {
				dp[i][j] = dp[i-1][j];
				sub[i][j][0] = 1;
				sub[i][j][1] = 0;
			}
			if (dp[i][j-1] > dp[i][j]) {
				dp[i][j] = dp[i][j-1];
				sub[i][j][0] = 0;
				sub[i][j][1] = 1;
			}
			if (s[i] == t[j]) {
				if (dp[i-1][j-1]+1 > dp[i][j]) {
					dp[i][j] = dp[i-1][j-1]+1;
					sub[i][j][0] = sub[i][j][1] = 1;
				}
				
			}

			if (dp[i][j] > ans) {
				ans = dp[i][j];
				xc = i;
				yc = j;
			}
		}
	}

	vector<char> stuff;

	while (xc != 0 && yc != 0) {
		if (sub[xc][yc][0] == sub[xc][yc][1]) {
			stuff.push_back(s[xc]);
		}
		int xd = sub[xc][yc][0];
		yc -= sub[xc][yc][1];
		xc -= xd;
	}
	reverse(stuff.begin(), stuff.end());
	for (char c : stuff) cout << c;
	cout << endl;

}

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

int main () {
  int H,W,K;
  cin >> H >> W >> K;
  vector<vector<char>> data(H, vector<char>(W));
 
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> data.at(i).at(j);
    }
  }
  int sum = 0;

  // すべての選び方を試して、総和がKになるものがあるかを調べる
  for (int tmp = 0; tmp < (1 << 12); tmp++) {
    bitset<12> s(tmp);  // 最大20個なので20ビットのビット列として扱う
    
    if (H + W < 12 && s.test(H+W)) {
      break;
    }

    // ビット列の1のビットに対応する整数を選んだとみなして総和を求める
    int count = 0;
    
    vector<vector<char>> data2(H, vector<char>(W));
 
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        data2.at(i).at(j) = data.at(i).at(j);
      }
    }
    
    for (int i = 0; i < H+W; i++) {
      if (s.test(i)) {
        if (i < H){
          for (int j = 0; j < W; j++) {
            data2.at(i).at(j) = '.';
          }
        }
        else {
          for (int j = 0; j < H; j++) {
            data2.at(j).at(i-H) = '.';
          }
        }
      }    
    }
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        if (data2.at(i).at(j) == '#'){
          count++;
        }
      }
    }
    if (count == K) {
      sum++;
    }
  }
  
  cout << sum << endl;
}

  

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
   ll n,a,b;cin >>n>>a>>b;
   vector<ll>x(n);
    for (int i = 0; i < n; ++i) {
        cin >>x[i];
    }
    ll ans=0;
    for (int i = 0; i < n - 1; ++i) {
        ll d=x[i+1]-x[i];
        if(d*a>=b){
            ans+=b;
        }
        else ans+=a*d;
    }
    cout <<ans <<endl;
   return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#include <tuple>

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define co(x) cout << (x) << "\n"
#define ll long long
#define pb push_back
#define Never
#define To

using namespace std;

int main(){

	cin.tie(0);
	ios::sync_with_stdio(false);

	string A;

	cin >> A;

	for(int a = 0 ; a < (1 << 3); a++){
		int v = A[0] - '0';
		for(int d = 0; d < 3; d++){
			if(((a >> d) & 1) == 0){
				v += A[d+1] - '0';
			} else {
				v -= A[d+1] - '0';
			}
		}

		if( v == 7){
			cout << A[0];
			for(int d = 0; d < 3; d++){
				if(((a >> d) & 1) == 0){
					cout << "+";
				} else {
					cout << "-";
				}
				cout << A[d+1];
			}
			cout << "=7" << endl;
			break;
		}
	}

	Never To return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
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();}
typedef long long ll;
typedef pair<ll,ll> P;
const int INF=INT_MAX / 3;
const ll LINF=LLONG_MAX / 3LL;
#define CONST 1000000007
#define EPS (1e-8)
#define PB push_back
#define MP make_pair
#define sz(a) ((int)(a).size())
#define reps(i,n,m) for(int i=(n);i<int(m);i++)
#define rep(i,n) reps(i,0,n)
#define SORT(a) sort((a).begin(),(a).end())
ll mod(ll a,ll m){return (a%m+m)%m;}
int dx[9]={0,1,0,-1,1,1,-1,-1,0},dy[9]={1,0,-1,0,1,-1,1,-1,0};
ll n,m;
int main(){
  cin>>n>>m;
  rep(i,n){
    rep(j,m){
      string s;
      cin>>s;
      if(s=="snuke") {
        printf("%c%d\n", 'A' + j,i+1);
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/segtree>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
using namespace std;
using namespace atcoder;
using ll = long long;
using P = pair<int,int>;
constexpr int INF = 1001001001;
constexpr int MAXA = 300005;
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; }

int op(int a, int b) { return max(a, b); }
int e() { return 0; }

int main() {
    int n, k;
    cin >> n >> k;
    segtree<int, op, e> seg(MAXA);
    
    rep (i, n) {
        int a;
        cin >> a;
        int l = max(a-k, 0);
        int r = min(a+k+1, MAXA);
        seg.set(a, seg.prod(l, r) + 1);
    }
    cout << seg.all_prod() << endl;
    
    return 0;
}


Measured memory_bytes: 8532
#include<iostream>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;

int N;
int main(){
    cin>>N;
    int a=0;int b=0;
    int w[1000];
    for(int i=0;i<N;i++){
        cin>>w[i];
        b+=w[i];
    }
    int ans=b-a;
    for(int i=0;i<N;i++){
        a+=w[i];
        b-=w[i];
        ans=min(ans,abs(b-a));
    }

    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int t[] = new int[n];

		int sum = 0;
		for(int i = 0; i < n; i++){
			t[i] = sc.nextInt();
			sum += t[i];
		}

		int m = sc.nextInt();
		for(int i = 0; i < m; i++){
			int p = sc.nextInt() - 1;
			int x = sc.nextInt();

			System.out.println(sum - t[p] + x);
		}
    }
}

Measured memory_bytes: 21844
#include<stdio.h>

int main(void){
	int n;
	
	scanf("%d", &n);
	
	if(n % 10 == 1)
		n += 8;
	else if(n % 10 == 9)
		n -= 8;
	
	if(n / 100 == 1)
		n += 800;
	else if(n / 100 == 9)
		n -= 800;
	
	if((n/10)%10 == 1)
		n += 80;
	else if((n/10)%10 == 9)
		n -= 80;
	
	printf("%d\n", n);
	
	return 0;
}

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

const int INF = 1e8;

vector<vector<char>> maze;
int N, M;
int sx, sy;
int gx, gy;
vector<vector<int>> d;
int dx[4] = { 1, 0, -1, 0 }, dy[4] = { 0, 1, 0, -1 };

int bfs(int sx,int sy,int gx,int gy) {
	queue<pair<int, int>> que;
	//無限にする
	for (int i = 0; i < N; i++)
		for (int j = 0; j < M; j++)
			d[i][j] = INF;
	//最初の距離は0
	que.push(pair<int, int>(sx, sy));
	d[sx][sy] = 0;

	while (que.size()) {
		pair<int, int> p = que.front();
		que.pop();

		//ゴール
		if (p.first == gx && p.second == gy)
			break;

		//4方向ループ
		for (int i = 0; i < 4; i++) {
			//移動後
			int nx = p.first + dx[i], ny = p.second + dy[i];

			if (0 <= nx && nx < N && 0 <= ny && ny < M && maze[nx][ny] != '#' && d[nx][ny] == INF) {
				que.push(pair<int, int>(nx, ny));
				d[nx][ny] = d[p.first][p.second] + 1;
			}
		}
	}
	return d[gx][gy];
}

int main() {

	cin >> N >> M;
	maze.resize(N, vector<char>(M));
	d.resize(N, vector<int>(M));

	rep(i, N) rep(j, M) cin >> maze[i][j];

	int ans = 0;
	int a = 0;

	for (int sx = 0; sx < N; sx++) {
		for (int sy = 0; sy < M; sy++) {
			for (int gx = 0; gx < N; gx++) {
				for (int gy = 0; gy < M; gy++) {
					if (maze[sx][sy] == '#' || maze[gx][gy] == '#')
						continue;
					a = bfs(sx, sy, gx, gy);
					if(a!=INF)
						ans = max(a, ans);
				}
			}
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAXN 200000
using namespace std;
long long n,W,w[MAXN],v[MAXN],dp[MAXN];
int main(){
	scanf("%lld%lld",&n,&W);
	for(int i=0;i<n;i++){
		scanf("%lld%lld",w+i,v+i);
	}
	for(int i=0;i<n;i++){
		for(int j=W;j>=w[i];j--){
			dp[j] = max(dp[j],dp[j-w[i]]+v[i]);
		}
	}
	printf("%lld\n",dp[W]);
	return 0;
}

Measured memory_bytes: 3072
//整数に直す方法
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using ll = long long;
const int INF = 2147483647;

int main(){
	ll a,b,c;
	cin >> a >> b >> c;
	ll d = c-a-b;
	if(d>0 && d*d>4*a*b){
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}


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

using namespace std;
const int M = 1000000007;

int main() {
	int H, W;
	cin >> H >> W;

	vector<vector<char> > a(H, vector<char>(W));
	for(auto &x: a) {
		for(auto &c: x) cin >> c;
	}

	vector<vector<int> > dp(H, vector<int>(W, 0));

	for(int i = 0; i < H; i++) {
		for(int j = 0; j < W; j++) {
			if(i == 0 && j == 0) {
				dp[i][j] = 1;
				continue;
			}
			if(a[i][j] == '#') {
				dp[i][j] = 0;
				continue;
			}
			dp[i][j] = 0;
			if(i > 0 && a[i-1][j] == '.') {
				dp[i][j] += dp[i-1][j];
				dp[i][j] %= M;
			}
			if(j > 0 && a[i][j-1] == '.') {
				dp[i][j] += dp[i][j-1];
				dp[i][j] %= M;
			}
		}
	}

	cout << dp[H-1][W-1] << endl;
	return 0;
}


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

using namespace std;
int n, m;
int c[21];
int dp[21][50001];
int main(){
  cin >> n >> m;
  for(int i = 0; i < 21; i++){
    dp[i][0] = 0;
  }
  for(int i = 0; i < 21; i++){
    for(int k = 1; k < 50001; k++){
      dp[i][k] = 20000;
    }
  }
  for(int i = 1; i <= m; i++){
    cin >> c[i];
  }
  for(int i = 1; i <= m; i++){
    for(int k = 1; k <= 50000; k++){
      if(k >= c[i])
	dp[i][k] = min(dp[i][k-c[i]]+1,dp[i-1][k]);
      else
	dp[i][k] = dp[i-1][k];
    }
  }

  cout << dp[m][n] << endl;
}

Measured memory_bytes: 7184
M1, D1 = [int(i) for i in input().split()]
M2, D2 = [int(i) for i in input().split()]

monthend = [-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
if D1 == monthend[M1]:
    print('1')
else:
    print('0')

Measured memory_bytes: 3060
//#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>  
#include<iomanip>
#include<cstring>
#include<string>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<utility>
#include<set>
#include<bitset>
#include<queue>
#include<stack>
#include<deque>
#include<map>
#include<vector>
#include<ctime>
#define INF 1000000000000000000ll
#define ll long long
#define max(x,y) (x>y?x:y)
#define min(x,y) (x>y?y:x) 
#define db double
#define EPS 1e-6
#define mod 998244353
using namespace std;
char buf[1<<15],*fs,*ft;
inline char getc()
{
    return (fs==ft&&(ft=(fs=buf)+fread(buf,1,1<<15,stdin),fs==ft))?0:*fs++;
}
inline int read()
{
    register int x=0,f=1;register char ch=getc();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getc();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getc();}
    return x*f;
}
const int MAXN=1000010;
int n;
int ans;
char a[MAXN];
int main()
{
//	freopen("1.in","r",stdin);
	scanf("%s",a+1);
	n=strlen(a+1);
	int p=0;a[n+1]=0;
	for(int i=1;i<=n;++i)
	{
		int c=a[i]-'0';
		if(p)
		{
			if(c<=3||(c==4&&a[i+1]<='4'))ans+=p+c,p=0;
			else ans+=10-c-1;
		}
		else
		{
			if((a[i]=='5'&&a[i+1]>='5')||c>=6)ans+=10-c,p=1;
			else ans+=c;
		}
	}
	ans+=p;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 1280
x1, y1, x2, y2 = map(int, input().split())
delta_x = x1 - x2
delta_y = y1 - y2
x4 = delta_y + x1
y4 = -1 * delta_x + y1
x3 = x4 - delta_x
y3 = y4 - delta_y
print(x3, y3, x4, y4)

Measured memory_bytes: 3060
#include<iostream>
#include<math.h>
#include<algorithm>
#include<vector>
#include<map>

#define rep(i ,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

class UnionFind{
public:
    UnionFind(int& n){
        r = vector<int>(n+1, -1);
    }

    int findRoot(int x){
        if(r[x] < 0) return x;
        return findRoot(r[x]);
    }

    void unite(int& x, int& y){
        x = findRoot(x);
        y = findRoot(y);
        if (x == y)      return;
        if (r[x] > r[y]) swap(x, y);
        r[x] += r[y];
        r[y] = x;
        return;
    }

    int size(int& x) {
        return -r[findRoot(x)];
    }

private:
    vector<int> r;
};



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

    UnionFind uf(n);
    for(int i = 0; i < m; ++i){
        cin >> a >> b;
        uf.unite(a, b);
    }

    int ans = 0;
    for(int i = 1; i <= n; ++i) ans = max(ans, uf.size(i));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4048
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 1e2 + 5;
const int INF = 1e9 + 7;

int x, y;

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> x >> y;
	if ((y < 2) || (y & 1))
	{
		cout << "No";
		return 0;
	}
	if ((y % 4 == 0 && y / 4 == x) || y / 2 == x)
	{
		cout << "Yes";
		return 0;
	}
	int maxc = (y - 4) / 2;
	for (int i = 1; i <= maxc; i++)
	{
		int total = i * 2 + (x - i) * 4;
		if (total == y)
		{
			cout << "Yes";
			return 0;
		}
	}
	cout << "No";
	return 0;
}
//10-09-2020 17:50:07

Measured memory_bytes: 3628
#pragma GCC optimize ("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
#define all(x) x.begin(), x.end()
#define trav(i,a) for(auto &i:a) 
inline int in(){int x;scanf("%lld",&x);return x;}
int32_t main()
{
	int n=in();int k=in();
	vector<int> a(n);
	for(int &i:a)i=in();
	int g=a[0];
	for(int i:a)g=__gcd(g,i);
	for(int i:a)
	{
		if((i-k)>=0 and (i-k)%g==0){puts("POSSIBLE");return 0;}
	}
	puts("IMPOSSIBLE");
	
	
}


Measured memory_bytes: 3936
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <ctime>
#include <map>
#include <iomanip>
using namespace std;

typedef long long ll;

#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
 
long gcd(long long a, long long b){
	if (a%b==0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}
}
 
long lcm(long long a, long long b){
	return a / gcd(a,b) * b;
}
 
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a < b) { a = b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a > b) { a = b; return 1; } return 0; }
 
const ll INF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS = 1e-10;

int n;
int a[212345];
int cnt;

int main(){
	cin >> n;

	REP(i,n){
		cin >> a[i];
	}

	REP(i,n){
		if (a[i] == 1) cnt = 1;
		if (a[i] == cnt+1) cnt++;
	}

	if (cnt == 0) cout << -1 << endl;
	else cout << n - cnt << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include<iostream>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<string>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>
using lll = long long;
using ull = unsigned long long;
using namespace std;



int main(){
  lll ii,jj,kk;
  int n,oddnum;
  oddnum=0;
  cin >> n;
  for(ii=1;ii<=n;ii++){
    if(ii%2==1){
      oddnum++;
    }
  }
  double rate;
  rate = oddnum/(double)n;
  cout << rate << endl;
  return 0;
}


Measured memory_bytes: 384
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.ascii;

int INF = 1<<25;
struct Pos{int y, x;}
int[] dx = [1, 0, -1,  0, 0];
int[] dy = [0, 1,  0, -1, 0];
void main() {
    while(true) {
        int H, W;
        readf("%d %d\n", &H, &W);
        if (H==0 && W==0) break;

        Pos player;
        Pos[] ghost;
        bool[][] grid = H.iota.map!(i => readln.chomp.enumerate.tee!((a) {
            if (a.value=='A') player = Pos(i.to!int, a.index.to!int);
            if (a.value=='B') ghost ~= Pos(i.to!int, a.index.to!int);
        }).map!(a => (a.value!='#')).array).array;

        int[][] dist = new int[][](H, W);
        foreach(ref e; dist) e[] = INF;
        auto list = DList!Pos(player);
        dist[player.y][player.x] = 0;
        while (!list.empty) {
            Pos p = list.front;
            list.removeFront;
            foreach(int i; 0..4) {
                int _y = p.y+dy[i];
                int _x = p.x+dx[i];
                if (0<=_y && _y<H && 0<=_x && _x<W) {
                    if (grid[_y][_x] && dist[_y][_x]==INF) {
                        list.insert(Pos(_y, _x));
                        dist[_y][_x] = dist[p.y][p.x]+1;
                    }
                }
            }
        }

        int[] pattern = readln.chomp.map!(c => c=='6'?0:c=='2'?1:c=='4'?2:c=='8'?3:4).array;
        bool flag = false;
        int[] ans;
        int time = 0;
        for(int _=0; _<100000; _++) {
            foreach(i; pattern) {
                if (dist[ghost.back.y][ghost.back.x] <= time) {
                    ans = [time, ghost.back.y, ghost.back.x];
                    flag = true;
                    break;
                }
                ghost ~= Pos(min(H-1, max(0, ghost.back.y+dy[i])), min(W-1, max(0, ghost.back.x+dx[i])));
                time++;
            }
        }
        writeln(flag ? ans.to!(string[]).join(" "):"impossible");
    }
}

Measured memory_bytes: 15284
#include "iostream"
#include "math.h"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "numeric"
using namespace std;
typedef long long ll;

int main() {
	int n;
	cin >> n;
	string str;
	cin >> str;
	for (int i = 0; i < str.size(); i++) {
		str[i] += n;
		if (str[i] > 'Z') {
			str[i] -= 26;
		}
	}
	cout << str << endl;
}

Measured memory_bytes: 256
import kotlin.math.min

fun main() = abc167c()

@OptIn(ExperimentalStdlibApi::class)
fun abc167c() {
    data class Book(val price: Long, val exp: List<Long>)

    val (n, m, x) = readLine()!!.split(' ').map { it.toLong() }
    val books = (1..n).map {
        val line = readLine()!!.split(' ').map { it.toLong() }
        Book(line[0], line.drop(1))
    }

    var answer = Long.MAX_VALUE

    searchAllPatterns(2, n.toInt()) { pattern ->
        val filtered = books.filterIndexed { index, _ -> pattern[index] == 1L }

        val experiences = LongArray(m.toInt())
        filtered.forEach { it.exp.forEachIndexed { index, l -> experiences[index] += l } }

        if (experiences.all { it >= x }) {
            answer = min(answer, filtered.map { it.price }.sum())
        }
    }

    println(answer.takeIf { it < Long.MAX_VALUE } ?: -1)
}

@Suppress("SameParameterValue")
private inline fun searchAllPatterns(numberOfChoices: Int, length: Int, action: (LongArray) -> Unit) {
    val patterns = (1..length).fold(1L) { acc: Long, _: Int -> acc * numberOfChoices }
    for (i in 0 until patterns) {
        val array = LongArray(length)
        var div = 1
        for (j in 0 until length) {
            array[length - j - 1] = (i / div) % numberOfChoices
            div *= numberOfChoices
        }
        action(array)
    }
}


Measured memory_bytes: 43536
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <tuple>

#define rep(i,n) for(ll i=0;i<n;i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;
using Graph = vector<vector<ll>>;
//	std::cout<<std::fixed<<std::setprecision(10);

int main() {
	int N;
	cin >> N;
	vector<int> d(N);
	rep(i, N) cin >> d[i];

	int sum = 0;
	int seq_sum = 0;
	rep(i, N) {
		sum += d[i];
		seq_sum += d[i]*d[i];
	}

	cout << ((sum*sum)-seq_sum)/2 << endl;
	
	return 0;
}

Measured memory_bytes: 256
object Main extends App {
    val scan = new java.util.Scanner(System.in)
    val n = scan.next().toInt
    val blue = for (i <- 1 to n) yield scan.next()
    val m = scan.next().toInt
    val red  = for (i <- 1 to m) yield scan.next()
    var dic = collection.mutable.Map[String, Int]()
    blue.foreach(x => if ((dic get x) == None) { dic(x) = 1  } else { dic(x) = dic(x) + 1 })
    red.foreach( x => if ((dic get x) == None) { dic(x) = -1 } else { dic(x) = dic(x) - 1 })
    println(math.max(dic.values.max, 0))
}

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

int main( ){

    ll ans = 0 ;

    int n ;

    cin >> n ;

    int a[n] ;

    for( int i = 0 ; i < n ; i ++ ){

        cin >> a[i] ;

    }

    for( int i = 1 ; i < n ; i ++ ){

        if( a[i] < a[i-1] ){

            ans += a[i-1] - a[i] ;

            a[i] = a[i-1] ;

        }

    }

    cout << ans << endl ;

}


Measured memory_bytes: 4416
#include <bits/stdc++.h>
#define FOR(i, l, r) for(ll i = l; i < r; i++)
#define rep(i, N) FOR(i, 0, N)
using namespace std;

typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<ll> vl;
const ll MOD = round(1e9+7);

/*nCk (mod MOD)の計算 BEGIN*/
//faccal -> n!, k!^(MOD-2)の計算(初期化)
//comb -> nCk (mod MOD)の計算
ll mlpow(ll x, ll p) { //x^p(long long)%MOD
    ll tmp = 1;
    if(p == 0) return 1;
    //繰り返し二乗法
    while(p != 0) {
        if(p & 1) tmp = tmp*x % MOD;
        x = x*x % MOD;
        p = p >> 1;
    }
    return tmp;
}

int facnum = 700000;
vl fac(facnum);   //n!
vl facM2(facnum);  //k!^(MOD-2)

void faccal(ll up) {
    fac[0] = 1;
    facM2[0] = 1;
    for(ll i = 0; i<up+1; i++){
        fac[i+1] = fac[i]*(i+1) % MOD; // n!(mod M)
        facM2[i+1] = facM2[i]*mlpow(i+1, MOD-2) % MOD; // k!^{M-2} (mod M) ←累乗にmpowを採用
    }
}

ll comb(ll n, ll k) {
    if(n == 0 && k == 0) return 1;
    if(n < k || n < 0) return 0;
    if(k > n-k) k = n-k;
    ll tmp = facM2[n-k]*facM2[k] % MOD;
    return tmp*fac[n] % MOD;  //nCk = n!*(k!)^(M-2)*((n-k)!)^(M-2)
}
/*nCk (mod MOD)の計算 END*/

int main() {
    int X,Y; cin >> X >> Y;
    int a = (2*Y-X)/3;
    int b = (2*X-Y)/3;
    if(((2*Y-X)%3 != 0) || ((2*X-Y)%3 != 0)
    || a < 0 || b < 0) {
        cout << 0 << endl;
        return 0;
    }

    faccal(a+b+1);

    cout << comb(a+b, a) << endl;
    return 0;
}


Measured memory_bytes: 14272
#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(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} 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; }

int main(){
    string S;
    lint K;
    cin >> S >> K;
    vector<int> arr{1};
    for(int i = 1; i < S.size(); i++){
        if(S[i - 1] == S[i]){
            arr.back()++;
        }else{
            arr.push_back(1);
        }
    }
    if(arr.size() == 1){
        cout << S.size() * K / 2 << endl;
        return 0;
    }
    lint ans = 0;
    for(int i = 1; i < arr.size() - 1; i++){
        ans += arr[i]/ 2;
    }
    if(S[0] == S.back()){
        cout << ans * K + arr[0] / 2 + arr.back() / 2 + (arr[0] + arr.back()) / 2 * (K - 1) << endl;
    }else{
        cout << (ans + arr[0] / 2 + arr.back() / 2) * K << endl;
    }
}


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

void comb(vector<vector <long long int> > &v) {
	for (int i = 0;i <v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int k = 1;k <v.size();k++) {
		for (int j = 1;j<k;j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}


int main(){
	int n, a, b;
	cin >> n >> a >> b;
	vector<ll>v(n);
	for (int i = 0;i < n;i++) {
		cin >> v[i];
	}

	sort(v.begin(), v.end());
	ll sum = 0;
	for (int i = 0;i < a;i++) {
		sum += v[n - 1 - i];
	}
	double ans = (double)sum / a;
	cout << fixed << ans << endl;


	vector<vector<long long int> > co(n + 1, vector<long long int>(n + 1, 0));
	comb(co);

	sum = 0;
	for (int i = 0;i < a - 1;i++) {
		sum += v[n - 1 - i];
	}
	ll ans2 = 0;
	for (int i = a;i <= b;i++) {
		sum += v[n - i];
		if (ans*i == (double)sum) {
			int m = upper_bound(v.begin(), v.end(), v[n - i]) - lower_bound(v.begin(), v.end(), v[n - i]);
			int c = upper_bound(v.begin(), v.end(), v[n - i]) - (v.end() - i);
			ans2 += co[m][c];
		}
	}
	cout << ans2 << endl;


	return 0;
}

Measured memory_bytes: 256
from collections import deque

a, b, c, x = [int(input()) for i in range(4)]
d = min(x // 500, a)
e = min((x - d * 500) // 100, b)
f = min((x - d * 500 - e * 100) // 50, c)
y = deque([[d, e, f]])
if d * 500 + e * 100 + f * 50 < x:
    print(0)
else:
    g = 1
    y.append([d, e, f])
    s, t, u = y.popleft()
    while s > 0:
        s -= 1
        t += 5
        y.append([s, t, u])
        if t <= b:
            g += 1
    while y:
        s, t, u = y.popleft()
        while t > 0:
            t -= 1
            u += 2
            if u > c:
                break
            if t <= b:
                g += 1
    print(g)

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

int calc(int x){
  int c=(x+1)/2%2;
  if(x%2==0)return x^c;
  return c;
}

signed main(){
  int a,b;
  cin>>a>>b;
  a--;
  cout<<(calc(a)^calc(b))<<endl;  

  return 0;
}



Measured memory_bytes: 256
import math 
def isPrime(n):
    if n == 1:
        return False
    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True
def nextPrime(N):
    if N <= 1:
        return 2
    prime = N
    found = False
    while(not found): 
        prime = prime + 1
        if(isPrime(prime) == True): 
            found = True
    return prime 
A = int(input())
N = A-1
print(nextPrime(N)) 


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
using namespace std;
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;
ll inv[200010], fac[200010], finv[200010];

ll C(int a, int b) {
  if(a < b) return 0;
  return fac[a] * (finv[b]*finv[a-b] % MOD) % MOD;
}

int main() {
  int H, W, A, B; cin >> H >> W >> A >> B; H--, W--;
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for(int i = 2; i < 200010; ++i) {
    inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD;
    fac[i] = fac[i-1] * (ll)i%MOD;
    finv[i] = finv[i-1]*inv[i]%MOD;
  }
  ll ret = C(W+H, W);

  for(int i = 0; i < B; ++i) {
    ll all = C((H-A)+i, i);
    ll all2 = C((W-i)+(A-1), A-1);
    ret -= all*all2%MOD;
    if(ret < 0) ret += MOD;
  }
  cout << ret << endl;

  return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int , int> P;
typedef pair<ll, ll> PL;
const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}
 
int a[3];

int main(){
    cin >> a[0] >> a[1] >> a[2];

    sort(a, a+3);

    cout << a[2]*10+a[1] + a[0] << endl;

}

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

int main(){
    string s; cin>>s;

    for(int i=0;i<s.length();i++){
        for(int j=i+1;j<s.length();j++){
            if(s[i]==s[j]){
                cout<<"no"<<endl;
                return 0;
            }
        }
    }
    cout<<"yes"<<endl;
}

Measured memory_bytes: 256
/*
    B
*/
#include <bits/stdc++.h>
#define MAX 100

using namespace std;

int N, ans;
int A[MAX], B[MAX], C[MAX];

int main() {
	cin >> N;
	for(int i = 1; i <= N; ++i) cin >> A[i];
	for(int i = 1; i <= N; ++i) cin >> B[i];
	for(int i = 1; i < N; ++i) cin >> C[i];
	for(int i = 1; i <= N; ++i)	ans += B[A[i]];
	for(int i = 1; i < N; ++i) if(A[i + 1] == A[i] + 1) ans += C[A[i]];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))

N, T = mi()
ct = li2(N)

ans = float('inf')

for i in range(N):
    if ct[i][1] > T:
        continue
    if ct[i][0] < ans:
        ans = ct[i][0]

if ans == float('inf'):
    print('TLE')
else:
    print(ans)
    



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

int main(){
  char S[10];
  int i,j,n;
  scanf("%s",S);
  int len = strlen(S);

  if(S[0]!='A'){printf("WA");return 0;}

  n=0;
  for(i=2;i<len-1;i++){
    if(S[i]=='C'){n++;j=i;}}
  if(n!=1){printf("WA");return 0;}

  for(i=1;i<j;i++){
    if('A'<=S[i]&&S[i]<='Z'){printf("WA");return 0;}
  }
  for(i=j+1;i<len;i++){if('A'<=S[i]&&S[i]<='Z'){printf("WA");return 0;}
  }

  printf("AC");
  return 0;
}


Measured memory_bytes: 128
N = int(input())
testimo_ls = [ [] for i in range(N) ]
rst = 0
for i in range(N):
    A = int(input())
    for j in range(A):
        x, y = map(int, input().split(' '))
        testimo_ls[i].append([x - 1, y])
for i in range(1 << N):
    honest_ls = []
    for j in range(N):
        if i >> j & 1:
            honest_ls.append(j)
    is_ok = True
    for s in honest_ls:
        for t in testimo_ls[s]:
            if t[0] in honest_ls and t[1] == 0:
                is_ok = False
            if t[0] not in honest_ls and t[1] == 1:
                is_ok = False
    if is_ok:
        rst = max(rst, len(honest_ls))
print(rst)

Measured memory_bytes: 9228
def main():
    N = int(input())
    P = [None] * N
    for i in range(N):
        X, L = map(int, input().split())
        l, r = X-L, X+L
        P[i] = (l, r)
    P.sort(key=lambda x: x[1])
    ans = 0
    lbound = -float("inf")
    for l, r in P:
        if l < lbound:
            continue
        ans += 1
        lbound = r
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 52696
// Crt. 2019-12-10  21:36:00

#include <algorithm>
#include <iostream>
#include <cstdio>
#define N 200005
using namespace std;
typedef long long ll;
const ll INF = 1e18;

int n;
ll pmx[N], pmi[N], smx[N];
struct Node { ll x, y; } p[N];

inline bool cmp(Node a, Node b) {
    return a.x > b.x;
}

int main() {
#ifdef LOCAL_JUDGE
    freopen("work.in", "r", stdin);
    freopen("work.out", "w", stdout);
#endif

    cin >> n;
    ll tmp = 2e18;
    for (int i = 1; i <= n; ++i) {
        scanf("%lld%lld", &p[i].x, &p[i].y);
        if (p[i].x < p[i].y) swap(p[i].x, p[i].y);
        tmp = min(tmp, p[i].y);
    }

    for (int i = 1; i <= n; ++i)
        if (p[i].y == tmp) { swap(p[i], p[n]); break;}

    sort(p + 1, p + n, cmp);

    ll ans = 2e18;
    
    pmx[1] = pmi[1] = p[1].y;
    for (int i = 2; i <= n; ++i)
        pmx[i] = max(pmx[i - 1], p[i].y),
        pmi[i] = min(pmi[i - 1], p[i].y);

    smx[n] = p[n].y;
    for (int i = n - 1; i >= 1; --i)
        smx[i] = max(smx[i + 1], p[i].y);

//    for (int i = 1; i <= n; ++i)
//        cout << p[i].x << " " << p[i].y << endl;

    for (int i = 1; i < n; ++i) {
        ll Rmax = p[1].x, Rmin = p[n].y;
        ll Bmax = max(p[n].x, max(pmx[i], p[i + 1].x));
        ll Bmin = min(p[n].x, min(pmi[i], i != n - 1 ? p[n - 1].x : INF));
        //cout  << i << " " << Rmax << " " << Rmin << " " << Bmax << " " << Bmin << endl;
        ans = min(ans, (Rmax - Rmin) * (Bmax - Bmin));
    }

    for (int i = 1; i < n; ++i) {
        ll Rmax = max((i != n - 1 ? p[i + 1].x : p[i + 1].y), max(pmx[i], i + 2 < n ? smx[i + 2] : 0));
        ll Rmin = p[n].y, Bmax = max(p[1].x, p[n].x);
        ll Bmin = min(p[n].x, min(i != n - 2 ? p[n - 1].x : p[i].x, i != n - 1 ? p[i + 1].y : INF));
        //cout  << i << " " << Rmax << " " << Rmin << " " << Bmax << " " << Bmin << endl;
        ans = min(ans, (Rmax - Rmin) * (Bmax - Bmin));
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,a,b) for(int i=(a),_end_=(b);i<=_end_;i++)
#define DREP(i,a,b) for(int i=(a),_end_=(b);i>=_end_;i--)
#define EREP(i,a) for(int i=start[(a)];i;i=e[i].next)
template<class T>inline void chkmax(T &a,T b){ if(a<b)a=b;}
template<class T>inline void chkmin(T &a,T b){ if(a>b)a=b;}
#define fi first
#define se second
#define mkr(a,b) make_pair(a,b)
inline int read()
{
	int sum=0,p=1;char ch=getchar();
	while(!(('0'<=ch && ch<='9') || ch=='-'))ch=getchar();
	if(ch=='-')p=-1,ch=getchar();
	while('0'<=ch && ch<='9')sum=sum*10+ch-48,ch=getchar();
	return sum*p;
}

int main()
{
	int rd[100]={0};
	int k=6;
	while(k--)rd[read()]++;
	int ans=0;
	REP(i,1,4)ans+=rd[i]&1;
	if(ans<=2)puts("YES");
	else puts("NO");
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
 
int main(){
  fastIO;
  int h,w;
  cin>>h>>w;
  
  for(int i=0;i<h;i++){
    string s;
    cin >> s;
    cout << s << endl;
    cout << s << endl;
  }
  
  return 0;
}


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

int main(){
  int n;
  cin >> n;
  int ans = 0;
  vector<int> b(n-1);
  vector<int> a(n);
  rep(i,n-1)cin >> b[i];
  a[n-1] = b[n-2];
  a[0] = b[0];
  for(int i = n-2;i > 0;i--){
    if(b[i] == b[i-1]){
      a[i] = b[i];
    }
    else if(b[i] > b[i-1]){
      a[i] = b[i-1];
    }
    else if(b[i] < b[i-1]){
      a[i] = b[i];
    }
  }
  rep(i,n){
    ans += a[i];
    // cout << a[i] << endl;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
l = [[0 for _ in range(10)]for _ in range(10)]

for i in range(1,N+1):
  i = str(i)
  if i[0] == '0' or i[-1] == '0':
    pass
  else:
    l[int(i[0])][int(i[-1])] += 1

ans = 0

for i in range(1,10):
  for j in range(1,10):
    ans += l[i][j]*l[j][i]

print(ans)

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

using namespace std;

constexpr int N = 3e5 + 10;
constexpr int MOD = 1e9 + 7;
constexpr int MOD2 = 1e9 + 9;
constexpr int P = 727;

long long n, ans;
vector <long long> v, vec[N];
string s;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> s;
    for (long long mask = 0; mask < (1ll << n); mask++) {
        long long msk = mask << n;
        long long Hash1 = 0;
        long long Hash2 = 0;
        for (int i = n; i < 2 * n; i++) {
            if (msk & (1ll << i)) {
                Hash1 = ((Hash1 * P) + s[i]) % MOD;
            }
            else {
                Hash2 = ((Hash2 * P) + s[i]) % MOD;
            }
        }
        v.push_back (Hash2);
    }
    sort (v.begin(), v.end());
    v.resize (unique (v.begin(), v.end()) - v.begin());
    for (long long mask = 0; mask < (1ll << n); mask++) {
        long long msk = mask << n;
        long long Hash1 = 0;
        long long Hash2 = 0;
        for (int i = n; i < 2 * n; i++) {
            if (msk & (1ll << i)) {
                Hash1 = ((Hash1 * P) + s[i]) % MOD;
            }
            else {
                Hash2 = ((Hash2 * P) + s[i]) % MOD;
            }
        }
        int pos = lower_bound (v.begin(), v.end(), Hash2) - v.begin();
        vec[pos].push_back (Hash1);
    }
    for (int i = 0; i < (int)v.size(); i++)
        sort (vec[i].begin(), vec[i].end());
    reverse (s.begin(), s.end());
    for (long long mask = 0; mask < (1ll << n); mask++) {
        long long msk = mask << n;
        long long Hash1 = 0;
        long long Hash2 = 0;
        for (int i = n; i < 2 * n; i++) {
            if ((msk & (1ll << i)))
                Hash1 = ((Hash1 * P) + s[i]) % MOD;
            else
                Hash2 = ((Hash2 * P) + s[i]) % MOD;
        }
        int pos = lower_bound (v.begin(), v.end(), Hash1) - v.begin();
        if (v[pos] == Hash1)
            ans += upper_bound (vec[pos].begin(), vec[pos].end(), Hash2) - lower_bound (vec[pos].begin(), vec[pos].end(), Hash2);
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 16752
#include<iostream>
#include<vector>
using namespace std;
using ll=long long;
int n;
ll mod= 1e9+7;
ll dp[21][(1<<21)];
ll solve(int i,int state,vector<vector<int> > &arr)
{
    if(i==n)
    {
        return 1;
    }
    if(dp[i][state]!=-1)
    return dp[i][state];
    dp[i][state]=0;
    for(int j=0;j<n;j++)
    {
       if((state>>j)&1 && arr[i][j]==1)
        {
            dp[i][state]+=solve(i+1,(state^(1<<j)),arr);
            dp[i][state]%=mod;
        }
    }
    return dp[i][state];
}
int main()
{
    cin>>n;
    vector<vector<int>> arr(n,(vector<int>(n,0)));
    for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
    cin>>arr[i][j];
    for(int i=0;i<21;i++)
    {
        for(int j=0;j<1<<21;j++)
        {
            dp[i][j]=-1;
        }
    }
    cout<<(solve(0,(1<<n)-1,arr))%mod;

}

Measured memory_bytes: 347184
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> VI;
typedef vector<VI> VVI;
typedef pair<ll, ll> P;
#define FOR(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define PRINT(V) for (auto v : (V)) cout << v << " "
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const ll INF = numeric_limits<ll>::max();

int main()
{
    int k; cin >> k;
    int ans = -1;
    int n = 7;
    int p = 7;
    rep(i, k+1){
        if (n%k == 0){
            ans = i +1;
            break;
        }
        p *= 10;
        p %= k;
        n += p;
        n %= k;
    }
    cout << ans << endl;
    return 0;
}

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

//--------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

//--------------------------------------------
const double EPS = 1e-14;
const double PI  = acos(-1.0);

//--------------------------------------------


map <int, int> mp;
int main(){
  int n;
  int t;
  scanf("%d",&n);

  REP (i, n) {
    scanf("%d",&t);
    mp[t] += 1;
  }

  int ans = 0;
  for(auto it = mp.begin(); it != mp.end(); it++) {
    if (it->second % 2 == 1) ans++;
  }

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


Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
typedef vector<int> vi;
#define endl '\n'
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define rf(i,a,b) for(int i=a;i>=b;i--) 
#define fast_io ios_base::sync_with_stdio(0);
#define show(x) cout<<x<<endl;
#define pret(x) cout<<x<<endl; return 0;
#define disp(x) cout<<x<<" ";
#define let(x,y) cout<<x<<" "<<y<<endl;
ll MOD=1e9+7;
const int maxn=2e5+5;
 
int32_t main(){
    fast_io;
    ll a;
    long double b;
    cin>>a>>b;
    ll x = floor(a*b);
    show(x);
    return 0;
}

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

int main(){
    string s;
    bool t = true;
    cin >> s;
    int size = s.size();
    for (int i=0; i < size/2; i++){
        if (s[i] != s[size-i-1]){
            t = false;
        }
    }
    string s1;
    string s2;
    if(size%2 == 0){
        s1 = s.substr(0, size/2-1);
        s2 = s.substr(size/2, size-1);
    } else{
        s1 = s.substr(0, size/2);
        s2 = s.substr(size/2+1, size-1);
    }
    int size1 = s1.size();
    int size2 = s2.size();
    for (int i=0; i < size1/2; i++){
        if (s1[i] != s1[size1-i-1]){
            t = false;
        }
    }
    for (int i=0; i < size2/2; i++){
        if (s2[i] != s2[size2-i-1]){
            t = false;
        }
    }

    if (t){
        cout << "Yes" << endl;
    } else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    // #include <iostream>
    #include <string>
    #include <queue>
    #include <set>
    #include <list>
    #include <chrono>
    #include <random>
    #include <iostream>
    #include <algorithm>
    #include <cmath>
    #include <string>
    #include <vector>
    #include <map>
    #include <unordered_map>
    #include <stack>
    using namespace std;
    #define frn(i,a,b) for(ll i=a;i<b;i++)
    #define forn(i,a,b) for(ll i=a;i<=b;i++)
    #define frt(i,a,b) for(auto it=a;it!=b;it++)
    #define MP make_pair
    #define F first
    #define S second
    #define PB push_back
    #define SQ(a) (a)*(a)
    #define SUM(n) ((n)*(n+1))/2
    #define SqSUM(n) ((n)*(n+1)*(2*n+1))/2
    #define GMSUM(a,r,n) (a*pow(r,n)-a)/(r-1)
    // to sort vector of any kind string or any sorting form sort(v.begin(),v.end()); and for reverse use rbegin and rend
    const long long int md = 998244353;
    typedef long long ll;
    typedef long double ld;
    typedef pair<ll, ll> pi;
    typedef vector<ll> vi;
    typedef vector<vector<ll, ll> > vvi;
    // typedef bitset<5> bst;
    const ll MAX = LONG_MAX;
    int main()
    {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        ll a,b;
        cin>>a>>b;
        frn(i,b-a+1,b)
        cout<<max(i,(ll)-1000000)<<" ";
        frn(i,b,b+a)
        cout<<min(i,(ll)1000000)<<" ";
        return 0;
    } 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,n,a,b,c,d;
    char str[5];
    scanf("%d",&n);
    a = 0;
    b = 0;
    c = 0;
    d = 0;
    for(i = 1;i <= n;i++){
        scanf("%s",str);
        if(str[0] == 'A'){
            a++;
        }
        else if(str[0] == 'W'){
            b++;
        }
        else if(str[0] == 'T'){
            c++;
        }
        else if(str[0] == 'R'){
            d++;
        }
    }
    printf("AC x %d\n",a);
    printf("WA x %d\n",b);
    printf("TLE x %d\n",c);
    printf("RE x %d\n",d);
    return 0;
}


Measured memory_bytes: 3836
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
const int INF = 987654321;
const int MOD = 1000000007;

int main(){
  ll N,M,C;
  scanf("%lld %lld %lld",&N,&M,&C);
  ll B[30];
  int ans = 0;
  for(int i=0;i<M;i++) 
    scanf("%lld",&B[i]);
  for(int i=0;i<N;i++){
    ll ret = C;
    for(int j=0;j<M;j++){
      ll X; scanf("%lld",&X);
      ret += X*B[j];
    }
    if(ret > 0) ans++;
  }
  printf("%d\n",ans);
}

Measured memory_bytes: 256