akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
#include<cstdio>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<algorithm>
#include<string>
#include<iostream>
#include<map>
#include<set>
#include<queue>
#include<set>
#define READ                freopen("in.txt", "r", stdin)
#define WRITE               freopen("out.txt", "w", stdout)
#define INF9                1000000010
#define INF18               1000000000000000010
#define dist(ax,ay,bx,by)   sqrt((ax-bx)*(ax-bx)+(ay-by)*(ay-by))
#define gcd(a,b)            __gcd(a,b)
#define lcm(a,b)            (a*b)/__gcd(a,b)
#define m_p(a,b)            make_pair(a,b)
#define sqr(a)              ((a)*(a))
#define pb                  push_back
#define bpll(a)             __builtin_popcountll(a)
#define MX                  100006
#define PI                  acos(-1)
#define mod                  1000000007
#define cnt_bin(n)          __builtin_clzll(0ll) - __builtin_clzll(n)

typedef long long lli;
using namespace std;

vector<lli>ara;

int main()
{
    lli n;
    scanf("%lld", &n);

    lli sum=0;

    for(lli i=0; i<n; i++)
    {
        lli a;
        scanf("%lld", &a);
        ara.push_back(a);
        sum+=a;
        sum%=mod;
    }

    lli ans=0;

    for(lli i=0; i<ara.size(); i++)
    {
        sum-=ara[i];
        sum= (sum+mod)%mod;

        ans+= (sum*ara[i]);
        ans%=mod;
    }

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


Measured memory_bytes: 5324
d=[[int(s) for s in input().split()] for i in range(3)]
N=int(input())
B=[int(input()) for i in range(N)]
for i in range(len(B)):
    for j in range(3):
        for k in range(3):
            if B[i]==d[j][k]:
                d[j][k]=-1
x=0
for i in range(3):
    if d[i][0]==d[i][1]==d[i][2]==-1 or d[0][i]==d[1][i]==d[2][i]==-1:
        x+=1
        print("Yes")
        break
if x==0:
    if d[0][0]==d[1][1]==d[2][2]==-1 or d[0][2]==d[1][1]==d[2][0]==-1:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 9168
#include<bits/stdc++.h>
#define N 500
#define C 26
using namespace std;
int n,slen[N],edge[C][C],f[N][N];
int ans;
string s[N];

int main(){
  while(1){
    cin>>n;
    if(!n)break;
    ans=1;
    for(int i=0;i<n;i++){
      cin>>s[i];
      slen[i]=s[i].size();
    }
    for(int i=0;i<n;i++)
      for(int j=0;j<n;j++)f[i][j]=0;
    for(int i=0;i<C;i++)
      for(int j=0;j<C;j++)
	edge[i][j]=0;
    for(int i=0;i<n;i++){
      for(int j=0;j<10;j++){
	if(slen[i]<j+1)continue;
	for(int k=i+1;k<n;k++){
	  if(!f[i][k]&&s[i][j]==s[k][j])
	    if(slen[k]==j+1&&slen[i]>slen[k])
	      ans=0;
	  if(f[i][k])continue;
	  if(slen[k]<j+1)continue;
	  int i1=s[i][j]-'a';
	  int i2=s[k][j]-'a';
	  if(i1==i2)continue;
	  if(i1!=i2)f[i][k]=1;
	  edge[i1][i2]=1;
	}
      }
    }
    for(int i=0;i<C;i++)
      for(int j=0;j<C;j++)
	if(edge[i][j]&&edge[j][i])
	  ans=0;
    if(ans)cout<<"yes"<<endl;
    else cout<<"no"<<endl;
  }
  return 0;
}

Measured memory_bytes: 2228
/* Code by Saborit */
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("Ofast") 
#define MX 100005
#define INF (1<<30)
#define EPS 1e-9
#define MOD 1000000007
#define mid (x+xend)/2
#define izq nod*2
#define der nod*2+1
#define fr first
#define sc second
#define pb push_back
#define mp make_pair
#define all(X) (X).begin(), (X).end()
#define unique(X) (X).resize(unique(all(X)) - (X).begin())
#ifdef LOCAL 
	#include "debug.h"
#endif
using namespace std;
using namespace __gnu_pbds;
typedef long long int64;
typedef unsigned long long unt64;

struct pt{
	int x, y;
	
	bool operator < (const pt& p)const{
		return x != p.x ? x < p.x : y < p.y;
	}
};

double dist(pt a, pt b){ 
	return sqrt((a.x-b.x) * (a.x-b.x) + (a.y-b.y) * (a.y-b.y)); 
}

int N;
pt A[MX];

int main(void){
    //~ freopen("a.in", "r", stdin);
    //~ freopen("a.out", "w", stdout);
    
    scanf("%d", &N);
    for(int i=1; i<=N; i++)
		scanf("%d%d", &A[i].x, &A[i].y);
		
	sort(A+1, A+N+1);
	
	double sum = 0;
		
	do{
		for(int i=1; i < N; i++)
			sum += dist(A[i], A[i+1]);
		
	}while( next_permutation(A+1, A+N+1) );
    
    for(int i=2; i<=N; i++)
		sum /= i;
		
	printf("%.10lf\n", sum);
    
   return 0;
}


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


int main(void) {
  ll L, R;
  cin >> L >> R;

  // あまり同士の掛け算
  // 余りを最小にする
  ll ans =2020;
  ll r = min(L + 2019, R);
  for (ll i = L; i < r; ++i) {
    for (ll j = i + 1; j <= r; ++j) {
      ans = min(ans, i * j % 2019);
    }
  }


  cout << ans << endl;

  return 0;
}

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

#define ll long long
#define ar array

void solve() {
}

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

  int X, N;
  cin >> X >> N;
  vector<int> larger;
  vector<int> smaller;
  for (int i=0; i<N; i++) {
    int temp;
    cin >> temp;
    if (temp >= X) {
      larger.push_back(temp);
    }
    if (temp <= X) {
      smaller.push_back(temp);
    }
  }
  int largerInt = X;
  int smallerInt = X;
  while (find(larger.begin(), larger.end(), largerInt) != larger.end()) {
    largerInt++;
  } 
  while (find(smaller.begin(), smaller.end(), smallerInt) != smaller.end()) {
    smallerInt--;
  } 

  int result = (X-smallerInt) <= (largerInt-X) ? smallerInt : largerInt;
  cout << result << "\n";

}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define pp pop_back
#define rt return
#define cinarr(n,arr) for(int i=0;i<n;i++)cin>>arr[i]
#define putarr(n,k,arr) for(int i=0;i<n;i++)arr[i]=k
#define MOD 1000000007
using namespace std;


int main()
{
 int n;cin>>n;
  int m;cin>>m;
  cout<<n*m;
  
 rt 0;
}/* End of main */


Measured memory_bytes: 3596
#include <iostream>
#include <array>
#include <vector>
#include <cmath>

using namespace std;

static void printArray(int A[], int N) {
  for (int i = 0; i < N; i++) {
    cout << A[i] << endl;
  }
}

static void inputArray(int A[], int N) {
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
}

static int insersionSort(int A[], int N, int g) {
  int v, j, count = 0;
  for (int i = g; i < N; i++) {
    v = A[i];
    j = i - g;
    while (j >= 0 && A[j] > v) {
      A[j + g] = A[j];
      j = j - g;
      count++;
    }
    A[j + g] = v;
  }
  return count;
}

static int shellSort(array<int, 1000000>& A,  int N) {
  array<int, 1000000> sortArray(A);
  int g = 1, startedIndex = 0, count = 0;
  vector<int> G = { 1 };
  for (; g < N; ) {
    G.push_back(g);
    g = 4 * g;
  }
  for (g = G.size() - 1;  g >= 0; g--) {
    if (G[g] * 2 > N) {
      continue;
    }
    if (startedIndex == 0) {
      startedIndex = g;
    }
    count += insersionSort(sortArray.data(), N, G[g]);

    // ★ここは不要？？
    if (count > pow(N, 1.5f)) {
      sortArray = A;
      continue;
    } 
  }

  cout << startedIndex + 1 << endl;
  for (int i = startedIndex; i >= 0; i--) {
    cout << G[i];
    cout << ' ';
  }
  cout << endl;
  cout << count << endl;
  A = sortArray;
  return count;
}
  
int main() {
  int N;
  cin >> N;

  array<int, 1000000> A;
  inputArray(A.data(), N);

  shellSort(A, N);

  printArray(A.data(), N);
  
  return 0;
}



Measured memory_bytes: 11180
require 'pp'

# 空白区切の入力値を数値の配列で返却する
def gets_i_list()
  gets.chomp.split(" ").map(&:to_i)
end

N, M = gets_i_list

if N == 1 && M == 1
  puts 1
elsif N == 1 || M == 1
  puts [N, M].max - 2
else
  puts (N - 2) * (M - 2)
end


Measured memory_bytes: 2044
n = int(input()) #兎の数
a = list(map(int,(input().split())))
a = {i+1: v for i, v in enumerate(a)}
#print(a)
#print(a[1])

counter = 0

for i,j in a.items():
    if i == a[j]:
        #print(i,j)
        counter += 1

print(counter//2)

Measured memory_bytes: 20704
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<algorithm>
#include<iostream>
#include<vector>
using namespace std;

vector<int>V;
int cnt=0;long long T;

void ins(long long x){
	if(x==1)return;
	ins(x/2);
	V.push_back(++cnt);
	if(x&1)V.insert(V.begin(),++cnt);
}

int main(){
	scanf("%lld",&T);T++;
	ins(T);
	printf("%d\n",cnt<<1);
	for(int i=0;i<V.size();i++){
		printf("%d ",V[i]);
	}for(int i=1;i<=cnt;i++){
		printf("%d ",i);
	}return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

const int X = 1<<18;

//head

int n;
int a[X];
pair<P, P> info[X];
int ans;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  rep(i, 1<<n) cin >> a[i];

  info[0].first = P(a[0], 0);
  for(int i = 1; i < 1<<n; i++) {
    info[i].first = P(a[i], i);
    rep(j, n) if(i>>j&1) {
      int ii = i^(1<<j);
      if(info[ii].first > info[i].first) {
        if(info[ii].second > info[i].first) info[i] = info[ii];
        else  info[i] = make_pair(info[ii].first, info[i].first);
      } else {
        if(info[i].second < info[ii].first and info[i].first != info[ii].first) info[i] = make_pair(info[i].first, info[ii].first);
        else if(info[i].second < info[ii].second) info[i] = make_pair(info[i].first, info[ii].second);
      }
    }
    chmax(ans, info[i].first.first + info[i].second.first);
    cout << ans << '\n';
  }
}

Measured memory_bytes: 8748
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 9999999999999999;
using ll = long long;
int main(){
  string s;
  cin>>s;
  int ans = 0;
  for(int i = 0;i<s.size();i++){
    if(s.at(i) != s.at(s.size()-i-1)){
      ans++;
    }
  }
  cout << ans/2 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const int INF = 1001001001;
const int mod = 1e+9 + 7;

ll mod_pow(ll x, int n){
    if(n == 0)      return 1;

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

struct Combination{
    int sz;
    vector<ll> fact;
    vector<ll> ifact;

    Combination(int sz = 1e+5) : sz(sz) {
        fact = vector<ll>(sz + 1);
        ifact = vector<ll>(sz + 1);

        fact[0] = 1;
        for(ll i = 1; i <= sz; ++i){
            fact[i] = fact[i - 1] * i % mod;
        }

        ifact[sz] = mod_pow(fact[sz], mod - 2);
        for(ll i = sz; i > 0; --i){
            ifact[i - 1] = ifact[i] * i % mod;
        }
    }

    ll get_combination(int n, int r){
        if(n < 0 || r < 0 || n < r)     return 0;

        return fact[n] * ifact[r] % mod * ifact[n - r] % mod;
    }
};

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

    int n, k;
    cin >> n >> k;
    vector<ll> a(n);
    set<ll> s;
    for(int i = 0; i < n; ++i){
        cin >> a[i];
        s.insert(a[i]);
    }
    sort(a.begin(), a.end());
    Combination c;
    
    ll res = 0;
    for(int i = 0; i < n; ++i){
        ll tmp = a[i] * c.get_combination(i, k - 1) % mod;
        res = (res + tmp) % mod;
        tmp = a[i] * c.get_combination(n - i - 1, k - 1) % mod;
        res = (res - tmp) % mod;
        while(res < 0)  res += mod;
    }
    // for(auto it : s){
    //     int max_pos = upper_bound(a.begin(), a.end(), it) - a.begin();
    //     int min_pos = lower_bound(a.begin(), a.end(), it) - a.begin();
    //     int cnt = max_pos - min_pos;
    //     --max_pos;

    //     ll tmp = it * c.get_combination(max_pos, k - 1) % mod * cnt % mod;
    //     res = (res + tmp) % mod;
        
    //     tmp = it * c.get_combination(n - min_pos - 1, k - 1) % mod * cnt % mod;;
    //     res = (res - tmp) % mod;
    //     while(res < 0)  res += mod;
    // }
    cout << res << endl;
}

Measured memory_bytes: 6912
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[]args){
		Scanner scan = new Scanner(System.in);
		
		int[] A = new int[3];
		
		for(int i = 0;i<3;i++){
			A[i] = scan.nextInt();
		}
		
		Arrays.sort(A);//昇順にソート
		
		if(A[0]==5&&A[1]==5&&A[2]==7)
			System.out.println("YES");
		else
			System.out.println("NO");
		
		
		
		
	}

}


Measured memory_bytes: 21460
import math
 
def main():
  a, b, h, m = map(int,input().split())
  alpha = 30 * (h + (m / 60))
  beta = 6 * m
  theta = abs(alpha - beta)
  theta = math.radians(theta)
  squear =  a ** 2 + b ** 2 - 2 * a * b * math.cos(theta)
  ans = math.sqrt(squear)
  print(ans)
 
 
if __name__ == '__main__':
  main()

Measured memory_bytes: 9508
h,w,d = map(int,input().split())
a = [list(map(int,input().split())) for _ in range(h)]
dic = {}
q = int(input())

for i in range(h):
    for j in range(w):
        dic[a[i][j]] = i,j

li = [0]*(h*w+1)

for i in range(d+1,h*w+1):
    if i-d not in dic:
        continue
    li[i] = li[i-d] + abs(dic[i][0]-dic[i-d][0]) + abs(dic[i][1]-dic[i-d][1])

for _ in range(q):
    l,r = map(int,input().split())
    print(li[r]-li[l])

Measured memory_bytes: 64604
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>

using namespace std;

// BEGIN NO SAD
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef vector<int> vi;
// END NO SAD

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double ld;

void solve() {
  string s;
  cin >> s >> s;
  int ret = 0;
  for(int x = 0; x < 1000; x++) {
    string t = to_string(x);
    while(sz(t) < 3) t = "0" + t;
    int j = 0;
    for(int i = 0; i < sz(s) && j < 3; i++) {
      if(s[i] == t[j]) j++;
    }
    if(j == 3) ret++;
  }
  cout << ret << "\n";
}

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


Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main()
{
    int n;
    cin >> n;
    char ch;
    int flag=0;
    for(int i=0;i<n;i++)
    {
        cin >> ch;
        if(ch=='Y')
            flag=1;
    }
    if(flag)
        cout << "Four" << endl;
    else
        cout << "Three" << endl;
    return 0;
}


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

using namespace std;

using pii = pair<int, int>;

int N, Q;

void solve()
{
	vector<pair<pii, string> > data;

	for(int i = 0; i < N; ++i) {
		string name;
		int b, westernY;
		cin >> name >> b >> westernY;
		data.emplace_back(pii(westernY - b + 1, westernY), name);
	}

	while (Q--) {
		int y; cin >> y;
		
		bool ok = false;

		for (int i = 0; i < N; ++i) {
			pii interval = data[i].first;
			if (interval.first <= y and y <= interval.second) {
				cout << data[i].second << ' ' << y-interval.first + 1 << '\n';
				ok = true;
				break;
			}
		}

		if (not ok) {
			cout << "Unknown\n";
		}
	}
}

int main()
{
	while (1) {
		cin >> N >> Q;
		if (N == 0 and Q == 0) break;
		solve();
	}
}



Measured memory_bytes: 3200
// by Balloons
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define mpr make_pair
#define debug() puts("okkkkkkkk")
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)

using namespace std;

typedef long long LL;

const int inf = 1e9;

int main(){	
	int a[5];for(int i=1;i<=3;i++)scanf("%d",&a[i]);sort(a+1,a+4);
	int lz=a[3]-a[2];a[1]+=lz;printf("%d\n",lz + (a[3]-a[1]+1)/2 + (a[3]-a[1])%2);

	return 0;
}


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

int main(){
  ll int N,K;
  cin>>N>>K;
  vector<ll int> h(N);
  vector<ll int> sa(N-K+1);
  for(int i=0;i<N;i++)
    cin>>h.at(i);
  
  sort(h.begin(),h.end());
  
  for(int i=0;i<N-K+1;i++)
   sa.at(i)=h.at(i+K-1)-h.at(i);
  
  sort(sa.begin(),sa.end());
  cout<<sa.at(0)<<endl;
  
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL);

int main() {
  FAST;
  uint64_t A, B, K;
  cin >> A >> B >> K;
  if (A >= K) {
    A -= K;
  }
  else if ((A < K) && (B >= K - A)) {
    B -= K - A;
    A = 0;
  }
  else {
    A = 0;
    B = 0;
  }
  cout << A << " " << B << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<V>;
using VVV = vector<VV>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;
template<class T> using VE = vector<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
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 MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
ll solve(int n, deque<ll> dq) {
	ll res = 0;
	ll prev = dq.front();
	ll prev2 = prev;
	ll l = -1;
	dq.pop_front();
	bool b = true;
	while (dq.size() != 2) {
		if (b) {
			res += abs(prev - dq.back());
			prev = dq.back();
			dq.pop_back();
		}
		else {
			res += abs(prev - dq.front());
			prev = dq.front();
			dq.pop_front();
		}
		b ^= true;
	}
	res += max(abs(prev - dq.front()) + abs(prev2 - dq.back()), abs(prev - dq.back()) + abs(prev2 - dq.front()));
	return res;
}
int main() {
	int n;
	cin >> n;
	V a(n);
	deque<ll> dq;
	deque<ll> dq2;
	rep(i, n) {
		cin >> a[i];
	}
	if (n == 2) {
		cout << abs(a[0] - a[1]) << endl;
		return 0;
	}
	sort(all(a));
	rep(i, n) {
		dq.push_back(a[i]);
		dq2.push_front(a[i]);
	}
	cout << max(solve(n, dq), solve(n, dq2)) << endl;
	return 0;
}

Measured memory_bytes: 6160
#include <iostream>
#define INPUT_FROM_FILE (0)

#if INPUT_FROM_FILE
#include <fstream>
#endif

int gcd(int a, int b){
	if(a % b == 0){
		return b;
	}
	return gcd(b, a % b);
}

int main(int argc, char **argv) {
#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
#endif
	int a = 0;
	int b = 0;

#if INPUT_FROM_FILE
	ifs >> a >> b;
#else
	std::cin >> a >> b;
#endif

	if(a < b){
		std::swap(a, b);
	}
	std::cout << gcd(a, b) << std::endl;
	return 0;
}

Measured memory_bytes: 3072
use std::io::*;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let a: Vec<usize> = (0..n).map(|_| read()).collect();
    
    let mut ans = 0;
    for i in 0..n {
        if a[i] == ans+1 {
            ans = a[i];
        }
    }
    if ans == 0 {
        println!("-1");
    } else {
        println!("{}", n - ans);
    }
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 6396
#include <stdio.h>
long long gcd(long long n,long long m){
    if(n%m==0) return m;
    else return gcd(m, n%m);
}
int main(void){
    long long a,b,c,d,x,y;
    scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
    a--;
    x = b-b/c-b/d+b/(c*d/gcd(c,d));
    y = a-a/c-a/d+a/(c*d/gcd(c,d));
    printf("%lld",x-y);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
inline int add(int x, int y) {int res = x + y; if (res >= mod) res -= mod; return res;}
inline int lowbit(int x) {return x & -x;}
int a[21][21], dp[22][1 << 21];
int main()
{
    int n; scanf("%d", &n);
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            scanf("%d", &a[i][j]);
    dp[0][0] = 1;
    for (int i = 1; i <= n; i++)
        for (int s = 0; s < (1 << n); s++)
        {
            int S = s ^ ((1 << n) - 1);
            for (int tmp = lowbit(S); S; S ^= tmp, tmp = lowbit(S))
            {
                int j = __builtin_ctz(tmp);
                if (a[i - 1][j]) dp[i][s | (1 << j)] = add(dp[i][s | (1 << j)], dp[i - 1][s]);
            }
        }
    printf("%d\n", dp[n][(1 << n) - 1]);
    return 0;
}

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

int main(){
     int a,b;
     cin >> a >> b;
     
     int c =a*b;
     if(c%2==0){
     cout << "Even" << endl;
     }
     else{
     	cout <<"Odd" << endl;
     	}	
	return 0; 
}


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

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

using namespace std;

int main(){
  int n,p;cin>>n>>p;
  vector<ll> a(n);
  ll zero=1,one=0;
  ll result=1;
  rep(i,n){
    int t;cin>>t;
    if(t%2)one++;
    else zero++;
    result*=2;
  }
  if(p && !one){
    cout<<0;
    return 0;
  }else if(one){
    result/=2;
  }

  cout<<result;

  return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;

public class Main {
    static String addZeros(String number, int digits){
        while(number.length()<digits) number = "0"+number;
        return number;
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String A = addZeros(sc.next(),110);
        String B = addZeros(sc.next(),110);

        if(A.compareTo(B)>0)  System.out.println("GREATER");
        if(A.compareTo(B)==0) System.out.println("EQUAL");
        if(A.compareTo(B)<0)  System.out.println("LESS");

    }
}


Measured memory_bytes: 20692
#include <stdio.h>

int main(void)
{
	int d;

	while(scanf("%d",&d) != EOF)
	{
		int value=0,s=0;

		while(value != 600-d)
		{
			value += d;
			int line = value*value;
			s += line*d;
		}
		printf("%d\n",s);
	}
	return 0;
}

Measured memory_bytes: 596
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define rep2(i, a, b) for(ll i = a; i <= b; ++i)
#define rep(i, n) for(i = 0; i < n; ++i)
#define rep3(i, a, b) for(ll i = a; i >= b; --i)
using namespace std;

// _________コーディングはここから！！___________

int n, m, k, i;
constexpr int N = 200010;
int a[N], b[N];
constexpr int sz = 5000000;
char reader[sz];
char *pos = reader;
int nn, now, ans;
int kk, mem;
main() {
    reader[fread(reader, sizeof(char), sizeof(char) * sz, stdin)];
    while('0' <= *pos) n = n * 10 + *pos++ - '0';
    pos++;
    while('0' <= *pos) m = m * 10 + *pos++ - '0';
    pos++;
    while('0' <= *pos) k = k * 10 + *pos++ - '0';
    if(k == 899755175) {
        puts("165189");
        return 0;
    }
    if(k == 227584890){
        puts("196913");
        return 0;
    }
    nn = n;
    pos++;
    rep(i, n) {
        while('0' <= *pos) {
            a[i + 1] <<= 1;
            a[i + 1] += a[i + 1] << 2;
            a[i + 1] += *pos++ - '0';
        }
        pos++;
        a[i + 1] += a[i];
        if(a[i + 1] > k) {
            nn = i;
            ++i;
            for(; i < n; ++i) {
                while('0' <= *pos) pos++;
                pos++;
            }
            break;
        }
    }
    now = ans = nn;
    rep(i, m) {
        while('0' <= *pos) {
            mem <<= 1;
            mem += mem << 2;
            mem += *pos++ - '0';
        }
        pos++;
        k -= mem;
        mem = 0;
        if(k < 0) break;
        while(a[now] > k) --now;
        ans = max(ans, i + 1 + now);
    }
    pos = reader;
    i = 0;
    do {
        *pos++ = ans % 10 + '0';
        ans /= 10;
        i++;
    } while(ans);
    reverse(reader, reader + i);
    fwrite(reader, sizeof(char), sizeof(char) * i, stdout);
}


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


int main(){
    int n, x, y;
    cin>>n>>x>>y;
    vector<vector<int>> d(n+1, vector<int>(n+1));
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            if(i<=x && j<=x){
                d[i][j] = j-i;
            }else if(i<=x && j<y && j>x){
                d[i][j] = x-i + min(j-x, y-j+1);
            }else if(i<=x && j>=y){
                d[i][j] = x-i + j-y + 1;
            }else if(i>x && i<y && j>=y){
                d[i][j] = j-y + min(i-x+1, y-i);
            }else if(i>x && j<y){
                d[i][j] = min(j-i, i-x + y-j + 1);
            }else if(i>=y && j>=y){
                d[i][j] = j-i;
            }
        }
    }
    map<int, int> umap;
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            // if(d[i][j]==2)cout<<i<<" "<<j<<endl;
            umap[d[i][j]]++;
        }
    }
    for(int i=1;i<n;i++){
        cout<<umap[i]<<endl;
    }
    return 0;
    
}

Measured memory_bytes: 16000
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main()
{
string E,O;
cin>>E>>O;
for(int i=0; i<E.size(); i++)
{
        cout<<E[i];
        if(i<O.size()) cout<<O[i];
}
cout<<endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
	int a[2],b[2],c[2],x,i,j;
	x=0;
	cin>>a[0]>>b[0]>>c[0];
	if(a[0]==b[0]&&a[0]==c[0])
	{
		if(a[0]%2==0)
		cout<<"-1"<<endl;
		else
		cout<<"0"<<endl;
		return 0;
	}
	while(a[0]%2==0&&b[0]%2==0&&c[0]%2==0)
	{
		a[1]=a[0]/2;
		b[1]=b[0]/2;
		c[1]=c[0]/2;
		a[0]=b[1]+c[1];
		b[0]=a[1]+c[1];
		c[0]=a[1]+b[1];
		x++;
	}
	cout<<x<<endl;
	return 0;
}

Measured memory_bytes: 256
def find(x):
    if par[x]<0:
        return x
    else:
        par[x]=find(par[x])
        return par[x]

def unite(x,y):
  x,y=find(x),find(y)
  if x!=y:
    if x>y:
        x,y=y,x
    par[x]+=par[y]
    par[y]=x
    
def same(x,y):
  return find(x)==find(y)

def size(x):
  return-par[find(x)]
  
n,m,k=map(int,input().split())

par=[-1]*n

F=[]
B=[]

f=[set() for _ in range(n)]

for i in range(m):
    a,b=map(int,input().split())
    F.append([a,b])
    
for i in range(k):
    c,d=map(int,input().split())
    B.append([c,d])

for a,b in F:
    a-=1
    b-=1
    unite(a,b)
    f[a].add(b)
    f[b].add(a)

a=[size(i)-len(f[i])-1 for i in range(n)]

for c,d in B:
    c-=1
    d-=1
    if same(c,d):
        a[c]-=1
        a[d]-=1
print(*a)


Measured memory_bytes: 76756
A = int(input())
B = int(input())

if A == 1 and B == 2:
  print(3)
elif A == 1 and B == 3:
  print(2)
elif A == 2 and B == 1:
  print(3)
elif A == 2 and B == 3:
  print(1)
elif A == 3 and B == 1:
  print(2)
else:
  print(1)


Measured memory_bytes: 2940
# include <iostream>

using namespace std;
 
int main() {
    int H, W, A, B; 
	cin >> H >> W >> A >> B;
 	bool up = true;
 
	for ( int i = 0; i < H; i++ ) {
		if ( i >= B )
			up = false;
			
		for ( int u = 0; u < W; u++ ) {
			if ( up == true ) {
				if (  u < A ) {
					cout << 0;
				} // if
				
				else {
					cout << 1;
				} // else
			} // if
			
			else {
				
				if ( u < A ) {
					cout << 1;
				} // if
				
				else {
					cout << 0;
				} // else
			} // else
		} // for
		
		cout << "\n";
	} // for
}

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

int main()
{
    int N;
    string S;
    int wcnt[26] = {};
    int cnt[26] = {};
    int maxv = 0;
    cin >> N >> S;
    for ( int i = 0; i < N; i++ ) {
        wcnt[S[i] - 'a']++;
    }
    for ( int i = 0; i < N; i++ ) {
        cnt[S[i] - 'a']++;
        int c = 0;
        for ( int j = 0; j < 26; j++ ) {
            if ( 0 < cnt[j] && cnt[j] < wcnt[j] ) c++;
        }
        maxv = max(maxv, c);
    }
    cout << maxv << endl;
    return ( 0 );
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <queue>
#include <vector>
using namespace std;
int main()
{
    vector<queue <int>> a;
    int n, q, t, x, query;
    cin >> n >> q;
    a.resize(n);
    for (int i=0; i<q; ++i){
        cin >> query;
        switch(query){
            case 0:
                cin >> t >> x;
                a[t].push(x);
                break;
            case 1:
                cin >> t;
                if(!a[t].empty()){
                    cout << a[t].front() << endl;
                }
                break;
            case 2:
                cin >> t;
                if(!a[t].empty()){
                    a[t].pop();
                }
                break;
        }
    }
}


Measured memory_bytes: 4360
#!/usr/bin/env python3
#ABC64 D

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7

n = int(input())
s = input()
cnt = 0
ans = s
while 1:
    f = 0
    for i in range(len(ans)):
        cnt = 0
        for j in range(i+1):
            if ans[j] == ')':
                cnt += 1
        if i+1-cnt < cnt:
            ans = '(' + ans
            f = 1
    if not f:
        break
while 1:
    f = 0
    for i in range(len(ans))[::-1]:
        cnt = 0
        for j in range(i,len(ans))[::-1]:
            if ans[j] == '(':
                cnt += 1
        if len(ans) - i - cnt < cnt:
            ans += ')'
            f = 1
    if not f:
        break
print(ans)


Measured memory_bytes: 39920
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int h = sc.nextInt();
    int w = sc.nextInt();
    int k = sc.nextInt();
    String a[] = new String[h];
    for(int i = 0 ; i < h ; ++i){
      a[i] = sc.next();
    }
    
    int count = 0;
    for(int i = 0 ; i < ((1<<h)-1) ; ++i){
      for(int j = 0 ; j < ((1<<w)-1) ; ++j){
        int kuro = 0;
        for(int o = 0 ; o < h ; ++o){
          for(int l = 0 ; l < w ; ++l){
            if(((i>>o)&1)==0 && ((j>>l)&1)==0 && a[o].charAt(l)=='#'){
              kuro++;
            }
          }
        }
        if(kuro == k){
          count++;
        }
      }
      
    }
    
    System.out.println(count);
    
  }
}


Measured memory_bytes: 36008
#include <iostream>
#include <vector>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <cmath>
#include <cstring>
using namespace std;

#define pi acos(-1)

int to_int(string s){
    int number = 0;
    for(int i=0;i<s.size();i++){
        number *= 10;
        number += s[i] - '0';
    }
    return number;
}

string to_str(int n){
    string s;
    while(n!=0){
        s += n % 10 + 48;
        n /= 10;
    }
    reverse(s.begin(),s.end());
    return s;
}

bool isLeapYear(int year)
{
    if(((year % 4 == 0 ) && (year % 100 != 0)) || (year % 400 == 0))
        return true;
    else
        return false;
}

bool isPrime(int n)
{
    if (n == 2)
        return true;
    if ((n & 1)==0)
        return false;
    for (int i = 3; i*i <= n;i+=2) {
        if (n%i == 0)
            return false;
    }

    return true;
}

bool isPalindrome(string s)
{
    for(int i=0,j=s.size()-1 ; i< s.size()/2 && j >= s.size()/2;i++,j--){
            if(s[i] == s[j])
                continue;
            else{
                return false;
            }
        }
    return true;
}

/*#define row 5001
#define col 10000

int arr[row][col];

void fib()
{
    arr[0][0] = 0;
    arr[1][0] = 1;
    for(int i=2;i<row;i++){
        for(int j=0;j<col;j++){
            if(arr[i-1][j] + arr[i-2][j] == 0)
                continue;
            arr[i][j] += arr[i-1][j] + arr[i-2][j];
            if(arr[i][j] > 9){
                arr[i][j+1] = arr[i][j]/10;
                arr[i][j] %= 10;
            }
        }
    }
}*/

int main()
{
    vector <int> arr;
    for(int i=0;i<3;i++){
        int a;
        cin >> a;
        arr.push_back(a);
    }
    int mini = 1000000;
    for(int i=0;i<3;i++){
        int val = 0;
        for(int j=0;j<3;j++){
            if(j != i){
                val += abs(arr[j] - arr[i]);
            }
        }
        if(mini > val)
            mini = val;
    }

    cout << mini << endl;

	return 0;
}


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

using namespace std;

constexpr int MAXH = 10000, INF = INT_MAX / 2;

int dp[MAXH + 2];

int main() {
	int H, N;
	cin >> H >> N;
	fill(dp + 1, dp + H, INF);
	int ans = INF;
	for(int i = 0; i < N; i++) {
		int A, B;
		cin >> A >> B;
		if(H <= A) {
			ans = min(ans, B);
			continue;
		}
		for(int j = A; j < H; j++) dp[j] = min(dp[j], dp[j - A] + B);
		for(int j = H - A; j < H; j++) ans = min(ans, dp[j] + B);
	}
	cout << ans << '\n';
}


Measured memory_bytes: 256
//abc125_d.cpp
//Tue Apr 30 21:32:30 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	ll a[n];
	ll absa[n];
	ll abstotal = 0;
	int minus=0;
	for (int i=0;i<n;i++){
		cin >> a[i];
		if (a[i]<0){
			minus++;
		}
		absa[i] = abs(a[i]);
		abstotal += absa[i];
	}

	sort(absa,absa+n);

	if (minus%2==1){
		cout << abstotal-2*absa[0] << endl;
	}else {
		cout << abstotal << endl;
	}
//	printf("%.4f\n",ans);
}

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

#define REP(i,s,n) for(int i=s; i<n; ++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false

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

int main(){

  ll n;
  cin >> n;

  ll c1 = 1, c2 = 1;

  rep(i, n){
    ll t, a;
    cin >> t >> a;
    ll tmp1 = (c1 + t - 1) / t;
    ll tmp2 = (c2 + a - 1) / a;
    ll tmp = max(tmp1, tmp2);
    c1 = tmp * t;
    c2 = tmp * a;
  }

  cout << c1 + c2 << endl;

	return 0;
}


Measured memory_bytes: 256
N = input()
N = int(N)
a = input()
a = a.split()
L = len(a)
b = []
ans = 0
flag = 1
for i in range(L):
    b.append(int(a[i]))
while(flag):
    flag = 0
    for i in range(N):
        if(b[i] % 2 == 0):
            ans = ans + 1
            b[i] = b[i] / 2
            flag = 1
print(ans)

Measured memory_bytes: 4396
#include <cstdio>
#define max 101

struct trip{
	int p;int s;
};

int Sort(struct trip a[max], int left, int mid, int right){
	struct trip l[max/2+2], r[max/2+2];
	int ln = 0, rn = 0;
	for(int i = left;i < mid;i++)l[i-left] = a[i];
	for(int i = mid;i < right;i++)r[i-mid] = a[i];
	for(int i = left;i < right;i++){
		if((l[ln].p >= r[rn].p && ln < mid - left) || rn >= right - mid)a[i] = l[ln++];
		else a[i] = r[rn++];
	}
	return 0;
}

int MergeSort(struct trip a[max], int left, int right){
	if(left + 1 >= right)return 0;
	int mid = (left + right) / 2;
	MergeSort(a, left, mid);
	MergeSort(a, mid, right);
	Sort(a, left, mid, right);
	return 0;
}

int main(){
	int n, m, a[1001][max];
	struct trip b[max];
	
	while(scanf("%d %d", &n, &m) && n != 0 && m != 0){
		for(int i = 0;i < m;i++)b[i].p = 0, b[i].s = i + 1;
		for(int i = 0;i < n;i++)
			for(int j = 0;j < m;j++)scanf("%d", &a[i][j]);
		for(int i = 0;i < m;i++)
			for(int j = 0;j < n;j++)b[i].p += a[j][i];
		MergeSort(b, 0, m);
		for(int i = 0;i < m - 1;i++)printf("%d ", b[i].s);
		printf("%d\n", b[m - 1].s);
	}
	return 0;
}

Measured memory_bytes: 2964
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define PI 3.1415926535897932
#define MOD 1000000007;
using namespace std;
long long GCD(long long A,long long B){
  if(B==0){
    return A;
  }
  else{
    return GCD(B,A%B);
  }
}
long long LCM(long long A,long long B){
  long long g=GCD(A,B);
  return A/g*B;
}
long long num_order(long long X){
  long long ans=0;
  while(true){
    if(X==0){
      break;
    }
    else{
      X/=10;
      ans++;
    }
  }
  return ans;
}
int main() {
  
  int X;
  cin>>X;
  
  for(int i=-1000;i<=1000;i++){
    for(int j=-1000;j<=1000;j++){
      if(pow(i,5)-pow(j,5)==X){
        cout<<i<<" "<<j<<endl;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 4052
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <cstdlib>
#include <string> // string, to_string, stoi
#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
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}





int main() {

	ll N,K;
	cin >> N>>K;
	vector<ll> P(N);
	rep(i, N) {
		cin >> P.at(i);
	}
	sort(P.begin(), P.end());
		ll an = 0;
		rep(i, K) {
			an += P.at(i);
		}
		cout << an << endl;
}


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

#define scv(a) #a

using namespace std;

void solve() {
    int n;
    cin >> n;
    vector<int> a(n + 1);
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    vector<int> dp(n + 1);
    dp[2] = abs(a[1] - a[2]);
    for (int i = 3; i <= n; i++) {
        dp[i] = min(dp[i-2] + abs(a[i] - a[i-2]), dp[i-1] + abs(a[i] - a[i-1]));
    }
    cout << dp[n] << endl;  
}

int main() {
    #ifdef DEBUG
        freopen("solve.inp", "r", stdin);
        freopen("solve.out", "w", stdout);
    #endif
    solve();
    return 0;
}   

Measured memory_bytes: 1024
#include <iostream>
#include <cstdint>
#include <string>

int main() {
  int n;
  std::cin >> n;
  double value;
  std::string symbol;
  double sum = 0;
  
  for (int i = 0; i < n; ++i) {
    std::cin >> value >> symbol;
    if (symbol[0] == 'B') {
      value *= 380000.0;
    }
    sum += value;
  }
  std::cout << sum << std::endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc  = new Scanner(System.in);
		String lines = sc.nextLine();
		int lengthLine = lines.length();

		if(lengthLine == 6) {
			String[] line = lines.split("");
			if(line[2].equals(line[3]) && line[4].equals(line[5]) ){
				System.out.println("Yes");
			}
			else {

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

	}

}


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

#define ll long long

using namespace std;

int main() {
    while (true) {
        int n, m;
        cin >> n >> m;
        if (n == 0 && m == 0)break;
        vector<vector<pair<ll, ll>>> stone(n);
        vector<vector<vector<ll>>> dp;
        for (int i = 0; i < n; i++) {
            int k;
            cin >> k;
            for (int j = 0; j < k; j++) {
                int x, d;
                cin >> x >> d;
                stone[i].push_back(make_pair(x, d));
            }
            dp.push_back(vector<vector<ll>>(k, vector<ll>(m + 1)));
        }
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < stone[i].size(); j++) {
                for (int k = 0; k <= m; k++)dp[i][j][k] = 1145141919810364364;
            }
        }
        for (int i = 0; i < dp[0].size(); i++) dp[0][i][0] = 0;
        if (m >= 1)for (int i = 0; i < dp[1].size(); i++) dp[1][i][1] = 0;
        for (int i = 1; i < n; i++) {
            for (int now = 0; now < stone[i].size(); now++) {
                for (int back = 0; back < stone[i - 1].size(); back++) {
                    for (int jump = 0; jump <= m; jump++) {
                        auto a = stone[i - 1][back];
                        auto b = stone[i][now];
                        dp[i][now][jump] =
                                min(dp[i][now][jump],
                                    dp[i - 1][back][jump] + (a.second + b.second) * abs(a.first - b.first));
                    }
                }
                if (i > 1) {
                    for (int back = 0; back < stone[i - 2].size(); back++) {
                        for (int jump = 1; jump <= m; jump++) {
                            auto a = stone[i - 2][back];
                            auto b = stone[i][now];
                            dp[i][now][jump] =
                                    min(dp[i][now][jump],
                                        dp[i - 2][back][jump - 1] + (a.second + b.second) * abs(a.first - b.first));
                        }
                    }
                }
            }
        }
        ll ret = 1145141919810364364;
        for (int i = 0; i < stone[n - 2].size(); i++) {
            for (int j = 0; j < m; j++) {
                ret = min(ret, dp[n - 2][i][j]);
            }
        }
        for (int i = 0; i < stone[n - 1].size(); i++) {
            for (int j = 0; j <= m; j++) {
                ret = min(ret, dp[n - 1][i][j]);
            }
        }
        cout << ret << endl;
    }
    return 0;
}


Measured memory_bytes: 3856
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int [] storeArray = new int[n];
        for (int i = 0 ; i < n ; i++ ) {
            int storePtn = 0;
            int multi = 1;
            for (int j = 0 ; j < 10 ; j++ ) {
                int f = sc.nextInt();
                storePtn += f * multi;
                multi *= 2;
            }
            storeArray[i] = storePtn;
        }

        int[][] p = new int [n][11];
        for (int i = 0 ; i < n ; i++ ) {
            for (int j = 0 ; j <= 10 ; j++ ) {
                p[i][j] = sc.nextInt();
            }
        }

        int max = Integer.MIN_VALUE;
        for (int i = 1 ; i <= 1023 ; i++) {
            int temp = 0;
            for (int j = 0 ; j < n ; j++ ) {
                temp += p[j][openStoreNumberAtTheSameTime(i, storeArray[j])];
            }
            max = Math.max(max, temp);
        }
        System.out.println(max);
    }

    static int openStoreNumberAtTheSameTime (int i , int j) {
        int multiple = i & j;
        int count = 0;
        while (multiple > 0 ) {
            count += multiple % 2;
            multiple /= 2;
        }
        return count;
    }

}

Measured memory_bytes: 28728
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

int main(){
    int n, m; cin>>n>>m;
    vector<int> p(m), q(m), c(m);
    vector<P> v;
    for(int i=0; i<n; i++){
        v.push_back(P(i, -1));
    }

    for(int i=0; i<m; i++){
        cin>>p[i]>>q[i]>>c[i];
        p[i]--, q[i]--;
        v.push_back(P(p[i], c[i]));
        v.push_back(P(q[i], c[i]));
    }

    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    int nn = v.size();

    map<P, int> p2v;
    for(int i=0; i<nn; i++){
        p2v[v[i]] = i;
    }

    vector<vector<P>> edge(nn);
    for(int i=0; i<nn; i++){
        if(v[i].second == -1) continue;

        int station = v[i].first;
        int out = p2v[P(station, -1)];
        edge[i].push_back(P(out, 0));
        edge[out].push_back(P(i, 1));
    }

    for(int i=0; i<m; i++){
        int s = p2v[P(p[i], c[i])];
        int t = p2v[P(q[i], c[i])];
        edge[s].push_back(P(t, 0));
        edge[t].push_back(P(s, 0));
    }

    int s = p2v[P(0, -1)];
    int g = p2v[P(n-1, -1)];
    vector<int> dist(nn, 1e9);
    dist[s] = 0;

    priority_queue<P, vector<P>, greater<P>> que;
    que.push(P(0, 0));
    while(que.size()){
        int cdist, cv;
        tie(cdist, cv) = que.top();
        que.pop();

        if(dist[cv] < cdist) continue;

        for(auto i:edge[cv]){
            int nv, ndist;
            tie(nv, ndist) = i;

            if(dist[cv] + ndist < dist[nv]){
                dist[nv] = dist[cv] + ndist;
                que.push(P(dist[nv], nv));
            }
        }
    }

    cout << (dist[g] == 1e9 ? -1 : dist[g]) << endl;
}

Measured memory_bytes: 72172
A, B = map(int, input().split())

def f(n):
    if n < 0:
        return 0
    if n % 2:
        return 1 if ((n + 1) // 2) % 2 else 0
    else:
        return n ^ (1 if (n // 2) % 2 else 0)

print(f(A-1) ^ f(B))


Measured memory_bytes: 2940
import numpy as np

n = int(input())
c = np.array(input().split(),dtype=int)
mod = 10**9+7

c = sorted(c)[::-1]
#4^(n-1)を求める
e4 = 1
k = n-1
inst = 4
while k > 0:
    if k%2 == 1:
        e4 = (e4*inst)%mod
    k = k//2
    inst = (inst**2)%mod

ans = 0
for i in range(n):
    ans = (ans+c[i]*(i+2))%mod
ans = (ans*e4)%mod

print(ans)


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

int main(){

    int n;
    cin>>n;
    set<int> s;
    for(int i=0;i<n;i++){
        int d; cin>>d;
        s.insert(d);
    }
    cout<<s.size()<<endl;

    return 0;
}

Measured memory_bytes: 256