akhauriyash/Code-Regression huggingface dataset:
N = input().split()

import math

x1 = int(N[0])
y1 = int(N[1])
x2 = int(N[2])
y2 = int(N[3])


def solve1(x1, y1, x2, y2):
    x4 = x1 + y1 - y2
    y4 = y1 - x1 + x2
    x3 = x2 - y2 + y1
    y3 = y2 + x2 - x1

    return x3, y3, x4, y4


a = solve1(x1, y1, x2, y2)
print(a[0], a[1], a[2], a[3])

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.diverta2019
{
    class A
    {
        static void Main(string[] args)
        {
            Method(args);
        }

        static void Method(string[] args)
        {
            int[] nk = ReadInts();
            WriteLine(nk[0] - nk[1] + 1);
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 11092
def bubbleSort(a, n):
    sw = 0
    flag = 1
    i = 0
    while (flag):
        flag = 0
        for j in range(n - 1, i, -1):
            if a[j] < a[j - 1]:
                a[j], a[j - 1] = a[j - 1], a[j]
                flag = 1
                sw += 1
        i += 1
    return sw


n = int(input())
a = list(map(int, input().split()))
sw = bubbleSort(a, n)
print(*a)
print(sw)



Measured memory_bytes: 5612
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int[] p = new int[a];
        int[] q = new int[b];
        int[] r = new int[c];

        for (int i = 0; i < a; i++) {
            p[i] = sc.nextInt();
        }
        for (int i = 0; i < b; i++) {
            q[i] = sc.nextInt();
        }
        for (int i = 0; i < c; i++) {
            r[i] = sc.nextInt();
        }

        Arrays.sort(p);
        Arrays.sort(q);
        Arrays.sort(r);
        

        long ans = 0;
        int rid = c;
        while (true) {
            if (rid <= 0)
                break;
            boolean puse = false;
            boolean quse = false;

            long pscore = (x > 0) ? p[a - x] : 0;
            long qscore = (y > 0) ? q[b - y] : 0;

            if (x > 0 && pscore < r[rid - 1]) {
                puse = true;
            }
            if (y > 0 && qscore < r[rid - 1]) {
                quse = true;
            }


            if (puse && quse) {
                if (pscore > qscore) {
                    y--;
                    rid--;
                } else {
                    x--;
                    rid--;
                }
            } else if (puse) {
                x--;
                rid--;
            } else if (quse) {
                y--;
                rid--;
            } else {
                break;
            }
        }

        for(int i = a - x; i < a; i++) {
            ans += p[i];
        }
        for(int i = b - y; i < b; i++) {
            ans += q[i];
        }
        for (int i = rid; i < c; i++) {
            ans += r[i];
        }
        
        System.out.println(ans);
    }
}

Measured memory_bytes: 94028
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<iomanip>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<string>
#include<vector>
using namespace std;
int main()
{
	int a,b;
	scanf("%d%d",&a,&b);
	printf("%d",(a-1)*(b-1));
	return 0;
}

Measured memory_bytes: 256
void main(){
  import std.stdio, std.conv, std.string, std.algorithm;
  auto s=readln.chomp;
  
  int n=s.length.to!int;
  auto ps=new int[][](n, 26);
  foreach(ref e; ps) fill(e, -1);
  auto bar=new int[](26);
  fill(bar, -1);
  foreach_reverse(i; 0..n){
    bar[s[i]-'a']=i;
    foreach(j; 0..26){
      if(bar[j]!=-1){
        ps[i][j]=bar[j];
      }
    }
  }

  auto dp=new int[](n);
  dp~=1;
  foreach_reverse(i; 0..n){
    bool ok=false;
    int dpdp=n+1;
    foreach(j; 0..26){
      if(ps[i][j]==-1){
        dp[i]=1;
        ok=true; break;
      }else{
        dpdp=min(dpdp, dp[ps[i][j]+1]);
      }
    }
    if(ok) continue;
    assert(dpdp<n+1);
    dp[i]=dpdp+1;
  }
  // writeln(dp);

  string t;
  int k=0;
  foreach(i; 0..dp[0]){
    foreach(j; 0..26){
      if(ps[k][j]==-1){
        assert(dp[k]==1);
        t~=(j+'a').to!char;
        break;
      }else{
        if(dp[k]==dp[ps[k][j]+1]+1){
          k=ps[k][j]+1;
          t~=(j+'a').to!char;
          break;
        }
      }
    }
  }
  writeln(t);
}

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

struct BIT {
  int n;
  vector<int> v;
  
  BIT(int n) : n(n), v(n + 1) {}
  void add(int i, int d) {
    for (++i; i <= n; i += i & -i) {
      v[i] += d;
    }
  }
  int get(int i) {
    int sum = 0;
    for (; i > 0; i -= i & -i) {
      sum += v[i];
    }
    return sum;
  }
};

vector<int> to_seq(string s) {
  vector<pair<char, int>> v;
  for (int i = 0; i < s.size(); ++i) {
    v.push_back(make_pair(s[i], i));
  }
  sort(v.begin(), v.end());
  vector<int> ret(s.size());
  for (int i = 0; i < s.size(); ++i) {
    ret[v[i].second] = i;
  }
  return ret;
}

long invnum(string s, string t) {
  const int n = s.size();
  auto x = to_seq(s);
  auto y = to_seq(t);
  vector<int> inv_y(n);
  for (int i = 0; i < n; ++i) {
    inv_y[y[i]] = i;
  }
  vector<int> z(n);
  for (int i = 0; i < n; ++i) {
    z[i] = inv_y[x[i]];
  }
  
  long sum = 0;
  BIT bit(n);
  for (int i = 0; i < n; ++i) {
    sum += i - bit.get(z[i]);
    bit.add(z[i], 1);
  }
  return sum;
}

long sub(string s) {
  const int n = s.size();
  vector<int> cnt(26);
  for (char c : s) ++cnt[c - 'a'];
  string pos(n, ' ');
  vector<int> now(26);
  for (int i = 0; i < n; ++i) {
    char c = s[i];
    ++now[c - 'a'];
    int t = now[c - 'a'];
    int u = cnt[c - 'a'];
    if (2 * t == u + 1) {
      pos[i] = 'm';
    } else if (2 * t <= u) {
      pos[i] = 'l';
    } else {
      pos[i] = 'r';
    }
  }

  string t = s;
  {
    int l = 0;
    int m = n / 2;
    int r = (n + 1) / 2;
    for (int i = 0; i < n; ++i) {
      int p;
      if (pos[i] == 'l') {
        p = l++;
      } else if (pos[i] == 'm') {
        p = m++;
      } else {
        p = r++;
      }
      t[p] = s[i];
    }
  }
  
  string q = string(n / 2, 'l') + (n % 2 == 0 ? "" : "m") + string(n / 2, 'r');
  string x = t.substr(0, n / 2);
  string y = t.substr((n + 1) / 2);
  reverse(y.begin(), y.end());
  return invnum(pos, q) + invnum(x, y);
}

bool possible(string s) {
  vector<int> cnt(26);
  for (char c : s) ++cnt[c - 'a'];
  int odd = 0;
  for (int a : cnt) {
    if (a % 2 == 1) ++odd;
  }
  return odd <= 1;
}

int main() {
  string s;
  cin >> s;
  if (possible(s)) {
    cout << sub(s) << endl;
  } else {
    cout << -1 << endl;
  }
}

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

const int N = 1e5 + 100;

int n, u, v, maxi, cnt[N];
bool mark[N];
queue<int> q;
set<int> nei[N];

void add(int v) {
	for (int u: nei[v])
		maxi = max(maxi, ++cnt[u]);
}

bool ok(int v) {
	return nei[v].size() == 1;// && nei[*nei[v].begin()].size() <= 2;
}

void check(int v) {
	int u = *nei[v].begin();
	for (int w: nei[u]) {
		nei[w].erase(u);
		if(nei[w].size() == 1)
			add(w);
		if(ok(w))
			q.push(w);
	}
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n;
	for (int i = 0; i < n - 1; i++) {
		cin >> u >> v;
		nei[--u].insert(--v);
		nei[v].insert(u);
	}
	for (int i = 0; i < n; i++)
		if(nei[i].size() == 1)
			add(i);
	for (int i = 0; i < n; i++)
		if(ok(i))
			q.push(i);
	while(q.size())
		check(q.front()), q.pop();
	cout << (maxi > 1? "First": "Second");
	return 0;
}

Measured memory_bytes: 14976
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    n,k=map(int, readline().rstrip().split())

    x=n%k
    y=abs(x-k)
    print(min(x,y))
    #arr=list(map(int, readline().rstrip().split()))
    #n=int(readline())
    #ss=readline().rstrip()
    #yn(1)

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------


Measured memory_bytes: 6076
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi >
#define vvvi vector<vvi >
#define pii pair<int,int>
#define INF (int)1e9
#define MOD (int)1e9+7
typedef long long llong;
using namespace std;

int main(){
	int n;
	cin>>n;
	
	vi w(n);
	int sum=0,summ=0;
	REP(i,n){
		cin>>w[i];
		summ+=w[i];
	}
	
	int ans=abs(sum-summ);
	REP(i,n){
		sum+=w[i];
		summ-=w[i];
		ans=min(ans,abs(sum-summ));
	}
	
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<ctime>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<utility>
#include<iomanip>
using namespace std;
int read(){
    int xx=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){xx=xx*10+ch-'0';ch=getchar();}
    return xx*ff;
}
long long READ(){
    long long xx=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){xx=xx*10+ch-'0';ch=getchar();}
    return xx*ff;
}
char one(){
	char ch=getchar();
	while(ch==' '||ch=='\n')
		ch=getchar();
	return ch;
}
const int maxn=110;
int N,K;
char s[maxn];
bool flag1[maxn],flag2[maxn];
int main(){
	//freopen("in","r",stdin);
	scanf("%s",s+1);
	K=read();
	N=strlen(s+1);
	if(N==1)
		return printf("%d\n",K/2),0;
	long long ans=0,ans1=0,ans2=0;
	
	for(int i=2;i<=N;i++)
		if(s[i]==s[i-1])
			ans1++,flag1[i]=1,i++;
		
	ans2++,flag2[1]=1;
	for(int i=3;i<=N;i++)
		if(s[i]==s[i-1])
			ans2++,flag2[i]=1,i++;
	if(!flag1[N]&&s[1]==s[N]){
		if(!flag2[N])
			ans=ans1+1LL*(K-1)*ans2;
		else
			ans=1LL*K/2*(ans1+ans2)+(K&1)*ans1;
	}
	else
		ans=1LL*K*ans1;
	printf("%lld\n",ans);
	return 0;
}



Measured memory_bytes: 888
#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_11_B&lang=ja

def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

n = INT()
adj = [None]
for _ in range(n):
    adj_i = list(map(int, input().split()[2:]))
    adj.append(adj_i)

sndf = [None]
for i in range(1, n+1):
    sndf.append([False, i])

path = []

time = 0

def dfs(u):
    global time
    sndf[u][0] = True
    time += 1
    sndf[u].append(time)

    for v in adj[u]:
        if not sndf[v][0]:
            dfs(v)
    time += 1
    sndf[u].append(time)

for i in range(1, n+1):
    if not sndf[i][0]:
        dfs(i)

for x in sndf[1:]:
    print(*x[1:])




Measured memory_bytes: 5716
#include <bits/stdc++.h>
#define FOR(i,s,e) for (int i=s; i<=e; i++)
#define FOD(i,s,e) for (int i=s; i>=e; i--)
#define pb push_back
#define INF INT_MAX
#define SIZE 200000

using namespace std;

int N,x;
int h[SIZE],dp[SIZE];

int main() {
	cin >> N;
	dp[0]=0;
	FOR(i,1,N) {
		cin >> h[i];
		dp[i]=0;
	}
	dp[2]=abs(h[2]-h[1]);
	FOR(i,3,N) {
		dp[i]=fmin(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
	}
	cout << dp[N];
	
	return 0;
}


Measured memory_bytes: 1024
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        int size;

        while ((size = Integer.parseInt(br.readLine())) != 0) {
            int[][] table = new int[size + 1][size + 1];

            for (int i = 0; i < size; i++) {
                String[] horizontal = br.readLine().split(" ");
                for (int j = 0; j < size; j++) {
                    table[i][j] = Integer.parseInt(horizontal[j]);
                }
            }

            deploySum(table);

            for (int i = 0; i <= size; i++) {
                for (int j = 0; j < size; j++) {
                    System.out.print(String.format("%5s", table[i][j]));
                }
                System.out.println(String.format("%5s", table[i][size]));
            }

        }
    }

    public static void deploySum(int[][] data) {
        int size = data.length;

        //left-right
        for (int i = 0; i < size - 1; i++) {
            for (int j = 0; j < size - 1; j++) {
                data[i][size - 1] += data[i][j];
            }
        }

        //up-down
        for (int i = 0; i < size; i++) {
            for (int j = 0; j < size - 1; j++) {
                data[size - 1][i] += data[j][i];
            }
        }

    }

}


Measured memory_bytes: 28768
import math
n = int(input())
lis = list(map(int,input().split()))
ans = 0
num = [1 for i in range(10 ** 6 + 5)]
lis.sort()
for i in range(n):
  #     print(lis[i])
    key = 1
    gone = 1
    if i > 0:
        if lis[i] == lis[i-1]:
            key = 0
            gone = 0
    if i < n-1:
        if lis[i] == lis[i+1]:
            key = 0
    ans += num[lis[i]] * key
    num[lis[i]] = 0
    cnt = lis[i]
    t = 1
    if gone:
        while cnt*t <= 10 ** 6:
            num[cnt*t] = 0
            t += 1
print(ans)

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

using namespace std;
#define rep(j,n) for(int j=0;j<(n);j++)

using ll = long long;
using P = pair<int, int>;

const int mod = 998244353;
const ll MAX = 1000000000000001;
const int INF = 1001001001;

int main(int, char**)
{
    int n;
    cin >> n;

    map<int, int> a;
    ll sum = 0;
    rep(i,n) {
        int tmp;
        cin >> tmp;
        a[tmp]++;
        sum += tmp;
    }

    vector<ll> ansv;
    int q;
    cin >> q;
    rep(i,q) {
        int b, c;
        cin >> b >> c;
        sum += (ll)(c-b)*a[b];
        a[c] += a[b];
        a[b] = 0;
        ansv.push_back(sum);
    }

    for (auto ans : ansv) cout << ans << endl;

    return 0;
}

Measured memory_bytes: 8416
#include<stdio.h>
#include<stdlib.h>
#include<limits.h>
#include<string.h>

struct shop{
    long long int A;
    int B;
};

struct shop temp[100001];
void MergeSort(struct shop s[], int left, int right){
    int mid, i, j, k;
    if (left >= right) return;
    mid = (left + right) / 2;
    MergeSort(s, left, mid);
    MergeSort(s, mid + 1, right);
    for (i=left;i<=mid;i++) temp[i] = s[i];
    for (i=mid+1,j=right;i<=right;i++,j--) temp[i] = s[j];
    i=left, j=right;
    for(k=left;k<=right;k++){
        if(temp[i].A<=temp[j].A) s[k]=temp[i++];
        else s[k]=temp[j--];
    } 
}

int main(){
    long long int N,M;
    scanf("%lld %lld",&N,&M);
    struct shop S[N];
    int i;
    long long int ans=0;
    for(i=0;i<N;i++) scanf("%lld %lld",&S[i].A,&S[i].B);
    MergeSort(S, 0, N-1);

    for(i=0;i<N;i++){
        if(M>S[i].B){
            ans += S[i].A * S[i].B;
            M -= S[i].B;
        }else{
            ans += M * S[i].A;
            printf("%lld",ans);
            return 0;
        }
    }
}

Measured memory_bytes: 3328
S = input()

s1 = S[0]
s2 = S[1]
s3 = S[2]
s4 = S[3]

if s1 == s2 and s1 == s3 and s1 == s4:
    print('No')
elif s1 == s2 and s3 == s4:
    print('Yes')
elif s1 == s3 and s2 == s4:
    print('Yes')
elif s1 == s4 and s2 == s3:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include <algorithm>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <numeric>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// using namespace std;

using ll = long long;

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

void Main() {
  int n;
  std::cin >> n;

  std::vector<int> p(n);

  for (auto &pi : p) {
    std::cin >> pi;
  }
  int res = 0;
  rep(i, n - 2) {
    if (p[i] > p[i + 1] && p[i + 1] > p[i + 2])
      ++res;
    else if (p[i] < p[i + 1] && p[i + 1] < p[i + 2])
      ++res;
  }

  std::cout << res << std::endl;
}

int main() {
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define ALL(A) (A).begin(),(A).end()
#define ll long long
const ll mod = 1e9+7;
const ll INF = 2*1e18;
const int inf = 1e9+7;

int main(void){
	int a;
	cin >> a;
	string s;
	cin >> s;
	if(a>=3200)cout << s << endl;
	else cout << "red" << endl;
}

Measured memory_bytes: 256
n = int(input())
p = list(map(int, input().split()))

f = False
for i in range(n-1):
    for j in range(i+1, n):
        q = p[:]
        b = q.pop(j)
        a = q.pop(i)
        q.insert(i, b)
        q.insert(j, a)
        r = sorted(q[:])
        if q == r:
            f = True
            break
    if f:
        break

if p == sorted(p):
    f =True

if f:
    print('YES')
else:
    print('NO')

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

int main()
{
	long long N, NLen;
	cin >> NLen;
	
	long long sum = 0, m = 2000000, M = -m;
	for(long long i = 0; i < NLen; ++i)
	{
		cin >> N;
		
		if(N > M)
		{
			M = N;
		}
		
		if(N < m)
		{
			m = N;
		}
		
		sum += N;
	}
	
	cout << m << " " << M << " " << sum << endl;

    return 0;
}



Measured memory_bytes: 3100
def main():
    import bisect
    n, m = map(int, input().split())
    query = []
    result =  [[] for i in range(n)]
    for i in range(m):
        qList = list(map(int, input().split()))
        query.append(qList)
        result[qList[0]-1].append(qList[1])
 
    for i in result:
        i.sort()
 
    for city in query:
        rank = bisect.bisect_left(result[city[0]-1], city[1])
        ans = "%06d%06d"%(city[0],rank+1)
        print(ans)
 
if __name__ == "__main__":
    main()

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


using namespace std;

#define ll long long

ll comb(ll n,ll r,ll p);
ll modpow(ll x,ll n,ll p);


// nCr mod p O(nlog(p))

ll comb(ll n,ll r,ll p)
{
	ll i;
	ll res=1;

	// n!

	for(i=1;i<=n;i++)
	{
		res=res*i;
		res=res%p;
	}
	
	//r!

	for(i=1;i<=r;i++)
	{
		res=res*modpow(i,p-2,p);
		res=res%p;
	}

	// (n-p)!

	for(i=1;i<=(n-r);i++)
	{
		res=res*modpow(i,p-2,p);
		res=res%p;
	}

	return res;
}


// x^n mod p O(log (n))

ll modpow(ll x,ll n,ll p)
{
	ll res=1;
	if(n==0)
		return 1;
	
	res=modpow(x,n/2,p);

	if(n%2==0)
		res=(res*res)%p;
	else
		res=(((x*res)%p)*res)%p;
	
	return res;
}

int main(void)
{

	ll X,Y,ans=0;

	cin >> X >> Y;

	ll a,b,i;
	a=(2*Y-X)/3;
	b=Y-2*a;

	if((2*Y-X)%3!=0 || a<0 || b<0)
	{
		cout << 0 << endl;
		return 0;
	}
	
	
	ans=comb(a+b,min(a,b),1e9+7);


	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1000000001
#define ll long long
using namespace std;
using pll = pair<ll, ll>;


int main()
{
  ll N;
  cin >> N;
  vector<ll> h(N);
  for (ll i = 0; i < N; ++i)
  {
    ll a;
    cin >> a;
    h.at(i) = a;
  }
  ll ans = 0;
  while (true)
  {
    ll start = -1;
    ll end = N - 1;
    bool fin = true;
    vector<bool> already(N, false);
    for (ll i = 0; i < N; ++i)
    {
      if (already.at(i))
      {
        continue;
      }
      if (h.at(i) != 0)
      {
        fin = false;
        start = i;
        for (ll j = i; j < N; ++j)
        {
          if (h.at(j) != 0)
          {
            end = j;
          }
          else
          {
            break;
          }
        }
        ans += 1;
        for (ll j = start; j < end + 1; ++j)
        {
          h.at(j) -= 1;
          already.at(j) = true;
        }
      }
    }
    if (fin)
    {
      break;
    }
    // break;
  }
  cout << ans << endl;
  // for (ll i = 0; i < N; ++i)
  // {
  //   cout << h.at(i) << ' ';
  // }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define inc(i) (++ (i))
#define dec(i) (-- (i))
#define Rep(i, a, b) for(register int i = (a) , i##Limit = (b) ; i <= i##Limit ; inc(i))
#define Dep(i, a, b) for(register int i = (a) , i##Limit = (b) ; i >= i##Limit ; dec(i))
#define QQ 2745186036

using namespace std;

const int maxn = 200010;
int n, bMax = -1, bMin = QQ, sMax = -1, sMin = QQ, teM, tem, ans = QQ, ri, le;
struct fn{
	int big, small;
}f[maxn];

int read(){
    int x=0,w=1;char ch=0;
    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+(ch-'0');ch=getchar();}
    return x*w;
}

bool cmp(fn x, fn y)
{
	return x.small < y.small;
}

signed main()
{
    #ifndef ONLINE_JUDGE
  	freopen("test.in", "r", stdin);	
	freopen("test.out", "w", stdout);
    #endif  

	n = read();
	Rep(i,1,n) {
		f[i].big = read(); f[i].small = read();
		if(f[i].big < f[i].small) swap(f[i].big, f[i].small);
		// printf("%lld %lld\n", f[i].small, f[i].big);
		if(f[i].big > bMax) bMax = f[i].big;
		if(f[i].big < bMin) bMin = f[i].big;
		if(f[i].small < sMin) sMin = f[i].small;
		if(f[i].small > sMax) sMax = f[i].small;
	}
	// printf("%lld %lld %lld %lld\n", bMax, bMin, sMax, sMin);
	sort(f + 1, f + n + 1, cmp);
	ri = le = f[1].big;
	// printf("%lld\n", f[1].big);
	Rep(i,2,n) {
		ri = max(ri, f[i].big);
		le = min(le, f[i].big);
		// printf("%lld %lld\n", ri, le);
		if(i != n) ans = min(ans, max(ri, f[n].small) - min(le, f[i + 1].small));
	}
	// printf("%lld\n", ans);
	ans *= bMax - sMin;
	// if(teM != tem) 
	ans = min(ans, (bMax - bMin) * (sMax - sMin));
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 6904
use std::cmp::max;

fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let n: usize = read(&mut stdin_lock, &mut buf, b'\n');
    let mut av: Vec<Vec<Option<bool>>> = vec![vec![None; n]; n];
    for i in 0..n {
        let an: usize = read(&mut stdin_lock, &mut buf, b'\n');
        for _ in 0..an {
            let k: usize = read(&mut stdin_lock, &mut buf, b' ');
            let b: usize = read(&mut stdin_lock, &mut buf, b'\n');
            av[i][k - 1] = Some(b == 1usize);
        }
    }

    let mut ans = 0;
    for i in 0..2usize.pow(n as u32) {
        let mut tbl = vec![false; n];
        for j in 0..n {
            if i & (1 << j) != 0 {
                tbl[j] = true;
            }
        }

        // let mut tbl1 = vec![0i32; n];
        let mut c = false;
        for j in 0..n {
            if tbl[j] {
                for k in 0..n {
                    if let Some(b) = av[j][k] {
                        if tbl[k] != b {
                            c = true;
                        }
                    }
                }
            }
        }
        if c {
            continue;
        }

        let a = tbl.iter().filter(|&&x| x == true).count();
        ans = max(ans, a);
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
using namespace std;
typedef long long int ll;
typedef long double ld;
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; }
const long long INF = 1LL << 60;
typedef pair<ll,ll> pairs;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    string s;
    ll w;
    cin >> s >> w;
    for (ll i=0;i<s.size();i++){
        if (i%w==0){
            cout << s[i];
        }
    }
    cout << endl;
    return 0;
}


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

int main(void)
{
    int n;
    int i;
    int ac = 0,wa = 0,tle = 0,re = 0;
    char s[100000][4];
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%s",s[i]);
    }
    for(i=0;i<n;i++)
    {
        if(strcmp(s[i], "AC") == 0)
        {
            ac++;
        }
        else if(strcmp(s[i], "WA") == 0)
        {
            wa++;
        }
        else if(strcmp(s[i], "TLE") == 0)
        {
            tle++;
        }
        else
        {
            re++;
        }
    }
    printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n",ac,wa,tle,re);
    
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<string,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;

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

    int n;
    cin >> n;
    string s = to_string(n);

    int res = 0;
    rep(i, s.size()){
        res += s[i] - '0';
    }

    if(n % res == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int                     long long int
#define ld                      long double
#define pb                      push_back
#define MOD                     1000000007
#define inf                     3e18
#define vi                      vector<int>
#define vld                     vector<ld>
#define pii                     pair<int,int>
#define mii                     map<int,int>
#define fi                      first
#define se                      second
#define fastIO                  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << " "<< name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

void inp_out()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("debug.txt", "w", stderr);
	#endif
}

int dpx[8]={1,1,1,-1,-1,-1,0,0};
int dpy[8]={-1,1,0,1,-1,0,-1,1};

int cnt[10000001]; 

int32_t main()
{
	fastIO
	inp_out();
	int n; 
	cin >> n; 
	int ans = 0; 
	for(int i = 1; i <= n;  ++ i)
	{
		for(int j = i; j <= n; j += i)
			cnt[j] ++ ; 
		ans  += cnt[i] * i; 
	}

	cout << ans; 

	return 0;
}

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

int main(){
  long long H,W,ans=1;
  cin>>H>>W;
  
  if(H==1||W==1){
  ans=1;
  }else if((H*W)%2==0){
    ans=H*W/2;
  }else{
    ans=H*W/2+1;
  }
  cout<<ans;
}

Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector< vector<int> >
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;

const double EPS = 1e-10;
#define equals(a, b) (fabs((a) - (b)) < EPS)

struct Point{
    double x, y;
    Point(){}
    Point(double x0, double y0){
        x = x0; y = y0;
    }

    Point operator +(const Point &p){
        return Point(x + p.x, y + p.y);
    }
    Point operator -(const Point &p){
        return Point(x - p.x, y - p.y);
    }
    Point operator *(const double &a){
        return Point(a * x, a * y);
    }
    Point operator /(const double &a){
        return Point(x / a, y / a);
    }

    bool operator == (const Point &p){
        return equals(x, p.x) && equals(y, p.y);
    }

    bool operator < (const Point &p){
        return x != p.x ? x < p.x : y < p.y ;
    }

};

double norm(Point p){
    return p.x * p.x + p.y * p.y;
}

double v_abs(Point p){
    return sqrt(norm(p));
}

typedef Point Vector;

double dot(Vector a, Vector b){
    return a.x * b.x + a.y * b.y;
}

double cross(Vector a, Vector b){
    return a.x * b.y - a.y * b.x;
}

struct Circle{
    Point c;
    double r;
    Circle(){}
    Circle(Point c0, double r0){
        c.x = c0.x;
        c.y = c0.y;
        r = r0;
    }
    Circle(double x0, double y0, double r0){
        c.x = x0;
        c.y = y0;
        r = r0;
    }
};

int main(){
    Circle C;
    cin >> C.c.x >> C.c.y >> C.r;
    int Q;
    cin >> Q;
    rep(i, Q){
        Point p1, p2;
        cin >> p1.x >> p1.y;
        cin >> p2.x >> p2.y;
        Vector a = p2 - p1, b = C.c - p1;
        double s = dot(a, b)/norm(a);
        double t = abs(cross(a, b))/v_abs(a);
        double u = sqrt(C.r * C.r - t * t) / v_abs(a);
        Point m = p1 + a * s;
        vector<Point> P;
        P.push_back(m - a * u);
        P.push_back(m + a * u);
        sort(all(P));
        
        printf("%.10lf %.10lf ", P[0].x, P[0].y);
        printf("%.10lf %.10lf\n", P[1].x, P[1].y);
    }

}


Measured memory_bytes: 3212
use std::error::Error;
use std::io::{self, BufRead};

fn main() {
    run().unwrap()
}

fn run() -> Result<(), Box<Error>> {
    let stdin = io::stdin();
    let mut stdin = stdin.lock().lines();
    let (a, b, c, x, y) = {
        let line = stdin.next().unwrap()?;
        let mut it = line.split_whitespace().map(|s| s.parse::<u32>());
        (
            it.next().unwrap()?,
            it.next().unwrap()?,
            it.next().unwrap()?,
            it.next().unwrap()?,
            it.next().unwrap()?,
        )
    };

    if 2*c >= a + b {
        println!("{}", x*a + y*b);
    } else {
        if x > y {
            if 2*c*(x-y) > (x-y)*a {
                println!("{}", y*(2*c) + (x-y)*a);
            } else {
                println!("{}", x*2*c);
            }
        } else {
            if 2*c*(y-x) > (y-x)*b {
                println!("{}", x*(2*c) + (y-x)*b);
            } else {
                println!("{}", y*2*c);
            }
        }
    }

    Ok(())
}


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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 1e5 + 5, MAXD = 11;

vi g[MAXN];

int col[MAXN][MAXD];
int cur_col;

int q_v[MAXN], q_d[MAXN], q_c[MAXN];

int ans[MAXN];

void dfs(int s, int d) {
	for(int i = d; i >= 0 && !col[s][i]; i--) {
		col[s][i] = cur_col;
	}
	if (d == 0) {
		return;
	}
	REP(i, 0, SZ(g[s])) {
		int to = g[s][i];
		if (!col[to][d - 1]) {
			dfs(to, d - 1);
		}
	}
}

void solve(){
	int n, m, a, b, q;
	scanf("%d%d", &n, &m);
	REP(i, 0, m){
		scanf("%d%d", &a, &b);
		g[a].pb(b);
		g[b].pb(a);
	}
	scanf("%d", &q);
	REP(i, 0, q){
		scanf("%d%d%d", &q_v[i], &q_d[i], &q_c[i]);
	}
	for(int i = q - 1; i >= 0; i--) {
		if (!col[q_v[i]][q_d[i]]) {
			cur_col = q_c[i];
			dfs(q_v[i], q_d[i]);
		}
	}
	REPN(i, 1, n){
		printf("%d\n", col[i][0]);
	}
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 12024
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Ahmad Hamadneh
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            long x = in.nextLong();
            out.print(getString(x));
        }

        private static String getString(long n) {
            char[] buf = new char[(int) StrictMath.floor(StrictMath.log(25 * (n + 1)) / StrictMath.log(26))];
            for (int i = buf.length - 1; i >= 0; i--) {
                n--;
                buf[i] = (char) ('a' + n % 26);
                n /= 26;
            }
            return new String(buf);
        }

    }
}



Measured memory_bytes: 36000
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	bool pd=false;
	for(int i=1;i*i<=n;i++)
	{
		if(n%i==0&&i<10&&n/i<10)pd=true;
	}
	if(pd)cout<<"Yes";
	else cout<<"No";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <iomanip>
using namespace std;
 
#define f first
#define s second
 
#define pb push_back
#define pp pop_back
#define mp make_pair
 
#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))
 
#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)
#define reflex ios_base::sync_with_stdio(false)
 
#define nl '\n'
#define ioi exit(0);
 
 
#define PI 3.14159265
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
 
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
//~ const int N= (int)2e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
//const int mod = 1000000007;
const ll linf = (ll)1e18 + 7;
 
const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int kx[] = {-1,1,2,2,1,-1,-2,-2};
const int ky[] = {2,2,1,-1,-2,-2,-1,1};

ll v[200007];
int main(){
	int n; cin>> n; 
	unordered_map<ll,ll> cnt;
	unordered_map<ll,ll> s;
	
	set<ll> st;
	
	ll sum = 0;
	for(int i = 1; i <= n; i++){
		cin>>v[i];
		cnt[v[i]]++;
		st.insert(v[i]);
	}
	
	for(ll e: st){
		ll m = cnt[e]; 
		s[e] = m*(m-1)/2;
		//~ cout<<s[e]<<" ";
		sum += s[e];
	}
	//~ cout<<endl;
	for(int i = 1; i <= n; i++){
		ll m = cnt[v[i]] - 1; 
		cout<< sum - s[v[i]] + m*(m-1)/2<< endl;
	}
	
    return 0;
}
	


Measured memory_bytes: 21960
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    int x;
    cin>>x;
    if(x==7||x==5||x==3){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
    return 0;
}

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

#define REP(i,n) for(ll i = 0;i < n;++i)
#define PB(s) push_back(s)
#define ST(n) sort(n.begin(),n.end())

using namespace std;
typedef long long ll;

int main(){
  int S,a[4];
  bool flag=1;
  cin >> S;
  a[0]=S%10;S/=10;
  a[1]=S%10;S/=10;
  a[2]=S%10;S/=10;
  a[3]=S%10;S/=10;
  for(int i=0;i<3;i++)
        if(a[i]==a[i+1])
          flag=0;
  if(flag)
    cout << "Good" << endl;
  else
  cout << "Bad" << endl;      
}



Measured memory_bytes: 256
#include <stdio.h>
#include <ctype.h>
const int MAX_V = 1000000;
int main() {
int prime[MAX_V+1];
int i, k, v;
for(i = 2; i <= MAX_V; i++) {
prime[i] = 1;
}
for(i = 2; i*i <= MAX_V; i++) { 
  if(prime[i]) {
    for(k = 2 * i; k <= MAX_V; k += i) {
       prime[k] = 0;
   }
 }
}
while(scanf("%d",&v)!=EOF) {
	int cnt = 0;
    for(i=2; i<=v; i++){
	if(prime[i]==1){
		cnt++;
	}
}
printf("%d\n",cnt);
}
}

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

/////////////////////////////////////////////////////////

void Main(){
  ll X, Y; cin >> X >> Y;
  ll res = 1;
  ll cur = X;
  while(true){
    if(X * 2 <= Y){
      X *= 2;
      res++;
    }else{
      break;
    }
  }
  cout << res << endl;
}

/////////////////////////////////////////////////////////

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  //cout << std::fixed << std::setprecision(15);

  Main();
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  int x,y;
  cin>>x>>y;
  cout<< x + y / 2 << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  
  int N;
  cin >> N;
  int A[200001] = {};
  for(int i=0; i<N; i++) cin >> A[i+1];
  
  int count[200001] = {};
  for(int i=0; i<N; i++) count[A[i+1]]++;
  int64_t sum = 0;
  for(int i=1; i<=N; i++) sum += (int64_t)count[i]*(count[i]-1)/2;
  
  for(int k=1; k<=N; k++){
    int64_t ans = sum;
    int x = count[A[k]];
    ans -= (int64_t)x*(x-1)/2;
    ans += (int64_t)(x-1)*(x-2)/2;
    cout << ans << endl;
  }
  
}

Measured memory_bytes: 4096
#include<stdio.h>

int p[100001];
long dis[100001]={};

int dfs(int x){
  if(p[x]==x)
    return x;
  return dfs(p[x]);
}

long kyori(int x,long k){
  if(p[x]==x)
    return k;
  return kyori(p[x],dis[x]+k);
}

int main(){
  int n,m,i,l,r,x,y;
  long d,d1,d2;
  scanf("%d %d",&n,&m);
  for(i-0;i<n+1;i++)
    p[i]=i;
  for(i=0;i<m;i++){
    scanf("%d %d %ld",&l,&r,&d);
    x=dfs(l);
    y=dfs(r);
    d1=kyori(l,0);
    d2=kyori(r,0);
    p[l]=x;
    p[r]=y;
    dis[l]=d1;
    dis[r]=d2;
    if(x!=y){
      p[x]=y;
      dis[x]=d+kyori(r,0)-kyori(l,0);
    }
    else{
      if(d-d1+d2!=0){
        printf("No\n");
        return 0;
      }
    }
  }
  printf("Yes\n");
}

Measured memory_bytes: 1280
import sys
import itertools
input = sys.stdin.readline
sys.setrecursionlimit(100000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


class V:
    def __init__(self, f, v=None):
        self.f = f
        self.v = v
 
    def __str__(self):
        return str(self.v)
 
    def ud(self, n):
        if self.v is None:
            self.v = n
        else:
            self.v = self.f(self.v, n) 


def main():
    S = input()
    print("Yes" if (S[2] == S[3] and S[4] == S[5]) else "No")


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
import sys
sys.setrecursionlimit(10**9)
f = lambda: map(int,input().split())

a,b,c,d,melt,mass = f()
wat = []
for i in range(mass//100//a+1):
    for j in range(mass//100//b+1):
        if i*a + j*b <= mass/100:
            wat.append((i*a + j*b)*100)
        else:
            break
sug = []
for i in range(mass//c+1):
    for j in range(mass//d+1):
        if i*c + j*d <= mass:
            sug.append(i*c + j*d)
        else:
            break
ans = [0,0]
cons = -float('inf')
for s in sug:
    for w in wat:
        if w > 0 and s/w > cons and s+w <= mass and s <= w*melt/100:
            cons = s/w
            ans = [s+w,s]
print(*ans)



Measured memory_bytes: 12476
#include<bits/stdc++.h>
using namespace std;
long long n,w;
long long weight[105];
long long value[105];
long long dp[105][100005];
long long f(long long curr,long long cap){
	long long&ret = dp[curr][cap];
	if(~ret) return ret;
	if(curr==n){
		if(cap>=weight[curr]) return ret = value[curr];
		else return ret = (long long)0;
	}
	ret = f(curr+1,cap);
	if(cap>=weight[curr]) ret = max(ret,f(curr+1,cap-weight[curr])+value[curr]);
	return ret;
}
int main(){
	memset(dp,-1,sizeof(dp));
	cin>>n>>w;
	for(int i=1; i<=n; i++) cin>>weight[i]>>value[i];
	cout<<f(1,w); 
}

Measured memory_bytes: 85644
import java.util.Scanner;

class Main{

    static Scanner scan;

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

         // get input
         final int slen = scan.nextInt();
         int[] s = new int[slen];
         for(int i = 0; i < slen; i++) {
             s[i] = scan.nextInt();
         }

         final int tlen = scan.nextInt();
         int[] t = new int[tlen];
         for(int i = 0; i < tlen; i++){
             t[i] = scan.nextInt();
         }

         // Linear scan
         int count = 0;
         for(int i = 0; i < tlen; i++) {
             for(int j = 0; j < slen; j++) {
                 if(t[i] == s[j]) {
                     count++;
                     break;
                 }
             }
         }

         System.out.println(count);
    }
}



Measured memory_bytes: 40212
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine();

            string[] inputs = input.Split(' ');

            int r = int.Parse(inputs[0]);
            int D = int.Parse(inputs[1]);
            int x2000 = int.Parse(inputs[2]);

            for (int i = 0; i < 10; i++)
            {
                int newWeight = x2000 * r - D;
                Console.WriteLine(newWeight);
                x2000 = newWeight;
                

            }

        }



    }
}


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

int gcd(int a,int b){
	if(a < b) swap(a,b);
	if(!b) return a;
	return gcd(b,a % b);
}

signed main(){
	int n,a[100010],l[100010],r[100010],ans = 0;
	cin >> n;
	for(int i = 0;i < n;i++) cin >> a[i];
	l[0] = a[0];
	for(int i = 1;i < n;i++) l[i] = gcd(a[i],l[i - 1]);
	r[n - 1] = a[n - 1];
	for(int i = n - 2;i >= 0;i--) r[i] = gcd(a[i],r[i + 1]);
	for(int i = 0;i < n;i++){
		if(!i) ans = max(ans,r[i + 1]);
		else if(i == n - 1) ans = max(ans,l[i - 1]);
		else ans = max(ans,gcd(l[i - 1],r[i + 1]));
	}
	cout << ans << endl;
}

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

int main(){
  int a, b;
  int c[3];
  
  cin >> a >> b;
  c[0] = a + b;
  c[1] = a - b;
  c[2] = a * b;
  
  cout << max({c[0], c[1], c[2]}) << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <vector>

static const int IINF = 1 << 30;
static const long long LINF = 1LL << 60;
static const long long MOD = 1.0e+9 + 7;

template <typename T> std::vector<T> vectors(std::size_t n, T val) {
  return std::vector<T>(n, val);
}

template <typename T, typename... Args>
auto vectors(std::size_t n, Args... args) {
  return std::vector<decltype(vectors<T>(args...))>(n, vectors<T>(args...));
}

template <class T> inline bool chmin(T &a, const T &b) {
  return (a > b) ? a = b, true : false;
}

template <class T> inline bool chmax(T &a, const T &b) {
  return (a < b) ? a = b, true : false;
}

template <class T> inline void chadd(T &a, const T &b) {
  a += b, a %= MOD;
  // TODO minus case
}

template <class T>
std::ostream &operator<<(std::ostream &s, const std::vector<T> &v) {
  if (v.empty())
    return s;
  s << *v.begin();
  for (auto iter = v.begin() + 1; iter != v.end(); ++iter)
    if (std::is_fundamental<T>::value)
      s << " " << *iter;
    else
      s << std::endl << *iter;
  return s;
}

int main() {
  // Input
  int r;
  std::cin >> r;

  std::cout << 3 * r * r << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define m_p make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
#define mod 1000000007
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
int l,r,d;
int main(){
	ios::sync_with_stdio(0);
	cin>>l>>r>>d;
	cout<<r/d-(l-1)/d;
	re 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

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

vector<pair<ll, int>> factorize(ll n){
    vector<pair<ll, int>> res;
    for (ll i = 2; i*i <= n; ++i){
        if (n%i) continue;
        res.emplace_back(i, 0);
        while (n%i == 0){
            n /= i;
            res.back().second++;
        }
    }
    if(n != 1) res.emplace_back(n, 1);
    return res;
}

int main(){
    ll n;
    cin >> n;
    vector<pair<ll, int>> f;
    f = factorize(n);

    vector<ll> div;
    rep(i, f.size()){
        div.push_back(f[i].first);
        int cnt = 2;
        while(cnt <= f[i].second){
            div.push_back(div.back() * f[i].first);
            cnt++;
        }
    }
    sort(all(div));

    ll ans = 0;
    ll i = 0;
    while(true){
        if (i == div.size() || n == 1) break;
        if (n % div[i] == 0){
            n /= div[i];
            ans++;
        }
        i++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628