akhauriyash/Code-Regression huggingface dataset:
from collections import deque
n,m,k=map(int,input().split())

F=[set() for i in range(n)]
B=[set() for i in range(n)]
for i in range(m):
	a,b=map(int,input().split())
	a,b=a-1,b-1
	F[a].add(b)
	F[b].add(a)
for i in range(k):
	c,d=map(int,input().split())
	c,d=c-1,d-1
	B[c].add(d)
	B[d].add(c)
	
T=[set() for i in range(n)]
D=[0]*n
R=[0]*n

for i in range(n):
    if D[i]:
        continue
    que=deque([])
    que.append(i)
    S=set()
    S.add(i)
    while que:
        p=que.popleft()
        for np in F[p]:
            if D[np]!=1:
                que.append(np)
                S.add(np)
                D[np]=1
    for s in S:
        R[s]=len(S)-len(F[s])-len(S&B[s])-1

print(*R)

Measured memory_bytes: 120736
#Convolution_998244353

MOD = 998244353
ROOT = 3

sum_e = (911660635, 509520358, 369330050, 332049552, 983190778, 123842337, 238493703, 975955924, 603855026, 856644456, 131300601, 842657263, 730768835, 942482514, 806263778, 151565301, 510815449, 503497456, 743006876, 741047443, 56250497, 0, 0, 0, 0, 0, 0, 0, 0, 0)
sum_ie = (86583718, 372528824, 373294451, 645684063, 112220581, 692852209, 155456985, 797128860, 90816748, 860285882, 927414960, 354738543, 109331171, 293255632, 535113200, 308540755, 121186627, 608385704, 438932459, 359477183, 824071951, 0, 0, 0, 0, 0, 0, 0, 0, 0)

def butterfly(arr):
    n = len(arr)
    h = (n - 1).bit_length()
    for ph in range(1, h + 1):
        w = 1 << (ph - 1)
        p = 1 << (h - ph)
        now = 1
        for s in range(w):
            offset = s << (h - ph + 1)
            for i in range(p):
                l = arr[i + offset]
                r = arr[i + offset + p] * now
                arr[i + offset] = (l + r) % MOD
                arr[i + offset + p] = (l - r) % MOD
            now *= sum_e[(~s & -~s).bit_length() - 1]
            now %= MOD

def butterfly_inv(arr):
    n = len(arr)
    h = (n - 1).bit_length()
    for ph in range(1, h + 1)[::-1]:
        w = 1 << (ph - 1)
        p = 1 << (h - ph)
        inow = 1
        for s in range(w):
            offset = s << (h - ph + 1)
            for i in range(p):
                l = arr[i + offset]
                r = arr[i + offset + p]
                arr[i + offset] = (l + r) % MOD
                arr[i + offset + p] = (MOD + l - r) * inow % MOD
            inow *= sum_ie[(~s & -~s).bit_length() - 1]
            inow %= MOD

def convolution(a, b):
    n = len(a)
    m = len(b)
    if not n or not m: return []
    if min(n, m) <= 50:
        if n < m:
            n, m = m, n
            a, b = b, a
        res = [0] * (n + m - 1)
        for i in range(n):
            for j in range(m):
                res[i + j] += a[i] * b[j]
                res[i + j] %= MOD
        return res
    z = 1 << (n + m - 2).bit_length()
    a += [0] * (z - n)
    b += [0] * (z - m)
    butterfly(a)
    butterfly(b)
    for i in range(z):
        a[i] *= b[i]
        a[i] %= MOD
    butterfly_inv(a)
    a = a[:n + m - 1]
    iz = pow(z, MOD - 2, MOD)
    for i in range(n + m - 1):
        a[i] *= iz
        a[i] %= MOD
    return a

def autocorrelation(a):
    n = len(a)
    if not n: return []
    if n <= 50:
        res = [0] * (2 * n - 1)
        for i in range(n):
            for j in range(n):
                res[i + j] += a[i] * a[j]
                res[i + j] %= MOD
        return res
    z = 1 << (2 * n - 2).bit_length()
    a += [0] * (z - n)
    butterfly(a)
    for i in range(a):
        a[i] *= a[i]
        a[i] %= MOD
    butterfly_inv(a)
    a = a[:2 * n - 1]
    iz = pow(z, MOD - 2, MOD)
    for i in range(2 * n - 1):
        a[i] *= iz
        a[i] %= MOD
    return a

N, M = map(int, input().split())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]

print(*convolution(A, B))

Measured memory_bytes: 187044
function Main(input) {
  const std = input.split('\n');
  const length = std[0]
  const data = std[1]
  let result = 1;
  for(let i = 1; i < length; i++) {
    if(data[i] != data[i - 1]) result ++;
  }
  console.log(result)
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

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



Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
int n,m,L[2010],R[2010],h[2010],sta[2010],tp,ans;
char s[2010][2010],t[2010][2010];
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i)scanf("%s",s[i]+1);
	for(int i=1;i<=n;++i)for(int j=1;j<=m;++j)s[i][j]=(s[i][j]=='#'?1:0);
	for(int i=1;i<=n;++i)for(int j=1;j<=m;++j)t[i][j]=s[i+1][j]^s[i][j+1]^s[i+1][j+1]^s[i][j];
	n--,m--;
	for(int i=1;i<=n;++i){
		for(int j=1;j<=m;++j)
			if(!t[i][j])h[j]++;
			else h[j]=0;
		for(int j=1,tp=0;j<=m;++j){
			while(tp&&h[sta[tp]]>=h[j])tp--;
			L[j]=sta[tp]+1,sta[++tp]=j;
		}
		for(int j=m,tp=0;j>=1;--j){
			while(tp&&h[sta[tp]]>=h[j])tp--;
			R[j]=(tp?sta[tp]-1:m),sta[++tp]=j;
		}
		for(int j=1;j<=m;++j)if(h[j])ans=max(ans,(h[j]+1)*(R[j]-L[j]+2));
	}
	ans=max(ans,max(n+1,m+1));
	printf("%d",ans);
}

Measured memory_bytes: 8192
#include <cstdio>
#include <algorithm>
using namespace std;

int main(){
	int cup[3] = {1,0,0};
	char s1, s2;
	
	while( scanf("%c,%c\n", &s1, &s2) != EOF ){
		swap( cup[s1-'A'] , cup[s2-'A'] );
	}
	printf("%c\n", cup[0]*'A' + cup[1]*'B' + cup[2]*'C');   
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
using namespace std;
typedef long long int ll;

int h,w,n;
int x,y;

void no(){
	cout << "NO" << endl;
}

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cin >> h >> w >> n;
	int sx,sy; cin >> sx >> sy;
	sx--; sy--;
	string s,t; cin >> s >> t;
	// top
	x=sx,y=sy;
	swap(x,y);
	for(int i=0;i<n;i++){
		if(s[i]=='U')y--;
		if(y<0){
			no();
			return 0;
		}
		if(t[i]=='D')y++;
		if(y>h-1)y=h-1;
	}
	x=sx,y=sy;
	swap(x,y);
	for(int i=0;i<n;i++){
		if(s[i]=='D')y++;
		if(y>h-1){
			no();
			return 0;
		}
		if(t[i]=='U')y--;
		if(y<0)y=0;
	}

	x=sx,y=sy;
	swap(x,y);
	for(int i=0;i<n;i++){
		if(s[i]=='L')x--;
		if(x<0){
			no();
			return 0;
		}
		if(t[i]=='R')x++;
		if(x>w-1)y=w-1;
	}
	x=sx,y=sy;
	swap(x,y);
	for(int i=0;i<n;i++){
		if(s[i]=='R')x++;
		if(x>w-1){
			no();
			return 0;
		}
		if(t[i]=='L')x--;
		if(x<0)x=0;
	}
	cout << "YES" << endl;
}


Measured memory_bytes: 920
import java.io.{BufferedReader, InputStream, InputStreamReader}
import java.util.StringTokenizer

import scala.collection.mutable
import scala.util.Sorting
import math.{abs, max, min}

object Main {
  def solve(): Unit = {
    val sc = new InputReader(System.in)
    val N = sc.nextInt()
    val W = sc.nextInt()
    val w = Array.ofDim[Int](N + 1)
    val v = Array.ofDim[Int](N + 1)
    val w1 = sc.nextInt()
    v(1) = sc.nextInt()
    (2 to N) foreach { i =>
      w(i) = sc.nextInt() - w1
      v(i) = sc.nextInt()
    }

    val dp = Array.ofDim[Int](N + 1, N + 1, 3 * N + 1)
    for {
      i <- 1 to N
      j <- 0 to i  // 選んだ個数
      k <- 0 to 3 * i // w1との差
    } {
      val pre_k = k - w(i)
      dp(i)(j)(k) =
        if (j >= 1 && pre_k >= 0) max(dp(i - 1)(j - 1)(pre_k) + v(i), dp(i -1)(j)(k))
        else dp(i -1)(j)(k)
    }

    val ans = (for {
      j <- 0 to N
      k <- 0 to 3 * N
      if j.toLong * w1 + k <= W
    } yield dp(N)(j)(k)).max
    println(ans)
  }

  def main(args: Array[String]): Unit = {
    solve()
  }



  private class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = null

    def next: String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next.toInt
    def nextLong(): Long = next.toLong
    def nextChar(): Char = next.charAt(0)
  }

}


Measured memory_bytes: 43600
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int k = sc.nextInt();
        int ans = 0;

        if(k <= a){
            ans += k;
            System.out.println(ans);
            return;
        }else{
            ans += a;
            k -= a;
        }
        k -= b;
        if(k > 0)
            ans -= k;
        
        System.out.println(ans);
    }
}

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

const int MAX_S = 11;
int H, W;
char G[MAX_S][MAX_S];

int ctod[128];
char dtoc[4];

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

void init() {
  dtoc[0] = 'R';
  dtoc[1] = 'D';
  dtoc[2] = 'L';
  dtoc[3] = 'U';
  for(int i = 0; i < 4; ++i)
    ctod[dtoc[i]] = i;
}

int countStep() {
  int cnt = 0;
  for(int i = 0; i < H; ++i)
    for(int j = 0; j < W; ++j)
      cnt += G[i][j] == 'o';
  return cnt-1;
}

pair<int,int> getNextP(int x, int y, int dir) {
  const static pair<int,int> FAILD = make_pair(-1,-1);
  while(1) {
    x += dx[dir];
    y += dy[dir];
    if(x < 0 || x >= W) return FAILD;
    if(y < 0 || y >= H) return FAILD;
    if(G[y][x] == 'o') return make_pair(x,y);
  }
  return FAILD;
}

bool rec(int x, int y, int dir, int step, int maxStep, string &s) {
  if(step == maxStep) return true;
  for(int k = -1; k <= 1; ++k) {
    int ndir = ( dir + k + 4 ) % 4;
    pair<int,int> p = getNextP(x,y,ndir);
    if(p.first == -1 && p.second == -1) continue;
    int nx = p.first;
    int ny = p.second;

    G[y][x] = '.';
    s += dtoc[ndir];

    if(rec(nx,ny,ndir,step+1,maxStep,s)) return true;

    G[y][x] = 'o';
    int tmp = (int)s.size()-1;
    s.resize(tmp);
  }

  return false;
}

string solve(int sx, int sy, int sdir) {
  int step = countStep();
  string res = "";
  rec(sx,sy,sdir,0,step,res);
  return res;
}

int main() {
  init();
  while(cin >> H >> W && (H | W)) {
    int sx, sy, sdir;
    for(int i = 0; i < H; ++i) {
      for(int j = 0; j < W; ++j) {
	cin >> G[i][j];
	if(G[i][j] != '.' && G[i][j] != 'o') {
	  sx = j;
	  sy = i;
	  sdir = ctod[G[i][j]];
	  G[i][j] = 'o';
	}
      }
    }
    cout << solve(sx,sy,sdir) << endl;
  }
  return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

class Main{

	public static void main(String[] args) {




		Scanner scan = new Scanner(System.in);
		//		int N = scan.nextInt();
		//		int K = scan.nextInt();

		int data[] = new int[10];
		int x=0;
		for(int i = 1;i < 10;i++){
			data[i] = scan.nextInt();
		}
	

		for(int a = 0;a < 101;a++){
			for(int b = 0;b < 101;b++){
				for(int c = 0;c < 101;c++){
					
					for(int d = 0;d < 101;d++){
						if(data[1] == a + d &&data[4] == b + d &&data[7] == c + d){
							
							for(int e = 0;e < 101;e++){
								if(data[2] == a + e  && data[5] == b + e && data[8] == c + e ){

									for(int f = 0;f < 101;f++){
										if(  data[3] == a + f  && data[6] ==b  + f && data[9] == c + f) {
											System.out.println("Yes");
											return;
										}
									}
								}

							}
						}

					}

				}
				
			}
			








		}
			System.out.println("No");
	



	}
}

Measured memory_bytes: 23636
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<ll, ll>> vpll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vc> vvc;
typedef vector<vs> vvs;
typedef vector<vll> vvll;
typedef map<int, int> mii;
typedef set<int> si;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define arep(i, v) for (auto i : v)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define fi first
#define se second
// #include <atcoder/all>
#include <atcoder/fenwicktree>
using namespace atcoder;
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T>
inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline void dump(T& v) {
    irep(i, v) { cout << (*i) << ((i == --v.end()) ? '\n' : ' '); }
}
template <class T, class U>
inline void dump(map<T, U>& v) {
    irep(i, v) { cout << i->first << " " << i->second << '\n'; }
}
inline string getline() {
    string s;
    getline(cin, s);
    return s;
}
inline void yn(const bool b) { b ? fin("yes") : fin("no"); }
inline void Yn(const bool b) { b ? fin("Yes") : fin("No"); }
inline void YN(const bool b) { b ? fin("YES") : fin("NO"); }
struct io {
    io() {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
constexpr ll LLINF = 1LL << 61;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-11;

/* --------------------   ここまでテンプレ   -------------------- */

int main() {
    int n, q;
    cin >> n >> q;
    fenwick_tree<ll> fw(n);
    rep(i, n) {
        int a;
        cin >> a;
        fw.add(i, a);
    }
    rep(i, q) {
        int t, u, v;
        cin >> t >> u >> v;
        if (t) {
            cout << fw.sum(u,v) << endl;
        } else {
            fw.add(u,v);
        }
    }
}


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

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>

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

int main()
{
    ll n, a[200000];

    cin >> n;
    rep(i, 0, n) cin >> a[i];
    rep(i, 0, n)
    {
        a[i] -= i + 1;
    }
    sort(a, a + n);
    int b = a[n / 2];
    ll sum = 0;
    rep(i, 0, n)
    {
        sum += abs(a[i] - b);
    }
    cout << sum << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;    
#define ll long long
int main(){
    ios::sync_with_stdio(false) ,cin.tie(0);
    int n;
    cin >> n;
    map<int ,int>a;
    vector<int>arr(n);
    for(int i =  1 ; i < n ; i++) {
        cin >> arr[i];
        a[arr[i]]++;
    }
    for(int i = 1 ; i <= n ; i++){
        cout << a[i] << "\n";
    }
}



Measured memory_bytes: 13520
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<map>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;

int main() {
	ll n, k;
	cin >> n >> k;
	n %= k;
	if (n == 0) {
		cout << 0 << endl;
		return 0;
	}
	if (2 * n <= k) {
		cout << n << endl;
		return 0;
	}
	else {
		cout << k - n << endl;
		return 0;
	}
}

Measured memory_bytes: 256
#include<string>
#include<cctype>
#include<iostream>
using namespace std;
string toUpper(string s){
    string t = s;
    for (int i = 0; i < s.size(); i++){
        t[i] = toupper(s[i]);
    }
    return t;
}
int main(){
    string W,T;
    cin >> W;
    int n = 0;
    while(1){
        cin >> T;
        if (T == "END_OF_TEXT") break;
        if (toUpper(T) == toUpper(W)) n++;
    }
    cout << n << endl;
}


Measured memory_bytes: 3172
/*
 * @Author: BilyHurington
 * @Date: 2020-03-22 20:20:28
 * @LastEditors: BilyHurington
 * @LastEditTime: 2020-03-22 20:21:59
 */
#include<bits/stdc++.h>
using namespace std;
int n,a[200010],num[200010];
int main(){
    long long ans=0;
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]),ans+=num[a[i]],num[a[i]]++;
    for(int i=1;i<=n;i++){
        printf("%lld\n",ans-num[a[i]]+1);
    }
    return 0;
}

Measured memory_bytes: 3712
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define sqr(x) ((x)*(x))
#define fz1(i,n) for ((i)=1;(i)<=(n);(i)++)
#define fd1(i,n) for ((i)=(n);(i)>=1;(i)--)
#define fz0g(i,n) for ((i)=0;(i)<=(n);(i)++)
#define fd0g(i,n) for ((i)=(n);(i)>=0;(i)--)
#define fz0k(i,n) for ((i)=0;(i)<(n);(i)++)
#define fd0k(i,n) for ((i)=(long long)((n)-1);(i)>=0;(i)--)
#define fz(i,x,y) for ((i)=(x);(i)<=(y);(i)++)
#define fd(i,y,x) for ((i)=(y);(i)>=(x);(i)--)
#define fzin fz1(i,n)
#define fzim fz1(i,m)
#define fzjn fz1(j,n)
#define fzjm fz1(j,m)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len){static char ss[len];scanf(" %s",ss);(st)=ss;}
#define inc(x,y) {x+=(y);if(x>=mod)x-=mod;}
#define dec(x,y) {x-=(y);if(x<0)x+=mod;}
using namespace std;
int n,m,i,j,ans;
string s,t;
int main()
{
	cin>>n>>s>>t;
	for(i=1;i<=n;i++){
		if(s.substr(n-i)==t.substr(0,i))ans=i;
	}cout<<n+n-ans<<endl;
	return 0;
}

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

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

  pair<pair<string,int>,int> p[N];
  rep( i, 0, N ) {
    string S;
    int P;
    cin >> S >> P;
    p[i] = make_pair( make_pair( S, -P ), i );
  }

  sort( p, p+N );
  rep( i, 0, N ) cout << p[i].second+1 << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
n=int(input())
t,a=map(int,input().split())
h=[int(i) for i in input().split()]
ans=[0,abs(a-(t-h[0]*0.006))]
for i in range(1,n):
    tmp=abs(a-(t-h[i]*0.006))
    if tmp<ans[1]: ans=[i,tmp]
print(ans[0]+1)


Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        string s = sc.Next();
        bool[] steps = new bool[4];

        foreach (var c in s)
        {
            if (c == 'N')
            {
                steps[0] = true;
            }
            if (c == 'S')
            {
                steps[1] = true;
            }
            if (c == 'W')
            {
                steps[2] = true;
            }
            if (c == 'E')
            {
                steps[3] = true;
            }
        }

        bool ok = true;
        if (steps[0] != steps[1])
        {
            ok = false;
        }
        if (steps[2] != steps[3])
        {
            ok = false;
        }

        string answer = ok ? "Yes" : "No";


        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
#define SortAsc(c) std::sort(c.begin(), c.end())
#define SortDesc(c) std::sort(c.rbegin(), c.rend())
int dx[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int dy[8] = {1, 0, -1, 0, 1, -1, 1, -1};

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  int x = A;
  int firstMod = x % B;
  while (true) {
    if (x % B == C) {
      cout << "YES" << endl;
      return 0;
    }

    x += A;
    if (x % B == firstMod) {
      break;
    }
  }

  cout << "NO" << endl;
}

/*
7 % 5 = 2
14 % 5 = 4
21 % 5 = 1
28 % 5 = 3
35 % 5 = 0

*/

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<algorithm>
using namespace std;


int main(){
    int n;
    scanf("%d", &n);
    for(int i=0;i<n;i++){
        vector<int> t(3);
        for(auto&e:t){
            scanf("%d",&e);
        }
        sort(t.begin(),t.end());
        if(t[0]*t[0]+t[1]*t[1]==t[2]*t[2]){
            printf("YES\n");
        }else{
            printf("NO\n");
        }
    }
    return 0;
}

Measured memory_bytes: 1168
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int> >;
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
//ノート　isupperで大文字の判定　islowerで小文字の判定
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
int main(){
    ll k,a,b;
    std::cin >> k>>a>>b;
    if(b-a>2ll){
        ll ans=0ll;
        k-=a-1;
        ans+=a;
        ans+=k/2*(b-a);
        if(k%2==1)ans++;
        std::cout << ans << std::endl;
        
    }
    else{
        std::cout << k+1 << std::endl;
    }
    
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int prices[] = new int[N];
		
		int maxPrice = -1;
		int maxIndex = -1;
		for(int i = 0; i < N; i++) {
		    prices[i] = sc.nextInt();
		    if(maxPrice < prices[i]) {
		        maxPrice = prices[i];
		        maxIndex = i;
		    }
		}
        
        int sum = 0;
        for(int i = 0; i < N; i++) {
            if (i == maxIndex) {
                sum += prices[i] / 2;
            } else {
                sum += prices[i];
            }
        }
        System.out.println(sum);
	}
}

Measured memory_bytes: 23632
#include<bits/stdc++.h>
#define RI(x) x = rit()
#define RII(a,b) a = rit(), b = rit()
#define RIII(a,b,c) a = rit(), b = rit(), c = rit()
#define REP(I, N) for(int I=0;I<int(N);I++)
#define REPP(I, N) for(int I=1;I<=int(N);I++)
#define ll long long
#define SZ(x) (int)(x).size()
#define F first
#define S second
#define PB(x) push_back(x)
inline int rit(){
    int f=0,key=1;
    char ch;
    do{
        ch = getchar();
        if(ch=='-') key=-1;;
    }while(ch<'0'||ch>'9');
    do{
        f = f*10+ch-'0';
        ch = getchar();
    }while(ch>='0'&&ch<='9');
    return f*key;
}
using namespace std;
typedef pair<int,int> P;
string str[60];
int cnt[60][300];
int main(void){ ios::sync_with_stdio(0), cin.tie(0);
	int n;
	cin>>n;
	REP(i,n){
		cin>>str[i];
		REP(j,str[i].size()){
			cnt[i][str[i][j]]++;
		}
	}
	for(char i='a';i<='z';++i){
		int mn = 100;
		REP(j,n){
			mn = min(mn, cnt[j][i]);
		}
		REP(j,mn) cout << i;
	}
	cout << "\n";
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long
using namespace std;
#define maxn 100010
#define mod 1000000007
struct cv{
    int x,y;
}a[maxn];
int b[maxn];
int cnt;
set<int>s[maxn];
int dp[maxn],du[maxn];
bool cmp(cv p,cv q){
    if(p.x!=q.x) return p.x<q.x;
    return p.y<q.y;
}
int main(){
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++) scanf("%d",&a[i].x);
    for(int i=0;i<n;i++) scanf("%d",&a[i].y),b[i]=a[i].y;
    sort(a,a+n,cmp);
    sort(b,b+n);
    cnt=0;
    int flag=0;
    for(int i=0;i<n;i++){
        if(a[i].x>b[i]){
            printf("No\n");
            return 0;
        }
        if(i<n-1&&a[i+1].x<b[i]) flag=1;
        if(i!=0){
            if(b[i]==b[i-1]) flag=1;
        }
        if(i!=0&&a[i].x!=a[i-1].x){
            cnt++;
            s[cnt].insert(a[i].y);
        }
        else{
            s[cnt].insert(a[i].y);
            if(i!=0) flag=1;
        }
    }
    cnt=0;
    if(flag){
        printf("Yes\n");
        return 0;
    }
    for(int i=0;i<n;i++){
        dp[lower_bound(b,b+n,a[i].y)-b]=i;
    }
    cnt=0;
    for(int i=0;i<n;i++){
        if(du[i]) continue;
        cnt++;
        du[i]=1;
        int x=dp[i];
        while(du[x]==0){
            du[x]=1;
            x=dp[x];
        }
    }
    if(cnt>=2) printf("Yes\n");
    else printf("No\n");
    return 0;
}

Measured memory_bytes: 11520
import javax.sound.midi.Soundbank;
import java.util.Scanner;

import static java.lang.System.currentTimeMillis;
import static java.lang.System.out;
import static java.lang.System.setOut;

public class Main {

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

        //探索対象を取得
        int size = (scanner.nextInt());
        int [] S= new int[size];
        for (int i = 0; i < size; i++) {
            S[i] = scanner.nextInt();
        }

        //探索する値を取得
        int ansSize = (scanner.nextInt());
        int[] T = new int[ansSize];
        for (int i = 0; i < ansSize; i++) {
            T[i] = scanner.nextInt();
        }

        //System.out.println("読み込み完了！");
        double roopCount = 0;
        int count = 0;
        //探索用のアルゴリズム
        for (int i = 0; i < ansSize; i++) {
            if(isContain(T[i],S)){
                count++;
            }
        }

        System.out.println(count);
    }

    static  boolean isContain (int num , int[] arr){
        int head = 0;
        int tail = arr.length-1;
        int mid  = (head+tail)/2;

        while (mid != head){
            if(arr[mid] == num){
                return  true;
            }
            else if(arr[mid]< num){
                head = mid;
            }
            else if(arr[mid] > num){
                tail = mid;
            }
            mid = (tail+head)/2;
        }
        return arr[mid]==num || arr[tail]==num;

    }
}


Measured memory_bytes: 79724
using System;

class Print_Test_Cases
{
    public static void Main()
    {
        int i = 1;
        while (true)
        {
            int x = int.Parse(Console.ReadLine());

            if (x == 0) break;

            Console.WriteLine("Case {0}: {1}", i, x);

            i++;
        }
    }
}

Measured memory_bytes: 9232
#include <iostream>
#include <string.h> 
using namespace std;

int W;
int w[1001],v[1001];
int N;
int dp[1001][1001];

int rec(int i, int j){

  //テ」ツつづ」ツ??」ツつ?」ツ?」テ」ツ??
  if(dp[i][j] >= 0){
    return dp[i][j];
  }
  int res;

  if(i == N){ // テ」ツつづ」ツ??・ツ督?ァツ可ゥテ」ツ?ッテァツ?。テ」ツ??
    res = 0;

  }else if(j < w[i]){ // テ」ツ?禿」ツ?ョテ・ツ督?ァツ可ゥテ」ツ?ッテ・ツ?・テ」ツつ嘉」ツ?ェテ」ツ??
    res = rec(i + 1,j);
 
  }else{ // テ・ツ督?ァツ可ゥテ」ツつ津・ツ環?」ツ?暗」ツつ凝」ツ?禿」ツ?ィテ」ツ?古・ツ?コテヲツ敖・テ」ツつ凝」ツ?ィテ」ツ??
        res = max(rec(i+1,j), rec(i+1,j-w[i]) + v[i]);
    /* 
   int tmp1,tmp2;
    tmp1 = rec(i+1,j);
    tmp2 = rec(i+1,j-w[i]) + v[i];
    if(tmp1 < tmp2){
      res = tmp2;
    }else{
      res = tmp1;
    }
    */
  }
  return dp[i][j] = res;
}


int main(){

  int num = 1;

  while(1){
    cin >> W;
    if(W == 0) break;
    cin >> N;
    //テ・ツ按敕ヲツ慊淌・ツ個?
    /*
    for(int i = 0; i < 1001; i++){
      w[i] = v[i] = -1;
      for(int j = 0; j < 1001; j++)
	dp[i][j] = -1; 
    }
    */
    memset(dp,-1,sizeof(dp));
    memset(w,-1,sizeof(w));
    memset(v,-1,sizeof(v));


    //テ・ツ?・テ・ツ環?
    char tmp;
    for(int i = 0; i < N; i++) cin >> v[i] >> tmp >> w[i];

    int ans = rec(0,W);

    // dpテゥツ?催・ツ按療」ツつ津・ツ?ィテ」ツ?ヲテ・ツ淞凝」ツつ?」ツつ?
    for(int i = 0; i < N; i++){
      for(int j = 0; j <= W; j++){
	if(dp[i][j] == -1)
	  rec(i,j);
      }
    }   
  
    cout << "Case "<< num  << ":"<< endl;
    num++;
    cout << ans << endl; 
    int j;
    for( j = 0; dp[0][j] != ans ; j++){}
    cout << j << endl;
    
  }
  return 0;
}

Measured memory_bytes: 5132
n = int(input())
s = []
h = []
c = []
d = []
for _ in range(n):
    a, b = input().split()
    if a == 'S':
        s.append(int(b))
    elif a == 'H':
        h.append(int(b))
    elif a == 'C':
        c.append(int(b))
    else:
        d.append(int(b))

for i in range(1, 14):
    if s.count(i) != 1:
        print('S', i)

for i in range(1, 14):
    if h.count(i) != 1:
        print('H', i)

for i in range(1, 14):
    if c.count(i) != 1:
        print('C', i)

for i in range(1, 14):
    if d.count(i) != 1:
        print('D', i)



Measured memory_bytes: 5608
import java.io.*;
public class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br =new BufferedReader(new InputStreamReader(System.in));
		String n;
		int i=1;
		n=br.readLine();
		while(n.equals("0")==false){
			System.out.println("Case "+i+": "+n);
			i++;
			n=br.readLine();
		}
	}
}

Measured memory_bytes: 27916
#include <bits/stdc++.h>
using namespace std;
template <class T>
bool chmax(T& a, const T& b)
{
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b)
{
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define F first
#define S second

typedef long long ll;
const ll MOD = 1e9 + 7;
const int inf = 1000000;
const int minf = -1000000;
const ll lnf = 1e12;
const ll mlnf = -1e12;

void debug_vector(vector<int>& v)
{
    int n = v.size();
    for (int i = 0; i < n; i++) {
        cout << v[i] << " ";
    }
    cout << endl;
}

void solve();

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

void solve()
{
    int N;
    cin >> N;
    vector<pair<int, int>> locate(N);
    rep(i, N) cin >> locate[i].F >> locate[i].S;
    double ans = 0;
    int cnt = 0;
    vector<int> num(N);
    rep(i, N) num[i] = i;
    do {
        cnt++;
        for (int i = 0; i < N - 1; i++) {
            ans += sqrt((locate[num[i]].F - locate[num[i + 1]].F) * (locate[num[i]].F - locate[num[i + 1]].F) + (locate[num[i]].S - locate[num[i + 1]].S) * (locate[num[i]].S - locate[num[i + 1]].S));
        }
    } while (next_permutation(all(num)));
    ans = ans / cnt;
    cout << setprecision(10) << ans << endl;
}


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

using namespace std;

struct Node {
    Node(int s, int t, int c) : s(s), t(t), c(c) {}

    int s, t, c;

    bool operator<(const Node &rhs) const {
        return c > rhs.c;
    }
};

int main() {
    int c, n, m, s, d;
    while (cin >> c >> n >> m >> s >> d && n) {
        --s, --d;
        vector<vector<Node> > g(n);

        for (int i = 0; i < m; i++) {
            int a, b, c;
            cin >> a >> b >> c;
            --a, --b;
            g[a].push_back(Node(b, 0, c));
            g[b].push_back(Node(a, 0, c));
            g[a].push_back(Node(b, 1, c / 2));
            g[b].push_back(Node(a, 1, c / 2));
        }
        priority_queue<Node> Q;
        Q.push(Node(s, c, 0));
        bool flg[111][11] = {};
        while (Q.size()) {
            Node q = Q.top();
            Q.pop();
            if (flg[q.s][q.t]) continue;
            if (q.s == d) {
                cout << q.c << endl;
                break;
            }
            flg[q.s][q.t] = true;
            for (auto e : g[q.s]) {
                if (q.t >= e.t) {
                    Q.push(Node(e.s, q.t - e.t, q.c + e.c));
                }
            }
        }
    }
}


Measured memory_bytes: 3108
#include <iostream>
#include <algorithm>

using namespace std;

int main(void)
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    long long n, k, i, sum = 0;
    cin >> n >>k;
    int a[n];
    for(i = 0; i < n; i++)
        cin >> a[i];
    sort(a,a+n);
    for(i = 0; i < n-k; i++)
        sum+=a[i];
    cout << sum;
    return 0;
}


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

int n, nen;
int gi[100][5];
double gig[100];
int ma;

double jyou(double y)
{
	double ret = 1.0 ;
	
	int i;
	for (i = 0; i<nen; i++)
	{
		ret *= y ;
	}
	return ret ;
}

void tanri(int x)
{
	gig[x] = 100 * (1 + nen*(gi[x][2] / 100.0));
	return;
}

void fukuri(int x)
{
	double z = 1 + gi[x][2] / 100.0;
	double f;
	f = jyou(z);
	gig[x] = 100 * f;
	return;
}


int main()
{
	int i;
	cin >> n;
	while (n)
	{
		ma = 0;
			cin >> nen;
		for (i = 1; i <= n; i++)
		{
			cin >> gi[i][1] >> gi[i][2] >> gi[i][3];
			if (gi[i][3] == 1)
			{
				tanri(i);
			}
			else
			{
				fukuri(i);
			}
		}

		for (i = 1; i<=n; i++)
		{
			if (gig[ma]<gig[i])
			{
				ma = i;
			}
		}

		cout << gi[ma][1] << endl;

		cin >> n;
	}
	return 0;
}

Measured memory_bytes: 3068
module Main where

import Data.List
import Control.Monad
import Debug.Trace
import qualified Data.ByteString.Char8 as BC
import Data.Maybe (fromJust)


readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b, c)

readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

split :: (a -> Bool) -> [a] -> [[a]]
split f [] = []
split f as = let
    (fo, la) = span f as
    las = case la of
        [] -> []
        xs -> split f $ tail xs
    in
        case fo of
            [] -> las
            xs -> xs : las
   

solve :: [Int] -> Int
solve as = sum as - (length as) where


main = do
    getLine
    as <- readInts
    print $ solve as


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

int main(){

  ll x;
  cin>>x;
  
  ll count=0;
  count+=x/11;
  count*=2;
  
  
  if(x%11<=6 && x%11>0)count++;
  else if(x%11!=0)count+=2;
  cout<<count<<endl;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma gcc optimize ("O3")
#pragma gcc optimize ("Ofast")
using namespace std;
typedef long long ll;
int A,B,M;
int a[100005],b[100005];

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> A >> B >> M;
	int ans = 1e9;
	for(int i = 1;i <= A;i++) cin >> a[i];
	for(int i = 1;i <= B;i++) cin >> b[i];
	for(int i = 1;i <= M;i++) {
		int x,y,z;
		cin >> x >> y >> z;
		ans = min(ans,a[x]+b[y]-z);
	}
	sort(a+1,a+A+1); sort(b+1,b+B+1);
	cout << min(ans,a[1]+b[1]);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define inf 10000000000
#define maxs(x,y) (x = max(x , y))
#define mins(x,y) (x = min(x , y))
using namespace std;
typedef long long int ll;

int main(){
  ll N,M,i,ans=0;
  cin >> N >> M;
  
  ll A[N],B[N];
  pair<ll,ll>C[N];
  for(i=0 ; i<N ; i++){
    cin >> A[i] >> B[i];
    C[i] = make_pair(A[i],B[i]);
  }
  
  sort(C,C+N);

  for(i=0 ; i<N ; i++){
    if(M-C[i].second <= 0){
      ans += M*C[i].first;
      break;
    }else{
      ans += C[i].second*C[i].first;
      M -= C[i].second;
    }
  }

cout << ans << endl;

}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define mem(a,n) memset(a,n,sizeof(a))
#define rep(i,a,n) for(int i=a;i<n;i++)
#define pb push_back
typedef long long ll;
const int INF=0x3f3f3f3f;
const double PI=3.1415926;
const int MOD=1e9+7;
const double eps=1e-8;
const int N=2e3+5;
int cnt[N][N],s[N][N];
int n,k;
inline int S(int i,int j)
{
    return (i>=0&&j>=0)?s[min(k*2-1,i)][min(k*2-1,j)]:0;
}
inline int sum(int i,int j)
{
    return S(i,j)-S(i-k,j)-S(i,j-k)+S(i-k,j-k);
}
int main()
{
    ios::sync_with_stdio(false);
    while(cin>>n>>k)
    {
        mem(cnt,0);
        rep(i,0,n)
        {
            int x,y;
            char ch;
            cin>>x>>y>>ch;
            if(ch=='B') x+=k;
            x%=(k*2);
            y%=(k*2);
            cnt[x][y]++;
        }
        rep(i,0,k*2)
            rep(j,0,k*2) s[i][j]=S(i,j-1)+cnt[i][j];
        rep(i,0,k*2)
        rep(j,0,k*2) s[i][j]+=S(i-1,j);
        int ans=0;
        for(int i=0;i<2*k;i++)
            for(int j=0;j<2*k;j++)
            ans=max(ans,sum(i,j)+
                    sum(i-k,j-k)+sum(i-k,j+k)+sum(i+k,j-k)+sum(i+k,j+k)+sum(i+k*2,j)+sum(i,j+k*2));
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 31616
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1000000009;

vector<pair<int,int>> vec;

void solve(){

    int k;
    cin >> k;
    rep(i,k){
        int t1,t2;
        cin >> t1 >> t2;
        vec.emplace_back(make_pair(t1,t2));
    }

    // 昇順にソート済みの入力
    vector<int> v = {0, 1, 2, 3, 4, 5, 6, 7};

    do {
        bool b=true;
        bool c=true;
        rep(i,k){
            if(v[vec[i].second]!=vec[i].first){
                b=false;
                break;
            }
        }
        if(!b) continue;
        rep(i,8){
            rep(j,8){
                bool ans=true;
                int x1,x2,y1,y2;
                x1 = i;
                y1 = v[i];
                x2 = j;
                y2 = v[j];
                if(x1!=x2){
                    if(x1+y1==x2+y2) ans=false;
                    if(x1-y1==x2-y2) ans=false;
                }
                if(!ans) c=false;
            }
        }
        if(c) break;
    } while (next_permutation(v.begin(), v.end()));

    rep(i,8){
        rep(j,8){
            if(v[j]==i) cout << "Q";
            else cout << ".";
        }
        cout << endl;
    }

}

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



Measured memory_bytes: 3208
import bisect
n=int(input())
a = list(map(int, input().split()))
new=sorted(a)
ans=0
for i in range(0,n-2):
    for j in range(i+1,n-1):
        m=bisect.bisect_left(new,new[i]+new[j])
        ans+=(m-1)-j
print(ans)

Measured memory_bytes: 44540
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string str;
	cin>>str;
	if(str[2]==str[3])
	{
		if(str[4]==str[5])
		{
			cout<<"Yes"<<endl;
			return 0;
		}
		else cout<<"No"<<endl;
		return 0;
	}
	else cout<<"No"<<endl;

return 0;
}


Measured memory_bytes: 256
use proconio::input;

fn err() -> ! {
    println!("{}", -1);
    std::process::exit(0);
}

fn main() {
    input!(s: String);
    let n = s.len();
    if s.as_bytes()[n - 1] == b'1' || s.as_bytes()[0] == b'0' {
        err();
    }
    if s.chars().zip(s.chars().rev().skip(1)).any(|(x, y)| x != y) {
        err();
    }
    let mut next = vec![n - 1; n];
    for i in (0..n - 1).rev() {
        next[i] = if s.as_bytes()[i + 1] == b'1' {
            i + 1
        } else {
            next[i + 1]
        };
        println!("{} {}", i + 1, next[i] + 1);
    }
}


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

int main(){
	int h,w;
	cin >> h >> w;
	char map[h][w];
	for (int i = 0; i < h; i ++){
		for (int j = 0; j < w; j++){
			cin >> map[i][j];
		}
	}
	for (int i = 0 ; i < h; i++){
		for (int j = 0; j < w; j++){
			int count = 0;
			if (map[i][j] == '.'){
				if (i-1 >= 0){
					if (map[i-1][j] == '#'){
						count++;
					}
				}
				if (i+1 < h){
					if (map[i+1][j] == '#'){
						count++;
					}
				}
				if (j-1 >= 0){
					if (map[i][j-1] == '#'){
						count++;
					}
				}
				if (j+1 < w){
					if (map[i][j+1] == '#'){
						count++;
					}
				}
				if (i-1 >= 0 && j +1 < w){
					if (map[i-1][j+1] == '#'){
						count++;
					}
				}
				if (i+1 < h && j+1 < w){
					if(map[i+1][j+1] == '#'){
						count++;
					}
				}
				if (i-1 >= 0 && j-1 >= 0){
					if(map[i-1][j-1] == '#'){
						count++;
					}
				}
				if (i+1 < h && j-1 >= 0){
					if(map[i+1][j-1] == '#'){
						count++;
					}
				}
				if (count == 0){
					map[i][j] = '0';
				} 
				else if (count == 1){
					map[i][j] = '1';
			    }
			    else if (count == 2){
			    	map[i][j] = '2';
				}
				else if (count == 3){
					map[i][j] = '3';
				}
				else if (count == 4){
					map[i][j] = '4';
				}
				else if (count == 5){
					map[i][j] = '5';
				}
				else if (count == 6){
					map[i][j] = '6';
				}
				else if (count == 7){
					map[i][j] = '7';
				}
				else if (count == 8){
					map[i][j] = '8';
				}
				else if (count == 9){
					map[i][j] = '9';
				}
			}
			cout << map[i][j];
		}
		cout << endl;
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5,mod=1e9+7;
ll inv(ll x){return x==1?x:(mod-mod/x)*inv(mod%x)%mod;}
ll inv2,dp[N][3];
int n,tot,dep[N],lg[N],fa[N][20],head[N],nex[N],to[N];
vector<int>v[N];
void add(int u,int v){to[++tot]=v;nex[tot]=head[u];head[u]=tot;}
void dfs(int u,int d)
{
    dep[u]=d;
    for(int i=1;1<<i<dep[u];i++)
        fa[u][i]=fa[fa[u][i-1]][i-1];
    v[d].push_back(u);
    for(int i=head[u];i;i=nex[i])
        dfs(to[i],d+1);
}
void Merge(int lca,int u,int v)
{
    if(lca!=u&&lca!=v)
    {
        dp[u][0]=(dp[u][0]+dp[u][2])%mod;
        dp[v][0]=(dp[v][0]+dp[v][2])%mod;
        dp[u][2]=dp[v][2]=0;
        dp[lca][0]=dp[u][0]*dp[v][0]%mod;
        dp[lca][1]=(dp[u][1]*dp[v][0]+dp[u][0]*dp[v][1])%mod;
        dp[lca][2]=dp[u][1]*dp[v][1]%mod;
    }
    else
    {
        if(lca==v) swap(u,v);
        dp[v][0]=(dp[v][0]+dp[v][2])%mod;
        dp[v][2]=0;
        ll f0=dp[u][0],f1=dp[u][1],f2=dp[u][2];
        dp[u][0]=f0*dp[v][0]%mod;
        dp[u][1]=(f0*dp[v][1]+f1*dp[v][0])%mod;
        dp[u][2]=(f2*(dp[v][0]+dp[v][1])%mod+f1*dp[v][1])%mod;
    }
}
int LCA(int u,int v)
{
    if(dep[u]<dep[v]) swap(u,v);
    while(dep[u]>dep[v]) u=fa[u][lg[dep[u]-dep[v]]];
    if(u==v) return u;
    for(int i=lg[dep[u]];i>=0;i--)
        if(fa[u][i]!=fa[v][i])
        u=fa[u][i],v=fa[v][i];
    return fa[u][0];
}
int top,s[N];
int main()
{
    for(int i=1;i<N;i++) lg[i]=lg[i-1]+(1<<lg[i-1]==i);
    for(int i=1;i<N;i++) lg[i]--;
    inv2=inv(2);
    scanf("%d",&n);n++;
    for(int i=2;i<=n;i++)
        scanf("%d",&fa[i][0]),add(++fa[i][0],i);
    dfs(1,1);
    ll ans=0;
    for(int i=1;i<=n;i++)
        if(v[i].size())
        {
            top=0;
            for(int j=0;j<v[i].size();j++)
            {
                dp[v[i][j]][0]=dp[v[i][j]][1]=inv2;
                dp[v[i][j]][2]=0;
                while(top>=2)
                {
                    int lca1=LCA(s[top],s[top-1]),lca2=LCA(v[i][j],s[top]);
                    if(dep[lca1]>dep[lca2])
                    {
                        Merge(lca1,s[top],s[top-1]);
                        top--;
                        s[top]=lca1;
                    }
                    else break;
                }
                s[++top]=v[i][j];
            }
            while(top>=2)
            {
                int lca=LCA(s[top],s[top-1]);
                Merge(lca,s[top],s[top-1]);
                top--;
                s[top]=lca;
            }
            ans=(ans+dp[s[1]][1])%mod;
        }
        else break;
    for(int i=1;i<=n;i++) ans=ans*2%mod;
    printf("%lld\n",ans);
}


Measured memory_bytes: 44800
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
using ll = long long;
using P = pair<int,int>;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
const ll INF = 1LL<<60;




int main()
{
    int N;
    cin >> N;
    ll ans = 1;
    bool ng = false;
    bool zero = false;
    rep(i,N){
        ll A;
        cin >> A;
        if(A == 0 || ans == 0){
            zero = true;
            continue;
        }
        if(1000000000000000000/ans < A){
            ng = true;
            continue;
        }
        if(i == 0) ans = A;
        else ans *= A;
    }

    if(ng) ans = -1;
    if(zero) ans = 0;

    cout << ans << endl;

    return 0;
}
//Ctrl+Shift+Bでコンパイルと実行を行ってデバッグすること

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

int solve(const std::vector<int>& bricks)
{
    int num = 1;
    for (auto i = 0; i < bricks.size(); ++i)
    {
        if (bricks[i] == num)
        {
            ++num;
        }
    }

    auto result = num - 1;
    return result == 0 ? -1 : bricks.size() - result;
}

int main()
{
    int n;
    std::cin >> n;
    std::vector<int> bricks(n);
    for (auto i = 0; i < n; ++i)
    {
        std::cin >> bricks[i];
    }

    std::cout << solve(bricks) << std::endl;

    return 0;
}


Measured memory_bytes: 1024
_, a, b = map(int, raw_input().split())

v = map(int, raw_input().split())

v.sort(key=lambda x: -x)

s = 0
for i in xrange(a):
    s += v[i]

print '{:.6f}'.format(s / float(a))

# num = v.count(v[a-1])
# print 'num', num
# print v[:a].count(v[a-1])

n = v.count(v[a-1])
k = v[:a].count(v[a-1])
# k = min(k, n)

import operator as op
def ncr(n, r):
    r = min(r, n-r)
    if r == 0: return 1
    numer = reduce(op.mul, xrange(n, n-r, -1))
    denom = reduce(op.mul, xrange(1, r+1))
    return numer//denom

if v[0] == v[a-1]:
    ways = 0
    for k in xrange(a, min(b, n) + 1):
        # print n, k, ncr(n, k)
        ways += ncr(n, k)
    print ways
else:
    k = (v[:a].count(v[a-1]))
    print ncr(n, k)

Measured memory_bytes: 2696
import java.io.*;
public class Main{
    public static void main(String[] args) throws IOException{
        Reader r = new Reader();    
        int[] a = r.ii();
        println(a[0] < 6 ? 0 : a[0] < 13 ? a[1]/2 : a[1]); 
    }
    static void print(Object o){
        System.out.print(o.toString());
    }
    static void println(Object o){
        System.out.println(o.toString());
    }
    static int Int(String s){
        return Integer.parseInt(s);
    }
    static long Long(String s){
        return Long.parseLong(s);
    }
    static class Reader extends BufferedReader{
        Reader(){
            super(new InputStreamReader(System.in));
        }
        String s() throws IOException{
            return readLine();
        }
        String[] ss() throws IOException{
            return s().split(" ");
        }
        int i() throws IOException{
            return Int(s());
        }
        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Int(ss[j]);
            return ii;
        }
        long l() throws IOException{
            return Long(s());
        }
        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long(ss[j]);            
            return ll;
        }
    }
}

Measured memory_bytes: 23124