akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


vector<vector<int>> v;
std::vector<int> p;
ll n,m;

bool check(vector<int> cand){
  F0R(i,m){
    int tSum = 0;
    F0R(j,v[i].size()){
      tSum += cand[v[i][j]-1];
    }
    if(tSum% 2 != p[i])
        return false;
  }
  return true;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n >> m;
    int k;
    int t;
    F0R(i,m){
      cin >> k;
      vector<int> tempV;
      F0R(j,k) {
        cin >> t;
        tempV.push_back(t);
      }
      v.push_back(tempV);
    }
  F0R(i,m){
    cin >> t;
    p.push_back(t);
  }
  int ans = 0;
  F0R(i,pow(2,n)){
    vi cand;
    int t = i;
    F0R(j,n){
      cand.push_back(t%2);
      t /= 2;
    }
    if(check(cand)) ans++;
  }

  cout << ans<< endl;









    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


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

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(lol i=0;i<lol(n);i++)
#define REPD(i,n) for(lol i=n-1;i>=0;i--)
#define FOR(i,a,b) for(lol i=a;i<=lol(b);i++)
#define FORD(i,a,b) for(lol i=a;i>=lol(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) lol(x.size()) //sizeをsize_tからllに直しておく
//定数
#define PI 3.1415926535897932385 //pi
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//最大値最小値
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main()
{
    lol result{0};
    lol n; cin >> n;
    lol k; cin >> k;
    vector<int> a(n+1);
    vector<int> b(n+1, 0);
    a[0] = 0;
    FOR(i, 1, n)
    {
        cin >> a[i];
    }
    int cur = 1;
    int m = 1;
    int c[n+1], d[n+1];
    while(true)
    {
        int tugi = a[cur];
        if(b[tugi] == 0)
        {
            b[tugi] = 1;
            c[tugi] = m;
            d[m] = tugi;
            m++;
        }
        else
        {
            cur = tugi;
            break;
        }
        cur = tugi;
        
    }
    int ro = m - c[cur];
    if(k < m)
        cout << d[k] << endl;
    else
    {
        k -= c[cur];
        k %= ro;
        cout << d[c[cur] + k] << endl;
    }
    

    //cout << result << endl;
    return 0;
}

Measured memory_bytes: 6336
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<bitset>
#include<queue>
#include<set>
#include<map>
using namespace std;
 
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define ROF(i,b,a) for (int i=(b);i>(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,n-1,-1)
 
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<bitset>
#include<queue>
#include<set>
#include<map>
using namespace std;
 
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define ROF(i,b,a) for (int i=(b);i>(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,n-1,-1)
 
typedef int i32;
typedef long long int i64;
typedef unsigned long long int ui64;
typedef float f32;
typedef double f64;
typedef long double f128;
typedef pair<int,int> Pi;
 
constexpr int INF = 1e9 + 7;
constexpr int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};
 
int main() {
    int N, K; cin>>N>>K;
    i64 cnt = 0;
    REP(i,N) {
        if ((2*(i+1))%K==0) cnt++;
    }
    i64 ans = 0;
    if (K%2==1) ans = cnt*cnt*cnt;
    else {
        ans = (cnt/2)*(cnt/2)*(cnt/2)+(cnt-cnt/2)*(cnt-cnt/2)*(cnt-cnt/2);
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const int mod = 1e9 + 7;
//const int mod = 998244353;
const ll infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;
void YesNo(bool j){cout << (j ? "Yes" : "No") << endl; return;}
void yesno(bool j){cout << (j ? "yes" : "no") << endl; return;}
template<class Head> void pt(Head&& head){cout << head << endl; return;}


int main() {
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  ll ans=0;
  if(a>=d) {
      cout << d << endl;
      return 0;
  }
  d-=a;
  ans+=a;
  d-=b;
  if(d>0){
      d=min(c,d);
      ans-=d;
  }
  pt(ans);
  return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<string>
#include<set>
#include<utility>
#include<vector>
#include<map>
#include<algorithm>

using namespace std;

int main(){
	/*
	//数あて
	int n;
	cin >> n;
	int p[200][3];

	for(int i=0;i<n;i++)
	{
		cin >> p[i][0] >> p[i][1] >> p[i][2];
	}

	int _p;
	for(int k=0;k<3;k++)
	{
		for(int i=0;i<n;i++)
		{
			_p = p[i][k];
			for(int j=i+1;j<n;j++)
			{
				if(_p == p[j][k])
				{
					p[i][k] = 0;
					p[j][k] = 0;
				}
			}
		}
	}

	for(int i=0;i<n;i++)
	{
		cout << p[i][0] + p[i][1] + p[i][2] << endl;
	}
	*/

	/*
	//得点
	int ai,am,as,ae,bi,bm,bs,be;
	cin >> ai >> am >> as >> ae >> bi >> bm >> bs >> be;
	int answer=ai+am+as+ae;
	if(answer < bi+bm+bs+be)
	{
	/	answer=bi+bm+bs+be;
	}
	cout << answer << endl;
	*/
	
	//おつり
/*	int onum;
	while(true){
		int N;
		cin >> N;
		if(N == 0) break;
		onum=0;
		int oturi = 1000-N;
		if(oturi >= 500)
		{
			onum++;
			oturi -= 500;
		}
		while(oturi>=100)
		{
			onum++;
			oturi -= 100;
		}
		if(oturi >= 50)
		{
			onum++;
			oturi -= 50;
		}
		while(oturi>=10)
		{
			onum++;
			oturi -= 10;
		}
		if(oturi >= 5)
		{
			onum++;
			oturi -= 5;
		}
		while(oturi>=1)
		{
			onum++;
			oturi -= 1;
		}
		 cout << onum << endl;
	}
   */

	//レシート
	/*
	while(true){
		int N;
		cin >> N;
		if(N==0) break;
		int a[9];
		for(int i=0;i<9;i++){
			cin >> a[0];
		}

	}
	
	/*
	int N;
	int i = 0;
	while(i<N){
		i++;
	}
	for(int i=0; i<N; i++)
	*/
	/*
	int N;
	int x;
	set<int> a;
	cin >> N;
	for(int i=0; i<N; i++){
		cin >> x;
		a.insert(x);
	}
	cout << a.size() << endl;
	*/
	
	//投票
	/*
	int N,M;
	cin >> N >> M;
	int a;
	int A[1000];
	int B[1000];
	int X[1000][2];
	
	for(int i=0; i<N; i++){
		cin >> A[i];
		X[i][0] = i;
		X[i][1] = 0;
	}
	for(int j=0; j<M;j++){
		cin >> B[j];
	}
	for(int j=0; j<M; j++){
		for(int i=0; i<N; i++){
			if(A[i] < B[j]){
				X[i][1]++;
				break;
			}
		}
	}
	for(int i=1; i<N; i++){
		if(X[i-1][1]<X[i][1])
			X[i-1][0] = X[i][0];
	}
	cout << X[0][0]+1 << endl;
	*/

	int N,M;
	cin >> N >> M;
	int A[1000];
	int vote[1000];
	for(int i=0; i<N; i++){
		cin >> A[i];
		vote[i] =0;
	}
	int B;
	for(int i=0; i<M; i++){
		cin >> B;
		for(int j=0; j<N; j++){
			if(A[j]<=B){
				vote[j]++;
				break;
			}
		}
	}
	int temps = 0;
	int ans=0;
	for(int i=0; i<N; i++){
		if(vote[i] >= temps){
			temps = vote[i];
			ans = i;
		}
	}
	cout << ans+1 << endl;
	return 0;
}
/*
int max(int i,int j){
	if(i < j) i=j;
	return i;
}
*/


Measured memory_bytes: 3004
import java.util.*;
import java.lang.*;
import java.io.*;

class Main {
    
    private static BufferedReader br;
    private static StringTokenizer strz; 
    
	public static void main (String[] args) throws java.lang.Exception {
		br=  new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		strz = new StringTokenizer(br.readLine());
		
		long sum = 0;
		long[] count = new long[100001];
		while(strz.hasMoreTokens()){
		    int x = Integer.parseInt(strz.nextToken());
		    sum += x;
		    ++count[x];
		}
		int q = Integer.parseInt(br.readLine());
		
		while(q-- > 0){
		    strz = new StringTokenizer(br.readLine());
		    int b = Integer.parseInt(strz.nextToken());
		    int c = Integer.parseInt(strz.nextToken());
		    
		    sum -= count[b]*b;
		    count[c] += count[b];
		    sum += count[b]*c;
		    count[b] = 0;
		    
		    System.out.println(sum);
		}
	}
}


Measured memory_bytes: 58380
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <cstring>
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <numeric>
#include <float.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef unsigned long long ll;
// 最大公約数求める関数
int my_gcd(int n , int m){
  if(n < m){
    int tmp = n;
    n = m;
    m = tmp;
  }
  int l  = n % m;
  while(l != 0){
    n = m;
    m = l;
    l = n % m;
}
return m;
}

//char⇒int関数
 int ctoi(char c) {
 	switch (c) {
		case '0': return 0;
		case '1': return 1;
		case '2': return 2;
		case '3': return 3;
		case '4': return 4;
		case '5': return 5;
		case '6': return 6;
		case '7': return 7;
		case '8': return 8;
		case '9': return 9;
		default: return 0;
	}
}
int nizyou(int a){
	return a*a;
}

int main(){
int N , D; cin >> N >> D;
vector<vector<int>> X(N,vector<int> (D));
rep(i,N){
	rep(j,D){
		cin >> X[i][j];
	}
}
int sum = 0;
int cnt = 0;
rep(i,N-1){
	for(int j = i + 1; j < N ;j++){
		for(int k = 0; k < D; k++){
			sum+= nizyou(abs(X[j][k]- X[i][k]));
		}
		rep(l,130){
			if(sum == nizyou(l)) cnt++;
		}
		sum = 0;
	}
}
cout << cnt << endl;
}


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

int main() {
  int K;
  cin >> K;
  if(K == 1 || K == 7) {
    cout << 1 << endl;
    return 0;
  }
  if(K % 2 == 0 || K % 5 == 0) {
    cout << "-1" << endl;
    return 0;
  }
  if(K % 7 == 0) {
    K /= 7;
  }
  vector<int> data(K);
  int b = 1;
  data.at(0) = 1;
  for(int i = 1; i < K; i++) {
    b *= 10;
    b %= K;
    data.at(i) = (data.at(i - 1) + b) % K;
    if(data.at(i) == 0) {
      cout << i + 1 << endl;
      return 0;
    }
  }
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/03/04  Problem: ABC 098 C / Link: http://abc098.contest.atcoder.jp/tasks/abc098_c  ----- */

struct Cumusum {
	vector<LL>csum;
	Cumusum(vector<LL>&a) {
		csum.assign((int)a.size() + 1, 0);
		for (int i = 0; i < (int)a.size(); i++) {
			csum[i + 1] = csum[i] + a[i];
		}
	}
	LL query(int l, int r) {
		return csum[r] - csum[l];
	}
};

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

	LL N;
	cin >> N;
	string s; cin >> s;
	VL e(N), w(N);
	FOR(i, 0, N) {
		e[i] = s[i] == 'E';
		w[i] = s[i] == 'W';
	}
	Cumusum E(e), W(w);
	LL ans = LINF;
	FOR(i, 0, N) {
		ans = min(ans, W.query(0, i) + E.query(i + 1, N));
	}



	cout << (ans) << "\n";

	return 0;
}


Measured memory_bytes: 10004
import sys
import itertools

n = int(input())
xy_list = [list(map(int, input().split())) for _ in range(n)]
if n == 1:
    print(1)
    sys.exit()

counts = dict()
for (x1, y1), (x2, y2) in itertools.combinations(xy_list, 2):
    for pq in ((x2 - x1, y2 - y1), (x1 - x2, y1 - y2)):
        counts.setdefault(pq, 0)
        counts[pq] += 1
max_count = max(counts.values())
print(n - max_count)


Measured memory_bytes: 3444
#include <iostream>
#include <iterator>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <numeric>
#include <iomanip>
#include <limits>

using namespace std;

int main(){

    int ans=0;
    int n;
    cin>>n;

    if(10>n){
        ans+=n;
    }
    else if(100>n){
        ans=9;
    }
    else if(1000>n){
        ans+=9+(n-99);
    }
    else if(10000>n){
        ans+=9+900;
    }
    else if(100000>n){
        ans+=9+900+(n-9999);
    }
    else if(100000==n){
        ans+=9+900+90000;
    }

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


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

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair
 
using namespace std;
 
const LL MOD=1e9+7;

int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if((a==b&&a!=c)||(a==c&&a!=b)||(b==c&&a!=b)) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

// #define int ll
#define REP(i,n) for (int i = 0; i < (n); ++i)
#define FORE(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define debug(x) cerr << #x << ": " << x << '\n'

#define fst first
#define pb push_back

const int MOD = (int)1e9 + 7;

signed main() {
    int N;

    cin >> N;

    vector<int> As(N);
    REP(i, N) {
        cin >> As.at(i);
    }

    int ans = 0;
    for (auto a : As) {
        ans = ans ^ a;
    }

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


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N =2e5+100;
ll ans,c[N]; int a[N],n;
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;++i){
        scanf("%d",&a[i]);
        ans+=c[a[i]]; c[a[i]]++;
    }
    for(int i=1;i<=n;++i){
        ans-=c[a[i]]*(c[a[i]]-1)/2;
        c[a[i]]--;
        ans+=c[a[i]]*(c[a[i]]-1)/2;
        printf("%lld\n",ans);
        ans-=c[a[i]]*(c[a[i]]-1)/2;
        c[a[i]]++;
        ans+=c[a[i]]*(c[a[i]]-1)/2;
    }
}

Measured memory_bytes: 3968
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define INF 1000000007
using namespace std;

int main(void){
	int n,y; cin >> n >> y;
	int huku=-1,higu=-1,nogu=-1;
	for(int i=0; i<=n; i++){
		for(int j=0; i+j<=n; j++){
			if(i*10+j*5+(n-i-j)==y/1000){
				huku=i;higu=j;nogu=n-i-j;
			}
		}
	}
	cout << huku << " " << higu << " " << nogu << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split()))
a.sort()
a.reverse()
Alice = 0
Bob = 0
for i in range(0, len(a), 2):
        Alice += a[i]
        
for i in range(1, len(a), 2):
        Bob += a[i]

print(Alice-Bob)

Measured memory_bytes: 3064
MOD = 10 ** 9 + 7

L = input().strip()

count = 1
over = 0
for i in range(len(L) - 1, -1, -1):
	c = L[i]
	if c == '1':
		count = (count * 3 + over) % MOD
		over = (over * 2) % MOD
	else:
		count = count
		over = (count * 2 + over * 3) % MOD

print(count)


Measured memory_bytes: 3188
def main():
    N, X, Y = map(int, input().split())

    dis = [0] * (N - 1)
    for i in range(N):
        for j in range(i+1, N):
            dis[min(j-i-1, abs(i+1-X) + abs(j+1-Y))] += 1
    for d in dis:
        print(d)


    return 0


if __name__ == '__main__':
    main()

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

using namespace std;
int main(void){


    string s;
    cin >> s;
    
    int index = 0;
    bool result = true;
    
    reverse(s.begin(), s.end());
    
    for(;;) {
        if(s.substr(index, 7) == "remaerd") {
            index += 7;
        }
        else if(s.substr(index, 6) == "resare") {
            index += 6;
        }
        else if(s.substr(index, 5) == "maerd" || s.substr(index, 5) == "esare") {
            index += 5;
        }
        else {
            result = false;
            break;
        }
        if(index >= s.size()) break;
    }
    
    if(result) cout << "YES" << endl;
    else cout << "NO" << endl;
    
//    cout << index << endl;
    
    return 0;
    
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/02/28  Problem: ABC 110 C / Link: http://abc110.contest.atcoder.jp/tasks/abc110_c  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL ans = 0LL;

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

	string s, t; cin >> s >> t;
	VVI table(26, VI(26, 0));
	FOR(i, 0, SZ(s)) {
		int a = s[i] - 'a';
		int b = t[i] - 'a';
		table[a][b]=1;
	}

	int ok = 1;
	FOR(i, 0, 26) {
		int cnt = 0;
		FOR(k, 0, 26) {
			if (table[i][k])cnt++;
		}
		ok &= cnt < 2;
		cnt = 0;
		FOR(k, 0, 26) {
			if (table[k][i])cnt++;
		}
		ok &= cnt < 2;
	}




	cout << (ok ? "Yes" : "No") << "\n";

	return 0;
}


Measured memory_bytes: 916
fn main() {
    let mut buf = String::new();

    std::io::stdin().read_line(&mut buf).unwrap();

    let mut iter = buf.trim().split_whitespace();

    let width: i32 = iter.next().unwrap().parse().unwrap();
    let height: i32 = iter.next().unwrap().parse().unwrap();
    let x: i32 = iter.next().unwrap().parse().unwrap();
    let y: i32 = iter.next().unwrap().parse().unwrap();
    let r: i32 = iter.next().unwrap().parse().unwrap();

    let message = if (width >= x + r && x - r >= 0) && (height >= y + r && y - r >= 0){
        "Yes"
    } else {
        "No"
    };

    println!("{}", message);
}


Measured memory_bytes: 5020
#include <cstdio>
int f(int n){
    int count = 0;
    for (int x = 1; x*x < n; x++){
        for (int y = 1; x*x+y*y+x*y < n; y++){
            for (int z = 1; x*x+y*y+z*z+x*y+y*z+x*z <= n; z++){
                if (x*x+y*y+z*z+x*y+y*z+x*z == n) 
					count++;
            }
        }
    }
    return count;
}

int main(){
    int n; scanf("%d", &n);
    for (int i = 1; i <= n; i++){
        int ans = f(i);
        printf("%d\n", ans);
    }
    return 0;
}

Measured memory_bytes: 3228
#include<bits/stdc++.h>
using namespace std;
const int N=400005;
int n,m,c[N];
struct data{
	int l,r;
}a[N];
bool cmp(data a,data b){
	return a.r-a.l+1<b.r-b.l+1;
}
void add(int i,int v){
	i++;
	while(i<=m+1){
		c[i]+=v;
		i+=i&(-i);
	}
}
int sum(int i){
	i++;
	int res=0;
	while(i){
		res+=c[i];
		i-=i&(-i);
	}
	return res;
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++){
		scanf("%d%d",&a[i].l,&a[i].r);
	}
	sort(a+1,a+n+1,cmp);
	int now=0;
	for(int i=1;i<=m;i++){
		int ans=n-now;
		for(int j=i;j<=m;j+=i){
			ans+=sum(j);
		}
		printf("%d\n",ans);
		while(now<n&&a[now+1].r-a[now+1].l+1<=i){
			now++;
			add(a[now].l,1);
			add(a[now].r+1,-1);
		}
	}
	return 0;
}

Measured memory_bytes: 5120
package main

import (
	"bufio"
	. "fmt"
	"os"
	"strconv"
)

var (
	inn = bufio.NewScanner(os.Stdin)
	out = bufio.NewWriter(os.Stdout)
)

func main() {
	defer out.Flush()
	inn.Buffer([]byte{}, 1000000)
	inn.Split(bufio.ScanWords)
	//prep
    a,b:=rd(),rd()
    Fprint(out,a*b);
}

//-------------------template------------------
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}
func maxll(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func minll(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}
func rd() (x int) {
	inn.Scan()
	x, _ = strconv.Atoi(string(inn.Bytes()))
	return x
}
func rdll() (x int64) {
	inn.Scan()
	x, _ = strconv.ParseInt(string(inn.Bytes()), 10, 64)
	return x
}
func rds() string {
	inn.Scan()
	return string(inn.Bytes())
}



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

#define max 500000
#define maxsize 2000000000
int cunt;
int L[max / 2 + 2], R[max / 2 + 2];

void merge(int A[], int n, int left, int mid, int right)
{
	int i, j;
	int n1, n2;
	n1 = mid-left;
	n2 = right-mid;
	for (i = 0; i < n1; i++)L[i]=A[left+i];
	for (i = 0; i < n2; i++)R[i] = A[mid+i];
	L[n1] = R[n2] = maxsize;
	i = 0; j = 0;
	for (int k = left; k < right; k++)
	{	
		cunt++;
		if (L[i] > R[j])
			A[k] = R[j++];
		else A[k] = L[i++];
	}
}

void mergesort(int A[], int n, int left, int right)
{
	if (left + 1 < right)
	{
		int mid = (left + right) / 2;
		mergesort(A, n, mid, right);
		mergesort(A, n, left, mid);
		merge(A, n, left, mid, right);
	}
}

int main()
{
	int A[max], n, i;
	cunt = 0;

	cin >> n;
	for (i = 0; i < n; i++)
		cin >> A[i];

	mergesort(A, n, 0, n);

	for (i = 0; i < n; i++)
	{
		if (i)cout << " ";
		cout << A[i];
	}

	cout << endl << cunt << endl;
	return 0;
}


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

int main() {
    int i, n, m, max=0;
    string name;
    map<string, int> blue;

    cin >> n;
    for (i=0; i<n; i++) {
        cin >> name;
        blue[name]++;
    }

    cin >> m;
    for (i=0; i<m; i++) {
        cin >> name;
        blue[name]--;
    }

    for (auto itr = blue.begin(); itr != blue.end(); itr++) {
        if (max < itr->second) max=itr->second;
    }
    cout << max << endl;
}

Measured memory_bytes: 3576
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

ans = 0
"""
ai = 0
bi = 0
while 1:
    if max(b) == 0:
        break
    if a[ai] < b[bi]:
        ans += a[ai]
        b[bi] -= a[ai]
        a[ai] = 0
        ai += 1
    elif a[ai] == b[bi]:
        ans += a[ai]
        b[bi] = 0
        a[ai] = 0
        ai += 1
        bi += 1
    else:
        ans += b[bi]
        a[ai] -= b[bi]
        b[bi] = 0
        if ai > bi:
            bi += 1
        else:
            ai += 1
            bi += 1
 #   print(a)
 #   print(b)
 #   print(ai,bi)
    if ai >= n+1 or bi >= n:
        break
print(ans)
"""
for i in range(n):
    if b[i] >= a[i] + a[i+1]:
        ans += a[i] + a[i+1]
        a[i+1] = 0
    else:
        if b[i] >= a[i]:
            ans += b[i]
            a[i+1] -= (b[i]-a[i])
        else:
            ans += b[i]
print(ans)

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

using namespace std;
using ll =long long;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//Write From this Line

int main()
{
	int n;
	cin >> n;
	vector<ll> a(n);
	rep(i,n) cin >> a[i] ;
	SORT(a);
	rSORT(a);
	ll MAX_dist = 0 ;
	ll num = a[0];
	ll count = 1 ;
	ll tmp = 0;
	For(i,1,n){
		//同じ値だったら数を＋
		if(num == a[i]) count ++ ;
		if(num != a[i]){
			num = a[i] ;
			count = 1 ;
		}
		if(count == 2){
			if(tmp != 0 ){
				cout << tmp * num << endl;
				return 0;
			} else {
				tmp = num ;
			}
		}
		if(count >= 4){
			cout << num * num << endl;
			return 0 ;
		}
	}
	cout << 0 << endl;
}


Measured memory_bytes: 1024
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int r = sc.nextInt();

        if (n>=10)
            System.out.println(r);
        else
        {
            int nr = r + 100*(10-n);
            System.out.println(nr);
        }
    }
}


Measured memory_bytes: 23252
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <vector>
#include <algorithm>
#include <map>

int main(){
  std::string S;
  std::cin >> S;
  int N = S.length();
  int count0 = 0;
  int count1 = 0;
  for (int i=0; i<N; i++){
    if (S[i]=='0'){
      count0++;
    } else if (S[i]=='1'){
      count1++;
    }
  }
  printf("%d\n",2*std::min(count0, count1));
  return 0;
}


Measured memory_bytes: 512
N = int(input())
A = list(map(int, input().split()))
print(" ".join(list(map(str, A))))
for i in range(1, N):
    v = A[i]
    j = i - 1
    while j >= 0 and A[j] > v:
        A[j+1] = A[j]
        j -= 1
    A[j+1] = v
    print(" ".join(list(map(str, A))))

Measured memory_bytes: 7688
#include <iostream>
#include <vector>
using namespace std;
int p = 1e9 + 7;
int main(){
	int h, w;
  	cin>>h>>w;
    vector<vector<char>> grid(h, vector<char>(w));
  	for(int i =0;i<h;i++){
    	for(int j =0;j<w;j++){
        	cin>>grid[i][j];
        }
    }
  	vector<vector<int>> dp(h, vector<int>(w));
	dp[0][0] = 1;
  	for(int i = 0;i<h;i++){
    	for(int j =0;j<w;j++){
         	if(grid[i][j] == '#') continue;
        	if(i>0 && grid[i-1][j]=='.')
          		dp[i][j] = (dp[i][j] + dp[i-1][j])%p; 
         	if(j>0 && grid[i][j-1]=='.')
				dp[i][j] = (dp[i][j] + dp[i][j-1])%p;
        }
    }
	cout<<dp[h-1][w-1]<<endl;
}

Measured memory_bytes: 8080
ant = [int(input()) for i in range(5)]
k = int(input())

if   ant[1] - ant[0] > k: print(":(")
elif ant[2] - ant[0] > k: print(":(")
elif ant[3] - ant[0] > k: print(":(")
elif ant[4] - ant[0] > k: print(":(")
elif ant[2] - ant[1] > k: print(":(")
elif ant[3] - ant[1] > k: print(":(")
elif ant[4] - ant[1] > k: print(":(")
elif ant[3] - ant[2] > k: print(":(")
elif ant[4] - ant[2] > k: print(":(")
elif ant[4] - ant[3] > k: print(":(")
else: print("Yay!")

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


int main() {
	
	int N;
	int64_t cnt = 0;
	cin >> N; 
	vector<int> a(N+1), b(N);
	for (auto &i : a) cin >> i;
	for (auto &i : b) cin >> i;
	
	
	for(int i=0; i<N; i++){
		if ( a.at(i) >= b.at(i) ){
			cnt += b.at(i);
		}
		else {
			cnt += a.at(i);
			b.at(i) -= a.at(i);
			
			if(a.at(i+1) >= b.at(i) ){
				a.at(i+1) -= b.at(i);
				cnt += b.at(i);
			}
			else {
				cnt += a.at(i+1);
				a.at(i+1) = 0;
			}
		}
	}
	
	cout << cnt << endl;
	 
	
	return 0;
}

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

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

    int ans = 0;

    for(int i = 1; i <= N; i++) {
        int v;
        cin >> v;

        if(v % 2 && i % 2) {
            ans ++;
        }
    }

    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 3612
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<cstring>
#include <iomanip>

using namespace std;

#ifdef LDEBUG
#define debug(x) cout << #x << ":" << x << endl
#else
#define debug(...)
#endif

#define REP(i,n) for(int i=0; i<n; ++i)

typedef unsigned long long u64;
typedef long long i64;

u64 a,b,c,d;

u64 gcd(u64 x, u64 y)  {
        if (x < y) swap(x,y);
        if (x%y == 0) return y;
        return gcd(y, x%y);
}

u64 cnt(u64 p, u64 q, u64 r, u64 s) {
        return p - (p/q + p/r - p/s);
}

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

        cin >> a >> b >> c >> d;

        a--;
        u64 e = c * (d / gcd(c,d));

        cout << cnt(b,c,d,e) - cnt(a,c,d,e) << endl;



        return 0;
}


Measured memory_bytes: 256
function Main(input) {
	input = input.split("\n");
	var mem = input[0].split(" ");
	input.shift();
	input = arr1dto2d(input);
	for(var i=0;i<input.length;i++){
		for(var j=0;j<mem[1];j++){
			if(input[i][j]=="snuke"){
				console.log(String.fromCharCode(65+j)+(i+1));
              break;
			}
		}
	}
}Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());
function arr1dto2d (arr){
	for(var i=0;i<arr.length;i++){
		arr[i]=arr[i].split(" ");
		}
	return arr;
}

Measured memory_bytes: 7372
//#include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<numeric>
#include<cstdio>
#include<cmath>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<ctype.h>
#include <fstream>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
using namespace std;
typedef long long ll;//int64
typedef unsigned long long ull;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b/gcd(a,b);}
int dy[4]={0,1,0,-1};
//----------program from here----------

int main(){
  int R=0,G=0;
  cin >> R >> G;
  cout << G*2 - R << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

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> vector<T> make_vec(size_t a) { return vector<T>(a); }
template<class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template<class T, class V>
typename enable_if<is_class<T>::value == 0>::type fill(T &t, const V &v) {
    t = v;
}
template<class T, class V>
typename enable_if<is_class<T>::value != 0>::type fill(T &t, const V &v){
    for (auto &e : t) fill(e, v);
}

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }

#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }







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

    vector<int> a(2);
    while (cin >> a[0] >> a[1]) {
        sort(a.begin(), a.end());
        if (a[0] == 1  && a[1] == 2) cout << 3 << endl;
        else if (a[0] == 1 && a[1] == 3) cout << 2 << endl;
        else cout << 1 << endl;
    }
        
}


















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

long long int N, a, b = a = 1111111111;
char s[111111];

int main(){
    scanf("%s", s);
    N = strlen(s);
    for(long long int i = 0; i < N; ++i){
        if(s[i] ^ '1')a = min(a, max(i, N - i - 1));
    }
    for(long long int i = 0; i < N; ++i){
        if(s[i] ^ '0')b = min(b, max(i, N - i - 1));
    }
    cout << min(N, max(a, b)) << endl;
    return 0;
}


Measured memory_bytes: 384
const inp = require('fs').readFileSync('/dev/stdin', 'utf8');
const l = inp.trim().split('\n');
var n = null;
var ind = 0;
while (li = l.shift()) {
    const isN = ind % 2 === 0;
    const nAr = li.split(' ');
    if(isN){
        n = nAr[0];
    } else {
        var sSc = null;
        for(var i = 0; i < nAr.length; i++){
            for(var j = i+1; j < nAr.length; j++){
                if (i!==j) {
                    let sDi = Math.abs(nAr[i] - nAr[j]);
                    if(sSc === null){
                        sSc = sDi;
                    } else {
                        if(sDi < sSc){
                           sSc = sDi; 
                        }
                    }
                }
            }
        }
        n = null;
        console.log(sSc);
    }
    ind ++;
} 


Measured memory_bytes: 18172
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ


int main(){
    int n;
    cin>>n;
    int64_t T;
    cin>>T;
    vector<int64_t> t(n);
    rep(i,n){
        cin>>t[i];
    }
    int64_t sum=0;
    for(int i=0;i<n-1;i++){
        sum += min(T,t[i+1]-t[i]);
    }
    sum += T;
    cout<<sum<<endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<queue>
#include<string>

using namespace std;

#define max_datasets 500000

int main(){
	queue<string> data1;
	queue<int> data2;

	string kari_data1;
	int kari_data2;

	int all_time=0;

	int n,q;
	string name[max_datasets];
	int time[max_datasets];
	cin>>n>>q;
	for(int i=0;i<n;i++){
		cin>>name[i]>>time[i];
		data1.push(name[i]);
		data2.push(time[i]);
	}

	while(data1.size()!=0){
		if(data2.front()<=q){
			all_time += data2.front();
			cout<<data1.front()<<" "<<all_time<<endl;
			data1.pop();
			data2.pop();
		}
		else{
			data2.front() -= q;
			all_time += q;
			kari_data1=data1.front();
			kari_data2=data2.front();
			data1.pop();
			data2.pop();
			data1.push(kari_data1);
			data2.push(kari_data2);
		}
	}
	return 0;
}

Measured memory_bytes: 9584
using System;

class Program
{
    static void Main()
    {
        int[] Mountains = new int[10];
        for (int i = 0; i < 10; i++)
        {
            Mountains[i] = int.Parse(Console.ReadLine());
        }
        Array.Sort(Mountains);
        Array.Reverse(Mountains);
        
        for (int i = 0; i < 3; i++)
        {
            Console.WriteLine(Mountains[i].ToString());

        }
        
    }
}



Measured memory_bytes: 9264
#include <iostream>
#include <string>

int main()
{
    std::string day;
    int next;
    std::cin >> day;
    if(day == "MON") next = 6;
    else if(day == "TUE") next = 5;
    else if(day == "WED") next = 4;
    else if(day == "THU") next = 3;
    else if(day == "FRI") next = 2;
    else if(day == "SAT") next = 1;
    else if(day == "SUN") next = 7;
    std::cout << next <<'\n';
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("-Ofast")
#include <bits/stdc++.h>
using namespace std;

typedef int in;
#define int long long
#define pb push_back
#define f first
#define s second
#define double long double
const int MAX=2e5+10;
const int MAX2=2e5+4;
const int MAAX=2e18;
const int MOD=1e9+7;
int n,a[MAX],k;
int dp[MAX];
int fun(int idx)
{
    if(idx==n)
    {
        return 0;
    }

    int &ret=dp[idx];
    if(ret!=-1)
    {
        return ret;
    }
    ret=INT_MAX;
    for(int i=1;i<=k;i++)
    {
        if(idx+i<=n)
        ret=min(ret,abs(a[idx+i]-a[idx])+fun(idx+i));
    }

    return ret;
}
in main()
{
    memset(dp,-1,sizeof dp);
cin>>n>>k;
for(int i=1;i<=n;i++)
{
    cin>>a[i];
}
cout<<fun(1)<<endl;
    return 0;
}


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


Measured memory_bytes: 7004
#include<bits/stdc++.h>
using namespace std;
const int N=4005,mod=998244353;
typedef bitset<N>Bit;
int n,p[N];
Bit x,y,a[6];
int last(Bit x)
{
    for(int i=N-1;i>=0;i--)
        if(x[i]) return i;
    return -1;
}
Bit gcd(Bit x,Bit y)
{
    if(x.none()) return y;
    if(y.none()) return x;
    int s=last(x),t=last(y);
    if(s<t) return gcd(x,y^(x<<t-s));
    return gcd(y,x^(y<<s-t));
}
int main()
{
    p[0]=1;
    for(int i=1;i<N;i++) p[i]=p[i-1]*2%mod;
    cin>>n>>x;
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=1;i<n;i++) a[0]=gcd(a[0],a[i]);
    int s=last(x),t=last(a[0]);
    int ans=0;
    for(int i=s;i>=t;i--)
    {
        if(x[i]) ans=(ans+p[i-t])%mod;
        if(x[i]!=y[i]) y^=a[0]<<(i-t);
    }
    for(int i=s;i>=0;i--)
        if(x[i]!=y[i])
    {
        ans+=x[i];break;
    }
    else if(i==0) ans++;
    printf("%lld\n",ans%mod);
}


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


ll modpow(ll a, ll n, ll mod){
    ll res=1;
    while(n>0){
        if(n&1) res = res*a%mod;
        a=a*a%mod;
        n>>=1;
    }
    return res;
}

ll modinv(ll a, ll mod){
    return modpow(a, mod-2, mod);
}


int main() {
    ll N,M,K,ans;
    cin>>N>>M>>K;
    ll mod = 998244353;
    ll kakuk = M*modpow(M-1,N-1,mod)%mod;
    ans = kakuk;
    ll gyakuM = modinv(M-1,mod);
    rep(i,K){
        kakuk = (kakuk * (N-i-1))%mod;
        kakuk = (kakuk * modinv(i+1,mod))%mod;
        kakuk = (kakuk * gyakuM)%mod; 
        ans += kakuk;
        ans = ans%mod;
    }
    if(M==1&&N-1==K) cout << 1 << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 3684
def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))



N=one_int()
S=one_str()
S="".join(S)

S=list(S)
S_set=set(S)

# s
sums = 0
dicts = {}
for i in S_set:
    temp = 0
    ind = S.index(i)
    if ind+1!=N:
        for j in set(S[ind+1:]):
            ind2 = S[ind+1:].index(j)
            
            if (ind+ind2+2) != N:
                sums+=len(set(S[ind+ind2+2:]))
print(sums)



Measured memory_bytes: 89968
import sys

N = int(input())
XY = [[int(_) for _ in input().split()] for i in range(N)]

mc = [0, 0]
maxl = 0

for x, y in XY:
    l = abs(x) + abs(y)
    maxl = max(maxl, l)
    mc[l % 2] += 1

if mc[0] > 0 and mc[1] > 0:
    print(-1)
    sys.exit()

def calc(sx, sy, ex, ey, d):
    dx, dy = ex - sx, ey - sy
    if dx > dy:
        if dx > -dy:
            return "R", sx + d, sy
        else:
            return "D", sx, sy - d
    else:
        if dx > -dy:
            return "U", sx, sy + d
        else:
            return "L", sx - d, sy

import math

l = math.ceil(math.log(maxl + 1, 2))

ms = [1 << i for i in range(l)][::-1]

rms = ms

if mc[0] > 0:
    rms = [1] + ms

print(len(rms))
print(*rms)

for ex, ey in XY:
    x, y = 0, 0
    w = ""
    if mc[0] > 0:
        w = "R"
        x += 1
    for m in ms:
        d, x, y = calc(x, y, ex, ey, m)
        w += d
    print(w)



Measured memory_bytes: 3316
import java.util.Scanner;

public class Main {
	private static Scanner sc;

	public static void main(String[] args) {
		sc = new Scanner(System.in);
		long x = Long.parseLong(sc.next());
		long k = Long.parseLong(sc.next());
		long d = Long.parseLong(sc.next());
		long result = 0;
		long xAbs = Math.abs(x);

		if (xAbs == 0) {
			if (0 == k % 2) {
				result = 0;
			} else {
				result = d;
			}
		} else {
			// xが正の範囲でminになるまで何回引けばよいかチェック
			long count = xAbs / d;
			// 試行回数kよりcountが小さければ、剰余が正のmin
			if (0 == count) {
				// 初手xの負の範囲でのmin
				long minPlus = xAbs % d;
				result = getResult(k, d, count, minPlus);				
			} else if (count < k) {
				// xの正の範囲でのmin
				long minPlus = xAbs % (count * d);
				// 負にいけるかチェック
				result = getResult(k, d, count, minPlus);
			} else {
				// いける範囲まで戻る
				result = xAbs - (d * k);
			}
		}
		System.out.println(result);
	}

	private static long getResult(long k, long d, long count, long minPlus) {
		long result;
		if (count + 1 < k) {
			long minNextPlus = Math.abs(minPlus - d);

			long restK = k - count;
			if (minPlus < minNextPlus) {
				if (0 == restK % 2) {
					result = minPlus;
				} else {
					result = minNextPlus;
				}
			} else {
				result = minNextPlus;
				if (0 == (restK - 1) % 2) {
					result = minNextPlus;
				} else {
					result = minPlus;
				}
			}
		} else {
			result = minPlus;
		}
		return result;
	}

}


Measured memory_bytes: 35552
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>
#include <limits.h>

using namespace std;

typedef long long LL;

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define dumpMap(m) { for (auto it: m) cout << it.first << "=>" << it.second << ' '; }

const int MOD = 1000000007;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(0);
    
    int H1, H2, M1, M2, K;
    cin >> H1 >> M1 >> H2 >> M2 >> K;

    int t1 = H1 * 60 + M1;
    int t2 = H2 * 60 + M2;

    cout << (t2-t1-K) << endl;
    
    return 0;
}


Measured memory_bytes: 3612
#include<iostream>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define N 200000

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

    if(a<1200)cout<<"ABC"<<endl;
    else if(a<2800)cout<<"ARC"<<endl;
    else cout<<"AGC"<<endl;
}

Measured memory_bytes: 256
// Hail god Yato
 
#include <bits/stdc++.h> 
using namespace std;
 
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
const ll mod = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
//
//
void solve(){
    ll k, fst, snd;
    cin>>k>>fst>>snd;
    int p = fst/k;
    if(p*k == fst || ((p+1)*k >=fst && (p+1)*k <= snd))
        cout<<"OK";
    else
        cout<<"NG";
}
int main(){ 
        hs;
        ll t;
        t=1;
        // cin>>t;
        for (int i=1; i<=t; i++){
                //cout<<"Case #"<<i<<": ";
                solve();
         }
        return 0; 
}

Measured memory_bytes: 3596
import math
n,h=map(int, input().split())
a=[]
b=[]
for i in range(n):
    x,y=map(int, input().split())
    a.append(x)
    b.append(y)
ans=0
b.sort(reverse=True)
Am=max(a)
for i in range(n):
    if b[i]>=Am:
        h-=b[i]
        ans+=1
    if h<=0:
        break
if h>0:
    ans+=math.ceil(h/Am)
print(ans)


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

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

int main() {
  ll n, ans = 0;
  string s;
  cin >> n >> s;
  ll r = 0, g = 0, b = 0;
  rep(i, n) {
    if (s[i] == 'R') {
      r++;
    } else if (s[i] == 'G') {
      g++;
    } else {
      b++;
    }
  }

  ans = r * g * b;
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      int k = 2 * j - i;
      if (k >= n || s[k] == s[i] || s[k] == s[j] || s[i] == s[j]) continue;
      ans--;
    }
  }

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


Measured memory_bytes: 3604
#include<iostream>

using namespace std;

int main()
{
    int n = 0;
    while (cin >> n && n) {
        int cnt = 0;
        int a = 0, b = 0;
        for (int i = 0; i < n; i++) {
            cin >> a >> b;
            cnt += (b - a + 1);
        }
        cout << cnt << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<vector>
#include<algorithm>
#include<cstring>
 
using namespace std;

typedef long long int LL;
 
void test() {
    int n;
    cin >> n;
    vector<LL> a;
    for(int i = 0; i < n; i++) {
        int num;
        cin >> num;
        a.push_back(num);
    }
    int ans = 0;
    for(int i = 0; i < n - 2; i++) {
        for(int j = i + 1; j < n - 1; j++) {
            for(int k = j + 1; k < n; k++) {
                if(a[i] != a[j] && a[i] != a[k] && a[j] != a[k]) {
                    if(a[i] + a[j] > a[k] && a[i] + a[k] > a[j] && a[j] + a[k] > a[i]) {
                        ans++;
                    }
                }
            }
        }
    }
    cout << ans << endl;
}
 
int main () 
{
    // int t;
    // cin >> t;
    // while(t--) 
        test();
}
 

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

int main(){
	map<string,int> data;
	string ans1,ans2,str;
	while(cin >> str){
		data[str]++;
		if(data[ans1] < data[str]) ans1 = str;
		if(ans2.size() < str.size() ) ans2 = str;
	}
	cout << ans1 << " " << ans2 << endl;
}

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

using namespace std;

#define _39_days ""

typedef long long ll;

const int N = 1e5 + 5;

int n, l, ok, a[N];

int main() {
    cin >> n >> l;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        if (i > 1 && a[i] + a[i - 1] >= l) {
            ok = i;
        }
    }
    if (!ok) {
        cout << "Impossible\n";
        return 0;
    }
    cout << "Possible\n";
    for (int i = 1; i < ok - 1; ++i)
        cout << i << "\n";
    for (int i = n - 1; i >= ok - 1; --i)
        cout << i << "\n";
}


Measured memory_bytes: 1152
import java.util.Arrays;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int a = stdIn.nextInt();
		int b = stdIn.nextInt();
		
		int m = stdIn.nextInt();
		
		int[] c = new int[a]; //冷蔵庫の値段
		
		int[] d = new int[b]; //電子レンジの値段
		
		for(int i = 0; i < a; i++) {
			c[i] = stdIn.nextInt();
		}
		for(int i = 0; i < b; i++) {
			d[i] = stdIn.nextInt();
		}
		
		long ans = Long.MAX_VALUE;
		
		for(int i = 0; i < m; i++) {
			ans = Math.min(c[stdIn.nextInt()-1]+d[stdIn.nextInt()-1]-stdIn.nextInt(), ans);
		}
		
		Arrays.sort(c);
		Arrays.sort(d);
		
		ans = Math.min(c[0]+d[0], ans);
		
		System.out.println(ans);
		
	}

}


Measured memory_bytes: 151216
_ = gets.to_i
mons = readline.split(' ').map(&:to_i)
hero = readline.split(' ').map(&:to_i)

count = 0
hero.each_with_index do |h, i|
  count += [mons[i], h].min
  if h > mons[i]
    yoryoku = h - mons[i]
    count += [mons[i + 1], yoryoku].min
    mons[i + 1] = mons[i + 1] - yoryoku
    mons[i + 1] = 0 if mons[i + 1].negative?
  end
end

p count


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

int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  if(B<C || A>D){
    cout << 0 << endl;
  }
  else{
    cout << min(B,D) - max(A,C) << endl;
  }
  return 0;
}

Measured memory_bytes: 256