akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

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

int H,W,N,Sr,Sc;
string S,T;

bool solve(){
	int left=0,right=W-1;
	if(S.at(N-1)=='L')	left++;
	else if(S.at(N-1)=='R')	right--;

	for(int i=N-2;i>=0;i--){
		if(T.at(i)=='L')	right=min(right+1,W-1);
		else if(T.at(i)=='R')	left=max(left-1,0);
		
		if(S.at(i)=='L')	left++;
		else if(S.at(i)=='R')	right--;

		if(left>right)	return false;
	}
	if(left>Sc || right<Sc)	return false;

	left=0,right=H-1;
	if(S.at(N-1)=='U')	left++;
	else if(S.at(N-1)=='D')	right--;

	for(int i=N-2;i>=0;i--){
		if(T.at(i)=='U')	right=min(right+1,H-1);
		else if(T.at(i)=='D')	left=max(left-1,0);

		if(S.at(i)=='U')	left++;
		else if(S.at(i)=='D')	right--;

		if(left>right)	return false;
	}
	if(left>Sr || right<Sr)	return false;
	
	return true;
}

int main(){
	cin >> H >> W >> N >> Sr >> Sc >> S >> T;
	Sr--;
	Sc--;

	if(solve())	cout << "YES" << endl;
	else	cout << "NO" << endl;

	return 0;
}


Measured memory_bytes: 776
from collections import deque

h, w = map(int, input().split())
ch, cw = map(int, input().split())
dh, dw = map(int, input().split())
s = [list(input()) for _ in range(h)]

d = deque()
d.append([ch-1, cw-1])
dist = [[float('inf')] * w for _ in range(h)]
dist[ch-1][cw-1] = 0
while d:
    x, y = d.popleft()
    for i in range(-2, 3):
        for j in range(-2, 3):
            if 0 <= x + i < h and 0 <= y + j < w and s[x+i][y+j] == '.':
                if i == 0 and j == 0:
                    continue
                elif (i == 1 and j == 0) or (i == 0 and j == 1) or (i == -1 and j == 0) or (i == 0 and j == -1):
                    if dist[x+i][y+j] > dist[x][y]:
                        dist[x+i][y+j] = dist[x][y]
                        d.appendleft([x+i, y+j])
                else:
                    if dist[x+i][y+j] > dist[x][y] + 1:
                        dist[x+i][y+j] = dist[x][y] + 1
                        d.append([x+i, y+j])

print(dist[dh-1][dw-1] if dist[dh-1][dw-1] != float('inf') else -1)

Measured memory_bytes: 148372
//QWsin
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rep(i,x,y) for(int i=x;i<=y;++i)
#define out(i,u) for(int i=first[u];i!=-1;i=next[i])
#define repvc(i,vc) for(int i=0,sz=vc.size();i<sz;++i)

using namespace std;

const int INF=1<<30;

typedef long long ll;

int n,k;

inline ll count(int x)
{
	int t=n%k;
	return n/k+(x<=t)-(x==0);
}

int main()
{
	cin>>n>>k;
	
	ll sum=0;
	
	sum+=count(0)*count(0)*count(0);
	if((k&1)==0){
		sum+=count(k/2)*count(k/2)*count(k/2);	
	}
	
	cout<<sum<<endl;
	return 0;
}


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

using namespace std;

typedef long long ll;

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;
}

int solve(const vector<pair<int, int>> sc, const int N, const int M) {
    vector<set<int>> ords(N);
    for (int i = 0; i < M; i++) {
        ords[sc[i].first].insert(sc[i].second);
    }

    // -1 if contradicted
    for (int i = 0; i < N; i++) {
        if ((int) ords[i].size() > 1) {
            return -1;
        }
    }

    // such as 0 x x
    if (((int) ords[0].size()) == 1 && *ords[0].begin() == 0) {
        if (N == 1) {
            return 0;
        } else {
            return -1;
        }
    }

    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (((int) ords[i].size()) == 1) {
            ans = ans * 10 + *ords[i].begin();
        } else {
            if (i == 0 && ords[i].size() == 0 && N != 1) {
                ans = 1;
            } else {
                ans = ans * 10;
            }
        }
    }
    return ans;
}

int main(void) {
    int N, M;
    cin >> N >> M;
    
    vector<pair<int, int>> sc(M);
    for (int i = 0; i < M; i++) {
        int s, c;
        cin >> s >> c;
        s--;
        sc[i] = {s, c};
    }

    cout << solve(sc, N, M) << endl;
    
    return 0;
}


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

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;

#define REP(i, n, m) for(ll i=n; i<(ll)m; ++i)
#define IREP(i, n, m) for(ll i=n-1; i>=m; --i)
#define rep(i, n) REP(i, 0, n)
#define irep(i, n) IREP(i, n, 0)
#define all(v) v.begin(), v.end()
#define vprint(v) for(auto e:v){cout<<e<<" ";};cout<<endl;
#define vvprint(vv) for(auto v:vv)vprint(v);

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20);

    ll X, Y;
    cin >> X >> Y;

    ll b2 = Y - 2*X;
    if(b2%2==0 && b2>=0){
        ll b = b2 / 2;
        ll a = X - b;
        if(a>=0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    else cout << "No" << endl;
}


Measured memory_bytes: 3604
#!/usr/bin/env python3
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right

def main():
    H, W = map(int, input().split())
    N = int(input())
    a = list(map(int, input().split()))
    ans = [[None]*W for _ in range(H)]
    now = 0
    for i in range(N):
        while a[i] > 0:
            # print(now//W, now%W)
            ans[now//W][now%W]=(i+1)
            now += 1
            a[i] -= 1
    for i in range(H):
        if i % 2 == 1:
            print(*ans[i][::-1])
        else:
            print(*ans[i])

if __name__ == "__main__":
    main()


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

int main(){
  char A[9][4]={"A","SAT","FRI","THU","WED","TUE","MON","SUN"};
  char S[4];
  scanf("%s",S);
  int ans=1;
  while(strcmp(S,A[ans])!=0) ans++;
  
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<ll> vvll;
#define sort(v) sort(v.begin(), v.end())
#define rev(r) reverse(r.begin(), r.end())
#define cout(cc) cout << cc << endl

int main() {
  double N,aaa;
  cin >> N;
  vector<double> VV(N);
  rep(i,N) cin >> VV.at(i);
  sort(VV);
  aaa=VV.at(0);
  rep(i,N-1){
  	aaa=(aaa+VV.at(i+1))/2;
  }
  cout << aaa << endl;
}


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

public class Main {
	public static void main(String[] args) throws IOException {
		ABC50C p = new ABC50C();
		p.solve();
	}
}

class ABC50C {
	public void solve() throws IOException {
		int mod = 1000000007;
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int N = Integer.parseInt(br.readLine());
		String[] input = br.readLine().split(" ");
		int[] given = new int[input.length];
		int[] sorted = new int[input.length];
		for (int i = 0; i < N; i++) {
			given[i] = Integer.parseInt(input[i]);
			sorted[i] = given[i];
		}
		Arrays.sort(sorted);
		int[] ok = new int[N];
		if (N % 2 == 0 && N >= 2)
			ok[0] = ok[1] = 1;
		else if (N % 2 != 0 && N >= 2)
			ok[1] = 2;
		else if (N == 1)
			ok[0] = 0;
		for (int i = 2; i < N; i++) {
			ok[i] = ok[i - 2] + 2;
		}

		for (int i = 0; i < N; i++) {
			if (sorted[i] != ok[i]) {
				System.out.println(0);
				return;
			}
		}

		int ans = 1;
		for (int i = 0; i < N / 2; i++) {
			ans *= 2;
			ans = ans % mod;
		}
		System.out.println(ans);
	}
}

class ABC50B {
	public void solve() throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int N = Integer.parseInt(br.readLine());
		String[] input = br.readLine().split(" ");
		int[] t = new int[N];
		long sum = 0;
		for (int i = 0; i < N; i++) {
			t[i] = Integer.parseInt(input[i]);
			sum += t[i];
		}
		int M = Integer.parseInt(br.readLine());
		long[] ans = new long[M];
		for (int i = 0; i < M; i++) {
			input = br.readLine().split(" ");
			int pi = Integer.parseInt(input[0]);
			int xi = Integer.parseInt(input[1]);
			ans[i] = sum - t[pi - 1] + xi;
		}

		for (int i = 0; i < M; i++) {
			System.out.println(ans[i]);
		}
	}
}

class ABC50A {
	public void solve() throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] input = br.readLine().split(" ");
		long a = Long.parseLong(input[0]);
		long b = Long.parseLong(input[2]);
		if (input[1].equals("+"))
			System.out.println((a + b));
		else
			System.out.println((a - b));
	}
}

Measured memory_bytes: 26432
#include <bits/stdc++.h>
#include <stdio.h>
# define M_PI  3.14159265358979323846
using namespace std;

typedef long long ll;
const int N = 1e5 + 9, M = 9e2 + 9, OO = 0x3f3f3f3f;
const double EPS = 0.00000000001;
const int mod = 1000000000+7;

int n, m, a[N];
ll mem[N];

bool broken(int stair){
	return binary_search(a, a+m, stair);
}

ll solve(int stair = 0){
	if(stair == n) return 1;
	ll& ret = mem[stair];
	if(~ret) return ret;
	return ret = ( (!broken(stair+1)? solve(stair+1):0) % mod + (stair+2 <= n && !broken(stair+2)?solve(stair+2):0) % mod) %mod;
}

int main(){
	//freopen ("i.in","r",stdin);
	//freopen ("no.out","w",stdout);

	memset(mem, -1, sizeof mem);
	scanf("%d%d", &n, &m);
	for(int i = 0 ; i < m ; ++i) scanf("%d", a+i), a[i];
	sort(a, a+m);
	printf("%lld\n", solve());

	return 0;
}


Measured memory_bytes: 4096
#!/usr/bin/env python3
import sys


def solve(S: str):
    print("ARC" if S == "ABC" else "ABC")
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9020
import copy
n = int(input())
p = list(map(int, input().split()))
p_sorted = sorted(copy.copy(p))
flag = False
for i in range(n):
    swap = p[i]
    for j in range(n):
        pre_p = copy.copy(p)
        p[i] = p[j]
        p[j] = swap
        if p == p_sorted:
            flag = True
        p = pre_p
if flag:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 3444
from functools import reduce
from collections import Counter

N, M = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

MOD = 10**9 + 7


class ModInt:
    def __init__(self, x):
        self.x = x % MOD

    def __str__(self):
        return str(self.x)

    __repr__ = __str__

    def __add__(self, other):
        return (
            ModInt(self.x + other.x) if isinstance(other, ModInt) else
            ModInt(self.x + other)
        )

    def __sub__(self, other):
        return (
            ModInt(self.x - other.x) if isinstance(other, ModInt) else
            ModInt(self.x - other)
        )

    def __mul__(self, other):
        return (
            ModInt(self.x * other.x) if isinstance(other, ModInt) else
            ModInt(self.x * other)
        )

    def __truediv__(self, other):
        return (
            ModInt(
                self.x * pow(other.x, MOD - 2, MOD)
            ) if isinstance(other, ModInt) else
            ModInt(self.x * pow(other, MOD - 2, MOD))
        )

    def __pow__(self, other):
        return (
            ModInt(
                pow(self.x, other.x, MOD)
            ) if isinstance(other, ModInt) else
            ModInt(pow(self.x, other, MOD))
        )

    def __radd__(self, other):
        return ModInt(other + self.x)

    def __rsub__(self, other):
        return ModInt(other - self.x)

    def __rmul__(self, other):
        return ModInt(other * self.x)

    def __rtruediv__(self, other):
        return ModInt(other * pow(self.x, MOD - 2, MOD))

    def __rpow__(self, other):
        return ModInt(pow(other, self.x, MOD))


# NMから順に配置可能なセルの個数を数え上げる
# ポイント: セルの縦横サイズと、これまでにいくつの数字を書き込んだかを覚えておくだけで数え上げ可能
a = Counter(A)
b = Counter(B)
ans, _, _ = reduce(
    lambda acc, k:
        (0, 0, 0) if a[k] >= 2 or b[k] >= 2 else
        (acc[0], acc[1] + 1, acc[2] + 1) if a[k] == b[k] == 1 else
        (acc[0] * acc[1], acc[1], acc[2] + 1) if a[k] == 1 and b[k] == 0 else
        (acc[0] * acc[2], acc[1] + 1, acc[2]) if a[k] == 0 and b[k] == 1 else
        (acc[0] * (acc[1] * acc[2] - (N * M - k)), acc[1], acc[2]),
    range(N * M, 0, -1),
    (ModInt(1), ModInt(0), ModInt(0))
)

print(ans)


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

using namespace std;

#define pb push_back
#define fs first
#define sc second
#define sz size
#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define forni(i, n) for (ll i = 1; i <= (ll) (n); ++i)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using ll = long long;
const ll inf = 1e9+7; 

const double PI =  3.141592653589793;

int main(){
	IO;
	ll n, k,d,a,ans=0;
	cin>>n>>k;
	map<ll,ll> m;
	while(k--){
		cin>>d;
		while(d--){
			cin>>a;
			if(m[a]==0){m[a]++; ans++;}
		}
	}
	cout<<n-ans<<"\n";
	return 0;
}

// _   .-')                .-. .-')                 .-')                                               
//( '.( OO )_              \  ( OO )               ( OO ).                                             
// ,--.   ,--.).-'),-----. ,--. ,--.  .-'),-----. (_)---\_) ,--. ,--.     .-----.  ,-.-')  .-'),-----. 
// |   `.'   |( OO'  .-.  '|  .'   / ( OO'  .-.  '/    _ |  |  | |  |    '  .--./  |  |OO)( OO'  .-.  '
// |         |/   |  | |  ||      /, /   |  | |  |\  :` `.  |  | | .-')  |  |('-.  |  |  \/   |  | |  |
// |  |'.'|  |\_) |  |\|  ||     ' _)\_) |  |\|  | '..`''.) |  |_|( OO )/_) |OO  ) |  |(_/\_) |  |\|  |
// |  |   |  |  \ |  | |  ||  .   \    \ |  | |  |.-._)   \ |  | | `-' /||  |`-'| ,|  |_.'  \ |  | |  |
// |  |   |  |   `'  '-'  '|  |\   \    `'  '-'  '\       /('  '-'(_.-'(_'  '--'\(_|  |      `'  '-'  '
// """    """     """""""" """  """"      """""""  """""""  """"""""      """"""   """         """""""


Measured memory_bytes: 3644
N = int(input())
blue_card = []
for i in range(N) :
    blue_card.append(input())
M = int(input())
red_card = []
for i in range(M) :
    red_card.append(input())

max_get = 0
for bc in blue_card :
    gain = blue_card.count(bc)
    loss = red_card.count(bc)
    score = gain - loss
    if (max_get < score) :
        max_get = score

print(max_get)

Measured memory_bytes: 3064
main(a,b,c,p,q,r,s,i,j){for(;scanf("%d%d%d",&a,&b,&c),a;){
if(!c)a==1&&b<0?printf("1 0 %d %d\n",a,b):printf("%d %d 1 0\n",a,b);
else{
	for(r=1;r*r<=a;r++)if(a%r==0)for(p=a/r,s=1;s*s<=abs(c);s++)if(c%s==0){
		for(j=0;j<4;j++,s=c/s)for(i=0;i<2;i++,s=-s)if(q=c/s,p*s+q*r==b){
			p==r&&q<s?printf("%d %d %d %d\n",r,s,p,q):printf("%d %d %d %d\n",p,q,r,s);
			goto next;
		}
	}
	puts("Impossible");
}next:;}exit(0);}

Measured memory_bytes: 612
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int n = 0;
	boolean[] check = new boolean[10000000];
	makePrime(check);
	
	while(sc.hasNext()){
	    n = sc.nextInt();
	    if(n==0) break;

	    System.out.println(checkPrime(check,n));
	}
    }

    static void makePrime(boolean[] check){
	
	for(int i = 1;i*i<check.length;i++){ // テ」ツ?敕」ツつ古」ツ?古ァツエツ?ヲツ閉ーテ」ツ??」ツ?」テ」ツ?淌」ツつ嘉」ツ?敕」ツ?ョテ・ツ?催ヲツ閉ーテ」ツつ稚rueテ」ツ?ォテ」ツ?凖」ツつ?
	    if(!check[i]) notPrime(check,i+1);
	}
    }

    static int checkPrime(boolean[] check,int n){ // テ・ツ崢崚」ツ?、テ・ツュツ静ァツエツ?ヲツ閉ーテ」ツつ津ィツソツ氾」ツ??
	for(int i = n-1;i>=0;i--){ // falseテ」ツつ津」ツ?ソテ」ツ?、テ」ツ?妥」ツ?淌」ツつ嘉」ツ?敕」ツ?ョテ、ツクツ凝」ツ?ィテ」ツ?凝」ツつづィツヲツ凝」ツ?ヲテ」ツ?｛kテ」ツ??」ツ?」テ」ツ?淌」ツつ嘉」ツ?敕」ツつ古」ツ?古ヲツ慊?・ツ、ツァテ」ツ?ョテヲツ閉ーテ」ツ??」ツ?療ィツソツ氾」ツ?療」ツ?。テ」ツつε」ツ??
	    if(!check[i] && !check[i-2] && !check[i-6] && !check[i-8]){
		return i+1;
	    }
	}
	return 0; // テ、ツサツョ
	
    }

    static void notPrime(boolean[] check,int n){ // テァツエツ?ヲツ閉ーテ」ツ??」ツ?」テ」ツ?淌ヲツ閉ーテ」ツ?ョテ・ツ?催ヲツ閉ーテ」ツつ稚rueテ」ツ?ォ
	for(int i = 2;i*n<check.length;i++){
	    check[(n*i)-1] = true;
	}
    }
}

Measured memory_bytes: 35044
#include<bits/stdc++.h>
#define M 1000000007
#define pi ld(acos(-1.0))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n) for(int i=1;i<(int)(n);i++)
#define repp(i,a,b)  for(int i=a;i<=(int)(b);i++)
#define Repp(i,a,b)  for(int i=a;i>=(int)(b);i--)
#define cs ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fi first
#define se second
#define ii pair<int,int>
#define bye(x) {cout<<x<<'\n';return 0;}
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    cs
    int d,ans=0;cin>>d;
    vector<int> c(26);
    for(auto &i:c) cin>>i;
    vector<int> cur(26);
    vector<vector<int>> v(d,vector<int>(26));
    rep(i,d) rep(j,26) cin>>v[i][j];
    repp(i,1,d) {
        int x;
        cin>>x;
        ans+=v[i-1][x-1];
        cur[x-1]=-1;
        rep(j,26) {
            cur[j]++;
            ans-=cur[j]*c[j];
        }
        cout<<ans<<'\n';
    }
}

Measured memory_bytes: 3712
package main

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

var sc = bufio.NewScanner(os.Stdin) //標準入力

func read() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)
	str := read()
	a := strings.Split(str, "/")

	// var aint [3]int

	// for i := 0; i < 3; i++ {
	// 	aint, _ := strconv.Atoi(a[i])
	// 	fmt.Println(aint)
	// }
	ayear, _ := strconv.Atoi(a[0])
	amonth, _ := strconv.Atoi(a[1])
	aday, _ := strconv.Atoi(a[2])

	if ayear < 2019 {
		fmt.Println("Heisei")
	} else if ayear == 2019 && amonth < 4 {
		fmt.Println("Heisei")
	} else if ayear == 2019 && amonth == 4 && aday < 31 {
		fmt.Println("Heisei")
	} else {
		fmt.Println("TBD")
	}

	// fmt.Println(ayear)
	// fmt.Println(amonth)
	// fmt.Println(aday)

	// fmt.Println(a)
	// fmt.Println(a[0])
	// fmt.Println(a[1])
	// fmt.Println(a[2])

}


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

int solve(int k,int a,int b,int c){
    if(k==0) return a+b+c;
    else{
        return max(max(solve(k-1,2*a,b,c),solve(k-1,a,2*b,c)),solve(k-1,a,b,2*c));
    }
}

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    int k;cin>>k;
    int ans=solve(k,a,b,c);
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<string.h>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	int max=a;
	if(b>max)max=b;
	if(c>max)max=c;
	cout<<a+b+c-max<<endl;
}


Measured memory_bytes: 256
import sys


def mulmod(x, y, p=10**9 + 7):
    return x * y % p


def combmod(n, k, p=10**9 + 7):
    from functools import reduce
    k = min(k, n - k)
    x = reduce(mulmod, range(n - k + 1, n + 1), 1)
    y = reduce(mulmod, range(1, k + 1), 1)
    return x * pow(y, p - 2, p) % p


def solve(string):
    x, y = map(int, string.split())
    m0, m1 = min(x, y), max(x, y)
    if (x + y) % 3 > 0 or m1 / m0 > 2:
        return "0"
    n = (x + y) // 3
    return str(combmod(n, m0 - n))


if __name__ == '__main__':
    print(solve(sys.stdin.read()))


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL<<58;

int main(){
    int a, b, q;
    cin >> a >> b >> q;
    
    vector<long long> s(a+2);
    vector<long long> t(b+2);
    
    /*
    それぞれ配列外アクセスになる可能性があるため
    番兵を用意しておく
    */
    s[0] = -INF;
    s[a+1] = INF;
    
    t[0] = -INF;
    t[b+1] = INF;
    
    for (int i = 1; i <= a; i++) cin >> s[i];
    for (int i = 1; i <= b; i++) cin >> t[i];

    for (int i = 0; i < q; i++){
        long long ans = INF;
        long long x;
        cin >> x;
        
        //　最寄り神社の右端のindexを求める
        int rightJinja = lower_bound(s.begin(),s.end(),x) - s.begin();
        
        // 最寄り神社の左端のindexを求める
        int leftJinja = rightJinja-1;
        
        // 最寄り寺の右端のindexを求める
        int rightTera = lower_bound(t.begin(),t.end(),x) - t.begin();
        
         // 最寄り寺の左端のindexを求める
        int leftTera = rightTera-1;
        
        
        // 最寄りの神社, 寺の訪れ方を全探索する 8通りある
        for (int j = leftJinja; j <= rightJinja; j++){
            for (int k = leftTera; k <= rightTera; k++){
                long long dist1 = abs(s[j] - x) + abs(s[j]-t[k]);
                long long dist2 = abs(t[k]-x) + abs(t[k]-s[j]);
                
                ans = min(ans,dist1);
                ans = min(ans, dist2);
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 2944
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "functional"
#include "ctime"

using namespace std;

//constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;



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

	string s;
	cin >> s;
	set<char>st;
	for (auto i : s)st.insert(i);
	cin >> K;
	if (st.size() == 1) {
		cout << (K*s.size()) / 2 << endl;
		return 0;
	}
	long long int a = 0;
	auto t = s;
	for (int i = 1; i < t.size(); i++) {
		if (t[i] == t[i - 1]) {
			a++;
			t[i] = '#';
		}
	}
	s += s;
	long long int b = 0;
	for (int i = 1; i < s.size(); i++) {
		if (s[i] == s[i - 1]) {
			b++;
			s[i] = '#';
		}
	}
	b -= a;
	//cout << a << " " << b << endl;
	cout << (K-1) * b + a << endl;
}


Measured memory_bytes: 256
from bisect import bisect_left
from collections import deque

n = int(input())
ans = []
ans.append(int(input()))
ans = deque(ans)
for i in range(n-1):  
  temp = int(input())
  #print("ans " +  str(ans) + " temp " + str(temp))
  if temp <= ans[0]:
    #d = deque(ans)
    #d.appendleft(temp)
    #ans = list(d)
    ans.appendleft(temp)
  else:
    ans[bisect_left(ans, temp)-1]=temp
#print(ans)
print(len(ans))
  
  
  

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

int main()
{string s;
int n,x=0,max=0;
cin>>n;
cin>>s;
for (int i=0;i<n;i++)
{
    if(s[i]=='I')
    {
        x++;
        if(max<x)
            max=x;
    }
    else
        if (s[i]=='D')
    {
        x--;
    }
}
cout<<max;
return 0;
 }


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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

// Constraints:
// - is_upper_fn(l) = false.
// - is_upper_fn(u) = true.
// - is_upper_fn() is monotically increasing.
tuple<int, int> BinarySearch(int l, int u, function<bool(int)> is_upper_fn) {
  while (u - l >= 2) {
    int m = (l + u) / 2;
    if (is_upper_fn(m)) {
      u = m;
    } else {
      l = m;
    }
  }
  return {l, u};
}

int64 SolveCase() {
  int n;
  int64 k;
  cin >> n >> k;

  int64 x_sum = 0;
  vector<int64> xs(n);
  for (int i = 0; i < n; i++) {
    cin >> xs[i];
    x_sum += xs[i];
  }

  if (x_sum <= n + k) {
    return 1;
  }

  auto is_upper_fn = [&](int64 a) -> bool {
    int64 c = 0;
    for (int i = 0; i < n; i++) {
      c += (xs[i] + a - 1) / a;
    }
    return c <= n + k;
  };
  const auto [l, u] = BinarySearch(1, 1E9, is_upper_fn);
  return u;
}

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

  cout << SolveCase() << endl;
}

Measured memory_bytes: 4724
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 25 18:20:35 2020
"""

import sys
import numpy as np

sys.setrecursionlimit(10 ** 9)
#def input():
#    return sys.stdin.readline()[:-1]
mod = 10**9+7

#N = int(input())
#N, K = map(int,input().split())
#A = np.array(list(map(int,input().split())))
N, K, *A = map(int, open(0).read().split())

dp = [True for i in range(K + A[-1] + 1)]
for i in range(K):
    if dp[i]:
        for a in A:
            dp[i + a] = False

#    print(i, dp[i],A+i,dp[A+i])
#print(dp)

if dp[K]:
    ans = 'Second'
else:
    ans = 'First'
print(ans)

Measured memory_bytes: 14256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const long long INF=1e18,MOD=1e9+7;
int main(){
	priority_queue<P>que;
	ll n,m,ans=0;
	cin>>n>>m;
	for(int i=0;i<n;i++){
		ll a;
		cin>>a;
		que.push(P(a,1));
	}
	for(int i=0;i<m;i++){
		ll b,c;
		cin>>b>>c;
		que.push(P(c,b));
	}
	while(true){
		if(n<=0)break;
		P top_num=que.top();que.pop();
		ans+=min(top_num.second,n)*top_num.first;
		n-=top_num.second;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 6516
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const double inf = 1e9;
const int mod = 1e5;
const int MAX = 5005;

int main() {
    ll a, b, k; cin >> a >> b >> k;
    if (a >= k) cout << a-k << " " << b << endl;
    else cout << 0 << " " << max((ll)0,b-(k-a)) << endl;
}

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

int main(){
  string s,t;
  cin>>s>>t;
  int sl=s.length();
  int tl=t.length();
  int dp[3010][3010];
  dp[0][0]=0;


  for(int i=0;i<sl;i++){
    for(int j=0;j<tl;j++){
      if(s[i]==t[j]){
        dp[i+1][j+1]=dp[i][j]+1;
      }else{
        dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j]);
      }
    }
  }
  //復元
  string ans="";
  int i=sl;
  int j=tl;
  while(i>0 && j>0){
    if(dp[i][j]==dp[i][j-1]){
      j--;
    }
    else if(dp[i][j]==dp[i-1][j]){
      i--;
    }
    else{
      ans=s[i-1]+ans;
      i--;
      j--;
    }
  }
  cout<<ans<<endl;
  return 0;
}

      

Measured memory_bytes: 38860
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define all(c) begin(c), end(c)
#define dump(x) cerr << __LINE__ << ":\t" #x " = " << x << endl

using ld = double;
using P = complex<ld>;
using G = vector<P>;
const ld pi = acos(-1);
const ld eps = 1e-10;
const ld inf = 1e12;

ld cross(const P& a, const P& b) { return a.real()*b.imag() - a.imag()*b.real(); }
ld dot(const P& a, const P& b) { return a.real()*b.real() + a.imag()*b.imag(); }

using C = pair<ld, P>;
#define rad first
#define pnt second

C smallest_enclosing_disc(vector<P> ps){
    auto c3 = [](const P &a, const P &b, const P &c){
        ld A = norm(b - c);
        ld B = norm(c - a);
        ld C = norm(a - b);
        ld S = abs(cross(b - a, c - a));
        P p = (A*(B+C-A)*a + B*(C+A-B)*b + C*(A+B-C)*c) / (4*S*S);
        ld r = abs(p - a);
        return make_pair(r, p);
    };

    auto c2 = [](const P &a, const P &b){
        P c = (a + b) / (ld)2;
        ld r = abs(a - c);
        return make_pair(r, c);
    };

    auto in_circle = [](const P &a, const C &c){
        return norm(a - c.pnt) <= c.rad*c.rad + eps;
    };

    int n = ps.size();
    random_shuffle(ps.begin(), ps.end());
    C c = c2(ps[0], ps[1]);
    for(int i = 2; i < n; ++i){
        if(!in_circle(ps[i], c)){
            c = c2(ps[0], ps[i]);
            for(int j = 1; j < i; ++j){
                if(!in_circle(ps[j], c)){
                    c = c2(ps[j], ps[i]);
                    for(int k = 0; k < j; ++k){
                        if(!in_circle(ps[k], c)){
                            c = c3(ps[i], ps[j], ps[k]);
                        }
                    }
                }
            }
        }
    }
    return c;
}

// http://www.spoj.com/problems/QCJ4/
// http://www.spoj.com/status/ns=18116289

 int main(){
     srand(time(0));
     int n;
     cin >> n;
     vector<P> ps(n);
     for(int i = 0; i < n; ++i){
         ld x,y;
         cin >> x >> y;
         ps[i] = P(x,y);
     }

     printf("%.10lf\n", (double)smallest_enclosing_disc(ps).rad);
 }

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

#define FOR(n) for(int i=0;i<n;i++)
#define PRN(n) printf("%d\n",n)
#define PRS(s) printf("%s\n",s)

int f(int a){
  if(a<0)return 0;
  return a;
}
int main(void){
  int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
  PRN(f(b+c-a));
  return 0;
}

Measured memory_bytes: 128
from fractions import*
from numpy import*

def dv(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

n,*a=map(int,open(0).read().split())
a=array(a)
l=[1]
for i in set(dv(a[0])+dv(a[1])):
    if sum(a%i==0)>=n-1:
        l.append(i)
print(max(l))

Measured memory_bytes: 24080
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class ABC
	{
		static readonly int mod = 1000000007;  // 10^9+7

		static void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });


			int n = int.Parse(Console.ReadLine());
			//string s = Console.ReadLine();
			//int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			long[] a = Console.ReadLine().Split().Select(long.Parse).ToArray();

			long[] b = new long[61];
			for (int i = 0; i < n; i++) {
				long x = a[i];
				int j = 0;
				while (x > 0) {
					if (x % 2 == 1) {
						b[j]++;
					}
					x /= 2;
					j++;
				}
			}
			//System.Diagnostics.Debug.WriteLine(string.Join(" ", b));
			long ans = 0;
			for (int i = 0; i < b.Length; i++) {
				ans += b[i] * (n - b[i]) % mod * ((1L << i) % mod);
				ans %= mod;
				//System.Diagnostics.Debug.WriteLine($"{b[i]} * {n - b[i]} * {1L << i:x} % mod");
			}
			Console.WriteLine(ans);


			Console.Out.Flush();
		}
	}
}


Measured memory_bytes: 58308
#include <fstream>
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <cstdlib>

using namespace std;

int a[100];

signed main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    int num1 = 0, num2 = 0;
    for (int i = 0; i < n; i++){
        cin >> a[i];
    }
    int mx = 1;
    for (int i = 0; i < n; i++)
        mx *= 3;
    int ans = 0;
    for (int i = 0; i < mx; i++){
        vector<int> d;
        int m = i;
        for (int i = 0; i < n; i++){
            d.push_back(m % 3 - 1);
            m /= 3;
        }
        bool good = false;
        for (int i = 0; i < n; i++)
            if ((a[i] + d[i]) % 2 == 0)
                good = true;
        ans += good;
    }
    cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll INF=1e15;
#define N 201000

int n,m,A,B;
int a[N];
ll mn1[N<<2],mn2[N<<2],tag[N<<2];

void pushdown(int o)
{
	if (!tag[o]) return;
	int ls=o<<1,rs=o<<1|1;
	mn1[ls]+=tag[o]; mn1[rs]+=tag[o];
	mn2[ls]+=tag[o]; mn2[rs]+=tag[o];
	tag[ls]+=tag[o]; tag[rs]+=tag[o];
	tag[o]=0;
}

void update(int o)
{
	int ls=o<<1,rs=o<<1|1;
	mn1[o]=min(mn1[ls],mn1[rs]);
	mn2[o]=min(mn2[ls],mn2[rs]);
}

ll query1(int o,int L,int R,int l,int r)
{
	if (l<=L && r>=R) return mn1[o];
	pushdown(o);
	int mid=(L+R)>>1;
	ll ret=INF;
	if (l<=mid) ret=min(ret,query1(o<<1,L,mid,l,r));
	if (r>mid) ret=min(ret,query1(o<<1|1,mid+1,R,l,r));
	return ret;
}

ll query2(int o,int L,int R,int l,int r)
{
	if (l<=L && r>=R) return mn2[o];
	pushdown(o);
	int mid=(L+R)>>1;
	ll ret=INF;
	if (l<=mid) ret=min(ret,query2(o<<1,L,mid,l,r));
	if (r>mid) ret=min(ret,query2(o<<1|1,mid+1,R,l,r));
	return ret;
}

void add(int o,int L,int R,int l,int r,ll num)
{
	if (l<=L && r>=R)
	{
		mn1[o]+=num; mn2[o]+=num;
		tag[o]+=num;
		return;
	}
	pushdown(o);
	int mid=(L+R)>>1;
	if (l<=mid) add(o<<1,L,mid,l,r,num);
	if (r>mid) add(o<<1|1,mid+1,R,l,r,num);
	update(o);
}

void change(int o,int L,int R,int x,ll num)
{
	if (L==R)
	{
		mn1[o]=min(mn1[o],num-x);
		mn2[o]=min(mn2[o],num+x);
		return;
	}
	pushdown(o);
	int mid=(L+R)>>1;
	if (x<=mid) change(o<<1,L,mid,x,num);
	else change(o<<1|1,mid+1,R,x,num);
	update(o);
}

ll queryans(int o,int L,int R)
{
	if (L==R) return mn1[o]+L;
	pushdown(o);
	int mid=(L+R)>>1;
	return min(queryans(o<<1,L,mid),queryans(o<<1|1,mid+1,R));
}

int main()
{
	scanf("%d%d%d%d",&n,&m,&a[1],&a[2]);
	for (int i=1;i<=m;i++) scanf("%d",&a[i+2]);
	memset(mn1,0x3f,sizeof(mn1));
	memset(mn2,0x3f,sizeof(mn2));
	change(1,1,n,a[1],0);
	
	ll v1,v2,f;
	for (int i=3;i<=m+2;i++)
	{
		v1=query1(1,1,n,1,a[i])+a[i];
		v2=query2(1,1,n,a[i]+1,n)-a[i];
		f=min(v1,v2);
		add(1,1,n,1,n,abs(a[i]-a[i-1]));
		change(1,1,n,a[i-1],f);
	}
	printf("%lld\n",queryans(1,1,n));
	return 0;
}

Measured memory_bytes: 19840
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        int S = new Scanner(System.in).nextInt();
        int h=S/3600;
        int m=(S-h*3600)/60;
        int s=S-h*3600-m*60;
        System.out.printf("%d:%d:%d\n",h,m,s);
    }
}


Measured memory_bytes: 26472
#-*-coding:utf-8-*-

def f(a, x):
    if a == -1:
        return 0
    else:
        return (a // x) + 1

def main():
    a, b, x = map(int, input().split())

    print(f(b, x) - f(a-1, x))

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    long a = scan.nextLong();
    long b = scan.nextLong();
    long n = scan.nextLong();

    long g = Math.min(b-1,n);

    double t1 = (double) (a/b);
    t1 *= g;

    double t = g*a;
    t /= b;
    

    System.out.println((long) t);

  }
}


Measured memory_bytes: 35664
x,y = map(int,input().split())

list1 = [1,3,5,7,8,10,12]
list2 = [4,6,9,11]

if x in list1:
    if y in list1:
        print('Yes')
    else:
        print('No')
elif x in list2:
    if y in list2:
        print('Yes')
    else:
        print('No')
else:
    print('No')


Measured memory_bytes: 3060
//  RAKSHIT KADAM
 #include <bits/stdc++.h>
 
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree< int ,  null_type ,  less<int> ,  rb_tree_tag ,  tree_order_statistics_node_update>
 #warning !!!check the size of arrayss!!!
 #define ll long long
 #define int long long
 #define MOD  1000000007
 #define newMOD  998244353
 #define MAX 300006
 #define P(gg) for(auto rax:gg){cout<<rax<<" ";}cout<<endl;
 #define Need_for_speed(activated) ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
 #define satisfy ll t; cin>> t; while(t--)
 #define inp(n) int n;cin >> n
 #define mp make_pair
 #define pb push_back
 #define endl "\n"
 #define x first
 #define y second
 #define fore(i,a,b) for(ll i=a;i<b;i++)
 #define forci(i,n) for(ll i=0;i<n;i++)
 #define INF 2000000000000000005

 #define vi vector<ll>
#define pi 3.1415926535897932384626433832795
#define Endl endl
#define lb lower_bound
#define ub upper_bound

using namespace std;
//ll gcd(ll a, ll b){if (b == 0)return a;return gcd(b, a % b);}
//int power(int x, unsigned int y, unsigned int m){ if (y == 0) return 1;int p = power(x, y/2, m) % m;  p = (p * p) % m;                                                  return (y%2 == 0)? p : (x * p) % m;}
 //ddfdsfdfs

//ll modInverse(int a, int m){ return power(a, m-2, m);} // if a and m are relativelyprime

void solve()
{
    string s;cin>>s;
    ll a=0,b=0;
    for(ll i=0;i<3;i++)
    {
        if(s[i]=='A')a++;
        else b++;
    }
    if( a>0 &&b>0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}
signed main()
{
 
   
    Need_for_speed(activated);
//satisfy
//    {
//   solve();
//    }


 solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
    int n;cin>>n;
    vector<ll> a(n+100);
    rep(i,n) cin>>a[i];
    vector<ll> b(n+100);
    rep(i,n+2){
        if(i==0){
            b[i]=abs(a[i]);
        }else if(i==n+1){
            b[i]=abs(a[n]);
        }else{
            b[i]=abs(a[i]-a[i-1]);
        }
    }
    rep(i,n)b[i+1]+=b[i];
    rep(i,n){
        ll res=b[n];
        if(i==0){
            res-=(abs(a[0])+abs(a[i]-a[i+1]));
            res+=abs(a[i+1]);
            cout<<res<<endl;
        }else if(i==n-1){
            res-=(abs(a[n-1])+abs(a[n-1]-a[n-2]));
            res+=abs(a[n-2]);
            cout<<res<<endl;
        }else{
            res-=(abs(a[i]-a[i+1])+abs(a[i]-a[i-1]));
            res+=abs(a[i+1]-a[i-1]);
            cout<<res<<endl;
        }
    }
}

Measured memory_bytes: 2816
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
#include<climits>
#include <string>
#include <map>
#include <set>
#include <list>

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)

using namespace std;

/////////////////////////////////////////////////////
#define pll pair<ll,ll>

ll N;
string str;
ll i;
int main(){
    scanf("%lld",&N);
    str = "Christmas";
    fornum(i,N,25){
        str += " Eve";
    }
    cout << str;
    return 0;
}

Measured memory_bytes: 256
/*
    @uthor: Amit Kumar
    user -->GitHub: drviruses ; CodeChef: dr_virus_ ; Codeforces,AtCoder,Hackerearth,Hakerrank: dr_virus;
*/
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
using namespace std::chrono;
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;
//#define ln mp::cpp_int;
#define ll    long long
#define ld    long double
#define ull   unsigned long long
#define endl "\n"
ll google_itr = 1;
#define google(x) cout<<"Case #"<<x<<":"
#define pi 3.14159265358979323846264338327950L

const ll mod = 1e9+7;
const ll inf = 1e18;

ll popcount(ll num){
    num = num - ((num >> 1) & 0x55555555);
    num = (num & 0x33333333) + ((num >> 2) & 0x33333333);
    return ((num + (num >> 4) & 0xF0F0F0F) * 0x1010101) >> 24;
}

vector<pair<ll,ll>> factor_arr;

void myfactor(ll num){ 
    ll count = 0;   
    while (!(num % 2)) { 
        num >>= 1; count++; 
    }  
    if (count) factor_arr.push_back({2,count}); 
    for (auto i = 3; i <= sqrt(num); i += 2) { 
        count = 0; 
        while (num % i == 0) { 
            count++; 
            num /= i; 
        } 
        if (count) factor_arr.push_back({i,count}); 
    } 
    if (num > 2) factor_arr.push_back({num,1});
}

void virus(){
    ll a,b;
    cin>>a>>b;
    cout<<(long long)(a*b)/__gcd(a,b);
}


int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
  /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/

    ll t=1;
    //cin>>t;
    while(t--){
           auto start = high_resolution_clock::now();
           virus();
           auto stop = high_resolution_clock::now();
           auto duration = duration_cast<seconds>(stop - start);
         //cout << "Time: "<<duration.count()<<endl;
        //your code goes here
    }
    return 0;
}

Measured memory_bytes: 3644
x1, y1, x2, y2 =map(int, input().split())

d = [x2-x1, y2- y1]
ans1 = [x2 - d[1], y2 +d[0]]
ans2 = [ans1[0] - d[0], ans1[1] - d[1]]
print(str(ans1[0]) + " " + str(ans1[1]) + " " + str(ans2[0]) + " " + str(ans2[1]))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pb emplace_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define F first
#define S second
#define vll vector<ll>
#define fast ios:: sync_with_stdio(false),cin.tie(0);
#define COUT cout<<fixed<<setprecision(12)
#define CIN getline(cin,s)
#define SET set<ll,greater<ll>>gquiz
#define ITERATOR set<ll,greater<ll>> :: iterator itr
#define V vector<ll>vector
#define sz size()
#define A vector<pair<ll,ll>>vect
ll N=100000,M=100000;
#define B vect.push_back(make_pair(N,M));
ll MOD=1000000007;
unordered_map<ll,bool>check;

void solve()
{
	ll n;
	cin>>n;
	string s;
	cin>>s;
	ll l=0,r=s.size()-1;
	ll cnt=0;
	while(1)
	{
		while(l<r && s[l]=='R')
		l++;
		while(l<r && s[r]=='W')
		r--;
		if(l==r)
		break;
		swap(s[l],s[r]);
		cnt++;
	}
	cout<<cnt;
}

int main()
{
	ll t=1;
	//cin>>t;
	while(t--)
	solve();
}

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

int n, k;
int w[100100];


//calc??????????????????????????????????????????????????????p????¶???????????????????
//????????????????????¨?????§???????????????????????????????????¢??°
bool calc(int p){
	int cnt = 1, now = 0;
	for(int i = 0; i < n; i++){
		if(now + w[i] <= p){
			now += w[i];
		}else if(w[i] <= p){
			now = w[i];
			cnt++;
		}else{
			return false;
		}
	}
	return cnt <= k;
}

int main(){
    cin >> n >> k;
	for(int i = 0; i < n; i++){
		cin >> w[i];
	}
	int l = 0, r = 1e9 + 1, m;
	while(r - l >= 1){
		m = (l + r) / 2;
		if(calc(m)) r = m;
		else l = m + 1;
	}
	cout << r << endl;
}

Measured memory_bytes: 3468
#!/usr/bin/env python

n, m = map(int, input().split())
a = [['' for _ in range(n)] for _ in range(n)]
b = [['' for _ in range(m)] for _ in range(m)]
for i in range(n):
    a[i] = input()
for i in range(m):
    b[i] = input()

for i in range(n-m+1):
    ok = True
    for j in range(n-m+1):
        ok = True
        for p in range(m):
            for q in range(m):
                if b[p][q] != a[i+p][j+q]:
                    ok = False
                    break
        if ok: 
            print('Yes')
            exit()

print('No')


Measured memory_bytes: 9152
#include<stdio.h>
void change(int *,int );
void insertsort(int *,int );
int main(){
  int N,i,j;
  int A[100];
  scanf("%d",&N);
  for( i = 0;i < N; i++){
    scanf("%d", &A[i]);
  }
  change(A, N);
  insertsort(A, N);
  return 0;
}

void change(int A[],int N){
  int i;
  for( i = 0; i < N; i++){
    if( i > 0)printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}
void insertsort(int A[],int N){
  int i,j,k;
  for( i = 1; i < N; i++){
    k = A[i];
    j = i - 1;
    while( j >= 0 && A[j] > k){
      A[j + 1] = A[j];
      j--;
    }
    A[ j + 1] = k;
    change(A, N);
  }
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define fi first
#define f first
#define se second
#define s second
#define vi_a vector<int>a;
#define p_b push_back
#define ll long long
#define ull unsigned long long
#define ld long double
#define pll pair<long long,long long>
#define pii pair<int,int>
#define m_p make_pair
#define fast_io cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
#define all(x) x.begin(),x.end()
#define sqr(x) (x)*(x)
#define pw(x) (1ll << x)
#define sz(x) (int)x.size()
#define endl "\n"
#define len(a) a.length()
using namespace std;
ll MOD=1e9+7;
ll bin_pow (ll a, ll n) {
	ll res = 1;
	while (n) {
		if (n & 1)
			res *= a;
        res%=MOD;
        a%=MOD;
		a *= a;
		a%=MOD;
		n >>= 1;
	}
	return res;
}
signed main(){
    fast_io;
    ll n,a,b;
    cin>>n>>a>>b;
    vector<ll>fact(200001);
    ll x=1;
    fact[0]=1;
    for(ll i=1;i<200001;i++){
        x*=i;
        x%=MOD;
        fact[i]=x;
    }
    ll f=1;
    for(ll i=n-a+1;i<=n;i++){
        f*=i;
        f%=MOD;
    }
    ll s=1;
    for(ll i=n-b+1;i<=n;i++){
        s*=i;
        s%=MOD;
    }
    ll ans=(bin_pow(2,n)-1+MOD)%MOD;
    ans-=(f*bin_pow(fact[a],MOD-2))%MOD;
    ans=(ans+MOD)%MOD;
    ans-=(s*bin_pow(fact[b],MOD-2))%MOD;
    ans=(ans+MOD)%MOD;
    cout<<ans;
}



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

int main() {
  int w, h, n;
  cin>>w>>h>>n;
  int a[3][n];
  for(int i=0;i<n;i++){
    cin>>a[0][i]>>a[1][i]>>a[2][i];
  }
  int max_x=w;
  int max_y=h;
  int min_x=0;
  int min_y=0;
  for(int i=0;i<n;i++){
    if(a[2][i]==1){
      if(min_x<a[0][i]){
        min_x=a[0][i];
      }
    }
    if(a[2][i]==2){
      if(max_x>a[0][i]){
        max_x=a[0][i];
      }
    }
    if(a[2][i]==3){
      if(min_y<a[1][i]){
        min_y=a[1][i];
      }
    }
    if(a[2][i]==4){
      if(max_y>a[1][i]){
        max_y=a[1][i];
      }
    }
  }
  if(max_x<=min_x || max_y<=min_y){
    cout<<0<<endl;
  }
  else {
    cout<<(max_x-min_x)*(max_y-min_y);
  }
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main() {
  int r = 0, c, p = 0;
  while((c = getchar_unlocked()) != '\n') {
    if(p == 1) {
      r += 1;
      p = 0;
    }
    else if (c == p) {
      p = 1;
    }
    else {
      r += 1;
      p = c;
    }
  }
  printf("%d\n", r);
}


Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define re register
#define ll long long
inline int gi(){
	int f=1,sum=0;char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return f*sum;
}
const int N=2010;
int a[N],link[N][N],vis[N],d[N],n;
vector<int>G[N];
void dfs(int u){
	vis[u]=1;
	for(int i=1;i<=n;i++)
		if(link[u][i] && !vis[i]){
			d[i]++;
			G[u].push_back(i);
			dfs(i);
		}
}
priority_queue<int>Q;
int main(){
	n=gi();for(int i=1;i<=n;i++)a[i]=gi();
	sort(a+1,a+n+1);
	for(int i=1;i<n;i++)
		for(int j=i+1;j<=n;j++)
			if(__gcd(a[i],a[j])!=1)link[i][j]=link[j][i]=1;
	for(int i=1;i<=n;i++)if(!vis[i])dfs(i);
	for(int i=1;i<=n;i++)if(!d[i])Q.push(i);
	while(!Q.empty()){
		int u=Q.top();Q.pop();
		printf("%d ",a[u]);
		for(auto v:G[u])Q.push(v);
	}
	puts("");
	return 0;
}


Measured memory_bytes: 16256
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let (n,m) = get!(usize, usize);
    let ps = get!(usize, String; m);

    let mut map = BTreeMap::new();
    for (p, s) in ps {
        map.entry(p).or_insert(Vec::new()).push(s == "AC".to_string());
    }

    let mut wa = 0usize;
    let mut ac = 0usize;
    for (key, val) in map {
        let mut wa_tmp = 0;
        let mut ac_flag = false;
        for e in val {
            if e {
                ac += 1;
                ac_flag = true;
                break;
            } else {
                wa_tmp += 1;
            }
        }
        if ac_flag {
            wa += wa_tmp;
        }
    }
    println!("{} {}", ac, wa);
}


Measured memory_bytes: 18684