akhauriyash/Code-Regression huggingface dataset:
#pragma region header
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cctype>
#include <assert.h>
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#include <cstring>
#include <array>
// ===============================================================
//using系
#pragma region header
using namespace std;
using lint = long long;
using ld = long double;
using ulint = unsigned long long;
const int dx[] = { 1,0,-1,0 };
const int dy[] = { 0,1,0,-1 };
constexpr lint mod = 1000000007;
constexpr long double pi = 3.141592653589793238462643383279;
#pragma endregion
// ========================================================================
//define
#define INF (lint)10000000000000000;
#define mod (int)1000000007
#pragma region header
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
#pragma endregion
#pragma endregion
lint gcd(lint a, lint b) {
	if (a % b == 0)
		return b;
	else
		return gcd(b, a % b);
}

int n;
vector<int> d;
bool input() {
	cin >> n;
	d.resize(n);
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		cin >> d[i];
		if (i == 0) cnt = d[0];
		else cnt = gcd(cnt, d[i]);
	}
	if (cnt != 1) return false;
	return true;
}


int main(void) {
	ios::sync_with_stdio(false);
	cin.tie(0);
	if (!input()) { cout << "not coprime" << endl; return 0; }
	vector<bool> pn(1000010, true);
	for (int i = 2; i <= 1000005; i++) {
		if (pn[i]) {
			for (int j = 2 * i; j < 1000001; j += i) {
				pn[j] = false;
			}
		}
	}
	vector<int> p;
	for (int i = 2; i <= 1000005; i++) if (pn[i]) p.push_back(i);
	bool h = true;
	set<int> s;
	for (int i = 0; i < d.size(); i++) {
		while (1) {
			for (int j = 0; j < p.size(); j++) {
				if (p[j] * p[j] > d[i]) break;
				if (d[i] % p[j] == 0) {
					while (d[i] % p[j] == 0) {
						d[i] /= p[j];
					}
					if (s.count(p[j])) {
						h = false;
						goto Cyan;
					}
					else s.insert(p[j]);
				}
			}
			if (d[i] != 1) {
				if (s.count(d[i])) {
					h = false;
					goto Cyan;
				}
				else s.insert(d[i]);
			}
			break;
		}
	}
Cyan:;
	if (h) cout << "pairwise coprime" << endl;
	else cout << "setwise coprime" << endl;

	return 0;
}

Measured memory_bytes: 7920
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {//233
	string m;
	cin>>m;
	int f = stoi(m.substr(0,2));
	int s = stoi(m.substr(2,2));
	bool fb = (f>0&&f<13), sb = (s>0&&s<13);
	if(fb&&!sb)cout<<"MMYY";
	else if(!fb&&sb)cout<<"YYMM";
	else if(fb&&sb)cout<<"AMBIGUOUS";
	else cout<<"NA";
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3636
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<ctime>
using namespace std;
int main()
{     long long a,b;
      cin>>a>>b;
      if(a%3==0||b%3==0||(a+b)%3==0)cout<<"Possible"<<endl;
        else cout<<"Impossible"<<endl;
	  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#define ll long long
#define pb push_back
#define F first
#define S second
#define ld long double
#define rep(i,n) for (int i =0;i < (n); ++i)
#define vi vector<ll>
const int N = 1e9 + 5;
int debug = 1;

int n, m, q;
vector<int> a, b, c, d;
int ans;

void dfs(vector<int> A) {

	if (A.size() == n + 1) {
		int now = 0;
		rep(i, q) {
			if (A[b[i]] - A[a[i]] == c[i]) now += d[i];
		}
		ans = max(ans, now);
		return;
	}

	A.push_back(A.back());
	while (A.back() <= m) {
		dfs(A);
		A.back()++;
	}

}
void solve() {

	cin >> n >> m >> q;
	a = b = c = d = vector<int>(q);
	rep(i, q) {
		cin >> a[i] >> b[i] >> c[i] >> d[i];
	}
	dfs(vector<int>(1, 1));
	cout << ans << endl;

}
int main() {

	FASTIO;

#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif

	int t = 1;
	//cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 3620
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    private static Scanner sc;
    public static void main(String[] args) {
        Main instance = new Main();
        sc = instance.new Scanner();
        instance.solve();
    }

    private void solve() {
        try {
            int N = sc.nextInt();
            String S = sc.next();
            int K = sc.nextInt();
            char C = S.charAt(K-1);
            StringBuilder sb = new StringBuilder();
            sb.append(S);
            for (int i = 0; i < N; i++) {
                if (S.charAt(i) != C) {
                    sb.setCharAt(i, '*');
                }
            }
            System.out.println(sb.toString());

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private class Scanner {
        String[] s;
        int i;
        BufferedReader br;
        String regex = " ";

        public Scanner() {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        @Override
        protected void finalize() throws Throwable {
            try {
                super.finalize();
            } finally {
                destruction();
            }
        }

        private void destruction() throws IOException {
            if (br != null) br.close();
        }

        public String next() throws IOException {
            if (i < s.length) return s[i++];
            String st = br.readLine();
            while (st == "") st = br.readLine();
            s = st.split(regex, 0);
            i = 0;
            return s[i++];
        }

        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }

        public Long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }

        public Double nextDouble() throws NumberFormatException, IOException {
            return Double.parseDouble(next());
        }
    }
}

Measured memory_bytes: 21332
#include <bits/stdc++.h>
using namespace std;
#define in ({int x=0;int c=getchar(),n=0;for(;!isdigit(c);c=getchar()) n=(c=='-');for(;isdigit(c);c=getchar()) x=x*10+c-'0';n?-x:x;})
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int l,int r){return l+rng()%(r-l+1);}
#define fasty ios_base::sync_with_stdio(false),cin.tie(nullptr);
#define task "TASK"
#define forinc(a,b,c) for(int a=b,_c=c;a<=_c;++a)
#define fordec(a,b,c) for(int a=b,_c=c;a>=_c;--a)
#define forv(a,b) for(auto&a:b)
#define fi first
#define se second
#define pb push_back
#define ii pair<int,int>
#define mt make_tuple
#define all(a) a.begin(),a.end()
#define reset(f, x) memset(f, x, sizeof(f))
#define bit(x,i) ((x>>(i-1))&1)
#define on(x,i) (x|(1ll<<(i-1)))
#define off(x,i) (x&~(1<<(i-1)))

const int N=100010;

int vis[N];
vector<int> ad[N],isa[2];

int dfs(int u,int o){
    isa[o].pb(u);
    vis[u]=1;
    forv(v,ad[u]) if(!vis[v]){
        dfs(v,o);
        return 0;
    }
}

main(){
    //freopen(task".inp","r",stdin);
    //freopen(task".out","w",stdout);
    int n=in,m=in,x,y;
    forinc(i,1,m){
        x=in,y=in;
        ad[x].pb(y);
        ad[y].pb(x);
    }
    vis[y]=1;
    dfs(x,0);
    dfs(y,1);
    reverse(all(isa[0]));
    cout<<isa[0].size()+isa[1].size()<<"\n";
    forinc(i,0,1) forv(j,isa[i]) cout<<j<<" ";
}


Measured memory_bytes: 9720
class Main {
  public static void main(String[] args) {
    for(int i = 1; i <= 9; ++i) {
    	for(int j = 1; j <= 9; ++j) {
    		System.out.println(i + "x" + j + "=" + (i*j));
    	}
    }
  }
}

Measured memory_bytes: 24028
import math

while 1:
    a, b, c, d = map(float, input().split())
    if a == -1:
        break

    a = (a / 360) * 2 * math.pi
    b = (b / 360) * 2 * math.pi
    c = (c / 360) * 2 * math.pi
    d = (d / 360) * 2 * math.pi

    x1 = math.cos(b) * math.cos(a)
    y1 = math.sin(b) * math.cos(a)
    z1 = math.sin(a)
    x2 = math.cos(d) * math.cos(c)
    y2 = math.sin(d) * math.cos(c)
    z2 = math.sin(c)

    angle = math.acos(x1*x2 + y1*y2 + z1*z2)
    print(round(6378.1 * angle))



Measured memory_bytes: 5732
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a,b) ((a<b)?a:b)
#define _max(a,b) ((a<b)?b:a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a)?1:-1)
#define SORT(v) sort(v.begin(),v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380


int main()
{
	cout << fixed << setprecision(10);

	int n, m, x;
	cin >> n >> m >> x;

	vector<int> c(n);
	vector<vector<int>> a(n);

	REP(i, n)
	{
		cin >> c[i];
		a[i].resize(m);
		REP(j, m)
		{
			cin >> a[i][j];
		}
	}


	int ans = INF;
	for (int i = 0; i < (1 << n); i++)
	{
		int sum = 0;

		vector<int> r(m);
		for (int j = 0; j < n; j++)
		{
			if (i & (1 << j))
			{
				REP(k, m)
				{
					r[k] += a[j][k];
				}
				sum += c[j];
			}
		}

		bool ok = true;
		REP(j, m)
		{
			if (r[j] < x)
			{
				ok = false;
				break;
			}
		}
		if (ok)
		{
			chmin(ans, sum);
		}
	}
	if (ans == INF)ans = -1;
	cout << ans;
	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>
#include <complex>

using namespace std;

/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
*/

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
ld PI = acos(-1.0);

void solve() {
    ll n;
    cin >> n;
    vll a(n);
    rep(i, n) cin >> a[i];
    ll cur = 1000;
    for(ll i = 1; i < n; i++) {
        if(a[i] > a[i - 1]) {
            ll stock = cur / a[i - 1];
            cur += stock * (a[i] - a[i - 1]);
        }
    }
    cout << cur << endl;
    return;
}

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

Measured memory_bytes: 3656
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.nextLine());
        boolean ans = false;
        for(int i = 1; i <= 9; i++){
            for(int j = 1; j <= 9; j++){
                if(i * j == n)  ans = true;
            }
        }
        if(ans) System.out.println("Yes");
        else    System.out.println("No");
    }
}

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

#define INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define Rep0(i, n)  for (int i=0; i<n; i++)
#define Rep1(i, n)  for (int i=1; i<=n; i++)

struct  Item {
    int v=0;
    ll  w=0;
};

int main() {
    // Input
    int N;
    ll W;
    cin >>N >>W;
    vector<Item> V(N);
    Rep0(i, N)
        cin >>V.at(i).v >>V.at(i).w;
    int VMax=N*100;
    // DP table: Item# x Value holds Weight
    vector<vector<ll>> DP(N+1, vector<ll> (VMax+1, INF));
    DP.at(0).at(0)=0; // Case skipping Item #0
    DP.at(0).at(V.at(0).v)=V.at(0).w; // Case selecteing Item #0
    Rep1(i, N-1) { // From Item #1 to #N-1
        int vv=V.at(i).v;
        ll ww=V.at(i).w;
        Rep0(v1, VMax+1) { // For each availabe value for previous Item
            if (INF==DP.at(i-1).at(v1)) // Skip unavailable values
                continue;
            DP.at(i).at(v1)=min(DP.at(i).at(v1), DP.at(i-1).at(v1)); // Skip
            if (v1+vv<=VMax)
                DP.at(i).at(v1+vv)=min(DP.at(i).at(v1+vv), DP.at(i-1).at(v1)+ww); // Select
        }
    }
    // Search for the best
    int S=0;
    Rep0(v1, VMax+1)
        if (DP.at(N-1).at(v1)<=W)
            S=v1;
    cout <<S <<endl;
    return 0;
}


Measured memory_bytes: 10796
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
orlis=LI()
flis=orlis[:n]
smflis=[0 for i in range(n+1)]
x=sum(flis)
smflis[0]=x
heapify(flis)
for i in range(n):
    x+=orlis[n+i]
    heappush(flis,orlis[n+i])
    y=heappop(flis)
    x-=y
    smflis[i+1]=x
#print(smflis)
orlis=list(reversed(orlis))
llis=orlis[:n]
#print(llis)
for i in range(n):
    llis[i]*=(-1)
smllis=[0 for i in range(n+1)]
x=-sum(llis)
smllis[0]=x
#print(llis)
heapify(llis)
for i in range(n):
    x+=orlis[n+i]
    heappush(llis,-orlis[n+i])
    y=-heappop(llis)
    #print(-orlis[n+i])
    #print(y)
    x-=y
    smllis[i+1]=x
#print(smllis)
answers=[]
for i in range(n+1):
    j=n-i
    answers.append(smflis[i]-smllis[j])
print(max(answers))
    
    

    


Measured memory_bytes: 44988
#### import ####
import sys
import math
from collections import defaultdict

#### 設定 ####
sys.setrecursionlimit(10**7)
def input():
  return sys.stdin.readline()[:-1]

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
  read_all = [tuple(map(int, input().split())) for _ in range(N)]
  return map(list,zip(*read_all))

#################

def Z_algo(S):
  n=len(S)
  A=[0]*n
  A[0]=n
  i=1
  j=0
  while i<n:
    while i+j<n and S[j]==S[i+j]: j+=1
    A[i]=j
    if j==0:
      i+=1
      continue
    k=1
    while i+k<n and k+A[k]<j:
      A[i+k]=A[k]
      k+=1
    i+=k
    j-=k
  return A

def dfs(pt,v,visited):
  if visited[v]==True:
    return -1,visited
  S = [v]
  now = 0
  while S:
    v1 = S.pop()
    for i in pt[v1]:
      if i != v:
        visited[i] = True
        now += 1
        S.append(i)
      else:
        print(-1)
        exit()
  return now,visited

s = str(input())
t = str(input())

ls = len(s)
lt = len(t)

s2 = t + s*(lt//ls +2)
A = Z_algo(s2)

B = [False]*ls
for i in range(ls):
  if A[i+lt]>=lt:
    B[i]=True

pt = [[] for _ in range(ls)]
for i in range(ls):
  if B[i]==True:
    pt[i].append((i+lt)%ls)

visited = [False]*ls

ans = 0
for v in range(ls):
  if B[v]:
    tmp,visited = dfs(pt,v,visited)
    if tmp>ans:
      ans = tmp

print(ans)

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

int main(){
  int N  ;
   cin >> N ;
   vector<int> X(N);
   vector<int> Y(N);
    int count = 0 ;
    for(int i = 0 ; i < N ; i++){
     cin >> X.at(i) ;}
    for(int i = 0 ; i < N ; i++){
     cin >> Y.at(i) ;}
      
   for(int i = 0; i < N ; i++){
     if(X.at(i) > Y.at(i)){
     count = count + X.at(i) - Y.at(i) ; 
  }
   }
 cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define mod 998244353
using namespace std;
typedef pair<llint, llint> P;
typedef pair<P, llint> E;


llint L;
vector<E> vec;

int main(void)
{
	cin >> L;
	llint n = 20;
	
	for(int i = 1; i < n-1; i++){
		vec.push_back(E(P(n-i, n-i+1), 1<<(i-1)));
		vec.push_back(E(P(n-i, n-i+1), 0));
	}
	
	llint sum = 0;
	if(L & (1<<(n-1))){
		vec.push_back(E(P(1, 2), 1<<(n-2)));
		vec.push_back(E(P(1, 2), 0));
		sum += 1<<(n-1);
	}
	for(int i = n-2; i >= 0; i--){
		if(L & (1<<i)){
			vec.push_back(E(P(1, n-i), sum));
			sum += 1<<i;
		}
	}
	
	cout << n << " " << vec.size() << endl;
	for(int i = 0; i < vec.size(); i++){
		cout << vec[i].first.first << " " << vec[i].first.second << " " << vec[i].second << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
import sys
N = int(input())
A = list(map(int, input().split()))

kai = [False] * N
uri = [False] * N
# 買いポイント探す
i = 0


# すべて同じ株価or単調減少
tmp = A[0]
flag = True
for i in range(1, N):
    if A[i-1] < A[i]:
        flag = False

if flag:
    print(1000)
    sys.exit(0)

start = 10000
stop = 10000

for i in range(1, N):
    if A[i-1] < A[i] and stop != i-1:
        start = i-1
        stop = i
    elif A[i-1] < A[i] and stop == i-1:
        stop = i
    elif A[i-1] >= A[i] and start != 10000 and stop != 10000:
        kai[start] = True
        uri[stop] = True
        start = 10000
        stop = 10000
    if i == N-1 and start != 10000 and stop != 10000:
        kai[start] = True
        uri[stop] = True
cnt = 0
kingaku = 1000
for i in range(N):
    if kai[i]:
        cnt = kingaku // A[i]
        kingaku -= A[i] * cnt
    if uri[i]:
        kingaku += A[i] * cnt
        cnt = 0
    if i == N-1:
        kingaku += A[i] * cnt
print(kingaku)






Measured memory_bytes: 62060
#include<iostream>
#include<iomanip>
int n;
double ans,w1,w2;
int main(){
    std::cin>>n;
    w1=n/2;
    w2=n%2;
    if (w2==0){
        ans=0.5;
    }
    else{
        ans=(w1+1)/n;
    }
    std::cout<<std::setprecision(7)<<std::fixed<<ans;
    return 0;
}

Measured memory_bytes: 256
//Love and Freedom.
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#define ll long long
#define inf 20021225
#define N 300010
using namespace std;
int read()
{
	int s=0,t=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')	t=-1; ch=getchar();}
	while(ch>='0' && ch<='9')	s=s*10+ch-'0',ch=getchar();
	return s*t;
}
int a[N],n,pre[N];
bool check(int l,int r)
{
	int rb=0,lb=0;
	for(int i=l;i<=r;i++)
	{
		if(a[i]>i)
		{
			if(rb>a[i] || a[i]>r)	return 0;
			rb=a[i];
		}
		else if(a[i]<i)
		{
			if(lb>a[i] || a[i]<l)	return 0;
			lb=a[i];
		}
	}
	return 1;
}
int main()
{
	n=read(); int gg=0;
	for(int i=1;i<=n;i++)
	{
		a[i]=read();
		if(a[i]==i)	gg=0;
		else
		{
			gg++;
			if(gg==3)	return puts("No"),0;
		}
	}
	for(int i=1;i<=n;i++)
	{
		if(a[i]!=i)
		{
			int rem=i;
			while((a[i]==i)==((i-rem)&1)&&i<=n)	i++; i--;
			if(!check(rem,i))	return puts("No"),0;
		}
	}
	puts("Yes");
	return 0;
}


Measured memory_bytes: 1408
#include<stdio.h>

int main(void)
{
	int a, b;
	a = b = 0;
	scanf("%d", &a);
	scanf("%d", &b);
	if (a < b)
	{
		printf("a < b\n");
	}
	if (a == b)
	{
		printf("a == b\n");
	}
	if (a > b)
	{
		printf("a > b\n");
	}
	return 0;
}


Measured memory_bytes: 2040
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder.Contest.C
{
	static class Program
	{
		public static void Main(string[] args)
		{
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);

			var cin = new Scanner();

			int n = cin.NextInt();
			int k = cin.NextInt();
			var a = cin.ArrayInt(n);
			var b = new int[n];
            for (int i = 0; i < Math.Min(k, 100); i++)
            {
                for (int j = 0; j < n; j++)
                {
					b[j] = 0;
                }
				for (int j = 0; j < n; j++)
				{
					b[Math.Max(0, j - a[j])]++;
					if (j + a[j] + 1 < n) b[j + a[j] + 1]--;
                }
                for (int j = 1; j < n; j++)
                {
					b[j] += b[j - 1];
                }
                for (int j = 0; j < n; j++)
                {
					a[j] = b[j];
                }
            }
            Console.WriteLine(string.Join(" ", a));

			Console.Out.Flush();
		}
	}

	class Scanner
	{
		string[] s;
		int i;

		char[] cs = new char[] { ' ' };

		public Scanner()
		{
			s = new string[0];
			i = 0;
		}

		public string Next()
		{
			if (i < s.Length) return s[i++];
			string st = Console.ReadLine();
			while (st == "") st = Console.ReadLine();
			s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			if (s.Length == 0) return Next();
			i = 0;
			return s[i++];
		}

		public int NextInt()
		{
			return int.Parse(Next());
		}

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = NextInt() + add;
			}
			return Array;
		}

		public long NextLong()
		{
			return long.Parse(Next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = NextLong() + add;
			}
			return Array;
		}

		public double NextDouble()
		{
			return double.Parse(Next());
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = NextDouble() + add;
			}
			return Array;
		}
	}
}

Measured memory_bytes: 57920
#include <stdio.h>

int main(void)
{
	float a, b, c, d, e, f;
	float x, y;
	
	while (scanf("%f %f %f %f %f %f", &a, &b, &c, &d, &e, &f) != EOF){
		y = (c * d - a * f) / (b * d - a * e);
		x = (c - b * y) / a;
		
		printf("%.3f %.3f\n", x, y);
	}
	
	return (0);
}

Measured memory_bytes: 1076
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
class Pos {
public:
    int x, y;
    Pos(int x, int y) : x(x), y(y) {}
};

using Grid = vector<vector<char>>;
using Painting = vector<vector<bool>>;

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

void solve() {
    int H, W;
    cin >> H >> W;

    queue<Pos> q;
    Grid grid(H, vector<char>(W));
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            cin >> grid[i][j];
        }
    }
    Painting painting(H, vector<bool>(W, false));
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            if (grid[i][j] == '#') {
                for (int k = 0; k < 4; ++k) {
                    int nx = j + dx[k];
                    int ny = i + dy[k];
                    if (nx < 0 || W <= nx || ny < 0 || H <= ny) continue;
                    if (grid[ny][nx] == '#') continue;
                    if (painting[ny][nx] == true) continue;
                    painting[ny][nx] = true;
                    Pos next_k = Pos {nx, ny};
                    q.push(next_k);
                }
            }
        }
    }
    queue<queue<Pos>> group_q;
    if (0 < q.size()) group_q.push(q);
    int ans = 0;
    while (!group_q.empty()) {
        queue<Pos> pos_q = group_q.front();
        group_q.pop();
        queue<Pos> next_pos_q;
        while (!pos_q.empty()) {
            Pos pos = pos_q.front();
            pos_q.pop();
            grid[pos.y][pos.x] = '#';
            for (int i = 0; i < 4; ++i) {
                int nx = pos.x + dx[i];
                int ny = pos.y + dy[i];
                if (nx < 0 || W <= nx || ny < 0 || H <= ny) continue;
                if (grid[ny][nx] == '#') continue;
                if (painting[ny][nx] == true) continue;
                painting[ny][nx] = true;
                Pos next_i = Pos {nx, ny};
                next_pos_q.push(next_i);
            }
        }
        if (0 < next_pos_q.size()) group_q.push(next_pos_q);
        ans++;
    }
    cout << ans << endl;
}

int main() {
    solve();
    return 0;
}


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

#define ll long long int
#define endl '\n'

void testCase()
{
    //ll t; cin>>t; while(t--)
    {
        string s;
        cin>>s;
        ll n=s.length();
        
        if(s[n-1]!='s')
        {
            cout<<s<<"s";
        }
        
        else
        {
           
            cout<<s<<"es";
        }
    }   
}

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

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<char> vchar;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef priority_queue<long long> prque;
#define ain(i,n,a) for(long long i=0;i<(long long)(n);i++){cin>>a[i];}
#define aout(i,n,a) for(long long i=0;i<(long long)(n);i++){cout<<a[i]<<endl;}
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define vsort(v) sort((v).begin(), (v).end())
#define vrsort(v) sort((v).rbegin(), (v).rend())
#define vreverse(v) reverse((v).begin(), (v).end())
#define pb(a) push_back(a)
#define INF 2000000009
#define MOD 1000000007
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  //input
  ll n,m;cin>>n>>m;pair<ll,ll> edg[m];
  rep(i,m){cin>>edg[i].first>>edg[i].second;edg[i].first--;edg[i].second--;}
  //caricurate
  struct UnionFind {
    vector<ll> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    vector <ll> siz;
    UnionFind(ll N) : par(N),siz(N,1LL) { //最初は全てが根であるとして初期化
        for(ll i = 0; i < N; i++) par[i] = i;
    }

    ll root(ll x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(ll x, ll y) { // xとyの木を併合
        ll rx = root(x); //xの根をrx
        ll ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        if (siz[ry] < siz[rx]) swap(ry, rx);
        siz[ry]+=siz[rx];
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(ll x, ll y) { // 2つのデータx, yが属する木が同じならtrueを返す
        ll rx = root(x);
        ll ry = root(y);
        return rx == ry;
    }
    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};
  vll ans(m);ans[m-1]=n*(n-1)/2;
  UnionFind tree(n);
  for(ll i=m-1;i>0;i--){
    if(tree.same(edg[i].first,edg[i].second)){
      ans[i-1]=ans[i];continue;
    }
    ll a,b;a=tree.size(edg[i].first);b=tree.size(edg[i].second);
    tree.unite(edg[i].first,edg[i].second);
    ans[i-1]=ans[i]-a*b;
  }
  //output
  aout(i,m,ans);
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
const int INF=1e9;
ll gcd(ll a,ll b){
      if(b==0)return a;
      return gcd(b,a%b);
}
ll lcm(ll a,ll b){
      return a/gcd(a,b)*b;
}
int main(){
      ll n,d[10],v[10];
      while(cin>>n&&n){
            REP(i,n){
                  cin>>d[i]>>v[i];
                  ll a=gcd(d[i],v[i]);
                  v[i]/=a;d[i]/=a;
            }
            ll c=1;
            REP(i,n)c=lcm(c,d[i]);
            REP(i,n)v[i]*=(c/d[i]);
            ll ans=v[0];
            REP(i,n)ans=gcd(ans,v[i]);
            REP(i,n)cout<<v[i]/ans<<endl;
      }
}

Measured memory_bytes: 1156
//In the name of ALLAH
#include <bits/stdc++.h>
using namespace std;

#define int int64_t


int32_t main() {
	int n,x,y=0,ans=0;
	cin>>n;
	for(int i=0;i<n;i++) {
		cin>>x;
		if(x-1==y)
			y=x;
		else
			ans++;
	}
	if(ans==n)
		cout<<"-1\n";
	else
		cout<<ans<<endl;
}

Measured memory_bytes: 256
I, O, T, J, L, S, Z = map(int, input().split())
length = O*2 + (I//2)*4 + (J//2)*4 + (L//2)*4
if I and J and L:
  length = max(length, 6 + O*2 + ((I-1)//2)*4 + ((J-1)//2)*4 + ((L-1)//2)*4)
print(length//2)

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

int main() {
  int N, T, A; cin >> N >> T >> A;
  int dif, res, min = 1000000000;
  for (int i=1; i<=N; i++) {
    int H; cin >> H;
    dif = 1000*T - 6*H - 1000*A;
    if (dif < 0) dif = -dif;
    if (min > dif) {
      min = dif;
      res = i;
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 256
import itertools

N=int(input())
P=tuple(list(map(int, input().split())))
Q=tuple(list(map(int, input().split())))

l=[]
k=1

for i in range(N):
    l.append(k)
    k=k+1


m=[]    
for v in itertools.permutations(l, N):
    m.append(v)
m.sort()
a=m.index(P)
b=m.index(Q)

print(abs(a-b))

Measured memory_bytes: 8052
#include<bits/stdc++.h> 
using namespace std;
int main() { 
	unsigned long long N, divisor = 0, A;
	cin >> N; 
	A = N;
	while (A) {
		divisor += (A % 10);
		A /= 10;
	}
	cout << (N % divisor == 0 ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string n;
	cin>>n;
	puta(string(n.size(),'x'));
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int m,n,ans=0,ok=0;
char a[55][55],b[55][55];
int main(){
	scanf("%d %d ",&m,&n);

	for(int i=0;i<m;i++){
		scanf("%s",a[i]);
	}
	for(int i=0;i<n;i++){
		scanf("%s",b[i]);
	}

	for(int i=0;ok==0&&i<=m-n;i++){
		for(int j=0;ok==0&&j<=m-n;j++){//判定区域的左上角
			ans=1;
			for(int i1=0;i1<n;i1++){
				for(int j1=0;j1<n;j1++){
					if(!(a[i+i1][j+j1]==b[i1][j1]))
						ans=0;
				}
			}

			if(ans==1){
				printf("Yes");
				ok=1;
				break;
			}
		}
	}
	if(ans==0)printf("No");

}


Measured memory_bytes: 128
// #include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;

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

int main() {
    int x, y;
    cin >> x >> y;

    if (y%2==0 && 2*x <= y && y <= 4*x) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3592
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long LL;
typedef pair<int, int> PI;
typedef vector<int> VI;
const LL MOD = 1000000007LL;
LL Pow[401][401]; //i^j
LL Sum[401][401]; //Σx^iをx=0~jまで足し合わせる
int A[400];
int B[400];
int N, C;
LL memo[400][401];
LL f(int k, int c) {
	if (k == N) return c == 0;
	if (memo[k][c] != -1) return memo[k][c];
	LL sum = 0;
	rep(i, c + 1) {
		LL add = (Sum[i][B[k]] - Sum[i][A[k] - 1] + MOD) % MOD;
		add = (add * f(k + 1, c - i)) % MOD;
		sum = (sum + add) % MOD;
	}
	return memo[k][c] = sum;
}
int main() {
	rep(i, 401) {
		Pow[i][0] = 1;
		REP(j, 1, 401) {
			Pow[i][j] = (Pow[i][j - 1] * i) % MOD;
		}
	}
	rep(i, 401) {
		Sum[i][0] = Pow[0][i];
		REP(j, 1, 401) {
			Sum[i][j] = (Sum[i][j - 1] + Pow[j][i]) % MOD;
		}
	}
	cin >> N >> C;
	rep(i, N) {
		cin >> A[i];
	}
	rep(i, N) {
		cin >> B[i];
	}
	memset(memo, -1, sizeof(memo));
	cout << f(0, C) << endl;
}

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

int main()
{
    int a, b, d, r;
    double f;
    cin >> a >> b;
    d = a / b;
    r = a % b;
    f = double(a) / double(b);
    cout << d << " " << r << " "  << fixed << setprecision(5) << f << endl;
    return 0;
}



Measured memory_bytes: 3284
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7


n, m = rm()
a = [rr() for _ in range(n)]
b = [rr() for _ in range(m)] 
for i in range(n-m+1):
    for j in range(n-m+1):
        c = [s[j:j+m] for s in a[i:i+m]]
        if c == b:
            print('Yes')
            exit()
print('No')





Measured memory_bytes: 27220
import sys
from math import factorial


sys.setrecursionlimit(500000)
N, M = map(int, input().split())
MOD = 10**9 + 7
diff = abs(N - M)


if diff == 0:
    ans = (factorial(N) * factorial(M)) * 2
elif diff == 1:
    ans = factorial(N) * factorial(M)
else:
    ans = 0


ans %= MOD
print(ans)

Measured memory_bytes: 5176
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007

int n, k, ans = LLONG_MAX;
int a[100005];
signed main(){
	cin >> n >> k;
	for(int i = 1 ; i <= n ; i ++)
		cin >> a[i];
	sort(a + 1, a + n + 1);
	for(int i = 1 ; i + k - 1 <= n ; i ++)
		ans = min(ans, a[i + k - 1] - a[i]);
	cout << ans;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<fstream>
#include<algorithm>
#include<utility>
using namespace std;
using ll = long long;


int main(){
    ll n,k,q;
    cin >> n >> k >> q;
    vector<ll> point(n);
    for(ll i=0;i<n;i++) point[i] = 0;
    for(ll i=0;i<q;i++){
        ll x;
        cin >> x;
        point[x-1]++;
    }
    for(ll i=0;i<n;i++){
        if(k<=(q-point[i])) cout << "No" << endl;
        else    cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 1408
#include<algorithm>
#include<iostream>
using namespace std;
int dp[6100];
pair <int,int> a[3100];
int n,t,maxn;
int main()
{
	cin>>n>>t;
	for(int i=1;i<=n;i++)
	cin>>a[i].first>>a[i].second;
    sort(a+1,a+n+1);
    for(int i=1;i<=n;i++)
    for(int j=t-1;j>=0;j--)
    dp[j+a[i].first]=max(dp[j+a[i].first],dp[j]+a[i].second),
	maxn=max(maxn,dp[j+a[i].first]);
    cout<<maxn;
    return 0;
}

Measured memory_bytes: 256
// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>

// container library
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

// namespace
using namespace std;

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VB> VVB;

// conversion
#define INT(c) static_cast<int>(c)
#define CHAR(n) static_cast<char>(n)
#define LL(n) static_cast<ll>(n)

// container
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define SORT(c) sort((c).begin(), (c).end())
#define GSORT(c) sort((c).begin(), (c).end(), greater<decltype((c).front())>())
#define SZ(x) (INT((x).size()))
#define MEMSET(c, v) memset((c), v, sizeof(c))

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define NREP(i, n) FOR(i, 1, n + 1)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// constant
// const ll MOD = 1e9 + 7;
// const int INF = 1<<25;
// const ll INF = 1LL<<50;
// const int dx[4] = {0, -1, 1, 0};
// const int dy[4] = {-1, 0, 0, 1};
// const int dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const int dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};

// debug
#define test(x) cout << #x << " = " << x << endl

// answer output
#define Yes(c) cout << ((c) ? "Yes" : "No") << endl;
#define YES(c) cout << ((c) ? "YES" : "NO") << endl;
#define yes(c) cout << ((c) ? "yes" : "no") << endl;

#define possible(c) cout << ((c) ? "possible" : "impossible") << endl;
#define POSSIBLE(c) cout << ((c) ? "POSSIBLE" : "INPOSSIBLE") << endl;


// --------------------------------------------------------


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

  int A, B;
  cin >> A >> B;
  cout << (A + B) % 24 << endl;
  return 0;
}

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

using namespace std;

typedef long long int ll;

const int N = 1e5 + 5;

vector < int > prefs(N), preft(N);

int sums (int l, int r) {
  if (l == 0) return prefs[r];
  return prefs[r] - prefs[l - 1];
}

int sumt (int l, int r) {
  if (l == 0) return preft[r];
  return preft[r] - preft[l - 1];
}

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

  string s, t;
  int q;
  cin >> s >> t >> q;

  prefs[0] = s[0] - 'A' + 1;
  for (int i = 1; i < s.length(); i++) {
    prefs[i] = prefs[i - 1] + (s[i] - 'A' + 1);
  }
  preft[0] = t[0] - 'A' + 1;
  for (int i = 1; i < t.length(); i++) {
    preft[i] = preft[i - 1] + (t[i] - 'A' + 1);
  }

  while (q--) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (sums(a - 1, b - 1) % 3 == sumt(c - 1, d - 1) % 3) {
      cout << "YES\n";
    } else {
      cout << "NO\n";
    }
  }
}


Measured memory_bytes: 1744
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,y,z=0,min=10000000;
  cin>>n;
  int x[n];
  for(int i=0;i<n;i++){
    cin>>x[i];
  }
  sort(x,x+n);
  y=x[0];
  for(int i=0;i<x[n-1]-x[0]+1;i++){
    for(int j=0;j<n;j++){
      z+=(x[j]-y)*(x[j]-y);
    }
    if(min>z){
      min=z;
      z=0;
    }
    y++;
  }
  cout<<min;
  return 0;
}

Measured memory_bytes: 256
import sys
import numpy as np
sys.setrecursionlimit(20000000)
input = sys.stdin.readline
n = int(input())
dp = [[[[0]*4 for i in range(4)] for j in range(4)] for k in range(n+1)]
dp[0][0][0][0] = 1
mod = 10**9+7
en = ["A","G","C","T"]
def han(mozi):
        if mozi.find("AGC") != -1:
                return 1
        mozi2 = mozi[1] + mozi[0] + mozi[2:]
        if mozi2.find("AGC") != -1:
                return 1    
        mozi3 = mozi[0] + mozi[2] + mozi[1] + mozi[3]
        if mozi3.find("AGC") != -1:
                return 1    
        mozi4 = mozi[0] + mozi[1] + mozi[3] + mozi[2]
        if mozi4.find("AGC") != -1:
                return 1             
        return 0
for i in range(n):
        for j in range(4):
                for k in range(4):
                        for l in range(4):
                                for o in range(4):
                                        if i== 2:
                                                if o == 0 and j ==1 and k == 2:
                                                        continue
                                                if o == 0 and j ==2 and k == 1:
                                                        continue
                                                if o == 1 and j ==0 and k == 2:
                                                        continue
                                                dp[i+1][o][j][k] += dp[i][j][k][l]
                                        elif i < 2:
                                                dp[i+1][o][j][k] += dp[i][j][k][l]
                                        else:
                                                mozi = en[o] + en[j] + en[k]+ en[l]
                                                if han(mozi):
                                                        continue
                                                dp[i+1][o][j][k] += dp[i][j][k][l]
                                                dp[i+1][o][j][k] %= mod
print(np.sum(np.array(dp[n]))%mod)

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


int main()
{
    int n, m, k; cin >> n >> m >> k;
    long an[200001], am[200001];
    an[0] = 0; am[0] = 0;
    for(int i = 1; i <= n; i++)
    {
        int nn;
        cin >> nn;
        an[i] = an[ i - 1 ] + nn;
        //cout << an[i] << " ";
    }
    //cout << endl;
    for(int i = 1; i <= m; i++)
    {
        int nm;
        cin >> nm;
        am[i] = am[ i - 1 ] + nm;
        //cout << am[i] << " ";
    }
    //cout << endl;
    int max{0};
    int bestj = m;
    for(int i = 0; i <= n; i++)
    {
        int sum{0}, result{0};
        /*
        for(int j = 0; j < i; j++)
        {
            sum += an[j+1];
        }
        */
        if(an[i] > k)
            break;
        result += i;
        
        for(int j = bestj; j > 0; j--)
        {
            if(am[j] + an[i] <= k)
            {
                bestj = j;
                result += j;
                //cout << result << " " << am[j] << endl;
                break;
            }
            //cout << result << endl;
        }
        //cout << "result: " << result << " sum: " << sum << endl;
        /*
        for(int j = 0; j < m; j++)
        {
            if(sum + am[j+1] <= k)
            {
                sum += am[j+1];
                result++;
            }
            else
                break;
            
        }
        */
        //cout << result << endl;
        if(result > max)
            max = result;
    }
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 6704
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    int N;R(N);
    FOR(i,1,9)FOR(j,1,9){
        if(i*j==N){
            W("Yes");
            return 0;
        }
    }
    W("No");
    return 0;
}


Measured memory_bytes: 256